- DSP log - http://www.dsplog.com -

Matlab or C for Viterbi Decoder?

Posted By Krishna Sankar On August 21, 2009 @ 5:21 am In Coding | 23 Comments

Are you bothered by speed of the speed of the simulations which you develop in Matlab/Octave? I was not bothered much, till I ran into the Viterbi decoder. If you recall, the Matlab/Octave simulation script for BER computation with hard soft decision Viterbi algorithm provided in post Viterbi with finite survivor state memory [1] took around 10 hours to run.

I knew C was much faster, so I coded the simulation again in C. Of Course, coding in C was much more difficult. I missed many functions (like conv(), rand(), randn() etc), the plotting capabilities and the statistical analysis capabilities of Matlab/Octave.

To have a graphical debug environment for C, I installed KDbg [2]. I already had the gcc [3] compiler installed, and I was all set to go. The C code, executed in 14 seconds !!!

home@home-desktop:$ gcc -g -lm script_ber_bpsk_convolutional_code_viterbi_decode.c
script_ber_bpsk_convolutional_code_viterbi_decode.c: In function ‘main’:
script_ber_bpsk_convolutional_code_viterbi_decode.c:54: warning: incompatible implicit declaration of built-in function ‘exp10’
home@home-desktop:$ date;./a.out; date
Fri Aug 21 05:35:09 IST 2009
|BER for BPSK in AWGN with hard/soft Viterbi decoder
|----------------------------------------------
|Eb/N0 | BER (sim) | BER (sim) | BER (theory) |
| (dB) | (hard)    | (soft)    | (uncoded)    |
|----------------------------------------------
|  0   | 0.198044  | 0.096864  | 0.078650     |
|  1   | 0.128787  | 0.045707  | 0.056282     |
|  2   | 0.072306  | 0.017853  | 0.037506     |
|  3   | 0.032038  | 0.005107  | 0.022878     |
|  4   | 0.011104  | 0.001269  | 0.012501     |
|  5   | 0.002886  | 0.000277  | 0.005954     |
|  6   | 0.000696  | 0.000054  | 0.002388     |
|  7   | 0.000100  | 0.000005  | 0.000773     |
|  8   | 0.000014  | 0.000000  | 0.000191     |
|  9   | 0.000000  | 0.000000  | 0.000034     |
Fri Aug 21 05:35:24 IST 2009
home@home-desktop:$

Please click here to download the C code for simulating BER for BPSK with convolutional coding with hard/soft decision Viterbi having finite survivor state memory [4].

Poll

I created a poll to collect your feedback on the choice of programming language. You can chose any two from Matlab/Octave/C/Scilab/Simulink/Others. If you chose “Others”, please specify some more details of the programming language in the Comments section.

Which programming language do you prefer? (can chose any two)

View Results [5]

Loading ... Loading ...

Note: RSS/email subscribers need to visit the site for participating and seeing the results from the poll.


Article printed from DSP log: http://www.dsplog.com

URL to article: http://www.dsplog.com/2009/08/21/matlab-or-c-for-viterbi-decoder/

URLs in this post:

[1] Viterbi with finite survivor state memory: http://www.dsplog.com/2009/07/27/viterbi-with-finite-survivor-state-memory/

[2] KDbg: http://www.kdbg.org/

[3] gcc: http://gcc.gnu.org/

[4] C code for simulating BER for BPSK with convolutional coding with hard/soft decision Viterbi having finite survivor state memory: http://www.dsplog.com/db-install/wp-content/uploads/2009/08/script_ber_bpsk_convolutional_code_viterbi_decode.c

[5] View Results: #ViewPollResults

[6] click here to SUBSCRIBE : http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1348583&loc=en_US

Copyright © 2007-2012 dspLog.com. All rights reserved. This article may not be reused in any fashion without written permission from http://www.dspLog.com.