Contents
Sionna OFDM Processing (ofdm/): Resource Grid, Modulation/Demodulation, and Channel Estimation
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
| File | Function | Main Public Classes/Functions |
|---|---|---|
__init__.py | Entry point of the OFDM subpackage | Re-exports symbols from all submodules |
resource_grid.py | Resource grid definition and mapping | ResourceGrid, ResourceGridMapper, ResourceGridDemapper, RemoveNulledSubcarriers |
modulator.py | OFDM modulator | OFDMModulator(Block): resource grid → time domain (IFFT + CP insertion) |
demodulator.py | OFDM demodulator | OFDMDemodulator(Block): CP removal, FFT, and compensation of the subcarrier phase introduced by l_min |
pilot_pattern.py | Pilot patterns | PilotPattern (composed of mask and pilots), EmptyPilotPattern, KroneckerPilotPattern |
channel_estimation.py | Channel estimation and interpolation | BaseChannelEstimator, LSChannelEstimator, BaseChannelInterpolator, NearestNeighborInterpolator, LinearInterpolator, LMMSEInterpolator1D, SpatialChannelFilter, LMMSEInterpolator, tdl_freq_cov_mat, tdl_time_cov_mat |
detection.py | OFDM channel detection | OFDMDetector, OFDMDetectorWithPrior, MaximumLikelihoodDetector, MaximumLikelihoodDetectorWithPrior, LinearDetector, KBestDetector, EPDetector, MMSEPICDetector |
equalization.py | OFDM channel equalization | OFDMEqualizer, LMMSEEqualizer, ZFEqualizer, MFEqualizer, PostEqualizationSINR, LMMSEPostEqualizationSINR |
precoding.py | OFDM transmit precoding | RZFPrecoder, 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 -th sample is
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=Truenulls the DC subcarrier;pilot_pattern="kronecker"combined withpilot_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_symbolsis 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:
Since pilots occupy only a small fraction of the resource elements, the remaining positions must be filled in by interpolation:
| Interpolator | Characteristics |
|---|---|
NearestNeighborInterpolator | Nearest neighbor, fastest, worst performance |
LinearInterpolator | Linear interpolation in time and/or frequency |
LMMSEInterpolator1D | 1-D LMMSE, requires a frequency-domain or time-domain covariance matrix |
LMMSEInterpolator | 2-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/:
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;modulator.py/demodulator.py— watch out for thel_minphase-compensation pitfall;channel_estimation.py— the LS formula is trivial; the real point is matching the interpolator with the covariance matrices;equalization.py/detection.py— the interface is unified as(y, h_hat, err_var, no); compare it against themimo/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…
Want to leave a note? Sign in first — comments are open to every signed-in reader.