Download presentation

Presentation is loading. Please wait.

Published byPatricia Bubb Modified about 1 year ago

1
Turbo Codes Colin O’Flynn Dalhousie University Last Update of This Presentation: Thursday Jan 26 / 2012

2
Handy Turbo code applications : a journey from a paper to realization Keattisak Sripimanwat Trellis and turbo coding Schlegel, Christian B.; Pérez, Lance C. Codes and turbo codes Claude Berrou Note: You need to be on Dalhousie Network or using EZProxy to access these resources online. 2

3
Handy The design and application of RZ turbo codes Xin Liao Note: You need to be on Dalhousie Network or using EZProxy to access these resources online. Turbo coding, turbo equalisation, and space-time coding : exit-chart aided near-capacity designs for wireless channels L. Hanzo et. al. aided-near-capacity-designs-for-wireless-channels/oclc/ &referer=brief_results 3

4
Handy References A Turbo Code Tutorial William E. Ryan Liang Li’s Nine Month Report & MATLAB Code Liang Li, Rob Maunder 4 Chapers 4,9,15 of Turbo coding, turbo equalisation, and space-time coding : exit-chart aided near-capacity designs for wireless channels

5
Notes If You Are Viewing Online Be sure to enable presentation notes, as there is some additional information there: 5 I’m using the following acronyms to reference where you can find additional information: CATC: Codes and Turbo Coding, 1 st Edition, Berrou TATC: Trellis and Turbo Coding, 1 st Edition, Schlegel TCT: Turbo Code Tutorial, Ryan TCTEASTC: Turbo Coding, Turbo Equalization, and Space-Time Coding

6
Which Reference to Use? Trellis and Turbo Coding – Very in-depth guide to Turbo Codes, including mathematical derivation. Covers sufficient background to make book stand-alone reference. Covers topics I didn’t find in other books such as derivation of free-distance for turbo codes. Codes and Turbo Coding – Less mathematical derivation by comparison, but contains some examples which are easier to follow. Author was also on team that invented Turbo Codes. Turbo Code Applications – Covers how codes are used in real systems, and also history of discovery in more depth than other books. Turbo coding, turbo equalisation, and space-time coding : exit-chart aided near-capacity designs for wireless channels - I found had easiest to understand description of how Turbo Decoding works. Includes a complete example of the decoding process, with intermediate values and internal operation of soft-output decoders. Also includes substantial number of charts showing difference in performance for changing Turbo parameters, which is fairly interesting. You can get a few chapters of this book online (see previous slides for link). 6

7
BACKGROUND, HAND- WAVING, AND ALL THAT STUFF 7

8
The Beginning < 8

9
“With 52 FPGAs for the processors, 52 FPGAs for the switches, seven FPGAs for the memory controllers and one FPGA to control the whole system, a total of 112 FPGAs are required. In total, the cost of the RACER II is approximately $200,000, which is 10 times cheaper than the BVD at the same decoding rate and without the need for custom ASICs” 9

10
The Beginning Large MHD Code “It's not the quantity that counts — it's the quality” Small MHD Code WRONG What we want What we can have 10

11
The Beginning Maybe we can get the large MHD by using several of the small ones… Large MHD Code Small MHD Code 11

12
Concatenated Codes: Serial Outer EncoderInner Encoder Permutation Inner DecoderOuter Decoder Permutation 12

13
Concatenated Codes: Parallel Encoder 1 Encoder 2 Permutation Systematic Part of Codeword Redundant Part of Codeword from Enc 1 Redundant Part of Codeword from Enc 2 13

14
Concatenated Codes: Comparison Shopping ParallelSerial Systematic ONLY, at least one should be recursive, need to be careful with code choice Systematic or Non-Systematic, pretty indifferent to code choice MHD Normally better compared to parallel 14

15
Example: Parallel Using Hamming (7,4) as base: Data Parity from Code 1 Parity from Code 2 15

16
Example: Parallel Using Hamming (7,4) as base: Data Parity from Code 1 Parity from Code 2 Math Stuff Rate = 16/40 =4/10 For input of weight 1, output = 5 Asymptotic Gain = 10log(R*d) = 10log(4 * 5 / 10) =3.01 dB Compare with input code: =10log(4 * 3 / 7) = 2.34 dB 16

17
Example: Serial Using Hamming (7,4) as base: Data Parity from Code 1 Parity from Code 2 Math Stuff Rate = 16/49 For input of weight 1, output = 9 Asymptotic Gain = 10log(R*d) = 10log(16 * 9 / 49) =4.68 dB Compare with input code: =10log(4 * 3 / 7) = 2.34 dB 17

18
Concatenated Codes: Conclusions As promised, serial codes had better MHD but worse Rate. Parallel codes can work well but should use Recursive Systematic Convolutional (RSC) codes – notice poor performance with hamming code here. 18

19
Tag Team (Iterative) Decoding Eat this Error-Man! 19

20
Iterative Example VSDAL THETA LANES APONG PINTO i ii iii iv v i.animate ii.Greek iii.Sticks iv.Conflicts v.slow 1.oral 2.representation 3.projection 4.force 5.rope This example from: Codes and Turbo Codes by Claude Berrou 20

21
Iterative Example - Across VSDAL THETA CANES APONG PINTO i ii iii iv v i.animate ii.Greek iii.Sticks iv.Conflicts v.slow 1.oral 2.representation 3.projection 4.force 5.rope This example from: Codes and Turbo Codes by Claude Berrou 21

22
Iterative Example - Down VSTAL THEGA CANES APONS PENTO i ii iii iv v i.animate ii.Greek iii.Sticks iv.Conflicts v.slow 1.oral 2.representation 3.projection 4.force 5.rope This example from: Codes and Turbo Codes by Claude Berrou 22

