This example shows how to measure the error vector magnitude (EVM) of NR test model (NR-TM) or fixed reference channel (FRC) waveforms. The example also shows how to add impairments including phase noise and memoryless nonlinearity.
For base station RF testing, the 3GPP 5G NR standard defines a set of NR-TM waveforms. For user equipment (UE) testing, the standard defines a set of FRC waveforms. The NR-TMs and FRCs for frequency range 1 (FR1) are defined in TS 38.141-1 while the NR-TMs and FRCs for frequency range 2 (FR2) are defined in TS 38.141-2.
This example shows how to generate an NR waveform (TM or FRC) and add impairments. Here we consider phase noise and memoryless nonlinearities. We then calculate the EVM of the resulting signal. We plot the RMS and peak EVMs per OFDM symbol, slot, and subcarrier. We also calculate the overall EVM (RMS EVM averaged over the complete waveform). Annex B and Annex C of TS 38.104 define an alternative method for computing the EVM in FR1 and FR2, respectively. The figure below shows the processing chain implemented in this example.
Each NR-TM or FRC waveform is defined by a combination of:
NR-TM/FRC name
Channel bandwidth
Subcarrier spacing
Duplexing mode
% Select one of the Release 15 NR-TMs for FR1 and FR2 among: % "NR-FR1-TM1.1","NR-FR1-TM1.2","NR-FR1-TM2", % "NR-FR1-TM2a","NR-FR1-TM3.1","NR-FR1-TM3.1a", % "NR-FR1-TM3.2","NR-FR1-TM3.3","NR-FR2-TM1.1", % "NR-FR2-TM2","NR-FR2-TM3.1" % or % Select one of the Release 15 FRCs for FR1 and FR2 among: % "DL-FRC-FR1-QPSK","DL-FRC-FR1-64QAM", % "DL-FRC-FR1-256QAM","DL-FRC-FR2-QPSK", % "DL-FRC-FR2-16QAM","DL-FRC-FR2-64QAM" rc = "NR-FR1-TM3.2"; % Reference channel (NR-TM or FRC) % Select the NR waveform parameters bw = "10MHz"; % Channel bandwidth scs = "30kHz"; % Subcarrier spacing dm = "FDD"; % Duplexing mode
For TMs, the generated waveform may contain more than one PDSCH. The chosen PDSCH to analyse is based on the RNTI. By default, the following RNTIs are considered for EVM calculation:
NR-FR1-TM2: RNTI = 2 (64QAM EVM)
NR-FR1-TM2a: RNTI = 2 (256QAM EVM)
NR-FR1-TM3.1: RNTI = 0 and 2 (64QAM EVM)
NR-FR1-TM3.1a: RNTI = 0 and 2 (256QAM EVM)
NR-FR1-TM3.2: RNTI = 1 (16QAM EVM)
NR-FR1-TM3.3: RNTI = 1 (QPSK EVM)
NR-FR2-TM2: RNTI = 2 (64QAM EVM)
NR-FR2-TM3.1: RNTI = 0 and 2 (64QAM EVM)
As per the specifications (TS 38.141-1, TS 38.141-2), these TMs are not designed to perform EVM measurements: NR-FR1-TM1.1, NR-FR1-TM1.2, NR-FR2-TM1.1. However, if you generate these TMs, the example measures the EVM for the following RNTIs.
NR-FR1-TM1.1: RNTI = 0 (QPSK EVM)
NR-FR1-TM1.2: RNTI = 2 (QPSK EVM)
NR-FR2-TM1.1: RNTI = 0 (QPSK EVM)
For FRCs, by default, RNTI 0 is considered for EVM calculation. In case the input waveform is neither a TM nor an FRC waveform, atmost one layer is supported for EVM measurement.
The example calculates the EVM for the RNTIs listed above. To override the default RNTIs, specify the targetRNTIs
vector
targetRNTIs = [];
To print EVM statistics, set displayEVM
to true
. To disable the prints, set displayEVM
to false
. To plot EVM statistics, set plotEVM
to true
. To disable the plots, set plotEVM
to false
displayEVM = true; plotEVM = true;
if displayEVM fprintf('Reference Channel = %s\n', rc); end
Reference Channel = NR-FR1-TM3.2
To measure EVM as defined in TS 38.104, Annex B(FR1) / Annex C(FR2), set evm3GPP
to true
. evm3GPP
is disabled by default.
evm3GPP = false;
Create waveform generator object and generate the waveform
tmwavegen = hNRReferenceWaveformGenerator(rc,bw,scs,dm); [txWaveform,tmwaveinfo,resourcesinfo] = generateWaveform(tmwavegen,tmwavegen.Config.NumSubframes);
This example considers two impairments: phase noise and memoryless nonlinearity. Enable or disable impairments by toggling the flags phaseNoiseOn
and nonLinearityModelOn
.
phaseNoiseOn = true; nonLinearityModelOn = true;
Normalize the waveform to fit the dynamic range of the nonlinearity.
txWaveform = txWaveform/max(abs(txWaveform),[],'all');
The waveform consists of one frame for FDD and two for TDD. Repeat the signal twice. We will remove the first half of the resulting waveform to avoid the transient introduced by the phase noise model.
txWaveform = repmat(txWaveform,2,1);
Introduce phase noise distortion. The figure shows the phase noise characteristic. The carrier frequency considered depends on the frequency range. We use values of 4 GHz and 28 GHz for FR1 and FR2 respectively. The phase noise characteristic is generated with the pole/zero model described in R1-163984, "Discussion on phase noise modeling".
if phaseNoiseOn sr = tmwaveinfo.Info.SamplingRate; % Carrier frequency if tmwavegen.Config.FrequencyRange == "FR1" % carrier frequency for FR1 fc = 4e9; else % carrier frequency for FR2 fc = 30e9; end % Calculate the phase noise level. foffsetLog = (4:0.1:log10(sr/2)); % model offset from 1e3Hz to sr/2 foffset = 10.^foffsetLog; % linear freq offset PN_dBc_Hz = hPhaseNoisePoleZeroModel(foffset,fc,'C'); figure; semilogx(foffset,PN_dBc_Hz); xlabel('Frequency offset (Hz)'); ylabel('dBc/Hz'); title('Phase noise model'); grid on % Apply phase noise to waveform pnoise = comm.PhaseNoise('FrequencyOffset',foffset,'Level',PN_dBc_Hz,'SampleRate',sr); pnoise.RandomStream = "mt19937ar with seed"; rxWaveform = zeros(size(txWaveform),'like',txWaveform); for i = 1:size(txWaveform,2) rxWaveform(:,i) = pnoise(txWaveform(:,i)); release(pnoise) end else rxWaveform = txWaveform; %#ok<UNRCH> end
Introduce nonlinear distortion. For this example, use the Rapp model. The figure shows the nonlinearity introduced. Set the parameters for the Rapp model to match the characteristics of the memoryless model from TR 38.803 "Memoryless polynomial model - Annex A.1".
if nonLinearityModelOn rapp = comm.MemorylessNonlinearity('Method','Rapp model'); rapp.Smoothness = 1.55; rapp.OutputSaturationLevel = 1; % Plot nonlinear characteristic plotNonLinearCharacteristic(rapp); % Apply nonlinearity for i = 1:size(rxWaveform,2) rxWaveform(:,i) = rapp(rxWaveform(:,i)); release(rapp) end end
The signal was previously repeated twice. Remove the first half of this signal. This avoids any transient introduced by the impairment models.
if dm == "FDD" nFrames = 1; else % TDD nFrames = 2; end rxWaveform(1:nFrames*tmwaveinfo.Info.SamplesPerSubframe*10,:) = [];
The function, hNRPDSCHEVM, performs these steps to decode and analyze the waveform:
Synchronization using the DM-RS over one frame for FDD (two frames for TDD)
OFDM demodulation of the received waveform
Channel estimation
Equalization
Common Phase error (CPE) estimation and compensation
PDSCH EVM computation (enable the switch evm3GPP
, to process according to the EVM measurement requirements specified in TS 38.104, Annex B (FR1) / Annex C (FR2)).
The example measures and outputs various EVM related statistics per symbol, per slot, and per frame peak EVM and RMS EVM. The example displays EVM for each slot and frame. It also displays the overall EVM averaged over the entire input waveform. The example produces a number of plots: EVM vs per OFDM symbol, slot, subcarrier, and overall EVM. Each plot displays the peak vs RMS EVM.
cfg = struct();
cfg.Evm3GPP = evm3GPP;
cfg.TargetRNTIs = targetRNTIs;
cfg.PlotEVM = plotEVM;
cfg.DisplayEVM = displayEVM;
cfg.Label = tmwavegen.ConfiguredModel{1};
% Compute and display EVM measurements
[evmInfo,eqSym,refSym] = hNRPDSCHEVM(tmwavegen.Config,rxWaveform,cfg);
RMS EVM, Peak EVM, slot 0: 3.929 20.636% RMS EVM, Peak EVM, slot 1: 3.779 13.962% RMS EVM, Peak EVM, slot 2: 3.683 10.465% RMS EVM, Peak EVM, slot 3: 3.679 12.549% RMS EVM, Peak EVM, slot 4: 4.169 17.878% RMS EVM, Peak EVM, slot 5: 4.053 17.728% RMS EVM, Peak EVM, slot 6: 3.960 15.706% RMS EVM, Peak EVM, slot 7: 4.031 14.790% RMS EVM, Peak EVM, slot 8: 3.799 14.443% RMS EVM, Peak EVM, slot 9: 3.803 12.730% RMS EVM, Peak EVM, slot 10: 3.946 14.595% RMS EVM, Peak EVM, slot 11: 3.661 14.484% RMS EVM, Peak EVM, slot 12: 3.773 13.534% RMS EVM, Peak EVM, slot 13: 3.930 17.440% RMS EVM, Peak EVM, slot 14: 3.754 12.184% RMS EVM, Peak EVM, slot 15: 3.832 17.780% RMS EVM, Peak EVM, slot 16: 3.774 14.530% RMS EVM, Peak EVM, slot 17: 3.950 14.131% RMS EVM, Peak EVM, slot 18: 3.948 18.886% RMS EVM, Peak EVM, slot 19: 3.871 13.786% Averaged RMS EVM frame 0: 3.868% Averaged overall RMS EVM: 3.868% Overall Peak EVM = 20.6363%
function plotNonLinearCharacteristic(memoryLessNonlinearity) % Plot the nonlinear characteristic of the power amplifier (PA) impairment % represented by the input parameter memoryLessNonlinearity, which is a % comm.MemorylessNonlinearity Communications Toolbox(TM) System object. % Input samples x = complex((1/sqrt(2))*(-1+2*rand(1000,1)),(1/sqrt(2))*(-1+2*rand(1000,1))); % Nonlinearity yRapp = memoryLessNonlinearity(x); % Release object to feed it a different number of samples release(memoryLessNonlinearity); % Plot characteristic figure; plot(10*log10(abs(x).^2),10*log10(abs(x).^2)); hold on; grid on plot(10*log10(abs(x).^2),10*log10(abs(yRapp).^2),'.'); xlabel('Input Power (dBW)'); ylabel('Output Power (dBW)'); title('Nonlinearity Impairment') legend('Linear characteristic', 'Rapp nonlinearity','Location','Northwest'); end