# Two-Dimensional Permutation Vectors' (PV) Code for Optical Code Division Multiple Access Systems
## 2 The 2D Wavelength-Hopping/Time-Spreading System
### W-T Two-Dimensional PV Approach  
The obtained 2D W-T OCDMA codes were generated either by using a mathematical approach or by extension of an existing one-dimensional code. In the proposed work, 2D W-T PV codes were obtained by using one-dimensional PV codes for both wavelength-hopping and time-spreading. The new codes can be constructed as follows.  
First, we construct \(M\) groups of PV codes as follows where \(M\) is ranging between 1 and \(PV_{pos}\).  
\[PV=\{G_{1},G_{2},G_{3},.........G_{M}\}, \tag{7}\]  
where \(G_{i}\) is 1D-PV code constructed based on the vector space \(\mathbb{R}^{\text{ }k}\) and an arbitrary permutation vector (_Permi_), so that:  
\[G_{i}=\mathbb{R}^{k1}[.,Permi]=\{C_{i1},C_{i2},C_{i3},......C_{ik}\},\]  
where, \(C_{ij}\) is a 1D-PV code where \(i\in[1,\ M]\) and \(j\in[1,\ K]\) and \(K\) is the number of generated codes in the group. Hence \(C_{ij}\) is an arbitrary code in \(G_{i}\). The 2D W-T PV codes can be constructed by selecting \(G_{i}\) to generate \(L\) time slots. Each \(C_{ij}\) will be used as time-spreading patterns to determine the positions of the wavelengths. For the wavelength-hopping patterns, another 1D-PV code group was used \(G_{d}\), where \(d\
eq i\). Hence, the wavelength-hopping patterns form the wavelength's index. Between two selected groups (\(G_{i}\) and \(G_{d}\)), the total number of served users = K\({}^{2}\). Therefore, the 2D W-T PV codes' generation equation was defined as:  
\[A_{d,i}=G_{d}^{T}G_{i}=\left(\begin{array}{cccc}C_{d1}C_{i1}&\cdots&C_{d1}C _{ik}\\ \vdots&\ddots&\vdots\\ C_{dk}C_{i1}&\cdots&C_{dk}C_{ik}\end{array}\right). \tag{8}\]Each element in \(A_{d,i}\) is a square matrix (\(L\times L\)), where \(L\) represents the number of available wavelengths and the number of time slots. The 2D W-T PV codes matrices were obtained by associating the rows with wavelengths and the columns with time slots. For example, choose i = 1 and d = 2 (group 1 and group 2 from Table 1). Then the code matrix \(C_{21}C_{11}\) is represented as follows.  
\[C_{21}C_{11}=\begin{pmatrix}0&0&0&0&0&0&\boxplus&0\\ 0&0&0&0&0&0&0&0\\ 0&0&\boxplus&0&0&0&0&0\\ 0&0&0&0&0&0&\boxplus&0\\ 0&0&0&0&0&0&0\\ 0&0&\boxplus&0&0&0&0&0\\ 0&0&0&0&0&0&0\\ 0&0&0&0&0&0&0\end{pmatrix}\]  
As shown in Figures 2 and 3, the 2D W-T PV generated codes were differentiated with either the wavelength's hopping or the time spreading.  
For example, from Figure 2, it is clear that the codes \(C_{21}C_{11}\) (pink colored) and \(C_{21}C_{12}\) (blue colored) shared the same spectral signature (\(\lambda_{3}\), \(\lambda_{5}\)) but transmitted them at different time slots (t3, t7) and (t5,t6), respectively. Furthermore, when two codes used the same time slots, like \(C_{21}C_{12}\) and \(C_{22}C_{12}\) (green colored), they sent different wavelengths, (\(\lambda_{3}\), \(\lambda_{5}\)) for \(C_{21}C_{12}\) and (\(\lambda_{6}\), \(\lambda_{8}\)) for \(C_{22}C_{12}\), thus maintaining a zero cross-correlation.  
Figure 3 shows a 3-dimensional (3D) graphic representation of two 2D W-T PV code sequences, which represent either time spreading or wavelength hopping. It is clear that user#5 and user#6 shared the same spectral signature with spreading at different time slots.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \(G_{1}\) & \(G_{2}\) & \(G_{3}\) & \(G_{4}\) & \(\ldots\) & \(G_{28}\) \\ \hline
**[00100010]** & [00101000] & [00101000] & [001001000] & [000100100] & \(\ldots\) & [00100100] \\
**[00001100]** & [0000010] & [10000100] & [000100010] & \(\ldots\) & [001000010] \\
**[0100000]** & [01010000] & [00100100] & [10000100] & \(\ldots\) & [10001000] \\ \hline \end{tabular}
\end{table}
Table 1: 1-dimensional-PV codes generated with code weight (w) = 2 and number of generated codes (K) = 4.