You are on page 1of 5

%% Turbo Code % Encoder: RSC (Recursive Systematic Convolution) % Decoder: BCJR iterative decoder % Author: o!

esh " Soni#al % Email: yo!eshsoni#al$!mail%com % &ast 'odi(ied : )*th Se+tember, )-*. %% /arameter declaration close all0clear all0clc0 12*E30 %Bloc4 len!th 52(loor()6rand(*,1))0 %7n(ormation bit !eneration 7nterleaver2rand+erm(1)0 %7nterleaver(random +ermutation o( (irst 1 inte!ers) S1RdB2-:-%8:90 %S1R in dB S1R2*-%:(S1RdB;*-)0 %S1R in linear scale 7teration230 ber2<eros(len!th(S1R),7teration)0 %Simulated BER(Each column corres+onds to one iteration) %% Encodin! 5=+i(*:1)25(7nterleaver(*:1))0 %7nterleavin! in+ut bits (or RSC>* encoder C-2<eros(*,1)0 %Code Bit (or encoder RSC>- C*2<eros(*,1)0 %Code Bit (or encoder RSC>* (or i2*:1 4 2 i0 #hile (4 ?2 *) C-(i) 2 @or ( C-(i),5(4) )0 C*(i) 2 @or ( C*(i),5=+i(4) )0 424>)0 end end /- 2 @or (5,A-,C-(*:end>*)B)0 /* 2 @or (5=+i,A-,C*(*:end>*)B)0 7n+ut=matri@2)6A-,*0-,*0-,*0-,*B>*0 %Cirst column re+resents in+ut2- and second column re+resents in+ut2* %Each ro# re+resents state --,*-,-* and ** res+ectively /arity=bit=matri@2)6A-,*0*,-0-,*0*,-B>*0 %/arity bits corres+ondin! to in+uts o( above matri@ mod=code=bit-2)65>*0 %'odulatin! Code Bits usin! B/S" 'odulation mod=code=bit*2)6/->*0 mod=code=bit)2)6/*>*0 (+rint((DEncodin! com+leted%%%EnD)0 %% Decodin! (or 42*:len!th(S1R) %Simulation starts here R-2sFrt(S1R(4))6mod=code=bit-Grandn(*,1)0 % Received Codebits Corres+ondin! to in+ut bits R*2sFrt(S1R(4))6mod=code=bit*Grandn(*,1)0 % Received Codebits Corres+ondin! to +arity bits o( RSC>R)2sFrt(S1R(4))6mod=code=bit)Grandn(*,1)0 % Received Codebits Corres+ondin! to +arity bits o( RSC>* R-=+i(*:1)2R-(7nterleaver(*:1))0 %7nterleavin! received codebits corres+ondin! to in+ut bits to be used by RSC>* BCJR2-0 %Cirst iteration #ill be done by BCJR>A+riori2ones(),1)0 %Cirst ro# (or +rob% o( i;+ - and second ro# (or +rob% o( i;+ * A+riori2A+riori6-%80 %7nitiali<in! all a+riori to *;) (or iter2*:7teration %7terative +rocess starts here i( BCJR22%7( BCJR is - then +ass R- and R* to calculate HA''A HA''A2!amma=*(A+riori,1,7n+ut=matri@,/arity=bit=matri@,R-,R*,S1R(4))0 else %7( BCJR is * then +ass R-=+i and R) to calculate HA''A HA''A2!amma=*(A+riori,1,7n+ut=matri@,/arity=bit=matri@,R-=+i,R),S1R(4))0 end A&/IA2al+ha=*(HA''A,1)0 %Calculation o( A&/IA at each sta!e usin! HA''A and A&/IA o( +revious sta!e BETA2beta=*(HA''A,1)0 %Calculation o( BETA at each sta!e usin! HA''A and BETA o( ne@t sta!e %Calculatin! &A//R usin! A&/IA,BETA and HA''A AJ,J,&A//R=*B2la++r(A&/IA,BETA,HA''A,1)0 decoded=bits2<eros(*,1)0 decoded=bits(&A//R=*?-)2*0 %Decodin! is done usin! &A//R values i( BCJR22%7( the decoder is BCJR>then ber(4,iter)2sum(abs((decoded=bits>5)))0 %calculate BER usin! in+ut 5 la++r=)(*:1)2&A//R=*(7nterleaver(*:1))0 %7nterleave the &A//R values and +ass to BCJR>* else %7( the decoder is BCJR>* then ber(4,iter)2sum(abs((decoded=bits>5=+i)))0 %calculate BER usin!

