# An FPGA Design with High Memory Efficiency and Decoding Performance for 5G LDPC Decoder
## 2 Related Definitions and Preliminaries
### 5G Quasi-Cyclic LDPC Codes
Each decoding layer consists  
\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline  & \(\mathbf{Z}\) & \multicolumn{8}{c}{**a**} \\ \cline{3-10}  & \(\mathbf{2}\) & \(\mathbf{3}\) & \(\mathbf{5}\) & \(\mathbf{7}\) & \(\mathbf{9}\) & \(\mathbf{11}\) & \(\mathbf{13}\) & \(\mathbf{15}\) \\ \hline  & 0 & 2 & 3 & 5 & 7 & 9 & 11 & 13 & 15 \\  & 1 & 4 & 6 & 10 & 14 & 18 & 22 & 26 & 30 \\  & 2 & 8 & 12 & 20 & 28 & 36 & 44 & 52 & 60 \\ \(\mathbf{k}\) & 3 & 16 & 24 & 40 & 56 & 72 & 88 & 104 & 120 \\  & 4 &of \(M/L\) consecutive rows of \(\mathbf{H}\) such that each variable node is connected only once to each layer. The set of consecutive rows of \(\mathbf{H}\) corresponding to layer \(l\in\{1,\cdots,L\}\) is denoted as \(\mathcal{M}_{l}\). To perform hardware implementation, we suppose that \(\gamma_{n}\), \(\alpha_{m,n}\), \(\widetilde{\gamma}_{n}\) messages are quantized on \(\widetilde{q}\)-bits, while \(q\)-bits (where \(q<\widetilde{q}\)) are used for the quantization of \(\beta_{m,n}\) messages. The symbol for the alphabet of \(\widetilde{q}\)-bit messages is \(\widetilde{\mathcal{M}}=(-\widetilde{Q},\cdots,-1\), \(0\), \(+1\),\(\cdots,+\widetilde{Q}\)), where \(\widetilde{Q}=2^{\widetilde{q}-1}-1\). The \(q\)-bit messages alphabet is expressed similarly by \(\mathcal{M}=(-Q,\cdots,-1\), \(0\), \(+1\),\(\cdots,+Q)\), where \(Q=2^{q-1}-1\)[26]. More specifically, \(\alpha_{m,n}\) messages should be represented in \(q\)-bits before being passed to CNs. To this purpose, the saturation functions \(s_{\mathcal{M}}(z)\) is applied, which is defined as:  
\[s_{\mathcal{M}}(z)= \begin{cases}-Q&\text{if }z<-Q\\ z&\text{if }z\in\mathcal{M}\\ +Q&\text{if }z>+Q\end{cases}  \tag{1}\]  
Similar definitions apply to the \(\tilde{q}\)-bit saturation function \(s_{\widetilde{\mathcal{M}}}\). ```
0:\(\mathbf{y}=(y_{1},y_{1},\ldots,y_{N})\in\mathcal{Y}^{N}\) (\(\mathcal{Y}\) is the channel output alphabet) \(\triangleright\) received word
0:\(\hat{\mathbf{x}}=(\hat{x}_{1},\hat{x}_{1},\ldots,\hat{x}_{N})\in\{0,1\}^{N}\)\(\triangleright\) estimated codeword
1:Initialization
2:for all\(n=1,\ldots,N\)do\(\mathbf{L}_{n}=\log\dfrac{\Pr(x_{n}=0\mid y_{n})}{\Pr(x_{n}=1\mid y_{n})}\); \(\hat{\gamma}_{n}=\gamma_{n}=\varphi(\mathbf{L}_{n})\)
3:endfor
4:for all\(m=1,\ldots,M\) and \(n\in\mathcal{H}(m)\)do\(\beta_{m,n}=0\);
5:endfor
6:Iteration Loop
7:for all\(i=1,\ldots,n_{iter}\)do\(\triangleright\) Loop over iterations
8:for all\(l=1,\ldots,L\)do\(\triangleright\) Loop over horizontal layers
9:for all\(m=1,\ldots,\mathcal{M}_{l}\) and \(m\in\mathcal{H}(n)\)do\(\triangleright\)VN-processing
10:\(\alpha_{m,n}=s_{\mathcal{M}}(\hat{\gamma}_{n}-\operatorname{sgn}(\beta_{m,n}) \cdot\max\{\lvert\beta_{m,n}\rvert-\delta,0\})\)
11:\(\alpha_{m,n}^{sel}=s_{\mathcal{M}}(\alpha_{m,n})\)
12:endfor
13:for all\(m=1,\ldots,\mathcal{M}_{l}\) and \(n\in\mathcal{H}(m)\)do\(\triangleright\)CN-processing
14:\(\beta_{m,n}= \begin{cases}A\cdot\min 1&\text{if position of}\lvert\alpha_{m,n^{\prime}}^{ sat}\rvert=\text{index\_min1}\\ A\cdot\max\{\min 1-\beta,0\}&\text{otherwise}\end{cases} \)
15:\(\min 1=\min_{n\in\mathcal{H}(m)}\lvert\alpha_{m,n}^{sat}\rvert\)
16:\(A=\prod_{n^{\prime}\in\mathcal{H}(m)\setminus n}\operatorname{sgn}(\alpha_{m,n^{\prime}}^{sat})\)
17:endfor
18:for all\(m=1,\ldots,\mathcal{M}_{l}\) and \(m\in\mathcal{H}(n)\)do\(\triangleright\)AP-update
19:\(\widetilde{\gamma}_{n}=s_{\mathcal{M}}(\alpha_{m,n}+\beta_{m,n})\)
20:endfor
21:endfor
22:endfor
23:End Iteration Loop
```  
\(n_{iter}\) is the maximum number of iterations. \(index\_min1\) is the position of \(min1\). In cases where there exists more than one \(min1\) value, \(index\_min1\) is determined as the position with the smallest index. \(\delta,\beta>0\) is the offset factors. \(\alpha_{m,n}^{sat}\) is the value of \(\alpha_{m,n}\) saturated to \(q\)-bit. ```  
**Algorithm 1** Layered HOMS decoding algorithm [19].