23
Iterative Example - Across VITAL THEGA CANES AGONS LENTO i ii iii iv v i.animate ii.Greek iii.Sticks iv.Conflicts v.slow 1.oral 2.representation 3.projection 4.force 5.rope This example from: Codes and Turbo Codes by Claude Berrou Agons = fight/struggle in Latin Lento = slow in Spanish 23

24
Iterative Example - Down VITAL OMEGA CANES AGONS LENTO i ii iii iv v i.animate ii.Greek iii.Sticks iv.Conflicts v.slow 1.oral 2.representation 3.projection 4.force 5.rope This example from: Codes and Turbo Codes by Claude Berrou Tenon = A projecting piece of wood made for insertion into a mortise in another piece 24

25
Iterative Example - Across VITAL OMEGA CANES AGONS LENTO i ii iii iv v i.animate ii.Greek iii.Sticks iv.Conflicts v.slow 1.oral 2.representation 3.projection 4.force 5.rope This example from: Codes and Turbo Codes by Claude Berrou 25

26
Turbo Encoder – General Format Encoder 1 Encoder 2 Permutation Systematic Part of Codeword Redundant Part of Codeword from Enc 1 Redundant Part of Codeword from Enc 2 Puncturing (Optional) 26

27
Turbo Encoder - Permutation WIRELES S CHANNEL 27

28
Turbo Encoder - Permutation WIRELES S CHANNEL

29
Turbo Encoder - Permutation Assumption: Nature Hates Us (In all fairness, we started it.) 29

30
Turbo Encoder - Permutation WIRELES S CHANNEL

31
Turbo Encoder - Termination 1.Do Nothing Decreases Asymptotic Gain Will give proof later about why this is bad – hold on 31

32
Turbo Encoder - Termination 2.Terminate the Trellis of One or Both, outside of permutation Encoder 1 Encoder 2 Permutation Systematic Part of Codeword Redundant Part of Codeword from Enc 1 Redundant Part of Codeword from Enc 2 Puncturing (Optional) Message 32

33
Unterminated Loss From “Illuminating the Structure of Code and Decoder of Parallel Concatenated Recursive Systematic (Turbo) Codes”, by Patrick Robertson 33 N=1024, only 1 st encoder terminated N=1024, both encoders terminated

34
Turbo Encoder - Termination 3. Use Interleaver to Terminate Trellis based on input sequence to first 34

35
Turbo Encoder - Termination 4. Circular Encoding (“Tail Biting”) 35 See page 138 of TATC or page 194 of CATC.

36
A LITTLE MORE RIGOR 36

37
Why is RSC So Good? Convolution Code (Not Systematic, Not Recursive): Note: Input of weight 1 results in finite-weight output TACT pp291, TTC pp1 37

38
Why is RSC So Good? Recursive Systematic Convolution Code: Note: Input of weight 1 results in infinite-weight output 38

39
Example with Non-Recursive Encoder 1 Encoder 2 Permutation Systematic Part of Codeword Redundant Part of Codeword from Enc 1 Redundant Part of Codeword from Enc 2 Non-recursive encoders 39

40
Example with RSC Encoder 1 Encoder 2 Permutation Systematic Part of Codeword Redundant Part of Codeword from Enc 1 Redundant Part of Codeword from Enc 2 RSC 40

41
Permutation - Linear Encoder 1 Encoder 2 Permutation dFree TACT pp

42
Encoder 2 Permutation - Random Encoder 1 Permutation dFree 42

43
Why Terminate Encoder 1? …

44
ANALYZING PERFORMANCE 44

45
What does Turbo Code BER Look Like? 45 Turbo Cliff

46
46

47
Bit Error Rate Bound of Finite- Length Convolution Code TACT 10.3 / 10.4 : pp

48
Distance Spectrum Representation of Bound TACT 10.3 / 10.4 : pp

49
Free Distance of Turbo Code TACT 10.3 / 10.4 : pp

50
Plotting Distance Spectrum function printBERContribution( d, Nd, wd, N, R ) %PRINTBERCONTRIBUTION Print contribution from distance spectrum components. % d, Nd, wd are arrays of numbers, each index corresponding to one spectral % component. N is interleaver size. R is rate. close all; %SNR Range in dB SNR_range = [0:0.01:2]; ebno = 10.^ (SNR_range./ 10); ber=zeros(length(d), length(ebno)); linetypes = {'b', 'r--', 'b--', 'r:', 'b:', 'r-.', 'b-.'}; leg = cell(1,length(d)); for i=1:length(d) ber(i+1,:) = ber(i,:) + ((Nd(i) * wd(i)) / N) * qfunc (sqrt(d(i) * 2 * R * ebno)); semilogy(SNR_range, ber(i+1,:), linetypes{i}); hold on leg{i} = sprintf('d = %d', d(i)); end legend(leg); 50

51
Distance Spectrum Examples The following plotted with Roger Garello’s algorithm & software. Based on ‘example 2’ available from: Full tutorial for plotting given in Part 2. Specifications: -No Puncturing (e.g.: rate = 1/3) -Block length =

52
Distance Spectrum (examples) dNdWd Linear Interleaver N=1000 >> inter = CreateLinearInterleaver(1000,25,40); >> writePerm(inter); turbo.exe >> plot(0:999, inter, ‘.’) 52

53
Distance Spectrum Contribution >> d=[ ]; >> Nd=[1 1 1]; >> wd=[1 2 1]; >> printBERContribution(d, Nd, wd, 1000, 1/3); 53

54
Distance Spectrum (examples) dNdWd Linear Interleaver N=1000 >> inter = CreateLinearInterleaver(1000,100,10); >> writePerm(inter); turbo.exe >> plot(0:999, inter, ‘.’) 54

55
Distance Spectrum (examples) dNdWd Random Interleaver N=1000 >> plot(0:999, inter, ‘.’) >> inter = CreateRandomInterleaver(1000); >> writePerm(inter); turbo.exe 55

56
Distance Spectrum (examples) dNdWd Another Random Interleaver N=1000 >> inter = randperm(1000) – 1; >> writePerm(inter) turbo.exe >> plot(0:999, inter, ‘.’) 56

