From 06e537ca5b59471487c2e6e33a36506e4a710423 Mon Sep 17 00:00:00 2001 From: ismagom Date: Sat, 19 Sep 2015 00:17:19 +0200 Subject: [PATCH] Tested PUSCH over the air --- srslte/include/srslte/modem/modem_table.h | 5 ++++ srslte/lib/modem/src/mod.c | 8 +++++- srslte/lib/modem/src/modem_table.c | 12 ++++++++ srslte/lib/modem/test/modem_test.c | 34 ++++++++++++++++------- srslte/lib/phch/src/pusch.c | 4 +-- srslte/lib/phch/src/ra.c | 5 +++- srslte/lib/scrambling/src/scrambling.c | 4 +-- 7 files changed, 56 insertions(+), 16 deletions(-) diff --git a/srslte/include/srslte/modem/modem_table.h b/srslte/include/srslte/modem/modem_table.h index 6f980bff0..bba4e7355 100644 --- a/srslte/include/srslte/modem/modem_table.h +++ b/srslte/include/srslte/modem/modem_table.h @@ -52,6 +52,10 @@ typedef struct SRSLTE_API { }srslte_soft_table_t; +typedef struct { + cf_t symbol[8]; +} bpsk_packed_t; + typedef struct { cf_t symbol[4]; } qpsk_packed_t; @@ -67,6 +71,7 @@ typedef struct SRSLTE_API { uint32_t nbits_x_symbol; // number of bits per symbol bool byte_tables_init; + bpsk_packed_t *symbol_table_bpsk; qpsk_packed_t *symbol_table_qpsk; qam16_packed_t *symbol_table_16qam; }srslte_modem_table_t; diff --git a/srslte/lib/modem/src/mod.c b/srslte/lib/modem/src/mod.c index bf3b0accd..f282c9f5f 100644 --- a/srslte/lib/modem/src/mod.c +++ b/srslte/lib/modem/src/mod.c @@ -55,13 +55,19 @@ int srslte_mod_modulate(srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, u /* Assumes packet bits as input */ int srslte_mod_modulate_bytes(srslte_modem_table_t* q, uint8_t *bits, cf_t* symbols, uint32_t nbits) { if (nbits%8) { - fprintf(stderr, "Warning: srslte_mod_modulate_bytes() accepts byte-aligned inputs only\n"); + fprintf(stderr, "Warning: srslte_mod_modulate_bytes() accepts byte-aligned inputs only " + "(nbits=%d, bits_x_symbol=%d)\n", nbits, q->nbits_x_symbol); } if (!q->byte_tables_init) { fprintf(stderr, "Error need to initiated modem tables for packeted bits before calling srslte_mod_modulate_bytes()\n"); return -1; } switch(q->nbits_x_symbol) { + case 1: + for (int i=0;isymbol_table_bpsk[bits[i]], sizeof(bpsk_packed_t)); + } + break; case 2: for (int i=0;isymbol_table_qpsk[bits[i]], sizeof(qpsk_packed_t)); diff --git a/srslte/lib/modem/src/modem_table.c b/srslte/lib/modem/src/modem_table.c index 5f54cc48e..61b144a78 100644 --- a/srslte/lib/modem/src/modem_table.c +++ b/srslte/lib/modem/src/modem_table.c @@ -51,6 +51,9 @@ void srslte_modem_table_free(srslte_modem_table_t* q) { if (q->symbol_table) { free(q->symbol_table); } + if (q->symbol_table_bpsk) { + free(q->symbol_table_bpsk); + } if (q->symbol_table_qpsk) { free(q->symbol_table_qpsk); } @@ -122,6 +125,15 @@ void srslte_modem_table_bytes(srslte_modem_table_t* q) { uint8_t mask_16qam[2] = {0xf0, 0xf}; switch(q->nbits_x_symbol) { + case 1: + q->symbol_table_bpsk = srslte_vec_malloc(sizeof(bpsk_packed_t)*256); + for (uint32_t i=0;i<256;i++) { + for (int j=0;j<8;j++) { + q->symbol_table_bpsk[i].symbol[j] = q->symbol_table[(i&(1<<(7-j)))>>(7-j)]; + } + } + q->byte_tables_init = true; + break; case 2: q->symbol_table_qpsk = srslte_vec_malloc(sizeof(qpsk_packed_t)*256); for (uint32_t i=0;i<256;i++) { diff --git a/srslte/lib/modem/test/modem_test.c b/srslte/lib/modem/test/modem_test.c index f349d2393..1b9a24d6e 100644 --- a/srslte/lib/modem/test/modem_test.c +++ b/srslte/lib/modem/test/modem_test.c @@ -131,33 +131,33 @@ int main(int argc, char **argv) { } /* allocate buffers */ - input = malloc(sizeof(uint8_t) * num_bits); + input = srslte_vec_malloc(sizeof(uint8_t) * num_bits); if (!input) { perror("malloc"); exit(-1); } - input_bytes = malloc(sizeof(uint8_t) * num_bits/8); + input_bytes = srslte_vec_malloc(sizeof(uint8_t) * num_bits/8); if (!input_bytes) { perror("malloc"); exit(-1); } - output = malloc(sizeof(uint8_t) * num_bits); + output = srslte_vec_malloc(sizeof(uint8_t) * num_bits); if (!output) { perror("malloc"); exit(-1); } - symbols = malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol); + symbols = srslte_vec_malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol); if (!symbols) { perror("malloc"); exit(-1); } - symbols_bytes = malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol); + symbols_bytes = srslte_vec_malloc(sizeof(cf_t) * num_bits / mod.nbits_x_symbol); if (!symbols_bytes) { perror("malloc"); exit(-1); } - llr = malloc(sizeof(float) * num_bits); + llr = srslte_vec_malloc(sizeof(float) * num_bits); if (!llr) { perror("malloc"); exit(-1); @@ -169,13 +169,27 @@ int main(int argc, char **argv) { } /* modulate */ - srslte_mod_modulate(&mod, input, symbols, num_bits); - - srslte_vec_fprint_b(stdout, input, num_bits); + struct timeval t[3]; + gettimeofday(&t[1], NULL); + int ntrials = 100; + for (int i=0;isf_idx, q->cell.id, cfg->nbits.nof_bits)) { return SRSLTE_ERROR; } - srslte_scrambling_bytes_offset(&seq, (uint8_t*) q->q, 0, cfg->nbits.nof_bits/8); + srslte_scrambling_bytes_offset(&seq, (uint8_t*) q->q, 0, cfg->nbits.nof_bits); srslte_sequence_free(&seq); } else { - srslte_scrambling_bytes_offset(&q->seq[cfg->sf_idx], (uint8_t*) q->q, 0, cfg->nbits.nof_bits/8); + srslte_scrambling_bytes_offset(&q->seq[cfg->sf_idx], (uint8_t*) q->q, 0, cfg->nbits.nof_bits); } // Correct UCI placeholder bits diff --git a/srslte/lib/phch/src/ra.c b/srslte/lib/phch/src/ra.c index 63ae13ee0..7613ec0f8 100644 --- a/srslte/lib/phch/src/ra.c +++ b/srslte/lib/phch/src/ra.c @@ -171,6 +171,8 @@ int srslte_ul_dci_to_grant_prb_allocation(srslte_ra_ul_dci_t *dci, srslte_ra_ul_ return SRSLTE_SUCCESS; } +static srslte_mod_t last_mod; + static int ul_dci_to_grant_mcs(srslte_ra_ul_dci_t *dci, srslte_ra_ul_grant_t *grant) { int tbs = -1; // 8.6.2 First paragraph @@ -195,13 +197,14 @@ static int ul_dci_to_grant_mcs(srslte_ra_ul_dci_t *dci, srslte_ra_ul_grant_t *gr } else if (dci->mcs_idx >= 29) { // Else use last TBS/Modulation and use mcs to obtain rv_idx tbs = 0; - grant->mcs.mod = 0; + grant->mcs.mod = last_mod; dci->rv_idx = dci->mcs_idx - 28; } if (tbs < 0) { fprintf(stderr, "Error computing TBS\n"); return SRSLTE_ERROR; } else { + last_mod = grant->mcs.mod; grant->mcs.tbs = (uint32_t) tbs; return SRSLTE_SUCCESS; } diff --git a/srslte/lib/scrambling/src/scrambling.c b/srslte/lib/scrambling/src/scrambling.c index 3a2dded0d..8aac5ef49 100644 --- a/srslte/lib/scrambling/src/scrambling.c +++ b/srslte/lib/scrambling/src/scrambling.c @@ -96,9 +96,9 @@ void srslte_scrambling_b_offset(srslte_sequence_t *s, uint8_t *data, int offset, } void srslte_scrambling_bytes(srslte_sequence_t *s, uint8_t *data) { - scrambling_b(s->c_bytes, data, 0, s->len); + scrambling_b(s->c_bytes, data, 0, s->len/8); } void srslte_scrambling_bytes_offset(srslte_sequence_t *s, uint8_t *data, int offset, int len) { - scrambling_b(s->c_bytes, data, offset, len); + scrambling_b(s->c_bytes, data, offset, len/8); }