% init modem
- Ts = 0.018; Tcp = 0.002; Rs = 1/Ts; bps = 2; Nc = 16; Ns = 8;
+ Ts = 0.018; Tcp = 0.002; Rs = 1/Ts; bps = 2; Nc = 17; Ns = 8;
states = ofdm_init(bps, Rs, Tcp, Ns, Nc);
ofdm_load_const;
init_cml('/home/david/Desktop/cml/');
load HRA_112_112.txt
[code_param framesize rate] = ldpc_init_user(HRA_112_112, modulation, mod_order, mapping);
- assert(Nbitsperframe == code_param.code_bits_per_frame);
+ assert(Nbitsperframe == (code_param.code_bits_per_frame + Nuwbits + Ntxtbits));
% Generate fixed test frame of tx bits and run OFDM modulator
states.Nbitsperframe = (Ns-1)*Nc*bps;
states.Nrowsperframe = states.Nbitsperframe/(Nc*bps);
states.Nsamperframe = (states.Nrowsperframe+1)*(states.M+states.Ncp);
- states.txt_len = 4; % reserve 4 bits/frame for auxillary text information
- states.uw_len = (Ns-1)*bps - states.txt_len;
+ states.Ntxtbits = 4; % reserve 4 bits/frame for auxillary text information
+ states.Nuwbits = (Ns-1)*bps - states.Ntxtbits;
% generate same pilots each time
rand('seed',1);
test_bits_ofdm = round(rand(1,Nbitsperframe));
- test_bits_ofdm(1:states.uw_len) = 0; % insert Unique Word
+ test_bits_ofdm(1:states.Ntxtbits) = 0; % insert Unique Word
printf("%d test bits\n", Nbitsperframe);
f=fopen("../src/test_bits_ofdm.h","wt");
Nrowsperframe = states.Nrowsperframe;
Nsamperframe = states.Nsamperframe;
timing_mx_thresh = 0.3;
+Nuwbits = states.Nuwbits;
+Ntxtbits = states.Ntxtbits;
W = states.W;
w = states.w;
rand('seed', 1);
tx_bits = round(rand(1,Nbitsperframe));
- tx_bits(1:states.uw_len) = 0; % insert UW
+ tx_bits(1:states.Nuwbits) = 0; % insert UW
% init logs and BER stats
states.verbose = 1;
- Nerrs = 0; rx_uw = zeros(1,states.uw_len);
+ Nerrs = 0; rx_uw = zeros(1,states.Nuwbits);
% main loop ----------------------------------------------------------------
if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial_sync')
[rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
- rx_uw = rx_bits(1:states.uw_len);
+ rx_uw = rx_bits(1:states.Nuwbits);
errors = xor(tx_bits, rx_bits);
Nerrs = sum(errors);
Nframes = floor((Nrows-1)/Ns);
rand('seed', 1);
tx_bits = round(rand(1,Nbitsperframe));
- tx_bits(1:states.uw_len) = 0; % insert UW
+ tx_bits(1:states.Nuwbits) = 0; % insert UW
tx = [];
for f=1:Nframes
rand('seed',1);
tx_bits = round(rand(1,Nbitsperframe));
-tx_bits(1:states.uw_len) = 0;
+tx_bits(1:states.Nuwbits) = 0;
% Run tx loop