57
Distance Spectrum Contribution >> d=[ ]; >> Nd=[ ]; >> wd = [ ]; >> printBERContribution(d, Nd, wd, 1000, 1/3); 57

58
Distance Spectrum (examples) dNdWd S Random Interleaver N=1000, S=9 >> inter = CreateSRandomInterleaver(1000, 9); >> writePerm(inter) turbo.exe >> plot(0:999, inter, ‘.’) 58

59
Distance Spectrum Contribution >> d=[ ]; >> Nd = [ ]; >> wd = [ ]; >> printBERContribution(d, Nd, wd, 1000, 1/3); 59

60
Distance Spectrum (examples) dNdWd S Random Interleaver N=1000, S=16 >> inter = CreateSRandomInterleaver(1000, 16); >> writePerm(inter) turbo.exe >> plot(0:999, inter, ‘.’) 60

61
Free Distance Asymptote vs. BER Using S-Random interleaver, S=9, same parameters as in previous slides. >> startup >> CmlSimulate(‘TurboTests’, [8]) (wait a while, can end early with Ctrl-C if you don’t need higher SNRs) >> CmlPlot(‘TurboTests’, [8]) >> close([2 3 4]) >> figure(1) >> hold on >> printBERContribution([18], [4], [8], 1000, 1/3) 61

62
Sidenote: Simulation Time SNR Value (dB)Delta Sim Time (hour:min:sec) Actual Sim Time (hour:min:sec) :00: :00:0200:00: :00:0300:00: :00:0700:00: :00:3200:00: :03:5500:04: :12:0500:16: :16:1800:33: :26:4500:59: :51:0301:50: :28:4703:19: :22:4605:42: :13:0409:55: :19:0918:14: :54:4535:08:33 Using cml running on dual 3.5 GHz Intel i7 990 on 64-bit Linux. No shortage of processing power! 62

63
Free Distance Asymptote vs. BER >> startup >> CmlSimulate(‘TurboTests’, [9]) (wait a while, can end early with Ctrl-C if you don’t need higher SNRs) >> CmlPlot(‘TurboTests’, [9]) >> close([2 3 4]) >> figure(1) >> hold on >> printBERContribution([11], [1], [1], 1000, 1/3) Using Linear interleaver, same parameters as in previous slides. 63

64
TURBO DECODING 64

65
Soft Input Soft Output (SISO) Decoder 1 Decoder 2 Things Only I Know Things only I Know Things we Both Know

66
A Posteriori Probability (APP) State 00 State 01 State 10 State 11

67
Log-likelihood Ratio 67 WARNING: Some papers define this other way around, so if using code or equations which rely on LLR, always look back to see which way the code/equation previously defined it. “Trellis and Turbo Coding” for example defines it as ln(p0/p1).

68
Log-likelihood Ratio 68 >> p1=[0:0.01:1] >> p0=1-p1; >> llr = log(p1./p0); >> plot([0:0.01:1], llr); >> xlabel('P(u = 1)'); >> ylabel('LLR(u)');

69
Maximum A Posteriori Estimation: A Dumb Approach 69 %Generate every possible codeword for i=1:2^nbits codeword = rsc_encode([feedback; feedforward], allValidInputs(i,:), 1); all_codewords(i,:) = reshape(codeword, 1, len); end %For every possible codeword & ours: find out Pcodeword for i=1:2^nbits bitsInDiff = sum(abs(input - all_codewords(i,:))); bitsOK = len - bitsInDiff; %Find APP Pr{X | Y} % X = Codeword that was transmitted % Y = Codeword that was receieved pcodeword(i) = pberr^bitsInDiff * (1-pberr)^bitsOK; end %Limited valid Tx codewords, so normalize probability to add up to 1.0 pcodeword = pcodeword./ (sum(pcodeword)); Step 1: Generate EVERY possible Codeword Step 2: Calculate probability that transmitter sent some codeword

70
MAP: A Dumb Approach 70 %Calculate individual probability of error pSystematic = zeros(1, nbits); for bitindex=1:nbits psum = 0; for i=1:2^nbits codewords_reshaped = reshape(all_codewords(i,:), 2, len/2); %Find probability any given bit is ZERO if codewords_reshaped(1, bitindex) == 0 psum = psum + pcodeword(i); end p0Systematic(bitindex) = psum; end %Find probability any given bit is ONE p1Systematic = p0Systematic; %From P1 & P0 calculate LLR llrs = log(p1Systematic./ p0Systematic); Note: this is not full code, see resources/brute_force_map.m for full listing Step 3: Calculate probability for each bit in systematic input part

71
MAP: A Dumb Approach, Example Information Bits: Run example yourself: doc\resources\brute_force_test.m Codeword after RSC: *** SEND OVER CHANNEL *** Location of errors after demodulating: Result of decoding: llrs: Codeword: Result of Actual LOG-MAP Algorithm SISO Decoder with HARD inputs:

72
MAP: A Smart Approach: BCJR 72 Optimal Decoding of Linear Codes for minimizing symbol error rate Bahl, L.; Cocke, J.; Jelinek, F.; Raviv, J.;

73
Soft Input Soft Output (SISO) 73 Normal input to decoder from demodulator (hard- input)

74
Soft Input Soft Output (SISO) 74 SISO Here is my best guess about the data a priori probability information Here is my best guess about the data a posteriori probability information

75
MAP: HISO vs SISO 75 Information to Send Demodulated Signal (input to SISO): Hard Limited Signal (input to HISO): Result of LOG-MAP Algorithm Decoder with HARD inputs: Result of LOG-MAP Algorithm Decoder with SOFT inputs:

76
EXIT Chart 76 Input Information Output Information CATC pp & TCTEASTC 16.3 pp Extrinsic Information Transfer (EXIT)

77
Turbo Decoder Setup 77 SISO Depuncturing / Reshaping Systematic Part Upper Encoder Parity Bits Lower Encoder Parity Bits Extrinsic Information

