# Efficient QC-LDPC Encoder for 5G New Radio
## 4 Proposed 5G NR QC-LDPC Encoder Design
### Proposed QC-LDPC Encoding Algorithm
The second step in the encoding process includes the computation of the \(p_{c}\) parity portions using Equation (21). The first step in the encoder implementation is the determination of the \(p_{a}\) part. Initially, Equation (20) is re-written in block form as follows:  
\[ \begin{bmatrix}a_{1,1}&a_{1,2}&\cdots&a_{1,k_{b}}\\ a_{2,1}&a_{2,2}&\cdots&a_{2,k_{b}}\\ a_{3,1}&a_{3,2}&\ddots&a_{3,k_{b}}\\ a_{4,1}&a_{4,2}&\cdots&a_{4,k_{b}}\end{bmatrix}\begin{bmatrix}s_{1}\\ s_{2}\\ \vdots\\ s_{k_{b}}\end{bmatrix} + \begin{bmatrix}1&0&-1&-1\\ 0&0&0&-1\\ -1&-1&0&0\\ 1&-1&-1&0\end{bmatrix}\begin{bmatrix}p_{a_{1}}\\ p_{a_{2}}\\ p_{a_{3}}\\ p_{a_{4}}\end{bmatrix} =0. \tag{22}\]  
This can then be expanded into the following set of equations:  
\[\sum_{j=1}^{k_{b}}a_{1,j}s_{j}+p_{a_{1}}^{(1)}+p_{a_{2}}=0, \tag{23}\]  
\[\sum_{j=1}^{k_{b}}a_{2,j}s_{j}+p_{a_{1}}+p_{a_{2}}+p_{a_{3}}=0, \tag{24}\]  
\[\sum_{j=1}^{k_{b}}a_{3,j}s_{j}+p_{a_{3}}+p_{a_{4}}=0, \tag{25}\]  
\[\sum_{j=1}^{k_{b}}a_{4,j}s_{j}+p_{a_{1}}^{(1)}+p_{a_{4}}=0, \tag{26}\]  
where \(p_{a_{1}}^{(\alpha)}\) denotes the \(\alpha^{\text{th}}\) (right) cyclic shifted version of \(p_{a_{1}}\) for \(0\leq\alpha\leq Z\). By adding up all the above equations, the following is obtained:  
\[p_{a_{1}}=\sum_{i=1}^{4}\sum_{j=1}^{k_{b}}a_{i,j}s_{j}. \tag{27}\]  
It should be noted that a straightforward implementation of \(a_{i,j}s_{j}\) can be done with the use of \(Z\)-bit cyclic shifters. Since \(a_{i,j}s_{j}\) is a circular right shift of \(s_{j}\) with the shift coefficient defined by \(a_{i,j}\), the hardware complexity is trivial. Based on the definition below,\[\lambda_{i}=\sum_{j=0}^{k_{b}}a_{ij}s_{j}\text{ for }i=1,2,3,4, \tag{28}\]  
the following can be obtained:  
\[p_{a_{1}}=\sum_{i=1}^{4}\lambda_{i}, \tag{29}\]  
\[p_{a_{2}}=\lambda_{1}+p_{a_{1}}^{(1)}, \tag{30}\]  
\[p_{a_{3}}=\lambda_{3}+p_{a_{4}}, \tag{31}\]  
\[p_{a_{4}}=\lambda_{4}+p_{a_{1}}^{(1)}. \tag{32}\]  
From Equation (28), each \(\lambda_{i}\) value is computed by accumulating all the \(a_{ij}s_{j}\) values. In Modulo 2, \(\lambda_{i}\) is obtained by carrying out XOR operations on all the elements of \(a_{ij}s_{j}\). The \(\lambda_{i}\) values can be estimated per clock cycle in \(g=4\) cycles. The first block of the parity bits \(p_{a_{1}}\) is then calculated by accumulating all the \(\lambda_{i}\) values. The remaining parity bits \(p_{a_{i}}\) can be obtained using a method that can be easily derived from Equations (30)-(32). This process can be done in two clock cycles since there is dependency between \(p_{a_{3}}\) and \(p_{a_{4}}\). All the parity bits \(p_{a}\) in the first parity portion are stored in registers. In a second step, the \(p_{c}\) portion can be easily determined based on Equation (21), where matrices \(C_{1}\) and \(C_{2}\) are given by  
\[C_{1}= \begin{bmatrix}c_{1,1}&c_{1,2}&\cdots&c_{1,k_{b}}\\ c_{2,1}&c_{2,2}&\cdots&c_{2,k_{b}}\\ \vdots&\vdots&\ddots&\vdots\\ c_{m_{b}-g,1}&c_{m_{b}-g,2}&\cdots&c_{m_{b}-g,k_{b}}\end{bmatrix} ;\;\;C_{2}= \begin{bmatrix}c_{1,k_{b}+1}&c_{1,k_{b}+2}&\cdots&c_{1,k_{b}+g}\\ c_{2,k_{b}+1}&c_{2,k_{b}+2}&\cdots&c_{2,k_{b}+g}\\ \vdots&\vdots&\ddots&\vdots\\ c_{m_{b}-g,k_{b}+1}&c_{m_{b}-g,k_{b}+2}&\cdots&c_{m_{b}-g,k_{b}+g}\end{bmatrix}  \tag{33}\]  
Upon the application of Equation (21), the elements of \(p_{c}\) can be computed using the following equations:  
\[p_{c_{1}}=\sum_{j=1}^{k_{b}}c_{1,j}s_{j}+\sum_{j=1}^{g}c_{1,k_{b} +j}p_{a_{j}}, \tag{34}\] \[p_{c_{2}}=\sum_{j=1}^{k_{b}}c_{2,j}s_{j}+\sum_{j=1}^{g}c_{2,k_{b} +j}p_{a_{j}},\] \[\vdots\] \[p_{c_{m_{b}-g}}=\sum_{j=1}^{k_{b}}c_{m_{b}-g,j}s_{j}+\sum_{j=1}^{ g}c_{m_{b}-g,k_{b}+j}p_{a_{j}}.\]  
Similarly, \(c_{i,j}s_{j}\) represents a circular shift of \(s_{j}\) with the shift coefficient defined by \(c_{i,j}\), and \(c_{i,k_{b}+j}p_{a_{j}}\) represents a circular shift of \(p_{a_{j}}\) with the shift coefficient defined by \(c_{i,j_{b}+j}\).