## 2 MUI Cancellation Algorithm of the Proposed SAC Receiver
Similar to the upper structure of the AWG decoder, the port selections are based on the chip positions of \"1s\" in \(\mathbf{C_{1}}\). Then, \(\mathbf{C_{1}}d_{1}\) is removed from \(\mathbf{R_{1}}\) by optical subtraction to complete the MUI elimination at the 1 st stage. To decode \(d_{2}\), \(\mathbf{R_{2}}\) is propagated back to the AWG decoder via a fiber loop. An electrical controller changes the previous setting of path connection and sets up a new link to the 2 nd input of the AWG. To generate \(\mathbf{C_{2}}d_{2}\), the optical signal from the EOM enters the 2 nd input port of the AWG encoder. Due to the cyclic-shift property of M-sequence codes and the AWG [30], \(\mathbf{C_{i}}\) can be decoded by transmitting \(\mathbf{R_{i}}\) to the \(i\)th input port of AWG decoder. Similarly, \(\mathbf{C_{i}}\) is generated by sending the light source  
Figure 4: Receiver architecture designed with recursive interference cancellation (RIC). Figure 3: Passive optical network (PON) topology based on OCDMA for downstream communications. OLT: optical line terminal; ONU: optical network unit. to the \(i\)th input port of AWG encoder. During the whole processes of MUI elimination, only the input connections of AWGs are adjusted by the electrical controller, while the output connections remain fixed. As the signals repeatedly propagate in a single receiver, this scheme is called recursive interference cancellation (RIC). RIC has the potential to solve the latency of signal processing in the electrical components, since it is executed in the optical domain. As for the limitation of the proposed AWG-based receiver, it is suitable for decoding the OCDMA codes with cyclic-shift property, and the code length must match the AWG port number. Furthermore, for a conventional balanced detector, the received optical signal is directly down-converted to the electrical domain. RIC executes optical-electrical (O/E) and electrical-optical (E/O) conversions to identify the interference bit and re-generate the similar interference term at each stage. Employing an additional BLS in the receiver increases the network complexity and power consumption. Therefore, RIC removes the network MUI at the cost of moderate receiver complexity. Figure 5 shows the decoding/encoding process of M-sequence code \(\mathbf{C_{1}}\). In the AWG decoder in Figure 5a, wavelength components of \(\lambda_{1}\), \(\lambda_{2}\), \(\lambda_{3}\), and \(\lambda_{6}\) appearing at the 1 st, 2 nd, 3 rd, and 6 th output port are obtained by linking \(\mathbf{R_{1}}\) to the 1 st input port. These components are collected at the upper branch to form an aggregated signal \(\{2\lambda_{1},3\lambda_{2},2\lambda_{3},\lambda_{6}\}\), which can be used for calculating \(\mathbf{R_{1}}\odot\mathbf{C_{1}}\) by summing the power on each wavelength (\(2+3+2+1=8\)). The wavelength signals shown at the lower branch \(\{\lambda_{4},\lambda_{5},2\lambda_{7}\}\) are used for calculating \(\mathbf{R_{1}}\odot\overline{\mathbf{C_{1}}}\) by summing their powers (\(1+1+2=4\)). Figure 5b shows the AWG encoder designed for generating M-sequence codes. The spectrum of BLS is de-multiplexed into seven wavelengths. Signals of \(\lambda_{1}\), \(\lambda_{2}\), \(\lambda_{3}\), and \(\lambda_{6}\) at the AWG output ports are bound together to obtain \(\mathbf{C_{1}}=\{1,1,1,0,0,1,0\}\). Similarly, we can also calculate \(\mathbf{R_{2}}\odot\overline{\mathbf{C_{2}}}\) by connecting \(\mathbf{R_{2}}\) to the 2 nd input port of the AWG decoder, as shown in Figure 6a. Figure 6b shows the encoding process of \(\mathbf{C_{2}}\) executed by switching the BLS spectrum to the 2 nd input of the AWG encoder. Based on Figures 5 and 6, seven M-sequences codes can be recognized/produced in a single device. Figure 5: Spectral distributions of M-sequence code \(\mathbf{C_{1}}\) in the process of (**a**) decoding and (**b**) encoding, based on array waveguide grating (AWG) structure. Next, we examine the effectiveness of the proposed system by conducting computer simulation using OptiSystem 7.0.