Single-chip encoder for optical routers: packet switching, burst switching and WDM-OCDMA transmission