in+ut 5=+i la++r=)(7nterleaver(*:1))2&A//R=*(*:1)0 %Re>interleave the &A//R values and +ass to BCJR>end &A//R=*2la++r=)0 ber(ber22*)2-0 %7!norin! * bit error A+riori(*,*:1)2*%;(*Ge@+(&A//R=*))0 %A+riori corres+ondin! to in+ut A+riori(),*:1)2e@+(&A//R=*)%;(*Ge@+(&A//R=*))0 %A+riori corres+ondin! to in+ut * BCJR2JBCJR0 %Chan!in! the state o( the decoder (or the ne@t iteration end %Kne iteration ends here u2 4;len!th(S1R) 6 *--0 strin! 2 Anum)str(round(u)) , D% decodin! com+leted %%%DB0 dis+(strin!)0 end ber2ber;10 (i!ure0 %% /lots (or simulated BER semilo!y(S1RdB,ber(:,*),D4>>D,Dline#idthD,)%-)0 hold on semilo!y(S1RdB,ber(:,)),Dm>oD,Dline#idthD,)%-)0 hold on semilo!y(S1RdB,ber(:,.),Db>LD,Dline#idthD,)%-)0 hold on semilo!y(S1RdB,ber(:,3),Dr>LD,Dline#idthD,)%-)0 %% Theoretical e@+ression (or BER (or corres+ondin! convolution code BER2<eros(*,len!th(S1R))0 (or M2*:*BER2BERG():M)6(M)6F(unc(sFrt((MG3)6S1R))0 end semilo!y(S1RdB,BER,Dc>D,Dline#idthD,)%-) title(DTurbo decoder +er(ormance over ANH1 channel (or B/S" modulated symbolsD)0 @label(DS1R(dB)D)0ylabel(DBERD)0 le!end(D*st 7terationD,D)nd 7terationD,D.rd 7terationD,D3th 7terationD,DTheoretical BoundD)0 !rid on a@is ti!ht Com+uter /ro!rams Nith Source Code 7( you are #orried about com+uter +ro!ram% 1o# you can (ind all com+uter +ro!rams here% To search, ty+e and hit enter &inear Convolution /osted by Ritesh Jain O -9:-9 O C /ro!rams, DS/ /ro!ram, 'AT&AB O - comments P A7': To veri(y &inear Convolution% EQR7/'E1TS: K+eratin! System S Nindo#s 5/ Constructor > Simulator So(t#are > CCStudio . T 'AT&AB U%8 TIEKR : Convolution is a (ormal mathematical o+eration, Must as multi+lication, addition, and inte!ration% Addition ta4es t#o numbers and +roduces a third number, #hile convolution ta4es t#o si!nals and +roduces a third si!nal% Convolution is used in the mathematics o( many (ields, such as +robability and statistics% 7n linear systems, convolution is used to describe the relationshi+ bet#een three si!nals o( interest: the in+ut si!nal, the im+ulse res+onse, and the out+ut si!nal% 7n this eFuation, @*(4), @)(n>4) and y(n) re+resent the in+ut to and out+ut (rom the system at time n% Iere #e could see that one o( the in+ut is shi(ted in time by a value every time it is multi+lied #ith the other in+ut si!nal% &inear Convolution is Fuite o(ten used as a method o( im+lementin! (ilters o( various ty+es% /RKHRA':

;; &inear convolution +ro!ram in c lan!ua!e usin! CCStudio VincludeLstdio%h? int @A*8B,hA*8B,yA*8B0 main() W int i,M,m,n0

