Merge remote-tracking branch 'origin/develop' into fix_nr_odd_prb
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include "assertions.h"
|
||||
#include "SIMULATION/TOOLS/sim.h"
|
||||
#include "common/utils/load_module_shlib.h"
|
||||
#include "PHY/CODING/nrLDPC_extern.h"
|
||||
//#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
|
||||
#include "openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h"
|
||||
@@ -118,15 +119,13 @@ int test_ldpc(short No_iteration,
|
||||
//short test_input[block_length];
|
||||
unsigned char *test_input[MAX_NUM_NR_DLSCH_SEGMENTS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};;
|
||||
//short *c; //padded codeword
|
||||
unsigned char *estimated_output[MAX_NUM_DLSCH_SEGMENTS];
|
||||
unsigned char *estimated_output_bit[MAX_NUM_DLSCH_SEGMENTS];
|
||||
unsigned char *test_input_bit;
|
||||
unsigned char estimated_output[MAX_NUM_DLSCH_SEGMENTS][block_length];
|
||||
memset(estimated_output, 0, sizeof(estimated_output));
|
||||
unsigned char *channel_input[MAX_NUM_DLSCH_SEGMENTS];
|
||||
unsigned char *channel_output_uncoded[MAX_NUM_DLSCH_SEGMENTS];
|
||||
unsigned char *channel_input_optim[MAX_NUM_DLSCH_SEGMENTS];
|
||||
double *channel_output;
|
||||
double *modulated_input[MAX_NUM_DLSCH_SEGMENTS];
|
||||
char *channel_output_fixed[MAX_NUM_DLSCH_SEGMENTS];
|
||||
//double channel_output[68 * 384];
|
||||
double modulated_input[MAX_NUM_DLSCH_SEGMENTS][68 * 384] = { 0 };
|
||||
char channel_output_fixed[MAX_NUM_DLSCH_SEGMENTS][68 * 384] = { 0 };
|
||||
unsigned int i,j,trial=0;
|
||||
short BG=0,nrows=0;//,ncols;
|
||||
int no_punctured_columns,removed_bit;
|
||||
@@ -155,24 +154,12 @@ int test_ldpc(short No_iteration,
|
||||
// generate input block
|
||||
for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
|
||||
test_input[j]=(unsigned char *)malloc16(sizeof(unsigned char) * block_length/8);
|
||||
memset(test_input[j], 0, sizeof(unsigned char) * block_length / 8);
|
||||
channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
|
||||
memset(channel_input[j], 0, sizeof(unsigned char) * 68 * 384);
|
||||
channel_input_optim[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
|
||||
channel_output_uncoded[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
|
||||
estimated_output[j] = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
|
||||
estimated_output_bit[j] = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
|
||||
modulated_input[j] = (double *)malloc16(sizeof(double) * 68*384);
|
||||
channel_output_fixed[j] = (char *)malloc16(sizeof( char) * 68*384);
|
||||
memset(channel_input_optim[j], 0, sizeof(unsigned char) * 68 * 384);
|
||||
}
|
||||
//modulated_input = (double *)malloc(sizeof(double) * 68*384);
|
||||
//channel_output = (double *)malloc(sizeof(double) * 68*384);
|
||||
//channel_output_fixed = (char *)malloc16(sizeof(char) * 68*384);
|
||||
//modulated_input = (double *)calloc(68*384, sizeof(double));
|
||||
channel_output = (double *)calloc(68*384, sizeof(double));
|
||||
//channel_output_fixed = (double *)calloc(68*384, sizeof(double));
|
||||
//channel_output_fixed = (unsigned char*)calloc(68*384, sizeof(unsigned char*));
|
||||
//estimated_output = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);///8);
|
||||
//estimated_output_bit = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
|
||||
test_input_bit = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
|
||||
|
||||
reset_meas(&time);
|
||||
reset_meas(time_optim);
|
||||
@@ -319,7 +306,6 @@ int test_ldpc(short No_iteration,
|
||||
for (i = 0; i < block_length+(nrows-no_punctured_columns) * Zc - removed_bit; i++)
|
||||
if (channel_input[j][i]!=channel_input_optim[j][i]) {
|
||||
printf("differ in seg %u pos %u (%u,%u)\n", j, i, channel_input[j][i], channel_input_optim[j][i]);
|
||||
free(channel_output);
|
||||
return (-1);
|
||||
}
|
||||
//else{
|
||||
@@ -367,12 +353,9 @@ int test_ldpc(short No_iteration,
|
||||
//channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits);
|
||||
|
||||
//Uncoded BER
|
||||
if (channel_output_fixed[j][i]<0)
|
||||
channel_output_uncoded[j][i]=1; //QPSK demod
|
||||
else
|
||||
channel_output_uncoded[j][i]=0;
|
||||
unsigned char channel_output_uncoded = channel_output_fixed[j][i]<0 ? 1 /* QPSK demod */ : 0;
|
||||
|
||||
if (channel_output_uncoded[j][i] != channel_input_optim[j][i-2*Zc])
|
||||
if (channel_output_uncoded != channel_input_optim[j][i-2*Zc])
|
||||
*errors_bit_uncoded = (*errors_bit_uncoded) + 1;
|
||||
|
||||
}
|
||||
@@ -423,12 +406,10 @@ int test_ldpc(short No_iteration,
|
||||
|
||||
for (i=0; i<block_length; i++)
|
||||
{
|
||||
estimated_output_bit[j][i] = (estimated_output[j][i/8]&(1<<(i&7)))>>(i&7);
|
||||
test_input_bit[i] = (test_input[j][i/8]&(1<<(i&7)))>>(i&7); // Further correct for multiple segments
|
||||
if (estimated_output_bit[j][i] != test_input_bit[i])
|
||||
{
|
||||
unsigned char estoutputbit = (estimated_output[j][i/8]&(1<<(i&7)))>>(i&7);
|
||||
unsigned char inputbit = (test_input[j][i/8]&(1<<(i&7)))>>(i&7); // Further correct for multiple segments
|
||||
if (estoutputbit != inputbit)
|
||||
*errors_bit = (*errors_bit) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//if (*errors == 1000)
|
||||
@@ -460,17 +441,8 @@ int test_ldpc(short No_iteration,
|
||||
for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
|
||||
free(test_input[j]);
|
||||
free(channel_input[j]);
|
||||
free(channel_output_uncoded[j]);
|
||||
free(channel_input_optim[j]);
|
||||
free(modulated_input[j]);
|
||||
free(channel_output_fixed[j]);
|
||||
free(estimated_output[j]);
|
||||
free(estimated_output_bit[j]);
|
||||
}
|
||||
//free(modulated_input);
|
||||
free(channel_output);
|
||||
//free(channel_output_fixed);
|
||||
//free(estimated_output);
|
||||
|
||||
nrLDPC_free_mem(p_nrLDPC_procBuf);
|
||||
|
||||
@@ -728,5 +700,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fclose(fd);
|
||||
|
||||
loader_reset();
|
||||
logTerm();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//Default simulation values (Aim for iterations = 1000000.)
|
||||
//Default simulation values (Aim for iterations = 1000000.)
|
||||
int decoder_int16=0;
|
||||
int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, 2=UCI
|
||||
double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB
|
||||
@@ -158,20 +158,25 @@ if (logFlag){
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t testArrayLength = ceil(testLength / 32.0);
|
||||
uint8_t coderArrayLength = ceil(coderLength / 32.0);
|
||||
uint32_t testInput[testArrayLength]; //generate randomly
|
||||
const uint8_t testArrayLength = ceil(testLength / 32.0);
|
||||
const uint8_t coderArrayLength = ceil(coderLength / 32.0);
|
||||
// in the polar code, often uint64_t arrays are used, but we work with
|
||||
// uint32_t arrays below, so realArrayLength is the length that always
|
||||
// satisfies uint64_t array length
|
||||
const uint8_t realArrayLength = ((testArrayLength + 1) / 2) * 2;
|
||||
printf("testArrayLength %d realArrayLength %d\n", testArrayLength, realArrayLength);
|
||||
uint32_t testInput[realArrayLength]; //generate randomly
|
||||
uint32_t encoderOutput[coderArrayLength];
|
||||
uint32_t estimatedOutput[testArrayLength]; //decoder output
|
||||
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
|
||||
uint32_t estimatedOutput[realArrayLength]; //decoder output
|
||||
memset(testInput,0,sizeof(uint32_t) * realArrayLength); // does not reset all
|
||||
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength);
|
||||
uint8_t encoderOutputByte[coderLength];
|
||||
double modulatedInput[coderLength]; //channel input
|
||||
double channelOutput[coderLength]; //add noise
|
||||
int16_t channelOutput_int16[coderLength];
|
||||
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, 1, NULL);
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, true);
|
||||
|
||||
#ifdef DEBUG_DCI_POLAR_PARAMS
|
||||
uint32_t dci_pdu[4];
|
||||
@@ -206,7 +211,8 @@ if (logFlag){
|
||||
modulated_input[i]=(-1)/sqrt(2);
|
||||
channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
|
||||
}
|
||||
decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, rnti);
|
||||
decoderState = polar_decoder_dci(channel_output, dci_est, NR_POLAR_DECODER_LISTSIZE, rnti,
|
||||
1, size, aggregation_level);
|
||||
printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]);
|
||||
free(encoder_outputByte);
|
||||
free(channel_output);
|
||||
@@ -239,13 +245,13 @@ if (logFlag){
|
||||
|
||||
start_meas(&timeEncoder);
|
||||
if (decoder_int16==1) {
|
||||
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, currentPtr);
|
||||
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level);
|
||||
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0)
|
||||
polar_encoder(testInput, encoderOutput, currentPtr);
|
||||
polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level);
|
||||
else if (polarMessageType == 1)
|
||||
polar_encoder_dci(testInput, encoderOutput, currentPtr, rnti);
|
||||
polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level);
|
||||
}
|
||||
stop_meas(&timeEncoder);
|
||||
|
||||
@@ -276,19 +282,20 @@ if (logFlag){
|
||||
start_meas(&timeDecoder);
|
||||
|
||||
if (decoder_int16==1) {
|
||||
decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0, currentPtr);
|
||||
decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0,
|
||||
polarMessageType, testLength, aggregation_level);
|
||||
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
|
||||
if (polarMessageType == 0) {
|
||||
decoderState = polar_decoder(channelOutput,
|
||||
estimatedOutput,
|
||||
currentPtr,
|
||||
decoderListSize);
|
||||
decoderState = polar_decoder(channelOutput,
|
||||
estimatedOutput,
|
||||
decoderListSize,
|
||||
polarMessageType, testLength, aggregation_level);
|
||||
} else if (polarMessageType == 1) {
|
||||
decoderState = polar_decoder_dci(channelOutput,
|
||||
estimatedOutput,
|
||||
currentPtr,
|
||||
decoderListSize,
|
||||
rnti);
|
||||
decoderState = polar_decoder_dci(channelOutput,
|
||||
estimatedOutput,
|
||||
decoderListSize,
|
||||
rnti,
|
||||
polarMessageType, testLength, aggregation_level);
|
||||
}
|
||||
}
|
||||
stop_meas(&timeDecoder);
|
||||
@@ -334,9 +341,9 @@ if (logFlag){
|
||||
decoderState=0;
|
||||
nBitError=0;
|
||||
blockErrorState=0;
|
||||
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
|
||||
memset(testInput,0,sizeof(uint32_t) * realArrayLength);
|
||||
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength);
|
||||
memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength);
|
||||
}
|
||||
|
||||
//Calculate error statistics for the SNR.
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#ifndef __NR_LDPC_TYPES__H__
|
||||
#define __NR_LDPC_TYPES__H__
|
||||
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "nrLDPCdecoder_defs.h"
|
||||
// ==============================================================================
|
||||
// TYPES
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include "assertions.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include "defs.h"
|
||||
#include "assertions.h"
|
||||
#include "openair1/PHY/CODING/nrLDPC_defs.h"
|
||||
@@ -280,4 +279,4 @@ int ldpc_encoder_orig(unsigned char *test_input,unsigned char *channel_input,int
|
||||
|
||||
int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, encoder_implemparams_t *impp) {
|
||||
return ldpc_encoder_orig(test_input[0],channel_input[0],Zc,Kb,block_length,BG,impp->gen_code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <types.h>
|
||||
#include "assertions.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "defs.h"
|
||||
|
||||
#include "ldpc384_byte.c"
|
||||
|
||||
@@ -33,10 +33,9 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include "assertions.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "openair1/PHY/CODING/nrLDPC_defs.h"
|
||||
#include "ldpc_encode_parity_check.c"
|
||||
#include "ldpc_generate_coefficient.c"
|
||||
|
||||
@@ -33,10 +33,9 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include "assertions.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "openair1/PHY/CODING/nrLDPC_defs.h"
|
||||
#include "ldpc_encode_parity_check.c"
|
||||
#include "ldpc_generate_coefficient.c"
|
||||
|
||||
@@ -33,10 +33,9 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include "assertions.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "openair1/PHY/CODING/nrLDPC_defs.h"
|
||||
|
||||
#include "ldpc_encode_parity_check.c"
|
||||
|
||||
@@ -29,12 +29,13 @@ uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){
|
||||
uint8_t crcPolynomialSize = 24;
|
||||
uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize];
|
||||
|
||||
uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *));
|
||||
uint8_t **crc_generator_matrix = malloc(payloadSizeBits*sizeof(uint8_t *) + payloadSizeBits*crcPolynomialSize*sizeof(uint8_t));
|
||||
if (crc_generator_matrix)
|
||||
for (int i = 0; i < payloadSizeBits; i++)
|
||||
crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t));
|
||||
crc_generator_matrix[i] = ((uint8_t*)&crc_generator_matrix[payloadSizeBits])+i*crcPolynomialSize;
|
||||
|
||||
for (int i = 0; i < crcPolynomialSize; i++) crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1];
|
||||
for (int i = 0; i < crcPolynomialSize; i++)
|
||||
crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1];
|
||||
|
||||
for (int i = payloadSizeBits-2; i >= 0; i--){
|
||||
for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1];
|
||||
|
||||
@@ -39,19 +39,44 @@
|
||||
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
|
||||
#include "assertions.h"
|
||||
|
||||
static inline void updateCrcChecksum2(int xlen,
|
||||
int ylen,
|
||||
uint8_t crcChecksum[xlen][ylen],
|
||||
int gxlen,
|
||||
int gylen,
|
||||
uint8_t crcGen[gxlen][gylen],
|
||||
uint8_t listSize,
|
||||
uint32_t i2,
|
||||
uint8_t len)
|
||||
{
|
||||
for (uint8_t i = 0; i < listSize; i++) {
|
||||
for (uint8_t j = 0; j < len; j++) {
|
||||
crcChecksum[j][i+listSize] = ( (crcChecksum[j][i] + crcGen[i2][j]) % 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int8_t polar_decoder(double *input,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize)
|
||||
uint8_t listSize,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level
|
||||
)
|
||||
{
|
||||
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true);
|
||||
//Assumes no a priori knowledge.
|
||||
uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
double *pathMetric = malloc(sizeof(double)*(2*listSize));
|
||||
uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True
|
||||
uint8_t bit[polarParams->N][polarParams->n+1][2*listSize];
|
||||
memset(bit,0,sizeof bit);
|
||||
uint8_t bitUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True
|
||||
memset(bitUpdated,0,sizeof bitUpdated);
|
||||
uint8_t llrUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True
|
||||
memset(llrUpdated,0,sizeof llrUpdated);
|
||||
double llr[polarParams->N][polarParams->n+1][2*listSize];
|
||||
uint8_t crcChecksum[polarParams->crcParityBits][2*listSize];
|
||||
memset(crcChecksum,0,sizeof crcChecksum);
|
||||
double pathMetric[2*listSize];
|
||||
uint8_t crcState[2*listSize]; //0=False, 1=True
|
||||
|
||||
for (int i=0; i<(2*listSize); i++) {
|
||||
pathMetric[i] = 0;
|
||||
@@ -63,13 +88,8 @@ int8_t polar_decoder(double *input,
|
||||
bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2);
|
||||
}
|
||||
|
||||
uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3
|
||||
uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2
|
||||
|
||||
for (int i = 0; i < polarParams->K; i++) {
|
||||
extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t));
|
||||
tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t));
|
||||
}
|
||||
uint8_t extended_crc_generator_matrix[polarParams->K][polarParams->crcParityBits]; //G_P3
|
||||
uint8_t tempECGM[polarParams->K][polarParams->crcParityBits]; //G_P2
|
||||
|
||||
for (int i=0; i<polarParams->payloadBits; i++) {
|
||||
for (int j=0; j<polarParams->crcParityBits; j++) {
|
||||
@@ -102,7 +122,7 @@ int8_t polar_decoder(double *input,
|
||||
}
|
||||
}
|
||||
|
||||
double *d_tilde = malloc(sizeof(double) * polarParams->N);
|
||||
double d_tilde[polarParams->N];
|
||||
nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength);
|
||||
|
||||
for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j];
|
||||
@@ -117,31 +137,33 @@ int8_t polar_decoder(double *input,
|
||||
uint8_t listIndex[2*listSize], copyIndex;
|
||||
|
||||
for (uint16_t currentBit=0; currentBit<polarParams->N; currentBit++) {
|
||||
updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1));
|
||||
updateLLR(currentListSize, currentBit, 0, polarParams->N, polarParams->n+1, 2*listSize, llr, llrUpdated, bit, bitUpdated);
|
||||
|
||||
if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit.
|
||||
updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit);
|
||||
updatePathMetric(pathMetric, currentListSize, 0, currentBit, polarParams->N, polarParams->n+1, 2*listSize, llr);
|
||||
} else { //Information or CRC bit.
|
||||
updatePathMetric2(pathMetric, llr, currentListSize, currentBit);
|
||||
updatePathMetric2(pathMetric, currentListSize, currentBit, polarParams->N, polarParams->n+1, 2*listSize, llr);
|
||||
|
||||
for (int i = 0; i < currentListSize; i++) {
|
||||
for (int j = 0; j < polarParams->N; j++) {
|
||||
for (int k = 0; k < (polarParams->n+1); k++) {
|
||||
for (int j = 0; j < polarParams->N; j++) {
|
||||
for (int k = 0; k < (polarParams->n+1); k++) {
|
||||
bit[j][k][i+currentListSize]=bit[j][k][i];
|
||||
llr[j][k][i+currentListSize]=llr[j][k][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < currentListSize; i++) {
|
||||
bit[currentBit][0][i]=0;
|
||||
crcState[i+currentListSize]=crcState[i];
|
||||
}
|
||||
for (int i = 0; i < currentListSize; i++) {
|
||||
bit[currentBit][0][i]=0;
|
||||
crcState[i+currentListSize]=crcState[i];
|
||||
}
|
||||
|
||||
for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1;
|
||||
|
||||
bitUpdated[currentBit][0]=1;
|
||||
updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits);
|
||||
updateCrcChecksum2(polarParams->crcParityBits, 2*listSize, crcChecksum,
|
||||
polarParams->K, polarParams->crcParityBits, extended_crc_generator_matrix,
|
||||
currentListSize, nonFrozenBit, polarParams->crcParityBits);
|
||||
currentListSize*=2;
|
||||
|
||||
//Keep only the best "listSize" number of entries.
|
||||
@@ -246,14 +268,7 @@ int8_t polar_decoder(double *input,
|
||||
|
||||
if (decoderIterationCheck==0) {
|
||||
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
free(tempECGM);
|
||||
return(-1);
|
||||
polarReturn(-1);
|
||||
}
|
||||
|
||||
nonFrozenBit++;
|
||||
@@ -282,33 +297,34 @@ int8_t polar_decoder(double *input,
|
||||
}
|
||||
}
|
||||
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_2D_array(tempECGM, polarParams->K);
|
||||
/*
|
||||
* Return bits.
|
||||
*/
|
||||
nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out);
|
||||
return(0);
|
||||
|
||||
polarReturn 0;
|
||||
}
|
||||
|
||||
int8_t polar_decoder_dci(double *input,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize,
|
||||
uint16_t n_RNTI) {
|
||||
uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **bitUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
uint8_t **llrUpdated = nr_alloc_uint8_2D_array(polarParams->N, (polarParams->n+1)); //0=False, 1=True
|
||||
double ***llr = nr_alloc_double_3D_array(polarParams->N, (polarParams->n+1), 2*listSize);
|
||||
uint8_t **crcChecksum = nr_alloc_uint8_2D_array(polarParams->crcParityBits, 2*listSize);
|
||||
double *pathMetric = malloc(sizeof(double)*(2*listSize));
|
||||
uint8_t *crcState = malloc(sizeof(uint8_t)*(2*listSize)); //0=False, 1=True
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level ) {
|
||||
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true);
|
||||
|
||||
uint8_t bit[polarParams->N][polarParams->n+1][2*listSize];
|
||||
memset(bit,0,sizeof bit);
|
||||
uint8_t bitUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True
|
||||
memset(bitUpdated,0,sizeof bitUpdated);
|
||||
uint8_t llrUpdated[polarParams->N][polarParams->n+1]; //0=False, 1=True
|
||||
memset(llrUpdated,0,sizeof llrUpdated);
|
||||
double llr[polarParams->N][polarParams->n+1][2*listSize];
|
||||
uint8_t crcChecksum[polarParams->crcParityBits][2*listSize];
|
||||
memset(crcChecksum,0,sizeof crcChecksum);
|
||||
double pathMetric[2*listSize];
|
||||
uint8_t crcState[2*listSize]; //0=False, 1=True
|
||||
uint8_t extended_crc_scrambling_pattern[polarParams->crcParityBits];
|
||||
|
||||
for (int i=0; i<(2*listSize); i++) {
|
||||
@@ -321,13 +337,8 @@ int8_t polar_decoder_dci(double *input,
|
||||
bitUpdated[i][0]=((polarParams->information_bit_pattern[i]+1) % 2);
|
||||
}
|
||||
|
||||
uint8_t **extended_crc_generator_matrix = malloc(polarParams->K * sizeof(uint8_t *)); //G_P3: K-by-P
|
||||
uint8_t **tempECGM = malloc(polarParams->K * sizeof(uint8_t *)); //G_P2: K-by-P
|
||||
|
||||
for (int i = 0; i < polarParams->K; i++) {
|
||||
extended_crc_generator_matrix[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t));
|
||||
tempECGM[i] = malloc(polarParams->crcParityBits * sizeof(uint8_t));
|
||||
}
|
||||
uint8_t extended_crc_generator_matrix[polarParams->K][polarParams->crcParityBits]; //G_P3: K-by-P
|
||||
uint8_t tempECGM[polarParams->K][polarParams->crcParityBits]; //G_P2: K-by-P
|
||||
|
||||
for (int i=0; i<polarParams->payloadBits; i++) {
|
||||
for (int j=0; j<polarParams->crcParityBits; j++) {
|
||||
@@ -366,17 +377,19 @@ int8_t polar_decoder_dci(double *input,
|
||||
extended_crc_scrambling_pattern[i]=(n_RNTI>>(23-i))&1;
|
||||
}
|
||||
|
||||
double *d_tilde = malloc(sizeof(double) * polarParams->N);
|
||||
double d_tilde[polarParams->N];
|
||||
nr_polar_rate_matching(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength);
|
||||
|
||||
for (int j = 0; j < polarParams->N; j++) llr[j][polarParams->n][0]=d_tilde[j];
|
||||
for (int j = 0; j < polarParams->N; j++)
|
||||
llr[j][polarParams->n][0]=d_tilde[j];
|
||||
|
||||
/*
|
||||
* SCL polar decoder.
|
||||
*/
|
||||
|
||||
for (int i=0; i<polarParams->crcParityBits; i++) {
|
||||
for (int j=0; j<polarParams->crcParityBits; j++) crcChecksum[i][0]=crcChecksum[i][0]+polarParams->crc_generator_matrix[j][i];
|
||||
for (int j=0; j<polarParams->crcParityBits; j++)
|
||||
crcChecksum[i][0]=crcChecksum[i][0]+polarParams->crc_generator_matrix[j][i];
|
||||
|
||||
crcChecksum[i][0]=(crcChecksum[i][0]%2);
|
||||
}
|
||||
@@ -388,12 +401,12 @@ int8_t polar_decoder_dci(double *input,
|
||||
uint8_t listIndex[2*listSize], copyIndex;
|
||||
|
||||
for (uint16_t currentBit=0; currentBit<polarParams->N; currentBit++) {
|
||||
updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1));
|
||||
updateLLR(currentListSize, currentBit, 0, polarParams->N, polarParams->n+1, 2*listSize, llr, llrUpdated, bit, bitUpdated);
|
||||
|
||||
if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit.
|
||||
updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit);
|
||||
updatePathMetric(pathMetric, currentListSize, 0, currentBit,polarParams->N, polarParams->n+1, 2*listSize, llr);
|
||||
} else { //Information or CRC bit.
|
||||
updatePathMetric2(pathMetric, llr, currentListSize, currentBit);
|
||||
updatePathMetric2(pathMetric, currentListSize, currentBit, polarParams->N, polarParams->n+1, 2*listSize, llr);
|
||||
|
||||
for (int i = 0; i < currentListSize; i++) {
|
||||
for (int j = 0; j < polarParams->N; j++) {
|
||||
@@ -412,7 +425,9 @@ int8_t polar_decoder_dci(double *input,
|
||||
for (int i = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1;
|
||||
|
||||
bitUpdated[currentBit][0]=1;
|
||||
updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits);
|
||||
updateCrcChecksum2(polarParams->crcParityBits, 2*listSize, crcChecksum,
|
||||
polarParams->K, polarParams->crcParityBits, extended_crc_generator_matrix,
|
||||
currentListSize, nonFrozenBit, polarParams->crcParityBits);
|
||||
currentListSize*=2;
|
||||
|
||||
//Keep only the best "listSize" number of entries.
|
||||
@@ -513,18 +528,12 @@ int8_t polar_decoder_dci(double *input,
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < currentListSize; i++) decoderIterationCheck+=crcState[i];
|
||||
for (uint8_t i = 0; i < currentListSize; i++)
|
||||
decoderIterationCheck+=crcState[i];
|
||||
|
||||
if (decoderIterationCheck==0) {
|
||||
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
free(tempECGM);
|
||||
return(-1);
|
||||
polarReturn -1;
|
||||
}
|
||||
|
||||
nonFrozenBit++;
|
||||
@@ -553,19 +562,12 @@ int8_t polar_decoder_dci(double *input,
|
||||
}
|
||||
}
|
||||
|
||||
free(d_tilde);
|
||||
free(pathMetric);
|
||||
free(crcState);
|
||||
nr_free_uint8_3D_array(bit, polarParams->N, (polarParams->n+1));
|
||||
nr_free_double_3D_array(llr, polarParams->N, (polarParams->n+1));
|
||||
nr_free_uint8_2D_array(crcChecksum, polarParams->crcParityBits);
|
||||
nr_free_uint8_2D_array(extended_crc_generator_matrix, polarParams->K);
|
||||
nr_free_uint8_2D_array(tempECGM, polarParams->K);
|
||||
/*
|
||||
* Return bits.
|
||||
*/
|
||||
nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out);
|
||||
return(0);
|
||||
|
||||
polarReturn 0;
|
||||
}
|
||||
|
||||
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
|
||||
@@ -604,8 +606,11 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
|
||||
uint32_t polar_decoder_int16(int16_t *input,
|
||||
uint64_t *out,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams)
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level )
|
||||
{
|
||||
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, true);
|
||||
int16_t d_tilde[polarParams->N];// = malloc(sizeof(double) * polarParams->N);
|
||||
nr_polar_rate_matching_int16(input, d_tilde, polarParams->rate_matching_pattern, polarParams->K, polarParams->N, polarParams->encoderLength);
|
||||
|
||||
@@ -702,5 +707,6 @@ uint32_t polar_decoder_int16(int16_t *input,
|
||||
rxcrc,polarParams->payloadBits);
|
||||
#endif
|
||||
out[0]=Ar;
|
||||
return(crc^rxcrc);
|
||||
|
||||
polarReturn crc^rxcrc;
|
||||
}
|
||||
|
||||
@@ -36,51 +36,25 @@
|
||||
|
||||
//#define DEBUG_NEW_IMPL 1
|
||||
|
||||
void updateLLR(double ***llr,
|
||||
uint8_t **llrU,
|
||||
uint8_t ***bit,
|
||||
uint8_t **bitU,
|
||||
uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen)
|
||||
{
|
||||
uint16_t offset = (xlen/(pow(2,(ylen-col-1))));
|
||||
for (uint8_t i=0; i<listSize; i++) {
|
||||
if (( (row) % (2*offset) ) >= offset ) {
|
||||
if(bitU[row-offset][col]==0) updateBit(bit, bitU, listSize, (row-offset), col, xlen, ylen);
|
||||
if(llrU[row-offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row-offset), (col+1), xlen, ylen);
|
||||
if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen);
|
||||
llr[row][col][i] = (pow((-1),bit[row-offset][col][i])*llr[row-offset][col+1][i]) + llr[row][col+1][i];
|
||||
} else {
|
||||
if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen);
|
||||
if(llrU[row+offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row+offset), (col+1), xlen, ylen);
|
||||
computeLLR(llr, row, col, i, offset);
|
||||
}
|
||||
}
|
||||
llrU[row][col]=1;
|
||||
|
||||
// printf("LLR (a %f, b %f): llr[%d][%d] %f\n",32*a,32*b,col,row,32*llr[col][row]);
|
||||
}
|
||||
|
||||
void updateBit(uint8_t ***bit,
|
||||
uint8_t **bitU,
|
||||
uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen)
|
||||
static inline void updateBit(uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen,
|
||||
int zlen,
|
||||
uint8_t bit[xlen][ylen][zlen],
|
||||
uint8_t bitU[xlen][ylen])
|
||||
{
|
||||
uint16_t offset = ( xlen/(pow(2,(ylen-col))) );
|
||||
|
||||
for (uint8_t i=0; i<listSize; i++) {
|
||||
if (( (row) % (2*offset) ) >= offset ) {
|
||||
if (bitU[row][col-1]==0) updateBit(bit, bitU, listSize, row, (col-1), xlen, ylen);
|
||||
if (bitU[row][col-1]==0) updateBit(listSize, row, (col-1), xlen, ylen, zlen, bit, bitU);
|
||||
bit[row][col][i] = bit[row][col-1][i];
|
||||
} else {
|
||||
if (bitU[row][col-1]==0) updateBit(bit, bitU, listSize, row, (col-1), xlen, ylen);
|
||||
if (bitU[row+offset][col-1]==0) updateBit(bit, bitU, listSize, (row+offset), (col-1), xlen, ylen);
|
||||
if (bitU[row][col-1]==0) updateBit(listSize, row, (col-1), xlen, ylen, zlen, bit, bitU);
|
||||
if (bitU[row+offset][col-1]==0) updateBit(listSize, (row+offset), (col-1), xlen, ylen, zlen, bit, bitU);
|
||||
bit[row][col][i] = ( (bit[row][col-1][i]+bit[row+offset][col-1][i]) % 2);
|
||||
}
|
||||
}
|
||||
@@ -88,11 +62,60 @@ void updateBit(uint8_t ***bit,
|
||||
bitU[row][col]=1;
|
||||
}
|
||||
|
||||
static inline void computeLLR(uint16_t row,
|
||||
uint16_t col,
|
||||
uint8_t i,
|
||||
uint16_t offset,
|
||||
int xlen,
|
||||
int ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen])
|
||||
{
|
||||
double a = llr[row][col + 1][i];
|
||||
double b = llr[row + offset][col + 1][i];
|
||||
llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); //eq. (8a)
|
||||
}
|
||||
|
||||
|
||||
void updateLLR(uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen],
|
||||
uint8_t llrU[xlen][ylen],
|
||||
uint8_t bit[xlen][ylen][zlen],
|
||||
uint8_t bitU[xlen][ylen]
|
||||
)
|
||||
{
|
||||
uint16_t offset = (xlen/(pow(2,(ylen-col-1))));
|
||||
for (uint8_t i=0; i<listSize; i++) {
|
||||
if (( (row) % (2*offset) ) >= offset ) {
|
||||
if(bitU[row-offset][col]==0) updateBit(listSize, (row-offset), col, xlen, ylen, zlen, bit, bitU);
|
||||
if(llrU[row-offset][col+1]==0) updateLLR(listSize, (row-offset), (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU );
|
||||
if(llrU[row][col+1]==0) updateLLR(listSize, row, (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU);
|
||||
llr[row][col][i] = (pow((-1),bit[row-offset][col][i])*llr[row-offset][col+1][i]) + llr[row][col+1][i];
|
||||
} else {
|
||||
if(llrU[row][col+1]==0) updateLLR(listSize, row, (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU );
|
||||
if(llrU[row+offset][col+1]==0) updateLLR(listSize, (row+offset), (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU );
|
||||
computeLLR(row, col, i, offset, xlen, ylen, zlen, llr);
|
||||
}
|
||||
}
|
||||
llrU[row][col]=1;
|
||||
|
||||
// printf("LLR (a %f, b %f): llr[%d][%d] %f\n",32*a,32*b,col,row,32*llr[col][row]);
|
||||
}
|
||||
|
||||
void updatePathMetric(double *pathMetric,
|
||||
double ***llr,
|
||||
uint8_t listSize,
|
||||
uint8_t bitValue,
|
||||
uint16_t row)
|
||||
uint8_t listSize,
|
||||
uint8_t bitValue,
|
||||
uint16_t row,
|
||||
int xlen,
|
||||
int ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen]
|
||||
)
|
||||
{
|
||||
int8_t multiplier = (2*bitValue) - 1;
|
||||
for (uint8_t i=0; i<listSize; i++)
|
||||
@@ -101,11 +124,14 @@ void updatePathMetric(double *pathMetric,
|
||||
}
|
||||
|
||||
void updatePathMetric2(double *pathMetric,
|
||||
double ***llr,
|
||||
uint8_t listSize,
|
||||
uint16_t row)
|
||||
uint8_t listSize,
|
||||
uint16_t row,
|
||||
int xlen,
|
||||
int ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen])
|
||||
{
|
||||
double *tempPM = malloc(sizeof(double) * listSize);
|
||||
double tempPM[listSize];
|
||||
memcpy(tempPM, pathMetric, (sizeof(double) * listSize));
|
||||
|
||||
uint8_t bitValue = 0;
|
||||
@@ -118,48 +144,8 @@ void updatePathMetric2(double *pathMetric,
|
||||
for (uint8_t i = listSize; i < 2*listSize; i++)
|
||||
pathMetric[i] = tempPM[(i-listSize)] + log(1 + exp(multiplier * llr[row][0][(i-listSize)])); //eq. (11b)
|
||||
|
||||
free(tempPM);
|
||||
}
|
||||
|
||||
void computeLLR(double ***llr,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint8_t i,
|
||||
uint16_t offset)
|
||||
{
|
||||
double a = llr[row][col + 1][i];
|
||||
double b = llr[row + offset][col + 1][i];
|
||||
llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); //eq. (8a)
|
||||
}
|
||||
|
||||
void updateCrcChecksum(uint8_t **crcChecksum,
|
||||
uint8_t **crcGen,
|
||||
uint8_t listSize,
|
||||
uint32_t i2,
|
||||
uint8_t len)
|
||||
{
|
||||
for (uint8_t i = 0; i < listSize; i++) {
|
||||
for (uint8_t j = 0; j < len; j++) {
|
||||
crcChecksum[j][i] = ( (crcChecksum[j][i] + crcGen[i2][j]) % 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updateCrcChecksum2(uint8_t **crcChecksum,
|
||||
uint8_t **crcGen,
|
||||
uint8_t listSize,
|
||||
uint32_t i2,
|
||||
uint8_t len)
|
||||
{
|
||||
for (uint8_t i = 0; i < listSize; i++) {
|
||||
for (uint8_t j = 0; j < len; j++) {
|
||||
crcChecksum[j][i+listSize] = ( (crcChecksum[j][i] + crcGen[i2][j]) % 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
decoder_node_t *new_decoder_node(int first_leaf_index, int level) {
|
||||
|
||||
decoder_node_t *node=(decoder_node_t *)malloc(sizeof(decoder_node_t));
|
||||
@@ -222,6 +208,23 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol
|
||||
return(new_node);
|
||||
}
|
||||
|
||||
void delete_nodes(decoder_node_t * n) {
|
||||
if (n) {
|
||||
if(n->left)
|
||||
delete_nodes(n->left);
|
||||
if(n->right)
|
||||
delete_nodes(n->right);
|
||||
free(n->alpha);
|
||||
free(n->beta);
|
||||
free(n);
|
||||
}
|
||||
}
|
||||
|
||||
void delete_decoder_tree(t_nrPolar_params *polarParams) {
|
||||
if (polarParams->tree.root)
|
||||
delete_nodes(polarParams->tree.root);
|
||||
}
|
||||
|
||||
void build_decoder_tree(t_nrPolar_params *polarParams)
|
||||
{
|
||||
polarParams->tree.num_nodes=0;
|
||||
|
||||
@@ -79,9 +79,10 @@ typedef struct decoder_tree_t_s {
|
||||
|
||||
struct nrPolar_params {
|
||||
//messageType: 0=PBCH, 1=DCI, -1=UCI
|
||||
int idx; //idx = (messageType * messageLength * aggregation_prime);
|
||||
struct nrPolar_params *nextPtr;
|
||||
|
||||
struct nrPolar_params *nextPtr __attribute__((aligned(16)));
|
||||
bool busy;
|
||||
uint32_t idx;
|
||||
uint8_t n_max;
|
||||
uint8_t i_il;
|
||||
uint8_t i_seg;
|
||||
@@ -138,34 +139,46 @@ typedef struct nrPolar_params t_nrPolar_params;
|
||||
|
||||
void polar_encoder(uint32_t *input,
|
||||
uint32_t *output,
|
||||
const t_nrPolar_params *polarParams);
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
void polar_encoder_dci(uint32_t *in,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint16_t n_RNTI);
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
void polar_encoder_fast(uint64_t *A,
|
||||
void *out,
|
||||
int32_t crcmask,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams);
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
int8_t polar_decoder(double *input,
|
||||
uint32_t *output,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize);
|
||||
uint8_t listSize,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
uint32_t polar_decoder_int16(int16_t *input,
|
||||
uint64_t *out,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams);
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
int8_t polar_decoder_dci(double *input,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint8_t listSize,
|
||||
uint16_t n_RNTI);
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level);
|
||||
|
||||
void generic_polar_decoder(const t_nrPolar_params *pp,
|
||||
decoder_node_t *node);
|
||||
@@ -183,13 +196,12 @@ void build_decoder_tree(t_nrPolar_params *pp);
|
||||
void build_polar_tables(t_nrPolar_params *polarParams);
|
||||
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
|
||||
|
||||
void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
|
||||
void nr_polar_print_polarParams(void);
|
||||
|
||||
t_nrPolar_params *nr_polar_params (int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level,
|
||||
int decoder_flag,
|
||||
t_nrPolar_params **polarList_ext);
|
||||
int decoder_flag);
|
||||
|
||||
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
|
||||
|
||||
@@ -278,34 +290,6 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1,
|
||||
uint16_t row,
|
||||
uint16_t col);
|
||||
|
||||
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen,
|
||||
uint16_t ylen,
|
||||
uint16_t zlen);
|
||||
|
||||
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
double ***nr_alloc_double_3D_array(uint16_t xlen,
|
||||
uint16_t ylen,
|
||||
uint16_t zlen);
|
||||
|
||||
double **nr_alloc_double_2D_array(uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
void nr_free_double_3D_array(double ***input,
|
||||
uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
void nr_free_double_2D_array(double **input,
|
||||
uint16_t xlen);
|
||||
|
||||
void nr_free_uint8_3D_array(uint8_t ***input,
|
||||
uint16_t xlen,
|
||||
uint16_t ylen);
|
||||
|
||||
void nr_free_uint8_2D_array(uint8_t **input,
|
||||
uint16_t xlen);
|
||||
|
||||
void nr_sort_asc_double_1D_array_ind(double *matrix,
|
||||
uint8_t *ind,
|
||||
uint8_t len);
|
||||
@@ -316,52 +300,33 @@ void nr_sort_asc_int16_1D_array_ind(int32_t *matrix,
|
||||
|
||||
void nr_free_double_2D_array(double **input, uint16_t xlen);
|
||||
|
||||
void updateLLR(double ***llr,
|
||||
uint8_t **llrU,
|
||||
uint8_t ***bit,
|
||||
uint8_t **bitU,
|
||||
uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen);
|
||||
|
||||
void updateBit(uint8_t ***bit,
|
||||
uint8_t **bitU,
|
||||
uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen);
|
||||
|
||||
void updateLLR(uint8_t listSize,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint16_t xlen,
|
||||
uint8_t ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen],
|
||||
uint8_t llrU[xlen][ylen],
|
||||
uint8_t bit[xlen][ylen][zlen],
|
||||
uint8_t bitU[xlen][ylen]
|
||||
);
|
||||
void updatePathMetric(double *pathMetric,
|
||||
double ***llr,
|
||||
uint8_t listSize,
|
||||
uint8_t bitValue,
|
||||
uint16_t row);
|
||||
|
||||
uint8_t listSize,
|
||||
uint8_t bitValue,
|
||||
uint16_t row,
|
||||
int xlen,
|
||||
int ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen]
|
||||
);
|
||||
void updatePathMetric2(double *pathMetric,
|
||||
double ***llr,
|
||||
uint8_t listSize,
|
||||
uint16_t row);
|
||||
|
||||
void computeLLR(double ***llr,
|
||||
uint16_t row,
|
||||
uint16_t col,
|
||||
uint8_t i,
|
||||
uint16_t offset);
|
||||
|
||||
void updateCrcChecksum(uint8_t **crcChecksum,
|
||||
uint8_t **crcGen,
|
||||
uint8_t listSize,
|
||||
uint32_t i2,
|
||||
uint8_t len);
|
||||
|
||||
void updateCrcChecksum2(uint8_t **crcChecksum,
|
||||
uint8_t **crcGen,
|
||||
uint8_t listSize,
|
||||
uint32_t i2,
|
||||
uint8_t len);
|
||||
uint8_t listSize,
|
||||
uint16_t row,
|
||||
int xlen,
|
||||
int ylen,
|
||||
int zlen,
|
||||
double llr[xlen][ylen][zlen]);
|
||||
|
||||
//Also nr_polar_rate_matcher
|
||||
static inline void nr_polar_interleaver(uint8_t *input,
|
||||
@@ -379,5 +344,13 @@ static inline void nr_polar_deinterleaver(uint8_t *input,
|
||||
{
|
||||
for (int i=0; i<size; i++) output[pattern[i]]=input[i];
|
||||
}
|
||||
void delete_decoder_tree(t_nrPolar_params *);
|
||||
|
||||
extern pthread_mutex_t PolarListMutex;
|
||||
#define polarReturn \
|
||||
pthread_mutex_lock(&PolarListMutex); \
|
||||
polarParams->busy=false; \
|
||||
pthread_mutex_unlock(&PolarListMutex); \
|
||||
return
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
|
||||
void polar_encoder(uint32_t *in,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams) {
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level) {
|
||||
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
|
||||
if (1) {//polarParams->idx == 0 || polarParams->idx == 1) { //PBCH or PDCCH
|
||||
/*
|
||||
uint64_t B = (((uint64_t)*in)&((((uint64_t)1)<<32)-1)) | (((uint64_t)crc24c((uint8_t*)in,polarParams->payloadBits)>>8)<<polarParams->payloadBits);
|
||||
@@ -57,10 +60,10 @@ void polar_encoder(uint32_t *in,
|
||||
*/
|
||||
//Calculate CRC.
|
||||
nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_A,
|
||||
polarParams->crc_generator_matrix,
|
||||
polarParams->nr_polar_crc,
|
||||
polarParams->payloadBits,
|
||||
polarParams->crcParityBits);
|
||||
polarParams->crc_generator_matrix,
|
||||
polarParams->nr_polar_crc,
|
||||
polarParams->payloadBits,
|
||||
polarParams->crcParityBits);
|
||||
|
||||
for (uint8_t i = 0; i < polarParams->crcParityBits; i++)
|
||||
polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2);
|
||||
@@ -150,12 +153,19 @@ void polar_encoder(uint32_t *in,
|
||||
|
||||
#endif
|
||||
nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out);
|
||||
|
||||
polarReturn;
|
||||
|
||||
}
|
||||
|
||||
void polar_encoder_dci(uint32_t *in,
|
||||
uint32_t *out,
|
||||
const t_nrPolar_params *polarParams,
|
||||
uint16_t n_RNTI) {
|
||||
uint16_t n_RNTI,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level) {
|
||||
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
|
||||
|
||||
#ifdef DEBUG_POLAR_ENCODER_DCI
|
||||
printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]);
|
||||
#endif
|
||||
@@ -249,6 +259,7 @@ void polar_encoder_dci(uint32_t *in,
|
||||
printf("\n[polar_encoder_dci] out: ");
|
||||
for (int i = 0; i < outputInd; i++) printf("[%d]->0x%08x\t", i, out[i]);
|
||||
#endif
|
||||
polarReturn;
|
||||
}
|
||||
|
||||
static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void *in,void *out) __attribute__((always_inline));
|
||||
@@ -334,7 +345,7 @@ void build_polar_tables(t_nrPolar_params *polarParams) {
|
||||
AssertFatal(polarParams->N==512 || polarParams->N==256 || polarParams->N==128,"N = %d, not done yet\n",polarParams->N);
|
||||
// build G bit vectors for information bit positions and convert the bit as bytes tables in nr_polar_kronecker_power_matrices.c to 64 bit packed vectors.
|
||||
// keep only rows of G which correspond to information/crc bits
|
||||
polarParams->G_N_tab = (uint64_t **)malloc((polarParams->K + polarParams->n_pc) * sizeof(int64_t *));
|
||||
polarParams->G_N_tab = (uint64_t **)calloc((polarParams->K + polarParams->n_pc),sizeof(int64_t *));
|
||||
int k=0;
|
||||
|
||||
for (int i=0; i<polarParams->N; i++) {
|
||||
@@ -418,11 +429,14 @@ void polar_encoder_fast(uint64_t *A,
|
||||
void *out,
|
||||
int32_t crcmask,
|
||||
uint8_t ones_flag,
|
||||
const t_nrPolar_params *polarParams) {
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level) {
|
||||
|
||||
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
|
||||
// AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K);
|
||||
AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K);
|
||||
AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits);
|
||||
uint64_t B[4]= {0,0,0,0},Cprime[4]= {0,0,0,0};
|
||||
int bitlen = polarParams->payloadBits;
|
||||
// append crc
|
||||
AssertFatal(bitlen<129,"support for payloads <= 128 bits\n");
|
||||
@@ -451,9 +465,12 @@ void polar_encoder_fast(uint64_t *A,
|
||||
A32_flip[1+offset]=((uint8_t *)&Aprime)[2];
|
||||
A32_flip[2+offset]=((uint8_t *)&Aprime)[1];
|
||||
A32_flip[3+offset]=((uint8_t *)&Aprime)[0];
|
||||
if (polarParams->crcParityBits == 24) tcrc = (uint64_t)(((crcmask^(crc24c(A32_flip,8*offset+bitlen)>>8)))&0xffffff);
|
||||
else if (polarParams->crcParityBits == 11) tcrc = (uint64_t)(((crcmask^(crc11(A32_flip,bitlen)>>21)))&0x7ff);
|
||||
else if (polarParams->crcParityBits == 6) tcrc = (uint64_t)(((crcmask^(crc6(A32_flip,bitlen)>>26)))&0x3f);
|
||||
if (polarParams->crcParityBits == 24)
|
||||
tcrc = (uint64_t)(((crcmask^(crc24c(A32_flip,8*offset+bitlen)>>8)))&0xffffff);
|
||||
else if (polarParams->crcParityBits == 11)
|
||||
tcrc = (uint64_t)(((crcmask^(crc11(A32_flip,bitlen)>>21)))&0x7ff);
|
||||
else if (polarParams->crcParityBits == 6)
|
||||
tcrc = (uint64_t)(((crcmask^(crc6(A32_flip,bitlen)>>26)))&0x3f);
|
||||
} else if (bitlen<=64) {
|
||||
uint8_t A64_flip[8+offset];
|
||||
if (ones_flag) {
|
||||
@@ -470,8 +487,10 @@ void polar_encoder_fast(uint64_t *A,
|
||||
A64_flip[5+offset]=((uint8_t *)&Aprime)[2];
|
||||
A64_flip[6+offset]=((uint8_t *)&Aprime)[1];
|
||||
A64_flip[7+offset]=((uint8_t *)&Aprime)[0];
|
||||
if (polarParams->crcParityBits == 24) tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,8*offset+bitlen)>>8)))&0xffffff;
|
||||
else if (polarParams->crcParityBits == 11) tcrc = (uint64_t)((crcmask^(crc11(A64_flip,bitlen)>>21)))&0x7ff;
|
||||
if (polarParams->crcParityBits == 24)
|
||||
tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,8*offset+bitlen)>>8)))&0xffffff;
|
||||
else if (polarParams->crcParityBits == 11)
|
||||
tcrc = (uint64_t)((crcmask^(crc11(A64_flip,bitlen)>>21)))&0x7ff;
|
||||
}
|
||||
else if (bitlen<=128) {
|
||||
uint8_t A128_flip[16+offset];
|
||||
@@ -481,38 +500,37 @@ void polar_encoder_fast(uint64_t *A,
|
||||
A128_flip[2] = 0xff;
|
||||
}
|
||||
uint128_t Aprime= (uint128_t)(((uint128_t)*A)<<(128-bitlen));
|
||||
A128_flip[0+offset]=((uint8_t*)&Aprime)[15]; A128_flip[1+offset]=((uint8_t*)&Aprime)[14];
|
||||
A128_flip[2+offset]=((uint8_t*)&Aprime)[13]; A128_flip[3+offset]=((uint8_t*)&Aprime)[12];
|
||||
A128_flip[4+offset]=((uint8_t*)&Aprime)[11]; A128_flip[5+offset]=((uint8_t*)&Aprime)[10];
|
||||
A128_flip[6+offset] =((uint8_t*)&Aprime)[9]; A128_flip[7+offset] =((uint8_t*)&Aprime)[8];
|
||||
A128_flip[8+offset] =((uint8_t*)&Aprime)[7]; A128_flip[9+offset] =((uint8_t*)&Aprime)[6];
|
||||
A128_flip[10+offset]=((uint8_t*)&Aprime)[5]; A128_flip[11+offset]=((uint8_t*)&Aprime)[4];
|
||||
A128_flip[12+offset]=((uint8_t*)&Aprime)[3]; A128_flip[13+offset]=((uint8_t*)&Aprime)[2];
|
||||
A128_flip[14+offset]=((uint8_t*)&Aprime)[1]; A128_flip[15+offset]=((uint8_t*)&Aprime)[0];
|
||||
if (polarParams->crcParityBits == 24) tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,8*offset+bitlen)>>8)))&0xffffff;
|
||||
else if (polarParams->crcParityBits == 11) tcrc = (uint64_t)((crcmask^(crc11(A128_flip,bitlen)>>21)))&0x7ff;
|
||||
for (int i=0; i<16 ; i++)
|
||||
A128_flip[i+offset]=((uint8_t*)&Aprime)[15-i];
|
||||
if (polarParams->crcParityBits == 24)
|
||||
tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,8*offset+bitlen)>>8)))&0xffffff;
|
||||
else if (polarParams->crcParityBits == 11)
|
||||
tcrc = (uint64_t)((crcmask^(crc11(A128_flip,bitlen)>>21)))&0x7ff;
|
||||
}
|
||||
|
||||
int n;
|
||||
// this is number of quadwords in the bit string
|
||||
int quadwlen = (polarParams->K>>6);
|
||||
|
||||
if ((polarParams->K&63) > 0) quadwlen++;
|
||||
int quadwlen = (polarParams->K+63)/64;
|
||||
|
||||
// Create the B bit string as
|
||||
// 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, p_0, p_1, ..., p_{N_parity-1}
|
||||
|
||||
//??? b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0
|
||||
|
||||
for (n=0; n<quadwlen; n++) if (n==0) B[n] = (A[n] << polarParams->crcParityBits) | tcrc;
|
||||
else B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits));
|
||||
uint64_t B[4]= {0};
|
||||
B[0] = (A[0] << polarParams->crcParityBits) | tcrc;
|
||||
for (n=1; n<quadwlen; n++)
|
||||
if ((bitlen+63)/64 > n)
|
||||
B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits));
|
||||
else
|
||||
B[n] = (A[n-1]>>(64-polarParams->crcParityBits));
|
||||
|
||||
uint8_t *Bbyte = (uint8_t *)B;
|
||||
|
||||
// for each byte of B, lookup in corresponding table for 64-bit word corresponding to that byte and its position
|
||||
uint64_t Cprime[4]= {0};
|
||||
if (polarParams->K<65)
|
||||
Cprime[0] = polarParams->cprime_tab0[0][Bbyte[0]] |
|
||||
polarParams->cprime_tab0[1][Bbyte[1]] |
|
||||
polarParams->cprime_tab0[1][Bbyte[1]] |
|
||||
polarParams->cprime_tab0[2][Bbyte[2]] |
|
||||
polarParams->cprime_tab0[3][Bbyte[3]] |
|
||||
polarParams->cprime_tab0[4][Bbyte[4]] |
|
||||
@@ -684,4 +702,7 @@ void polar_encoder_fast(uint64_t *A,
|
||||
}
|
||||
memset((void*)out,0,polarParams->encoderLength>>3);
|
||||
polar_rate_matching(polarParams,(void *)D, out);
|
||||
|
||||
polarReturn;
|
||||
|
||||
}
|
||||
|
||||
@@ -43,163 +43,6 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1, uint8_t **matr
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
|
||||
uint8_t ***output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_uint8_3D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
output[i] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_uint8_3D_array] Problem at 2D allocation");
|
||||
nr_free_uint8_3D_array(output, xlen, ylen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
output[i][j] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
if ((output[i][j] = malloc(zlen * sizeof *output[i][j])) == NULL) {
|
||||
perror("[nr_alloc_uint8_3D_array] Problem at 3D allocation");
|
||||
nr_free_uint8_3D_array(output, xlen, ylen);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen, uint16_t ylen) {
|
||||
uint8_t **output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_uint8_2D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
output[i] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_uint8_2D_array] Problem at 2D allocation");
|
||||
nr_free_uint8_2D_array(output, xlen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
output[i][j] = 0;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
double ***nr_alloc_double_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
|
||||
double ***output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_double_3D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
output[i] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_double_3D_array] Problem at 2D allocation");
|
||||
nr_free_double_3D_array(output, xlen, ylen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
output[i][j] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
if ((output[i][j] = malloc(zlen * sizeof *output[i][j])) == NULL) {
|
||||
perror("[nr_alloc_double_3D_array] Problem at 3D allocation");
|
||||
nr_free_double_3D_array(output, xlen, ylen);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
double **nr_alloc_double_2D_array(uint16_t xlen, uint16_t ylen) {
|
||||
double **output;
|
||||
int i, j;
|
||||
|
||||
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
|
||||
perror("[nr_alloc_double_3D_array] Problem at 1D allocation");
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
output[i] = NULL;
|
||||
|
||||
|
||||
for (i = 0; i < xlen; i++)
|
||||
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
|
||||
perror("[nr_alloc_double_2D_array] Problem at 2D allocation");
|
||||
nr_free_double_2D_array(output, xlen);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < xlen; i++)
|
||||
for (j = 0; j < ylen; j++)
|
||||
output[i][j] = 0;
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void nr_free_double_3D_array(double ***input, uint16_t xlen, uint16_t ylen) {
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < xlen; i++) {
|
||||
for (j = 0; j < ylen; j++) {
|
||||
free(input[i][j]);
|
||||
}
|
||||
free(input[i]);
|
||||
}
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_double_2D_array(double **input, uint16_t xlen) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < xlen; i++) {
|
||||
free(input[i]);
|
||||
}
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_uint8_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen) {
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < xlen; i++) {
|
||||
for (j = 0; j < ylen; j++) {
|
||||
free(input[i][j]);
|
||||
}
|
||||
free(input[i]);
|
||||
}
|
||||
free(input);
|
||||
}
|
||||
|
||||
void nr_free_uint8_2D_array(uint8_t **input, uint16_t xlen) {
|
||||
for (int i = 0; i < xlen; i++) free(input[i]);
|
||||
free(input);
|
||||
}
|
||||
|
||||
// Modified Bubble Sort.
|
||||
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) {
|
||||
int swaps;
|
||||
|
||||
+194
-161
@@ -33,178 +33,236 @@
|
||||
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
|
||||
#include "PHY/NR_TRANSPORT/nr_dci.h"
|
||||
|
||||
#define PolarKey ((messageType<<24)|(messageLength<<8)|aggregation_level)
|
||||
static t_nrPolar_params * PolarList=NULL;
|
||||
pthread_mutex_t PolarListMutex=PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static int intcmp(const void *p1,const void *p2) {
|
||||
return(*(int16_t *)p1 > *(int16_t *)p2);
|
||||
}
|
||||
|
||||
static void nr_polar_init(t_nrPolar_params * *polarParams,
|
||||
int8_t messageType,
|
||||
static void nr_polar_delete_list(t_nrPolar_params * polarParams) {
|
||||
if (!polarParams)
|
||||
return;
|
||||
if (polarParams->nextPtr)
|
||||
nr_polar_delete_list(polarParams->nextPtr);
|
||||
|
||||
delete_decoder_tree(polarParams);
|
||||
//From build_polar_tables()
|
||||
for (int k=0; k < polarParams->K + polarParams->n_pc; k++)
|
||||
if (polarParams->G_N_tab[k])
|
||||
free(polarParams->G_N_tab[k]);
|
||||
free(polarParams->G_N_tab);
|
||||
free(polarParams->rm_tab);
|
||||
if (polarParams->crc_generator_matrix)
|
||||
free(polarParams->crc_generator_matrix);
|
||||
//polar_encoder vectors:
|
||||
free(polarParams->nr_polar_crc);
|
||||
free(polarParams->nr_polar_aPrime);
|
||||
free(polarParams->nr_polar_APrime);
|
||||
free(polarParams->nr_polar_D);
|
||||
free(polarParams->nr_polar_E);
|
||||
//Polar Coding vectors
|
||||
free(polarParams->nr_polar_U);
|
||||
free(polarParams->nr_polar_CPrime);
|
||||
free(polarParams->nr_polar_B);
|
||||
free(polarParams->nr_polar_A);
|
||||
free(polarParams->interleaving_pattern);
|
||||
free(polarParams->deinterleaving_pattern);
|
||||
free(polarParams->rate_matching_pattern);
|
||||
free(polarParams->information_bit_pattern);
|
||||
free(polarParams->Q_I_N);
|
||||
free(polarParams->Q_F_N);
|
||||
free(polarParams->Q_PC_N);
|
||||
free(polarParams->channel_interleaver_pattern);
|
||||
free(polarParams);
|
||||
}
|
||||
|
||||
static void nr_polar_delete(void) {
|
||||
pthread_mutex_lock(&PolarListMutex);
|
||||
nr_polar_delete_list(PolarList);
|
||||
PolarList=NULL;
|
||||
pthread_mutex_unlock(&PolarListMutex);
|
||||
}
|
||||
|
||||
t_nrPolar_params * nr_polar_params(int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level,
|
||||
int decoder_flag) {
|
||||
t_nrPolar_params *currentPtr = *polarParams;
|
||||
uint16_t aggregation_prime = (messageType >= 2) ? aggregation_level : nr_polar_aggregation_prime(aggregation_level);
|
||||
|
||||
// The lock is weak, because we never delete in the list, only at exit time
|
||||
// therefore, returning t_nrPolar_params * from the list is safe for future usage
|
||||
pthread_mutex_lock(&PolarListMutex);
|
||||
if(!PolarList)
|
||||
atexit(nr_polar_delete);
|
||||
|
||||
t_nrPolar_params *currentPtr = PolarList;
|
||||
//Parse the list. If the node is already created, return without initialization.
|
||||
while (currentPtr != NULL) {
|
||||
//printf("currentPtr->idx %d, (%d,%d)\n",currentPtr->idx,currentPtr->payloadBits,currentPtr->encoderLength);
|
||||
//LOG_D(PHY,"Looking for index %d\n",(messageType * messageLength * aggregation_prime));
|
||||
if (currentPtr->idx == (messageType * messageLength * aggregation_prime)) return;
|
||||
else currentPtr = currentPtr->nextPtr;
|
||||
if (currentPtr->busy == false && currentPtr->idx == PolarKey ) {
|
||||
currentPtr->busy=true;
|
||||
pthread_mutex_unlock(&PolarListMutex);
|
||||
if (decoder_flag && !currentPtr->tree.root)
|
||||
build_decoder_tree(currentPtr);
|
||||
return currentPtr ;
|
||||
}
|
||||
else
|
||||
currentPtr = currentPtr->nextPtr;
|
||||
}
|
||||
|
||||
// printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams);
|
||||
//Else, initialize and add node to the end of the linked list.
|
||||
t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1);
|
||||
|
||||
if (newPolarInitNode != NULL) {
|
||||
// LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime);
|
||||
newPolarInitNode->idx = (messageType * messageLength * aggregation_prime);
|
||||
newPolarInitNode->nextPtr = NULL;
|
||||
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
|
||||
newPolarInitNode->busy=true;
|
||||
pthread_mutex_unlock(&PolarListMutex);
|
||||
|
||||
if (messageType == 0) { //PBCH
|
||||
newPolarInitNode->n_max = NR_POLAR_PBCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PBCH_I_IL;
|
||||
newPolarInitNode->i_seg = NR_POLAR_PBCH_I_SEG;
|
||||
newPolarInitNode->n_pc = NR_POLAR_PBCH_N_PC;
|
||||
newPolarInitNode->n_pc_wm = NR_POLAR_PBCH_N_PC_WM;
|
||||
newPolarInitNode->i_bil = NR_POLAR_PBCH_I_BIL;
|
||||
newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS;
|
||||
newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS;
|
||||
newPolarInitNode->encoderLength = NR_POLAR_PBCH_E;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS;
|
||||
newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits);//G_P
|
||||
//printf("Initializing polar parameters for PBCH (K %d, E %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength);
|
||||
} else if (messageType == 1) { //DCI
|
||||
newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_DCI_I_IL;
|
||||
newPolarInitNode->i_seg = NR_POLAR_DCI_I_SEG;
|
||||
newPolarInitNode->n_pc = NR_POLAR_DCI_N_PC;
|
||||
newPolarInitNode->n_pc_wm = NR_POLAR_DCI_N_PC_WM;
|
||||
newPolarInitNode->i_bil = NR_POLAR_DCI_I_BIL;
|
||||
newPolarInitNode->crcParityBits = NR_POLAR_DCI_CRC_PARITY_BITS;
|
||||
newPolarInitNode->payloadBits = messageLength;
|
||||
newPolarInitNode->encoderLength = aggregation_level*108;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS;
|
||||
newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
|
||||
//printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level);
|
||||
} else if (messageType == 2) { //UCI PUCCH2
|
||||
AssertFatal(aggregation_level>2,"Aggregation level (%d) for PUCCH 2 encoding is NPRB and should be > 2\n",aggregation_level);
|
||||
AssertFatal(messageLength>11,"Message length %d is too short for polar encoding of UCI\n",messageLength);
|
||||
newPolarInitNode->n_max = NR_POLAR_PUCCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PUCCH_I_IL;
|
||||
newPolarInitNode->encoderLength = aggregation_level * 16;
|
||||
AssertFatal(newPolarInitNode != NULL, "[nr_polar_init] New t_nrPolar_params * could not be created");
|
||||
|
||||
// LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime);
|
||||
newPolarInitNode->idx = PolarKey;
|
||||
newPolarInitNode->nextPtr = NULL;
|
||||
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
|
||||
|
||||
if (messageType == 0) { //PBCH
|
||||
newPolarInitNode->n_max = NR_POLAR_PBCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PBCH_I_IL;
|
||||
newPolarInitNode->i_seg = NR_POLAR_PBCH_I_SEG;
|
||||
newPolarInitNode->n_pc = NR_POLAR_PBCH_N_PC;
|
||||
newPolarInitNode->n_pc_wm = NR_POLAR_PBCH_N_PC_WM;
|
||||
newPolarInitNode->i_bil = NR_POLAR_PBCH_I_BIL;
|
||||
newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS;
|
||||
newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS;
|
||||
newPolarInitNode->encoderLength = NR_POLAR_PBCH_E;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS;
|
||||
newPolarInitNode->crc_generator_matrix = crc24c_generator_matrix(newPolarInitNode->payloadBits);//G_P
|
||||
//printf("Initializing polar parameters for PBCH (K %d, E %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength);
|
||||
} else if (messageType == 1) { //DCI
|
||||
newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_DCI_I_IL;
|
||||
newPolarInitNode->i_seg = NR_POLAR_DCI_I_SEG;
|
||||
newPolarInitNode->n_pc = NR_POLAR_DCI_N_PC;
|
||||
newPolarInitNode->n_pc_wm = NR_POLAR_DCI_N_PC_WM;
|
||||
newPolarInitNode->i_bil = NR_POLAR_DCI_I_BIL;
|
||||
newPolarInitNode->crcParityBits = NR_POLAR_DCI_CRC_PARITY_BITS;
|
||||
newPolarInitNode->payloadBits = messageLength;
|
||||
newPolarInitNode->encoderLength = aggregation_level*108;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS;
|
||||
newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
|
||||
//printf("Initializing polar parameters for DCI (K %d, E %d, L %d)\n",newPolarInitNode->payloadBits,newPolarInitNode->encoderLength,aggregation_level);
|
||||
} else if (messageType == 2) { //UCI PUCCH2
|
||||
AssertFatal(aggregation_level>2,"Aggregation level (%d) for PUCCH 2 encoding is NPRB and should be > 2\n",aggregation_level);
|
||||
AssertFatal(messageLength>11,"Message length %d is too short for polar encoding of UCI\n",messageLength);
|
||||
newPolarInitNode->n_max = NR_POLAR_PUCCH_N_MAX;
|
||||
newPolarInitNode->i_il = NR_POLAR_PUCCH_I_IL;
|
||||
newPolarInitNode->encoderLength = aggregation_level * 16;
|
||||
|
||||
newPolarInitNode->i_seg = 0;
|
||||
newPolarInitNode->i_seg = 0;
|
||||
|
||||
if ((messageLength >= 360 && newPolarInitNode->encoderLength >= 1088)||
|
||||
(messageLength >= 1013)) newPolarInitNode->i_seg = 1;
|
||||
if ((messageLength >= 360 && newPolarInitNode->encoderLength >= 1088)||
|
||||
(messageLength >= 1013)) newPolarInitNode->i_seg = 1;
|
||||
|
||||
newPolarInitNode->crcParityBits = 11;
|
||||
newPolarInitNode->n_pc = 0;
|
||||
newPolarInitNode->n_pc_wm = 0;
|
||||
newPolarInitNode->crcParityBits = 11;
|
||||
newPolarInitNode->n_pc = 0;
|
||||
newPolarInitNode->n_pc_wm = 0;
|
||||
|
||||
if (messageLength < 20) {
|
||||
newPolarInitNode->crcParityBits = 6;
|
||||
newPolarInitNode->n_pc = 3;
|
||||
if ((newPolarInitNode->encoderLength - messageLength - 6 + 3) < 193) newPolarInitNode->n_pc_wm = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
newPolarInitNode->i_bil = NR_POLAR_PUCCH_I_BIL;
|
||||
|
||||
newPolarInitNode->payloadBits = messageLength;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS;
|
||||
//newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
|
||||
//LOG_D(PHY,"New polar node, encoderLength %d, aggregation_level %d\n",newPolarInitNode->encoderLength,aggregation_level);
|
||||
} else {
|
||||
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
|
||||
if (messageLength < 20) {
|
||||
newPolarInitNode->crcParityBits = 6;
|
||||
newPolarInitNode->n_pc = 3;
|
||||
if ((newPolarInitNode->encoderLength - messageLength - 6 + 3) < 193) newPolarInitNode->n_pc_wm = 1;
|
||||
}
|
||||
|
||||
newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode.
|
||||
newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K,
|
||||
newPolarInitNode->encoderLength,
|
||||
newPolarInitNode->n_max);
|
||||
newPolarInitNode->n = log2(newPolarInitNode->N);
|
||||
newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n);
|
||||
//polar_encoder vectors:
|
||||
newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits);
|
||||
newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3));
|
||||
newPolarInitNode->nr_polar_APrime = malloc(sizeof(uint8_t) * newPolarInitNode->K);
|
||||
newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N);
|
||||
newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength);
|
||||
//Polar Coding vectors
|
||||
newPolarInitNode->nr_polar_U = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat
|
||||
newPolarInitNode->nr_polar_CPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat
|
||||
newPolarInitNode->nr_polar_B = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat
|
||||
newPolarInitNode->nr_polar_A = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat
|
||||
newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n);
|
||||
newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
|
||||
nr_polar_interleaving_pattern(newPolarInitNode->K,
|
||||
newPolarInitNode->i_il,
|
||||
newPolarInitNode->interleaving_pattern);
|
||||
newPolarInitNode->deinterleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
|
||||
|
||||
for (int i=0; i<newPolarInitNode->K; i++)
|
||||
newPolarInitNode->deinterleaving_pattern[newPolarInitNode->interleaving_pattern[i]] = i;
|
||||
|
||||
newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
|
||||
uint16_t *J = malloc(sizeof(uint16_t) * newPolarInitNode->N);
|
||||
nr_polar_rate_matching_pattern(newPolarInitNode->rate_matching_pattern,
|
||||
J,
|
||||
nr_polar_subblock_interleaver_pattern,
|
||||
newPolarInitNode->K,
|
||||
newPolarInitNode->N,
|
||||
newPolarInitNode->encoderLength);
|
||||
newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N);
|
||||
newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc));
|
||||
newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value.
|
||||
newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc));
|
||||
newPolarInitNode->i_bil = NR_POLAR_PUCCH_I_BIL;
|
||||
|
||||
for (int i = 0; i <= newPolarInitNode->N; i++)
|
||||
newPolarInitNode->Q_F_N[i] = -1; // Empty array.
|
||||
|
||||
nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern,
|
||||
newPolarInitNode->Q_I_N,
|
||||
newPolarInitNode->Q_F_N,
|
||||
J,
|
||||
newPolarInitNode->Q_0_Nminus1,
|
||||
newPolarInitNode->K,
|
||||
newPolarInitNode->N,
|
||||
newPolarInitNode->encoderLength,
|
||||
newPolarInitNode->n_pc);
|
||||
// sort the Q_I_N array in ascending order (first K positions)
|
||||
qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp);
|
||||
newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
|
||||
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
|
||||
newPolarInitNode->i_bil,
|
||||
newPolarInitNode->encoderLength);
|
||||
free(J);
|
||||
if (decoder_flag == 1) build_decoder_tree(newPolarInitNode);
|
||||
build_polar_tables(newPolarInitNode);
|
||||
init_polar_deinterleaver_table(newPolarInitNode);
|
||||
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
|
||||
newPolarInitNode->payloadBits = messageLength;
|
||||
newPolarInitNode->crcCorrectionBits = NR_POLAR_PUCCH_CRC_ERROR_CORRECTION_BITS;
|
||||
//newPolarInitNode->crc_generator_matrix=crc24c_generator_matrix(newPolarInitNode->payloadBits+newPolarInitNode->crcParityBits);//G_P
|
||||
//LOG_D(PHY,"New polar node, encoderLength %d, aggregation_level %d\n",newPolarInitNode->encoderLength,aggregation_level);
|
||||
} else {
|
||||
AssertFatal(1 == 0, "[nr_polar_init] New t_nrPolar_params * could not be created");
|
||||
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
|
||||
}
|
||||
|
||||
//Fixme: the list is not thread safe
|
||||
//The defect is not critical: we always append (never delete items) and adding two times the same is fine
|
||||
newPolarInitNode->nextPtr=*polarParams;
|
||||
*polarParams=newPolarInitNode;
|
||||
return;
|
||||
newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode.
|
||||
newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K,
|
||||
newPolarInitNode->encoderLength,
|
||||
newPolarInitNode->n_max);
|
||||
newPolarInitNode->n = log2(newPolarInitNode->N);
|
||||
newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n);
|
||||
//polar_encoder vectors:
|
||||
newPolarInitNode->nr_polar_crc = malloc(sizeof(uint8_t) * newPolarInitNode->crcParityBits);
|
||||
newPolarInitNode->nr_polar_aPrime = malloc(sizeof(uint8_t) * ((ceil((newPolarInitNode->payloadBits)/32.0)*4)+3));
|
||||
newPolarInitNode->nr_polar_APrime = malloc(sizeof(uint8_t) * newPolarInitNode->K);
|
||||
newPolarInitNode->nr_polar_D = malloc(sizeof(uint8_t) * newPolarInitNode->N);
|
||||
newPolarInitNode->nr_polar_E = malloc(sizeof(uint8_t) * newPolarInitNode->encoderLength);
|
||||
//Polar Coding vectors
|
||||
newPolarInitNode->nr_polar_U = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat
|
||||
newPolarInitNode->nr_polar_CPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat
|
||||
newPolarInitNode->nr_polar_B = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat
|
||||
newPolarInitNode->nr_polar_A = malloc(sizeof(uint8_t) * newPolarInitNode->payloadBits); //Decoder: nr_polar_aHat
|
||||
newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n);
|
||||
newPolarInitNode->interleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
|
||||
nr_polar_interleaving_pattern(newPolarInitNode->K,
|
||||
newPolarInitNode->i_il,
|
||||
newPolarInitNode->interleaving_pattern);
|
||||
newPolarInitNode->deinterleaving_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->K);
|
||||
|
||||
for (int i=0; i<newPolarInitNode->K; i++)
|
||||
newPolarInitNode->deinterleaving_pattern[newPolarInitNode->interleaving_pattern[i]] = i;
|
||||
|
||||
newPolarInitNode->rate_matching_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
|
||||
uint16_t J[newPolarInitNode->N];
|
||||
nr_polar_rate_matching_pattern(newPolarInitNode->rate_matching_pattern,
|
||||
J,
|
||||
nr_polar_subblock_interleaver_pattern,
|
||||
newPolarInitNode->K,
|
||||
newPolarInitNode->N,
|
||||
newPolarInitNode->encoderLength);
|
||||
newPolarInitNode->information_bit_pattern = malloc(sizeof(uint8_t) * newPolarInitNode->N);
|
||||
newPolarInitNode->Q_I_N = malloc(sizeof(int16_t) * (newPolarInitNode->K + newPolarInitNode->n_pc));
|
||||
newPolarInitNode->Q_F_N = malloc( sizeof(int16_t) * (newPolarInitNode->N + 1)); // Last element shows the final array index assigned a value.
|
||||
newPolarInitNode->Q_PC_N = malloc( sizeof(int16_t) * (newPolarInitNode->n_pc));
|
||||
|
||||
for (int i = 0; i <= newPolarInitNode->N; i++)
|
||||
newPolarInitNode->Q_F_N[i] = -1; // Empty array.
|
||||
|
||||
nr_polar_info_bit_pattern(newPolarInitNode->information_bit_pattern,
|
||||
newPolarInitNode->Q_I_N,
|
||||
newPolarInitNode->Q_F_N,
|
||||
J,
|
||||
newPolarInitNode->Q_0_Nminus1,
|
||||
newPolarInitNode->K,
|
||||
newPolarInitNode->N,
|
||||
newPolarInitNode->encoderLength,
|
||||
newPolarInitNode->n_pc);
|
||||
// sort the Q_I_N array in ascending order (first K positions)
|
||||
qsort((void *)newPolarInitNode->Q_I_N,newPolarInitNode->K,sizeof(int16_t),intcmp);
|
||||
newPolarInitNode->channel_interleaver_pattern = malloc(sizeof(uint16_t) * newPolarInitNode->encoderLength);
|
||||
nr_polar_channel_interleaver_pattern(newPolarInitNode->channel_interleaver_pattern,
|
||||
newPolarInitNode->i_bil,
|
||||
newPolarInitNode->encoderLength);
|
||||
if (decoder_flag == 1)
|
||||
build_decoder_tree(newPolarInitNode);
|
||||
build_polar_tables(newPolarInitNode);
|
||||
init_polar_deinterleaver_table(newPolarInitNode);
|
||||
//printf("decoder tree nodes %d\n",newPolarInitNode->tree.num_nodes);
|
||||
|
||||
newPolarInitNode->nextPtr=PolarList;
|
||||
PolarList=newPolarInitNode;
|
||||
return newPolarInitNode;
|
||||
}
|
||||
|
||||
void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
|
||||
void nr_polar_print_polarParams() {
|
||||
uint8_t i = 0;
|
||||
|
||||
if (polarParams == NULL) {
|
||||
if (PolarList == NULL) {
|
||||
printf("polarParams is empty.\n");
|
||||
} else {
|
||||
t_nrPolar_params * polarParams=PolarList;
|
||||
while (polarParams != NULL) {
|
||||
printf("polarParams[%d] = %d\n", i, polarParams->idx);
|
||||
printf("polarParams[%d] = %d, %d, %d\n", i,
|
||||
polarParams->idx>>24, (polarParams->idx>>8)&0xFFFF, polarParams->idx&0xFF);
|
||||
polarParams = polarParams->nextPtr;
|
||||
i++;
|
||||
}
|
||||
@@ -213,31 +271,6 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
|
||||
return;
|
||||
}
|
||||
|
||||
t_nrPolar_params *nr_polar_params (int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level,
|
||||
int decoding_flag,
|
||||
t_nrPolar_params **polarList_ext) {
|
||||
static t_nrPolar_params *polarList = NULL;
|
||||
nr_polar_init(polarList_ext != NULL ? polarList_ext : &polarList,
|
||||
messageType,messageLength,aggregation_level,decoding_flag);
|
||||
t_nrPolar_params *polarParams=polarList_ext != NULL ? *polarList_ext : polarList;
|
||||
const int tag=messageType * messageLength * (messageType>=2 ? aggregation_level : nr_polar_aggregation_prime(aggregation_level));
|
||||
|
||||
|
||||
|
||||
while (polarParams != NULL) {
|
||||
// LOG_D(PHY,"nr_polar_params : tag %d (from nr_polar_init %d)\n",tag,polarParams->idx);
|
||||
if (polarParams->idx == tag)
|
||||
return polarParams;
|
||||
|
||||
polarParams = polarParams->nextPtr;
|
||||
}
|
||||
|
||||
AssertFatal(false,"Polar Init tables internal failure, no polarParams found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level) {
|
||||
if (aggregation_level == 0) return 0;
|
||||
else if (aggregation_level == 1) return NR_POLAR_AGGREGATION_LEVEL_1_PRIME;
|
||||
|
||||
+108
-68
@@ -242,37 +242,9 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
|
||||
common_vars->debugBuff = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t)*100);
|
||||
common_vars->debugBuff_sample_offset = 0;
|
||||
|
||||
|
||||
// Channel estimates for SRS
|
||||
/*
|
||||
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
|
||||
srs_vars[UE_id].srs_ch_estimates = (int32_t **)malloc16( 64*sizeof(int32_t *) );
|
||||
srs_vars[UE_id].srs_ch_estimates_time = (int32_t **)malloc16( 64*sizeof(int32_t *) );
|
||||
|
||||
for (i=0; i<64; i++) {
|
||||
srs_vars[UE_id].srs_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size );
|
||||
srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
|
||||
}
|
||||
} //UE_id
|
||||
*/
|
||||
/*generate_ul_ref_sigs_rx();
|
||||
|
||||
init_ulsch_power_LUT();*/
|
||||
|
||||
/*
|
||||
// SRS
|
||||
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
|
||||
srs_vars[UE_id].srs = (int32_t *)malloc16_clear(2*fp->ofdm_symbol_size*sizeof(int32_t));
|
||||
}
|
||||
*/
|
||||
// PRACH
|
||||
prach_vars->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
|
||||
prach_vars->rxsigF = (int16_t **)malloc16_clear(Prx*sizeof(int16_t*));
|
||||
/*
|
||||
for (i=0;i<Prx;i++){
|
||||
prach_vars->rxsigF[i] = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
|
||||
}
|
||||
*/
|
||||
prach_vars->prach_ifft = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t));
|
||||
|
||||
init_prach_list(gNB);
|
||||
@@ -328,51 +300,102 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
|
||||
void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
|
||||
{
|
||||
NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms;
|
||||
NR_gNB_COMMON *const common_vars = &gNB->common_vars;
|
||||
NR_gNB_PUSCH **const pusch_vars = gNB->pusch_vars;
|
||||
/*LTE_eNB_SRS *const srs_vars = gNB->srs_vars;
|
||||
LTE_eNB_PRACH *const prach_vars = &gNB->prach_vars;*/
|
||||
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
|
||||
int Ptx=gNB->gNB_config.carrier_config.num_tx_ant.value;
|
||||
const int Ptx = gNB->gNB_config.carrier_config.num_tx_ant.value;
|
||||
const int Prx = gNB->gNB_config.carrier_config.num_rx_ant.value;
|
||||
const int max_ul_mimo_layers = 4; // taken from phy_init_nr_gNB()
|
||||
const int n_buf = Prx * max_ul_mimo_layers;
|
||||
|
||||
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
|
||||
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
|
||||
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
|
||||
free_and_zero(pdcch_dmrs[slot][symb]);
|
||||
free_and_zero(pdcch_dmrs[slot]);
|
||||
}
|
||||
free_and_zero(pdcch_dmrs);
|
||||
|
||||
uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs;
|
||||
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
|
||||
for (int symb = 0; symb < fp->symbols_per_slot; symb++) {
|
||||
for (int q = 0; q < NR_MAX_NB_CODEWORDS; q++)
|
||||
free_and_zero(pdsch_dmrs[slot][symb][q]);
|
||||
free_and_zero(pdsch_dmrs[slot][symb]);
|
||||
}
|
||||
free_and_zero(pdsch_dmrs[slot]);
|
||||
}
|
||||
free_and_zero(gNB->nr_gold_pdsch_dmrs);
|
||||
|
||||
uint32_t ****pusch_dmrs = gNB->nr_gold_pusch_dmrs;
|
||||
for(int nscid = 0; nscid < 2; nscid++) {
|
||||
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
|
||||
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
|
||||
free_and_zero(pusch_dmrs[nscid][slot][symb]);
|
||||
free_and_zero(pusch_dmrs[nscid][slot]);
|
||||
}
|
||||
free_and_zero(pusch_dmrs[nscid]);
|
||||
}
|
||||
free_and_zero(pusch_dmrs);
|
||||
|
||||
uint32_t ***csi_rs = gNB->nr_gold_csi_rs;
|
||||
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
|
||||
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
|
||||
free_and_zero(csi_rs[slot][symb]);
|
||||
free_and_zero(csi_rs[slot]);
|
||||
}
|
||||
free_and_zero(csi_rs);
|
||||
|
||||
for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) {
|
||||
for (int i = 0; i < Prx; i++){
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal[i]);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel[i]);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq[i]);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time[i]);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i]);
|
||||
}
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal);
|
||||
free_and_zero(gNB->nr_srs_info[id]->noise_power);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time);
|
||||
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted);
|
||||
free_and_zero(gNB->nr_srs_info[id]);
|
||||
}
|
||||
|
||||
free_ul_reference_signal_sequences();
|
||||
free_gnb_lowpapr_sequences();
|
||||
|
||||
reset_nr_transport(gNB);
|
||||
|
||||
NR_gNB_COMMON * common_vars = &gNB->common_vars;
|
||||
for (int i = 0; i < Ptx; i++) {
|
||||
free_and_zero(common_vars->txdataF[i]);
|
||||
/* rxdataF[i] is not allocated -> don't free */
|
||||
free_and_zero(common_vars->beam_id[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Prx; ++i) {
|
||||
free_and_zero(common_vars->rxdataF[i]);
|
||||
free_and_zero(common_vars->rxdata[i]);
|
||||
}
|
||||
|
||||
free_and_zero(common_vars->txdataF);
|
||||
free_and_zero(common_vars->rxdata);
|
||||
free_and_zero(common_vars->rxdataF);
|
||||
// PDCCH DMRS sequences
|
||||
free_and_zero(pdcch_dmrs);
|
||||
/*
|
||||
// Channel estimates for SRS
|
||||
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
|
||||
for (i=0; i<64; i++) {
|
||||
free_and_zero(srs_vars[UE_id].srs_ch_estimates[i]);
|
||||
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time[i]);
|
||||
}
|
||||
free_and_zero(common_vars->beam_id);
|
||||
|
||||
free_and_zero(srs_vars[UE_id].srs_ch_estimates);
|
||||
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time);
|
||||
} //UE_id
|
||||
|
||||
//free_ul_ref_sigs();
|
||||
|
||||
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) free_and_zero(srs_vars[UE_id].srs);
|
||||
free_and_zero(common_vars->debugBuff);
|
||||
|
||||
NR_gNB_PRACH* prach_vars = &gNB->prach_vars;
|
||||
free_and_zero(prach_vars->prachF);
|
||||
free_and_zero(prach_vars->rxsigF);
|
||||
free_and_zero(prach_vars->prach_ifft);
|
||||
|
||||
for (i = 0; i < 64; i++) free_and_zero(prach_vars->prach_ifft[0][i]);
|
||||
|
||||
free_and_zero(prach_vars->prach_ifft[0]);
|
||||
free_and_zero(prach_vars->rxsigF[0]);
|
||||
*/
|
||||
NR_gNB_PUSCH** pusch_vars = gNB->pusch_vars;
|
||||
for (int ULSCH_id=0; ULSCH_id<gNB->number_of_nr_ulsch_max; ULSCH_id++) {
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
for (int i = 0; i < Prx; i++) {
|
||||
free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]);
|
||||
}
|
||||
for (int i = 0; i < 4*fp->nb_antennas_rx; i++) {
|
||||
for (int i = 0; i < n_buf; i++) {
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates[i]);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i]);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time[i]);
|
||||
@@ -392,8 +415,8 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_valid_re_per_slot);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp);
|
||||
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag0);
|
||||
@@ -405,14 +428,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
|
||||
free_and_zero(pusch_vars[ULSCH_id]->llr);
|
||||
free_and_zero(pusch_vars[ULSCH_id]);
|
||||
} //ULSCH_id
|
||||
/*
|
||||
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) gNB->UE_stats_ptr[UE_id] = NULL;
|
||||
*/
|
||||
|
||||
|
||||
free_gnb_lowpapr_sequences();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Adding nr_schedule_handler
|
||||
@@ -553,6 +568,16 @@ void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) {
|
||||
}
|
||||
}
|
||||
|
||||
void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg)
|
||||
{
|
||||
const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
|
||||
const nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
|
||||
const uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value;
|
||||
for (int i=0; i<gNB->number_of_nr_dlsch_max; i++)
|
||||
for (int j=0; j<2; j++)
|
||||
free_gNB_dlsch(&msg->dlsch[i][j], grid_size);
|
||||
}
|
||||
|
||||
void init_nr_transport(PHY_VARS_gNB *gNB) {
|
||||
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
|
||||
LOG_I(PHY, "Initialise nr transport\n");
|
||||
@@ -577,7 +602,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
|
||||
|
||||
for (int j=0; j<2; j++) {
|
||||
// ULSCH for data
|
||||
gNB->ulsch[i][j] = new_gNB_ulsch(MAX_LDPC_ITERATIONS, fp->N_RB_UL, 0);
|
||||
gNB->ulsch[i][j] = new_gNB_ulsch(MAX_LDPC_ITERATIONS, fp->N_RB_UL);
|
||||
|
||||
if (!gNB->ulsch[i][j]) {
|
||||
LOG_E(PHY,"Can't get gNB ulsch structures\n");
|
||||
@@ -593,3 +618,18 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
|
||||
|
||||
//fp->pucch_config_common.deltaPUCCH_Shift = 1;
|
||||
}
|
||||
|
||||
void reset_nr_transport(PHY_VARS_gNB *gNB)
|
||||
{
|
||||
const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_NR_PUCCH_MAX; i++)
|
||||
free_gNB_pucch(gNB->pucch[i]);
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_NR_SRS_MAX; i++)
|
||||
free_gNB_srs(gNB->srs[i]);
|
||||
|
||||
for (int i=0; i<gNB->number_of_nr_ulsch_max; i++)
|
||||
for (int j=0; j<2; j++)
|
||||
free_gNB_ulsch(&gNB->ulsch[i][j], fp->N_RB_UL);
|
||||
}
|
||||
|
||||
@@ -174,17 +174,13 @@ void nr_phy_free_RU(RU_t *ru)
|
||||
|
||||
LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx);
|
||||
|
||||
free_and_zero(ru->nr_frame_parms);
|
||||
free_and_zero(ru->frame_parms);
|
||||
|
||||
if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals
|
||||
int32_t *ptr;
|
||||
for (i = 0; i < ru->nb_tx; i++) {
|
||||
ptr=&ru->common.txdata[i][-ru->sf_extension];
|
||||
free_and_zero(ptr);
|
||||
}
|
||||
for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdata[i]);
|
||||
for (i = 0; i < ru->nb_tx; i++)
|
||||
free_and_zero(ru->common.txdata[i]);
|
||||
free_and_zero(ru->common.txdata);
|
||||
|
||||
for (i = 0; i < ru->nb_rx; i++)
|
||||
free_and_zero(ru->common.rxdata[i]);
|
||||
free_and_zero(ru->common.rxdata);
|
||||
} // else: IF5 or local RF -> nothing to free()
|
||||
|
||||
@@ -193,7 +189,7 @@ void nr_phy_free_RU(RU_t *ru)
|
||||
free_and_zero(ru->common.rxdata_7_5kHz);
|
||||
|
||||
// free beamforming input buffers (TX)
|
||||
for (i = 0; i < 15; i++) free_and_zero(ru->common.txdataF[i]);
|
||||
for (i = 0; i < ru->nb_tx; i++) free_and_zero(ru->common.txdataF[i]);
|
||||
free_and_zero(ru->common.txdataF);
|
||||
|
||||
// free IFFT input buffers (TX)
|
||||
@@ -205,15 +201,21 @@ void nr_phy_free_RU(RU_t *ru)
|
||||
free_and_zero(ru->common.rxdataF);
|
||||
|
||||
for (j=0;j<NUMBER_OF_NR_RU_PRACH_OCCASIONS_MAX;j++) {
|
||||
for (i = 0; i < ru->nb_rx; i++) {
|
||||
for (i = 0; i < ru->nb_rx; i++)
|
||||
free_and_zero(ru->prach_rxsigF[j][i]);
|
||||
}
|
||||
free_and_zero(ru->prach_rxsigF[j]);
|
||||
}
|
||||
for (i = 0; i < ru->num_gNB; i++) {
|
||||
for (p = 0; p < 15; p++) {
|
||||
for (j=0; j<ru->nb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]);
|
||||
free_and_zero(ru->beam_weights[i][p]);
|
||||
|
||||
if (ru->do_precoding == 1) {
|
||||
for (i = 0; i < ru->num_gNB; i++) {
|
||||
for (p = 0; p < ru->nb_log_antennas; p++) {
|
||||
for (j=0; j<ru->nb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]);
|
||||
free_and_zero(ru->beam_weights[i][p]);
|
||||
}
|
||||
}
|
||||
for(i=0; i< ru->nb_tx; ++i)
|
||||
free_and_zero(ru->common.beam_id[i]);
|
||||
free_and_zero(ru->common.beam_id);
|
||||
}
|
||||
}
|
||||
free_and_zero(ru->common.sync_corr);
|
||||
|
||||
+372
-145
@@ -111,6 +111,49 @@ void phy_init_nr_ue__PDSCH(NR_UE_PDSCH *const pdsch,
|
||||
}
|
||||
}
|
||||
|
||||
void phy_term_nr_ue__PDSCH(NR_UE_PDSCH* pdsch, const NR_DL_FRAME_PARMS *const fp)
|
||||
{
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
for (int j = 0; j < NR_MAX_NB_LAYERS; j++) {
|
||||
const int idx = j * fp->nb_antennas_rx + i;
|
||||
for (int k = 0; k < NR_MAX_NB_LAYERS; k++)
|
||||
free_and_zero(pdsch->rho[i][j*NR_MAX_NB_LAYERS+k]);
|
||||
free_and_zero(pdsch->rxdataF_comp0[idx]);
|
||||
free_and_zero(pdsch->dl_ch_estimates[idx]);
|
||||
free_and_zero(pdsch->dl_ch_estimates_ext[idx]);
|
||||
free_and_zero(pdsch->dl_bf_ch_estimates[idx]);
|
||||
free_and_zero(pdsch->dl_bf_ch_estimates_ext[idx]);
|
||||
free_and_zero(pdsch->dl_ch_mag0[idx]);
|
||||
free_and_zero(pdsch->dl_ch_magb0[idx]);
|
||||
free_and_zero(pdsch->dl_ch_magr0[idx]);
|
||||
}
|
||||
free_and_zero(pdsch->rxdataF_ext[i]);
|
||||
free_and_zero(pdsch->rxdataF_uespec_pilots[i]);
|
||||
free_and_zero(pdsch->ptrs_phase_per_slot[i]);
|
||||
free_and_zero(pdsch->ptrs_re_per_slot[i]);
|
||||
free_and_zero(pdsch->dl_ch_ptrs_estimates_ext[i]);
|
||||
free_and_zero(pdsch->rho[i]);
|
||||
}
|
||||
free_and_zero(pdsch->pmi_ext);
|
||||
free_and_zero(pdsch->llr[0]);
|
||||
free_and_zero(pdsch->layer_llr[0]);
|
||||
free_and_zero(pdsch->llr128);
|
||||
free_and_zero(pdsch->rxdataF_ext);
|
||||
free_and_zero(pdsch->rxdataF_uespec_pilots);
|
||||
free_and_zero(pdsch->rxdataF_comp0);
|
||||
free_and_zero(pdsch->rho);
|
||||
free_and_zero(pdsch->dl_ch_estimates);
|
||||
free_and_zero(pdsch->dl_ch_estimates_ext);
|
||||
free_and_zero(pdsch->dl_bf_ch_estimates);
|
||||
free_and_zero(pdsch->dl_bf_ch_estimates_ext);
|
||||
free_and_zero(pdsch->dl_ch_mag0);
|
||||
free_and_zero(pdsch->dl_ch_magb0);
|
||||
free_and_zero(pdsch->dl_ch_magr0);
|
||||
free_and_zero(pdsch->ptrs_phase_per_slot);
|
||||
free_and_zero(pdsch->ptrs_re_per_slot);
|
||||
free_and_zero(pdsch->dl_ch_ptrs_estimates_ext);
|
||||
}
|
||||
|
||||
void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch,
|
||||
const NR_DL_FRAME_PARMS *const fp) {
|
||||
AssertFatal( pusch, "pusch==0" );
|
||||
@@ -120,9 +163,14 @@ void phy_init_nr_ue_PUSCH(NR_UE_PUSCH *const pusch,
|
||||
}
|
||||
}
|
||||
|
||||
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
int nb_connected_gNB,
|
||||
uint8_t abstraction_flag) {
|
||||
void phy_term_nr_ue_PUSCH(NR_UE_PUSCH *pusch)
|
||||
{
|
||||
for (int i = 0; i < NR_MAX_NB_LAYERS; i++)
|
||||
free_and_zero(pusch->txdataF_layers[i]);
|
||||
}
|
||||
|
||||
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
|
||||
{
|
||||
// create shortcuts
|
||||
NR_DL_FRAME_PARMS *const fp = &ue->frame_parms;
|
||||
NR_UE_COMMON *const common_vars = &ue->common_vars;
|
||||
@@ -134,10 +182,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
int gNB_id;
|
||||
int th_id;
|
||||
uint32_t ****pusch_dmrs;
|
||||
uint16_t N_n_scid[2] = {0,1}; // [HOTFIX] This is a temporary implementation of scramblingID0 and scramblingID1 which are given by DMRS-UplinkConfig
|
||||
int n_scid;
|
||||
abstraction_flag = 0;
|
||||
LOG_I(PHY, "Initializing UE vars (abstraction %u) for gNB TXant %u, UE RXant %u\n", abstraction_flag, fp->nb_antennas_tx, fp->nb_antennas_rx);
|
||||
LOG_I(PHY, "Initializing UE vars for gNB TXant %u, UE RXant %u\n", fp->nb_antennas_tx, fp->nb_antennas_rx);
|
||||
phy_init_nr_top(ue);
|
||||
// many memory allocation sizes are hard coded
|
||||
AssertFatal( fp->nb_antennas_rx <= 4, "hard coded allocation for ue_common_vars->dl_ch_estimates[gNB_id]" );
|
||||
@@ -191,7 +236,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
///////////
|
||||
ue->nr_gold_pusch_dmrs = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***));
|
||||
pusch_dmrs = ue->nr_gold_pusch_dmrs;
|
||||
n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization
|
||||
|
||||
for (slot=0; slot<fp->slots_per_frame; slot++) {
|
||||
pusch_dmrs[slot] = (uint32_t ***)malloc16(fp->symbols_per_slot*sizeof(uint32_t **));
|
||||
@@ -208,7 +252,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
}
|
||||
}
|
||||
|
||||
nr_init_pusch_dmrs(ue, N_n_scid, n_scid);
|
||||
///////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -230,29 +273,27 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
for (i=0; i<10; i++)
|
||||
ue->tx_power_dBm[i]=-127;
|
||||
|
||||
if (abstraction_flag == 0) {
|
||||
// init TX buffers
|
||||
common_vars->txdata = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
|
||||
common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
|
||||
// init TX buffers
|
||||
common_vars->txdata = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
|
||||
common_vars->txdataF = (int32_t **)malloc16( fp->nb_antennas_tx*sizeof(int32_t *) );
|
||||
|
||||
for (i=0; i<fp->nb_antennas_tx; i++) {
|
||||
common_vars->txdata[i] = (int32_t *)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) );
|
||||
common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->samples_per_slot_wCP*sizeof(int32_t) );
|
||||
}
|
||||
for (i=0; i<fp->nb_antennas_tx; i++) {
|
||||
common_vars->txdata[i] = (int32_t *)malloc16_clear( fp->samples_per_subframe*10*sizeof(int32_t) );
|
||||
common_vars->txdataF[i] = (int32_t *)malloc16_clear( fp->samples_per_slot_wCP*sizeof(int32_t) );
|
||||
}
|
||||
|
||||
// init RX buffers
|
||||
common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
// init RX buffers
|
||||
common_vars->rxdata = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
}
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++) {
|
||||
common_vars->rxdata[i] = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) );
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
}
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++) {
|
||||
common_vars->rxdata[i] = (int32_t *) malloc16_clear( (2*(fp->samples_per_frame)+2048)*sizeof(int32_t) );
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->samples_per_slot_wCP) );
|
||||
}
|
||||
common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(fp->samples_per_slot_wCP) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,9 +312,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
}
|
||||
}
|
||||
|
||||
ue->scramblingID_pdcch = fp->Nid_cell;
|
||||
nr_gold_pdcch(ue,fp->Nid_cell);
|
||||
|
||||
//PDSCH DMRS init (eNB offset = 0)
|
||||
ue->nr_gold_pdsch[0] = (uint32_t ****)malloc16(fp->slots_per_frame*sizeof(uint32_t ***));
|
||||
uint32_t ****pdsch_dmrs = ue->nr_gold_pdsch[0];
|
||||
@@ -293,12 +331,6 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
}
|
||||
}
|
||||
|
||||
// initializing the scrambling IDs for PDSCH DMRS
|
||||
for (int i=0; i<2; i++)
|
||||
ue->scramblingID[i]=fp->Nid_cell;
|
||||
|
||||
nr_gold_pdsch(ue,ue->scramblingID);
|
||||
|
||||
// DLSCH
|
||||
for (gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
@@ -330,129 +362,119 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
ue->nr_srs_info->srs_estimated_channel_time_shifted[i] = (int32_t *) malloc16_clear(fp->ofdm_symbol_size*MAX_NUM_NR_SRS_SYMBOLS*sizeof(int32_t));
|
||||
}
|
||||
|
||||
if (abstraction_flag == 0) {
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
phy_init_nr_ue__PDSCH( ue->pdsch_vars[th_id][gNB_id], fp );
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
phy_init_nr_ue__PDSCH( ue->pdsch_vars[th_id][gNB_id], fp );
|
||||
}
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr_shifts = (uint8_t *)malloc16_clear(7*2*fp->N_RB_DL*12);
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr_shifts_p = ue->pdsch_vars[0][gNB_id]->llr_shifts;
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream = (int16_t **)malloc16_clear( sizeof(int16_t *) );
|
||||
}
|
||||
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
}
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++)
|
||||
for (j=0; j<4; j++) {
|
||||
const int idx = (j*fp->nb_antennas_rx)+i;
|
||||
const size_t num = 7*2*fp->N_RB_DL*12+4;
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num );
|
||||
}
|
||||
}
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr_shifts = (uint8_t *)malloc16_clear(7*2*fp->N_RB_DL*12);
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr_shifts_p = ue->pdsch_vars[0][gNB_id]->llr_shifts;
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear( (8*(3*8*8448))*sizeof(int16_t) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream = (int16_t **)malloc16_clear( sizeof(int16_t *) );
|
||||
}
|
||||
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
}
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++)
|
||||
for (j=0; j<4; j++) {
|
||||
const int idx = (j*fp->nb_antennas_rx)+i;
|
||||
const size_t num = 7*2*fp->N_RB_DL*12+4;
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t) * num );
|
||||
}
|
||||
//const size_t num = 7*2*fp->N_RB_DL*12+4;
|
||||
for (k=0; k<8; k++) { //harq_pid
|
||||
for (l=0; l<8; l++) { //round
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
}
|
||||
|
||||
//const size_t num = 7*2*fp->N_RB_DL*12+4;
|
||||
for (k=0; k<8; k++) { //harq_pid
|
||||
for (l=0; l<8; l++) { //round
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l] = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
}
|
||||
for (int i=0; i<fp->nb_antennas_rx; i++)
|
||||
for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++)
|
||||
const int idx = (j*fp->nb_antennas_rx)+i;
|
||||
|
||||
for (int i=0; i<fp->nb_antennas_rx; i++)
|
||||
for (int j=0; j<4; j++) { //frame_parms->nb_antennas_tx; j++)
|
||||
const int idx = (j*fp->nb_antennas_rx)+i;
|
||||
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
}
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx] = (int32_t *)malloc16_clear(7*2*sizeof(int32_t)*(fp->N_RB_DL*12));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdcch_vars[th_id][gNB_id]->llr = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->llr16 = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->wbar = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->e_rx = (int16_t *)malloc16_clear( 4*2*100*12 );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
// Channel estimates
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++) {
|
||||
ue->pdcch_vars[th_id][gNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4));
|
||||
|
||||
for (j=0; j<4; j++) {
|
||||
int idx = (j*fp->nb_antennas_rx)+i;
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
|
||||
// size_t num = 7*2*fp->N_RB_DL*12;
|
||||
size_t num = 4*273*12; // 4 symbols, 100 PRBs, 12 REs per PRB
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PBCH
|
||||
pbch_vars[gNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); //
|
||||
prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
|
||||
prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
|
||||
// 100 PRBs * 12 REs/PRB * 4 PDCCH SYMBOLS * 2 LLRs/RE
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdcch_vars[th_id][gNB_id]->llr = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->llr16 = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->wbar = (int16_t *)malloc16_clear( 2*4*100*12*sizeof(uint16_t) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->e_rx = (int16_t *)malloc16_clear( 4*2*100*12 );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rho = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
// Channel estimates
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear(4*fp->nb_antennas_rx*sizeof(int32_t *));
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++) {
|
||||
pbch_vars[gNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
|
||||
ue->pdcch_vars[th_id][gNB_id]->rho[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*(100*12*4));
|
||||
|
||||
for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) {
|
||||
for (j=0; j<4; j++) {
|
||||
int idx = (j*fp->nb_antennas_rx)+i;
|
||||
pbch_vars[gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->symbols_per_slot*(fp->ofdm_symbol_size+LTE_CE_FILTER_LENGTH) );
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
|
||||
// size_t num = 7*2*fp->N_RB_DL*12;
|
||||
size_t num = 4*273*12; // 4 symbols, 100 PRBs, 12 REs per PRB
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear(sizeof(int32_t) * num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PBCH
|
||||
pbch_vars[gNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
|
||||
pbch_vars[gNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); //
|
||||
prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
|
||||
prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
|
||||
|
||||
for (i=0; i<fp->nb_antennas_rx; i++) {
|
||||
pbch_vars[gNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
|
||||
|
||||
for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) {
|
||||
int idx = (j*fp->nb_antennas_rx)+i;
|
||||
pbch_vars[gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
|
||||
pbch_vars[gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
|
||||
}
|
||||
}
|
||||
|
||||
pbch_vars[gNB_id]->decoded_output = (uint8_t *)malloc16_clear(64);
|
||||
}
|
||||
|
||||
// initialization for the last instance of pdsch_vars (used for MU-MIMO)
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
ue->pdsch_vars[th_id][gNB_id] = (NR_UE_PDSCH *)malloc16_clear(sizeof(NR_UE_PDSCH));
|
||||
}
|
||||
|
||||
if (abstraction_flag == 0) {
|
||||
for (th_id=0; th_id<RX_NB_TH_MAX; th_id++) {
|
||||
//phy_init_lte_ue__PDSCH( ue->pdsch_vars[th_id][gNB_id], fp );
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr[1] = (int16_t *)malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
|
||||
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = (int16_t *)malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
|
||||
}
|
||||
} else { //abstraction == 1
|
||||
ue->sinr_dB = (double *) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
|
||||
ue->pdsch_vars[th_id][gNB_id] = malloc16_clear(sizeof(NR_UE_PDSCH));
|
||||
ue->pdsch_vars[th_id][gNB_id]->llr[1] = malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
|
||||
ue->pdsch_vars[th_id][gNB_id]->layer_llr[1] = malloc16_clear((8*(3*8*8448))*sizeof(int16_t));
|
||||
}
|
||||
|
||||
ue->sinr_CQI_dB = (double *) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
|
||||
@@ -473,25 +495,224 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_nr_ue_transport(PHY_VARS_NR_UE *ue,
|
||||
int abstraction_flag) {
|
||||
void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
|
||||
{
|
||||
const NR_DL_FRAME_PARMS* fp = &ue->frame_parms;
|
||||
phy_term_nr_top();
|
||||
|
||||
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
|
||||
for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
|
||||
phy_term_nr_ue_PUSCH(ue->pusch_vars[th_id][gNB_id]);
|
||||
free_and_zero(ue->pusch_vars[th_id][gNB_id]);
|
||||
free_and_zero(ue->pucch_vars[th_id][gNB_id]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
|
||||
for (int symb = 0; symb < fp->symbols_per_slot; symb++) {
|
||||
for (int q = 0; q < NR_MAX_NB_CODEWORDS; q++)
|
||||
free_and_zero(ue->nr_gold_pusch_dmrs[slot][symb][q]);
|
||||
free_and_zero(ue->nr_gold_pusch_dmrs[slot][symb]);
|
||||
}
|
||||
free_and_zero(ue->nr_gold_pusch_dmrs[slot]);
|
||||
}
|
||||
free_and_zero(ue->nr_gold_pusch_dmrs);
|
||||
|
||||
NR_UE_COMMON* common_vars = &ue->common_vars;
|
||||
|
||||
for (int i = 0; i < fp->nb_antennas_tx; i++) {
|
||||
free_and_zero(common_vars->txdata[i]);
|
||||
free_and_zero(common_vars->txdataF[i]);
|
||||
}
|
||||
|
||||
free_and_zero(common_vars->txdata);
|
||||
free_and_zero(common_vars->txdataF);
|
||||
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
free_and_zero(common_vars->rxdata[i]);
|
||||
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++)
|
||||
free_and_zero(common_vars->common_vars_rx_data_per_thread[th_id].rxdataF[i]);
|
||||
}
|
||||
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
|
||||
free_and_zero(common_vars->common_vars_rx_data_per_thread[th_id].rxdataF);
|
||||
}
|
||||
free_and_zero(common_vars->rxdata);
|
||||
|
||||
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
|
||||
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
|
||||
free_and_zero(ue->nr_gold_pdcch[0][slot][symb]);
|
||||
free_and_zero(ue->nr_gold_pdcch[0][slot]);
|
||||
}
|
||||
free_and_zero(ue->nr_gold_pdcch[0]);
|
||||
|
||||
for (int slot=0; slot<fp->slots_per_frame; slot++) {
|
||||
for (int symb=0; symb<fp->symbols_per_slot; symb++) {
|
||||
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
|
||||
free_and_zero(ue->nr_gold_pdsch[0][slot][symb][q]);
|
||||
free_and_zero(ue->nr_gold_pdsch[0][slot][symb]);
|
||||
}
|
||||
free_and_zero(ue->nr_gold_pdsch[0][slot]);
|
||||
}
|
||||
free_and_zero(ue->nr_gold_pdsch[0]);
|
||||
|
||||
for (int gNB_id = 0; gNB_id < ue->n_connected_gNB; gNB_id++) {
|
||||
|
||||
// PDSCH
|
||||
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
|
||||
for (int k = 0; k < 8; k++) { //harq_pid
|
||||
for (int l = 0; l < 8; l++) { //round
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
for (int j = 0; j < 4; j++) { //frame_parms->nb_antennas_tx; j++)
|
||||
const int idx = j * fp->nb_antennas_rx + i;
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l][idx]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l][idx]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l][idx]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l][idx]);
|
||||
}
|
||||
}
|
||||
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->rxdataF_comp1[k][l]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho_ext[k][l]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_mag1[k][l]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_magb1[k][l]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
const int idx = (j*fp->nb_antennas_rx)+i;
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext[idx]);
|
||||
}
|
||||
}
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr_shifts);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr[1]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->layer_llr[1]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr128_2ndstream);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->dl_ch_rho2_ext);
|
||||
|
||||
phy_term_nr_ue__PDSCH(ue->pdsch_vars[th_id][gNB_id], fp);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]);
|
||||
}
|
||||
|
||||
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int idx = j * fp->nb_antennas_rx + i;
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates[idx]);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time[idx]);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp[idx]);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext[idx]);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext[idx]);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext[idx]);
|
||||
}
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho[i]);
|
||||
}
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->llr16);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->wbar);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->e_rx);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_comp);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_rho_ext);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rho);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->rxdataF_ext);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_ext);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates);
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]->dl_ch_estimates_time);
|
||||
|
||||
free_and_zero(ue->pdcch_vars[th_id][gNB_id]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
free_and_zero(ue->nr_srs_info->srs_received_signal[i]);
|
||||
free_and_zero(ue->nr_srs_info->srs_ls_estimated_channel[i]);
|
||||
free_and_zero(ue->nr_srs_info->srs_estimated_channel_freq[i]);
|
||||
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time[i]);
|
||||
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted[i]);
|
||||
}
|
||||
free_and_zero(ue->nr_srs_info->srs_generated_signal);
|
||||
free_and_zero(ue->nr_srs_info->noise_power);
|
||||
free_and_zero(ue->nr_srs_info->srs_received_signal);
|
||||
free_and_zero(ue->nr_srs_info->srs_ls_estimated_channel);
|
||||
free_and_zero(ue->nr_srs_info->srs_estimated_channel_freq);
|
||||
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time);
|
||||
free_and_zero(ue->nr_srs_info->srs_estimated_channel_time_shifted);
|
||||
free_and_zero(ue->nr_srs_info);
|
||||
|
||||
free_and_zero(ue->srs_vars[gNB_id]);
|
||||
|
||||
for (int i = 0; i < fp->nb_antennas_rx; i++) {
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext[i]);
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int idx = (j*fp->nb_antennas_rx)+i;
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp[idx]);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates[idx]);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time[idx]);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->llr);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]->decoded_output);
|
||||
free_and_zero(ue->pbch_vars[gNB_id]);
|
||||
|
||||
free_and_zero(ue->prach_vars[gNB_id]->prachF);
|
||||
free_and_zero(ue->prach_vars[gNB_id]->prach);
|
||||
free_and_zero(ue->prach_vars[gNB_id]);
|
||||
}
|
||||
|
||||
const int gNB_id = ue->n_connected_gNB;
|
||||
for (int th_id = 0; th_id < RX_NB_TH_MAX; th_id++) {
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->llr[1]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]->layer_llr[1]);
|
||||
free_and_zero(ue->pdsch_vars[th_id][gNB_id]);
|
||||
}
|
||||
|
||||
free_and_zero(ue->sinr_CQI_dB);
|
||||
}
|
||||
|
||||
void term_nr_ue_transport(PHY_VARS_NR_UE *ue)
|
||||
{
|
||||
const int N_RB_DL = ue->frame_parms.N_RB_DL;
|
||||
for (int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int k = 0; k < RX_NB_TH_MAX; k++) {
|
||||
free_nr_ue_dlsch(&ue->dlsch[k][i][j], N_RB_DL);
|
||||
free_nr_ue_ulsch(&ue->ulsch[k][i][j], N_RB_DL);
|
||||
}
|
||||
}
|
||||
|
||||
free_nr_ue_dlsch(&ue->dlsch_SI[i], N_RB_DL);
|
||||
free_nr_ue_dlsch(&ue->dlsch_ra[i], N_RB_DL);
|
||||
}
|
||||
|
||||
free_nr_ue_dlsch(&ue->dlsch_MCH[0], N_RB_DL);
|
||||
}
|
||||
|
||||
void init_nr_ue_transport(PHY_VARS_NR_UE *ue)
|
||||
{
|
||||
for (int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) {
|
||||
for (int j=0; j<2; j++) {
|
||||
for (int k=0; k<RX_NB_TH_MAX; k++) {
|
||||
AssertFatal((ue->dlsch[k][i][j] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag))!=NULL,"Can't get ue dlsch structures\n");
|
||||
AssertFatal((ue->dlsch[k][i][j] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL))!=NULL,"Can't get ue dlsch structures\n");
|
||||
LOG_D(PHY,"dlsch[%d][%d][%d] => %p\n",k,i,j,ue->dlsch[k][i][j]);
|
||||
AssertFatal((ue->ulsch[k][i][j] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NR_MAX_ULSCH_HARQ_PROCESSES, abstraction_flag))!=NULL,"Can't get ue ulsch structures\n");
|
||||
AssertFatal((ue->ulsch[k][i][j] = new_nr_ue_ulsch(ue->frame_parms.N_RB_UL, NR_MAX_ULSCH_HARQ_PROCESSES))!=NULL,"Can't get ue ulsch structures\n");
|
||||
LOG_D(PHY,"ulsch[%d][%d][%d] => %p\n",k,i,j,ue->ulsch[k][i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
ue->dlsch_SI[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag);
|
||||
ue->dlsch_ra[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL, abstraction_flag);
|
||||
ue->dlsch_SI[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL);
|
||||
ue->dlsch_ra[i] = new_nr_ue_dlsch(1,1,NSOFT,MAX_LDPC_ITERATIONS,ue->frame_parms.N_RB_DL);
|
||||
ue->transmission_mode[i] = ue->frame_parms.nb_antenna_ports_gNB==1 ? 1 : 2;
|
||||
}
|
||||
|
||||
//ue->frame_parms.pucch_config_common.deltaPUCCH_Shift = 1;
|
||||
ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL,0);
|
||||
ue->dlsch_MCH[0] = new_nr_ue_dlsch(1,NR_MAX_DLSCH_HARQ_PROCESSES,NSOFT,MAX_LDPC_ITERATIONS_MBSFN,ue->frame_parms.N_RB_DL);
|
||||
|
||||
for(int i=0; i<5; i++)
|
||||
ue->dl_stats[i] = 0;
|
||||
@@ -555,3 +776,9 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) {
|
||||
//init_unscrambling_lut();
|
||||
//set_taus_seed(1328);
|
||||
}
|
||||
|
||||
void phy_term_nr_top(void)
|
||||
{
|
||||
free_ul_reference_signal_sequences();
|
||||
free_context_synchro_nr();
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ int l1_north_init_eNB(void);
|
||||
int phy_init_top(LTE_DL_FRAME_PARMS *frame_parms);
|
||||
|
||||
void phy_init_nr_top(PHY_VARS_NR_UE *ue);
|
||||
void phy_term_nr_top(void);
|
||||
|
||||
|
||||
/*!
|
||||
@@ -395,8 +396,9 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp,uint8_t i_ssb);
|
||||
int nr_init_frame_parms(nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS *frame_parms);
|
||||
int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms, fapi_nr_config_request_t *config, uint16_t nr_band);
|
||||
void nr_init_frame_parms_ue_sa(NR_DL_FRAME_PARMS *frame_parms, uint64_t downlink_frequency, int32_t uplink_frequency_offset, uint8_t mu, uint16_t nr_band);
|
||||
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag);
|
||||
void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag);
|
||||
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB);
|
||||
void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB);
|
||||
void init_nr_ue_transport(PHY_VARS_NR_UE *ue);
|
||||
void init_N_TA_offset(PHY_VARS_NR_UE *ue);
|
||||
void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms);
|
||||
int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char lowmem_flag);
|
||||
@@ -405,11 +407,13 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,
|
||||
void phy_free_nr_gNB(PHY_VARS_gNB *gNB);
|
||||
int l1_north_init_gNB(void);
|
||||
void init_nr_transport(PHY_VARS_gNB *gNB);
|
||||
void reset_nr_transport(PHY_VARS_gNB *gNB);
|
||||
|
||||
void init_dfts(void);
|
||||
|
||||
void fill_subframe_mask(PHY_VARS_eNB *eNB);
|
||||
void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg);
|
||||
void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg);
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
|
||||
@@ -6481,7 +6481,7 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t subframe,unsigned int *c
|
||||
sprintf(fname,"dlsch%d_rxF_r%d_uespec0.m",eNB_id,round);
|
||||
sprintf(vname,"dl%d_rxF_r%d_uespec0",eNB_id,round);
|
||||
LOG_M(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_uespec_pilots[0],
|
||||
12*(ue->frame_parms.N_RB_DL)*NSYMB,1,1);
|
||||
12*(ue->frame_parms.N_RB_DL),1,1);
|
||||
/*
|
||||
LOG_M("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*NSYMB,1,1);
|
||||
LOG_M("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*NSYMB,1,1);
|
||||
|
||||
@@ -122,23 +122,20 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC,
|
||||
*********************************************************************/
|
||||
|
||||
int16_t get_index_for_dmrs_lowpapr_seq(int16_t num_dmrs_res) {
|
||||
|
||||
int16_t index = -1;
|
||||
|
||||
if (num_dmrs_res >= dmrs_ul_allocated_res[(MAX_INDEX_DMRS_UL_ALLOCATED_REs-1)])
|
||||
|
||||
int16_t index = num_dmrs_res/6 - 1;
|
||||
|
||||
if (index >= MAX_INDEX_DMRS_UL_ALLOCATED_REs)
|
||||
index = MAX_INDEX_DMRS_UL_ALLOCATED_REs-1;
|
||||
else
|
||||
index = (num_dmrs_res/6) -1;
|
||||
|
||||
for (;index >= 0; index--) {
|
||||
if (dmrs_ul_allocated_res[index] == num_dmrs_res)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
LOG_D(PHY, "num_dmrs_res: %d INDEX RETURNED: %d", num_dmrs_res, index);
|
||||
return index;
|
||||
LOG_D(PHY, "num_dmrs_res: %d INDEX RETURNED: %d", num_dmrs_res, index);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@@ -204,6 +201,11 @@ int16_t *base_sequence_36_or_larger(unsigned int Msc_RS,
|
||||
|
||||
void generate_lowpapr_typ1_refsig_sequences(unsigned int scaling)
|
||||
{
|
||||
/* prevent multiple calls, relevant when both UE & gNB initialize this */
|
||||
static bool already_called = false;
|
||||
if (already_called) return;
|
||||
already_called = true;
|
||||
|
||||
unsigned int u,Msc_RS;
|
||||
unsigned int v = 0; // sequence hopping and group hopping are not supported yet
|
||||
|
||||
@@ -223,6 +225,11 @@ void generate_lowpapr_typ1_refsig_sequences(unsigned int scaling)
|
||||
|
||||
void generate_ul_reference_signal_sequences(unsigned int scaling)
|
||||
{
|
||||
/* prevent multiple calls, relevant when both UE & gNB initialize this */
|
||||
static bool already_called = false;
|
||||
if (already_called) return;
|
||||
already_called = true;
|
||||
|
||||
unsigned int u,v,Msc_RS;
|
||||
|
||||
#if 0
|
||||
@@ -295,10 +302,10 @@ void free_ul_reference_signal_sequences(void)
|
||||
for (u=0; u < U_GROUP_NUMBER; u++) {
|
||||
for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) {
|
||||
if (rv_ul_ref_sig[u][v][Msc_RS])
|
||||
free16(rv_ul_ref_sig[u][v][Msc_RS],2*sizeof(int16_t)*ul_allocated_re[Msc_RS]);
|
||||
free_and_zero(rv_ul_ref_sig[u][v][Msc_RS]);
|
||||
if ((v==0) && (Msc_RS < MAX_INDEX_DMRS_UL_ALLOCATED_REs))
|
||||
if (dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS])
|
||||
free16(dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS],2*sizeof(int16_t)*dmrs_ul_allocated_res[Msc_RS]);
|
||||
free_and_zero(dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +328,7 @@ void free_gnb_lowpapr_sequences(void)
|
||||
v=0;
|
||||
for (u=0; u < U_GROUP_NUMBER; u++) {
|
||||
if (gNB_dmrs_lowpaprtype1_sequence[u][v][Msc_RS])
|
||||
free16(gNB_dmrs_lowpaprtype1_sequence[u][v][Msc_RS],2*sizeof(int16_t)*dmrs_ul_allocated_res[Msc_RS]);
|
||||
free_and_zero(gNB_dmrs_lowpaprtype1_sequence[u][v][Msc_RS]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +130,8 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
|
||||
uint16_t Nid = dci_pdu->ScramblingId;
|
||||
uint16_t scrambling_RNTI = dci_pdu->ScramblingRNTI;
|
||||
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE,
|
||||
dci_pdu->PayloadSizeBits,
|
||||
dci_pdu->AggregationLevel,
|
||||
0,NULL);
|
||||
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI,1,currentPtr);
|
||||
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI, 1,
|
||||
NR_POLAR_DCI_MESSAGE_TYPE, dci_pdu->PayloadSizeBits, dci_pdu->AggregationLevel);
|
||||
#ifdef DEBUG_CHANNEL_CODING
|
||||
printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu->AggregationLevel);
|
||||
printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n",
|
||||
|
||||
@@ -55,42 +55,39 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) {
|
||||
NR_gNB_DLSCH_t *dlsch = *dlschptr;
|
||||
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
|
||||
|
||||
if (dlsch) {
|
||||
if (N_RB != 273) {
|
||||
a_segments = a_segments*N_RB;
|
||||
a_segments = a_segments/273 +1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY,"Freeing dlsch %p\n",dlsch);
|
||||
#endif
|
||||
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
|
||||
|
||||
if (harq->b) {
|
||||
free16(harq->b, a_segments * 1056);
|
||||
harq->b = NULL;
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY, "Freeing harq->b (%p)\n", harq->b);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY, "Freeing dlsch process %d c (%p)\n", i, harq->c);
|
||||
#endif
|
||||
|
||||
for (r = 0; r < a_segments; r++) {
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY, "Freeing dlsch process %d c[%d] (%p)\n", i, r, harq->c[r]);
|
||||
#endif
|
||||
|
||||
if (harq->c[r]) {
|
||||
free16(harq->c[r], 1056);
|
||||
harq->c[r] = NULL;
|
||||
}
|
||||
}
|
||||
free16(dlsch, sizeof(NR_gNB_DLSCH_t));
|
||||
*dlschptr = NULL;
|
||||
if (N_RB != 273) {
|
||||
a_segments = a_segments*N_RB;
|
||||
a_segments = a_segments/273 +1;
|
||||
}
|
||||
|
||||
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
|
||||
if (harq->b) {
|
||||
free16(harq->b, a_segments * 1056);
|
||||
harq->b = NULL;
|
||||
}
|
||||
for (r = 0; r < a_segments; r++) {
|
||||
free(harq->c[r]);
|
||||
harq->c[r] = NULL;
|
||||
}
|
||||
free(harq->pdu);
|
||||
|
||||
for (int aa = 0; aa < 64; aa++)
|
||||
free(dlsch->calib_dl_ch_estimates[aa]);
|
||||
free(dlsch->calib_dl_ch_estimates);
|
||||
|
||||
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
|
||||
free(dlsch->mod_symbs[q]);
|
||||
|
||||
for (int layer = 0; layer < NR_MAX_NB_LAYERS; layer++) {
|
||||
free(dlsch->txdataF_precoding[layer]);
|
||||
free(dlsch->txdataF[layer]);
|
||||
for (int aa = 0; aa < 64; aa++)
|
||||
free(dlsch->ue_spec_bf_weights[layer][aa]);
|
||||
free(dlsch->ue_spec_bf_weights[layer]);
|
||||
}
|
||||
|
||||
free(dlsch);
|
||||
*dlschptr = NULL;
|
||||
}
|
||||
|
||||
NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
|
||||
@@ -299,8 +299,8 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
|
||||
|
||||
/// CRC, coding and rate matching
|
||||
polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0,
|
||||
nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,0,NULL)
|
||||
);
|
||||
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
|
||||
|
||||
#ifdef DEBUG_PBCH_ENCODING
|
||||
printf("Channel coding:\n");
|
||||
|
||||
|
||||
@@ -92,6 +92,5 @@ uint8_t get_l0(uint16_t dlDmrsSymbPos) {
|
||||
if ((mask&1) == 1) break;
|
||||
mask>>=1;
|
||||
}
|
||||
AssertFatal(l0 < 4,"impossible l0 %d\n",l0);
|
||||
return (l0);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
uint8_t abstraction_flag,
|
||||
uint16_t N_RB);
|
||||
|
||||
void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB);
|
||||
|
||||
/** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation. It performs
|
||||
- RB extraction (signal and channel estimates)
|
||||
- channel compensation (matched filtering)
|
||||
@@ -296,6 +298,7 @@ int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame,int slot, find_type_t type);
|
||||
int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type);
|
||||
|
||||
NR_gNB_PUCCH_t *new_gNB_pucch(void);
|
||||
void free_gNB_pucch(NR_gNB_PUCCH_t *pucch);
|
||||
|
||||
void nr_fill_pucch(PHY_VARS_gNB *gNB,
|
||||
int frame,
|
||||
@@ -308,6 +311,7 @@ int nr_find_pucch(uint16_t rnti,
|
||||
PHY_VARS_gNB *gNB);
|
||||
|
||||
NR_gNB_SRS_t *new_gNB_srs(void);
|
||||
void free_gNB_srs(NR_gNB_SRS_t *srs);
|
||||
|
||||
int nr_find_srs(uint16_t rnti,
|
||||
int frame,
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#include "PHY/defs_gNB.h"
|
||||
#include "common/utils/threadPool/thread-pool.h"
|
||||
|
||||
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch,uint8_t N_RB_UL);
|
||||
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch, uint16_t N_RB_UL);
|
||||
|
||||
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint8_t abstraction_flag);
|
||||
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL);
|
||||
|
||||
|
||||
/*! \brief Perform PUSCH decoding. TS 38.212 V15.4.0 subclause 6.2
|
||||
|
||||
@@ -54,60 +54,40 @@
|
||||
|
||||
//extern double cpuf;
|
||||
|
||||
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr,uint8_t N_RB_UL)
|
||||
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr, uint16_t N_RB_UL)
|
||||
{
|
||||
|
||||
int i,r;
|
||||
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
|
||||
NR_gNB_ULSCH_t *ulsch = *ulschptr;
|
||||
|
||||
if (ulsch) {
|
||||
if (N_RB_UL != 273) {
|
||||
a_segments = a_segments*N_RB_UL;
|
||||
a_segments = a_segments/273 +1;
|
||||
}
|
||||
|
||||
|
||||
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
|
||||
|
||||
if (ulsch->harq_processes[i]) {
|
||||
if (ulsch->harq_processes[i]->b) {
|
||||
free16(ulsch->harq_processes[i]->b,a_segments*1056);
|
||||
ulsch->harq_processes[i]->b = NULL;
|
||||
}
|
||||
for (r=0; r<a_segments; r++) {
|
||||
free16(ulsch->harq_processes[i]->c[r],(8448)*sizeof(uint8_t));
|
||||
ulsch->harq_processes[i]->c[r] = NULL;
|
||||
}
|
||||
for (r=0; r<a_segments; r++) {
|
||||
if (ulsch->harq_processes[i]->d[r]) {
|
||||
free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t));
|
||||
ulsch->harq_processes[i]->d[r] = NULL;
|
||||
}
|
||||
}
|
||||
for (r=0; r<a_segments; r++) {
|
||||
if (ulsch->harq_processes[i]->w[r]) {
|
||||
free16(ulsch->harq_processes[i]->w[r],(3*(6144+64))*sizeof(int16_t));
|
||||
ulsch->harq_processes[i]->w[r] = NULL;
|
||||
}
|
||||
}
|
||||
for (r=0; r<a_segments; r++) {
|
||||
if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]){
|
||||
nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
|
||||
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
|
||||
}
|
||||
}
|
||||
free16(ulsch->harq_processes[i],sizeof(NR_UL_gNB_HARQ_t));
|
||||
ulsch->harq_processes[i] = NULL;
|
||||
}
|
||||
}
|
||||
free16(ulsch,sizeof(NR_gNB_ULSCH_t));
|
||||
*ulschptr = NULL;
|
||||
if (N_RB_UL != 273) {
|
||||
a_segments = a_segments*N_RB_UL;
|
||||
a_segments = a_segments/273 +1;
|
||||
}
|
||||
|
||||
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
|
||||
if (ulsch->harq_processes[i]) {
|
||||
if (ulsch->harq_processes[i]->b) {
|
||||
free_and_zero(ulsch->harq_processes[i]->b);
|
||||
ulsch->harq_processes[i]->b = NULL;
|
||||
}
|
||||
for (r=0; r<a_segments; r++) {
|
||||
free_and_zero(ulsch->harq_processes[i]->c[r]);
|
||||
free_and_zero(ulsch->harq_processes[i]->d[r]);
|
||||
free_and_zero(ulsch->harq_processes[i]->w[r]);
|
||||
nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
|
||||
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
|
||||
}
|
||||
free_and_zero(ulsch->harq_processes[i]);
|
||||
ulsch->harq_processes[i] = NULL;
|
||||
}
|
||||
}
|
||||
free_and_zero(*ulschptr);
|
||||
}
|
||||
|
||||
|
||||
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint8_t abstraction_flag)
|
||||
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL)
|
||||
{
|
||||
|
||||
NR_gNB_ULSCH_t *ulsch;
|
||||
@@ -129,13 +109,11 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint
|
||||
|
||||
ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16_clear(sizeof(NR_UL_gNB_HARQ_t));
|
||||
ulsch->harq_processes[i]->b = (uint8_t*)malloc16_clear(ulsch_bytes);
|
||||
if (abstraction_flag == 0) {
|
||||
for (r=0; r<a_segments; r++) {
|
||||
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
|
||||
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16_clear(8448*sizeof(uint8_t));
|
||||
ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16_clear((68*384)*sizeof(int16_t));
|
||||
ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16_clear((3*(6144+64))*sizeof(int16_t));
|
||||
}
|
||||
for (r=0; r<a_segments; r++) {
|
||||
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
|
||||
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16_clear(8448*sizeof(uint8_t));
|
||||
ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16_clear((68*384)*sizeof(int16_t));
|
||||
ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16_clear((3*(6144+64))*sizeof(int16_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,11 @@ NR_gNB_PUCCH_t *new_gNB_pucch(void){
|
||||
return (pucch);
|
||||
}
|
||||
|
||||
void free_gNB_pucch(NR_gNB_PUCCH_t *pucch)
|
||||
{
|
||||
free_and_zero(pucch);
|
||||
}
|
||||
|
||||
int nr_find_pucch(uint16_t rnti,
|
||||
int frame,
|
||||
int slot,
|
||||
@@ -1533,7 +1538,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
|
||||
}
|
||||
else { // polar coded case
|
||||
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(2,nb_bit,pucch_pdu->prb_size,1,&gNB->uci_polarParams);
|
||||
__m64 *rp_re[Prx2][2];
|
||||
__m64 *rp2_re[Prx2][2];
|
||||
__m64 *rp_im[Prx2][2];
|
||||
@@ -1660,7 +1664,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
|
||||
} // half_prb
|
||||
} // symb
|
||||
// run polar decoder on llrs
|
||||
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, currentPtr);
|
||||
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, 2,nb_bit,pucch_pdu->prb_size);
|
||||
LOG_D(PHY,"UCI decoderState %d, payload[0] %llu\n",decoderState,(unsigned long long)decodedPayload[0]);
|
||||
if (decoderState>0) decoderState=1;
|
||||
corr_dB = dB_fixed64(corr);
|
||||
|
||||
@@ -49,6 +49,11 @@ NR_gNB_SRS_t *new_gNB_srs(void){
|
||||
return (srs);
|
||||
}
|
||||
|
||||
void free_gNB_srs(NR_gNB_SRS_t *srs)
|
||||
{
|
||||
free_and_zero(srs);
|
||||
}
|
||||
|
||||
int nr_find_srs(uint16_t rnti,
|
||||
int frame,
|
||||
int slot,
|
||||
|
||||
@@ -667,6 +667,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
|
||||
unsigned short p,
|
||||
unsigned char symbol,
|
||||
unsigned short BWPStart,
|
||||
uint8_t config_type,
|
||||
unsigned short bwp_start_subcarrier,
|
||||
unsigned short nb_rb_pdsch)
|
||||
{
|
||||
@@ -678,10 +679,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
|
||||
int16_t *fl=NULL,*fm=NULL,*fr=NULL,*fml=NULL,*fmr=NULL,*fmm=NULL,*fdcl=NULL,*fdcr=NULL,*fdclh=NULL,*fdcrh=NULL, *frl=NULL, *frr=NULL;
|
||||
int ch_offset,symbol_offset;
|
||||
|
||||
NR_UE_DLSCH_t **dlsch = ue->dlsch[proc->thread_id][gNB_id];
|
||||
const unsigned char harq_pid = dlsch[0]->current_harq_pid;
|
||||
NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[harq_pid];
|
||||
|
||||
uint8_t nushift;
|
||||
int **dl_ch_estimates =ue->pdsch_vars[proc->thread_id][gNB_id]->dl_ch_estimates;
|
||||
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF;
|
||||
@@ -703,7 +700,6 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
|
||||
if (is_SI) {
|
||||
rb_offset -= BWPStart;
|
||||
}
|
||||
uint8_t config_type = dlsch0_harq->dmrsConfigType;
|
||||
int8_t delta = get_delta(p, config_type);
|
||||
|
||||
// checking if re-initialization of scrambling IDs is needed
|
||||
|
||||
@@ -72,6 +72,7 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
|
||||
unsigned short p,
|
||||
unsigned char symbol,
|
||||
unsigned short BWPStart,
|
||||
uint8_t config_type,
|
||||
unsigned short bwp_start_subcarrier,
|
||||
unsigned short nb_rb_pdsch);
|
||||
|
||||
|
||||
@@ -126,76 +126,75 @@ void nr_pdcch_demapping_deinterleaving(uint32_t *llr,
|
||||
|
||||
*/
|
||||
int c = 0, r = 0;
|
||||
uint16_t bundle_j = 0, f_bundle_j = 0, f_reg = 0;
|
||||
uint16_t f_bundle_j = 0;
|
||||
uint32_t coreset_C = 0;
|
||||
uint16_t index_z, index_llr;
|
||||
int coreset_interleaved = 0;
|
||||
int N_regs = coreset_nbr_rb*coreset_time_dur;
|
||||
|
||||
if (reg_bundle_size_L != 0) { // interleaving will be done only if reg_bundle_size_L != 0
|
||||
coreset_interleaved = 1;
|
||||
coreset_C = (uint32_t) (coreset_nbr_rb / (coreset_interleaver_size_R * reg_bundle_size_L));
|
||||
coreset_C = (uint32_t) (N_regs / (coreset_interleaver_size_R * reg_bundle_size_L));
|
||||
} else {
|
||||
reg_bundle_size_L = 6;
|
||||
}
|
||||
|
||||
int B_rb = reg_bundle_size_L/coreset_time_dur; // nb of RBs occupied by each REG bundle
|
||||
int num_bundles_per_cce = 6/reg_bundle_size_L;
|
||||
int max_bundles = NR_MAX_PDCCH_AGG_LEVEL*num_bundles_per_cce;
|
||||
int f_bundle_j_list[max_bundles];
|
||||
|
||||
int f_bundle_j_list[(2*NR_MAX_PDCCH_AGG_LEVEL) - 1] = {};
|
||||
|
||||
for (int reg = 0; reg < coreset_nbr_rb; reg++) {
|
||||
if ((reg % reg_bundle_size_L) == 0) {
|
||||
// for each bundle
|
||||
for (int nb = 0; nb < max_bundles; nb++) {
|
||||
if (coreset_interleaved == 0) f_bundle_j = nb;
|
||||
else {
|
||||
if (r == coreset_interleaver_size_R) {
|
||||
r = 0;
|
||||
c++;
|
||||
}
|
||||
|
||||
bundle_j = (c * coreset_interleaver_size_R) + r;
|
||||
f_bundle_j = ((r * coreset_C) + c + n_shift) % (coreset_nbr_rb / reg_bundle_size_L);
|
||||
|
||||
if (coreset_interleaved == 0) f_bundle_j = bundle_j;
|
||||
|
||||
f_bundle_j_list[reg / 6] = f_bundle_j;
|
||||
|
||||
f_bundle_j = ((r * coreset_C) + c + n_shift) % (N_regs / reg_bundle_size_L);
|
||||
r++;
|
||||
}
|
||||
if ((reg % reg_bundle_size_L) == 0) r++;
|
||||
f_bundle_j_list[nb] = f_bundle_j;
|
||||
}
|
||||
|
||||
// Get cce_list indices by reg_idx in ascending order
|
||||
int f_bundle_j_list_id = 0;
|
||||
int f_bundle_j_list_ord[(2*NR_MAX_PDCCH_AGG_LEVEL)-1] = {};
|
||||
// Get cce_list indices by bundle index in ascending order
|
||||
int f_bundle_j_list_ord[number_of_candidates][max_bundles];
|
||||
for (int c_id = 0; c_id < number_of_candidates; c_id++ ) {
|
||||
f_bundle_j_list_id = CCE[c_id];
|
||||
for (int p = 0; p < NR_MAX_PDCCH_AGG_LEVEL; p++) {
|
||||
for (int p2 = CCE[c_id]; p2 < CCE[c_id] + L[c_id]; p2++) {
|
||||
AssertFatal(p2<2*NR_MAX_PDCCH_AGG_LEVEL,"number_of_candidates %d : p2 %d, CCE[%d] %d, L[%d] %d\n",number_of_candidates,p2,c_id,CCE[c_id],c_id,L[c_id]);
|
||||
if (f_bundle_j_list[p2] == p) {
|
||||
AssertFatal(f_bundle_j_list_id < 2*NR_MAX_PDCCH_AGG_LEVEL,"f_bundle_j_list_id %d\n",f_bundle_j_list_id);
|
||||
f_bundle_j_list_ord[f_bundle_j_list_id] = p;
|
||||
int start_bund_cand = CCE[c_id]*num_bundles_per_cce;
|
||||
int max_bund_per_cand = L[c_id]*num_bundles_per_cce;
|
||||
int f_bundle_j_list_id = 0;
|
||||
for(int nb = 0; nb < max_bundles; nb++) {
|
||||
for(int bund_cand = start_bund_cand; bund_cand < start_bund_cand+max_bund_per_cand; bund_cand++){
|
||||
if (f_bundle_j_list[bund_cand] == nb) {
|
||||
f_bundle_j_list_ord[c_id][f_bundle_j_list_id] = nb;
|
||||
f_bundle_j_list_id++;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int rb = 0;
|
||||
int rb_count = 0;
|
||||
int data_sc = 9; // 9 sub-carriers with data per PRB
|
||||
for (int c_id = 0; c_id < number_of_candidates; c_id++ ) {
|
||||
for (int symbol_idx = start_symbol; symbol_idx < start_symbol+coreset_time_dur; symbol_idx++) {
|
||||
for (int cce_count = CCE[c_id/coreset_time_dur]+c_id%coreset_time_dur; cce_count < CCE[c_id/coreset_time_dur]+c_id%coreset_time_dur+L[c_id]; cce_count += coreset_time_dur) {
|
||||
for (int reg_in_cce_idx = 0; reg_in_cce_idx < NR_NB_REG_PER_CCE; reg_in_cce_idx++) {
|
||||
|
||||
f_reg = (f_bundle_j_list_ord[cce_count] * reg_bundle_size_L) + reg_in_cce_idx;
|
||||
index_z = 9 * rb;
|
||||
index_llr = (uint16_t) (f_reg + symbol_idx * coreset_nbr_rb) * 9;
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
z[index_z + i] = llr[index_llr + i];
|
||||
for (int cce_count = 0; cce_count < L[c_id]; cce_count ++) {
|
||||
for (int k=0; k<NR_NB_REG_PER_CCE/reg_bundle_size_L; k++) { // loop over REG bundles
|
||||
int f = f_bundle_j_list_ord[c_id][k+NR_NB_REG_PER_CCE*cce_count/reg_bundle_size_L];
|
||||
for(int rb=0; rb<B_rb; rb++) { // loop over the RBs of the bundle
|
||||
index_z = data_sc * rb_count;
|
||||
index_llr = (uint16_t) (f*B_rb + rb + symbol_idx * coreset_nbr_rb) * data_sc;
|
||||
for (int i = 0; i < data_sc; i++) {
|
||||
z[index_z + i] = llr[index_llr + i];
|
||||
#ifdef NR_PDCCH_DCI_DEBUG
|
||||
LOG_I(PHY,"[cce_count=%d,reg_in_cce_idx=%d,bundle_j=%d,symbol_idx=%d,candidate=%d] z[%d]=(%d,%d) <-> \t[f_reg=%d,fbundle_j=%d] llr[%d]=(%d,%d) \n",
|
||||
cce_count,reg_in_cce_idx,bundle_j,symbol_idx,c_id,(index_z + i),*(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]),
|
||||
f_reg,f_bundle_j,(index_llr + i),*(int16_t *) &llr[index_llr + i], *(1 + (int16_t *) &llr[index_llr + i]));
|
||||
LOG_I(PHY,"[candidate=%d,symbol_idx=%d,cce=%d,REG bundle=%d,PRB=%d] z[%d]=(%d,%d) <-> \t llr[%d]=(%d,%d) \n",
|
||||
c_id,symbol_idx,cce_count,k,f*B_rb + rb,(index_z + i),*(int16_t *) &z[index_z + i],*(1 + (int16_t *) &z[index_z + i]),
|
||||
(index_llr + i),*(int16_t *) &llr[index_llr + i], *(1 + (int16_t *) &llr[index_llr + i]));
|
||||
#endif
|
||||
}
|
||||
rb_count++;
|
||||
}
|
||||
rb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -762,6 +761,7 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
|
||||
rel15->number_of_candidates,
|
||||
rel15->CCE,
|
||||
rel15->L);
|
||||
|
||||
LOG_D(PHY,"we end nr_pdcch_demapping_deinterleaving()\n");
|
||||
LOG_D(PHY,"Ending nr_rx_pdcch() function\n");
|
||||
|
||||
@@ -802,14 +802,18 @@ void nr_pdcch_unscrambling(int16_t *z,
|
||||
/* This function compares the received DCI bits with
|
||||
* re-encoded DCI bits and returns the number of mismatched bits
|
||||
*/
|
||||
uint16_t nr_dci_false_detection(uint64_t *dci,
|
||||
int16_t *soft_in,
|
||||
const t_nrPolar_params *polar_param,
|
||||
int encoded_length,
|
||||
int rnti) {
|
||||
static uint16_t nr_dci_false_detection(uint64_t *dci,
|
||||
int16_t *soft_in,
|
||||
int encoded_length,
|
||||
int rnti,
|
||||
int8_t messageType,
|
||||
uint16_t messageLength,
|
||||
uint8_t aggregation_level
|
||||
) {
|
||||
|
||||
uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD];
|
||||
polar_encoder_fast(dci, (void*)encoder_output, rnti, 1, (t_nrPolar_params *)polar_param);
|
||||
polar_encoder_fast(dci, (void*)encoder_output, rnti, 1,
|
||||
messageType, messageLength, aggregation_level);
|
||||
uint8_t *enout_p = (uint8_t*)encoder_output;
|
||||
uint16_t x = 0;
|
||||
|
||||
@@ -836,6 +840,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
//int gNB_id = 0;
|
||||
int16_t tmp_e[16*108];
|
||||
rnti_t n_rnti;
|
||||
int e_rx_cand_idx = 0;
|
||||
|
||||
for (int j=0;j<rel15->number_of_candidates;j++) {
|
||||
int CCEind = rel15->CCE[j];
|
||||
@@ -856,26 +861,24 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
if (dci_found==1) continue;
|
||||
int dci_length = rel15->dci_length_options[k];
|
||||
uint64_t dci_estimation[2]= {0};
|
||||
const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList);
|
||||
|
||||
LOG_D(PHY, "(%i.%i) Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n",
|
||||
proc->frame_rx, proc->nr_slot_rx, j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L, dci_length,nr_dci_format_string[rel15->dci_format_options[k]]);
|
||||
proc->frame_rx, proc->nr_slot_rx, j, rel15->number_of_candidates, CCEind, e_rx_cand_idx, L, dci_length, nr_dci_format_string[rel15->dci_format_options[k]]);
|
||||
|
||||
nr_pdcch_unscrambling(&pdcch_vars->e_rx[CCEind*108], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e);
|
||||
nr_pdcch_unscrambling(&pdcch_vars->e_rx[e_rx_cand_idx], rel15->coreset.scrambling_rnti, L*108, rel15->coreset.pdcch_dmrs_scrambling_id, tmp_e);
|
||||
|
||||
#ifdef DEBUG_DCI_DECODING
|
||||
uint32_t * z = (uint32_t *) &pdcch_vars->e_rx[CCEind*108];
|
||||
for (int index_z = 0; index_z < 6*L; index_z++){
|
||||
uint32_t *z = (uint32_t *) &pdcch_vars->e_rx[e_rx_cand_idx];
|
||||
for (int index_z = 0; index_z < L*6; index_z++){
|
||||
for (int i=0; i<9; i++) {
|
||||
LOG_I(PHY,"z[%d]=(%d,%d) \n", (9*index_z + i), *(int16_t *) &z[9*index_z + i],*(1 + (int16_t *) &z[9*index_z + i]));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t crc = polar_decoder_int16(tmp_e,
|
||||
dci_estimation,
|
||||
1,
|
||||
currentPtrDCI);
|
||||
NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
|
||||
|
||||
n_rnti = rel15->rnti;
|
||||
LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d)\n",
|
||||
@@ -883,7 +886,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
if (crc == n_rnti) {
|
||||
LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n",
|
||||
proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation);
|
||||
uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,currentPtrDCI,L*108,n_rnti);
|
||||
uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,L*108,n_rnti, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
|
||||
ue->dci_thres = (ue->dci_thres + mb) / 2;
|
||||
if (mb > (ue->dci_thres+20)) {
|
||||
LOG_W(PHY,"DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n",j,mb,L*108,ue->dci_thres);
|
||||
@@ -905,6 +908,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
|
||||
LOG_D(PHY,"(%i.%i) Decoded crc %x does not match rnti %x for DCI format %d\n", proc->frame_rx, proc->nr_slot_rx, crc, n_rnti, rel15->dci_format_options[k]);
|
||||
}
|
||||
}
|
||||
e_rx_cand_idx += 9*L*6*2; //e_rx index for next candidate (L CCEs, 6 REGs per CCE and 9 REs per REG and 2 uint16_t per RE)
|
||||
}
|
||||
pdcch_vars->nb_search_space = 0;
|
||||
return(dci_ind->number_of_dcis);
|
||||
|
||||
@@ -79,7 +79,7 @@ void init_dlsch_tpool(uint8_t num_dlsch_threads) {
|
||||
free(params);
|
||||
}
|
||||
|
||||
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr,uint8_t N_RB_DL) {
|
||||
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) {
|
||||
int i,r;
|
||||
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
|
||||
NR_UE_DLSCH_t *dlsch=*dlschptr;
|
||||
@@ -131,7 +131,7 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr,uint8_t N_RB_DL) {
|
||||
}
|
||||
}
|
||||
|
||||
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL, uint8_t abstraction_flag) {
|
||||
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL) {
|
||||
NR_UE_DLSCH_t *dlsch;
|
||||
uint8_t exit_flag = 0,i,r;
|
||||
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
|
||||
@@ -167,30 +167,28 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
|
||||
else
|
||||
exit_flag=3;
|
||||
|
||||
if (abstraction_flag == 0) {
|
||||
for (r=0; r<a_segments; r++) {
|
||||
dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
|
||||
dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(1056);
|
||||
for (r=0; r<a_segments; r++) {
|
||||
dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
|
||||
dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(1056);
|
||||
|
||||
if (dlsch->harq_processes[i]->c[r])
|
||||
memset(dlsch->harq_processes[i]->c[r],0,1056);
|
||||
else
|
||||
exit_flag=2;
|
||||
if (dlsch->harq_processes[i]->c[r])
|
||||
memset(dlsch->harq_processes[i]->c[r],0,1056);
|
||||
else
|
||||
exit_flag=2;
|
||||
|
||||
dlsch->harq_processes[i]->d[r] = (short *)malloc16((5*8448)*sizeof(short));
|
||||
dlsch->harq_processes[i]->d[r] = (short *)malloc16((5*8448)*sizeof(short));
|
||||
|
||||
if (dlsch->harq_processes[i]->d[r])
|
||||
memset(dlsch->harq_processes[i]->d[r],0,(5*8448)*sizeof(short));
|
||||
else
|
||||
exit_flag=2;
|
||||
if (dlsch->harq_processes[i]->d[r])
|
||||
memset(dlsch->harq_processes[i]->d[r],0,(5*8448)*sizeof(short));
|
||||
else
|
||||
exit_flag=2;
|
||||
|
||||
dlsch->harq_processes[i]->w[r] = (short *)malloc16((5*8448)*sizeof(short));
|
||||
dlsch->harq_processes[i]->w[r] = (short *)malloc16((5*8448)*sizeof(short));
|
||||
|
||||
if (dlsch->harq_processes[i]->w[r])
|
||||
memset(dlsch->harq_processes[i]->w[r],0,(5*8448)*sizeof(short));
|
||||
else
|
||||
exit_flag=2;
|
||||
}
|
||||
if (dlsch->harq_processes[i]->w[r])
|
||||
memset(dlsch->harq_processes[i]->w[r],0,(5*8448)*sizeof(short));
|
||||
else
|
||||
exit_flag=2;
|
||||
}
|
||||
} else {
|
||||
exit_flag=1;
|
||||
|
||||
@@ -936,12 +936,12 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext,
|
||||
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
|
||||
|
||||
for (aatx=0; aatx<nb_aatx; aatx++) {
|
||||
dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12];
|
||||
|
||||
for (atx=0; atx<nb_aatx; atx++) {
|
||||
avg_rho_re[aarx][aatx*nb_aatx+atx] = 0;
|
||||
avg_rho_im[aarx][aatx*nb_aatx+atx] = 0;
|
||||
rho128 = (__m128i *)&rho[aarx][aatx*nb_aatx+atx][symbol*nb_rb*12];
|
||||
dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12];
|
||||
dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[atx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12];
|
||||
|
||||
for (rb=0; rb<nb_rb_0; rb++) {
|
||||
|
||||
@@ -337,6 +337,22 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
||||
sync_pos_frame = n_symb_prefix0*(fp->ofdm_symbol_size + fp->nb_prefix_samples0)+(ue->symbol_offset-n_symb_prefix0)*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
||||
// for a correct computation of frame number to sync with the one decoded at MIB we need to take into account in which of the n_frames we got sync
|
||||
ue->init_sync_frame = n_frames - 1 - is;
|
||||
|
||||
// compute the scramblingID_pdcch and the gold pdcch
|
||||
ue->scramblingID_pdcch = fp->Nid_cell;
|
||||
nr_gold_pdcch(ue,fp->Nid_cell);
|
||||
|
||||
// compute the scrambling IDs for PDSCH DMRS
|
||||
for (int i=0; i<2; i++)
|
||||
ue->scramblingID[i]=fp->Nid_cell;
|
||||
|
||||
nr_gold_pdsch(ue,ue->scramblingID);
|
||||
|
||||
// initialize the pusch dmrs
|
||||
uint16_t N_n_scid[2] = {fp->Nid_cell,fp->Nid_cell};
|
||||
int n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization
|
||||
nr_init_pusch_dmrs(ue, N_n_scid, n_scid);
|
||||
|
||||
// we also need to take into account the shift by samples_per_frame in case the if is true
|
||||
if (ue->ssb_offset < sync_pos_frame){
|
||||
ue->rx_offset = fp->samples_per_frame - sync_pos_frame + ue->ssb_offset;
|
||||
|
||||
@@ -533,8 +533,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
|
||||
|
||||
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
|
||||
//polar decoding de-rate matching
|
||||
const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList);
|
||||
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,currentPtr);
|
||||
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,
|
||||
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
|
||||
|
||||
if(decoderState) return(decoderState);
|
||||
|
||||
@@ -601,7 +601,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
|
||||
#endif
|
||||
|
||||
nr_downlink_indication_t dl_indication;
|
||||
fapi_nr_rx_indication_t *rx_ind = calloc(1, sizeof(*rx_ind));
|
||||
fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1);
|
||||
uint16_t number_pdus = 1;
|
||||
|
||||
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
|
||||
@@ -609,6 +609,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
|
||||
|
||||
if (ue->if_inst && ue->if_inst->dl_indication)
|
||||
ue->if_inst->dl_indication(&dl_indication, NULL);
|
||||
else
|
||||
free(rx_ind); // dl_indication would free(), so free() here if not called
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -50,24 +50,23 @@
|
||||
\brief This function frees memory allocated for a particular DLSCH at UE
|
||||
@param dlsch Pointer to DLSCH to be removed
|
||||
*/
|
||||
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch,uint8_t N_RB_DL);
|
||||
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch, uint16_t N_RB_DL);
|
||||
|
||||
|
||||
/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
|
||||
/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft)
|
||||
\brief This function allocates structures for a particular DLSCH at UE
|
||||
@returns Pointer to DLSCH to be removed
|
||||
@param Kmimo Kmimo factor from 36-212/36-213
|
||||
@param Mdlharq Maximum number of HARQ rounds (36-212/36-213)
|
||||
@param Nsoft Soft-LLR buffer size from UE-Category
|
||||
@params N_RB_DL total number of resource blocks (determine the operating BW)
|
||||
@param abstraction_flag Flag to indicate abstracted interface
|
||||
*/
|
||||
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL, uint8_t abstraction_flag);
|
||||
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL);
|
||||
|
||||
|
||||
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch,unsigned char N_RB_UL);
|
||||
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch, uint16_t N_RB_UL);
|
||||
|
||||
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag);
|
||||
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids);
|
||||
|
||||
/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception.
|
||||
@param stream0_in Input from channel compensated (MR combined) stream 0
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
//#define DEBUG_ULSCH_CODING
|
||||
|
||||
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL)
|
||||
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL)
|
||||
|
||||
{
|
||||
int i, r;
|
||||
@@ -105,12 +105,8 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL)
|
||||
}
|
||||
|
||||
|
||||
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL,
|
||||
int number_of_harq_pids,
|
||||
uint8_t abstraction_flag)
|
||||
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids)
|
||||
{
|
||||
NR_UE_ULSCH_t *ulsch;
|
||||
unsigned char exit_flag = 0,i,r;
|
||||
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
|
||||
|
||||
if (N_RB_UL != 273) {
|
||||
@@ -120,97 +116,54 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL,
|
||||
|
||||
uint32_t ulsch_bytes = a_segments*1056; // allocated bytes per segment
|
||||
|
||||
ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t));
|
||||
NR_UE_ULSCH_t *ulsch = malloc16(sizeof(NR_UE_ULSCH_t));
|
||||
DevAssert(ulsch);
|
||||
memset(ulsch, 0, sizeof(*ulsch));
|
||||
|
||||
if (ulsch) {
|
||||
memset(ulsch,0,sizeof(NR_UE_ULSCH_t));
|
||||
ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES;
|
||||
ulsch->Mlimit = 4; // maximum harq retransmissions
|
||||
|
||||
ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES;
|
||||
ulsch->Mlimit = 4; // maximum harq retransmissions
|
||||
//for (i=0; i<10; i++)
|
||||
//ulsch->harq_ids[i] = 0;
|
||||
|
||||
//for (i=0; i<10; i++)
|
||||
//ulsch->harq_ids[i] = 0;
|
||||
for (int i = 0; i < number_of_harq_pids; i++) {
|
||||
|
||||
for (i=0; i<number_of_harq_pids; i++) {
|
||||
ulsch->harq_processes[i] = malloc16(sizeof(NR_UL_UE_HARQ_t));
|
||||
DevAssert(ulsch->harq_processes[i]);
|
||||
memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t));
|
||||
|
||||
ulsch->harq_processes[i] = (NR_UL_UE_HARQ_t *)malloc16(sizeof(NR_UL_UE_HARQ_t));
|
||||
ulsch->harq_processes[i]->a = malloc16(ulsch_bytes);
|
||||
DevAssert(ulsch->harq_processes[i]->a);
|
||||
bzero(ulsch->harq_processes[i]->a,ulsch_bytes);
|
||||
|
||||
// printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]);
|
||||
if (ulsch->harq_processes[i]) {
|
||||
memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t));
|
||||
ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes);
|
||||
ulsch->harq_processes[i]->a = (unsigned char*)malloc16(ulsch_bytes);
|
||||
ulsch->harq_processes[i]->b = malloc16(ulsch_bytes);
|
||||
DevAssert(ulsch->harq_processes[i]->b);
|
||||
bzero(ulsch->harq_processes[i]->b,ulsch_bytes);
|
||||
|
||||
if (ulsch->harq_processes[i]->a) {
|
||||
bzero(ulsch->harq_processes[i]->a,ulsch_bytes);
|
||||
} else {
|
||||
printf("Can't allocate PDU\n");
|
||||
exit_flag=1;
|
||||
}
|
||||
for (int r = 0; r < a_segments; r++) {
|
||||
// account for filler in first segment and CRCs for multiple segment case
|
||||
ulsch->harq_processes[i]->c[r] = malloc16(8448);
|
||||
DevAssert(ulsch->harq_processes[i]->c[r]);
|
||||
bzero(ulsch->harq_processes[i]->c[r],8448);
|
||||
|
||||
if (ulsch->harq_processes[i]->b)
|
||||
bzero(ulsch->harq_processes[i]->b,ulsch_bytes);
|
||||
else {
|
||||
LOG_E(PHY,"Can't get b\n");
|
||||
exit_flag=1;
|
||||
}
|
||||
|
||||
if (abstraction_flag==0) {
|
||||
for (r=0; r<a_segments; r++) {
|
||||
// account for filler in first segment and CRCs for multiple segment case
|
||||
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448);
|
||||
ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output
|
||||
|
||||
if (ulsch->harq_processes[i]->c[r]) {
|
||||
bzero(ulsch->harq_processes[i]->c[r],8448);
|
||||
} else {
|
||||
printf("Can't get c\n");
|
||||
exit_flag=2;
|
||||
}
|
||||
if (ulsch->harq_processes[i]->d[r]) {
|
||||
bzero(ulsch->harq_processes[i]->d[r],(68*384));
|
||||
} else {
|
||||
printf("Can't get d\n");
|
||||
exit_flag=2;
|
||||
}
|
||||
}
|
||||
ulsch->harq_processes[i]->e = (uint8_t*)malloc16(14*N_RB_UL*12*8);
|
||||
if (ulsch->harq_processes[i]->e) {
|
||||
bzero(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
|
||||
} else {
|
||||
printf("Can't get e\n");
|
||||
exit_flag=1;
|
||||
}
|
||||
ulsch->harq_processes[i]->f = (uint8_t*)malloc16(14*N_RB_UL*12*8);
|
||||
if (ulsch->harq_processes[i]->f) {
|
||||
bzero(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
|
||||
} else {
|
||||
printf("Can't get f\n");
|
||||
exit_flag=1;
|
||||
}
|
||||
}
|
||||
|
||||
ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
|
||||
ulsch->harq_processes[i]->first_tx = 1;
|
||||
} else {
|
||||
LOG_E(PHY,"Can't get harq_p %d\n",i);
|
||||
exit_flag=3;
|
||||
}
|
||||
ulsch->harq_processes[i]->d[r] = malloc16(68*384); //max size for coded output
|
||||
DevAssert(ulsch->harq_processes[i]->d[r]);
|
||||
bzero(ulsch->harq_processes[i]->d[r],(68*384));
|
||||
}
|
||||
|
||||
if (exit_flag==0) {
|
||||
for (i=0; i<number_of_harq_pids; i++) {
|
||||
ulsch->harq_processes[i]->round=0;
|
||||
}
|
||||
return(ulsch);
|
||||
}
|
||||
ulsch->harq_processes[i]->e = malloc16(14*N_RB_UL*12*8);
|
||||
DevAssert(ulsch->harq_processes[i]->e);
|
||||
bzero(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
|
||||
|
||||
ulsch->harq_processes[i]->f = malloc16(14*N_RB_UL*12*8);
|
||||
DevAssert(ulsch->harq_processes[i]->f);
|
||||
bzero(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
|
||||
|
||||
ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
|
||||
ulsch->harq_processes[i]->first_tx = 1;
|
||||
}
|
||||
|
||||
LOG_E(PHY,"new_ue_ulsch exit flag, size of %d , %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t));
|
||||
free_nr_ue_ulsch(&ulsch,N_RB_UL);
|
||||
return(NULL);
|
||||
|
||||
|
||||
return(ulsch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
|
||||
NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id];
|
||||
|
||||
uint8_t num_of_codewords = 1; // tmp assumption
|
||||
int Nid_cell = 0;
|
||||
int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
|
||||
uint16_t number_dmrs_symbols = 0;
|
||||
|
||||
@@ -153,7 +152,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
|
||||
if (start_sc >= frame_parms->ofdm_symbol_size)
|
||||
start_sc -= frame_parms->ofdm_symbol_size;
|
||||
|
||||
ulsch_ue->Nid_cell = Nid_cell;
|
||||
ulsch_ue->Nid_cell = frame_parms->Nid_cell;
|
||||
|
||||
for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) {
|
||||
if((ul_dmrs_symb_pos >> i) & 0x01)
|
||||
@@ -391,7 +390,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
|
||||
// Perform this on gold sequence, not required when SC FDMA operation is done,
|
||||
LOG_D(PHY,"DMRS in symbol %d\n",l);
|
||||
nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
|
||||
|
||||
|
||||
} else {
|
||||
dmrs_idx = 0;
|
||||
}
|
||||
|
||||
@@ -440,33 +440,10 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
|
||||
void free_context_pss_nr(void)
|
||||
{
|
||||
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
|
||||
|
||||
if (primary_synchro_time_nr[i] != NULL) {
|
||||
free(primary_synchro_time_nr[i]);
|
||||
primary_synchro_time_nr[i] = NULL;
|
||||
}
|
||||
else {
|
||||
LOG_E(PHY,"Fatal memory deallocation problem \n");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (primary_synchro_nr[i] != NULL) {
|
||||
free(primary_synchro_nr[i]);
|
||||
primary_synchro_nr[i] = NULL;
|
||||
}
|
||||
else {
|
||||
LOG_E(PHY,"Fatal memory deallocation problem \n");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (pss_corr_ue[i] != NULL) {
|
||||
free(pss_corr_ue[i]);
|
||||
pss_corr_ue[i] = NULL;
|
||||
}
|
||||
else {
|
||||
LOG_E(PHY,"Fatal memory deallocation problem \n");
|
||||
assert(0);
|
||||
}
|
||||
free_and_zero(primary_synchro_nr[i]);
|
||||
free_and_zero(primary_synchro_nr2[i]);
|
||||
free_and_zero(primary_synchro_time_nr[i]);
|
||||
free_and_zero(pss_corr_ue[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -850,7 +850,7 @@ static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_
|
||||
printf("\t\t [nr_pucch2_3_4_scrambling] scrambling M_bit=%d bits\n", M_bit);
|
||||
#endif
|
||||
}
|
||||
void nr_uci_encoding(uint64_t payload,
|
||||
static void nr_uci_encoding(uint64_t payload,
|
||||
uint8_t nr_bit,
|
||||
int fmt,
|
||||
uint8_t is_pi_over_2_bpsk_enabled,
|
||||
@@ -946,12 +946,10 @@ void nr_uci_encoding(uint64_t payload,
|
||||
AssertFatal(nrofPRB<=16,"Number of PRB >16\n");
|
||||
} else if (A>=12) {
|
||||
AssertFatal(A<65,"Polar encoding not supported yet for UCI with more than 64 bits\n");
|
||||
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
|
||||
A,
|
||||
nrofPRB,
|
||||
1,
|
||||
NULL);
|
||||
polar_encoder_fast(&payload, b, 0,0,currentPtr);
|
||||
polar_encoder_fast(&payload, b, 0,0,
|
||||
NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
|
||||
A,
|
||||
nrofPRB);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ void reset_stats(FL_OBJECT *button, long arg) {
|
||||
int i,j,k;
|
||||
PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0];
|
||||
|
||||
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
|
||||
for (i=0; i<NUMBER_OF_DLSCH_MAX; i++) {
|
||||
for (k=0; k<8; k++) { //harq_processes
|
||||
for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) {
|
||||
phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0;
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include "time_meas.h"
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "assertions.h"
|
||||
#include <pthread.h>
|
||||
#include "common/config/config_userapi.h"
|
||||
#include <common/utils/threadPool/thread-pool.h>
|
||||
// global var for openair performance profiler
|
||||
int opp_enabled = 0;
|
||||
double cpu_freq_GHz __attribute__ ((aligned(32)));
|
||||
|
||||
double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0;
|
||||
static uint32_t max_cpumeasur;
|
||||
static time_stats_t **measur_table;
|
||||
notifiedFIFO_t measur_fifo;
|
||||
double get_cpu_freq_GHz(void)
|
||||
{
|
||||
if (cpu_freq_GHz <1 ) {
|
||||
time_stats_t ts = {0};
|
||||
reset_meas(&ts);
|
||||
ts.trials++;
|
||||
ts.in = rdtsc_oai();
|
||||
sleep(1);
|
||||
ts.diff = (rdtsc_oai()-ts.in);
|
||||
cpu_freq_GHz = (double)ts.diff/1000000000;
|
||||
printf("CPU Freq is %f \n", cpu_freq_GHz);
|
||||
}
|
||||
return cpu_freq_GHz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void print_meas_now(time_stats_t *ts,
|
||||
const char *name,
|
||||
FILE *file_name)
|
||||
{
|
||||
if (opp_enabled) {
|
||||
//static double cpu_freq_GHz = 3.2;
|
||||
|
||||
//if (cpu_freq_GHz == 0.0)
|
||||
//cpu_freq_GHz = get_cpu_freq_GHz(); // super slow
|
||||
if (ts->trials>0) {
|
||||
//fprintf(file_name,"Name %25s: Processing %15.3f ms for SF %d, diff_now %15.3f \n", name,(ts->p_time/(cpu_freq_GHz*1000000.0)),subframe,ts->p_time);
|
||||
fprintf(file_name,"%15.3f us, diff_now %15.3f \n",(ts->p_time/(cpu_freq_GHz*1000.0)),(double)ts->p_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_meas(time_stats_t *ts,
|
||||
const char *name,
|
||||
time_stats_t *total_exec_time,
|
||||
time_stats_t *sf_exec_time)
|
||||
{
|
||||
if (opp_enabled) {
|
||||
static int first_time = 0;
|
||||
static double cpu_freq_GHz = 0.0;
|
||||
|
||||
if (cpu_freq_GHz == 0.0)
|
||||
cpu_freq_GHz = get_cpu_freq_GHz();
|
||||
|
||||
if (first_time == 0) {
|
||||
first_time=1;
|
||||
|
||||
if ((total_exec_time == NULL) || (sf_exec_time== NULL))
|
||||
fprintf(stderr, "%25s %25s %25s %25s %25s %6f\n","Name","Total","Per Trials", "Num Trials","CPU_F_GHz", cpu_freq_GHz);
|
||||
else
|
||||
fprintf(stderr, "%25s %25s %25s %20s %15s %6f\n","Name","Total","Average/Frame","Trials", "CPU_F_GHz", cpu_freq_GHz);
|
||||
}
|
||||
|
||||
if (ts->trials>0) {
|
||||
//printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials);
|
||||
if ((total_exec_time == NULL) || (sf_exec_time== NULL)) {
|
||||
fprintf(stderr, "%25s: %15.3f us; %15d; %15.3f us;\n",
|
||||
name,
|
||||
(ts->diff/ts->trials/cpu_freq_GHz/1000.0),
|
||||
ts->trials,
|
||||
ts->max/cpu_freq_GHz/1000.0);
|
||||
} else {
|
||||
fprintf(stderr, "%25s: %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n",
|
||||
name,
|
||||
(ts->diff/cpu_freq_GHz/1000000.0),
|
||||
((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100, // percentage
|
||||
(ts->diff/ts->trials/cpu_freq_GHz/1000.0),
|
||||
((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100, // percentage
|
||||
ts->trials);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int print_meas_log(time_stats_t *ts,
|
||||
const char *name,
|
||||
time_stats_t *total_exec_time,
|
||||
time_stats_t *sf_exec_time,
|
||||
char *output)
|
||||
{
|
||||
int stroff = 0;
|
||||
static int first_time = 0;
|
||||
static double cpu_freq_GHz = 0.0;
|
||||
|
||||
if (cpu_freq_GHz == 0.0)
|
||||
cpu_freq_GHz = get_cpu_freq_GHz();
|
||||
|
||||
if (first_time == 0) {
|
||||
first_time=1;
|
||||
|
||||
if ((total_exec_time == NULL) || (sf_exec_time== NULL))
|
||||
stroff += sprintf(output, "%25s %25s %25s %25s %25s %6f\n","Name","Total","Per Trials", "Num Trials","CPU_F_GHz", cpu_freq_GHz);
|
||||
else
|
||||
stroff += sprintf(output+stroff, "%25s %25s %25s %20s %15s %6f\n","Name","Total","Average/Frame","Trials", "CPU_F_GHz", cpu_freq_GHz);
|
||||
}
|
||||
|
||||
if (ts->trials>0) {
|
||||
//printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials);
|
||||
if ((total_exec_time == NULL) || (sf_exec_time== NULL)) {
|
||||
stroff += sprintf(output+stroff, "%25s: %15.3f us; %15d; %15.3f us;\n",
|
||||
name,
|
||||
(ts->diff/ts->trials/cpu_freq_GHz/1000.0),
|
||||
ts->trials,
|
||||
ts->max/cpu_freq_GHz/1000.0);
|
||||
} else {
|
||||
stroff += sprintf(output+stroff, "%25s: %15.3f ms (%5.2f%%); %15.3f us (%5.2f%%); %15d;\n",
|
||||
name,
|
||||
(ts->diff/cpu_freq_GHz/1000000.0),
|
||||
((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100, // percentage
|
||||
(ts->diff/ts->trials/cpu_freq_GHz/1000.0),
|
||||
((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100, // percentage
|
||||
ts->trials);
|
||||
}
|
||||
}
|
||||
return stroff;
|
||||
}
|
||||
|
||||
double get_time_meas_us(time_stats_t *ts)
|
||||
{
|
||||
static double cpu_freq_GHz = 0.0;
|
||||
|
||||
if (cpu_freq_GHz == 0.0)
|
||||
cpu_freq_GHz = get_cpu_freq_GHz();
|
||||
|
||||
if (ts->trials>0)
|
||||
return (ts->diff/ts->trials/cpu_freq_GHz/1000.0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* function for the asynchronous measurment module: cpu stat are sent to a dedicated thread
|
||||
* which is in charge of computing the cpu time spent in a given function/algorithm...
|
||||
*/
|
||||
|
||||
time_stats_t *register_meas(char *name)
|
||||
{
|
||||
for (int i=0; i<max_cpumeasur; i++) {
|
||||
if (measur_table[i] == NULL) {
|
||||
measur_table[i] = (time_stats_t *)malloc(sizeof(time_stats_t));
|
||||
memset(measur_table[i] ,0,sizeof(time_stats_t));
|
||||
measur_table[i]->meas_name = strdup(name);
|
||||
measur_table[i]->meas_index = i;
|
||||
measur_table[i]->tpoolmsg =newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
|
||||
measur_table[i]->tstatptr = (time_stats_msg_t *)NotifiedFifoData(measur_table[i]->tpoolmsg);
|
||||
return measur_table[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void free_measurtbl(void) {
|
||||
for (int i=0; i<max_cpumeasur; i++) {
|
||||
if (measur_table[i] != NULL) {
|
||||
free(measur_table[i]->meas_name);
|
||||
delNotifiedFIFO_elt(measur_table[i]->tpoolmsg);
|
||||
free(measur_table[i]);
|
||||
}
|
||||
}
|
||||
//free the fifo...
|
||||
}
|
||||
|
||||
void run_cpumeasur(void) {
|
||||
struct sched_param schedp;
|
||||
pthread_setname_np(pthread_self(), "measur");
|
||||
schedp.sched_priority=0;
|
||||
int rt=pthread_setschedparam(pthread_self(), SCHED_IDLE, &schedp);
|
||||
AssertFatal(rt==0, "couldn't set measur thread priority: %s\n",strerror(errno));
|
||||
initNotifiedFIFO(&measur_fifo);
|
||||
while(1) {
|
||||
notifiedFIFO_elt_t *msg = pullNotifiedFIFO(&measur_fifo);
|
||||
time_stats_msg_t *tsm = (time_stats_msg_t *)NotifiedFifoData(msg);
|
||||
switch(tsm->msgid) {
|
||||
case TIMESTAT_MSGID_START:
|
||||
measur_table[tsm->timestat_id]->in=tsm->ts;
|
||||
(measur_table[tsm->timestat_id]->trials)++;
|
||||
break;
|
||||
case TIMESTAT_MSGID_STOP:
|
||||
/// process duration is the difference between two clock points
|
||||
measur_table[tsm->timestat_id]->p_time = (tsm->ts - measur_table[tsm->timestat_id]->in);
|
||||
measur_table[tsm->timestat_id]->diff += measur_table[tsm->timestat_id]->p_time;
|
||||
if ( measur_table[tsm->timestat_id]->p_time > measur_table[tsm->timestat_id]->max )
|
||||
measur_table[tsm->timestat_id]->max = measur_table[tsm->timestat_id]->p_time;
|
||||
break;
|
||||
case TIMESTAT_MSGID_DISPLAY:
|
||||
{
|
||||
char aline[256];
|
||||
int start, stop;
|
||||
if (tsm->displayFunc != NULL) {
|
||||
if(tsm->timestat_id >= 0) {
|
||||
start=tsm->timestat_id ;
|
||||
stop=start+1;
|
||||
}
|
||||
else {
|
||||
start=0;
|
||||
stop=max_cpumeasur ;
|
||||
}
|
||||
for (int i=start ; i<stop ; i++) {
|
||||
if (measur_table[i] != NULL) {
|
||||
sprintf(aline,"%s: %15.3f us ",measur_table[i]->meas_name, measur_table[i]->trials==0?0:( (measur_table[i]->trials/measur_table[i]->diff )/ cpu_freq_GHz /1000 ));
|
||||
tsm->displayFunc(aline);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIMESTAT_MSGID_END:
|
||||
free_measurtbl();
|
||||
delNotifiedFIFO_elt(msg);
|
||||
pthread_exit(NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
delNotifiedFIFO_elt(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_meas(void) {
|
||||
pthread_t thid;
|
||||
paramdef_t cpumeasur_params[] = CPUMEASUR_PARAMS_DESC;
|
||||
int numparams=sizeof(cpumeasur_params)/sizeof(paramdef_t);
|
||||
int rt = config_get( cpumeasur_params,numparams,CPUMEASUR_SECTION);
|
||||
AssertFatal(rt >= 0, "cpumeasur configuration couldn't be performed");
|
||||
measur_table=calloc(max_cpumeasur,sizeof( time_stats_t *));
|
||||
AssertFatal(measur_table!=NULL, "couldn't allocate %u cpu measurements entries\n",max_cpumeasur);
|
||||
rt=pthread_create(&thid,NULL, (void *(*)(void *))run_cpumeasur, NULL);
|
||||
AssertFatal(rt==0, "couldn't create cpu measurment thread: %s\n",strerror(errno));
|
||||
}
|
||||
|
||||
void end_meas(void) {
|
||||
notifiedFIFO_elt_t *nfe = newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
|
||||
time_stats_msg_t *msg = (time_stats_msg_t *)NotifiedFifoData(nfe);
|
||||
msg->msgid = TIMESTAT_MSGID_END ;
|
||||
pushNotifiedFIFO(&measur_fifo, nfe);
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#ifndef __TIME_MEAS_DEFS__H__
|
||||
#define __TIME_MEAS_DEFS__H__
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include "common/utils/threadPool/thread-pool.h"
|
||||
// global var to enable openair performance profiler
|
||||
extern int opp_enabled;
|
||||
extern double cpu_freq_GHz __attribute__ ((aligned(32)));;
|
||||
// structure to store data to compute cpu measurment
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#define OAI_CPUTIME_TYPE long long
|
||||
#elif defined(__arm__)
|
||||
#define OAI_CPUTIME_TYPE uint32_t
|
||||
#else
|
||||
#error "building on unsupported CPU architecture"
|
||||
#endif
|
||||
|
||||
#define TIMESTAT_MSGID_START 0 /*!< \brief send time at measure starting point */
|
||||
#define TIMESTAT_MSGID_STOP 1 /*!< \brief send time at measure end point */
|
||||
#define TIMESTAT_MSGID_ENABLE 2 /*!< \brief enable measure point */
|
||||
#define TIMESTAT_MSGID_DISABLE 3 /*!< \brief disable measure point */
|
||||
#define TIMESTAT_MSGID_DISPLAY 10 /*!< \brief display measure */
|
||||
#define TIMESTAT_MSGID_END 11 /*!< \brief stops the measure threads and free assocated resources */
|
||||
typedef void(*meas_printfunc_t)(const char* format, ...);
|
||||
typedef struct {
|
||||
int msgid; /*!< \brief message id, as defined by TIMESTAT_MSGID_X macros */
|
||||
int timestat_id; /*!< \brief points to the time_stats_t entry in cpumeas table */
|
||||
OAI_CPUTIME_TYPE ts; /*!< \brief time stamp */
|
||||
meas_printfunc_t displayFunc; /*!< \brief function to call when DISPLAY message is received*/
|
||||
} time_stats_msg_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
OAI_CPUTIME_TYPE in; /*!< \brief time at measure starting point */
|
||||
OAI_CPUTIME_TYPE diff; /*!< \brief average difference between time at starting point and time at endpoint*/
|
||||
OAI_CPUTIME_TYPE p_time; /*!< \brief absolute process duration */
|
||||
OAI_CPUTIME_TYPE diff_square; /*!< \brief process duration square */
|
||||
OAI_CPUTIME_TYPE max; /*!< \brief maximum difference between time at starting point and time at endpoint*/
|
||||
int trials; /*!< \brief number of start point - end point iterations */
|
||||
int meas_flag; /*!< \brief 1: stop_meas not called (consecutive calls of start_meas) */
|
||||
char *meas_name; /*!< \brief name to use when printing the measure (not used for PHY simulators)*/
|
||||
int meas_index; /*!< \brief index of this measure in the measure array (not used for PHY simulators)*/
|
||||
int meas_enabled; /*!< \brief per measure enablement flag. send_meas tests this flag, unused today in start_meas and stop_meas*/
|
||||
notifiedFIFO_elt_t *tpoolmsg; /*!< \brief message pushed to the cpu measurment queue to report a measure START or STOP */
|
||||
time_stats_msg_t *tstatptr; /*!< \brief pointer to the time_stats_msg_t data in the tpoolmsg, stored here for perf considerations*/
|
||||
} time_stats_t;
|
||||
#define MEASURE_ENABLED(X) (X->meas_enabled)
|
||||
|
||||
|
||||
|
||||
|
||||
static inline void start_meas(time_stats_t *ts) __attribute__((always_inline));
|
||||
static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline));
|
||||
|
||||
|
||||
void print_meas_now(time_stats_t *ts, const char *name, FILE *file_name);
|
||||
void print_meas(time_stats_t *ts, const char *name, time_stats_t *total_exec_time, time_stats_t *sf_exec_time);
|
||||
int print_meas_log(time_stats_t *ts, const char *name, time_stats_t *total_exec_time, time_stats_t *sf_exec_time, char *output);
|
||||
double get_time_meas_us(time_stats_t *ts);
|
||||
double get_cpu_freq_GHz(void);
|
||||
|
||||
#if defined(__i386__)
|
||||
static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline));
|
||||
static inline unsigned long long rdtsc_oai(void) {
|
||||
unsigned long long int x;
|
||||
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
|
||||
return x;
|
||||
}
|
||||
#elif defined(__x86_64__)
|
||||
static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline));
|
||||
static inline unsigned long long rdtsc_oai(void) {
|
||||
unsigned long long a, d;
|
||||
__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
|
||||
return (d<<32) | a;
|
||||
}
|
||||
|
||||
#elif defined(__arm__)
|
||||
static inline uint32_t rdtsc_oai(void) __attribute__((always_inline));
|
||||
static inline uint32_t rdtsc_oai(void) {
|
||||
uint32_t r = 0;
|
||||
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) );
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CPUMEAS_DISABLE 0
|
||||
#define CPUMEAS_ENABLE 1
|
||||
#define CPUMEAS_GETSTATE 2
|
||||
static inline int cpumeas(int action) {
|
||||
switch (action) {
|
||||
case CPUMEAS_ENABLE:
|
||||
opp_enabled = 1;
|
||||
break;
|
||||
|
||||
case CPUMEAS_DISABLE:
|
||||
opp_enabled = 0;
|
||||
break;
|
||||
|
||||
case CPUMEAS_GETSTATE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return opp_enabled;
|
||||
}
|
||||
|
||||
static inline void start_meas(time_stats_t *ts) {
|
||||
if (opp_enabled) {
|
||||
if (ts->meas_flag==0) {
|
||||
ts->trials++;
|
||||
ts->in = rdtsc_oai();
|
||||
ts->meas_flag=1;
|
||||
} else {
|
||||
ts->in = rdtsc_oai();
|
||||
}
|
||||
if ((ts->trials&16383)<10) ts->max=0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void stop_meas(time_stats_t *ts) {
|
||||
if (opp_enabled) {
|
||||
long long out = rdtsc_oai();
|
||||
ts->diff += (out-ts->in);
|
||||
/// process duration is the difference between two clock points
|
||||
ts->p_time = (out-ts->in);
|
||||
ts->diff_square += (out-ts->in)*(out-ts->in);
|
||||
|
||||
if ((out-ts->in) > ts->max)
|
||||
ts->max = out-ts->in;
|
||||
|
||||
ts->meas_flag=0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void reset_meas(time_stats_t *ts) {
|
||||
ts->in=0;
|
||||
ts->diff=0;
|
||||
ts->p_time=0;
|
||||
ts->diff_square=0;
|
||||
ts->max=0;
|
||||
ts->trials=0;
|
||||
ts->meas_flag=0;
|
||||
}
|
||||
|
||||
static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) {
|
||||
if (opp_enabled) {
|
||||
dst_ts->trials=src_ts->trials;
|
||||
dst_ts->diff=src_ts->diff;
|
||||
dst_ts->max=src_ts->max;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void merge_meas(time_stats_t *dst_ts, time_stats_t *src_ts)
|
||||
{
|
||||
if (!opp_enabled)
|
||||
return;
|
||||
dst_ts->trials += src_ts->trials;
|
||||
dst_ts->diff += src_ts->diff;
|
||||
if (src_ts->max > dst_ts->max)
|
||||
dst_ts->max = src_ts->max;
|
||||
}
|
||||
|
||||
extern notifiedFIFO_t measur_fifo;
|
||||
#define CPUMEASUR_SECTION "cpumeasur"
|
||||
|
||||
#define CPUMEASUR_PARAMS_DESC { \
|
||||
{"max_cpumeasur", "Max number of cpu measur entries", 0, uptr:&max_cpumeasur, defintval:100, TYPE_UINT, 0},\
|
||||
}
|
||||
|
||||
void init_meas(void);
|
||||
time_stats_t *register_meas(char *name);
|
||||
#define START_MEAS(X) send_meas(X, TIMESTAT_MSGID_START)
|
||||
#define STOP_MEAS(X) send_meas(X, TIMESTAT_MSGID_STOP)
|
||||
static inline void send_meas(time_stats_t *ts, int msgid) {
|
||||
if (MEASURE_ENABLED(ts) ) {
|
||||
ts->tstatptr->timestat_id=ts->meas_index;
|
||||
ts->tstatptr->msgid = msgid ;
|
||||
ts->tstatptr->ts = rdtsc_oai();
|
||||
pushNotifiedFIFO(&measur_fifo, ts->tpoolmsg);
|
||||
}
|
||||
}
|
||||
void end_meas(void);
|
||||
|
||||
#endif
|
||||
@@ -122,7 +122,7 @@ static inline void* malloc16_clear( size_t size )
|
||||
#include "PHY/impl_defs_top_NB_IoT.h"
|
||||
#include "PHY/impl_defs_lte_NB_IoT.h"
|
||||
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
//#include "PHY/CODING/defs.h"
|
||||
#include "PHY/CODING/defs_NB_IoT.h"
|
||||
#include "openair2/PHY_INTERFACE/IF_Module_NB_IoT.h"
|
||||
@@ -452,9 +452,6 @@ typedef struct {
|
||||
int sub_frame_start;
|
||||
///
|
||||
int sub_frame_step;
|
||||
///
|
||||
unsigned long long gotIQs;
|
||||
|
||||
} UE_rxtx_proc_NB_IoT_t;
|
||||
|
||||
/// Context data structure for eNB subframe processing
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "common_lib.h"
|
||||
#include "openairinterface5g_limits.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "defs_common.h"
|
||||
#include "nfapi_nr_interface_scf.h"
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#include "defs_common.h"
|
||||
#include "impl_defs_top.h"
|
||||
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "PHY/CODING/coding_defs.h"
|
||||
#include "PHY/TOOLS/tools_defs.h"
|
||||
#include "platform_types.h"
|
||||
@@ -154,7 +154,6 @@ typedef struct {
|
||||
|
||||
int sub_frame_start;
|
||||
int sub_frame_step;
|
||||
unsigned long long gotIQs;
|
||||
} UE_rxtx_proc_t;
|
||||
|
||||
/// Context data structure for eNB subframe processing
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#include "assertions.h"
|
||||
|
||||
//#include <complex.h>
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "platform_types.h"
|
||||
#define MAX_NUM_RU_PER_eNB 64
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#include "defs_common.h"
|
||||
#include "defs_RU.h"
|
||||
#include "impl_defs_top.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
//#include "PHY/CODING/coding_defs.h"
|
||||
#include "PHY/TOOLS/tools_defs.h"
|
||||
#include "platform_types.h"
|
||||
@@ -202,7 +202,7 @@ typedef struct {
|
||||
int repetition_number[4];
|
||||
} LTE_eNB_PRACH;
|
||||
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "PHY/CODING/coding_defs.h"
|
||||
#include "PHY/TOOLS/tools_defs.h"
|
||||
#include "PHY/LTE_TRANSPORT/transport_eNB.h"
|
||||
|
||||
@@ -779,7 +779,7 @@ typedef struct PHY_VARS_gNB_s {
|
||||
/// statistics for ULSCH measurement collection
|
||||
NR_gNB_SCH_STATS_t ulsch_stats[NUMBER_OF_NR_SCH_STATS_MAX];
|
||||
NR_gNB_UCI_STATS_t uci_stats[NUMBER_OF_NR_UCI_STATS_MAX];
|
||||
t_nrPolar_params *uci_polarParams;
|
||||
t_nrPolar_params **polarParams;
|
||||
|
||||
/// SRS variables
|
||||
nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX];
|
||||
@@ -856,7 +856,7 @@ typedef struct PHY_VARS_gNB_s {
|
||||
/*
|
||||
time_stats_t phy_proc;
|
||||
*/
|
||||
time_stats_t *phy_proc_tx[2];
|
||||
time_stats_t phy_proc_tx;
|
||||
time_stats_t phy_proc_rx;
|
||||
time_stats_t rx_prach;
|
||||
/*
|
||||
@@ -973,7 +973,6 @@ typedef struct processingData_L1tx {
|
||||
uint16_t num_pdsch_slot;
|
||||
int num_dl_pdcch;
|
||||
int num_ul_pdcch;
|
||||
time_stats_t phy_proc_tx;
|
||||
} processingData_L1tx_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
#include "impl_defs_top.h"
|
||||
#include "impl_defs_nr.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "time_meas.h"
|
||||
#include "PHY/CODING/coding_defs.h"
|
||||
#include "PHY/TOOLS/tools_defs.h"
|
||||
#include "platform_types.h"
|
||||
@@ -814,7 +814,6 @@ typedef struct {
|
||||
|
||||
fapi_nr_config_request_t nrUE_config;
|
||||
|
||||
t_nrPolar_params *polarList;
|
||||
NR_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX+1]; // two RxTx Threads
|
||||
NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
|
||||
|
||||
@@ -387,8 +387,6 @@ struct NR_DL_FRAME_PARMS {
|
||||
uint8_t N_ssb;
|
||||
/// SSB index
|
||||
uint8_t ssb_index;
|
||||
/// PBCH polar encoder params
|
||||
t_nrPolar_params pbch_polar_params;
|
||||
/// OFDM symbol offset divisor for UL
|
||||
uint32_t ofdm_offset_divisor;
|
||||
};
|
||||
|
||||
@@ -62,7 +62,6 @@ typedef struct {
|
||||
|
||||
int sub_frame_start;
|
||||
int sub_frame_step;
|
||||
unsigned long long gotIQs;
|
||||
uint8_t decoder_thread_available1;
|
||||
int dci_err_cnt;
|
||||
} UE_nr_rxtx_proc_t;
|
||||
|
||||
Reference in New Issue
Block a user