mirror of https://github.com/PentHertz/srsLTE.git
Tested PUSCH over the air
This commit is contained in:
parent
728ccad448
commit
06e537ca5b
|
@ -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;
|
||||
|
|
|
@ -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;i<nbits/8;i++) {
|
||||
memcpy(&symbols[8*i], &q->symbol_table_bpsk[bits[i]], sizeof(bpsk_packed_t));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (int i=0;i<nbits/8;i++) {
|
||||
memcpy(&symbols[4*i], &q->symbol_table_qpsk[bits[i]], sizeof(qpsk_packed_t));
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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;i<ntrials;i++) {
|
||||
srslte_mod_modulate(&mod, input, symbols, num_bits);
|
||||
}
|
||||
gettimeofday(&t[2], NULL);
|
||||
get_time_interval(t);
|
||||
|
||||
printf("Bit: %d us\n", t[0].tv_usec);
|
||||
|
||||
/* Test packed implementation */
|
||||
srslte_bit_pack_vector(input, input_bytes, num_bits);
|
||||
srslte_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits);
|
||||
gettimeofday(&t[1], NULL);
|
||||
for (int i=0;i<ntrials;i++) {
|
||||
srslte_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits);
|
||||
}
|
||||
gettimeofday(&t[2], NULL);
|
||||
get_time_interval(t);
|
||||
|
||||
printf("Byte: %d us\n", t[0].tv_usec);
|
||||
|
||||
for (int i=0;i<num_bits/mod.nbits_x_symbol;i++) {
|
||||
if (symbols[i] != symbols_bytes[i]) {
|
||||
|
|
|
@ -537,10 +537,10 @@ int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srs
|
|||
if (srslte_sequence_pusch(&seq, rnti, 2 * cfg->sf_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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue