物理层 手册专题 1,745 字

Matlab:默认函数:LTE 上行(SC-FDMA)解调(含 DMRS 分析)——1RB

本页是前一篇教程的延伸:LTE 上行SC-FDMA解调不含 DMRS 分析。在那篇教程中,我们有两个重要的前提条件。

采集:2026-11-18T02:08:45+08:00 · 查看英文原文 ↗

原始来源:https://www.sharetechnote.com/html/Handbook_LTE_UL_Demodulation_DMRS_1RB_Ex01.html

正文

本页是前一篇教程的延伸:LTE 上行(SC-FDMA)解调(不含 DMRS 分析)。在那篇教程中,我们有两个重要的前提条件。

i) 定时同步

ii) 解调后的相位补偿

本页将展示如何从 PUSCH DMRS 数据中得到这些项(实际上是相位与幅度两者的补偿)。这里使用的 I/Q 数据同样由真实硬件(矢量信号发生器)产生,并由矢量信号分析仪带特殊同步信号采集。因此你不必实现同步算法以及大量补偿——那对一个示例来说负担过重。如果你有兴趣以入门水平从事 LTE DSP 工作,这也可以提供帮助或动力。

接收机知道 UE 发送的 DMRS,因为小区标识和时隙号就确定了它。把接收到的 DMRS 除以已知的那个,就得到各子载波上的信道,该估计随后用于校正同一时隙的数据符号。本页对一个 RB 的 PUSCH 做这件事。

本节涵盖的主题如下。

  • 结果
  • 数据的 LTE 配置
  • Matlab 代码
  • 均衡是如何工作的?
  • 参考资料 一个 DMRS 符号能把解调改善多少?下图把不含 DMRS 的结果与含 DMRS 的结果并列,针对时隙 0 的七个 SC-FDMA 符号。每一行是一个符号,图的左半与右半分别是两种情形。

下面是此处所列 Matlab 源代码的结果。(A) 显示子帧 0 第一个时隙内各符号 IFFT 结果的幅度,这是未用 DMRS 补偿的情形。(B) 是 (A) 的 I/Q 图(实部与虚部)。(C) 显示用 DMRS 补偿(均衡)后子帧 0 第一个时隙内各符号 IFFT 结果的幅度。(D) 是 (C) 的 I/Q 图。

时隙 0 七个 SC-FDMA 符号在基于 DMRS 的均衡前后的 PUSCH 1 RB 解调结果

图注:时隙 0 七个 SC-FDMA 符号在基于 DMRS 的均衡前后的 PUSCH 1 RB 解调结果

列 (A)、(B) 是均衡前,列 (C)、(D) 是均衡后。第四行是 DMRS 符号本身。

  • 均衡前:列 (A) 的幅度起伏,列 (B) 的点散布在旋转后的点簇周围。
  • 均衡后:列 (C) 的幅度平坦,列 (D) 显示四个干净的 QPSK 点。
  • 第四行即 DMRS:在列 (A) 和 (C) 中平坦,在列 (B) 和 (D) 中为圆周上的若干点。 第四行说明了均衡为何有效。其列 (A) 是平坦的,因此接收到的 DMRS 在全部 12 个子载波上幅度相同;也就是说,信道在整个 RB 上主要改变相位而不是幅度。从一个子载波到下一个子载波发生变化的相位(例如小时偏偏差造成的相位斜率)会在 IFFT 之后把相邻的 QPSK 符号混在一起,这种混叠正是列 (A) 中的起伏和列 (B) 中的发散。

DMRS 行未经变换预编码,因此代码对其跳过 IFFT。于是列 (D) 显示的是 DMRS 序列本身,其点落在圆周上而不是四个 QPSK 位置。DMRS - PUSCH - 1RB 页面给出了小区 ID 0 时的同一序列。

  • DMRS 幅度平坦:信道在整个 RB 上主要旋转相位。
  • 起伏来自相位斜率:相位未校正时 IFFT 会把相邻符号混在一起。
  • 一个 DMRS 符号校正整个时隙:六个数据符号共用同一个估计。 配置清单分为两半。前四项足以完成解调,后三项确定均衡所比对的 DMRS 序列。

本例使用的数据来自以下 LTE 配置。如果不考虑补偿过程(均衡过程),只有前四项才重要;后三个参数用于 DMRS 分析。RB 数与 StartRB 对解调和补偿两个过程都用得到。

  • 系统带宽 = 5 MHz
  • 采样率 = 7.68 MHz
  • RB 数 = 1
  • 起始 RB = 0
  • 物理小区 ID = 0
  • 子帧号 = 0
  • 时隙号 = 0 起始 RB = 0 把该 RB 放在 25 RB 载波的下边缘。经过 7.5 kHz 搬移和 fftshift 之后,300 个子载波中最低的那个落在从 1 开始计数的第 257 - 150 = 107 个频点,这就是代码取第 107 至 118 个频点的原因。不同的起始 RB 会使该窗口每个 RB 移动 12 个频点。