78
Turbo Decoder Iterations 78 Iteration 1 Iteration 2 Iteration 3 Iteration 4

79
EXIT Chart Notes 79

80
EXIT Chart Notes 80

81
EXIT Chart Notes 81

82
EXIT Chart – BER of Previous 82

83
EXAMPLE 83

84
Turbo Example 84 % SNR in dB to run channel at, play around % with this to get a good number % which uses a few turbo iterations. On my % system this causes the code to do % 3 iterations to correct all the errors SNR = -7.3; %Length of data in bits frame_length = 9; % The generator polynomials we are using feedback_polynomial = [ ] feedforward_polynomial = [ ]

85
Turbo Example - Polynomial 85 feedback_polynomial = [ ] feedforward_polynomial = [ ]

86
Turbo Example 86 %Keep all tail bits tail_pattern = [1 1 1 %Encoder 1 Systematic Part %Encoder 1 Parity Part %Encoder 2 Systemtic Part 1 1 1];%Encoder 2 Parity Part %Puncture systematic part from encoder 2 pun_pattern = [ 1 1 %Encoder 1 Systematic Part 1 1 %Encoder 1 Parity Part 0 0 %Encoder 2 Systemtic Part 1 1];%Encoder 2 Parity Part

87
Turbo Example - Puncturing 87

88
Turbo Example 88 %Max number of iterations to display turbo_iterations = 5; %Automatically stop when no more errors autostop = 1;

89
Turbo Example – Data 89 % Data Generation %Seed the random number generator so we always %get the same random data rand('state', 0); randn('state', 0); %Generate some random data data = round( rand( 1, frame_length ) ); fprintf('Information Data = '); fprintf('%d ', data); fprintf('\n'); Information Data =

90
Turbo Example - Encoding 90 % Encoding %Make polynomial genPoly = [feedback_polynomial; feedforward_polynomial]; %How many rows in polynomial? [N, K] = size(genPoly); upper_data = data; upper_output = ConvEncode( upper_data, genPoly, 0); %lower input data is interleaved version of upper lower_data = interleave(data, 1); lower_output = ConvEncode( lower_data, genPoly, 0); % convert to matrices (each row is from one row of the generator) upper_reshaped = [ reshape( upper_output, N, length(upper_output)/N ) ]; lower_reshaped = [ reshape( lower_output, N, length(lower_output)/N ) ];

91
Turbo Example - Encoding 91 Upper Code Input = Upper Code Systematic = Upper Code Parity =

92
Turbo Example - Encoding function [interleaved] = interleave(input, print) input_data = reshape(input, a, a); output_data = input_data'; interleaved = reshape(output_data, 1, length(input));

93
Turbo Example - Encoding 93 Lower Code Input = Lower Code Systematic = Lower Code Parity =

94
Turbo Example - Puncturing 94 % parallel concatenate unpunctured_word = [upper_reshaped lower_reshaped]; fprintf('\n\nUnpunctured = '); fprintf('%d ', unpunctured_word); fprintf('\n'); %Puncture Codeword codeword = Puncture( unpunctured_word, pun_pattern, tail_pattern ); fprintf('Punctured = '); fprintf('%d ', codeword); fprintf('\n'); Unpunctured = Punctured =

95
Turbo Example - Puncturing 95 Upper Code Systematic = Upper Code Parity = Lower Code Systematic = Lower Code Parity = Upper Code Puncturing = Lower Code Puncturing = Lower Code Puncturing = Upper Code Systematic = Upper Code Parity = Lower Code Systematic = Lower Code Parity = Punctured =

96
Turbo Example - Channel 96 % Modulate, Channel, and Demodulate %Turn into +/- 1 for BPSK modulation example tx = -2*(codeword-0.5); %Generate AWGN of correct length EsNo = 10^(SNR/10.0); variance = 1/(2*EsNo); noise = sqrt(variance)*randn(1, length(tx) ); %Add AWGN rx = tx + noise; %Demodulate symbol_likelihood = -2*rx./variance; %Stats plot(symbol_likelihood, zeros(1, length(symbol_likelihood)), '.') fprintf('Received log-liklihood ratio (LLR): mean(abs(LLR)) = %f\n', mean(abs(symbol_likelihood)));

97
Turbo Example - Channel 97 Sending data over AWGN channel, SNR= Received log-liklihood ratio (LLR): mean(abs(LLR)) =

98
Turbo Example - Depuncturing 98 % Decoding % intialize error counter errors = zeros( turbo_iterations, 1 ); % depuncture and split into format used in each decoder depunctured_output = Depuncture(symbol_likelihood, pun_pattern, tail_pattern ); input_upper_c = reshape( depunctured_output(1:N,:), 1, N*length(depunctured_output) ); input_lower_c = reshape( depunctured_output(N+1:N+N,:), 1, N*length(depunctured_output) ); LLR After Channel = LLR After Depuncturing = Upper Input = Lower Input =

99
Turbo Example – Decode Setup 99 % No estimate of original data input_upper_u = zeros( 1, frame_length ); saved_outLLR = []; saved_outExt = []; saved_interLLR = []; saved_interExt = []; totalIts = 0; traj = zeros(1,2); figure; axis square; title('Turbo Decoder Trajectory'); ylabel('I_E'); xlabel('I_A'); xlim([0,1]); ylim([0,1]); hold on; IA = 0; IE = 0;

100
Turbo Example - Decoding 100 % Iterate over a number of times for turbo_iter=1:turbo_iterations fprintf( '\n*** Turbo iteration = %d\n', turbo_iter ); % Pass through upper decoder [output_upper_u output_upper_c] = SisoDecode( input_upper_u, input_upper_c, genPoly, 0, 0 ); % Extract Extrinsic information ext = output_upper_u - input_upper_u; % Interleave this information, which organizes it % in the same manner which the lower decoder sees bits input_lower_u = interleave(ext, 0);

