# Flexible 5G New Radio LDPC Encoder Optimized for High Hardware Usage Efficiency
## 2 Encoding of LDPC Codes
### Efficient Algorithm for Flexible Encoding  
As mentioned earlier, the 5G NR communication standard imposes the necessity for high LDPC encoder flexibility. There are a total of 102 codes derived just from two base graph matrices by lifting each with every one of 51 lifting sizes. The standard also introduces the shortening of base graph matrices, which additionally increases the number of possible codes by tens of times [1]. This flexibility cannot be achieved by any method that requires either multiplying with generator matrix or any matrix inversion without extremely high usage of memory or logic resources. Therefore, the flexible encoding must be achieved based on the previously described forward substitution method. The forward substitution-based encoding for BG1 codes has been presented in [35]. It has been shown that this method is multiple times more efficient than straightforward and RU methods and that fast encoding can be achieved. The first step is the calculation of core parity bits. After that, the additional parity bits can be calculated using only the lower part of the PCM. Similar to Wi-Fi codes, the encoding process solves the following system of equations:  
\[\mathbf{Hx}^{\text{T}}=0\Rightarrow\left[ \begin{array}{cccc}\mathbf{A}& \mathbf{B}&0\\ \mathbf{C}&\mathbf{D}&\mathbf{I}\end{array} \right]\left[ \begin{array}{c} \mathbf{i}^{\text{T}}\\ \mathbf{p}_{\text{c}}^{\text{T}}\\ \mathbf{p}_{\text{a}}^{\text{T}}\end{array} \right]=0. \tag{24}\]  
This system can be split into the smaller system of equations from which core parity bits can be calculated (25) and the set of equations from which additional parity bits are afterward calculated (26). \[\mathbf{p}_{\mathbf{a}}^{\text{T}}=\left[ \begin{array}{cccc}\mathbf{c}_{1,1 }&\mathbf{c}_{1,2}&\cdots&\mathbf{c}_{1,k_{b}}&\mathbf{d}_{1,1}&\mathbf{d}_{1,2}&\mathbf{d}_{1,3}&\mathbf{d}_{1,4}\\ \mathbf{c}_{2,1}&\mathbf{c}_{2,2}&\cdots&\mathbf{c}_{2,k_{b}}&\mathbf{d}_{2,1 }&\mathbf{d}_{2,2}&\mathbf{d}_{2,3}&\mathbf{d}_{2,4}\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\vdots&\vdots\\ \mathbf{c}_{m_{b}-4,1}&\mathbf{c}_{m_{b}-4,2}&\cdots&\mathbf{c}_{m_{b}-4,k_{b}} &\mathbf{d}_{m_{b}-4,1}&\mathbf{d}_{m_{b}-4,2}&\mathbf{d}_{m_{b}-4,3}&\mathbf{ d}_{m_{b}-4,4}\end{array} \right]\times\left[ \begin{array}{c}\mathbf{p}_{\text{c}}^{\text{T}}\\ \mathbf{p}_{\text{c}}^{\text{T}}\\ \mathbf{p}_{\text{c}}^{\text{T}}\\ \mathbf{p}_{\text{c}}^{\text{T}}\\ \mathbf{p}_{\text{c}}^{\text{T}}\end{array} \right]=0, \tag{25}\]  
\[\mathbf{p}_{\mathbf{a}}^{\text{T}}=\left[ \begin{array}{cccccc}\mathbf{c}_{1,1}&\mathbf{c}_{1,2}&\cdots&\mathbf{c}_{1,k_{b}}&\mathbf{d}_{1,1}&\mathbf{d}_{ 1,2}&\mathbf{d}_{1,3}&\mathbf{d}_{1,4}\\ \mathbf{c}_{2,1}&\mathbf{c}_{2,2}&\cdots&\mathbf{c}_{2,k_{b}}&\mathbf{d}_{2,1 }&\mathbf{d}_{2,2}&\mathbf{d}_{2,3}&\mathbf{d}_{2,4}\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\vdots&\vdots\\ \mathbf{c}_{m_{b}-4,1}&\mathbf{c}_{m_{b}-4,2}&\cdots&\mathbf{c}_{m_{b}-4,k_{b}} &\mathbf{d}_{m_{b}-4,1}&\mathbf{d}_{m_{b}-4,2}&\mathbf{d}_{m_{b}-4,3}&\mathbf{ d}_{m_{b}-4,4}\end{array} \right]\times\left[ \begin{array}{c}\mathbf{i}^{\text{T}}\\ \mathbf{p}_{\text{c}}^{\text{T}}\end{array} \right]. \tag{26}\]For BG1 codes, the system (25) is just a special case of the system (12), where \(r=2\). Therefore, if the intermediate results are denoted as  
\[\mathbf{\lambda}_{j}^{\mathsf{T}}=\sum\limits_{l=1}^{k_{b}}\mathbf{a}_{j,l}\mathbf{ i}_{l}^{\mathsf{T}},\,j\in\{1,2,3,4\}, \tag{27}\]  
core parity bits can be calculated using the following expressions:  
\[\mathbf{p}_{\mathbf{\epsilon},1}=\sum\limits_{j=1}^{4}\mathbf{\lambda}_{j};\quad \mathbf{p}_{\mathbf{\epsilon},2}=\mathbf{\lambda}_{1}+\mathbf{p}_{\mathbf{\epsilon},1}^{(1 )};\quad\mathbf{p}_{\mathbf{\epsilon},4}=\mathbf{\lambda}_{4}+\mathbf{p}_{\mathbf{\epsilon },1}^{(1)};\quad\mathbf{p}_{\mathbf{\epsilon},3}=\mathbf{\lambda}_{3}+\mathbf{p}_{ \mathbf{\epsilon},4}\enspace. \tag{28}\]  
In [35], the system (25) is solved only for BG1 codes. In this paper, flexibility was a key requirement.