# Optical Code Construction of 2D Spectral/Spatial BIBD Codes for SAC-OCDMA Systems
## 4 2D-BIBD System Performance Analysis  
The Gaussian approximation is applied to evaluate the 2D-BIBD code performance of the SAC based OCDMA system. PIN shot noise and thermal noise were considered in our analysis. We performed the study by referring to BER and with the help of varying different performance parameters such as received power, the number of users, etc. To measure the required signal to noise ratio (SNR), the photocurrent noise can be represented as:  
\[\left\langle i_{noise}^{2}\right\rangle=\ \left\langle i_{PIN}^{2}\right\rangle+\ \left\langle i_{shot}^{2}\right\rangle+\ \left\langle i_{thermal}^{2}\right\rangle \tag{10}\]  
where, \(i_{shot}^{2}\), \(i_{PIN}^{2}\), and \(i_{thermal}^{2}\) represent shot noise, phase induced intensity, and thermal noise originated at the receiving end, respectively. Therefore, Equation (10) can be rewritten as:  
\[\left\langle i_{\text{noise}}^{2}\right\rangle=I_{rec}^{2}B_{rec}\tau_{rec}+2 eI_{Total}B_{rec}+\frac{4K_{b}T_{n}B}{R_{N}} \tag{11}\]  
where, \(I_{rec}\) and \(I_{Total}\) represent the average of total photocurrents, respectively. \(\tau_{rec}\) and \(B_{rec}\) represent the coherence time of incident light on the photodiode and the receiver electrical bandwidth, respectively. Further \(K_{b}\), \(R_{N}\), \(T_{n}\), and \(e\) represent [PERSON]'s constant, the load resistance, the absolute temperature, and the electron's charge, respectively. Here, \(\tau_{rec}\) can be written as  
\[\tau_{rec}=\frac{\int_{0}^{\infty}G^{2}\ (v)dv}{\left[\int_{0}^{\infty}G\ (v)dv \right]^{2}} \tag{12}\]  
where \(r(v)\) denotes the single sideband source power spectral density (PSD) for the receiving end's optical signals. Thus, PSD can be represented as:  
\[r(v)=\frac{P_{sr}}{w_{2}\Delta v}\sum_{k=0}^{K-1}d(k)\sum_{i=0}^{L_{2}-1}\sum _{j=0}^{L_{1}-1}c_{1j}(k)u(v,i)dv \tag{13}\]  
where \(P_{sr}\) represents the effective transmitter power at the photodiode. \(w_{1}\) and \(w_{2}\) are the code weights of the 2D-BIBD code, and \(K\) is the number of simultaneous users. The user data bit is denoted by \(d(k)\). \(L_{1}\) and \(L_{2}\), respectively, represent lengths of the spatial and spectral codes. \(C_{i,j}(k)\) denotes the \(k^{th}\) user element code word. \(\phi(v,i)\) is defined as follows:  
\[\phi(v,i)=\left\{u\bigg{[}v-v_{0}-\frac{\Delta v}{2L_{1}}(-L_{1}+2i-2)\bigg{]} -u\bigg{[}v-v_{0}-\frac{\Delta v}{2L_{1}}(-L_{1}+2i)\bigg{]}\right\} \tag{14}\]  
where \(u(v)\) shows the unit step function and is expressed as:  
\[u(v)=\left\{ \begin{array}{ll}1,&v\geq 0\\ 0,&v<0\end{array} \right. \tag{15}\]Optical signals PSDs at PDs 0-1 at the receiving end can be obtained using the cross-correlation between \(C^{(d)}\) and \(C_{g,h}\). This can be expressed as:  
\[G_{0}(\
u)=\frac{P_{sr}}{w_{2}\Delta\
u}\sum\limits_{k=0}^{K-1}d(k)\sum\limits _{i=0}^{L_{2}-1}\sum\limits_{j=0}^{L_{1}-1}c_{i,j}^{(0)}c_{I,j}(k)u(\
u,i) \tag{16}\]  
\[G_{1}(\
u)=\frac{P_{sr}}{(w_{1}-1)w_{2}\Delta\
u}\sum\limits_{k=0}^{K-1}d(k) \sum\limits_{i=0}^{L_{2}-1}\sum\limits_{j=0}^{L_{1}-1}c_{i,j}^{(2)}c_{I,j}(k)u( \
u,i) \tag{17}\]  
For worst-case analysis, the first step is to set \(d(k)\) = 1 and output currents (\(I_{PD_{0}}-I_{PD_{1}}\)) obtained using \(G_{0}(\
u)\) and \(G_{1}(\
u)\). This can be expressed as follows. First photodiode (PD\({}_{0}\)):  
\[ \begin{split} I_{PD_{0}}=\mathcal{R}\int\limits_{0}^{\infty}G_{ 0}(\
u)dv=\frac{\mathcal{R}P_{sr}}{w_{2}\Delta\
u}\int\limits_{0}^{\infty} \sum\limits_{k=0}^{K-1}d(k)\sum\limits_{i=0}^{L_{2}-1}\sum\limits_{j=0}^{L_{ 1}-1}c_{i,j}^{(0)}c_{\text{I}j}(k)u(\
u,i)\\ =\frac{\mathcal{R}P_{sr}}{w_{2}L_{1}}\Big{[}w_{2}w_{1}+w_{2}\frac {(K-1)(L_{2}-1)}{L_{2}L_{1}-1}\Big{]}\end{split}  \tag{18}\]  
Second photodiode (PD\({}_{1}\)):  
\[