test = 'compare to c';
if strcmp(test, 'compare to c')
- frames = 2;
+ frames = 35;
foff = 0;
dfoff = 0;
- EsNodB = 0;
+ EsNodB = 8;
fading_en = 0;
hf_delay_ms = 2;
compare_with_c = 1;
% If in sync just do sample rate processing on latest frame
if sync == 1
- [ch_symb rx_timing rx_filt rx_baseband afdmdv acohpsk.f_est] = rate_Fs_rx_processing(afdmdv, ch_fdm_frame, acohpsk.f_est, acohpsk.Nsymbrowpilot, nin, 1);
- rx_baseband_log = [rx_baseband_log rx_baseband];
- rx_filt_log = [rx_filt_log rx_filt];
- ch_symb_log = [ch_symb_log; ch_symb];
+ [ch_symb rx_timing rx_filt rx_baseband afdmdv acohpsk.f_est] = rate_Fs_rx_processing(afdmdv, ch_fdm_frame, acohpsk.f_est, acohpsk.Nsymbrowpilot, nin, 0);
[next_sync acohpsk] = frame_sync_fine_freq_est(acohpsk, ch_symb, sync, next_sync);
acohpsk.ct_symb_ff_buf(1:2,:) = acohpsk.ct_symb_ff_buf(acohpsk.Nsymbrowpilot+1:acohpsk.Nsymbrowpilot+2,:);
acohpsk.ct_symb_ff_buf(3:acohpsk.Nsymbrowpilot+2,:) = acohpsk.ct_symb_buf(acohpsk.ct+3:acohpsk.ct+acohpsk.Nsymbrowpilot+2,:);
+ rx_baseband_log = [rx_baseband_log rx_baseband];
+ rx_filt_log = [rx_filt_log rx_filt];
ch_symb_log = [ch_symb_log; ch_symb];
rx_timing_log = [rx_timing_log rx_timing];
fest_log = [fest_log acohpsk.f_est];
rx_bits_log = [rx_bits_log rx_bits];
tx_bits_prev_log = [tx_bits_prev_log prev_tx_bits2];
ratio_log = [ratio_log acohpsk.ratio];
+ ct_symb_ff_log = [ct_symb_ff_log; acohpsk.ct_symb_ff_buf(1:acohpsk.Nsymbrowpilot,:)];
% BER stats
%rx_filt_log = [rx_filt_log rx_filt];
%rx_timing_log = [rx_timing_log rx_timing];
%ch_symb_log = [ch_symb_log; ch_symb];
- % TODO ct_symb_ff_log = [ct_symb_ff_log; acohpsk.ct_symb_ff_buf(1:acohpsk.Nsymbrowpilot,:)];
+ % ct_symb_ff_log = [ct_symb_ff_log; acohpsk.ct_symb_ff_buf(1:acohpsk.Nsymbrowpilot,:)];
if sync == 0
end
ber = Nerrs/Tbits;
-printf("\nEsNodB: %4.1f ber..: %4.3f Nerrs..: %d Tbits..: %d\n", EsNodB, ber, Nerrs, Tbits);
+printf("\nOctave EsNodB: %4.1f ber..: %4.3f Nerrs..: %d Tbits..: %d\n", EsNodB, ber, Nerrs, Tbits);
if compare_with_c
+ % Determine bit error rate
+
+ sz = length(tx_bits_log_c);
+ Nerrs_c = sum(xor(tx_bits_prev_log, rx_bits_log_c(framesize+1:length(rx_bits_log_c))));
+ Tbits_c = length(tx_bits_prev_log);
+ ber_c = Nerrs_c/Tbits_c;
+ printf("C EsNodB.....: %4.1f ber_c: %4.3f Nerrs_c: %d Tbits_c: %d\n", EsNodB, ber_c, Nerrs_c, Tbits_c);
+
% Output vectors from C port ---------------------------------------------------
load ../build_linux/unittest/tcohpsk_out.txt
stem_sig_and_error(5, 211, real(rx_baseband_log_c(1,:)), real(rx_baseband_log(1,:) - rx_baseband_log_c(1,:)), 'rx baseband re', [1 length(rx_baseband_log) -10 10])
stem_sig_and_error(5, 212, imag(rx_baseband_log_c(1,:)), imag(rx_baseband_log(1,:) - rx_baseband_log_c(1,:)), 'rx baseband im', [1 length(rx_baseband_log) -10 10])
- [n m] = size(ch_symb_log); n = 40;
+ [n m] = size(ch_symb_log);
stem_sig_and_error(6, 211, real(ch_symb_log_c), real(ch_symb_log - ch_symb_log_c), 'ch symb re', [1 n -1.5 1.5])
stem_sig_and_error(6, 212, imag(ch_symb_log_c), imag(ch_symb_log - ch_symb_log_c), 'ch symb im', [1 n -1.5 1.5])
%stem_sig_and_error(7, 211, real(ct_symb_ff_log_c), real(ct_symb_ff_log - ct_symb_ff_log_c), 'ct symb ff re', [1 n -1.5 1.5])
check(rx_symb_log, rx_symb_log_c, 'rx_symb',0.01);
check(rx_bits_log, rx_bits_log_c, 'rx_bits');
- % Determine bit error rate
-
- sz = length(tx_bits_log_c);
- Nerrs_c = sum(xor(tx_bits_prev_log, rx_bits_log_c));
- Tbits_c = length(tx_bits_prev_log);
- ber_c = Nerrs_c/Tbits_c;
- printf("EsNodB: %4.1f ber_c: %4.3f Nerrs_c: %d Tbits_c: %d\n", EsNodB, ber_c, Nerrs_c, Tbits_c);
else
}
-void rate_Fs_rx_processing(struct COHPSK *coh, COMP ch_symb[NSYMROWPILOT][COHPSK_NC*ND], COMP ch_fdm_frame[], float *f_est, int nsymb, int nin, int freq_track)
+void rate_Fs_rx_processing(struct COHPSK *coh, COMP ch_symb[][COHPSK_NC*ND], COMP ch_fdm_frame[], float *f_est, int nsymb, int nin, int freq_track)
{
struct FDMDV *fdmdv = coh->fdmdv;
int r, c, i;
for (i=0; i<NSW-1; i++) {
update_ct_symb_buf(coh->ct_symb_buf, &ch_symb[i*NSYMROWPILOT]);
}
- frame_sync_fine_freq_est(coh, &ch_symb[(NSW-1)*NSYMROWPILOT], sync, &next_sync);
+ /*
+ for(i=0; i<NSW*NSYMROWPILOT; i++) {
+ printf("%f %f\n", ch_symb[i][0].real, ch_symb[i][0].imag);
+ }
+ */
+ /*
+ for(i=0; i<NCT_SYMB_BUF; i++) {
+ printf("%f %f\n", coh->ct_symb_buf[i][0].real, coh->ct_symb_buf[i][0].imag);
+ }
+ */
+ frame_sync_fine_freq_est(coh, &ch_symb[(NSW-1)*NSYMROWPILOT], sync, &next_sync);
if (fabs(coh->f_fine_est) > 2.0) {
fprintf(stderr, " [%d] Hmm %f is a bit big :(\n", coh->frame, coh->f_fine_est);
/* If in sync just do sample rate processing on latest frame */
if (sync == 1) {
- rate_Fs_rx_processing(coh, ch_symb, rx_fdm, &coh->f_est, NSYMROWPILOT, nin, 1);
- frame_sync_fine_freq_est(coh, &ch_symb[(NSW-1)*NSYMROWPILOT], sync, &next_sync);
+ rate_Fs_rx_processing(coh, ch_symb, rx_fdm, &coh->f_est, NSYMROWPILOT, nin, 0);
+ frame_sync_fine_freq_est(coh, ch_symb, sync, &next_sync);
for(r=0; r<2; r++)
for(c=0; c<COHPSK_NC*ND; c++)
#include "comp_prim.h"
#include "noise_samples.h"
-#define FRAMES LOG_FRAMES /* LOG_FRAMES is #defined in cohpsk_internal.h */
+#define FRAMES 35 /* LOG_FRAMES is #defined in cohpsk_internal.h */
#define SYNC_FRAMES 12 /* sync state uses up extra log storage as we reprocess several times */
#define FRAMESL (SYNC_FRAMES*FRAMES) /* worst case is every frame is out of sync */
#define RS 50
#define FOFF 0
-#define ESNODB 0
+#define ESNODB 8
extern float pilots_coh[][PILOTS_NC];
int rx_bits_log[COHPSK_BITS_PER_FRAME*FRAMES];
FILE *fout;
- int f, r, c, log_r, log_data_r, noise_r;
+ int f, r, c, log_r, log_data_r, noise_r, ff_log_r;
int *ptest_bits_coh, *ptest_bits_coh_end;
COMP phase_ch;
/* init stuff */
- log_r = log_data_r = noise_r = log_bits = 0;
+ log_r = log_data_r = noise_r = log_bits = ff_log_r = 0;
ptest_bits_coh = (int*)test_bits_coh;
ptest_bits_coh_end = (int*)test_bits_coh + sizeof(test_bits_coh)/sizeof(int);
memcpy(tx_bits, test_bits_coh, sizeof(int)*COHPSK_BITS_PER_FRAME);
for(r=0; r<NSYMROWPILOT; r++, log_r++) {
for(c=0; c<COHPSK_NC*ND; c++) {
tx_symb_log[log_r][c] = tx_symb[r][c];
- ct_symb_ff_log[log_r][c] = coh->ct_symb_ff_buf[r][c];
}
}
if (coh->sync == 1) {
- for(r=0; r<NSYMROW; r++, log_data_r++) {
+ for(r=0; r<NSYMROWPILOT; r++, ff_log_r++) {
+ for(c=0; c<COHPSK_NC*ND; c++) {
+ ct_symb_ff_log[ff_log_r][c] = coh->ct_symb_ff_buf[r][c];
+ }
+ }
+
+ for(r=0; r<NSYMROW; r++, log_data_r++) {
for(c=0; c<COHPSK_NC*ND; c++) {
rx_amp_log[log_data_r][c] = coh->amp_[r][c];
rx_phi_log[log_data_r][c] = coh->phi_[r][c];
assert(log_r <= NSYMROWPILOT*FRAMES);
assert(noise_r <= NSYMROWPILOT*M*FRAMES);
assert(log_data_r <= NSYMROW*FRAMES);
+
+ printf("\r[%d]", f+1);
}
+ printf("\n");
/*---------------------------------------------------------*\
Dump logs to Octave file for evaluation