“原文 Understanding LTE with MATLAB ,作者Houman Zarrinkoub,本文是对于该书的翻译,书中的专业性词汇给出了英文原文,图和表的排版都是参考原文,翻译不准确的地方请读者多多包涵。
本文仅限于个人学习,研究,交流,不得用于其他商业用途!”

4.6 速率匹配
到目前为止,我们只考虑了基础编码率为1/3的Turbo编码操作。速率匹配是实现自适应编码的重要手段,是现代通信标准的一个重要特征。它有助于在信道条件下增加吞吐量。在低失真信道中,我们可以用接近单位的编码率对数据进行编码,这减少了前向纠错中比特串的数目。另外,在降级信道,我们可以使用更小的编码速率和增加纠错比特的数量。
在具有速率匹配的信道编码中,我们从一个恒定的1/3速率turbo编码器开始,并使用速率匹配通过重复或穿孔来达到任何期望的速率。如果要求低于1/3的速率,我们重复turbo编码器输出位。对于高于1/3的速率,我们穿刺或删除一些Turbo编码器输出位。代码的删节不是简单的子采样的结果,而是基于交织方法。该方法被示为保持所产生的更高码率的汉明距离[2]。
速率匹配包涵:
子块交错;
奇偶校验位交织;
钻头修剪;
基于速率的比特选择和传输。
速率匹配中的第一个操作是基于简单矩形交织器的子块交织。通过在速率匹配中使用循环缓冲区的概念,通过在循环缓冲区上进行比特选择操作来简单地实现增加或减少(分别)速率到所需水平所必需的打孔和重复操作。最后,通过连接码块,编码比特准备好传输到PDSCH进行处理。
4.6.1 MATLAB例子
为了忠实于我们从简单到复杂的教学方法,我们将首先研究速率匹配,然后再介绍LTE标准中传输块信道编码的所有细节。这个MATLAB函数实现了LTE标准中规定的速率匹配的三个特性:子块交织、奇偶校验位交织、以及具有循环缓冲位选择的速率匹配。
1function y= RateMatcher(in, Kplus, Rate)
2% Rate matching per coded block, with and without the bit selection.
3D = Kplus+4;
4if numel(in)~=3*D, error('Kplus (2nd argument) times 3 must be size of input 1.');end
5
6% Parameters
7colTcSb = 32;
8rowTcSb = ceil(D/colTcSb);
9Kpi = colTcSb * rowTcSb;
10Nd = Kpi - D;
11
12% Bit streams
13d0 = in(1:3:end); % systematic
14d1 = in(2:3:end); % parity 1st
15d2 = in(3:3:end); % parity 2nd
16
17i0=(1:D)';
18Index=indexGenerator(i0,colTcSb, rowTcSb, Nd);
19Index2=indexGenerator2(i0,colTcSb, rowTcSb, Nd);
20
21% Sub-block interleaving - per stream
22v0 = subBlkInterl(d0,Index);
23v1 = subBlkInterl(d1,Index);
24v2 = subBlkInterl(d2,Index2);
25vpre=[v1,v2].';
26v12=vpre(:);
27
28% Concat 0, interleave 1, 2 sub-blk streams
29% Bit collection
30wk = zeros(numel(in), 1);
31wk(1:D) = v0(~isnan( v0 ));
32wk(D+1:end) = v12(~isnan( v12 ));
33
34% Apply rate matching
35N=ceil(D/Rate);
36y=wk(1:N);
37
38end
39
40
41function v = indexGenerator(d, colTcSb, rowTcSb, Nd)
42% Sub-block interleaving - for d0 and d1 streams only
43
44colPermPat = [0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30,...
45 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31];
46
47% For 1 and 2nd streams only
48y = [NaN*ones(Nd, 1); d]; % null (NaN) filling
49inpMat = reshape(y, colTcSb, rowTcSb).';
50permInpMat = inpMat(:, colPermPat+1);
51v = permInpMat(:);
52
53end
54
55function v = indexGenerator2(d, colTcSb, rowTcSb, Nd)
56% Sub-block interleaving - for d2 stream only
57
58colPermPat = [0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30,...
59 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31];
60pi = zeros(colTcSb*rowTcSb, 1);
61for i = 1 : length(pi)
62 pi(i) = colPermPat(floor((i-1)/rowTcSb)+1) + colTcSb*(mod(i-1, rowTcSb)) + 1;
63end
64
65% For 3rd stream only
66y = [NaN*ones(Nd, 1); d]; % null (NaN) filling
67inpMat = reshape(y, colTcSb, rowTcSb).';
68ytemp = inpMat.';
69y = ytemp(:);
70v = y(pi);
71
72end
73
74function out=subBlkInterl(d0,Index)
75out=zeros(size(Index));
76IndexG=~isnan(Index);
77IndexB=isnan(Index);
78MyIndex=Index(IndexG);
79out(IndexG)=d0(MyIndex);
80Nd=sum(IndexB);
81out(IndexB)=nan(Nd,1);
82end
83
这个MATLAB函数显示了定义LTE速率推进算法的交织、交织和比特选择操作的序列。速率行列式的输入是1/3 turbo编码器的输出。因此,对于大小为K的输入块,速率行进器的输入具有3(K+4)的大小,包括三个系统流和两个奇偶校验流。首先,我们将三个流中的每一个细分为32位部分,并交织这些部分中的每一个。由于每个流可能不能被32整除,所以我们将虚拟位添加到流的开头,这样得到的向量可以被细分成32位的整数。用于Systematic位和奇偶校验1位的子块交织是相同的,但是用于奇偶校验2位的子块交织是不同的。
然后,我们创建一个由虚填充的系统位和虚填充奇偶校验1和奇偶校验2位的交替构成的输出向量。最后,通过删除虚拟位,我们生成用于速率缩颈操作的循环缓冲区。速率匹配的最后一步是位选择,其中删除循环缓冲区中的虚拟位,并选择前几个位。所选比特与turbo编码器输入长度的比例是速率匹配后的新速率。
在RateDematcher() 函数中,我们对速率匹配中的那些运算进行逆运算。我们创建了一个由虚填充的系统位和奇偶校验位组成的向量,将输入向量的可用样本放置在向量中,并通过去隔行和去隔行创建了适当数量的LLR样本,以成为1/3涡轮解码器的输入。
1function out = RateDematcher(in, Kplus)
2% Undoes the Rate matching per coded block.
3%#codegen
4
5% Parameters
6colTcSb = 32;
7D = Kplus+4;
8rowTcSb = ceil(D/colTcSb);
9Kpi = colTcSb * rowTcSb;
10Nd = Kpi - D;
11
12tmp=zeros(3*D,1);
13tmp(1:numel(in))=in;
14
15% no bit selection - assume full buffer passed in
16i0=(1:D)';
17Index= indexGenerator(i0,colTcSb, rowTcSb, Nd);
18Index2= indexGenerator2(i0,colTcSb, rowTcSb, Nd);
19Indexpre=[Index,Index2+D].';
20Index12=Indexpre(:);
21
22% Bit streams
23tmp0=tmp(1:D);
24tmp12=tmp(D+1:end);
25v0 = subBlkDeInterl(tmp0, Index);
26d12=subBlkDeInterl(tmp12, Index12);
27v1=d12(1:D);
28v2=d12(D+(1:D));
29
30% Interleave 1, 2, 3 sub-blk streams - for turbo decoding
31temp = [v0 v1 v2].';
32out = temp(:);
33end
34
35function v = indexGenerator(d, colTcSb, rowTcSb, Nd)
36% Sub-block interleaving - for d0 and d1 streams only
37
38colPermPat = [0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30,...
39 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31];
40
41% For 1 and 2nd streams only
42y = [NaN*ones(Nd, 1); d]; % null (NaN) filling
43inpMat = reshape(y, colTcSb, rowTcSb).';
44permInpMat = inpMat(:, colPermPat+1);
45v = permInpMat(:);
46
47end
48
49function v = indexGenerator2(d, colTcSb, rowTcSb, Nd)
50% Sub-block interleaving - for d2 stream only
51
52colPermPat = [0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30,...
53 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31];
54pi = zeros(colTcSb*rowTcSb, 1);
55for i = 1 : length(pi)
56 pi(i) = colPermPat(floor((i-1)/rowTcSb)+1) + colTcSb*(mod(i-1, rowTcSb)) + 1;
57end
58
59% For 3rd stream only
60y = [NaN*ones(Nd, 1); d]; % null (NaN) filling
61inpMat = reshape(y, colTcSb, rowTcSb).';
62ytemp = inpMat.';
63y = ytemp(:);
64v = y(pi);
65
66end
67
68function out=subBlkDeInterl(in,Index)
69out=zeros(size(in));
70IndexG=find(~isnan(Index)==1);
71IndexOut=Index(IndexG);
72out(IndexOut)=in;
73end
74
4.6.2 误码率测量
现在我们将研究使用除1/3以外的编码速率对turbo编码算法的影响。函数chap6_ex05_crc实现收发器算法,该收发器算法执行CRC生成、turbo编码、加扰和调制及其逆操作的组合,同时实现提前终止机制和应用速率匹配操作。
1function [ber, numBits,itersHist]=chap6_ex05_crc(EbNo, maxNumErrs, maxNumBits)
2%% Constants
3clear functions;
4FRM=2432-24; % Size of bit frame
5Kplus=FRM+24;
6Indices = lteIntrlvrIndices(Kplus);
7ModulationMode=1;
8k=2*ModulationMode;
9CodingRate=1/2;
10snr = EbNo + 10*log10(k) + 10*log10(CodingRate);
11noiseVar = 10.^(-snr/10);
12%% Processsing loop modeling transmitter, channel model and receiver
13Hist = disp.Histogram('LowerLimit', 1,'UpperLimit', maxIter, 'NumBins', maxIter, 'RunningHistogram', true);
14
15numErrs = 0; numBits = 0; nS=0;
16while ((numErrs < maxNumErrs) && (numBits < maxNumBits))
17 % Transmitter
18 u = randi([0 1], FRM,1); % Randomly generated input bits
19 data= CbCRCGenerator(u); % Transport block CRC code
20 t0 = TurboEncoder(data, Indices); % Turbo Encoder
21 t1 = RateMatcher(t0,Kplus,CodingRate); %Rate Matcher
22 t2 = Scrambler(t1, nS); % Scrambler
23 t3 = Modulator(t2, ModulationMode); % Modulator
24 % Channel
25 c0 = AWGNChannel(t3, snr); % AWGN channel
26 % Receiver
27 r0 = DemodulatorSoft(c0, ModulationMode, noiseVar); % Demodulator
28 r1 = DescramblerSoft(r0, nS); % Descrambler
29 r2 = RateDematcher(r1,Kplus);
30 [y, ~,iters] = TurboDecoder_crc(-r2, Indices); % Turbo Deocder
31 % Measurements
32 numErrs = numErrs + sum(y~=u); % Update number of bit errors
33 numBits = numBits + FRM; % Update number of bits processed
34 itersHist = step(Hist,iters);
35 % Manage slot number with each subframe processed
36 nS = nS + 2; nS = mod(nS, 20);
37end
38%% Clean up & collect results
39ber = numErrs/numBits; % Compute Bit Error Rate (BER)
40end
41
通过增加turbo编码器之后的速率匹配操作和解码器之后的速率分派操作,我们可以模拟使用高于1/3的任何编码速率的效果。当然,在处理更干净的信道的传输场景中使用更低的编码率,其中需要更少的错误校正。

通过修改函数中的变量CodingRate,我们激活了速率匹配操作,并且可以检查目标编码速率的多个值的BER性能作为SNR的函数。图4.8中的结果表明,正如预期的那样,1/3速率收发器的性能优于1/2速率收发器。
未完待续
2018/12/5