物理小区 ID = 0 在关闭组跳变时给出组 u = 0。时隙 0 随后给出 ncs = 4、α = 2π/3,与 DMRS - PUSCH - 1RB 页面的计算一致。代码中的 DMRS 向量使用 36.211 v19.3.0 表 5.5.1.2-1 的第 0 行,与该计算逐值相符。

  • 第 107 至 118 个频点:起始 RB = 0,即 300 个子载波中最低的 12 个。
  • u = 0、ncs = 4:小区 ID 0、时隙 0,且 cyclicShift 与 DCI 循环移位均为 0。
  • DMRS 向量与表 5.5.1.2-1 一致:第 0 行,每个子载波按 α = 2π/3 旋转。 与 LTE 上行(SC-FDMA)解调页面相比,代码多了一个新块:它先解调 DMRS 符号、据此算出 EqFactor,然后在 IFFT 之前把 EqFactor 应用于该时隙的每个符号。

下面是产生上图结果的 Matlab 源代码。代码有意写得较长。如果用 for 循环,我本可以把它写得非常短,但那样反而更难理解。因此我尽量把每个过程一步步写出。希望即使它看起来稍显冗长,你也能更容易跟上。

clear all;

% you can download the data file in this example from here.

% this is for reading the baseband IQ data of OFDM symbol in time domain.

% detailed explantion for this three line and file format in this example is described in

% Matlab : Read Number in Binary file page.

fid = fopen(‘LTE_UL_5_1_CID_0_1RB_NoFilter.bin’,‘r’);

[data,count] = fread(fid, ‘single’);

fclose(fid);

% This variable represents the first sample in the first SCFDM symbol.

% How do I know this ? This is just a magic number I could figure out from the vector signal

% analyzer. Just think this is just a given number. If you seriously want to work in this

% area, try to implement the algorithm to find this number on your own.

Offset = 280228;

% Nfft represents the FFT size for the specified system bandwidth. 512 is the FFT size for

% 5 Mhz System Bandwidth.

Nfft = 512;

% N_RB is the number of RB assinged to this signal. N_RE is the number of Resource Elements

% in this signal and can be calculated from N_RB. This N_RE determines the IFFT size in

% demodulation process (N_RE is the size of IFFT)

N_RB = 1;

N_RE = N_RB * 12;

% SamplingScale is to figure out the number of samples in CP and OFDM Symbol for each specific system

% Bandwidth from the 20 Mhz Bandwidth. Physical Layer Parameters - FDD, Downlink will help you understand

% the meaning of each numbers here.

SamplingScale = (double(Nfft)/2048);

CP_LengthList = SamplingScale * [160;144;144;144;144;144;144];

Symbol_LengthList = SamplingScale * [2048;2048;2048;2048;2048;2048;2048];

% This is to generate a complex numbered sequence to shift the frequency of the I/Q signal by 7.5 Khz

% the number of samples of this data is same as the number of samples of each SC-FDM symbol.

Ts = 1.0/(7.68 * 10^6);

t = linspace(0,Nfft-1,Nfft);

t = t .* Ts;

Fshift = 7.5 * 1000 ;

FrequencyShift = exp(j2piFshiftt);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Calculate Equalization Factor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This would be the main part of this tutorial. I would calculate Equalization Factor

% basically by comparing the ideal DMRS generated from the Physical Cell ID, Number of RB,

% Slot Number and the algorithm described in PUSCH DMRS page.

% In this tutorial, I manually copied DMRS data using the algorithm described in PUSCH DMRS

% with Physical Cell ID = 0, Number of RB = 1, Slot Number 0.

DMRS = [0.7071-0.7071i -0.9659+0.2588i 0.9659+0.2588i -0.7071-0.7071i -0.2588-0.9659i …

0.9659+0.2588i 0.7071+0.7071i -0.9659+0.2588i 0.9659+0.2588i 0.7071+0.7071i …

0.9659-0.2588i 0.9659+0.2588i];

% Taking the inverse of DMRS

DMRS_Inv = 1 ./ DMRS;

% Taking out PUSCH DMRS Symbol from the slots and Demodulate.

ChunkStart = Offset …

  • CP_LengthList(1) + Symbol_LengthList(1) …

  • CP_LengthList(2) + Symbol_LengthList(2) …

  • CP_LengthList(3) + Symbol_LengthList(3) …

  • CP_LengthList(4);

ChunkLength = Symbol_LengthList(4);

DataChunk = data((2.* ChunkStart)-1 : (2.*(ChunkStart+ChunkLength)-2));

DataChunkI = DataChunk(1:2:length(DataChunk));

