Transport block size calculation
Before transmitting anything, the gNB computes the exact Transport Block Size (TBS) — how many information bits fit into the given resource allocation at the given MCS. This is not a free choice — TS 38.214 defines a precise formula so both the gNB and UE compute identical TBS values.
// Step 1: Count REs available N_PRB = 37 (allocated RBs) N_symb = 12 (allocated OFDM symbols) N_DMRS_RE = 3 (DMRS occupies 3 REs per RB per symbol) N_OH = 0 (no overhead configured) N_RE_bar = 12 × 12 − 3 = 141 (per RB) N_RE = 141 × 37 = 5,217 REs // Step 2: Tentative information bits R = 766/1024 = 0.748 (code rate from MCS table) Q_m = 8 (256-QAM: 8 bits/symbol) N_layers = 1 N_info = N_RE × R × Q_m × N_layers = 5,217 × 0.748 × 8 × 1 = 31,257 bits // Step 3: Quantise to valid TBS (Table 5.1.3.2-2) TBS = 31,112 bits (nearest valid TBS ≤ N_info)
PDSCH transmission chain
Once the TBS is determined, the gNB processes the transport block through a defined chain before transmitting. The UE reverses this chain to recover the original bits.
LDPC encoding — why 5G uses LDPC
5G NR uses LDPC (Low-Density Parity-Check) codes for data channels (PDSCH, PUSCH). LDPC codes are capacity-approaching codes with very efficient iterative decoding. They replaced LTE's Turbo codes due to better performance at high code rates (needed for 256-QAM and beyond) and more parallelisable decoding.
Two base graphs are defined: BG1 for large TBS or high code rates, BG2 for small TBS or low code rates. Our TBS = 31,112 bits and MCS = 20 (high rate) → BG1 is selected.
// Base graph selection: TBS = 31,112, R = 0.748, R > 0.67 and TBS > 3824 → BG1 // BG1: max code block size = 8448 bits // CRC attachment: TBS + 24-bit CRC = 31,136 bits // Code block segmentation: B = 31,136, max CB size K_cb = 8448 C = ceil(B / (K_cb − L)) = ceil(31,136 / 8424) = 4 code blocks // Each code block: K = 7,784 bits (padded to nearest valid LDPC lifting size) Each CB gets 24-bit CRC appended Output of LDPC encoder: N = K × n_LDPC = 7,784 × (66/22) // Total encoded bits before rate matching: Total = 4 × 23,352 = 93,408 bits
Rate matching and modulation
The LDPC encoder produces more bits than can fit in the allocated resources. Rate matching selects the right subset of coded bits to fill exactly the available REs. For retransmissions, a different starting offset (redundancy version RV) is used, sending different parity bits each time.
// Rate matching output: E_r = ceil(N_RE × Q_m × R / C) = ceil(5217 × 8 × 0.748 / 4) = 7,810 bits per CB // Total = 4 × 7810 = 31,240 → rounded to 31,232 bits (multiple of Q_m) // Scrambling: // XOR with PN sequence seeded by: c_init = n_RNTI×2^15 + n_ID c_init = 0x3A7F × 32768 + 442 = 0x74FE01BA // Modulation (256-QAM): 8 bits → 1 complex symbol 31,232 bits / 8 = 3,904 complex symbols // Layer mapping (1 layer): All 3,904 symbols on layer 0 // RE mapping: symbols placed at data REs // (skipping DMRS positions, starting symbol 2)
DMRS — enabling channel estimation
Before the UE can decode the 256-QAM data, it needs accurate channel estimates. PDSCH DMRS (Type 1, mapping type A) are placed at symbol 2, every other subcarrier within the allocated RBs. The pattern is known to both gNB and UE from the DCI antenna port field.