# Area-Efficient Universal Code Generator for GPS L1C and BDS B1C Signals
## 2 Background
### Legendre Sequence-Based PRN Code Generation  
To enable receivers to distinguish satellite signals, each satellite transmits signals with individual PRN codes, such as \(C_{data}(t)\) and \(C_{pilot}(t)\), shown in Equation (2). The PRN codes are divided according to the configurations into plain codes consisting of only primary codes and tiered codes in which primary codes and secondary codes are combined.  
The generation method is the same for both primary codes and secondary codes. Firstly, a Legendre sequence is generated; next, a Weil sequence is configured based on the Legendre sequence, and a primary code or a secondary code is generated through the post-processing of the Weil sequence. In the case of a plain code, the primary code becomes the final PRN code, and, in the case of a tiered code, the final PRN code is determined by the combination of the primary code and the secondary code.  
To examine the foregoing in terms of formulas, first, a Legendre sequence, the length of which is \(N_{L}\), is defined as shown in Equation (3).  
\[L(k)=\left\{\begin{array}{c}0,\,k=0\\ 1,\,k\
eq 0\,and\,k=x^{2}\text{mod}N_{L}(\text{integer}\,x)\\ 0,\,else\end{array}\right. \tag{3}\]  
where \(k\) is the index of Legendre sequence for \((0\leq k<N_{L})\). Then, a Weil sequence, of which the length is \(N_{W}\), is calculated through the modulo-2 addition operation of two Legendre sequences with a phase difference as shown in Equation (4).  
\[W(k;w)=L(k)\oplus L(k+\omega) \tag{4}\]  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Signal Property** & **GPS L1C** & **BDS B1C** \\ \hline Frequency (MHz) & 1575.42 (L1) & 1575.42 (L1) \\ Modulation & TMBOC & QMBOC \\ Data code (\(C_{data}\)) & Plain code & Plain code \\ Pilot code (\(C_{pilot}\)) & Tiered code & Tiered code \\ Code rate (Mcps) & 1.023 & 1.023 \\ \hline \hline \end{tabular}
\end{table}
Table 2: GPS L1C and BDS BIC signals.  
where \(k\) is the index of Weil sequence for \((0\leq k<N_{W})\) and \(\omega\) is the phase difference between two Legendre sequences. Finally, a post-processing process is carried out to generate a primary code or a secondary code, of which the length is \(N_{C}\), using the Weil sequence expressed as shown in Equation (4). In the case of GPS L1C signals, a post-processing process through which a 7-bit fixed sequence {0,1,1,0,1,0,0} is inserted based on the insertion point \(\tau\) is carried out.  
\[C(k;w;\tau)=\left\{\begin{array}{rl}0,&k=\tau-1,\ \tau+2,\ \tau+4,\ \tau+5\\ 1,&k=\tau,\ \tau+1,\ \tau+3\\ W(k;\omega),&else\end{array}\right. \tag{5}\]  
where \(k\) is the index of GPS L1C code for \((0\leq k<N_{C})\) and \(\tau\) is the insertion point. Every GPS satellite in a GPS satellite system has a unique phase difference \(\omega\) and an insertion point \(\tau\) and generates a unique code through the phase difference and insertion point. In addition, in the case of BDS B1C signals, a post-processing process is carried out through which the Weil code, of which the length is \(N_{W}\), is periodically truncated as shown in Equation (6).  
\[C(k;w;\tau)=W((k+p-1)\text{mod}N_{W};\omega) \tag{6}\]  
where \(k\) is the index of BDS B1C code for \((0\leq k<N_{C})\) and \(p\) is the truncation point. Furthermore, \(p\) indicates the Weil code truncation point while meaning that the code starts from the \(p\)th Weil sequence chip. BDS B1C satellites in the BDS satellite system generate individual codes by using their unique phase difference \(\omega\) and truncation point \(p\). Table 3 summarizes the lengths and detailed parameters by sequence of GPS L1C signals and BDS B1C signals.