% Octave simulation of BPSK with short LDPC codes developed by Bill. First step\r
% in use of LDPC codes with FreeDV and Codec 2 700C.\r
%\r
-% See lpdc.m for instruction son how to install CML library\r
+% NOTE: You will need to set the CML path in the call to init_cml() below\r
+% for you CML install. See lpdc.m for instructions on how to install \r
+% CML library\r
\r
1;\r
\r
-function init_cml\r
+\r
+function init_cml(path_to_cml)\r
currentdir = pwd;\r
- thiscomp = computer;\r
-\r
- if strfind(thiscomp, 'pc-linux-gnu')==8 \r
- if exist('LdpcEncode')==0, \r
- %cd '~/cml'\r
- cd '/home/david/Desktop/cml'\r
- CmlStartup \r
- end\r
+ \r
+ if exist(path_to_cml, 'dir') == 7\r
+ cd(path_to_cml)\r
+ CmlStartup \r
+ cd(currentdir); \r
+ else\r
+ printf("\n---------------------------------------------------\n");\r
+ printf("Can't start CML in path: %s\n", path_to_cml);\r
+ printf("See CML path instructions at top of this script\n");\r
+ printf("-----------------------------------------------------\n\n");\r
+ assert(0);\r
end\r
- cd(currentdir); \r
end\r
\r
\r
max_iterations, decoder_type, 1, 1);\r
Niters = sum(PCcnt!=0);\r
detected_data = x_hat(Niters,:);\r
+\r
+ if isfield(sim_in, "c_include_file") \r
+\r
+ % optionally dump code and unit test data to a C header file\r
+\r
+ code_param.c_include_file = sim_in.c_include_file;\r
+ ldpc_gen_h_file(code_param, max_iterations, decoder_type, input_decoder_c, x_hat, detected_data);\r
+ end\r
+\r
detected_data = detected_data(1:code_param.data_bits_per_frame);\r
end\r
\r
endfunction\r
\r
\r
+% Used to generate C header file for C port\r
+\r
+function run_c_header\r
+\r
+ sim_in.code = 'ldpc';\r
+ load HRA_112_112.txt\r
+ data_bits_per_frame = 112;\r
+ rate = 0.5;\r
+ bits = data_bits_per_frame;\r
+ Ntrials = bits/data_bits_per_frame;\r
+ sim_in.genie_Es = 1;\r
+ sim_in.packet_size = 28;\r
+ EbNodB = 2;\r
+ sim_in.hf_en = 0;\r
+ sim_in.Esvec = EbNodB + 10*log10(rate);\r
+ sim_in.c_include_file = "../src/HRA_112_112.h";\r
+\r
+ sim_out = run_sim(sim_in, HRA_112_112, Ntrials);\r
+endfunction\r
+\r
+\r
% Start simulation here ----------------------------------------------\r
\r
+% change this path for your CML installation\r
+\r
+init_cml('/home/david/Desktop/cml');\r
+\r
rand('seed',1);\r
randn('seed',1);\r
more off;\r
format;\r
-init_cml;\r
close all;\r
\r
-plot_curves(0);\r
-plot_curves(1);\r
+% plotting curves (may take a while)\r
+\r
+%plot_curves(0);\r
+%plot_curves(1);\r
+\r
+% generating error files \r
+\r
+run_single(700*10, 'ldpc', 'awgn', 2, 'awgn_2dB_ldpc.err')\r
+run_single(700*10, 'diversity', 'awgn', 2, 'awgn_2dB_diversity.err')\r
+run_single(700*10, 'ldpc', 'hf', 6, 'hf_6dB_ldpc.err')\r
+run_single(700*10, 'diversity', 'hf', 6, 'hf_6dB_diversity.err')\r
\r
-%run_single(700*10, 'ldpc', 'awgn', 2, 'awgn_2dB_ldpc.err')\r
-%run_single(700*10, 'diversity', 'awgn', 2, 'awgn_2dB_diversity.err')\r
-%run_single(700*10, 'ldpc', 'hf', 6, 'hf_6dB_ldpc.err')\r
-%run_single(700*10, 'diversity', 'hf', 6, 'hf_6dB_diversity.err')\r
+% generate C header for C port of code\r
\r
+%run_c_header\r