# A Design Method of Code Correlation Reference Waveform in GNSS Based on Least-Squares Fitting
## 2 Least-Squares Method of S-Curve Shaping  
The signal distortion by band-limited effects is mainly due to the channel filters in the signal generation and the receiver front-end. The received line-of-sight (LOS) signal in a band-limited receiver can be expressed in a continuous-time model as follows. \[r(t)=A\tilde{X}(t-\tau_{0})D(t-\tau_{0})\cos(2\pi f_{0}t+\varphi_{0})+n(t) \tag{1}\]  
Here, \(r(t)\) is received with additive white Gaussian noise \(n(t)\) of an \(N_{0}\) power spectrum density (PSD). \(A\) is the signal amplitude, and \(D(t)\) is the navigation message bit stream, which is ignored in the following. The path delay is given as \(\tau_{0}\). The carrier frequency is \(f_{0}\), and the carrier phase offset is \(\varphi_{0}\). \(\tilde{X}(t)\) is the expression for the baseband BOC waveform \(X(t)\) after channel filtering. The baseband waveform \(X(t)=c(t)\cdot sc(t)\), where \(c(t)\) is the PRN code and \(sc(t)=sign[sin(2\pi f_{sc}t)]\) is the subcarrier with frequency \(f_{sc}\). \[\tilde{X}(t) = X(t)\otimes h(t) \tag{2}\]  
The channel impulse response during the whole signal transmission and receiving is detonated as \(h(t)\). Assuming perfect carrier frequency synchronization, the in-phase and quadrature-phase baseband signal after frequency down-conversion are given as follows. \[I(t) = A\tilde{X}(t-\tau_{0})\cos(\varphi_{0}-\phi_{0})+n_{I}(t)\] \[Q(t) = A\tilde{X}(t-\tau_{0})\sin(\varphi_{0}-\phi_{0})+n_{Q}(t) \tag{3}\]  
Here, \(\phi_{0}\) is the local estimation of \(\varphi_{0}\), \(n_{I}(t)\), and \(n_{Q}(t)\) are the white Gaussian noise of a \(N_{0}\) power spectrum density (PSD). For the receiver using the CCRW technique, the reference waveform \(W(t)\) is correlated with the baseband signal \(I(t)\) and \(Q(t)\) with a coherent integration time of \(T\). The narrow correlator technique and double-delta technique can be fit into different reference waveforms, as well [7]. \[I_{W}(\varepsilon) = AR_{\tilde{X}W}(\varepsilon)\cos(\varphi_{e})+N_{I}\] \[Q_{W}(\varepsilon) = AR_{\tilde{X}W}(\varepsilon)\sin(\varphi_{e})+N_{Q} \tag{4}\]  
Here, \(\varphi_{e}\) is the estimation error of carrier phase, and \(\varepsilon\) is the code phase estimation error. The correlation result of \(\tilde{X}(t-\varepsilon)\) and \(W(t)\) is \(R_{\tilde{X}W}(\varepsilon)\). \(N_{I}\) and \(N_{Q}\) are the noise part after integration with the variances of \(R_{WW}(0)N_{0}/T\). Basically, there are two types of reference waveforms, i.e., 'transition-based' and 'per-chip' reference waveforms, as depicted in Figure 4.  
For 'transition-based' reference waveforms, the reference waveform appears only at the original code transitions. They can be synthesized as a linear combination of multiple instances of time-shifted local code replicas, like the narrow correlator technique and double-delta technique. For 'per-code' reference waveforms, the reference waveform appear at a fixed position in each code chip, usually at the chip boundary, like the CCRW W2 technique and the BOC-gated-PRN (BGP) waveform [8]. Here, only the 'per-code' reference waveforms are studied, as the 'transition-based' reference waveforms were discussed in [12]. The expression of the 'per-code' reference waveform can be given as follows. \[W(t)=\sum_{j=0}^{\infty}g(t-jT_{C})c_{j}(t) \tag{5}\]  
Here, \(g(t)\) is the element gate, and \(c_{j}(t)\) is the \(j\)-th PRN code. The element gate occurs at the edge of each chip. By choosing \(g(t)\), the S-curve is shaped accordingly. However, the analytic expression of \(R_{XW}\) is only resolved for the BPSK signal with infinite bandwidth. Here, a general method for the code tracking reference function design of the BPSK and BOC(m, n) signals with finite bandwidth is proposed.