DataChunkQ = DataChunk(2:2:length(DataChunk));

DataChunkComplex = DataChunkI + j*DataChunkQ;

DataChunkFFT = fftshift(fft(DataChunkComplex .* FrequencyShift’));

DataChunkFFT_RE = DataChunkFFT(107:107+(N_RE-1));

% Calculating Equalization Factor by multiplying DMRS_Inv with the demodulated DMRS.

% Very important thing : For transposing DataChunkFFT_RE don’t use (’). I need just mechanical

% transposition of DataChunkFFT_RE to make the two vectors multiplicable, but if you use (’)

% it does not only transpose but also taking the complex conjugate of each element, meaning

% it takes Hermitian transposition which would give you completely unexpected result in this

% case. It took me a couple hours to realize this. (I am using Matlab 2014 for this page)

EqFactor = DMRS_Inv .* transpose(DataChunkFFT_RE);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demoulate the symbol 0 within the slot 0 of Subframe 0.

% ChuckStart here indicates the index(position) of the first sample within the binary file.

% You would notice that I skip the first CP length. This is the same effect of removing the

% first CP as described in CP removal described in RE Map to/from Antenna page.

  • CP_LengthList(1);

% This variable indicates the number of samples within the first OFDM symbol excluding the CP

ChunkLength = Symbol_LengthList(1);

% This is to read I/Q data pair.

% This is to separate I and Q into a separate array (vector)

% This is to combine I array and Q array into a complex number array.

% This is to convert the time domain OFDM symbol into the frequency domain. Note that the data

% is shifted in frequency domain. Unlike the previous example : PUSCH Demodulation (without

% compensation with DMRS), I did fftshift() in this example. For me, it is easier to take out

% the subcarries allocated for allocated RB. But if you think, the previous method is easier

% for you, go for it.

% This is to take out the data samples which will be mapped to each resource element

% within the symbol

% Taking the IFFT and normalize to get normalized I/Q

DataChunkFFT_IFFT = ifft(DataChunkFFT_RE);

DataChunkFFT_IFFT_Norm = DataChunkFFT_IFFT/max(abs(DataChunkFFT_IFFT));

% Plot the normalized I/Q in frequency domain. This is the data before compensation

subplot(7,6,[1 2]);

plot(abs(DataChunkFFT_IFFT_Norm));xlim([1, length(DataChunkFFT_IFFT_Norm)]); ylim([0 1.2]);

set(gca,‘xticklabel’,[]);set(gca,‘yticklabel’,[]);

set(gca,‘xtick’,[]);set(gca,‘ytick’,[]);

% Taking the IFFT and normalize to get normalized I/Q. This is a kind of duplicated process

% of the steps right above.

DataChunkFFT_RE = DataChunkFFT_RE ;

DataChunkFFT_IFFT = DataChunkFFT_IFFT/max(abs(DataChunkFFT_IFFT));

DataChunkFFT_IFFT = DataChunkFFT_IFFT;

DataChunkFftMag = abs(DataChunkFFT_IFFT);

subplot(7,6,3);

plot(real(DataChunkFFT_IFFT),imag(DataChunkFFT_IFFT),‘ro’,‘MarkerFaceColor’,[1 0 0],‘MarkerSize’,2);

xlim([-1 1]);ylim([-1 1]);

% Taking the IFFT and normalize to get normalized I/Q. But this one has an important

% difference comparing with the processs shown above. In this step, you see ‘EqFactor’

% is multiplied before ifft(). Also, notice in this case I used “EqFactor’” rather than

% transpose(EqFactor).

DataChunkFFT_RE = DataChunkFFT_RE .* EqFactor’ ;

% Plotting the I/Q in frequency Domain

subplot(7,6,[4 5]);

plot(DataChunkFftMag);xlim([1, length(DataChunkFftMag)]); ylim([0 1.2]);

% Plotting the I/Q in Constellation

subplot(7,6,6);

DataChunkFFT_Comp = DataChunkFFT_IFFT;

DataChunkFFT_Comp = DataChunkFFT_Comp/max(abs(DataChunkFFT_Comp));

plot(real(DataChunkFFT_Comp),imag(DataChunkFFT_Comp),‘ro’,‘MarkerFaceColor’,[1 0 0],‘MarkerSize’,2);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 1 within the slot 0 of Subframe 0. Everything is same

% as in the symbol 0 analysis except the ‘ChunkStart. So I would not explain any further.

  • CP_LengthList(2) ;

ChunkLength = Symbol_LengthList(2);

subplot(7,6,[7 8]);

subplot(7,6,9);

subplot(7,6,[10 11]);

subplot(7,6,12);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 2 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(3);

ChunkLength = Symbol_LengthList(3);

subplot(7,6,[13 14]);

subplot(7,6,15);

subplot(7,6,[16 17]);

