% attempt to start up CML, path will be different on your machine
-path_to_cml = '/home/david/Desktop/cml/mex';
-addpath(path_to_cml);
+path_to_cml = '~/cml';
+addpath(strcat(path_to_cml, "/mex"), strcat(path_to_cml, "/mat"));
cml_support = 0;
if exist("Somap") == 0
printf("Can't find CML mex directory so we won't run those tests for now...\n");
assert(Nbitsperframe == (code_param.code_bits_per_frame + states.Nuwbits + states.Ntxtbits));
end
+tx_bits = zeros(1,Nbitsperframe);
rand('seed',1);
-tx_bits = round(rand(1,Nbitsperframe));
+
+payload_data_bits = round(rand(1,(Nbitsperframe-Nuwbits-Ntxtbits)/2));
if cml_support
- ibits = tx_bits(Nuwbits+Ntxtbits+1:Nuwbits+Ntxtbits+code_param.data_bits_per_frame);
+ ibits = payload_data_bits;
codeword = LdpcEncode(ibits, code_param.H_rows, code_param.P_matrix);
tx_bits(Nuwbits+Ntxtbits+1:end) = codeword;
+else
+ tx_bits(Nuwbits+Ntxtbits+1:end) = [payload_data_bits payload_data_bits];
end
-tx_bits(1:Nuwbits+Ntxtbits) = 0;
+tx_bits(1:Nuwbits+Ntxtbits) = [states.tx_uw zeros(1,Ntxtbits)];
% Run tx loop
symbol_likelihood = Demod2D(arx_np(Nuwtxtsymbolsperframe+1:end), S_matrix, EsNo, arx_amp(Nuwtxtsymbolsperframe+1:end));
bit_likelihood = Somap(symbol_likelihood);
- [x_hat errors] = MpDecode(-bit_likelihood(1:code_param.code_bits_per_frame), code_param.H_rows, code_param.H_cols, max_iterations, decoder_type, 1, 1);
- detected_data = x_hat(max_iterations,:);
-
+ [x_hat paritychecks] = MpDecode(-bit_likelihood(1:code_param.code_bits_per_frame), code_param.H_rows, code_param.H_cols, max_iterations, decoder_type, 1, 1);
+ [mx mx_ind] = max(paritychecks);
+ detected_data = x_hat(mx_ind,:);
+
% make sure LDPC decoding is working OK
assert(codeword == detected_data);
check(sample_point_log, sample_point_log_c, 'sample_point');
check(foff_hz_log, foff_hz_log_c, 'foff_est_hz');
check(rx_bits_log, rx_bits_log_c, 'rx_bits');
-check(symbol_likelihood_log, symbol_likelihood_log_c, 'symbol_likelihood_log');
-check(bit_likelihood_log, bit_likelihood_log_c, 'bit_likelihood_log');
-check(detected_data_log, detected_data_log_c, 'detected_data');
+if cml_support
+ check(symbol_likelihood_log, symbol_likelihood_log_c, 'symbol_likelihood_log');
+ check(bit_likelihood_log, bit_likelihood_log_c, 'bit_likelihood_log');
+ check(detected_data_log, detected_data_log_c, 'detected_data');
+end
#define CODED_BITSPERFRAME 224 /* number of LDPC codeword bits/frame */
+/* QPSK constellation for symbol likelihood calculations */
+
+static COMP S_matrix[] = {
+ { 1.0f, 0.0f},
+ { 0.0f, 1.0f},
+ { 0.0f, -1.0f},
+ {-1.0f, 0.0f}
+};
+
/*---------------------------------------------------------------------------*\
FUNCTION....: fs_offset()
/* See CML startup code in tofdm.m */
+ for(i=0; i<OFDM_NUWBITS; i++) {
+ tx_bits[i] = ofdm->tx_uw[i];
+ }
+ for(i=OFDM_NUWBITS; i<OFDM_NUWBITS+OFDM_NTXTBITS; i++) {
+ tx_bits[i] = 0;
+ }
+
#define LDPC_ENABLE
#ifdef LDPC_ENABLE
unsigned char ibits[HRA_112_112_NUMBERROWSHCOLS];
assert(HRA_112_112_NUMBERROWSHCOLS == ldpc.CodeLength/2);
for(i=0; i<ldpc.CodeLength/2; i++) {
- ibits[i] = test_bits_ofdm[i+OFDM_NUWBITS+OFDM_NTXTBITS];
+ ibits[i] = payload_data_bits[i];
}
encode(&ldpc, ibits, pbits);
- for(i=0; i<OFDM_NUWBITS+OFDM_NTXTBITS; i++) {
- tx_bits[i] = 0;
- }
- for(j=0; j<ldpc.CodeLength/2; i++,j++) {
+ for(j=0, i=OFDM_NUWBITS+OFDM_NTXTBITS; j<ldpc.CodeLength/2; i++,j++) {
tx_bits[i] = ibits[j];
}
for(j=0; j<ldpc.CodeLength/2; i++,j++) {
}
assert(i == OFDM_BITSPERFRAME);
#else
- for(i=0; i<OFDM_BITSPERFRAME; i++) {
- tx_bits = test_bits_ofdm[i];
+ for(i=OFDM_NUWBITS+OFDM_NTXTBITS,j=0; j<ldpc.CodeLength/2; i++,j++) {
+ tx_bits[i] = payload_data_bits[j];
+ }
+ for(j=0; j<ldpc.CodeLength/2; i++,j++) {
+ tx_bits[i] = payload_data_bits[j];
}
#endif