# Flexible 5G New Radio LDPC Encoder Optimized for High Hardware Usage Efficiency
## 2 Encoding of LDPC Codes
### Forward Substitution-Based Encoding  
Many standardized LDPC codes have a structure that can facilitate even more efficient encoding than any of the previously described methods. For example, codes from Wi-Fi 802.11n/ac/ax have a double diagonal structure of the right-hand side of the PCM, whereas the left-hand side has a nonspecific conventional quasi-cyclic structure [37], as shown in (12). \[\textbf{H}=\left[ \begin{array}{cccccccccccc}\textbf{h}_{1,1}&\textbf{h}_{1,2 }&\cdots&\textbf{h}_{1,k_{b}}&\textbf{I}^{(1)}&\textbf{I}&0&\cdots&0&0&\cdots &0\\ \textbf{h}_{2,1}&\textbf{h}_{2,2}&\cdots&\textbf{h}_{2,k_{b}}&0&\textbf{I}& \textbf{I}&\cdots&0&0&\cdots&0\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\vdots&\ddots&\vdots&\vdots& \ddots&\vdots\\ \textbf{h}_{r-1,1}&\textbf{h}_{r-1,2}&\cdots&\textbf{h}_{r-1,k_{b}}&0&0&0& \cdots&\textbf{I}&0&\cdots&0\\ \textbf{h}_{r,1}&\textbf{h}_{r,2}&\cdots&\textbf{h}_{r,k_{b}}&\textbf{I}&0&0& \cdots&\textbf{I}&\textbf{I}&\cdots&0\\ \textbf{h}_{r+1,1}&\textbf{h}_{r+1,2}&\cdots&\textbf{h}_{r+1,k_{b}}&0&0&0& \cdots&0&\textbf{I}&\cdots&0\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\ddots& \vdots\\ \textbf{h}_{m_{b},1}&\textbf{h}_{m_{b},2}&\cdots&\textbf{h}_{m_{b},k_{b}}& \textbf{I}^{(1)}&0&0&\cdots&0&0&\cdots&\textbf{I}\\ \end{array} \right] \tag{12}\]  
In (12), \(\textbf{h}_{j,k}\) represents a single CPM in QC-LDPC code's PCM, which can be either circularly shifted identity matrix or zero matrix, \(k_{b}\) is the number of information bit groups each of which has \(Z\) bits, whereas the \(m_{b}\) is the number of parity check equation groups each of which contains \(Z\) parity check equations. **I** is an identity matrix. In general, \(\textbf{W}^{(s)}\) represents any matrix circularly shifted by \(s\). The matrix is circularly shifted by circularly shifting each of its sub vectors. A described deterministic PCM form can be exploited to implement low-area encoders based on a forward substitution (FS) [30; 31; 32; 33; 34]. Since the code is quasi cyclic, the codeword can be grouped into \(k_{b}\) information bit groups and \(m_{b}\) parity bit groups as follows:  
\[\textbf{x}=\left[ \begin{array}{cccccccc}\textbf{i}_{1}&\textbf{i}_{2}&\cdots &\textbf{i}_{k_{b}}&\textbf{P}_{1}&\textbf{P}_{2}&\cdots&\textbf{P}_{m_{b}} \\ \end{array} \right]. \tag{13}\]From (5), (12), and (13), it is simple to derive the following system of equations in GF(2):  
\[ \begin{array}{c}\sum\limits_{l=1}^{k_{b}}\mathbf{h}_{l}j_{l}^{\text{T}}+ \mathbf{p}_{1}^{\text{T}(1)}+\mathbf{p}_{2}^{\text{T}}=0,\ (1^{\text{st}}\ \text{row})\\ \sum\limits_{l=1}^{k_{b}}\mathbf{h}_{j}j_{l}^{\text{T}}+\mathbf{p}_{j}^{\text{ T}}+\mathbf{p}_{j+1}^{\text{T}}=0,\ \text{for}\ j\in\{2,3,\ldots,r-1\}\cup\{r+1,r+2,\ldots,m_{b}-1\}\\ \sum\limits_{l=1}^{k_{b}}\mathbf{h}_{r}j_{l}^{\text{T}}+\mathbf{p}_{1}^{\text{ T}}+\mathbf{p}_{r}^{\text{T}}+\mathbf{p}_{r+1}^{\text{T}}=0,\ (r^{\text{th}}\ \text{row})\\ \sum\limits_{l=1}^{k_{b}}\mathbf{h}_{m_{b}}j_{l}^{\text{T}}+\mathbf{p}_{1}^{ \text{T}(1)}+\mathbf{p}_{m_{b}}^{\text{T}}=0,\ (m_{b}^{\text{th}}\ \text{row})\end{array}  \tag{14}\]  
Parity group \(\mathbf{p}_{1}\) can be calculated by adding up all the equations from (14), which gives the following expression:  
\[\mathbf{p}_{1}^{\text{T}}=\sum\limits_{j=1}^{m_{b}}\sum\limits_{l=1}^{k_{b}} \mathbf{h}_{j}j_{l}^{\text{T}}. \tag{15}\]  
In hardware, each of the \(m_{b}\) sums \(\sum_{l=1}^{k_{b}}\mathbf{h}_{j}j_{l}^{\text{T}}\) is usually calculated by circularly shifting the information group vectors \(\mathbf{i}_{l}^{\text{T}}\) and by calculating the sum of shifted vectors using XOR gates. If these sums are denoted with \(\boldsymbol{\lambda}_{j}\), then the rest of the parity bit vectors can be calculated as follows:  
\[\begin{array}{c}\mathbf{p}_{2}^{\text{T}}=\boldsymbol{\lambda}_{1}+\mathbf{ p}_{1}^{\text{T}(1)};\ \to the right-hand side of IEEE 802.11n/ac/ax PCMs described in Section 2.5.