+rint((XEn enter value (or mX)0 scan((X%dX,Tm)0 +rint((XEn enter value (or nX)0 scan((X%dX,Tn)0 +rint((XEnter values (or i;+ @(n):EnX)0 (or(i2-0iLm0iGG) scan((X%dX,T@AiB)0 (or(i2-0iLn0 iGG)

+rint((XEnter Yalues (or i;+ h(n) EnX)0 scan((X%dX,ThAiB)0 ;; +addin! o( <eors (or(i2m0iL2mGn>*0iGG) @AiB2-0 Cate!ories

Z-Z8 'icro+rocessor (8) A++lied Chemistry (.) Assembly &an!ua!e (8) C /ro!rams (*.) Com+uter Hra+hics (9) DS/ /ro!ram ()) 'AT&AB ()) YID& (*.) Recent Readers Archives )-** (.3) &ive Tra((ic Ceed Entries (RSS) Comments (RSS) &7"E 7T Collo#ers #ith Hoo!le Criend Connect 'embers (.) Already a member[Si!n in &i4e Send 3 +eo+le li4e this% Be the (irst o( your (riends% /a!e* o(.&inear Convolution O Com+uter /ro!ram Nith Source Code -U>**>)-*.htt+:;;allcom+uter+ro!rams%blo!s+ot%in;)-**;-9;linear >convolution%html (or(i2n0iL2mGn>*0iGG)

hAiB2-0 ;6 convolution o+eration 6; (or(i2-0iLmGn>*0iGG) W yAiB2-0 (or(M2-0ML2i0MGG) W yAiB2yAiBG(@AMB6hAi>MB)0 \ \ ;;dis+layin! the o;+ (or(i2-0iLmGn>*0iGG) +rint((XEn The Yalue o( out+ut yA%dB2%dX,i,y AiB)0 \ Result: enter value (or m 8 enter value (or n 8 Enter values (or i;+ * ) . 3 8 Enter Yalues (or h * ) . 3 8 The Yalue o( out+ut yA-B2* The Yalue o( out+ut yA*B23 The Yalue o( out+ut yA)B2*- The Yalue o( out+ut yA.B2)- The Yalue o( out+ut yA3B2.8 The Yalue o( out+ut yA8B233 The Yalue o( out+ut yA]B23] The Yalue o( out+ut yAUB23- The Yalue o( out+ut yAZB2)8 % 'AT&AB +ro!ram (or linear convolution %linear convolution +ro!ram clc0 clear all0 close all0 dis+(Dlinear convolution +ro!ramD)0 @2in+ut(Denter i;+ @(n):D)0 m2len!th(@)0 h2in+ut(Denter i;+ h(n):D)0 n2len!th(h)0 @2A@,<eros(*,n)B0 sub+lot(),),*), stem(@)0 title(Di;+ seFuencce @(n)is:D)0 @label(D>>>> ?nD)0 ylabel(D>>>>?@(n)D)0!rid0 h2Ah,<eros(*,m)B0 sub+lot(),),)), stem(h)0 SEK Services T Tools Submit E@+ress Clic4 here to submit your site to the search en!ines (or (ree^ htt+:;;###%submitdomainname%com &ive Tra((ic Ceed

A visitor (rom Chennai, Tamil 1adu vie#ed X&inear Convolution O Com+uter /ro!ram Nith Source CodeX - secs a!o A visitor (rom ThanMavur, Tamil 1adu vie#ed X&inear Convolution O Com+uter /ro!ram Nith Source CodeX 8- secs a!o A visitor (rom 'umbai, 'aharashtra vie#ed XZ-Z8 'icro+rocessor Assembly &an!ua!e /ro!ram to Add t#o Z>bit numbers O Com+uter /ro!ram Nith Source CodeX * hour 3U mins a!o A visitor (rom Ali!arh, Rttar /radesh vie#ed X/ro!ram to Add t#o BCD 1umbers O Com+uter /ro!ram Nith Source CodeX . hours 9 mins a!o A visitor (rom Chennai, Tamil 1adu vie#ed X&inear Convolution O Com+uter /ro!ram Nith Source CodeX 3 hours .9 mins a!o A visitor (rom Rohta4, Iaryana vie#ed X/ro!ram to Dra# Sin!le /i@el on Screen O Com+uter /ro!ram Nith Source CodeX ] hours )Z mins a!o A visitor (rom Bhubanes#ar, Krissa vie#ed XZ-Z8 'icro+rocessor Assembly &an!ua!e /ro!ram to Add t#o Z>bit numbers O Com+uter /ro!ram Nith Source CodeX U hours *U mins a!o A visitor (rom 'a+le Hrove, 'innesota vie#ed XDesi!n and Yeri(y Cull Subtractor by Rsin! Behavioural 'odel #ith i(,elsi( T then Statements /a!e) o(.&inear Convolution O Com+uter /ro!ram Nith Source Code -U>**>)-*.htt+:;;allcom+uter+ro!rams%blo!s+ot%in;)-**;-9;linear >convolution%html 1e#er /ost Klder /ost title(Di;+ seFuencce h(n)is:D)0 @label(D>>>>?nD)0 ylabel(D>>>>?h(n)D)0!rid0 dis+(Dconvolution o( @(n) T h(n) is y(n):D)0 y2<eros(*,mGn>*)0 (or i2*:mGn>* y(i)2-0 y(i)2y(i)G@(M)6h(i>MG*)0 (or M2*:mGn>* end end end i((MLiG*)

y sub+lot(),),A.,3B),stem(y)0 title(Dconvolution o( @(n) T h(n) is :D)0 @label(D>>>>?nD)0 ylabel(D>>>>?y(n)D)0!rid0 Result : - comments /ost a Comment Iome Subscribe to: /ost Comments (Atom) Com+uter /ro!rams Nith Source Code by Ritesh "umar Jain Jum+ to TK/ /a!e. o(.&inear Convolution O Com+uter /ro!ram Nith Source Code -U>**>)-*.htt+:;;allcom+uter+ro!rams%blo!s+ot%in;)-**;-9;linear >convolution%html

You might also like