“原文 Understanding LTE with MATLAB ,作者Houman Zarrinkoub,本文是對(duì)于該書(shū)的翻譯,書(shū)中的專(zhuān)業(yè)性詞匯給出了英文原文,圖和表的排版都是參考原文,翻譯不準(zhǔn)確的地方請(qǐng)讀者多多包涵。
本文僅限于個(gè)人學(xué)習(xí),研究,交流,不得用于其他商業(yè)用途!”
4.6 速率匹配
到目前為止,我們只考慮了基礎(chǔ)編碼率為1/3的Turbo編碼操作。速率匹配是實(shí)現(xiàn)自適應(yīng)編碼的重要手段,是現(xiàn)代通信標(biāo)準(zhǔn)的一個(gè)重要特征。它有助于在信道條件下增加吞吐量。在低失真信道中,我們可以用接近單位的編碼率對(duì)數(shù)據(jù)進(jìn)行編碼,這減少了前向糾錯(cuò)中比特串的數(shù)目。另外,在降級(jí)信道,我們可以使用更小的編碼速率和增加糾錯(cuò)比特的數(shù)量。
在具有速率匹配的信道編碼中,我們從一個(gè)恒定的1/3速率turbo編碼器開(kāi)始,并使用速率匹配通過(guò)重復(fù)或穿孔來(lái)達(dá)到任何期望的速率。如果要求低于1/3的速率,我們重復(fù)turbo編碼器輸出位。對(duì)于高于1/3的速率,我們穿刺或刪除一些Turbo編碼器輸出位。代碼的刪節(jié)不是簡(jiǎn)單的子采樣的結(jié)果,而是基于交織方法。該方法被示為保持所產(chǎn)生的更高碼率的漢明距離[2]。
速率匹配包涵:
子塊交錯(cuò);
奇偶校驗(yàn)位交織;
鉆頭修剪;
基于速率的比特選擇和傳輸。
速率匹配中的第一個(gè)操作是基于簡(jiǎn)單矩形交織器的子塊交織。通過(guò)在速率匹配中使用循環(huán)緩沖區(qū)的概念,通過(guò)在循環(huán)緩沖區(qū)上進(jìn)行比特選擇操作來(lái)簡(jiǎn)單地實(shí)現(xiàn)增加或減少(分別)速率到所需水平所必需的打孔和重復(fù)操作。最后,通過(guò)連接碼塊,編碼比特準(zhǔn)備好傳輸?shù)絇DSCH進(jìn)行處理。
4.6.1 MATLAB例子
為了忠實(shí)于我們從簡(jiǎn)單到復(fù)雜的教學(xué)方法,我們將首先研究速率匹配,然后再介紹LTE標(biāo)準(zhǔn)中傳輸塊信道編碼的所有細(xì)節(jié)。這個(gè)MATLAB函數(shù)實(shí)現(xiàn)了LTE標(biāo)準(zhǔn)中規(guī)定的速率匹配的三個(gè)特性:子塊交織、奇偶校驗(yàn)位交織、以及具有循環(huán)緩沖位選擇的速率匹配。
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
這個(gè)MATLAB函數(shù)顯示了定義LTE速率推進(jìn)算法的交織、交織和比特選擇操作的序列。速率行列式的輸入是1/3 turbo編碼器的輸出。因此,對(duì)于大小為K的輸入塊,速率行進(jìn)器的輸入具有3(K+4)的大小,包括三個(gè)系統(tǒng)流和兩個(gè)奇偶校驗(yàn)流。首先,我們將三個(gè)流中的每一個(gè)細(xì)分為32位部分,并交織這些部分中的每一個(gè)。由于每個(gè)流可能不能被32整除,所以我們將虛擬位添加到流的開(kāi)頭,這樣得到的向量可以被細(xì)分成32位的整數(shù)。用于Systematic位和奇偶校驗(yàn)1位的子塊交織是相同的,但是用于奇偶校驗(yàn)2位的子塊交織是不同的。
然后,我們創(chuàng)建一個(gè)由虛填充的系統(tǒng)位和虛填充奇偶校驗(yàn)1和奇偶校驗(yàn)2位的交替構(gòu)成的輸出向量。最后,通過(guò)刪除虛擬位,我們生成用于速率縮頸操作的循環(huán)緩沖區(qū)。速率匹配的最后一步是位選擇,其中刪除循環(huán)緩沖區(qū)中的虛擬位,并選擇前幾個(gè)位。所選比特與turbo編碼器輸入長(zhǎng)度的比例是速率匹配后的新速率。
在RateDematcher() 函數(shù)中,我們對(duì)速率匹配中的那些運(yùn)算進(jìn)行逆運(yùn)算。我們創(chuàng)建了一個(gè)由虛填充的系統(tǒng)位和奇偶校驗(yàn)位組成的向量,將輸入向量的可用樣本放置在向量中,并通過(guò)去隔行和去隔行創(chuàng)建了適當(dāng)數(shù)量的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 誤碼率測(cè)量
現(xiàn)在我們將研究使用除1/3以外的編碼速率對(duì)turbo編碼算法的影響。函數(shù)chap6_ex05_crc實(shí)現(xiàn)收發(fā)器算法,該收發(fā)器算法執(zhí)行CRC生成、turbo編碼、加擾和調(diào)制及其逆操作的組合,同時(shí)實(shí)現(xiàn)提前終止機(jī)制和應(yīng)用速率匹配操作。
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
通過(guò)增加turbo編碼器之后的速率匹配操作和解碼器之后的速率分派操作,我們可以模擬使用高于1/3的任何編碼速率的效果。當(dāng)然,在處理更干凈的信道的傳輸場(chǎng)景中使用更低的編碼率,其中需要更少的錯(cuò)誤校正。
通過(guò)修改函數(shù)中的變量CodingRate,我們激活了速率匹配操作,并且可以檢查目標(biāo)編碼速率的多個(gè)值的BER性能作為SNR的函數(shù)。圖4.8中的結(jié)果表明,正如預(yù)期的那樣,1/3速率收發(fā)器的性能優(yōu)于1/2速率收發(fā)器。
未完待續(xù)
2018/12/5
點(diǎn)擊關(guān)注了解更多精彩內(nèi)容!