ldpc;\r
\r
%\r
-sim_in.Eprob = 0.1; \r
-disp([' test with erasure probability of ' num2str(sim_in.Eprob)]); \r
+%sim_in.Eprob = 0.1; \r
+%disp([' test with erasure probability of ' num2str(sim_in.Eprob)]); \r
\r
-sim_in.comment = 'test ldpc';\r
-sim_in.Esvec = 8:1/2:11; \r
+%sim_in.comment = 'test ldpc';\r
+%sim_in.Esvec = 8:1/2:11; \r
\r
%sim_in.rate = 3/4;\r
%sim_in.framesize = 16200\r
--- /dev/null
+% LDPC unit test script\r
+% David Rowe 18 Dec 2013\r
+% Based on siulation by Bill Cowley\r
+\r
+% Start CML library\r
+\r
+currentdir = pwd;\r
+addpath '/home/david/tmp/cml/mat' % assume the source files stored here\r
+cd /home/david/tmp/cml\r
+CmlStartup % note that this is not in the cml path!\r
+cd(currentdir)\r
+\r
+% Our LDPC library\r
+\r
+ldpc;\r
+\r
+% Start simulation\r
+\r
+rate = 3/4; \r
+framesize = 576; \r
+\r
+mod_order = 4; \r
+modulation = 'QPSK';\r
+mapping = 'gray';\r
+\r
+demod_type = 0;\r
+decoder_type = 0;\r
+max_iterations = 100;\r
+\r
+code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping);\r
+\r
+Ntrials = 84;\r
+EsNo=10;\r
+\r
+Tbits = Terrs = Ferrs = 0;\r
+ \r
+data = [];\r
+r = []; \r
+\r
+% Encode a bunch of frames\r
+\r
+for nn = 1: Ntrials \r
+ d = round( rand( 1, code_param.data_bits_per_frame ) );\r
+ data = [data d];\r
+ [codeword, s] = ldpc_enc(d, code_param);\r
+ code_param.code_bits_per_frame = length(codeword);\r
+ code_param.symbols_per_frame = length(s);\r
+ r = [r s];\r
+end\r
+\r
+% Decode a bunch of frames\r
+\r
+for nn = 1: Ntrials \r
+ st = (nn-1)*code_param.symbols_per_frame + 1;\r
+ en = (nn)*code_param.symbols_per_frame;\r
+ detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, r(st:en), EsNo);\r
+ st = (nn-1)*code_param.data_bits_per_frame + 1;\r
+ en = (nn)*code_param.data_bits_per_frame;\r
+ error_positions = xor( detected_data(1:code_param.data_bits_per_frame), data(st:en) );\r
+ Nerrs = sum( error_positions);\r
+ \r
+ if Nerrs>0, fprintf(1,'x'), else fprintf(1,'.'), end\r
+ if (rem(nn, 50)==0), fprintf(1,'\n'), end \r
+ if Nerrs>0, Ferrs = Ferrs +1; end\r
+ Terrs = Terrs + Nerrs;\r
+ Tbits = Tbits + code_param.data_bits_per_frame; \r
+end\r
+fprintf(1,'\n')\r
+\r