subplot(7,6,18);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 3 within the slot 0 of Subframe 0. The symbol 3(the fourth

% symbol in LTE UL slot is special. It is special symbol carrying PUSCH DMRS data, it does

% not carry any user data. It just carries special reference signal based on a Table 5.5.1.2-1 base (not Zad-off Chu for 1 RB)

% sequence. This signal does not go through transformation procoding when it is transmitted

% so this does not go through IFFT process when it is demodulated. But I am still using the

% variable xxxx_IFFT in this step as I used for other symbols.

DataChunkFFT_RE_Norm = DataChunkFFT_RE/max(abs(DataChunkFFT_RE));

subplot(7,6,[19 20]);

plot(abs(DataChunkFFT_RE_Norm));xlim([1, length(DataChunkFFT_RE)]); ylim([0 1.2]);

DataChunkFFT_IFFT = DataChunkFFT_RE;

subplot(7,6,21);

subplot(7,6,[22 23]);

subplot(7,6,24);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 4 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(4) + Symbol_LengthList(4) …

  • CP_LengthList(5);

ChunkLength = Symbol_LengthList(5);

subplot(7,6,[25 26]);

subplot(7,6,27);

subplot(7,6,[28 29]);

subplot(7,6,30);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 5 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(5) + Symbol_LengthList(5) …

  • CP_LengthList(6);

ChunkLength = Symbol_LengthList(6);

subplot(7,6,[31 32]);

subplot(7,6,33);

subplot(7,6,[34 35]);

subplot(7,6,36);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Demodulation of symbol 6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This is to demodulate the symbol 6 within the slot 0 of Subframe 0. Everything is same

  • CP_LengthList(6) + Symbol_LengthList(6) …

  • CP_LengthList(7);

ChunkLength = Symbol_LengthList(7);

subplot(7,6,[37 38]);

subplot(7,6,39);

subplot(7,6,[40 41]);

subplot(7,6,42);

1 RB 的 DMRS 并不是 Zadoff-Chu 序列。Zadoff-Chu 序列从 3 RB 起才使用,1 RB 和 2 RB 改为使用表 5.5.1.2-1 和表 5.5.1.2-2 的基序列。代码中针对符号 3 的注释已相应更正。代码其余部分以相同方式处理两类序列,因为它只用到那 12 个已知取值。

与 LTE 上行(SC-FDMA)解调页面不同,本代码还使用了 fftshift。于是被占用的频点构成一个连续的块,即 107 至 118,而不是 FFT 输出两端的两个块。FrequencyShift’ 仍会对比移取共轭,因此样本仍被下移 7.5 kHz,与那一页相同。

  • 先 DMRS,后数据:EqFactor 来自符号 3,并应用于整个时隙。
  • 符号 3 不做 IFFT:DMRS 未经变换预编码。
  • 1 RB 的 DMRS 来自表 5.5.1.2-1:Zadoff-Chu 序列从 3 RB 起才使用。
  • fftshift 使该 RB 保持为一个连续块:第 107 至 118 个频点。 EqFactor 究竟存的是什么,为什么代码乘以 EqFactor’ 而不是除以它?答案解释了代码注释中提示的那两个转置。

EqFactor = DMRS_Inv .* transpose(DataChunkFFT_RE) 是接收到的 DMRS 除以已知 DMRS。对每个子载波而言,该比值是信道 H,而不是它的逆。代码随后把每个数据子载波乘以 EqFactor’,即 H 的共轭。于是每个数据值 Y = HX 变成 |H|2X:信道相位被抵消,只剩下实数增益 |H|2。

由于 DMRS 行是平坦的,该增益在这里的 12 个子载波上几乎相同。代码在 IFFT 之后对每个符号都做了归一化,因此这个恒定增益也消失了。当增益在子载波之间变化时,改用除以 H 可以把它精确去除,那就是同一个均衡器的迫零形式。

因此这两个转置都是有意为之。函数 transpose() 保持接收到的 DMRS 原样,于是 EqFactor 就是 H;EqFactor’ 对 H 取共轭,而共轭正是去除相位所需要的。乘以 H 本身会使相位误差加倍而不是消除它。

  • EqFactor 就是 H:接收到的 DMRS 除以已知 DMRS。
  • 数据乘以 H 的共轭:相位抵消,剩下 |H|2。
  • 归一化去除恒定增益:DMRS 行表明该增益在整个 RB 上是平坦的。
  • 除以 H 是迫零形式:它还能校正随子载波变化的增益。 3GPP TS 36.211 v19.3.0——第 5.5.1 条(基序列)、第 5.5.2.1 条(PUSCH DMRS)、第 5.6 条(SC-FDMA 基带信号生成)

LTE 上行(SC-FDMA)解调

DMRS - PUSCH - 1RB

图示资源


同族文档