101
Turbo Example - Decoding 101 % Pass through lower decoder [output_lower_u output_lower_c] = SisoDecode( input_lower_u, input_lower_c, genPoly, 0, 0 ); % Interleave and extract Extrinsic information input_upper_u = interleave( output_lower_u - input_lower_u, 0 ); % Hard decision based on LLR: if 0 bit is 1 detected_data = (sign(interleaved_output_lower_u) + 1) / 2; % Find errors – NOT part of turbo algorithm, since normally you don’t have % actual data. But we do so take advantage of that to detect when to stop error_positions = xor( detected_data, data); if (sum(error_positions)==0) && (autostop) break; else errors(turbo_iter) = temp_errors + errors(turbo_iter); end

102
Turbo Example - Outputs 102 *** Turbo iteration = 1 Error Vector = Errors = 2, mean(abs(output LLR)) = *** Turbo iteration = 2 Error Vector = Errors = 1, mean(abs(output LLR)) = *** Turbo iteration = 3 Error Vector = Errors = 0, mean(abs(output LLR)) =

103
Turbo Decoder - LLRs 103 input_upper_u Error Vectors for Each Iteration

104
Turbo Decoder - Extrinsic Error Vectors for Each Iteration output_upper_u - input_upper_u

105
Turbo Decoder - Extrinsic Error Vectors for Each Iteration output_upper_u - input_upper_u

