# Flexible 5G New Radio LDPC Encoder Optimized for High Hardware Usage Efficiency
## 2 Encoding of LDPC Codes
### Forward Substitution-Based Encoding
Depending on the base graph, the matrix \(\mathbf{B}\) can have one of the following structures:  
\[\mathbf{B}_{\text{BG1}}=\left[ \begin{array}{cccc}\mathbf{I}^{(1)}&\mathbf{I}& 0&0\\ \mathbf{I}&\mathbf{I}&\mathbf{I}&0\\ 0&0&\mathbf{I}&\mathbf{I}\\ \mathbf{I}^{(1)}&0&0&\mathbf{I}\\ \end{array} \right];\mathbf{B}_{\text{BG2}}=\left[ \begin{array}{cccc} \mathbf{I}&\mathbf{I}&0&0\\ 0&\mathbf{I}&\mathbf{I}&0\\ \mathbf{I}^{(1)}&0&\mathbf{I}&\mathbf{I}\\ \end{array} \right]. \tag{18}\]  
A scatter diagram of the base graph for both BG1 and BG2 matrices is shown in Figure 1.  
The codeword (of length \(n_{b}Z\), where \(n_{b}=k_{b}+m_{b}\)) can be represented in systematic form as  
\[\mathbf{x}=\left[ \begin{array}{cc}\mathbf{i}&\mathbf{p_{c}}&\mathbf{p_{a}} \end{array} \right], \tag{19}\]  
where \(\mathbf{p_{c}}\) represents a vector of so-called core parity bits and \(\mathbf{p_{a}}\) is a vector of so-called additional parity bits [40]. The information bits vector is of length \(k_{b}Z\), whereas the parity bit vectors are of length \(4Z\) and \((m_{b}-4)Z\), respectively. Since the upper right submatrix of the PCM is a zero matrix, all core parity bits can be calculated from information bits using submatrices \(\mathbf{A}\) and \(\mathbf{B}\). Additional parity bits can be calculated from information and core parity bits using submatrices \(\mathbf{C}\) and \(\mathbf{D}\). The lifting size \(Z\) can take values from 2 to 384 and must have a form of  
\[Z=a\cdot 2^{j}, \tag{20}\]  
where \(a\) can take values from the set {2, 3, 5, 7, 9, 11, 13, 15}, which gives a total of 51 different lifting size values. There are two base graph matrices (BG1 and BG2) available from which all codes are derived. Each base graph matrix has a corresponding set of base exponent matrices. The set includes one matrix for each possible value of parameter \(a\) from (20), defined for the corresponding maximum lifting size (256, 384, 320, 224, 288, 352, 208, or 240). Every exponent matrix contains nonnegative and negative entries. Nonnegative entries represent the values by which the corresponding identity submatrices are circularly shifted. All other entries are equal to \(-1\) and represent zero submatrices. The structure of a base exponent matrix is  
\[\mathbf{V}=\left[ \begin{array}{cccc}V_{1,1}&V_{1,2}&\cdots&V_{1,n_{b}}\\ V_{2,1}&V_{2,2}&\cdots&V_{1,n_{b}}\\ \vdots&\vdots&\ddots&\vdots\\ V_{m_{b},1}&V_{m_{b},2}&\cdots&V_{m_{b},n_{b}}\\ \end{array} \right]. \tag{21}\]  
Figure 1: Base graph matrix structures for codes in 5G NR. Base exponent matrices define exponent matrices for every other lifting size whose structure is the same as  
\[\mathbf{P}=\left[ \begin{array}{cccc}P_{1,1}&P_{1,2}&\cdots&P_{1,n_{b}}\\ P_{2,1}&P_{2,2}&\cdots&P_{1,n_{b}}\\ \vdots&\vdots&\ddots&\vdots\\ P_{m_{b},1}&P_{m_{b},2}&\cdots&P_{m_{b},n_{b}}\end{array} \right]. \tag{22}\]  
Shift values \(P_{j,l}\) are calculated as follows:  
\[P_{j,l}= \begin{cases}-1,&\text{if }V_{j,l}=-1\\ V_{j,l}\text{mod}Z,&\text{if }V_{j,l}>-1\end{cases} , \tag{23}\]  
where mod represents modulo operation [1; 5; 9]. Up until today, the 5G NR standard introduces the highest number of possible LDPC codes. A practical system must have all the codes supported since the choice of which code is used is made in the runtime. Therefore, the encoder and the decoder need to be flexible, which defines a challenge for designers of practical systems.