Web Simulation 

 

 

 

 

5G NR LDPC Base Graph 2 (BG2) H-Matrix Tutorial 

This interactive tutorial visualizes the construction of the 5G NR LDPC parity-check matrix (H) from Base Graph 2 (BG2). The flow goes from a single number—the Transport Block Size (TBS)—to a sparse H-matrix with thousands of elements: TBS → Zc / iLS → Base Graph grid → expanded H-matrix.

NOTE : You would need considerable depth of understanding on LDPC itself to understand meaning of the tables and output results on this simulation. For the theorectical aspects of LDPC, refer to this note

Mathematical foundation

1. Input and set selection

You enter TBS. The simulator chooses the lifting size Zc and the set index iLS (0–7) so that Kb · Zc ≥ Ktarget, where Kb = 10 (constant for BG2) and Ktarget ≈ TBS + 24 (CRC). The 3GPP spec defines eight lifting sets; each set gives a list of allowed Zc values (e.g. Set 0: 2, 4, 8, …, 256). The smallest valid Zc in the appropriate set is selected.

2. Base Graph (BG2) visualization

BG2 is a 42×52 template. Each cell (r, c) is either empty (null) or holds a shift value sr,c that depends on iLS: the shift table stores eight values per cell (one per iLS). The left grid shows this base graph; occupied cells display the current shift. Hovering a cell highlights the corresponding block in the full H-matrix on the right.

3. Lifting (expansion)

Each non-empty cell (r, c) is replaced by a Zc×Zc circulant matrix: an identity matrix shifted right by sr,c mod Zc. Empty cells become Zc×Zc zero blocks. Clicking a cell in the base graph opens a Block Detail popup showing the circulant (1s and 0s) for that block.

4. Full H-matrix

The final H has size (42·Zc) × (52·Zc). It is drawn on the canvas as a bitmap: black = 1, white = 0. At large Zc the matrix is very sparse; the canvas scales to fit the simulation area (max width 800 px).

Input
→ Zc / iLS → Base Graph 42×52 → H-Matrix
iLS calculation (3GPP TS 38.212 Table 5.3.2-1: Sets of LDPC lifting size Z)
Process:
  1. Ktarget = TBS + 24 (code block length including CRC).
  2. For BG2, Kb = 10 (constant for BG2). Require Kb · Zc ≥ Ktarget.
  3. Search all sets in the table below; choose the smallest Zc that satisfies the condition.
  4. The set index iLS of that set is used for the base graph shift table.
Set index (iLS) Set of lifting sizes (Z)
0 2, 4, 8, 16, 32, 64, 128, 256
1 3, 6, 12, 24, 48, 96, 192, 384
2 5, 10, 20, 40, 80, 160, 320
3 7, 14, 28, 56, 112, 224
4 9, 18, 36, 72, 144, 288
5 11, 22, 44, 88, 176, 352
6 13, 26, 52, 104, 208
7 15, 30, 60, 120, 240
Shifting Table (3GPP TS 38.212 Table 5.3.2-3 format): H_BG (Row index i, Column index j), Vi,j (Set index i_LS 0–7). Value for current i_LS is highlighted.
Base Graph (42×52)
Systematic (cols 0–1) Parity (cols 2–51)
H-Matrix (42·Zc × 52·Zc) = ()
Property Value / Formula Description
Base Graph Dim 42 × 52 The macro template.
Lifting Size (Zc) — User input (scaling factor).
Full H-Matrix Dim — The actual sparse matrix size.
Total Elements — Total number of bits in the H-matrix.
Codeword Generator (Functional LDPC Encoder)
Impairment Injection
Codeword vector c (click a bit to flip)
Encoding & verification
Action Logic Result
Encoding Solve H·c = 0 Generates valid parity bits.
Transmission Send vector c The complete codeword.
Verification Check H·cT Must be 0 for no errors.
Error H·cT ≠ 0 Syndrome non-zero; failed rows highlighted.

 

Usage

Use this simulation to explore 5G NR LDPC BG2 H-matrix construction and codeword verification:

  1. TBS (Transport Block Size): Enter an integer (e.g. 40 or 1000). Changing TBS triggers Generate H to compute Zc and iLS and to auto-fill the Transport Block Bits textarea with exactly 10×Zc bits (systematic capacity). Click Generate H manually to refresh after editing TBS.
  2. iLS and Zc: You can override the auto choice. iLS (0–7) selects the shift column in the 3GPP table; Zc is populated from the selected set. Changing either updates the Base Graph, H-matrix, and the TB bits field (10×Zc length).
  3. Base Graph grid (left): Each cell shows the shift value for the current iLS, or is empty. Hover a cell to highlight the corresponding Zc×Zc block in the H-matrix. Click a cell to open a popup with the circulant matrix for that block.
  4. H-Matrix canvas (right): Renders the full sparse matrix: black = 1, white = 0. Size is (42·Zc)×(52·Zc). For large Zc, pixels are scaled to fit.
  5. Codeword Generator: Transport Block Bits holds 10×Zc systematic bits (label shows current/max). It is auto-filled when TBS or Zc changes. If you type more than 10×Zc bits, the value is truncated when you click Generate Codeword. Generate Codeword (s, p) builds the full codeword c and displays it in the Bit Viewer (Block 0–51, Zc bits per row; Blocks 0–9 = systematic, 10–51 = parity). Click a bit to flip it; validity updates in real time.
  6. Validity Check: The panel below the button shows H·cT = z: syndrome weight, failed row indices (if any), and a pass/fail summary. Status bar shows VALID (Syndrome = 0) or INVALID.
  7. Impairment Injection: Inject 1-Bit Error or Inject Burst Error flips random bits; Apply LDPC Correction re-encodes from the current TB bits to restore a valid codeword.

Tips: Start with a small TBS (e.g. 40) for a small Zc and readable H-matrix and bit viewer. The pipeline is: Input → Zc/iLS → Base Graph → H-Matrix → Codeword → Verification (H·cT).

Parameters

  • TBS: Transport Block Size in bits. With Generate H, computes Zc and iLS and draws the H-matrix. Changing TBS also triggers TB bits auto-fill to 10×Zc.
  • iLS (Set index): 0–7. Selects the 3GPP shift column. Changing it updates the Base Graph, H-matrix, and TB bits length.
  • Zc (Lifting size): From the current iLS set. Sets circulant size and H dimensions; changing Zc auto-fills TB bits to 10×Zc and regenerates the codeword.
  • Generate H: From TBS, computes Ktarget = TBS + 24, picks smallest Zc with Kb·Zc ≥ Ktarget, updates iLS/Zc, draws Base Graph and H-matrix, then syncs TB bits and generates the codeword.
  • Transport Block Bits: Binary 0/1 string of length 10×Zc (systematic). Label shows (current / max) bits; input exceeding max is truncated on Generate Codeword.