106
Turbo Example - Decoding 106 detected_data = reshape( detected_data', 1, frame_length);

107
Turbo Example - Decoding 107 % Combine output_c and puncture % convert to matrices (each row is from one row of the generator) upper_reshaped = [ reshape( output_upper_c, N, length(output_upper_c)/N ) ]; lower_reshaped = [ reshape( output_lower_c, N, length(output_lower_c)/N ) ]; % parallel concatenate unpunctured_word = [upper_reshaped lower_reshaped]; Upper Code Output = Upper Code Output Systematic = Upper Code Output Parity = Lower Code Output = Lower Code Output Systematic = Lower Code Output Parity =

108
Part 2 – Computer simulations 108

109
Coded Modulation Library Iterative Solutions has created an Open Source (LGPL) project to simulate Turbo Codes. Key functions written in C & work on Linux, Windows, MAC from MATLAB Speeds up simulation drastically compared to MATLAB-only solution NOTE: Comes with Documentation in documentation/CMLOverview.pdf, see that file for more help, as I won’t repeat information in that file

110
Downloading CML I’ve extended CML to add: Bunch of examples Tutorial file (shows decoding step-by-step) Some simple additional interleavers Functions to find dFree and plot asymptote EXIT Chart Plotting & Trajectories (wouldn’t trust it 100%) Option to plot only specified iteration without changing files (useful for comparisons) 110

111
Download CML My version + this presentation stored in SVN on Or download a.zip from 111

112
Installing CML 1.Unzip file somewhere 2.On Windows – you are done. On other systems: Startup MATLAB, go to cml\mex\source and run ‘ make ’ 3.Optional for dFree calculation: Download turbo.exe from direct link:

113
Running CML 1.cd to directory you unzipped file in 2.run command ‘startup’ 113 >> cd E:\Documents\academic\classes\ilo2\turbocml\trunk >> startup >>

114
RUNNING BER SIMULATIONS 114

115
Running Simulations Simulations run with ‘CmlSimulate’ command. Parameters for simulations stored in scenario files Scenario files stored in ‘cml/localscenarios’ and ‘cml/scenarios’. Simulation results saved in ‘cml/output’ – You can interrupt simulation and continue it later without loosing all the data 115

116
Running Simulations 116 >> CmlSimulate('TurboTests', [1 2 3]) Use file TurboTests.mRun scenarios 1, 2, and 3

117
Running Simulations 117 >> CmlSimulate('TurboTests', [3 6]) Initializing case (3):UMTS-TC, BPSK, Rayleigh, 530 bits, max-log-MAP Initializing case (6):UMTS-TC, BPSK, Rayleigh, 5114 bits, max-log-MAP Record 1 UMTS-TC, BPSK, Rayleigh, 530 bits, max-log-MAP Eb/No in dB = dB Clock 13:32:26 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Eb/No in dB = dB Clock 13:32:27 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx??? Operation terminated by user during ==> TurboDecode at 99 Hit Ctrl-C To Abort

118
Running Simulations 118 >> CmlSimulate('TurboTests', [3 6]) Initializing case (3):UMTS-TC, BPSK, Rayleigh, 530 bits, max-log-MAP Initializing case (6):UMTS-TC, BPSK, Rayleigh, 5114 bits, max-log-MAP Record 1 UMTS-TC, BPSK, Rayleigh, 530 bits, max-log-MAP Eb/No in dB = dB Clock 13:32:31 Eb/No in dB = dB Clock 13:32:31 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Eb/No in dB = dB Clock 13:32:32 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxx. Eb/No in dB = dB Clock 13:32:34 xxxxxxxxxxxxx.xxxxxxxxxxxxx.xxxxxxxxxxxxxx.Simulation Complete Clock 13:32:38 Continue Simulation – Note 1.4 dB point already simulated and saved

119
Running Simulations 119 >> CmlSimulate('TurboTests', [11]) Initializing case (11):TC, BPSK, AWGN, bits, max-log-MAP Record 1 TC, BPSK, AWGN, bits, max-log-MAP Eb/No in dB = dB Clock 10: 3:11 xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxx. Eb/No in dB = dB Clock 10: 5: 7 xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxx. Eb/No in dB = dB Clock 10: 7: 3.x.x.x..x..xx..x...xxx..x.x..x.xx..x.x.xx.x.xx..x.....x...x.x.xx.x.xx.xx..x..xx....x..xxx..x....x.x.x...x.....xxx.x.....x...x.x.x.x.x x...x.....x.x.x...xx....x.x.x.....xx.x.x x..x.x.x.x..x..x....x....x.. xx....x.....x..xx.x.xx.x...x.x.....x.....x..xx.x.x..x..x...x...x. Eb/No in dB = dB Clock 10:28: x x x x..x x x x x x x x x x.... ‘x’ printed for errors in frames As you go over turbo cliff, simulation times become massive… note 0.25 dB change in SNR (this sim step isn’t done yet either)

120
Plotting Simulations Use ‘CmlPlot’ command in same way as Simulate. You can copy saved.mat files from another source to the proper place in Output if you don’t do the simulations yourself. e.g.: 120 On command line, copy proper.mat file from server running simulation: $ cd cml/output/TurboCodes $ scp Back in MATLAB, Plot results, we can see how Simulation is doing and decide if we have enough data >> CmlPlot('TurboTests', [11]) Initializing case (11):TC, BPSK, AWGN, bits, max-log-MAP ans = B: [] … BUNCH MORE STUFF …

121
Plotting Simulations Scenario File decides what type of simulation, and thus what type of plot: 121 ‘coded’ means Bit Error Rate (BER) and Frame Error Rate (FER). Only sim type I’m using.

122
Resulting Plots 122 Figure 1: BER vs Eb/No Figure 2: BER vs Es/No Figure 3: FER vs Eb/No Figure 4: FER vs Es/No EbNo = EsNo./sim_param(i).rate; for this example rate=

123
Comparing Turbo Iterations 123 record = 8; sim_param(record).comment = 'TC, BPSK, AWGN, 1000 bits, max-log-MAP'; sim_param(record).SNR = 0:0.25:3.5; sim_param(record).framesize = 1000; sim_param(record).channel = 'awgn'; sim_param(record).decoder_type = 1; sim_param(record).max_iterations = 16; sim_param(record).plot_iterations = [ ]; Plot BER for iterations 1, 5, 10, 16

124
Comparing Turbo Iterations 124 >> CmlPlot('TurboTests', [8], 'iter', [1 2 3]) Initializing case (8):TC, BPSK, AWGN, 1000 bits, max-log-MAP Override scenario file, plot iterations 1,2, and 3. Final iteration always plotted (in this example = 16)

125
Comparing Plots 125 >> CmlPlot('TurboTests', [8 11], 'iter', [16]) Use ‘iter’ override to only plot final iteration, cleans up plot

126
Comparing Plots Specify ‘linetype’ in Scenario file to make plots different 126 record = 8;... sim_param(record).linetype = 'g-';... record = 11;... sim_param(record).linetype = ‘b-';...

127
Defining your Own Simulation: 1 Copy/Paste block of code, increment ‘record’ number, adjust parameters. e.g.: 127 record = 8; sim_param(record).comment = 'TC, BPSK, AWGN, 1000 bits, max-log-MAP'; sim_param(record).SNR = 0:0.25:3.5; sim_param(record).framesize = 1000; sim_param(record).channel = 'awgn'; sim_param(record).decoder_type = 1; sim_param(record).max_iterations = 16; sim_param(record).plot_iterations = [ ]; sim_param(record).linetype = 'g-'; sim_param(record).sim_type = 'coded'; sim_param(record).code_configuration = 1; sim_param(record).SNR_type = 'Eb/No in dB'; sim_param(record).modulation = 'BPSK'; You need to change this You should change this Change as needed Continued on Next Page

128
Defining your Own Simulation: Continued on Next Page sim_param(record).mod_order = 2; sim_param(record).bicm = 1; sim_param(record).demod_type = 0; sim_param(record).legend = sim_param(record).comment; sim_param(record).code_interleaver =... strcat( 'CreateSRandomInterleaver(', int2str(sim_param(record).framesize ), ', 9)' ); Interleaver is specified as a function which gets called, so you need to create a string with all the parameters that will be required. Examples: S-Random, S=9 strcat( 'CreateSRandomInterleaver(', int2str(sim_param(record).framesize ), ', 9)' ) S-Random, S=16 strcat( 'CreateSRandomInterleaver(', int2str(sim_param(record).framesize ), ', 16)' ) Random strcat( 'CreateRandomInterleaver(', int2str(sim_param(record).framesize ), ‘)' ) Linear (note this has fixed parameters, need to change them if frame-size changes) 'CreateLinearInterleaver(1000, 25, 40)' UMTS strcat( 'CreateUmtsInterleaver(', int2str(sim_param(record).framesize ), ')' );

129
Defining your Own Simulation: Continued on Next Page Polynomial order for RSC: [ Feedback Feedforward]] % Feedback = [1011] % Feedforward = [1111] sim_param(record).g1 = [ ]; sim_param(record).g2 = sim_param(record).g1; sim_param(record).nsc_flag1 = 0; sim_param(record).nsc_flag2 = 0; %No puncturing sim_param(record).pun_pattern1 = [ ]; sim_param(record).pun_pattern2= [ ]; sim_param(record).tail_pattern1 = [ ]; sim_param(record).tail_pattern2 =... sim_param(record).tail_pattern1; Puncturing pattern specified in: [ Systematic Part Codeword Part] Pattern needs to be long enough to show pattern, see examples next page

130
Defining your Own Simulation: Continued on Next Page %No puncturing sim_param(record).pun_pattern1 = [ ]; sim_param(record).pun_pattern2= [ ]; sim_param(record).tail_pattern1 = [ ]; sim_param(record).tail_pattern2 =... sim_param(record).tail_pattern1; %Rate = 1/2 Puncturing sim_param(record).pun_pattern1 = [ ]; sim_param(record).pun_pattern2= [ ]; sim_param(record).tail_pattern1 = [ ]; sim_param(record).tail_pattern2 =... sim_param(record).tail_pattern1;

