Contents

Sionna OFDM Processing (ofdm/): Resource Grid, Modulation/Demodulation, and Channel Estimation

OFDM & NR
#Sionna#OFDM#channel-estimation#resource-grid

ofdm/ handles waveform-level processing: it maps bits onto a two-dimensional time–frequency grid and then transforms them into time-domain samples. Its data model is the resource grid ResourceGrid, whose shape is conventionally written as [batch, num_tx, num_streams, num_ofdm_symbols, fft_size].

1. Files and Responsibilities

FileFunctionMain Public Classes/Functions
__init__.pyEntry point of the OFDM subpackageRe-exports symbols from all submodules
resource_grid.pyResource grid definition and mappingResourceGrid, ResourceGridMapper, ResourceGridDemapper, RemoveNulledSubcarriers
modulator.pyOFDM modulatorOFDMModulator(Block): resource grid → time domain (IFFT + CP insertion)
demodulator.pyOFDM demodulatorOFDMDemodulator(Block): CP removal, FFT, and compensation of the subcarrier phase introduced by l_min
pilot_pattern.pyPilot patternsPilotPattern (composed of mask and pilots), EmptyPilotPattern, KroneckerPilotPattern
channel_estimation.pyChannel estimation and interpolationBaseChannelEstimator, LSChannelEstimator, BaseChannelInterpolator, NearestNeighborInterpolator, LinearInterpolator, LMMSEInterpolator1D, SpatialChannelFilter, LMMSEInterpolator, tdl_freq_cov_mat, tdl_time_cov_mat
detection.pyOFDM channel detectionOFDMDetector, OFDMDetectorWithPrior, MaximumLikelihoodDetector, MaximumLikelihoodDetectorWithPrior, LinearDetector, KBestDetector, EPDetector, MMSEPICDetector
equalization.pyOFDM channel equalizationOFDMEqualizer, LMMSEEqualizer, ZFEqualizer, MFEqualizer, PostEqualizationSINR, LMMSEPostEqualizationSINR
precoding.pyOFDM transmit precodingRZFPrecoder, PrecodedChannel, RZFPrecodedChannel, CBFPrecodedChannel, EyePrecodedChannel

The classes in detection.py and equalization.py also have same-named counterparts under mimo/, and the difference lies in the interfaces (see the MIMO processing article): the OFDM versions require resource_grid and stream_management, and their input is (y, h_hat, err_var, no).

The design of precoding.py is rather special: classes like PrecodedChannel bundle “precoding + channel” into a single composite channel, so that the receiver can reuse the same detector without caring about what processing happened on the transmit side.

2. OFDM Modulation and Demodulation

The modulation side is simply an IFFT plus a cyclic prefix; the nn-th sample is

x[n]=1N∑k=0N−1X[k] ej2πkn/N,n=0,…,N+Ncp−1x[n] = \frac{1}{\sqrt{N}} \sum_{k=0}^{N-1} X[k] \, e^{j 2\pi k n / N}, \quad n = 0, \dots, N + N_{cp} - 1

On the demodulation side, the CP is removed and an FFT is performed. Key detail: if the time-domain taps contain negative delays (l_min < 0), the frequency domain acquires a phase ramp that grows linearly with the subcarrier index; the l_min parameter of OFDMDemodulator exists precisely to compensate for it—when constructing the demodulator, l_min must match the one used when generating the channel, otherwise you end up with a channel estimate corrupted by a phase rotation.

import torch
from sionna.phy.ofdm import OFDMModulator, OFDMDemodulator

modulator = OFDMModulator(cyclic_prefix_length=16)
demodulator = OFDMDemodulator(fft_size=72, l_min=0, cyclic_prefix_length=16)

x_freq = torch.randn(64, 14, 72, dtype=torch.complex64)
x_time = modulator(x_freq)     # [64, 1232]
x_hat = demodulator(x_time)    # Restored to [64, 14, 72]

The output length 1232 = 14 × (72 + 16) is exactly “FFT size plus CP length per symbol, times the number of symbols”.

3. Resource Grid

from sionna.phy.ofdm import ResourceGrid, ResourceGridMapper
from sionna.phy.mapping import QAMSource

rg = ResourceGrid(num_ofdm_symbols=14, fft_size=64, subcarrier_spacing=30e3,
                  num_guard_carriers=[5, 6], dc_null=True,
                  pilot_pattern="kronecker", pilot_ofdm_symbol_indices=[2, 11])
rg.show()

mapper = ResourceGridMapper(rg)
qam = QAMSource(4)
x = qam([32, 1, 1, rg.num_data_symbols])
rg_mapped = mapper(x)          # [32, 1, 1, 14, 64]

