# Optical Code Construction of 2D Spectral/Spatial BIBD Codes for SAC-OCDMA Systems
## 3 2D-BIBD System Description
### Construction of 2D-BIBD Receiver Architecture  
The receiver module of 2D-BIBD OCDMA system consists of multiple star couplers, optical combiners, two balanced detectors followed by a low-pass Bessel filter section, an optical adder, and an integrator to implement the desired decision (Figure 2). Further, each balanced detector section is composed of two photodiodes (PD0-PD2 and PD1-PD3) connected in a balanced mode. Spatial decoding is performed by the combination of \(k_{pd}\) optical switches and two optical power combiners. FBG filters are used for the spectral decoding operation. Additonnally, the optical combiner combines the optical signals obtained by the star couplers i.e., it connects consistent star couplers with a balanced detector. The selection of the star coupler depends on the location of binary 1s in the \(Y\)th code sequence.  
Upper and lower optical combiners receive and combine the signals from the multiple star couplers. The optical combiner at the upper side combines the star couplers' signals, which are matched to the spatial code pattern \(Y_{g}^{T}\) (1s of the spatial code pattern). Whereas, the lower optical combiner is used to receive and mix the signals from the consistent star couplers, which are further matched to the complementary spatial code pattern \(\overline{Y^{T}}_{g}\) (1s of the spatial code pattern).  
There are four sets of FBGs, two attenuators, two PIN diodes, and four circulators. FBG#1 and FBG#8 have equal number of gratings. FBG#2 and FBG#4 which are structured according to the spectral code pattern \(X_{h}\), are used to extract the spectral components, which are matched with the 1s of the \(X_{h}\).  
FBG#1 and FBG#3 have the same number of gratings as FBG#2 and FBG#4. The configurations of FBG#2 and FBG#4 are set totally reverse to that of FBG#1 and FBG#3 to compensate for the round-trip delay. In the same way, FBG#6 and FBG#8 are constructed consistent with the complementary spectral code sequence \(\overline{X}_{h}\). Their combination is used to extract the spectral components, which correspond to the \"1s\" of the additional spectral code sequence \(\overline{X}_{h}\). (FBG#5 and FBG#7) and (FBG#6 and FBG#8) have the same gratings, except that the arrangements are totally reverse to compensate for the round-trip delays of signals [9; 16].  
Both balanced detectors operations are similar except for the attenuation values. In this case, the spectral components which are matched with FBG#2 are transmitted to FBG#1 and a delay line. The function of the delay line is to compensate for the delay caused by FBG#5 and FBG#6. After this, optical pulses are sent to photo diode PD0. In the same way, the spectral components matched with FBG#6 are further sent to FBG#5 and an optical attenuator (value set to \([1/(w_{1}-1)]\)) which is derived from the SNR expression analysis of the proposed 2D-BIBD code. Next, optical pulses are sent to PD2.  
Figure 2: Receiver structure of the 2D-BIBD OCDMA system.  
In the BD2 operation, the spectral components matched to FBG#4 are sent to FBG#3, through an attenuator and a delay line, which compensates for the delay caused by FBG#8 and FBG#7. In this case, the attenuator value is set to \([1/(w_{1}-1)]\). The optical pulses are sent to PD1. Similarly, spectral components which are matched to FBG#8 are further sent to FBG#7 and an optical attenuator (value set to \([1/(w_{1}-1)]\)).  
During the whole process, only those signal components which are matched to the spatial and spectral code patterns of the receiver reach PD0. Spectrally decoded data has been converted into electrical output using PD0 and PD2. These two output currents are combined and passed to the integrator and the low pass filtering operation. The difference in outputs of PD0 and PD2 and PD1 and PD3 are \(R^{(0)}(g,h)\) and \(R^{(2)}(g,h)/(w_{1}-1)\), respectively, and provide complete elimination of multiuser interference (Equation (9)).