131
Defining your Own Simulation: sim_param(record).filename = strcat( data_directory,... strcat(int2str(record), 'umts',... int2str(sim_param(record).framesize ),... sim_param(record).channel,... int2str( sim_param(record).decoder_type ), '.mat') ); sim_param(record).reset = 0; sim_param(record).max_trials = 1e9*ones(... size(sim_param(record).SNR) ); sim_param(record).minBER = 1e-8; sim_param(record).max_frame_errors = 100*... ones( 1, length(sim_param(record).SNR) ); sim_param(record).save_rate =... ceil(511400/sim_param(record).framesize); See CMLOverview.pdf slide 17 THIS IS CRITICAL: Must have unique filename for each record, or records will share data. Here it autogenerates filename based on some parameters, but if you are lazy add a strcat() of int2str(record) to ensure filename for each record # is unique, which I have done here. Save this file to save your simulation results. Set to ‘1’ to force simulation to run again, and not used previously saved results Continued on Next Page

132
Defining your Own Simulation: Number of trajectories to plot on EXIT chart, set to ‘0’ for none sim_param(record).exit_trajectories = 5; sim_param(record).exit_nframes = 100; sim_param(record).exit_iterations = 20; sim_param(record).exit_snr = -4:2:0; Number of frames for each Ia point. If you have short frames set this higher (>1000), if you have very long frames can set this much shorter. Number of iterations to plot trajectory over SNR in dB to plot EXIT charts over. Creates one chart for each point, so don’t make too many! This example plots three: -4 dB, -2 dB, and 0 dB.

133
Changing Simulation Parameters Some simulation parameters you can change without needing to reset simulation: 133 SNR filename comment legend linetype plot_iterations save_rate reset max_trials minBER minFER max_frame_errors compiled_mode input_filename trial_size scenarios exit_trajectories exit_iterations exit_snr exit_nframes NB: Reset = Throw away all previously simulated results. When changing above parameters previously simulated results can be integrated into new simulated data

134
Changing Simulation Parameters The rest you need to reset simulation by setting ‘reset=1’ in the record, otherwise you get a mismatch since some data was simulated with potentially different data (be sure to set reset back to 0 once done) 134 e.g.: >> CmlPlot('TurboTests', [9]) Initializing case (9):TC, BPSK, AWGN, 1000 bits, max-log-MAP Warning: field pun_pattern2 does not match stored value, using stored value >> CmlSimulate('TurboTests', [9]) Initializing case (9):TC, BPSK, AWGN, 1000 bits, max-log-MAP Warning: field pun_pattern2 does not match stored value, using stored value CML is not impressed.

135
EXIT CHARTS 135

136
EXIT Chart Plotting 136 >> CmlPlotExit('TurboTests', [11]) Actual Trajectories Theoretical NOTE: This function doesn’t save any state, so save your figures if they took a while to calculate!

137
EXIT Chart Plotting 137 I’m not too confident on EXIT chart accuracy. TurboTests scenario number 13 should match figure of TATC, but it doesn’t.

138
FREE DISTANCE 138

139
Free Distance Calculation Free distance calculation done by Roberto Garello’s program/algorithm from You must be in freeDistance directory Simply call a single scenario you’d like analyzed like: 139 >> cd turboUtils\freeDistance >>[dfree, Nfree, wfree] = CmlFindDfree('UmtsScenarios', [1]) Initializing case (1):UMTS-TC, BPSK, AWGN, 40 bits, max-log-MAP Calling Garellos turbo program, this step could take a while dfree = 12 Nfree = 2 wfree = 8

140
Free Distance Spectrum You do this manually by looking at output file out.txt in directory Function printBERContribution can be used to plot free distance asymptote (see earlier examples) 140

141
141 Fin Did you find this helpful? Find errors? Please let me know at or visit for

142
Review Questions 142

143
Q1: Plotting Run a simulation with a R=1/2 Turbo Code, SRandom Interleaver with S=9, Interleaver length=512 Plot iterations 1-10 over SNR of 0-3dB. Also plot the improvement in SNR for each iteration for a BER of ~10E-5 (if possible) 143

144
Q1: Plotting Hint #1: Polynomials are: feedback = [ ] feedforward = [ ] Hint #2: R=1/2 implies we are puncturing half the parity bits. See slide in this presentation entitled “Defining Your Own Simulation: 4”. Hint #3: There is no function for plotting the SNR improvement, you’ll need to read off graph (consider using MATLAB data-point picker here). 144

145
Q2: SISO Decoding The brute force MAP example used hard inputs. Can you extend that to work on soft-input decoding? – Hint #1: The code already outputs the true soft-input LOG-MAP algorithm, which should match your results – Hint #2: Doing so will require calculating probability of bit in error (pberr) for each input bit. Remember for hard-input we are only told if result of demodulating was >0 or <0, which we use with Q function to give probability bit with original value +/- 1 was thrown over zero. For soft-input we are given actual result of demodulation, so instead need to find probability bit was thrown from +/- 1 to that value instead of zero. – Hint #3: The easiest way to do the above will be to consider the output of the demodulator as LLRs. You can find a formula in the references to convert from LLR to Pb(0) and Pb(1). 145

146
Q3: Free Distance I have an idea for an interleaver which maps like this for a 1000-bit input: Columns 40 Rows

147
Q3: Continued That is, the interleaver vector would look like: [ … 999] 147

148
Q3: Continued 1.Plot the free distance asymptote for a rate 1/3 code compared to normal linear & S-Random interleavers. You can use TurboTests.m scenario 9 as a starting point (and the comparison). 2.Also plot the visualization of the interleaver to understand the performance 148

149
ANSWERS TO QUESTIONS (CHEATER) 149

150
Question Answer Scenario NB: I highly suggest trying to answer them on your own first! But the scenario file, which parts of are copied here, is in localscenarios/TurboReviewAnswers.m. 150