A few key points:

  • num_guard_carriers=[5, 6] are the guard bands on the left and right sides; dc_null=True nulls the DC subcarrier;
  • pilot_pattern="kronecker" combined with pilot_ofdm_symbol_indices=[2, 11] uses two full OFDM symbol rows as pilots, which is the most common comb-type + Kronecker structure;
  • rg.num_data_symbols is the number of available resource elements after subtracting pilots, guard bands, and the DC subcarrier; before mapping data you must generate exactly this many symbols;
  • rg.show() plots the grid, which is very handy while tuning parameters.

4. Channel Estimation

LSChannelEstimator first performs a least-squares estimate at the pilot positions:

h^LS[k,l]=y[k,l]xpilot[k,l]\hat{h}_{\text{LS}}[k, l] = \frac{y[k, l]}{x_{\text{pilot}}[k, l]}

Since pilots occupy only a small fraction of the resource elements, the remaining positions must be filled in by interpolation:

InterpolatorCharacteristics
NearestNeighborInterpolatorNearest neighbor, fastest, worst performance
LinearInterpolatorLinear interpolation in time and/or frequency
LMMSEInterpolator1D1-D LMMSE, requires a frequency-domain or time-domain covariance matrix
LMMSEInterpolator2-D LMMSE, joint time–frequency filtering, best performance

LMMSE interpolation requires the channel covariance, and Sionna directly provides utilities that compute the covariance matrices analytically from TDL models:

from sionna.phy.ofdm import (ResourceGrid, LSChannelEstimator, LMMSEInterpolator,
                             tdl_freq_cov_mat, tdl_time_cov_mat)

rg = ResourceGrid(num_ofdm_symbols=14, fft_size=64, subcarrier_spacing=30e3,
                  num_tx=1, num_streams_per_tx=1,
                  pilot_pattern="kronecker", pilot_ofdm_symbol_indices=[2, 11])

cov_mat_freq = tdl_freq_cov_mat("A", 30e3, 64, 100e-9)
cov_mat_time = tdl_time_cov_mat("A", 3.0, 3.5e9, 35.7e-6, 14)
interpolator = LMMSEInterpolator(rg.pilot_pattern, cov_mat_time, cov_mat_freq,
                                 order="f-t")
estimator = LSChannelEstimator(rg, interpolator=interpolator)

h_hat, err_var = estimator(y, no)     # y is the received resource grid, no is the noise power

order="f-t" means the 2-D factorization is done frequency-first, then time. Here you must pass the TDL model name, subcarrier spacing, FFT size, and delay spread/Doppler together, because they determine the channel’s correlation in time and frequency—if these parameters do not match the actual channel, the performance advantage of LMMSE shrinks dramatically.

The err_var returned by the estimator is not just a statistic shown to the user: it is fed as-is into the detector/equalizer as the weight of the channel uncertainty. This is the biggest difference between OFDM link design and calling mimo/ standalone.

5. Equalization and Detection

import numpy as np
import torch
from sionna.phy.ofdm import ResourceGrid, LMMSEEqualizer, LinearDetector
from sionna.phy.mimo import StreamManagement

rg = ResourceGrid(num_ofdm_symbols=14, fft_size=64, subcarrier_spacing=30e3,
                  num_tx=2, num_streams_per_tx=2,
                  pilot_pattern="kronecker", pilot_ofdm_symbol_indices=[2, 11])
sm = StreamManagement(np.ones([1, 2]), 2)

# LMMSE equalization: input (y, h_hat, err_var, no)
equalizer = LMMSEEqualizer(rg, sm)
x_hat, no_eff = equalizer(y, h_hat, err_var, no)

# Linear detection (outputs bit LLRs; the OFDM version takes rg and sm as positional arguments)
detector = LinearDetector("lmmse", "bit", "app", rg, sm,
                          constellation_type="qam", num_bits_per_symbol=4)
llr = detector(y, h_hat, err_var, no)

StreamManagement plays the same role here as in mimo/, except the parameter form is simplified to “which transmitters does each receiver receive” (np.ones([1, 2]) means a single receiver receives all streams from 2 transmitters).

6. Summary

Recommended learning order for ofdm/:

  1. resource_grid.py — first understand how the resource elements are laid out and how pilots occupy them; every downstream module uses it as its coordinate system;
  2. modulator.py / demodulator.py — watch out for the l_min phase-compensation pitfall;
  3. channel_estimation.py — the LS formula is trivial; the real point is matching the interpolator with the covariance matrices;
  4. equalization.py / detection.py — the interface is unified as (y, h_hat, err_var, no); compare it against the mimo/ versions.

The next article takes this whole stack onto concrete 5G NR configurations and shows how nr/ strings it into an end-to-end transceiver chain.

Comments

Loading comments…

    ← Back to home