# A Flexible FPGA-Based Stochastic Decoder for 5G LDPC Codes
## 3 Construction of BGM in 5G NR Standard  
The PCM \(H\) is represented and constructed from its BGM \(H_{b}\)[9]. The \(H_{b}\) has dimension \(m_{b}\times n_{b}\), where \(M=m_{b}\times z_{c}\) and \(N=n_{b}\times z_{c}\). The entries of \(H_{b}\) are expanded with a \(z_{c}\times z_{c}\) square sub-matrix in \(H\), where \(z_{c}\) is known as the lifting size or expansion factor. The entry value '\(-1\)' of \(H_{b}\) is replaced by a zero matrix of dimension \(z_{c}\times z_{c}\) in \(H\), and the value '\(0\)' is replaced by the identity matrix of dimension \(z_{c}\times z_{c}\), and another non-'\(-1\)' entry value \(1\leq S_{i,j}\leq z_{c}\), also known as the shift value, is replaced by circulant permutation matrix \(I(S_{i,j})\). The subscripts \(i,j\) represent the row index and column index of the entry, respectively. The sub-matrix \(I(S_{i,j})\) is obtained by each row of the identity matrix having a right-shift value of \(S_{i,j}\) positions. The value of \(S_{i,j}\) is calculated from the function (5). The value of \(V_{i,j}\) is obtained from Tables 5.3.2-2 and 5.3.2-3 of 5G NR standard specification 3 GPP TS 38.212 [8] according to the selected BGM and the set index \(i_{LS}\).  
Figure 4: SVN and its implementation unit.  
Figure 3: SCN and its implementation unit.  
In this paper, we constructed BGM \(H_{b1}\) of \((N,K)\) LDPC code having a message or information block length \(K=1232\) and code rate \(R=K/N=1/3\). The five steps are listed below for constructing the \(H_{b1}\) with \(k_{b}\) as the length of the message block columns. The terms \(k_{b}\) of \(H_{b1}\) and \(K\) of \(H\) are related, as \(K=k_{b}\times z_{c}\).  
1. Select from the two BGMs: As per the specification of 3 GPP TS 38.212 [8], since the code rate \(R\geq 1/4\), BGM1 is selected.
2. Calculate the value \(k_{b}\) after selecting BGM: From the specification of 3 GPP TS 38.212 [8], BGM1 has \(k_{b}=22\).
3. Find the expansion factor \(z_{c}\) : Select the minimum \(z_{c}\) from Table 5.3.2-1 [8] such that \(k_{b}\times z_{c}\geq K\). For given \(K=1232\), \(k_{b}=22\), and \(z_{c}\) is calculated as \(1232/22=56\).
4. Select the set index \(i_{LS}\): After \(z_{c}\) is determined, the suitable shift coefficient matrix set from Table 5.3.2-1 [8] must be selected. Since \(z_{c}=56\), the set index \(i_{LS}=3\) is considered.
5. Compute the BGM entry values: Utilize the function (5) to determine the entry values \(S_{i,j}\) by means of the modular \(z_{c}\) operation. \[S_{i,j}=f(V_{i,j},z_{c})=\begin{cases}-1,&\text{if $V_{i,j}=-1$};\\ mod(V_{i,j},z_{c}),&\text{else}\end{cases}\] (5)
6. Construct the PCM \(H\): Substitute each entry of the BGM by the corresponding circulant permutation matrix or zero matrix of size \(z_{c}\times z_{c}\) in \(H\).  
From Step 5, the first entry \(h_{0,0}\) of \(H_{b1}\) is calculated using \(mod(V_{0,0},z_{c})=\text{mod}\) (\(223\), \(56\)) = \(55\), where the selected \(V_{0,0}=223\) value is obtained from Table 5.3.2-2 [8] and corresponds to row index \(i=0\), column index \(j=0\), and set index \(i_{LS}=3\). Similarly, the remaining entry values are calculated by using a function (5) and \(V_{i,j}\) values obtained from Table 5.3.2-2 [8] based on the entry's row and column indexes. Table 2 shows calculations of the corresponding values of a few entries of \(H_{b1}\). The constructed \(H_{b1}\) has dimensions of \(46\times 68\).  
In order to achieve the desired information lengths and rate adaptation in 5G NR QC-LDPC codes, a process of shortening and puncturing is carried out. The characteristics of BGM1 are described in the Table 3. The BGM \(H_{b1}\) is shown in Table 4.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Entry of \(H_{b1}\)** & \(V_{i,j}\) & \(mod\) (\(V_{i,j},z_{c}\)) & **Corresponding Values** \\ \hline \(h_{0,0}\) & \(V_{0,0}=223\) & \(mod\) (\(223,56\)) & \(55\) \\ \hline \