Fixed some tests. Saving signals to file in pdsch in debug mode

master
ismagom 9 years ago
parent 0e513ad3f3
commit 1ffa34015f

@ -1,4 +1,4 @@
function [ out ] = read_real( filename, count ) function [ out ] = read_int16( filename, count )
%READ_COMPLEX Summary of this function goes here %READ_COMPLEX Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here

@ -14,7 +14,7 @@ SNR_values = 25;
waveform = sum(waveform,2); waveform = sum(waveform,2);
if ~isempty(recordedSignal) if ~isempty(recordedSignal)
rmccFgOut = struct('NCellID',1,'CellRefP',1,'CFI',1,'NDLRB',100,'DuplexMode','FDD','CyclicPrefix','Normal'); rmccFgOut = struct('CellRefP',1,'NDLRB',100,'DuplexMode','FDD','CyclicPrefix','Normal');
rmccFgOut.PDSCH.RNTI = 1234; rmccFgOut.PDSCH.RNTI = 1234;
rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2); rmccFgOut.PDSCH.PRBSet = repmat(transpose(0:rmccFgOut.NDLRB-1),1,2);
rmccFgOut.PDSCH.TxScheme = 'Port0'; rmccFgOut.PDSCH.TxScheme = 'Port0';

@ -416,8 +416,8 @@ int srslte_pdsch_decode_rnti(srslte_pdsch_t *q,
} }
if (SRSLTE_VERBOSE_ISDEBUG()) { if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("pdsch_symbols: ",0); DEBUG("SAVED FILE pdsch_symbols.dat: symbols after equalization\n",0);
srslte_vec_fprint_c(stdout, q->d, cfg->nbits.nof_re); srslte_vec_save_file("pdsch_symbols.dat", q->d, cfg->nbits.nof_re*sizeof(cf_t));
} }
/* demodulate symbols /* demodulate symbols
@ -438,6 +438,11 @@ int srslte_pdsch_decode_rnti(srslte_pdsch_t *q,
srslte_scrambling_s_offset(&q->seq[cfg->sf_idx], q->e, 0, cfg->nbits.nof_bits); srslte_scrambling_s_offset(&q->seq[cfg->sf_idx], q->e, 0, cfg->nbits.nof_bits);
} }
if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("SAVED FILE llr.dat: LLR estimates after demodulation and descrambling\n",0);
srslte_vec_save_file("llr.dat", q->e, cfg->nbits.nof_bits*sizeof(int16_t));
}
return srslte_dlsch_decode(&q->dl_sch, cfg, softbuffer, q->e, data); return srslte_dlsch_decode(&q->dl_sch, cfg, softbuffer, q->e, data);
} else { } else {

@ -285,18 +285,8 @@ static int encode_tb_off(srslte_sch_t *q,
srslte_crc_attach_byte(&q->crc_cb, q->cb_in, rlen); srslte_crc_attach_byte(&q->crc_cb, q->cb_in, rlen);
} }
if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("CB#%d: ", i);
srslte_vec_fprint_byte(stdout, q->cb_in, cb_len/8);
}
/* Turbo Encoding */ /* Turbo Encoding */
srslte_tcod_encode_lut(&q->encoder, q->cb_in, q->parity_bits, cblen_idx); srslte_tcod_encode_lut(&q->encoder, q->cb_in, q->parity_bits, cblen_idx);
if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("CB#%d encoded: ", i);
srslte_vec_fprint_byte(stdout, q->parity_bits, 2*cb_len/8);
}
} }
DEBUG("RM cblen_idx=%d, n_e=%d, wp=%d, nof_e_bits=%d\n",cblen_idx, n_e, wp, nof_e_bits); DEBUG("RM cblen_idx=%d, n_e=%d, wp=%d, nof_e_bits=%d\n",cblen_idx, n_e, wp, nof_e_bits);
@ -400,12 +390,20 @@ static int decode_tb(srslte_sch_t *q,
n_e = Qm * ((uint32_t) ceilf((float) Gp/cb_segm->C)); n_e = Qm * ((uint32_t) ceilf((float) Gp/cb_segm->C));
} }
bzero(softbuffer->buffer_f[i], (3*cb_len+12)*sizeof(int16_t));
/* Rate Unmatching */ /* Rate Unmatching */
if (srslte_rm_turbo_rx_lut(&e_bits[rp], softbuffer->buffer_f[i], n_e, cblen_idx, rv)) { if (srslte_rm_turbo_rx_lut(&e_bits[rp], softbuffer->buffer_f[i], n_e, cblen_idx, rv)) {
fprintf(stderr, "Error in rate matching\n"); fprintf(stderr, "Error in rate matching\n");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (SRSLTE_VERBOSE_ISDEBUG()) {
char tmpstr[64];
snprintf(tmpstr,64,"rmout_%d.dat",i);
DEBUG("SAVED FILE %s: Encoded turbo code block %d\n", tmpstr, i);
srslte_vec_save_file(tmpstr, softbuffer->buffer_f[i], (3*cb_len+12)*sizeof(int16_t));
}
/* Turbo Decoding with CRC-based early stopping */ /* Turbo Decoding with CRC-based early stopping */
q->nof_iterations = 0; q->nof_iterations = 0;
uint32_t len_crc; uint32_t len_crc;
@ -440,11 +438,6 @@ static int decode_tb(srslte_sch_t *q,
cb_len, rlen, wp, rp, n_e, q->nof_iterations); cb_len, rlen, wp, rp, n_e, q->nof_iterations);
if (SRSLTE_VERBOSE_ISDEBUG()) {
DEBUG("CB#%d IN: ", i);
srslte_vec_fprint_byte(stdout, q->cb_in, cb_len/8);
}
// If CB CRC is not correct, early_stop will be false and wont continue with rest of CBs // If CB CRC is not correct, early_stop will be false and wont continue with rest of CBs
/* Copy data to another buffer, removing the Codeblock CRC */ /* Copy data to another buffer, removing the Codeblock CRC */

@ -33,6 +33,9 @@
#include "srslte/srslte.h" #include "srslte/srslte.h"
// Enable to measure execution time
//#define DO_OFDM
srslte_cell_t cell = { srslte_cell_t cell = {
6, // nof_prb 6, // nof_prb
1, // nof_ports 1, // nof_ports
@ -116,7 +119,9 @@ srslte_pdsch_t pdsch;
srslte_ofdm_t ofdm_tx, ofdm_rx; srslte_ofdm_t ofdm_tx, ofdm_rx;
int dummy_function() { int dummy_function() {
#ifdef DO_OFDM
srslte_ofdm_rx_sf(&ofdm_rx, sf_symbols, slot_symbols[1]); srslte_ofdm_rx_sf(&ofdm_rx, sf_symbols, slot_symbols[1]);
#endif
srslte_softbuffer_rx_reset_tbs(&softbuffer_rx, grant.mcs.tbs); srslte_softbuffer_rx_reset_tbs(&softbuffer_rx, grant.mcs.tbs);
return srslte_pdsch_decode(&pdsch, &pdsch_cfg, &softbuffer_rx, slot_symbols[0], ce, 0, data); return srslte_pdsch_decode(&pdsch, &pdsch_cfg, &softbuffer_rx, slot_symbols[0], ce, 0, data);
} }
@ -153,7 +158,7 @@ int main(int argc, char **argv) {
sf_symbols=srslte_vec_malloc(sizeof(cf_t)*SRSLTE_SF_LEN_PRB(cell.nof_prb)); sf_symbols=srslte_vec_malloc(sizeof(cf_t)*SRSLTE_SF_LEN_PRB(cell.nof_prb));
/* Configure PDSCH */ /* Configure PDSCH */
if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, subframe, 0)) { if (srslte_pdsch_cfg(&pdsch_cfg, cell, &grant, cfi, subframe, rv_idx)) {
fprintf(stderr, "Error configuring PDSCH\n"); fprintf(stderr, "Error configuring PDSCH\n");
exit(-1); exit(-1);
} }
@ -188,11 +193,6 @@ int main(int argc, char **argv) {
srslte_pdsch_set_rnti(&pdsch, rnti); srslte_pdsch_set_rnti(&pdsch, rnti);
if (srslte_softbuffer_tx_init(&softbuffer_tx, cell.nof_prb)) {
fprintf(stderr, "Error initiating TX soft buffer\n");
goto quit;
}
if (srslte_softbuffer_rx_init(&softbuffer_rx, cell.nof_prb)) { if (srslte_softbuffer_rx_init(&softbuffer_rx, cell.nof_prb)) {
fprintf(stderr, "Error initiating RX soft buffer\n"); fprintf(stderr, "Error initiating RX soft buffer\n");
goto quit; goto quit;
@ -204,57 +204,72 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening file %s\n", input_file); fprintf(stderr, "Error opening file %s\n", input_file);
exit(-1); exit(-1);
} }
#ifdef DO_OFDM
srslte_filesource_read(&fsrc, sf_symbols, SRSLTE_SF_LEN_PRB(cell.nof_prb));
#else
srslte_filesource_read(&fsrc, slot_symbols[0], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp)); srslte_filesource_read(&fsrc, slot_symbols[0], SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp));
#endif
srslte_filesource_free(&fsrc); srslte_chest_dl_t chest;
} if (srslte_chest_dl_init(&chest, cell)) {
printf("Error initializing equalizer\n");
exit(-1);
}
srslte_chest_dl_estimate(&chest, slot_symbols[0], ce, subframe);
srslte_chest_dl_free(&chest);
if (SRSLTE_VERBOSE_ISNONE()) { srslte_filesource_free(&fsrc);
printf("Decoding TBS: %d\r",grant.mcs.tbs); } else {
} if (srslte_softbuffer_tx_init(&softbuffer_tx, cell.nof_prb)) {
for (i=0;i<grant.mcs.tbs/8;i++) { fprintf(stderr, "Error initiating TX soft buffer\n");
data[i] = rand()%256; goto quit;
} }
for (rv=0;rv<=rv_idx;rv++) { for (i=0;i<grant.mcs.tbs/8;i++) {
data[i] = rand()%256;
}
for (rv=0;rv<=rv_idx;rv++) {
pdsch_cfg.rv = rv; pdsch_cfg.rv = rv;
if (!input_file) { if (!input_file) {
if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, slot_symbols)) { if (srslte_pdsch_encode(&pdsch, &pdsch_cfg, &softbuffer_tx, data, slot_symbols)) {
fprintf(stderr, "Error encoding PDSCH\n"); fprintf(stderr, "Error encoding PDSCH\n");
goto quit; goto quit;
}
} }
}
/* combine outputs */ /* combine outputs */
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {
for (j=0;j<SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);j++) { for (j=0;j<SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);j++) {
if (i > 0) { if (i > 0) {
slot_symbols[0][j] += slot_symbols[i][j]; slot_symbols[0][j] += slot_symbols[i][j];
}
ce[i][j] = 1;
} }
ce[i][j] = 1;
} }
}
srslte_ofdm_tx_sf(&ofdm_tx, slot_symbols[0], sf_symbols);
int M=1; #ifdef DO_OFDM
int r=0; srslte_ofdm_tx_sf(&ofdm_tx, slot_symbols[0], sf_symbols);
srslte_sch_set_max_noi(&pdsch.dl_sch, 1); #endif
gettimeofday(&t[1], NULL);
for (i=0;i<M;i++) {
r = dummy_function();
}
gettimeofday(&t[2], NULL);
get_time_interval(t);
printf("DECODED %s in %.2f (PHY bitrate=%.2f Mbps. Processing bitrate=%.2f Mbps)\n", r?"Error":"OK",
(float) t[0].tv_usec/M, (float) grant.mcs.tbs/1000, (float) grant.mcs.tbs*M/t[0].tv_usec);
if (r) {
ret = -1;
goto quit;
} }
} }
int M=1;
int r=0;
srslte_sch_set_max_noi(&pdsch.dl_sch, 10);
gettimeofday(&t[1], NULL);
for (i=0;i<M;i++) {
r = dummy_function();
}
gettimeofday(&t[2], NULL);
get_time_interval(t);
printf("DECODED %s in %.2f (PHY bitrate=%.2f Mbps. Processing bitrate=%.2f Mbps)\n", r?"Error":"OK",
(float) t[0].tv_usec/M, (float) grant.mcs.tbs/1000, (float) grant.mcs.tbs*M/t[0].tv_usec);
if (r) {
ret = -1;
goto quit;
}
ret = 0; ret = 0;
quit: quit:
srslte_pdsch_free(&pdsch); srslte_pdsch_free(&pdsch);

@ -121,6 +121,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
uint32_t max_iterations = 5;
mexutils_read_uint32_struct(PDSCHCFG, "NTurboDecIts", &max_iterations);
char *mod_str = mexutils_get_char_struct(PDSCHCFG, "Modulation"); char *mod_str = mexutils_get_char_struct(PDSCHCFG, "Modulation");
if (!strcmp(mod_str, "QPSK")) { if (!strcmp(mod_str, "QPSK")) {
@ -211,7 +214,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!data_bytes) { if (!data_bytes) {
return; return;
} }
srslte_softbuffer_rx_reset(&softbuffer);
srslte_sch_set_max_noi(&pdsch.dl_sch, max_iterations);
int r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, data_bytes); int r = srslte_pdsch_decode(&pdsch, &cfg, &softbuffer, input_fft, ce, noise_power, data_bytes);
free(data_bytes); free(data_bytes);

Loading…
Cancel
Save