first pass at ldpc ut script
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 19 Dec 2013 01:45:02 +0000 (01:45 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 19 Dec 2013 01:45:02 +0000 (01:45 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1346 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ldpcenc.m
codec2-dev/octave/ldpcut.m [new file with mode: 0644]

index 3a9a51d374ac3a099544aac154494624387bbd92..6c449272e8cabe34d461e2d9893d1b632e364e9a 100644 (file)
@@ -15,11 +15,11 @@ cd(currentdir)
 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
diff --git a/codec2-dev/octave/ldpcut.m b/codec2-dev/octave/ldpcut.m
new file mode 100644 (file)
index 0000000..80142ba
--- /dev/null
@@ -0,0 +1,69 @@
+% 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