EVM buffer takes number of bits

master
Xavier Arteaga 4 years ago committed by Andre Puschmann
parent a278a49e42
commit e621a1cde3

@ -45,12 +45,12 @@ typedef struct {
* @param nof_prb that provides the maximum number of bits
* @return EVM buffer pointer
*/
static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_prb)
static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_bits)
{
srslte_evm_buffer_t* q = (srslte_evm_buffer_t*)srslte_vec_malloc(sizeof(srslte_evm_buffer_t));
// Check allocation result and number of PRB
if (!q || !nof_prb) {
if (!q || !nof_bits) {
ERROR("Malloc");
return q;
}
@ -59,7 +59,7 @@ static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_prb)
memset(q, 0, sizeof(srslte_evm_buffer_t));
// Set max number of bits
q->max_bits = srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, nof_prb);
q->max_bits = nof_bits;
// Allocate hard bits
q->hard_bits = srslte_vec_u8_malloc(q->max_bits);
@ -83,17 +83,14 @@ static inline srslte_evm_buffer_t* srslte_evm_buffer_alloc(uint32_t nof_prb)
* @param nof_prb that provides the maximum number of bits
* @return EVM buffer pointer
*/
static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t nof_prb)
static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t new_max_bits)
{
// Assert pointer and number of PRB
if (!q || !nof_prb) {
if (!q || !new_max_bits) {
ERROR("Invalid inputs");
return;
}
// Get new number of max bits
uint32_t new_max_bits = srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, nof_prb);
// Return if no resize is required
if (q->max_bits >= new_max_bits) {
return;
@ -161,6 +158,14 @@ static inline void srslte_evm_buffer_resize(srslte_evm_buffer_t* q, uint32_t nof
ptr += sizeof(LLR_T); \
HARDBITS[i] = w; \
} \
if (NOF_SOFTBITS % 8) { \
uint8_t w = 0xff; \
for (uint32_t i = 0; i < NOF_SOFTBITS % 8; i++) { \
w ^= (*ptr & 0x80) >> i; \
ptr += sizeof(LLR_T); \
} \
HARDBITS[NOF_SOFTBITS / 8] = w; \
} \
} while (false)
/**

@ -296,7 +296,7 @@ static int pdsch_init(srslte_pdsch_t* q, uint32_t max_prb, bool is_ue, uint32_t
// If it is the UE, allocate EVM buffer, for only minimum PRB
if (is_ue) {
q->evm_buffer[i] = srslte_evm_buffer_alloc(6);
q->evm_buffer[i] = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6));
if (!q->evm_buffer[i]) {
ERROR("Allocating EVM buffer\n");
goto clean;

@ -166,7 +166,7 @@ static int pusch_init(srslte_pusch_t* q, uint32_t max_prb, bool is_ue)
goto clean;
}
q->evm_buffer = srslte_evm_buffer_alloc(6);
q->evm_buffer = srslte_evm_buffer_alloc(srslte_ra_tbs_from_idx(SRSLTE_RA_NOF_TBS_IDX - 1, 6));
if (!q->evm_buffer) {
ERROR("Allocating EVM buffer\n");
goto clean;

Loading…
Cancel
Save