This is matlab code for LTE turbo encoder and log-map based decoder. Simulation result is as above. To run the test, run “turbo_top” in matlab env. Program prompts for some inputs and you can just type return to use default settings. It will take some time to go through several Eb/N0 scenarios and at the end of simulation, BER vs Eb/N0 curve is plotted.
HereĀ is some sample code. Full matlab codeĀ is attached.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
%% TOP % project: TurboCodec % name: Turbo decoder % note: % <Implemention of TurboDecoder under the LTE Standards> % G = [ 1 0 1 1; 1 1 0 1]; % rate = 1/3; % version: v1.0 % %--------------------------------------------------------------------- function [source_code] = lte_turbo_decoder(input_LLR,blocksize,f1,f2,algorithm,iter) %% function description % input_LLR: from demodulater % blocksize: length of interleaver % f1, f2: parameters of interleaver % algorithm: choose a decoding algorithm, % for '1' is Log_Map, % for '2' is Max_Log_Map % iter: number of iteration % % source_code: decoding result %% function initial x = input_LLR(:,1); % z1 = input_LLR(:,2); % z2 = input_LLR(:,3); % %________________________________ if length(x) ~= blocksize+4 disp('ERROR ! length(x) != K+4 '); error('length(x)= %d',length(x)); error('K+4 = %d',blocksize+4); end %%initial values in_s = zeros(blocksize+4,2); in_i = zeros(blocksize+4,2); %SISO_1 in_s(:,1) = x; in_s(:,2) = z1; %SISO_2 % x_i = zeros(blocksize+4,1);% %________________________________________________________ % M = 1; w=blocksize/M; id = M-1; % id from 0 to M-1 id_w = id*w + w -1; init_s = 0; init_i = 0; init_theta = mod( (f1+f2+2*f2*init_s), blocksize); % [adrs_s,adrs_i] = interleaver(init_s,init_i,init_theta,blocksize,id_w,f2); %interleaver outputs two addresses[ adrs_s, adrs_i] %_____________________________________________________________ for i=1:blocksize+4 if i <= blocksize x_i(i) = x( adrs_i(i)+1 ); else x_i(i) = x(i); end end in_i(:,1) = x_i; in_i(:,2) = z2; % %% ____________Call SISO LOG-MAP or MAX-LOG-MAP___________________________ % %_____________________________________________________________ %disp('%_______________go to itel.--------------'); % ex_info = zeros(blocksize+4,1); % ex_info_s = zeros(blocksize+4,1); ex_info_i = zeros(blocksize+4,1); %_____________________________________ for i=1:iter %ex_info_s = zeros(blocksize+4,1); for j=1:blocksize+4 if j <= blocksize % ex_info_s( adrs_i(j)+1 ) = ex_info( adrs_s(j)+1 ); else ex_info_s( j ) = ex_info(j); end end ex_info = ex_info_s; %CALL SISO 1 if algorithm == 2 [soft_out,ex_info]=siso_mlm(in_s,ex_info);%% else [soft_out,ex_info]=siso_lm(in_s,ex_info);% %[soft_out,ex_info] = log_map(in_s,ex_info); end %interleave address: [adrs_s adrs_i ] for j=1:blocksize+4 if j <= blocksize ex_info_i(j) = ex_info( adrs_i(j)+1 ); else ex_info_i(j) = ex_info(j); end end ex_info = ex_info_i; %CALL SISO 2 if algorithm == 2 [soft_out,ex_info]=siso_mlm(in_i,ex_info);%% else [soft_out,ex_info]=siso_lm(in_i,ex_info);% % [soft_out,ex_info] = log_map(in_i,ex_info); end end %.................................... %------------------------------------ %% soft outputs soft_out_s = zeros(blocksize+4,1); % for j=1:blocksize+4 if j <= blocksize % soft_out_s( adrs_i(j)+1 ) = soft_out( adrs_s(j)+1 ); else soft_out_s( j ) = soft_out(j); end end %________________________________________ %% hard decision LLR = soft_out_s; %---------------------------------------- source_code = zeros(blocksize,1); for i=1:blocksize if LLR(i) >= 0 source_code(i) = 1; else source_code(i) = 0; end end % %% ------------end of Decoding--------- |
The following is site premium content.
Use points to gain access. You can either purchase points or contribute content and use contribution points to gain access.
Use points to gain access. You can either purchase points or contribute content and use contribution points to gain access.
Highlights: 61 words
Groups:
Tags:
I need this too !
I need this
Nice
Good! Just what I am looking for.