add set_cell() call to PSCCH and allocate for max PRB in pscch_init()

master
Andre Puschmann 5 years ago
parent 151ce10a96
commit e4b5fa122f

@ -48,6 +48,7 @@ typedef enum SRSLTE_API {
typedef struct SRSLTE_API {
srslte_sl_tm_t tm;
uint32_t N_sl_id;
uint32_t nof_prb;
srslte_cp_t cp;
} srslte_cell_sl_t;
@ -80,8 +81,11 @@ typedef enum SRSLTE_API {
#define SRSLTE_PSCCH_QM 2
#define SRSLTE_PSCCH_TM12_NOF_PRB (1)
#define SRSLTE_PSCCH_TM34_NOF_PRB (2)
#define SRSLTE_PSCCH_MAX_NOF_PRB (SRSLTE_PSCCH_TM34_NOF_PRB)
#define SRSLTE_PSCCH_SCRAMBLING_SEED (510) ///< Scrambling seed for PSCCH is 510
#define SRSLTE_PSCCH_MAX_CODED_BITS (3 * (SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN))
#define SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS (12)
#define SRSLTE_PSCCH_TM12_NUM_DMRS_SYMBOLS (2)
#define SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT (10)
@ -89,6 +93,8 @@ typedef enum SRSLTE_API {
#define SRSLTE_PSCCH_TM34_NUM_DATA_SYMBOLS (10)
#define SRSLTE_PSCCH_TM34_NUM_DMRS_SYMBOLS (4)
#define SRSLTE_PSCCH_MAX_NUM_DATA_SYMBOLS (SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS)
SRSLTE_API int srslte_sl_get_num_symbols(srslte_sl_tm_t tm, srslte_cp_t cp);
SRSLTE_API bool srslte_psbch_is_symbol(srslte_sl_symbol_t type, srslte_sl_tm_t tm, uint32_t i);

@ -40,6 +40,7 @@
typedef struct SRSLTE_API {
uint32_t max_prb;
srslte_cell_sl_t cell;
uint32_t sci_len;
@ -87,7 +88,8 @@ typedef struct SRSLTE_API {
} srslte_pscch_t;
SRSLTE_API int srslte_pscch_init(srslte_pscch_t* q, srslte_cell_sl_t cell);
SRSLTE_API int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb);
SRSLTE_API int srslte_pscch_set_cell(srslte_pscch_t* q, srslte_cell_sl_t cell);
SRSLTE_API int srslte_pscch_encode(srslte_pscch_t* q, uint8_t* sci, cf_t* sf_buffer, uint32_t prb_idx);
SRSLTE_API int srslte_pscch_decode(srslte_pscch_t* q, cf_t* equalized_sf_syms, uint8_t* sci, uint32_t prb_idx);
SRSLTE_API int srslte_pscch_put(srslte_pscch_t* q, cf_t* sf_buffer, uint32_t prb_idx);

@ -35,30 +35,14 @@
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
int srslte_pscch_init(srslte_pscch_t* q, srslte_cell_sl_t cell)
int srslte_pscch_init(srslte_pscch_t* q, uint32_t max_prb)
{
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL) {
ret = SRSLTE_ERROR;
if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) {
q->sci_len = srslte_sci_format0_sizeof(cell.nof_prb);
q->nof_symbols = SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS;
q->pscch_nof_prb = SRSLTE_PSCCH_TM12_NOF_PRB;
if (cell.cp == SRSLTE_CP_EXT) {
q->nof_symbols = SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT;
}
} else if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) {
q->sci_len = SRSLTE_SCI_TM34_LEN;
q->nof_symbols = SRSLTE_PSCCH_TM34_NUM_DATA_SYMBOLS;
q->pscch_nof_prb = SRSLTE_PSCCH_TM34_NOF_PRB;
} else {
return ret;
}
q->cell = cell;
q->max_prb = max_prb;
// CRC
uint32_t crc_poly = 0x11021;
@ -82,14 +66,14 @@ int srslte_pscch_init(srslte_pscch_t* q, srslte_cell_sl_t cell)
q->encoder.tail_biting = true;
int poly[3] = {0x6D, 0x4F, 0x57};
memcpy(q->encoder.poly, poly, 3 * sizeof(int));
q->d = srslte_vec_malloc(sizeof(uint8_t) * (3 * (SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN)));
q->d = srslte_vec_malloc(sizeof(uint8_t) * SRSLTE_PSCCH_MAX_CODED_BITS);
if (!q->d) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
bzero(q->d, sizeof(uint8_t) * (3 * (SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN)));
memset(q->d, 0, sizeof(uint8_t) * SRSLTE_PSCCH_MAX_CODED_BITS);
q->d_16 = srslte_vec_malloc(sizeof(int16_t) * (3 * (SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN)));
q->d_16 = srslte_vec_malloc(sizeof(int16_t) * SRSLTE_PSCCH_MAX_CODED_BITS);
if (!q->d_16) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -98,35 +82,36 @@ int srslte_pscch_init(srslte_pscch_t* q, srslte_cell_sl_t cell)
srslte_viterbi_init(
&q->dec, SRSLTE_VITERBI_37, q->encoder.poly, SRSLTE_SCI_MAX_LEN + SRSLTE_SCI_CRC_LEN, q->encoder.tail_biting);
q->E = SRSLTE_NRE * q->nof_symbols * q->pscch_nof_prb * SRSLTE_PSCCH_QM;
q->e = srslte_vec_malloc(sizeof(uint8_t) * q->E);
///< Max E value for memory allocation
uint32_t E_max = SRSLTE_NRE * SRSLTE_PSCCH_MAX_NUM_DATA_SYMBOLS * SRSLTE_PSCCH_MAX_NOF_PRB * SRSLTE_PSCCH_QM;
q->e = srslte_vec_malloc(sizeof(uint8_t) * E_max);
if (!q->e) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->e_16 = srslte_vec_malloc(sizeof(int16_t) * q->E);
q->e_16 = srslte_vec_malloc(sizeof(int16_t) * E_max);
if (!q->e_16) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->e_bytes = srslte_vec_malloc(sizeof(uint8_t) * q->E / 8);
q->e_bytes = srslte_vec_malloc(sizeof(uint8_t) * E_max / 8);
if (!q->e_bytes) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->interleaver_lut = srslte_vec_malloc(sizeof(uint32_t) * q->E);
q->interleaver_lut = srslte_vec_malloc(sizeof(uint32_t) * E_max);
if (!q->interleaver_lut) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->codeword = srslte_vec_malloc(sizeof(uint8_t) * q->E);
q->codeword = srslte_vec_malloc(sizeof(uint8_t) * E_max);
if (!q->codeword) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->codeword_bytes = srslte_vec_malloc(sizeof(uint8_t) * q->E / 8);
q->codeword_bytes = srslte_vec_malloc(sizeof(uint8_t) * E_max / 8);
if (!q->codeword_bytes) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
@ -134,40 +119,74 @@ int srslte_pscch_init(srslte_pscch_t* q, srslte_cell_sl_t cell)
// Scrambling
bzero(&q->seq, sizeof(srslte_sequence_t));
srslte_sequence_LTE_pr(&q->seq, q->E, SRSLTE_PSCCH_SCRAMBLING_SEED);
srslte_sequence_LTE_pr(&q->seq, E_max, SRSLTE_PSCCH_SCRAMBLING_SEED);
// Modulation
if (srslte_modem_table_lte(&q->mod, SRSLTE_MOD_QPSK)) {
return SRSLTE_ERROR;
}
q->mod_symbols = srslte_vec_malloc(sizeof(cf_t) * q->E / SRSLTE_PSCCH_QM);
q->mod_symbols = srslte_vec_malloc(sizeof(cf_t) * E_max / SRSLTE_PSCCH_QM);
if (!q->mod_symbols) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
q->llr = srslte_vec_malloc(sizeof(float) * q->E);
q->llr = srslte_vec_malloc(sizeof(float) * E_max);
if (!q->llr) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
// DFT Precoding
if (srslte_dft_precoding_init(&q->dft_precoder, q->cell.nof_prb, true)) {
if (srslte_dft_precoding_init(&q->dft_precoder, SRSLTE_PSCCH_MAX_NOF_PRB, true)) {
return SRSLTE_ERROR;
}
q->scfdma_symbols = srslte_vec_malloc(sizeof(cf_t) * q->E / SRSLTE_PSCCH_QM);
q->scfdma_symbols = srslte_vec_malloc(sizeof(cf_t) * E_max / SRSLTE_PSCCH_QM);
if (!q->scfdma_symbols) {
ERROR("Error allocating memory\n");
return SRSLTE_ERROR;
}
// IDFT Predecoding
if (srslte_dft_precoding_init(&q->idft_precoder, q->pscch_nof_prb, false)) {
if (srslte_dft_precoding_init(&q->idft_precoder, SRSLTE_PSCCH_MAX_NOF_PRB, false)) {
return SRSLTE_ERROR;
}
ret = SRSLTE_SUCCESS;
}
return ret;
}
int srslte_pscch_set_cell(srslte_pscch_t* q, srslte_cell_sl_t cell)
{
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q != NULL && cell.nof_prb <= q->max_prb) {
ret = SRSLTE_ERROR;
if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) {
q->sci_len = srslte_sci_format0_sizeof(cell.nof_prb);
q->nof_symbols = SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS;
q->pscch_nof_prb = SRSLTE_PSCCH_TM12_NOF_PRB;
if (cell.cp == SRSLTE_CP_EXT) {
q->nof_symbols = SRSLTE_PSCCH_TM12_NUM_DATA_SYMBOLS_EXT;
}
} else if (cell.tm == SRSLTE_SIDELINK_TM3 || cell.tm == SRSLTE_SIDELINK_TM4) {
q->sci_len = SRSLTE_SCI_TM34_LEN;
q->nof_symbols = SRSLTE_PSCCH_TM34_NUM_DATA_SYMBOLS;
q->pscch_nof_prb = SRSLTE_PSCCH_TM34_NOF_PRB;
} else {
return ret;
}
q->cell = cell;
///< Calculate actual number of RE
q->E = SRSLTE_NRE * q->nof_symbols * q->pscch_nof_prb * SRSLTE_PSCCH_QM;
///< Last OFDM symbol is processed but not transmitted
q->nof_tx_re = (q->nof_symbols - 1) * SRSLTE_NRE * q->pscch_nof_prb;

@ -37,7 +37,7 @@
#include "srslte/phy/utils/vector.h"
char* input_file_name;
srslte_cell_sl_t cell = {.nof_prb = 6, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM};
srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 0, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM};
bool use_standard_lte_rates = false;
uint32_t size_sub_channel = 10;
uint32_t num_sub_channel = 5;
@ -150,11 +150,16 @@ int base_init()
srslte_sci_init(&sci, cell.nof_prb, cell.tm, size_sub_channel, num_sub_channel);
if (srslte_pscch_init(&pscch, cell) != SRSLTE_SUCCESS) {
if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH init\n");
return SRSLTE_ERROR;
}
if (srslte_pscch_set_cell(&pscch, cell) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH set cell\n");
return SRSLTE_ERROR;
}
if (srslte_chest_sl_init_pscch_dmrs(&pscch_chest) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH DMRS init\n");
return SRSLTE_ERROR;

@ -31,22 +31,18 @@
#include "srslte/phy/utils/debug.h"
#include "srslte/phy/utils/vector.h"
int32_t N_sl_id = 168;
uint32_t nof_prb = 6;
srslte_cp_t cp = SRSLTE_CP_NORM;
srslte_sl_tm_t tm = SRSLTE_SIDELINK_TM2;
uint32_t size_sub_channel = 10;
uint32_t num_sub_channel = 5;
srslte_cell_sl_t cell = {.nof_prb = 6, .N_sl_id = 168, .tm = SRSLTE_SIDELINK_TM2, .cp = SRSLTE_CP_NORM};
uint32_t size_sub_channel = 10;
uint32_t num_sub_channel = 5;
uint32_t prb_idx = 0;
void usage(char* prog)
{
printf("Usage: %s [cdeipt]\n", prog);
printf("\t-p nof_prb [Default %d]\n", nof_prb);
printf("\t-c N_sl_id [Default %d]\n", N_sl_id);
printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (tm + 1));
printf("\t-p nof_prb [Default %d]\n", cell.nof_prb);
printf("\t-c N_sl_id [Default %d]\n", cell.N_sl_id);
printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell.tm + 1));
printf("\t-v [set srslte_verbose to debug, default none]\n");
}
@ -56,24 +52,24 @@ void parse_args(int argc, char** argv)
while ((opt = getopt(argc, argv, "ceiptv")) != -1) {
switch (opt) {
case 'c':
N_sl_id = (int32_t)strtol(argv[optind], NULL, 10);
cell.N_sl_id = (int32_t)strtol(argv[optind], NULL, 10);
break;
case 'p':
nof_prb = (uint32_t)strtol(argv[optind], NULL, 10);
cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 't':
switch (strtol(argv[optind], NULL, 10)) {
case 1:
tm = SRSLTE_SIDELINK_TM1;
cell.tm = SRSLTE_SIDELINK_TM1;
break;
case 2:
tm = SRSLTE_SIDELINK_TM2;
cell.tm = SRSLTE_SIDELINK_TM2;
break;
case 3:
tm = SRSLTE_SIDELINK_TM3;
cell.tm = SRSLTE_SIDELINK_TM3;
break;
case 4:
tm = SRSLTE_SIDELINK_TM4;
cell.tm = SRSLTE_SIDELINK_TM4;
break;
default:
usage(argv[0]);
@ -99,16 +95,21 @@ int main(int argc, char** argv)
char sci_msg[SRSLTE_SCI_MSG_MAX_LEN] = "";
uint32_t sf_n_re = SRSLTE_SF_LEN_RE(nof_prb, cp);
uint32_t sf_n_re = SRSLTE_SF_LEN_RE(cell.nof_prb, cell.cp);
cf_t* sf_buffer = srslte_vec_malloc(sizeof(cf_t) * sf_n_re);
// SCI
srslte_sci_t sci;
srslte_sci_init(&sci, nof_prb, tm, size_sub_channel, num_sub_channel);
srslte_sci_init(&sci, cell.nof_prb, cell.tm, size_sub_channel, num_sub_channel);
// PSCCH
srslte_pscch_t pscch;
if (srslte_pscch_init(&pscch, nof_prb, tm, cp) != SRSLTE_SUCCESS) {
if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH init\n");
return SRSLTE_ERROR;
}
if (srslte_pscch_set_cell(&pscch, cell) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH init\n");
return SRSLTE_ERROR;
}

Loading…
Cancel
Save