This example shows how 5G Toolbox™ link-level simulations define the signal-to-noise ratio (SNR).
The examples define the SNR as the average SNR per resource element (RE) per receive antenna. REs are defined in the resource grid (that is, in the frequency domain). To achieve the desired SNR, the examples introduce an equivalent noise level in the time domain.
The SNR is defined as
and are the average signal power per RE per receive antenna and the average noise power per RE per receive antenna, respectively. models the AWGN that is added to the signal.
For a signal with discrete Fourier transform (DFT) , Parseval's theorem states
is the FFT length. Divide the equation by to get the average signal power
In 5G, the signal of interest does not use all FFT bins (or REs) because of guard bands or zero padding. Additionally, the signal allocation can occupy only a part of the available grid. If the signal uses only bins (or REs) of the FFT, the signal power is
is the number of nonzero power REs per OFDM symbol.
The signal power per RE is
The noise power per RE is
Because the noise is added in the time domain, the noise occupies all bins, not just the allocated REs. Therefore, the noise power, , is divided by and not .
Considering these definitions, the SNR becomes
The 5G Toolbox link examples assume that , where is the number of receive antennas. This assumption means that the overall received power over all antennas is one.
The noise power at the input of the OFDM demodulator is
To generate noise with power , scale the complex random samples by .
The factor of 2 in this equation accounts for the complex nature of the noise samples.
Most 5G Toolbox examples that model a link use this scaling factor. This scaling factor assumes that the root mean squared of the signal RE values is . This assumption does not always apply when using a propagation channel.
The propagation channel introduces a number of effects, such as correlation, antenna polarization, and antenna element gain. These channel effects can impact the signal power at the receiver. These effects make estimating the SNR at the receiver and setting up a simulation to model a specific SNR difficult. To overcome this difficulty, the SNR definition in the link examples does not consider any of the channel effects. The SNR definition matches the SNR that is measured without a fading channel and when .
NormalizeChannelOutputs property of the channel objects to
true normalizes the channel outputs by the number of receive antennas such that , as assumed in the derivation.
NormalizePathGains property of the channel objects to
true sets the total power of the average path gains to 0 dB.
The SNR definition does not consider any of the channel effects.
This section verifies the equation that is derived in the previous section. Because the introduced SNR definition does not take into account any of the channel effects, this verification does not include a propagation channel.
This figure shows the setup to measure the SNR per RE per antenna.
This setup implements these steps.
Generate a resource grid with physical downlink shared channel (PDSCH) symbols.
OFDM-modulate the grid.
OFDM-demodulate the received signal and the noise separately.
Measure the power of the signal and the noise per RE per antenna.
Calculate and display the SNR.
Specify the desired SNR in dB.
SNRdB = 0; rng("default") % Set default random number generator for repeatability
Set the number of transmit and receive antennas. Because no channel exists, assume that the number of transmit and receive antennas is the same.
nTxAnts = 2; nRxAnts = nTxAnts;
Specify the carrier parameters.
carrier = nrCarrierConfig; carrier.NSizeGrid = 52; % Grid size in resource blocks carrier.SubcarrierSpacing = 15; % Subcarrier spacing waveformInfo = nrOFDMInfo(carrier); % Waveform information pdsch = nrPDSCHConfig; pdsch.Modulation = "16QAM"; pdsch.PRBSet = 0:(carrier.NSizeGrid-1); % PDSCH allocation
Create a norm-one precoding vector that is normalized by the number of layers.
w = (1/sqrt(pdsch.NumLayers))*ones(pdsch.NumLayers,nTxAnts);
To achieve the desired SNR, calculate the noise scaling factor: .
SNR = 10^(SNRdB/10); N0 = 1/sqrt(2.0*nRxAnts*double(waveformInfo.Nfft)*SNR);
Generate precoded PDSCH symbols.
[pdschIndices,pdschInfo] = nrPDSCHIndices(carrier,pdsch); pdschBits = randi([0 1],pdschInfo.G,1); pdschSymbols = nrPDSCH(carrier,pdsch,pdschBits); pdschSymbolsPrecoded = pdschSymbols*w;
Create a resource grid and map the precoded PDSCH symbols to the resource grid.
pdschGrid = nrResourceGrid(carrier,nTxAnts); [~,pdschAntIndices] = nrExtractResources(pdschIndices,pdschGrid); pdschGrid(pdschAntIndices) = pdschSymbolsPrecoded;
txWaveform = nrOFDMModulate(carrier,pdschGrid);
Assume no channel exists. Because the SNR definition assumes that , normalize the received signal by the number of receive antennas.
rxWaveform = txWaveform/sqrt(nRxAnts);
rxNoise = N0*complex(randn(size(rxWaveform)),randn(size(rxWaveform)));
OFDM-demodulate the noise and signal separately to measure the power of the received signal and noise independently. Extract the PDSCH symbols from the received grid.
% OFDM demodulation rxSignalGrid = nrOFDMDemodulate(carrier,rxWaveform); rxNoiseGrid = nrOFDMDemodulate(carrier,rxNoise); % PDSCH symbols extraction rxPDSCHSymbols = rxSignalGrid(pdschAntIndices);
Measure the received signal power per RE, , and the noise power per RE, .
Verify that the measured SNR values approximate the specified SNR parameter.
Sre = (1/waveformInfo.Nfft.^2)*rms(rxPDSCHSymbols).^2; Nre = (1/waveformInfo.Nfft)*rms(rxNoise).^2; for n=1:nRxAnts disp("Received signal power per RE antenna " + string(n) + " = " + string(pow2db(Sre(n))+30) + " dBm"); disp("Received noise power per RE antenna " + string(n) + " = " + string(pow2db(Nre(n))+30) + " dBm"); disp("SNR (antenna " + string(n) + ") = " + string(pow2db(Sre(n)/Nre(n))) + " dB"); end
Received signal power per RE antenna 1 = -33.186 dBm
Received noise power per RE antenna 1 = -33.2432 dBm
SNR (antenna 1) = 0.057195 dB
Received signal power per RE antenna 2 = -33.186 dBm
Received noise power per RE antenna 2 = -33.2371 dBm
SNR (antenna 2) = 0.051146 dB