151
Question 1: Setup % Question 1 % Run a simulation with a R=1/2 Turbo Code, SRandom Interleaver with S=9, Interleaver length=512 % Plot iterations 1-10 over SNR of 0-3dB. % Also plot the improvement in SNR for each iteration for a BER of ~10E-5. record = 1; sim_param(record).comment = 'Review Question 1'; sim_param(record).SNR = 0:.2:3; sim_param(record).framesize = 512; sim_param(record).channel = 'AWGN'; sim_param(record).decoder_type = 1; sim_param(record).max_iterations = 10; sim_param(record).plot_iterations = [1:sim_param(record).max_iterations]; sim_param(record).linetype = 'r-'; sim_param(record).sim_type = 'coded'; sim_param(record).code_configuration = 1; sim_param(record).SNR_type = 'Eb/No in dB'; sim_param(record).modulation = 'BPSK'; sim_param(record).mod_order = 2; sim_param(record).bicm = 1; sim_param(record).demod_type = 0; sim_param(record).legend = sim_param(record).comment; sim_param(record).code_interleaver =... strcat( 'CreateSRandomInterleaver(', int2str(sim_param(record).framesize ), ', 9)' ); 151

152
Question 1: Setup Continued %From question slide: % d1(D)=1+D^2+D^3 <= Feedback = [1011] % d2(D)=1+D+D^3+D^4 <= Feedforward = [1111] sim_param(record).g1 = [ ]; sim_param(record).g2 = sim_param(record).g1; sim_param(record).nsc_flag1 = 0; sim_param(record).nsc_flag2 = 0; sim_param(record).pun_pattern1 = [ ]; sim_param(record).pun_pattern2= [ ]; sim_param(record).tail_pattern1 = [ ]; sim_param(record).tail_pattern2 = sim_param(record).tail_pattern1; sim_param(record).filename = strcat( data_directory,... strcat( 'q1', int2str(sim_param(record).framesize ), sim_param(record).channel, int2str( sim_param(record).decoder_type ), '.mat') ); sim_param(record).reset = 0; sim_param(record).max_trials = 1e9*ones(size(sim_param(record).SNR) ); sim_param(record).minBER = 1e-6; sim_param(record).max_frame_errors = 200*ones( 1, length(sim_param(record).SNR) ); sim_param(record).save_rate = ceil(511400/sim_param(record).framesize); 152

153
Question 1: Running Commands >> CmlSimulate('TurboReviewAnswers', [1]) Initializing case (1):Review Question 1 Record 1 Review Question 1 ….. >> CmlPlot('TurboReviewAnswers', [1]) 153

154
Question 1: BER Results 154

155
Question 2: SISO Decoder NB: Files located in doc/resources/question_answers/q2_softbrute 1.Output of demodulator is used as input LLR 2.Convert LLR to probability of error for each bit 3.Use that probability in calculation of probability of word in error 4.Rest of file is same as in the hard input 155

156
Code Clips %Demodulate rx_demodulated = -2*rx./variance; %Chop into binary received = (sign(rx_demodulated) + 1)/2; % Do MAP Algorithm fprintf('Result of decoding:\n'); [llrs, resultingCodeword] = brute_force_map_soft(feedback, feedforward, received, rx_demodulated, nbits) 156

157
Code Clips 157 %Convert input LLR into pberr, this equation is: %D = exp(-LLR/2) / (1+exp(-LLR); %P1 = D * exp(LLR/2) %P0 = D * exp(-LLR/2) %Error will be minimum of those two pberr = zeros(1,nbits); for i=1:length(llr_input) D = exp(-llr_input(i)/2) / (1+exp(-llr_input(i))); pberr(i) = min([D*exp(llr_input(i)/2) D*exp(- llr_input(i)/2) ]); end

158
%For every possible codeword & ours: find out Pcodeword for i=1:2^nbits %Generates an error vector indicating which bits are different %between received codeword & codeword we are testing against bitsInDiff = abs(input - all_codewords(i,:)); %Generates a vector with only the probabilities of bits in error pbErrVect = bitsInDiff.* pberr; %Get non-zero elements, multiple together, this works on previous %operation which got only probabilities of bits we care about pbCodeError = prod(pbErrVect(find(pbErrVect))); %Do same steps as above, I haven't duplicate the documentation %though bitsSame = 1-bitsInDiff; pbOkVect = bitsSame.* (1-pberr); pbCodeOk = prod(pbOkVect(find(pbOkVect))); %Find APP Pr{X | Y} % X = Codeword that was transmitted % Y = Codeword that was receieved pcodeword(i) = pbCodeError * pbCodeOk; end 158

159
Q3: Fancy (or not?) Interleaver 159 function [output] = q3_interleaver(rows, cols) linput = rows*cols; input = [0:linput-1]; output = zeros(1,length(input)); input = reshape(input, cols, rows)'; j = 1; for startingrow=1:rows; %Start at left point in each row... col = 1; row = startingrow; while row > 0 && col <= cols output(j) = input(row,col); col = col+1; row = row-1; j = 1+j; end for startingcol=2:cols; %Do bottom row all way along col = startingcol; row = rows; while row > 0 && col <= cols output(j) = input(row,col); col = col+1; row = row-1; j = 1+j; end

160
Q3: Fancy (or not?) Interleaver record = 2; % Copy everything from our reference sim_param(record) = sim_param(9); sim_param(record).code_interleaver =... strcat( 'q3_interleaver(25, 40)' ); Assuming record 9 is setup using Linear, and 10 is using SRandom, and you are in directory with q3_interleaver.m: >> [df1, nf1, wf1] = CmlFinddFree('TurboReviewAnswers ', [2]) >> [df2, nf2, wf2] = CmlFinddFree('TurboReviewAnswers', [9]) >> [df3, nf3, wf3] = CmlFinddFree('TurboReviewAnswers', [10]) >> printBERContribution( df1, nf1, wf1, 1000, 1/3 ) >> hold on >> printBERContribution( df2, nf2, wf2, 1000, 1/3 ) >> printBERContribution( df3, nf3, wf3, 1000, 1/3 ) 160

161
Q3 Results: Not Very Good 161

162
Q3 Results: Not Very Good 162

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google