diff --git a/ci-scripts/oai-ci-vm-tool b/ci-scripts/oai-ci-vm-tool index ed43e26729e23738b76e4fd9fb063f87518fe3b3..3d9fb87cba007815c3413a8881ad151b15d5f325 100755 --- a/ci-scripts/oai-ci-vm-tool +++ b/ci-scripts/oai-ci-vm-tool @@ -252,7 +252,7 @@ case $key in VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim LOG_PATTERN=.Rel15.txt - NB_PATTERN_FILES=9 + NB_PATTERN_FILES=10 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=8192 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" @@ -331,7 +331,7 @@ case $key in VM_NAME=ci-phy-sim ARCHIVES_LOC=phy_sim LOG_PATTERN=.Rel15.txt - NB_PATTERN_FILES=9 + NB_PATTERN_FILES=10 BUILD_OPTIONS="--phy_simulators" VM_MEMORY=8192 RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index cb9c181a94a237d3de4f8af9802e3926807a021e..d5c5c10d64efde02ceb35d0c9563deb3a7ec7d2d 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1116,15 +1116,19 @@ set(PHY_POLARSRC ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_procedures.c ${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c ) +set(PHY_SMALLBLOCKSRC + ${OPENAIR1_DIR}/PHY/CODING/nrSmallBlock/encodeSmallBlock.c + ${OPENAIR1_DIR}/PHY/CODING/nrSmallBlock/decodeSmallBlock.c +) set(PHY_TURBOIF ${OPENAIR1_DIR}/PHY/CODING/coding_load.c - ) +) set(PHY_LDPCSRC ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c - ) +) add_library(coding MODULE ${PHY_TURBOSRC} ) set(PHY_SRC_COMMON @@ -1290,6 +1294,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c ${OPENAIR1_DIR}/PHY/TOOLS/lut.c ${PHY_POLARSRC} + ${PHY_SMALLBLOCKSRC} ${PHY_LDPCSRC} ) @@ -1334,6 +1339,7 @@ set(PHY_SRC_UE ${OPENAIR1_DIR}/PHY/INIT/nr_init_ue.c # ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c ${PHY_POLARSRC} + ${PHY_SMALLBLOCKSRC} ${PHY_LDPCSRC} ) @@ -2513,6 +2519,12 @@ add_executable(polartest ${OPENAIR_DIR}/common/utils/backtrace.c) target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) + +add_executable(smallblocktest + ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c + ${OPENAIR_DIR}/common/utils/backtrace.c) +target_link_libraries(smallblocktest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) + add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c ${OPENAIR_DIR}/common/utils/backtrace.c) diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml index 500312596743d857b4e0db3ec7799c7f99f0a91d..792e46cec630622fd3ebdb926487b862a5e9ce97 100644 --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1116,8 +1116,31 @@ <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false> <nruns>3</nruns> </testCase> - + <testCase id="015107"> + <class>execution</class> + <desc>shortblocktest Test cases. (Test1: 3 bits), + (Test2: 6 bits), + (Test3: 7 bits), + (Test4: 11 bits)</desc> + <pre_compile_prog></pre_compile_prog> + <compile_prog>$OPENAIR_DIR/cmake_targets/build_oai</compile_prog> + <compile_prog_args> --phy_simulators -c </compile_prog_args> + <pre_exec>$OPENAIR_DIR/cmake_targets/autotests/tools/free_mem.bash</pre_exec> + <pre_exec_args></pre_exec_args> + <main_exec> $OPENAIR_DIR/targets/bin/smallblocktest.Rel15</main_exec> + <main_exec_args>-l 3 -s -4 -d 1 -i 10000 + -l 6 -s -4 -d 1 -i 10000 + -l 7 -s -4 -d 1 -i 10000 + -l 11 -s -4 -d 1 -i 10000</main_exec_args> + <tags>smallblocktest.test1 smallblocktest.test2 smallblocktest.test3 smallblocktest.test4</tags> + <search_expr_true>BLER= 0.000000</search_expr_true> + <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false> + <nruns>3</nruns> + </testCase> + + + <testCase id="015108"> <class>execution</class> <desc>nr_ulschsim Test cases. (Test1: 106 PRB), (Test2: 217 PRB), diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index ba7fdc6cb0e611115d583a66bca9eaa5dcc59a65..e99d84a134d1bec38c40d7252e8198f313e532f3 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -80,8 +80,6 @@ function print_help() { This program installs OpenAirInterface Software You should have ubuntu 16.xx or 18.04 updated Options --h - This help -c | --clean Erase all files to make a rebuild from start -C | --clean-all @@ -686,7 +684,7 @@ function main() { echo_info "Compiling unitary tests simulators" # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" - simlist="dlsim ulsim polartest ldpctest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim" + simlist="dlsim ulsim polartest ldpctest smallblocktest nr_pbchsim nr_dlschsim nr_dlsim nr_ulschsim" for f in $simlist ; do compilations \ phy_simulators $f \ diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 8c5d33975c83673253eaaecf85a6086c776b9d11..1c4b291069ed7550c8593565979b68d21abdcdbd 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -683,7 +683,7 @@ install_asn1c_from_source(){ # better to use a given commit than a branch in case the branch # is updated and requires modifications in the source of OAI #git checkout velichkov_s1ap_plus_option_group - git checkout d3aed06bb2bec7df1b5c6d0333f8c7dfc5993372 + git checkout f12568d617dbf48497588f8e227d70388fa217c9 autoreconf -iv ./configure make -j`nproc` diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 8390c3af25a14e394826f5d5cf42fd2ddea5883e..b8a72ece7b892356af65bfba0b2fa7a1cf4a9313 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -83,11 +83,11 @@ extern "C" { * @brief LOG defines 9 levels of messages for users. Importance of these levels decrease gradually from 0 to 8 * @{*/ # define OAILOG_DISABLE -1 /*!< \brief disable all LOG messages, cannot be used in LOG macros, use only in LOG module */ -# define OAILOG_ERR 0 /*!< \brief critical error conditions, impact on "must have" fuctinalities */ +# define OAILOG_ERR 0 /*!< \brief critical error conditions, impact on "must have" functionalities */ # define OAILOG_WARNING 1 /*!< \brief warning conditions, shouldn't happen but doesn't impact "must have" functionalities */ # define OAILOG_INFO 2 /*!< \brief informational messages most people don't need, shouldn't impact real-time behavior */ -# define OAILOG_DEBUG 3 /*!< \brief first level debug-level messages, for developers , may impact real-time behavior */ -# define OAILOG_TRACE 4 /*!< \brief second level debug-level messages, for developers ,likely impact real-time behavior*/ +# define OAILOG_DEBUG 3 /*!< \brief first level debug-level messages, for developers, may impact real-time behavior */ +# define OAILOG_TRACE 4 /*!< \brief second level debug-level messages, for developers, likely impact real-time behavior*/ #define NUM_LOG_LEVEL 5 /*!< \brief the number of message levels users have with LOG (OAILOG_DISABLE is not available to user as a level, so it is not included)*/ /* @}*/ diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 1b46cab3c1963c065e4919ba9729af516e4aa9f2..76cde6c3bec0fa399f9af3be811c95b5e1153b35 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,116 +11,137 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" +//#include "PHY/NR_TRANSPORT/nr_transport.h" +//#include "common/utils/LOG/log.h" //#define DEBUG_DCI_POLAR_PARAMS //#define DEBUG_POLAR_TIMING -//#define DEBUG_CRC +//#define DEBUG_POLARTEST int main(int argc, char *argv[]) { - //Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.) - time_stats_t timeEncoder,timeDecoder; - opp_enabled=1; - int decoder_int16=0; - cpu_freq_GHz = get_cpu_freq_GHz(); - reset_meas(&timeEncoder); - reset_meas(&timeDecoder); - randominit(0); - crcTableInit(); //Default simulation values (Aim for iterations = 1000000.) + int decoder_int16=0; int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB double SNR, SNR_lin; int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). uint32_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error. - uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0; + uint16_t testLength = NR_POLAR_PBCH_PAYLOAD_BITS, coderLength = NR_POLAR_PBCH_E; + uint16_t blockErrorCumulative=0, bitErrorCumulative=0; double timeEncoderCumulative = 0, timeDecoderCumulative = 0; - uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0; + uint8_t aggregation_level = 8, decoderListSize = 8, logFlag = 0; + uint16_t rnti=0; - while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:hqg")) != -1) + while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) switch (arguments) { - case 's': - SNRstart = atof(optarg); - break; - - case 'd': - SNRinc = atof(optarg); - break; - - case 'f': - SNRstop = atof(optarg); - break; - - case 'm': - polarMessageType = atoi(optarg); - break; - - case 'i': - iterations = atoi(optarg); - break; - - case 'l': - decoderListSize = (uint8_t) atoi(optarg); - break; - - case 'a': - pathMetricAppr = (uint8_t) atoi(optarg); - break; - - case 'q': - decoder_int16 = 1; - break; - - case 'g': - iterations = 1; - SNRstart = -6.0; - SNRstop = -6.0; - decoder_int16 = 1; - break; - - case 'h': - printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr\n"); - exit(-1); - - default: - perror("[polartest.c] Problem at argument parsing with getopt"); - exit(-1); + case 's': + SNRstart = atof(optarg); + break; + + case 'd': + SNRinc = atof(optarg); + break; + + case 'f': + SNRstop = atof(optarg); + break; + + case 'm': + polarMessageType = atoi(optarg); + if (polarMessageType!=0 && polarMessageType!=1 && polarMessageType!=2) + printf("Illegal polar message type %d (should be 0,1 or 2)\n", polarMessageType); + break; + + case 'i': + iterations = atoi(optarg); + break; + + case 'l': + decoderListSize = (uint8_t) atoi(optarg); + break; + + case 'q': + decoder_int16 = 1; + break; + + case 'g': + iterations = 1; + SNRstart = -6.0; + SNRstop = -6.0; + decoder_int16 = 1; + break; + + case 'F': + logFlag = 1; + break; + + case 'L': + aggregation_level=atoi(optarg); + if (aggregation_level != 1 && aggregation_level != 2 && aggregation_level != 4 && aggregation_level != 8 && aggregation_level != 16) { + printf("Illegal aggregation level %d \n",aggregation_level); + exit(-1); + } + break; + + case 'k': + testLength=atoi(optarg); + if (testLength < 12 || testLength > 60) { + printf("Illegal packet bitlength %d \n",testLength); + exit(-1); + } + break; + + case 'h': + printf("./polartest\nOptions\n-h Print this help\n-s SNRstart (dB)\n-d SNRinc (dB)\n-f SNRstop (dB)\n-m [0=PBCH|1=DCI|2=UCI]\n" + "-i Number of iterations\n-l decoderListSize\n-q Flag for optimized coders usage\n-F Flag for test results logging\n" + "-L aggregation level (for DCI)\n-k packet_length (bits) for DCI/UCI\n"); + exit(-1); + break; + + default: + perror("[polartest.c] Problem at argument parsing with getopt"); + exit(-1); + break; } + //Initiate timing. (Results depend on CPU Frequency. Therefore, might change due to performance variances during simulation.) + time_stats_t timeEncoder,timeDecoder; + opp_enabled=1; + cpu_freq_GHz = get_cpu_freq_GHz(); + reset_meas(&timeEncoder); + reset_meas(&timeDecoder); + randominit(0); + crcTableInit(); + if (polarMessageType == 0) { //PBCH - testLength = 64;//NR_POLAR_PBCH_PAYLOAD_BITS; - coderLength = NR_POLAR_PBCH_E; - aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; + aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL; } else if (polarMessageType == 1) { //DCI - //testLength = nr_get_dci_size(params_rel15->dci_format, params_rel15->rnti_type, &fp->initial_bwp_dl, cfg); - testLength = 41; //20; - coderLength = 108*8; //to be changed by aggregate level function. + coderLength = 108*aggregation_level; } else if (polarMessageType == -1) { //UCI - //testLength = ; - //coderLength = ; + printf("UCI testing not supported yet\n"); + exit(-1); } //Logging time_t currentTime; - time (¤tTime); char fileName[512], currentTimeInfo[25]; char folderName[] = "."; - /* - folderName=getenv("HOME"); - strcat(folderName,"/Desktop/polartestResults"); - */ + FILE *logFile; + /*folderName=getenv("HOME"); + strcat(folderName,"/Desktop/polartestResults");*/ + +if (logFlag){ + time (¤tTime); #ifdef DEBUG_POLAR_TIMING - sprintf(fileName,"%s/TIMING_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); + sprintf(fileName,"%s/TIMING_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); #else - sprintf(fileName,"%s/_ListSize_%d_pmAppr_%d_Payload_%d_Itr_%d",folderName,decoderListSize,pathMetricAppr,testLength,iterations); + sprintf(fileName,"%s/_ListSize_%d_Payload_%d_Itr_%d", folderName, decoderListSize, testLength, iterations); #endif strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(¤tTime)); strcat(fileName,currentTimeInfo); //Create "~/Desktop/polartestResults" folder if it doesn't already exist. - /* - struct stat folder = {0}; - if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO); - */ - FILE *logFile; + /*struct stat folder = {0}; + if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/ logFile = fopen(fileName, "w"); if (logFile==NULL) { @@ -129,11 +150,12 @@ int main(int argc, char *argv[]) { } #ifdef DEBUG_POLAR_TIMING - fprintf(logFile, - ",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); + fprintf(logFile,",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n"); #else fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); #endif +} + uint8_t testArrayLength = ceil(testLength / 32.0); uint8_t coderArrayLength = ceil(coderLength / 32.0); uint32_t testInput[testArrayLength]; //generate randomly @@ -146,253 +168,156 @@ int main(int argc, char *argv[]) { 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); + #ifdef DEBUG_DCI_POLAR_PARAMS uint32_t dci_pdu[4]; memset(dci_pdu,0,sizeof(uint32_t)*4); dci_pdu[0]=0x01189400; - printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); - uint32_t encoder_output[54]; - memset(encoder_output,0,sizeof(uint32_t)*54); + printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_pdu[0], dci_pdu[1], dci_pdu[2], dci_pdu[3]); uint16_t size=41; - uint16_t rnti=3; + rnti=3; aggregation_level=8; + uint32_t encoder_output[54]; + memset(encoder_output,0,sizeof(uint32_t)*54); t_nrPolar_params *currentPtrDCI=nr_polar_params(1, size, aggregation_level); - polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); - for (int i=0; i<54; i++) - printf("encoder_output: [%2d]->0x%08x \n",i, encoder_output[i]); + polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti); + for (int i=0; i<54; i++) printf("encoder_output: [%2d]->0x%08x \n", i, encoder_output[i]); uint8_t *encoder_outputByte = malloc(sizeof(uint8_t) * currentPtrDCI->encoderLength); - double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); - uint32_t dci_estimation[4]; - memset(dci_estimation,0,sizeof(uint32_t)*4); - printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); - nr_bit2byte_uint32_8_t(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); + double *modulated_input = malloc (sizeof(double) * currentPtrDCI->encoderLength); + double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); + uint32_t dci_est[4]; + memset(dci_est,0,sizeof(uint32_t)*4); + 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]); + nr_bit2byte_uint32_8(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); printf("[polartest] encoder_outputByte: "); + for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); printf("\n"); - for (int i = 0; i < currentPtrDCI->encoderLength; i++) printf("%d-", encoder_outputByte[i]); - - printf("\n"); - + SNR_lin = pow(10, 0/10); //SNR = 0 dB for(int i=0; i<currentPtrDCI->encoderLength; i++) { - if (encoder_outputByte[i] == 0) { - channel_output[i]=1/sqrt(2); - } else { - channel_output[i]=(-1)/sqrt(2); - } + if (encoder_outputByte[i] == 0) + modulated_input[i]=1/sqrt(2); + else + 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_estimation, - currentPtrDCI, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - rnti); - printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); + decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, rnti); + 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); + free(modulated_input); return 0; #endif -#ifdef DEBUG_CRC - uint32_t crc; - unsigned int poly24c = 0xb2b11700; - uint32_t testInputCRC[4]; - testInputCRC[0]=0x00291880; - //testInputCRC[0]=0x01189400; - testInputCRC[1]=0x00000000; - testInputCRC[2]=0x00000000; - testInputCRC[3]=0x00000000; - uint32_t testInputcrc=0x01189400; - uint32_t testInputcrc2=0x00291880; - uint8_t testInputCRC2[8]; - nr_crc_bit2bit_uint32_8_t(testInputCRC, 32, testInputCRC2); - printf("testInputCRC2: [0]->%x \t [1]->%x \t [2]->%x \t [3]->%x\n" - " [4]->%x \t [5]->%x \t [6]->%x \t [7]->%x\n", - testInputCRC2[0], testInputCRC2[1], testInputCRC2[2], testInputCRC2[3], - testInputCRC2[4], testInputCRC2[5], testInputCRC2[6], testInputCRC2[7]); - unsigned int crc41 = crc24c(testInputCRC, 32); - unsigned int crc65 = crc24c(testInputCRC, 56); - printf("crc41: [0]->0x%08x\tcrc65: [0]->0x%08x\n",crc41, crc65); - - for (int i=0; i<32; i++) printf("crc41[%d]=%d\tcrc65[%d]=%d\n",i,(crc41>>i)&1,i,(crc65>>i)&1); - - crc = crc24c(testInputCRC, testLength)>>8; - - for (int i=0; i<24; i++) printf("[i]=%d\n",(crc>>i)&1); - - printf("crc: [0]->0x%08x\n",crc); - //crcbit(testInputCRC, sizeof(test) - 1, poly24c)); - testInputCRC[testLength>>3] = ((uint8_t *)&crc)[2]; - testInputCRC[1+(testLength>>3)] = ((uint8_t *)&crc)[1]; - testInputCRC[2+(testLength>>3)] = ((uint8_t *)&crc)[0]; - printf("testInputCRC: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", - testInputCRC[0], testInputCRC[1], testInputCRC[2], testInputCRC[3]); - //uint32_t trial32 = 0xffffffff; - uint32_t trial32 = 0xf10fffff; - uint8_t a[4]; - //memcpy(a, &trial32, sizeof(trial32)); - *(uint32_t *)a = trial32; - unsigned char trial[4]; - trial[0]=0xff; - trial[1]=0xff; - trial[2]=0x0f; - trial[3]=0xf1; - uint32_t trialcrc = crc24c(trial, 32); - uint32_t trialcrc32 = crc24c((uint8_t *)&trial32, 32); - //uint32_t trialcrc32 = crc24c(a, 32); - printf("crcbit(trial = %x\n", crcbit(trial, 4, poly24c)); - printf("trialcrc = %x\n", trialcrc); - printf("trialcrc32 = %x\n", trialcrc32); - - for (int i=0; i<32; i++) printf("trialcrc[%2d]=%d\ttrialcrc32[%2d]=%d\n",i,(trialcrc>>i)&1,i,(trialcrc32>>i)&1); - - //uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; - uint8_t nr_polar_A[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1}; - uint8_t nr_polar_crc[24]; - uint8_t **crc_generator_matrix = crc24c_generator_matrix(32); - nr_matrix_multiplication_uint8_1D_uint8_2D(nr_polar_A, - crc_generator_matrix, - nr_polar_crc, - 32, - 24); - - for (uint8_t i = 0; i < 24; i++) { - nr_polar_crc[i] = (nr_polar_crc[i] % 2); - printf("nr_polar_crc[%d]=%d\n",i,nr_polar_crc[i]); - } - - return 0; -#endif -#ifdef DEBUG_POLAR_TIMING for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { - SNR_lin = pow(10, SNR / 10); - - for (itr = 1; itr <= iterations; itr++) { - for (int j=0; j<ceil(testLength / 32.0); j++) { - for(int i=0; i<32; i++) { - testInput[j] |= ( ((uint32_t) (rand()%2)) &1); - testInput[j]<<=1; - } - } - - printf("testInput: [0]->0x%08x \n", testInput[0]); - polar_encoder_timing(testInput, encoderOutput, currentPtr, cpu_freq_GHz, logFile); - } - } - - fclose(logFile); - free(testInput); - free(encoderOutput); - free(modulatedInput); - free(channelOutput); - free(estimatedOutput); - return (0); + printf("SNR %f\n",SNR); + SNR_lin = pow(10, SNR/10); + + for (itr = 1; itr <= iterations; itr++) { + //Generate random values for all the bits of "testInput", not just as much as "currentPtr->payloadBits". + for (int i = 0; i < testArrayLength; i++) { + for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) { + testInput[i] |= ( ((uint32_t) (rand()%2)) &1); + testInput[i]<<=1; + } + testInput[i] |= ( ((uint32_t) (rand()%2)) &1); + } + +#ifdef DEBUG_POLARTEST + //testInput[0] = 0x360f8a5c; + printf("testInput: [0]->0x%08x\n", testInput[0]); +#endif + int len_mod64=currentPtr->payloadBits&63; + ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<<len_mod64)-1); + + start_meas(&timeEncoder); + if (decoder_int16==1) { + polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, currentPtr); + //polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0, currentPtr); + } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI + if (polarMessageType == 0) + polar_encoder(testInput, encoderOutput, currentPtr); + else if (polarMessageType == 1) + polar_encoder_dci(testInput, encoderOutput, currentPtr, rnti); + } + stop_meas(&timeEncoder); + +#ifdef DEBUG_POLARTEST + printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); + //for (int i=1;i<coderArrayLength;i++) printf("encoderOutput: [i]->0x%08x\n", i, encoderOutput[1]); #endif - // We assume no a priori knowledge available about the payload. - double aPrioriArray[currentPtr->payloadBits]; - - for (int i=0; i<currentPtr->payloadBits; i++) aPrioriArray[i] = NAN; - - for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { - printf("SNR %f\n",SNR); - SNR_lin = pow(10, SNR/10); - - for (itr = 1; itr <= iterations; itr++) { - for (int i = 0; i < testArrayLength; i++) { - for (int j = 0; j < (sizeof(testInput[0])*8)-1; j++) { - testInput[i] |= ( ((uint32_t) (rand()%2)) &1); - testInput[i]<<=1; - } - - testInput[i] |= ( ((uint32_t) (rand()%2)) &1); - } - /*printf("testInput: [0]->0x%08x\n", testInput[0]); - for (int i=0; i<32; i++) - printf("%d\n",(testInput[0]>>i)&1);*/ - int len_mod64=currentPtr->payloadBits&63; - ((uint64_t *)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<<len_mod64)-1); - start_meas(&timeEncoder); - - if (decoder_int16==0) - polar_encoder(testInput, encoderOutput, currentPtr); - else - polar_encoder_fast((uint64_t *)testInput, encoderOutput,0, currentPtr); - - //polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0, currentPtr); - stop_meas(&timeEncoder); - /*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]); - printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/ //Bit-to-byte: - nr_bit2byte_uint32_8_t(encoderOutput, coderLength, encoderOutputByte); + nr_bit2byte_uint32_8(encoderOutput, coderLength, encoderOutputByte); //BPSK modulation for(int i=0; i<coderLength; i++) { - if (encoderOutputByte[i] == 0) - modulatedInput[i]=1/sqrt(2); - else - modulatedInput[i]=(-1)/sqrt(2); - - channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); - - if (decoder_int16==1) { - if (channelOutput[i] > 15) channelOutput_int16[i] = 127; - else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; - else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); - } + if (encoderOutputByte[i] == 0) + modulatedInput[i]=1/sqrt(2); + else + modulatedInput[i]=(-1)/sqrt(2); + + channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin))); + + if (decoder_int16==1) { + if (channelOutput[i] > 15) channelOutput_int16[i] = 127; + else if (channelOutput[i] < -16) channelOutput_int16[i] = -128; + else channelOutput_int16[i] = (int16_t) (8*channelOutput[i]); + } } start_meas(&timeDecoder); - /*decoderState = polar_decoder(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - aPrioriArray, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/ - if (decoder_int16==0) - decoderState = polar_decoder_aPriori(channelOutput, - estimatedOutput, - currentPtr, - NR_POLAR_DECODER_LISTSIZE, - NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION, - aPrioriArray); - else - decoderState = polar_decoder_int16(channelOutput_int16, - (uint64_t *)estimatedOutput, - currentPtr); - + if (decoder_int16==1) { + decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, currentPtr); + } else { //0 --> PBCH, 1 --> DCI, -1 --> UCI + if (polarMessageType == 0) { + decoderState = polar_decoder(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize); + } else if (polarMessageType == 1) { + decoderState = polar_decoder_dci(channelOutput, + estimatedOutput, + currentPtr, + decoderListSize, + rnti); + } + } stop_meas(&timeDecoder); - /*printf("testInput: [0]->0x%08x\n", testInput[0]); - printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/ + +#ifdef DEBUG_POLARTEST + printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]); +#endif //calculate errors if (decoderState!=0) { - blockErrorState=-1; - nBitError=-1; + blockErrorState=-1; + nBitError=-1; } else { - for (int j = 0; j < currentPtr->payloadBits; j++) { - if (((estimatedOutput[0]>>j) & 1) != ((testInput[0]>>j) & 1)) nBitError++; - - // printf("bit %d: %d => %d\n",j,(testInput[0]>>j)&1,(estimatedOutput[0]>>j)&1); - } - - if (nBitError>0) { - blockErrorState=1; - // printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]); - } + for (int i = 0; i < (testArrayLength-1); i++) { + for (int j = 0; j < 32; j++) { + if ( ((estimatedOutput[i]>>j) & 1) != ((testInput[i]>>j) & 1) ) + nBitError++; + } + } + for (int j = 0; j < testLength - ((testArrayLength-1) * 32); j++) + if ( ((estimatedOutput[(testArrayLength-1)]>>j) & 1) != ((testInput[(testArrayLength-1)]>>j) & 1) ) + nBitError++; } + if (nBitError>0) blockErrorState=1; +#ifdef DEBUG_POLARTEST + for (int i = 0; i < testArrayLength; i++) + printf("[polartest/decoderState=%d] testInput[%d]=0x%08x, estimatedOutput[%d]=0x%08x\n",decoderState, i, testInput[i], i, estimatedOutput[i]); +#endif //Iteration times are in microseconds. timeEncoderCumulative+=(timeEncoder.diff/(cpu_freq_GHz*1000.0)); timeDecoderCumulative+=(timeDecoder.diff/(cpu_freq_GHz*1000.0)); - fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, - (timeEncoder.diff/(cpu_freq_GHz*1000.0)), (timeDecoder.diff/(cpu_freq_GHz*1000.0))); + if (logFlag) fprintf(logFile,",%f,%d,%d,%f,%f\n", SNR, nBitError, blockErrorState, (timeEncoder.diff/(cpu_freq_GHz*1000.0)), (timeDecoder.diff/(cpu_freq_GHz*1000.0))); if (nBitError<0) { blockErrorCumulative++; @@ -405,17 +330,19 @@ int main(int argc, char *argv[]) { decoderState=0; nBitError=0; blockErrorState=0; + memset(testInput,0,sizeof(uint32_t) * testArrayLength); + memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength); + memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength); } //Calculate error statistics for the SNR. - printf("[ListSize=%d, Appr=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%9.3fus, t_Decoder=%9.3fus\n", - decoderListSize, pathMetricAppr, SNR, ((double)blockErrorCumulative/iterations), + printf("[ListSize=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%9.3fus, t_Decoder=%9.3fus\n", + decoderListSize, SNR, ((double)blockErrorCumulative/iterations), ((double)bitErrorCumulative / (iterations*testLength)), (double)timeEncoder.diff/timeEncoder.trials/(cpu_freq_GHz*1000.0),(double)timeDecoder.diff/timeDecoder.trials/(cpu_freq_GHz*1000.0)); //(timeEncoderCumulative/iterations),timeDecoderCumulative/iterations); - if (blockErrorCumulative==0 && bitErrorCumulative==0) - break; + if (blockErrorCumulative==0 && bitErrorCumulative==0) break; blockErrorCumulative = 0; bitErrorCumulative = 0; @@ -425,6 +352,6 @@ int main(int argc, char *argv[]) { print_meas(&timeEncoder,"polar_encoder",NULL,NULL); print_meas(&timeDecoder,"polar_decoder",NULL,NULL); - fclose(logFile); + if (logFlag) fclose(logFile); return (0); } diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c new file mode 100644 index 0000000000000000000000000000000000000000..ee1a228ab80fb28af4618e52f4627309d5dd2012 --- /dev/null +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -0,0 +1,166 @@ +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" +#include "SIMULATION/TOOLS/sim.h" +#include <getopt.h> + +//#define DEBUG_SMALLBLOCKTEST + +signed char quantize(double D, double x, unsigned char B) +{ + double qxd; + short maxlev; + qxd = floor(x/D); + + maxlev = 1<<(B-1);//(char)(pow(2,B-1)); + + if (qxd <= -maxlev) + qxd = -maxlev; + else if (qxd >= maxlev) + qxd = maxlev-1; + + return((char)qxd); +} + +int main(int argc, char *argv[]) { + + time_stats_t timeEncoder,timeDecoder; + opp_enabled=1; + cpu_freq_GHz = get_cpu_freq_GHz(); + reset_meas(&timeEncoder); + reset_meas(&timeDecoder); + randominit(0); + + int arguments, iterations = 1000, messageLength = 11; + //int matlabDebug = 0; + uint32_t testInput, encoderOutput, codingDifference, nBitError=0, blockErrorState = 0, blockErrorCumulative=0, bitErrorCumulative=0; + uint16_t estimatedOutput; + double SNRstart = -20.0, SNRstop = 5.0, SNRinc= 0.5; //dB + double SNR, SNR_lin, sigma; + double modulatedInput[NR_SMALL_BLOCK_CODED_BITS], channelOutput[NR_SMALL_BLOCK_CODED_BITS]; + //int16_t channelOutput_int16[NR_SMALL_BLOCK_CODED_BITS]; + int8_t channelOutput_int8[NR_SMALL_BLOCK_CODED_BITS]; + unsigned char qbits=8; + + while ((arguments = getopt (argc, argv, "s:d:f:l:i:mhg")) != -1) + switch (arguments) + { + case 's': + SNRstart = atof(optarg); + break; + + case 'd': + SNRinc = atof(optarg); + break; + + case 'f': + SNRstop = atof(optarg); + break; + + case 'l': + messageLength = atoi(optarg); + break; + + case 'i': + iterations = atoi(optarg); + break; + + /*case 'm': + matlabDebug = 1; + //#define DEBUG_POLAR_MATLAB + break;*/ + + case 'g': + iterations = 1; + SNRstart = -6.0; + SNRstop = -6.0; + messageLength = 11; + break; + + case 'h': + //printf("./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations -m Matlab Debug\n"); + printf("./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations\n"); + exit(-1); + + default: + perror("[smallblocktest.c] Problem at argument parsing with getopt"); + exit(-1); + } + + + uint16_t mask = 0x07ff >> (11-messageLength); + for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) { + printf("SNR %f\n",SNR); + SNR_lin = pow(10, SNR/10.0); + sigma = 1.0/sqrt(SNR_lin); + + for (int itr = 1; itr <= iterations; itr++) { + + //Generate random test input of length "messageLength" + testInput = 0; + for (int i = 1; i < messageLength; i++) { + testInput |= ( ((uint32_t) (rand()%2)) &1); + testInput<<=1; + } + testInput |= ( ((uint32_t) (rand()%2)) &1); + //Encoding + start_meas(&timeEncoder); + encoderOutput = encodeSmallBlock((uint16_t*)&testInput, (uint8_t)messageLength); + stop_meas(&timeEncoder); + + for (int i=0; i<NR_SMALL_BLOCK_CODED_BITS; i++) { + //BPSK modulation + if ((encoderOutput>>i) & 1 ) { + modulatedInput[i]=-1; + } else { + modulatedInput[i]=1; + } + + //AWGN + channelOutput[i] = modulatedInput[i] + ( gaussdouble(0.0,1.0) * ( 1/sqrt(SNR_lin) ) ); + + //Quantization + channelOutput_int8[i] = quantize(sigma/16.0, channelOutput[i], qbits); + } + + //Decoding + start_meas(&timeDecoder); + estimatedOutput = decodeSmallBlock(channelOutput_int8, (uint8_t)messageLength); + stop_meas(&timeDecoder); + +#ifdef DEBUG_SMALLBLOCKTEST + printf("[smallblocktest] Input = 0x%x, Output = 0x%x, DecoderOutput = 0x%x\n", testInput, encoderOutput, estimatedOutput); + for (int i=0;i<32;i++) + printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, codingDifference[%d]=%d, Mask[%d] = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (codingDifference>>i)&1, i, (mask>>i)&1); +#endif + + //Error Calculation + estimatedOutput &= mask; + codingDifference = ((uint32_t)estimatedOutput) ^ testInput; // Count the # of 1's in codingDifference by Brian Kernighan’s algorithm. + + for (nBitError = 0; codingDifference; nBitError++) + codingDifference &= codingDifference - 1; + + blockErrorState = (nBitError > 0) ? 1 : 0; + + blockErrorCumulative+=blockErrorState; + bitErrorCumulative+=nBitError; + + nBitError = 0; blockErrorState = 0; + } + + //Error statistics for the SNR; iteration times are in nanoseconds and microseconds, respectively. + printf("[smallblocktest] SNR=%+7.3f, BER=%9.6f, BLER=%9.6f, t_Encoder=%9.3fns, t_Decoder=%7.3fus\n", + SNR, + ((double)bitErrorCumulative / (iterations*messageLength)), + ((double)blockErrorCumulative/iterations), + ((double)timeEncoder.diff/timeEncoder.trials)/(cpu_freq_GHz), + ((double)timeDecoder.diff/timeDecoder.trials)/(cpu_freq_GHz*1000.0)); + + blockErrorCumulative=0; + bitErrorCumulative=0; + } + + print_meas(&timeEncoder, "smallblock_encoder", NULL, NULL); + print_meas(&timeDecoder, "smallblock_decoder", NULL, NULL); + + return (0); +} diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 5e0ebeb991fa499dda5f1384ef6362313614bcee..ee5c302adb03264058bcfcf113deb5ad9719b3c9 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -106,17 +106,6 @@ void crcTableInit (void) } while (++c); } -//Generic version -void crcTable256Init (uint32_t poly, uint32_t* crc256Table) -{ - unsigned char c = 0; - - do { - crc256Table[c] = crcbit(&c, 1, poly); - } while (++c); - -} - /********************************************************* Byte by byte implementations, @@ -236,30 +225,10 @@ crc8 (unsigned char * inptr, int bitlen) return crc; } -//Generic version -unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table) -{ - int octetlen, resbit; - unsigned int crc = 0; - octetlen = bitlen/8; // Change in bytes - resbit = (bitlen % 8); - - while (octetlen-- > 0) - { - crc = (crc << 8) ^ crc256Table[(*inptr++) ^ (crc >> 24)]; - } - - if (resbit > 0) - { - crc = (crc << resbit) ^ crc256Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))]; - } - return crc; -} - int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type) { uint32_t crc=0,oldcrc=0; - uint8_t crc_len,temp; + uint8_t crc_len=0; switch (crc_type) { case CRC24_A: @@ -335,7 +304,7 @@ main() { unsigned char test[] = "Thebigredfox"; crcTableInit(); - printf("%x\n", crcbit(test, sizeof(test) - 1, poly24)); + printf("%x\n", crcbit(test, sizeof(test) - 1, poly24a)); printf("%x\n", crc24(test, (sizeof(test) - 1)*8)); printf("%x\n", crcbit(test, sizeof(test) - 1, poly8)); printf("%x\n", crc8(test, (sizeof(test) - 1)*8)); diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c deleted file mode 100644 index c7841880714e794cb636ffd03849ec8027ba29ce..0000000000000000000000000000000000000000 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.c +++ /dev/null @@ -1,117 +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 - */ - -#include <stdio.h> -#include "time_meas.h" -#include <math.h> -#include <unistd.h> - -// global var for openair performance profiler -extern int opp_enabled; - - -double get_cpu_freq_GHz(void) { - - 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->diff_now/(cpu_freq_GHz*1000000.0)),subframe,ts->diff_now); - fprintf(file_name,"%15.3f ms, diff_now %15.3f \n",(ts->diff_now/(cpu_freq_GHz*1000000.0)),(double)ts->diff_now); - - } - } -} - -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 ms ; %15.3f us; %15d;\n", - name, - (ts->diff/cpu_freq_GHz/1000000.0), - (ts->diff/ts->trials/cpu_freq_GHz/1000.0), - ts->trials); - } 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); - } - } - } - -} - -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; -} diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h deleted file mode 100644 index e6bec3117695fe37a0df182e15c949b814b31047..0000000000000000000000000000000000000000 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_tools/time_meas.h +++ /dev/null @@ -1,156 +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> -// global var to enable openair performance profiler -static int opp_enabled = 1; -double cpu_freq_GHz; -#if defined(__x86_64__) || defined(__i386__) - -typedef struct { - - long long in; - long long diff; - long long diff_now; - long long p_time; /*!< \brief absolute process duration */ - long long diff_square; /*!< \brief process duration square */ - long long max; - int trials; - int meas_flag; -} time_stats_t; -#elif defined(__arm__) -typedef struct { - uint32_t in; - uint32_t diff_now; - uint32_t diff; - uint32_t p_time; /*!< \brief absolute process duration */ - uint32_t diff_square; /*!< \brief process duration square */ - uint32_t max; - int trials; -} time_stats_t; - -#endif -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); -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 - -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(); - } - } -} - -static inline void stop_meas(time_stats_t *ts) -{ - - if (opp_enabled) { - long long out = rdtsc_oai(); - - ts->diff_now = (out-ts->in); - - ts->diff_now = (out-ts->in); - 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->trials=0; - ts->diff=0; - ts->diff_now=0; - ts->p_time=0; - ts->diff_square=0; - ts->max=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; - } -} - -#endif diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h index ae32f6ffb6f68c9ee1319950c7d89e31cdce1031..a61a15459c0b113901c96b3c9ca8d1ab734e2380 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h @@ -31,7 +31,7 @@ #ifndef __NR_LDPC_TYPES__H__ #define __NR_LDPC_TYPES__H__ -#include "./nrLDPC_tools/time_meas.h" +#include "PHY/TOOLS/time_meas.h" // ============================================================================== // TYPES diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c index beabeead36e2d4a5a741e2a7d4b899315795a358..fdba4e1b65fa41d222b7e26edb8f3773f6bed85e 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c @@ -19,9 +19,20 @@ * contact@openairinterface.org */ +/*!\file PHY/CODING/nrPolar_tools/nr_bitwise_operations.c + * \brief + * \author Turker Yilmaz + * \date 2018 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" -void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { +void nr_bit2byte_uint32_8(uint32_t *in, uint16_t arraySize, uint8_t *out) { uint8_t arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < (arrayInd-1); i++) { for (int j = 0; j < 32; j++) { @@ -29,10 +40,11 @@ void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { } } - for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; + for (int j = 0; j < arraySize - ((arrayInd-1) * 32); j++) + out[j + ((arrayInd-1) * 32)] = (in[(arrayInd-1)] >> j) & 1; } -void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { +void nr_byte2bit_uint8_32(uint8_t *in, uint16_t arraySize, uint32_t *out) { uint8_t arrayInd = ceil(arraySize / 32.0); for (int i = 0; i < arrayInd; i++) { out[i]=0; @@ -43,16 +55,3 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { out[i]|=in[(i*32)]; } } - -void nr_crc_bit2bit_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) { - out[0]=0xff; - out[1]=0xff; - out[2]=0xff; - uint8_t arrayInd = ceil(arraySize / 32.0); - for (int i = 0; i < arrayInd; i++) { - out[3+i*4] = ((in[i] & (0x0000000f))<<4) | ((in[i] & (0x000000f0))>>4); - out[4+i*4] = (((in[i] & (0x00000f00))<<4) | ((in[i] & (0x0000f000))>>4))>>8; - out[5+i*4] = (((in[i] & (0x000f0000))<<4) | ((in[i] & (0x00f00000))>>4))>>16; - out[6+i*4] = (((in[i] & (0x0f000000))<<4) | ((in[i] & (0xf0000000))>>4))>>24; - } -} diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c b/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c index ef329b3aaa73cde95d51616cc48a1a2955cb86f5..461eb7d6f699d577ab9df125c200a273546f3f05 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_crc_byte.c @@ -21,43 +21,36 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" - // ----- Old implementation ---- uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){ uint8_t crcPolynomialPattern[25] = {1,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,0,0,0,1,0,1,1,1}; // 1011 0010 1011 0001 0001 0111 D^24 + D^23 + D^21 + D^20 + D^17 + D^15 + D^13 + D^12 + D^8 + D^4 + D^2 + D + 1 - uint8_t crcPolynomialSize = 24;// 24 because crc24c + uint8_t crcPolynomialSize = 24; uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize]; uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); if (crc_generator_matrix) - { for (int i = 0; i < payloadSizeBits; i++) - { crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); - } - } 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]; + temp1[crcPolynomialSize-1]=0; - for (int j = 0; j < crcPolynomialSize; j++) temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; + for (int j = 0; j < crcPolynomialSize; j++) + temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; for (int j = 0; j < crcPolynomialSize; j++){ - if(temp1[j]+temp2[j] == 1){ + if(temp1[j]+temp2[j] == 1) crc_generator_matrix[i][j]=1; - } else { + else crc_generator_matrix[i][j]=0; - } } - } - return crc_generator_matrix; } @@ -70,30 +63,26 @@ uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits){ uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); if (crc_generator_matrix) - { for (int i = 0; i < payloadSizeBits; i++) - { crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); - } - } 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]; - for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1]; temp1[crcPolynomialSize-1]=0; - for (int j = 0; j < crcPolynomialSize; j++) temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; + for (int j = 0; j < crcPolynomialSize; j++) + temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; for (int j = 0; j < crcPolynomialSize; j++){ - if(temp1[j]+temp2[j] == 1){ + if(temp1[j]+temp2[j] == 1) crc_generator_matrix[i][j]=1; - } else { + else crc_generator_matrix[i][j]=0; - } } - } return crc_generator_matrix; @@ -105,33 +94,30 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits){ // 0110 0001 D^6 + D^5 + 1 uint8_t crcPolynomialSize = 6; uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize]; - uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); + if (crc_generator_matrix) - { for (int i = 0; i < payloadSizeBits; i++) - { crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); - } - } - 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]; - for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1]; temp1[crcPolynomialSize-1]=0; - for (int j = 0; j < crcPolynomialSize; j++) temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; + for (int j = 0; j < crcPolynomialSize; j++) + temp2[j]=crc_generator_matrix[i+1][0]*crcPolynomialPattern[j+1]; for (int j = 0; j < crcPolynomialSize; j++){ - if(temp1[j]+temp2[j] == 1){ + if(temp1[j]+temp2[j] == 1) crc_generator_matrix[i][j]=1; - } else { + else crc_generator_matrix[i][j]=0; - } } - } return crc_generator_matrix; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index cc90247c12c9bc1d0456cceec6c057b7a4ffcf73..66d0fc481c137ec1b85f5f776880f0b1cffadcb7 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -21,11 +21,11 @@ /*!\file PHY/CODING/nrPolar_tools/nr_polar_decoder.c * \brief - * \author Turker Yilmaz + * \author Raymond Knopp, Turker Yilmaz * \date 2018 * \version 0.1 * \company EURECOM - * \email turker.yilmaz@eurecom.fr + * \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr * \note * \warning */ @@ -39,12 +39,11 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" -int8_t polar_decoder( - double *input, - uint8_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr) { +int8_t polar_decoder(double *input, + uint32_t *out, + t_nrPolar_params *polarParams, + uint8_t listSize) +{ //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 @@ -118,12 +117,12 @@ int8_t polar_decoder( 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), pathMetricAppr); + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1)); if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit); } else { //Information or CRC bit. - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + updatePathMetric2(pathMetric, llr, currentListSize, currentBit); for (int i = 0; i < currentListSize; i++) { for (int j = 0; j < polarParams->N; j++) { @@ -293,567 +292,14 @@ int8_t polar_decoder( /* * Return bits. */ - //nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } -int8_t polar_decoder_aPriori(double *input, - uint32_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload) { - 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 - - for (int i=0; i<(2*listSize); i++) { - pathMetric[i] = 0; - crcState[i]=1; - } - - for (int i=0; i<polarParams->N; i++) { - llrUpdated[i][polarParams->n]=1; - 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)); - } - - for (int i=0; i<polarParams->payloadBits; i++) { - for (int j=0; j<polarParams->crcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; - } - } - - for (int i=polarParams->payloadBits; i<polarParams->K; i++) { - for (int j=0; j<polarParams->crcParityBits; j++) { - if( (i-polarParams->payloadBits) == j ) { - tempECGM[i][j]=1; - } else { - tempECGM[i][j]=0; - } - } - } - - for (int i=0; i<polarParams->K; i++) { - for (int j=0; j<polarParams->crcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; - } - } - - //The index of the last 1-valued bit that appears in each column. - uint16_t last1ind[polarParams->crcParityBits]; - - for (int j=0; j<polarParams->crcParityBits; j++) { - for (int i=0; i<polarParams->K; i++) { - if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; - } - } - - double *d_tilde = malloc(sizeof(double) * 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]; - - /* - * SCL polar decoder. - */ - uint32_t nonFrozenBit=0; - uint8_t currentListSize=1; - uint8_t decoderIterationCheck=0; - int16_t checkCrcBits=-1; - 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), pathMetricAppr); - - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 - } else { //Information or CRC bit. - if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { - //Information bit with known value of "0". - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); - bitUpdated[currentBit][0]=1; //0=False, 1=True - } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { - //Information bit with known value of "1". - updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); - - for (uint8_t i=0; i<currentListSize; i++) bit[currentBit][0][i]=1; - - bitUpdated[currentBit][0]=1; - updateCrcChecksum(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - } else { - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); - - for (int i = 0; i < currentListSize; i++) { - 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 = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; - - bitUpdated[currentBit][0]=1; - updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - currentListSize*=2; - - //Keep only the best "listSize" number of entries. - if (currentListSize > listSize) { - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - //sort listIndex[listSize, ..., 2*listSize-1] in descending order. - uint8_t swaps, tempInd; - - for (uint8_t i = 0; i < listSize; i++) { - swaps = 0; - - for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { - if (listIndex[j+1] > listIndex[j]) { - tempInd = listIndex[j]; - listIndex[j] = listIndex[j + 1]; - listIndex[j + 1] = tempInd; - swaps++; - } - } - - if (swaps == 0) - break; - } - - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; i<polarParams->N; i++) { - for (int j=0; j<(polarParams->n+1); j++) { - bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; - llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; - } - } - } - - for (int k=(listSize-1); k>0; k--) { - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; - } - } - - for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; - - //Copy the best "listSize" number of entries to the first indices. - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->N; i++) { - for (int j = 0; j < (polarParams->n + 1); j++) { - bit[i][j][k] = bit[i][j][copyIndex]; - llr[i][j][k] = llr[i][j][copyIndex]; - } - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - crcState[k]=crcState[copyIndex]; - } - - currentListSize = listSize; - } - } - - for (int i=0; i<polarParams->crcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; - break; - } - } - - if ( checkCrcBits > (-1) ) { - for (uint8_t i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]==1) { - crcState[i]=0; //0=False, 1=True - } - } - } - - 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); - return(-1); - } - - nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; - } - } - - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - - for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { - if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; - - //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - - //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) - polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; - - break; - } - } - - 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_t(polarParams->nr_polar_A, polarParams->payloadBits, out); - return(0); -} - - - -int8_t polar_decoder_aPriori_timing(double *input, - uint32_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload, - double cpuFreqGHz, - FILE *logFile) { - 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 - - for (int i=0; i<(2*listSize); i++) { - pathMetric[i] = 0; - crcState[i]=1; - } - - for (int i=0; i<polarParams->N; i++) { - llrUpdated[i][polarParams->n]=1; - 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)); - } - - for (int i=0; i<polarParams->payloadBits; i++) { - for (int j=0; j<polarParams->crcParityBits; j++) { - tempECGM[i][j]=polarParams->crc_generator_matrix[i][j]; - } - } - - for (int i=polarParams->payloadBits; i<polarParams->K; i++) { - for (int j=0; j<polarParams->crcParityBits; j++) { - if( (i-polarParams->payloadBits) == j ) { - tempECGM[i][j]=1; - } else { - tempECGM[i][j]=0; - } - } - } - - for (int i=0; i<polarParams->K; i++) { - for (int j=0; j<polarParams->crcParityBits; j++) { - extended_crc_generator_matrix[i][j]=tempECGM[polarParams->interleaving_pattern[i]][j]; - } - } - - //The index of the last 1-valued bit that appears in each column. - uint16_t last1ind[polarParams->crcParityBits]; - - for (int j=0; j<polarParams->crcParityBits; j++) { - for (int i=0; i<polarParams->K; i++) { - if (extended_crc_generator_matrix[i][j]==1) last1ind[j]=i; - } - } - - double *d_tilde = malloc(sizeof(double) * 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]; - - /* - * SCL polar decoder. - */ - uint32_t nonFrozenBit=0; - uint8_t currentListSize=1; - uint8_t decoderIterationCheck=0; - int16_t checkCrcBits=-1; - 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), pathMetricAppr); - - if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 - } else { //Information or CRC bit. - if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 0) ) { - //Information bit with known value of "0". - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); - bitUpdated[currentBit][0]=1; //0=False, 1=True - } else if ( (polarParams->interleaving_pattern[nonFrozenBit] <= polarParams->payloadBits) && - (aPrioriPayload[polarParams->interleaving_pattern[nonFrozenBit]] == 1) ) { - //Information bit with known value of "1". - updatePathMetric(pathMetric, llr, currentListSize, 1, currentBit, pathMetricAppr); - - for (uint8_t i=0; i<currentListSize; i++) bit[currentBit][0][i]=1; - - bitUpdated[currentBit][0]=1; - updateCrcChecksum(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - } else { - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); - - for (int i = 0; i < currentListSize; i++) { - 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 = currentListSize; i < 2*currentListSize; i++) bit[currentBit][0][i]=1; - - bitUpdated[currentBit][0]=1; - updateCrcChecksum2(crcChecksum, extended_crc_generator_matrix, currentListSize, nonFrozenBit, polarParams->crcParityBits); - currentListSize*=2; - - //Keep only the best "listSize" number of entries. - if (currentListSize > listSize) { - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - //sort listIndex[listSize, ..., 2*listSize-1] in descending order. - uint8_t swaps, tempInd; - - for (uint8_t i = 0; i < listSize; i++) { - swaps = 0; - - for (uint8_t j = listSize; j < (2*listSize - i) - 1; j++) { - if (listIndex[j+1] > listIndex[j]) { - tempInd = listIndex[j]; - listIndex[j] = listIndex[j + 1]; - listIndex[j + 1] = tempInd; - swaps++; - } - } - - if (swaps == 0) - break; - } - - //First, backup the best "listSize" number of entries. - for (int k=(listSize-1); k>0; k--) { - for (int i=0; i<polarParams->N; i++) { - for (int j=0; j<(polarParams->n+1); j++) { - bit[i][j][listIndex[(2*listSize-1)-k]]=bit[i][j][listIndex[k]]; - llr[i][j][listIndex[(2*listSize-1)-k]]=llr[i][j][listIndex[k]]; - } - } - } - - for (int k=(listSize-1); k>0; k--) { - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][listIndex[(2*listSize-1)-k]] = crcChecksum[i][listIndex[k]]; - } - } - - for (int k=(listSize-1); k>0; k--) crcState[listIndex[(2*listSize-1)-k]]=crcState[listIndex[k]]; - - //Copy the best "listSize" number of entries to the first indices. - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->N; i++) { - for (int j = 0; j < (polarParams->n + 1); j++) { - bit[i][j][k] = bit[i][j][copyIndex]; - llr[i][j][k] = llr[i][j][copyIndex]; - } - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - for (int i = 0; i < polarParams->crcParityBits; i++) { - crcChecksum[i][k]=crcChecksum[i][copyIndex]; - } - } - - for (int k = 0; k < listSize; k++) { - if (k > listIndex[k]) { - copyIndex = listIndex[(2*listSize-1)-k]; - } else { //Use the backup. - copyIndex = listIndex[k]; - } - - crcState[k]=crcState[copyIndex]; - } - - currentListSize = listSize; - } - } - - for (int i=0; i<polarParams->crcParityBits; i++) { - if (last1ind[i]==nonFrozenBit) { - checkCrcBits=i; - break; - } - } - - if ( checkCrcBits > (-1) ) { - for (uint8_t i = 0; i < currentListSize; i++) { - if (crcChecksum[checkCrcBits][i]==1) { - crcState[i]=0; //0=False, 1=True - } - } - } - - 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); - return(-1); - } - - nonFrozenBit++; - decoderIterationCheck=0; - checkCrcBits=-1; - } - } - - for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i; - - nr_sort_asc_double_1D_array_ind(pathMetric, listIndex, currentListSize); - - for (uint8_t i = 0; i < fmin(listSize, (pow(2,polarParams->crcCorrectionBits)) ); i++) { - if ( crcState[listIndex[i]] == 1 ) { - for (int j = 0; j < polarParams->N; j++) polarParams->nr_polar_U[j]=bit[j][0][listIndex[i]]; - - //Extract the information bits (û to ĉ) - nr_polar_info_bit_extraction(polarParams->nr_polar_U, polarParams->nr_polar_CPrime, polarParams->information_bit_pattern, polarParams->N); - //Deinterleaving (ĉ to b) - nr_polar_deinterleaver(polarParams->nr_polar_CPrime, polarParams->nr_polar_B, polarParams->interleaving_pattern, polarParams->K); - - //Remove the CRC (â) - for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j]; - - break; - } - } - - 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_t(polarParams->nr_polar_A, polarParams->payloadBits, out); - return(0); -} - - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_params *polarParams, uint8_t listSize, - uint8_t pathMetricAppr, 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 @@ -941,12 +387,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), pathMetricAppr); + updateLLR(llr, llrUpdated, bit, bitUpdated, currentListSize, currentBit, 0, polarParams->N, (polarParams->n+1)); if (polarParams->information_bit_pattern[currentBit]==0) { //Frozen bit. - updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit, pathMetricAppr); //approximation=0 --> 11b, approximation=1 --> 12 + updatePathMetric(pathMetric, llr, currentListSize, 0, currentBit); } else { //Information or CRC bit. - updatePathMetric2(pathMetric, llr, currentListSize, currentBit, pathMetricAppr); + updatePathMetric2(pathMetric, llr, currentListSize, currentBit); for (int i = 0; i < currentListSize; i++) { for (int j = 0; j < polarParams->N; j++) { @@ -1116,7 +562,7 @@ int8_t polar_decoder_dci(double *input, /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_A, polarParams->payloadBits, out); return(0); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c index a1a17a9d9e7500fa64502dee2fa8925a2ca8dc30..bf8a90e0d98844384c1722759f24b1dec9037de7 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c @@ -37,27 +37,26 @@ //#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, - uint8_t approximation) + 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, approximation); - if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen, approximation); + 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, approximation); - if(llrU[row+offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row+offset), (col+1), xlen, ylen, approximation); - computeLLR(llr, row, col, i, offset, approximation); + 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; @@ -73,7 +72,6 @@ void updateBit(uint8_t ***bit, uint16_t xlen, uint8_t ylen) { - uint16_t offset = ( xlen/(pow(2,(ylen-col))) ); for (uint8_t i=0; i<listSize; i++) { @@ -91,78 +89,47 @@ void updateBit(uint8_t ***bit, } void updatePathMetric(double *pathMetric, - double ***llr, + double ***llr, uint8_t listSize, uint8_t bitValue, - uint16_t row, - uint8_t approximation) + uint16_t row) { - if (approximation) { //eq. (12) - for (uint8_t i=0; i<listSize; i++) { - if ((2*bitValue) != ( 1 - copysign(1.0,llr[row][0][i]) )) pathMetric[i] += fabs(llr[row][0][i]); - } - } else { //eq. (11b) - int8_t multiplier = (2*bitValue) - 1; - for (uint8_t i=0; i<listSize; i++) pathMetric[i] += log ( 1 + exp(multiplier*llr[row][0][i]) ) ; - } -} + int8_t multiplier = (2*bitValue) - 1; + for (uint8_t i=0; i<listSize; i++) + pathMetric[i] += log ( 1 + exp(multiplier*llr[row][0][i]) ) ; //eq. (11b) +} void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, - uint16_t row, - uint8_t appr) + uint16_t row) { double *tempPM = malloc(sizeof(double) * listSize); - for (int i=0; i < listSize; i++) tempPM[i]=pathMetric[i]; - + memcpy(tempPM, pathMetric, (sizeof(double) * listSize)); uint8_t bitValue = 0; - if (appr) { //eq. (12) - for (uint8_t i = 0; i < listSize; i++) { - if ((2 * bitValue) != (1 - copysign(1.0, llr[row][0][i]))) pathMetric[i] += fabs(llr[row][0][i]); - } - } else { //eq. (11b) - int8_t multiplier = (2 * bitValue) - 1; - for (uint8_t i = 0; i < listSize; i++) pathMetric[i] += log(1 + exp(multiplier * llr[row][0][i])); - } + int8_t multiplier = (2 * bitValue) - 1; + for (uint8_t i = 0; i < listSize; i++) + pathMetric[i] += log(1 + exp(multiplier * llr[row][0][i])); //eq. (11b) bitValue = 1; - if (appr) { //eq. (12) - for (uint8_t i = listSize; i < 2*listSize; i++) { - if ((2 * bitValue) != (1 - copysign(1.0, llr[row][0][(i-listSize)]))) pathMetric[i] = tempPM[(i-listSize)] + fabs(llr[row][0][(i-listSize)]); - } - } else { //eq. (11b) - int8_t multiplier = (2 * bitValue) - 1; - for (uint8_t i = listSize; i < 2*listSize; i++) pathMetric[i] = tempPM[(i-listSize)] + log(1 + exp(multiplier * llr[row][0][(i-listSize)])); - } + multiplier = (2 * bitValue) - 1; + 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, - uint8_t approximation) + uint16_t offset) { double a = llr[row][col + 1][i]; - double absA = fabs(a); double b = llr[row + offset][col + 1][i]; - double absB = fabs(b); - - if (approximation || isinf(absA) || isinf(absB)) { //eq. (9) - llr[row][col][i] = copysign(1.0, a) * copysign(1.0, b) * fmin(absA, absB); - } else { //eq. (8a) - llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); - } - - + llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); //eq. (8a) } void updateCrcChecksum(uint8_t **crcChecksum, @@ -193,7 +160,7 @@ void updateCrcChecksum2(uint8_t **crcChecksum, -decoder_node_t *new_decoder_node(int first_leaf_index,int level) { +decoder_node_t *new_decoder_node(int first_leaf_index, int level) { decoder_node_t *node=(decoder_node_t *)malloc(sizeof(decoder_node_t)); @@ -208,32 +175,34 @@ decoder_node_t *new_decoder_node(int first_leaf_index,int level) { node->beta = (int16_t*)malloc16(node->Nv*sizeof(int16_t)); memset((void*)node->beta,-1,node->Nv*sizeof(int16_t)); - return(node); } -decoder_node_t *add_nodes(int level,int first_leaf_index,t_nrPolar_params *pp) { +decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *polarParams) { - int all_frozen_below=1; + int all_frozen_below = 1; int Nv = 1<<level; - decoder_node_t *new_node = new_decoder_node(first_leaf_index,level); + decoder_node_t *new_node = new_decoder_node(first_leaf_index, level); #ifdef DEBUG_NEW_IMPL - printf("New node %d order %d, level %d\n",pp->tree.num_nodes,Nv,level); + printf("New node %d order %d, level %d\n",polarParams->tree.num_nodes,Nv,level); #endif - pp->tree.num_nodes++; + polarParams->tree.num_nodes++; if (level==0) { #ifdef DEBUG_NEW_IMPL - printf("leaf %d (%s)\n",first_leaf_index,pp->information_bit_pattern[first_leaf_index]==1 ? "information or crc" : "frozen"); + printf("leaf %d (%s)\n", first_leaf_index, polarParams->information_bit_pattern[first_leaf_index]==1 ? "information or crc" : "frozen"); #endif new_node->leaf=1; - new_node->all_frozen = pp->information_bit_pattern[first_leaf_index]==0 ? 1 : 0; + new_node->all_frozen = polarParams->information_bit_pattern[first_leaf_index]==0 ? 1 : 0; return new_node; // this is a leaf node } for (int i=0;i<Nv;i++) { - if (pp->information_bit_pattern[i+first_leaf_index]>0) all_frozen_below=0; + if (polarParams->information_bit_pattern[i+first_leaf_index]>0) + all_frozen_below=0; } - if (all_frozen_below==0) new_node->left=add_nodes(level-1,first_leaf_index,pp); + + if (all_frozen_below==0) + new_node->left=add_nodes(level-1, first_leaf_index, polarParams); else { #ifdef DEBUG_NEW_IMPL printf("aggregating frozen bits %d ... %d at level %d (%s)\n",first_leaf_index,first_leaf_index+Nv-1,level,((first_leaf_index/Nv)&1)==0?"left":"right"); @@ -241,21 +210,22 @@ decoder_node_t *add_nodes(int level,int first_leaf_index,t_nrPolar_params *pp) { new_node->leaf=1; new_node->all_frozen=1; } - if (all_frozen_below==0) new_node->right=add_nodes(level-1,first_leaf_index+(Nv/2),pp); + if (all_frozen_below==0) + new_node->right=add_nodes(level-1,first_leaf_index+(Nv/2),polarParams); #ifdef DEBUG_NEW_IMPL printf("new_node (%d): first_leaf_index %d, left %p, right %p\n",Nv,first_leaf_index,new_node->left,new_node->right); -#endif +#endif + return(new_node); } - -void build_decoder_tree(t_nrPolar_params *pp) { - - pp->tree.num_nodes=0; - pp->tree.root = add_nodes(pp->n,0,pp); +void build_decoder_tree(t_nrPolar_params *polarParams) +{ + polarParams->tree.num_nodes=0; + polarParams->tree.root = add_nodes(polarParams->n,0,polarParams); #ifdef DEBUG_NEW_IMPL - printf("root : left %p, right %p\n",pp->tree.root->left,pp->tree.root->right); + printf("root : left %p, right %p\n",polarParams->tree.root->left,polarParams->tree.root->right); #endif } @@ -271,7 +241,7 @@ void build_decoder_tree(t_nrPolar_params *pp) { #define _mm_subs_pi16(a,b) vsub_s16(a,b) #endif -void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { +void applyFtoleft(const t_nrPolar_params *pp, decoder_node_t *node) { int16_t *alpha_v=node->alpha; int16_t *alpha_l=node->left->alpha; int16_t *betal = node->left->beta; @@ -368,18 +338,18 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { else #endif - { // equvalent scalar code to above, activated only on non x86/ARM architectures + { // equivalent scalar code to above, activated only on non x86/ARM architectures for (int i=0;i<node->Nv/2;i++) { - a=alpha_v[i]; - b=alpha_v[i+(node->Nv/2)]; - maska=a>>15; - maskb=b>>15; - absa=(a+maska)^maska; - absb=(b+maskb)^maskb; - minabs = absa<absb ? absa : absb; - alpha_l[i] = (maska^maskb)==0 ? minabs : -minabs; - // printf("alphal[%d] %d (%d,%d)\n",i,alpha_l[i],a,b); - } + a=alpha_v[i]; + b=alpha_v[i+(node->Nv/2)]; + maska=a>>15; + maskb=b>>15; + absa=(a+maska)^maska; + absb=(b+maskb)^maskb; + minabs = absa<absb ? absa : absb; + alpha_l[i] = (maska^maskb)==0 ? minabs : -minabs; + // printf("alphal[%d] %d (%d,%d)\n",i,alpha_l[i],a,b); + } } if (node->Nv == 2) { // apply hard decision on left node betal[0] = (alpha_l[0]>0) ? -1 : 1; @@ -394,7 +364,7 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) { } } -void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { +void applyGtoright(const t_nrPolar_params *pp,decoder_node_t *node) { int16_t *alpha_v=node->alpha; int16_t *alpha_r=node->right->alpha; @@ -448,7 +418,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { } else #endif - {// equvalent scalar code to above, activated only on non x86/ARM architectures or Nv=1,2 + {// equivalent scalar code to above, activated only on non x86/ARM architectures or Nv=1,2 for (int i=0;i<node->Nv/2;i++) { alpha_r[i] = alpha_v[i+(node->Nv/2)] - (betal[i]*alpha_v[i]); } @@ -463,13 +433,9 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) { } } +int16_t all1[16] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; -int16_t all1[16] = {1,1,1,1, - 1,1,1,1, - 1,1,1,1, - 1,1,1,1}; - -void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { +void computeBeta(const t_nrPolar_params *pp,decoder_node_t *node) { int16_t *betav = node->beta; int16_t *betal = node->left->beta; @@ -504,38 +470,37 @@ void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) { int ssr4len = node->Nv/2/8; register __m128i allones=*((__m128i*)all1); for (int i=0;i<sse4len;i++) { - ((__m256i*)betav)[i] = _mm_or_si128(_mm_cmpeq_epi16(((__m128i*)betar)[i], - ((__m128i*)betal)[i]),allones)); + ((__m256i*)betav)[i] = _mm_or_si128(_mm_cmpeq_epi16(((__m128i*)betar)[i], ((__m128i*)betal)[i]),allones)); } } else if (sse4mod == 4) { - ((__m64*)betav)[0] = _mm_or_si64(_mm_cmpeq_pi16(((__m64*)betar)[0], - ((__m64*)betal)[0]),*((__m64*)all1)); + ((__m64*)betav)[0] = _mm_or_si64(_mm_cmpeq_pi16(((__m64*)betar)[0], ((__m64*)betal)[0]),*((__m64*)all1)); } else #endif { for (int i=0;i<node->Nv/2;i++) { - betav[i] = (betal[i] != betar[i]) ? 1 : -1; + betav[i] = (betal[i] != betar[i]) ? 1 : -1; } } } else memcpy((void*)&betav[0],betar,(node->Nv/2)*sizeof(int16_t)); memcpy((void*)&betav[node->Nv/2],betar,(node->Nv/2)*sizeof(int16_t)); - } void generic_polar_decoder(const t_nrPolar_params *pp,decoder_node_t *node) { // Apply F to left - applyFtoleft(pp,node); + applyFtoleft(pp, node); // if left is not a leaf recurse down to the left - if (node->left->leaf==0) generic_polar_decoder(pp,node->left); + if (node->left->leaf==0) + generic_polar_decoder(pp, node->left); - applyGtoright(pp,node); - if (node->right->leaf==0) generic_polar_decoder(pp,node->right); + applyGtoright(pp, node); + if (node->right->leaf==0) generic_polar_decoder(pp, node->right); - computeBeta(pp,node); + computeBeta(pp, node); } + diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index 39c262040631ee8b3331f4c7bf9e7beaacc60abf..2c37462f7525bd52f5b31483b589e857e10d373c 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -21,11 +21,11 @@ /*!\file PHY/CODING/nrPolar_tools/nr_polar_defs.h * \brief - * \author Turker Yilmaz + * \author Raymond Knopp, Turker Yilmaz * \date 2018 * \version 0.1 * \company EURECOM - * \email turker.yilmaz@eurecom.fr + * \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr * \note * \warning */ @@ -46,7 +46,6 @@ //#include "SIMULATION/TOOLS/sim.h" #define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t -#define NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION 0 //uint8_t; 0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12) #define NR_POLAR_AGGREGATION_LEVEL_1_PRIME 149 //uint16_t #define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 //uint16_t @@ -54,12 +53,13 @@ #define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 //uint16_t #define NR_POLAR_AGGREGATION_LEVEL_16_PRIME 167 //uint16_t -static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 }; - +static const uint8_t nr_polar_subblock_interleaver_pattern[32] = {0,1,2,4,3,5,6,7,8,16,9,17,10,18,11,19,12,20,13,21,14,22,15,23,24,25,26,28,27,29,30,31}; #define Nmax 1024 #define nmax 10 +#define uint128_t __uint128_t + typedef struct decoder_node_t_s { struct decoder_node_t_s *left; struct decoder_node_t_s *right; @@ -106,18 +106,17 @@ struct nrPolar_params { int16_t *Q_PC_N; uint8_t *information_bit_pattern; uint16_t *channel_interleaver_pattern; - uint32_t crc_polynomial; + //uint32_t crc_polynomial; uint8_t **crc_generator_matrix; //G_P uint8_t **G_N; uint64_t **G_N_tab; int groupsize; - int *rm_tab; + int *rm_tab; uint64_t cprime_tab0[32][256]; uint64_t cprime_tab1[32][256]; uint64_t B_tab0[32][256]; uint64_t B_tab1[32][256]; - uint32_t *crc256Table; uint8_t **extended_crc_generator_matrix; //lowercase: bits, Uppercase: Bits stored in bytes //polar_encoder vectors @@ -152,40 +151,31 @@ void polar_encoder_fast(uint64_t *A, t_nrPolar_params *polarParams); int8_t polar_decoder(double *input, - uint8_t *output, + uint32_t *output, t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr); + uint8_t listSize); uint32_t polar_decoder_int16(int16_t *input, uint64_t *out, const t_nrPolar_params *polarParams); -int8_t polar_decoder_aPriori(double *input, - uint32_t *output, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload); - -int8_t polar_decoder_aPriori_timing(double *input, - uint32_t *output, - t_nrPolar_params *polarParams, - uint8_t listSize, - uint8_t pathMetricAppr, - double *aPrioriPayload, - double cpuFreqGHz, - FILE *logFile); - int8_t polar_decoder_dci(double *input, uint32_t *out, t_nrPolar_params *polarParams, uint8_t listSize, - uint8_t pathMetricAppr, uint16_t n_RNTI); -void generic_polar_decoder(const t_nrPolar_params *, - decoder_node_t *); +void generic_polar_decoder(const t_nrPolar_params *pp, + decoder_node_t *node); + +void applyFtoleft(const t_nrPolar_params *pp, + decoder_node_t *node); + +void applyGtoright(const t_nrPolar_params *pp, + decoder_node_t *node); + +void computeBeta(const t_nrPolar_params *pp, + decoder_node_t *node); void build_decoder_tree(t_nrPolar_params *pp); void build_polar_tables(t_nrPolar_params *polarParams); @@ -193,9 +183,9 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams); void nr_polar_print_polarParams(t_nrPolar_params *polarParams); -t_nrPolar_params *nr_polar_params ( int8_t messageType, - uint16_t messageLength, - uint8_t aggregation_level); +t_nrPolar_params *nr_polar_params (int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level); uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level); @@ -256,17 +246,19 @@ void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *pattern, uint16_t size); -void nr_bit2byte_uint32_8_t(uint32_t *in, - uint16_t arraySize, - uint8_t *out); +void nr_bit2byte_uint32_8(uint32_t *in, + uint16_t arraySize, + uint8_t *out); -void nr_byte2bit_uint8_32_t(uint8_t *in, - uint16_t arraySize, - uint32_t *out); +void nr_byte2bit_uint8_32(uint8_t *in, + uint16_t arraySize, + uint32_t *out); -void nr_crc_bit2bit_uint32_8_t(uint32_t *in, - uint16_t arraySize, - uint8_t *out); +uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); + +uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); + +uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, @@ -320,7 +312,6 @@ 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, @@ -329,8 +320,7 @@ void updateLLR(double ***llr, uint16_t row, uint16_t col, uint16_t xlen, - uint8_t ylen, - uint8_t approximation); + uint8_t ylen); void updateBit(uint8_t ***bit, uint8_t **bitU, @@ -344,21 +334,18 @@ void updatePathMetric(double *pathMetric, double ***llr, uint8_t listSize, uint8_t bitValue, - uint16_t row, - uint8_t approximation); + uint16_t row); void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, - uint16_t row, - uint8_t approximation); + uint16_t row); void computeLLR(double ***llr, uint16_t row, uint16_t col, uint8_t i, - uint16_t offset, - uint8_t approximation); + uint16_t offset); void updateCrcChecksum(uint8_t **crcChecksum, uint8_t **crcGen, @@ -372,12 +359,6 @@ void updateCrcChecksum2(uint8_t **crcChecksum, uint32_t i2, uint8_t len); -uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits); - -uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits); - -uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits); - //Also nr_polar_rate_matcher static inline void nr_polar_interleaver(uint8_t *input, uint8_t *output, @@ -387,14 +368,10 @@ static inline void nr_polar_interleaver(uint8_t *input, } static inline void nr_polar_deinterleaver(uint8_t *input, - uint8_t *output, - uint16_t *pattern, - uint16_t size) { - for (int i=0; i<size; i++) { - output[pattern[i]]=input[i]; - } + uint8_t *output, + uint16_t *pattern, + uint16_t size) { + for (int i=0; i<size; i++) output[pattern[i]]=input[i]; } -void build_decoder_tree(t_nrPolar_params *pp); - #endif diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index a9bef7ca38196c950849f02be4bedc4f9bc7b6f2..9858f16cb050f285a31077275cad43f891fd34dc 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -32,10 +32,11 @@ //#define DEBUG_POLAR_ENCODER //#define DEBUG_POLAR_ENCODER_DCI -//#define DEBUG_POLAR_ENCODER_TIMING +//#define DEBUG_POLAR_MATLAB #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "assertions.h" +#include <stdint.h> //input [a_31 a_30 ... a_0] //output [f_31 f_30 ... f_0] [f_63 f_62 ... f_32] ... @@ -43,23 +44,23 @@ void polar_encoder(uint32_t *in, uint32_t *out, t_nrPolar_params *polarParams) { - if (polarParams->idx == 0) { //PBCH + 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); #ifdef DEBUG_POLAR_ENCODER printf("polar_B %llx (crc %x)\n",B,crc24c((uint8_t*)in,polarParams->payloadBits)>>8); #endif nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/ - nr_bit2byte_uint32_8_t((uint32_t *)in, polarParams->payloadBits, polarParams->nr_polar_A); + nr_bit2byte_uint32_8(in, polarParams->payloadBits, polarParams->nr_polar_A); /* * Bytewise operations */ //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); @@ -77,6 +78,8 @@ void polar_encoder(uint32_t *in, for (int i = 0; i<polarParams->K; i++) B2 = B2 | ((uint64_t)polarParams->nr_polar_B[i] << i); printf("polar_B %llx\n",B2); + for (int i=0; i< polarParams->payloadBits; i++) printf("a[%d]=%d\n", i, polarParams->nr_polar_A[i]); + for (int i=0; i< polarParams->K; i++) printf("b[%d]=%d\n", i, polarParams->nr_polar_B[i]); #endif /* for (int j=0;j<polarParams->crcParityBits;j++) { for (int i=0;i<polarParams->payloadBits;i++) @@ -115,10 +118,10 @@ void polar_encoder(uint32_t *in, polarParams->nr_polar_U[247]=1; polarParams->nr_polar_U[253]=1;*/ nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_U, - polarParams->G_N, - polarParams->nr_polar_D, - polarParams->N, - polarParams->N); + polarParams->G_N, + polarParams->nr_polar_D, + polarParams->N, + polarParams->N); for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); @@ -146,7 +149,7 @@ void polar_encoder(uint32_t *in, for (int i=0; i< polarParams->encoderLength; i++) printf("f[%d]=%d\n", i, polarParams->nr_polar_E[i]); #endif - nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out); } void polar_encoder_dci(uint32_t *in, @@ -160,7 +163,7 @@ void polar_encoder_dci(uint32_t *in, * Bytewise operations */ //(a to a') - nr_bit2byte_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_A); + nr_bit2byte_uint32_8(in, polarParams->payloadBits, polarParams->nr_polar_A); for (int i=0; i<polarParams->crcParityBits; i++) polarParams->nr_polar_APrime[i]=1; @@ -168,35 +171,29 @@ void polar_encoder_dci(uint32_t *in, #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] A: "); - for (int i=0; i<polarParams->payloadBits; i++) printf("%d-", polarParams->nr_polar_A[i]); - printf("\n"); - printf("[polar_encoder_dci] APrime: "); + printf("[polar_encoder_dci] APrime: "); for (int i=0; i<polarParams->K; i++) printf("%d-", polarParams->nr_polar_APrime[i]); - printf("\n"); - printf("[polar_encoder_dci] GP: "); + printf("[polar_encoder_dci] GP: "); for (int i=0; i<polarParams->crcParityBits; i++) printf("%d-", polarParams->crc_generator_matrix[0][i]); - printf("\n"); #endif //Calculate CRC. nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_APrime, - polarParams->crc_generator_matrix, - polarParams->nr_polar_crc, - polarParams->K, - polarParams->crcParityBits); + polarParams->crc_generator_matrix, + polarParams->nr_polar_crc, + polarParams->K, + polarParams->crcParityBits); for (uint8_t i = 0; i < polarParams->crcParityBits; i++) polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2); #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] CRC: "); - for (int i=0; i<polarParams->crcParityBits; i++) printf("%d-", polarParams->nr_polar_crc[i]); - printf("\n"); #endif @@ -208,55 +205,16 @@ void polar_encoder_dci(uint32_t *in, polarParams->nr_polar_B[i]= polarParams->nr_polar_crc[i-(polarParams->payloadBits)]; //Scrambling (b to c) - for (int i=0; i<16; i++) { - polarParams->nr_polar_B[polarParams->payloadBits+8+i] = - ( polarParams->nr_polar_B[polarParams->payloadBits+8+i] + ((n_RNTI>>(15-i))&1) ) % 2; - } + for (int i=0; i<16; i++) + polarParams->nr_polar_B[polarParams->payloadBits+8+i]=( polarParams->nr_polar_B[polarParams->payloadBits+8+i] + ((n_RNTI>>(15-i))&1) ) % 2; - /* //(a to a') - nr_crc_bit2bit_uint32_8_t(in, polarParams->payloadBits, polarParams->nr_polar_aPrime); - //Parity bits computation (p) - polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits)); - #ifdef DEBUG_POLAR_ENCODER_DCI - printf("[polar_encoder_dci] crc: 0x%08x\n", polarParams->crcBit); - for (int i=0; i<32; i++) - { - printf("%d\n",((polarParams->crcBit)>>i)&1); - } - #endif - //(a to b) - // - // Bytewise operations - // - uint8_t arrayInd = ceil(polarParams->payloadBits / 8.0); - for (int i=0; i<arrayInd-1; i++){ - for (int j=0; j<8; j++) { - polarParams->nr_polar_B[j+(i*8)] = ((polarParams->nr_polar_aPrime[3+i]>>(7-j)) & 1); - } - } - for (int i=0; i<((polarParams->payloadBits)%8); i++) { - polarParams->nr_polar_B[i+(arrayInd-1)*8] = ((polarParams->nr_polar_aPrime[3+(arrayInd-1)]>>(7-i)) & 1); - } - for (int i=0; i<8; i++) { - polarParams->nr_polar_B[polarParams->payloadBits+i] = ((polarParams->crcBit)>>(31-i))&1; - } - //Scrambling (b to c) - for (int i=0; i<16; i++) { - polarParams->nr_polar_B[polarParams->payloadBits+8+i] = - ( (((polarParams->crcBit)>>(23-i))&1) + ((n_RNTI>>(15-i))&1) ) % 2; - }*/ #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] B: "); - for (int i = 0; i < polarParams->K; i++) printf("%d-", polarParams->nr_polar_B[i]); - printf("\n"); #endif //Interleaving (c to c') - nr_polar_interleaver(polarParams->nr_polar_B, - polarParams->nr_polar_CPrime, - polarParams->interleaving_pattern, - polarParams->K); + nr_polar_interleaver(polarParams->nr_polar_B, polarParams->nr_polar_CPrime, polarParams->interleaving_pattern, polarParams->K); //Bit insertion (c' to u) nr_polar_bit_insertion(polarParams->nr_polar_CPrime, polarParams->nr_polar_U, @@ -267,13 +225,11 @@ void polar_encoder_dci(uint32_t *in, polarParams->n_pc); //Encoding (u to d) nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_U, - polarParams->G_N, - polarParams->nr_polar_D, - polarParams->N, - polarParams->N); - - for (uint16_t i = 0; i < polarParams->N; i++) - polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); + polarParams->G_N, + polarParams->nr_polar_D, + polarParams->N, + polarParams->N); + for (uint16_t i = 0; i < polarParams->N; i++) polarParams->nr_polar_D[i] = (polarParams->nr_polar_D[i] % 2); //Rate matching //Sub-block interleaving (d to y) and Bit selection (y to e) @@ -284,28 +240,54 @@ void polar_encoder_dci(uint32_t *in, /* * Return bits. */ - nr_byte2bit_uint8_32_t(polarParams->nr_polar_E, polarParams->encoderLength, out); + nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out); #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] E: "); - for (int i = 0; i < polarParams->encoderLength; i++) printf("%d-", polarParams->nr_polar_E[i]); uint8_t outputInd = ceil(polarParams->encoderLength / 32.0); printf("\n[polar_encoder_dci] out: "); - - for (int i = 0; i < outputInd; i++) { - printf("[%d]->0x%08x\t", i, out[i]); - } - + for (int i = 0; i < outputInd; i++) printf("[%d]->0x%08x\t", i, out[i]); #endif } static inline void polar_rate_matching(t_nrPolar_params *polarParams,void *in,void *out) __attribute__((always_inline)); static inline void polar_rate_matching(t_nrPolar_params *polarParams,void *in,void *out) { - if (polarParams->groupsize == 8) + + // handle rate matching with a single 128 bit word using bit shuffling + // can be done with SIMD intrisics if needed + if (polarParams->groupsize < 8) { + AssertFatal(polarParams->encoderLength<=128,"Need to handle groupsize<8 and N>128\n"); + uint128_t *out128=(uint128_t*)out; + uint128_t *in128=(uint128_t*)in; + *out128=0; + uint128_t tmp0; +#ifdef DEBUG_POLAR_ENCODER + uint128_t tmp1; +#endif + for (int i=0; i<polarParams->encoderLength; i++) { +#ifdef DEBUG_POLAR_ENCODER + printf("%u<-%u : %llx.%llx =>",i,polarParams->rate_matching_pattern[i],((uint64_t *)out)[1],((uint64_t *)out)[0]); +#endif + tmp0 = (*in128&(((uint128_t)1)<<polarParams->rate_matching_pattern[i])); + if (tmp0!=0) { + *out128 = *out128 | ((uint128_t)1)<<i; +#ifdef DEBUG_POLAR_ENCODER + tmp1 = ((uint128_t)1)<<i; + printf("%llx.%llx<->%llx.%llx => %llx.%llx\n", + ((uint64_t *)&tmp0)[1],((uint64_t *)&tmp0)[0], + ((uint64_t *)&tmp1)[1],((uint64_t *)&tmp1)[0], + ((uint64_t *)out)[1],((uint64_t *)out)[0]); +#endif + } + } + + } + // These are based on LUTs for byte and short word groups + else if (polarParams->groupsize == 8) for (int i=0; i<polarParams->encoderLength>>3; i++) ((uint8_t *)out)[i] = ((uint8_t *)in)[polarParams->rm_tab[i]]; - else + else // groupsize==16 for (int i=0; i<polarParams->encoderLength>>4; i++) { ((uint16_t *)out)[i] = ((uint16_t *)in)[polarParams->rm_tab[i]]; } @@ -342,7 +324,7 @@ void build_polar_tables(t_nrPolar_params *polarParams) { } } - AssertFatal(polarParams->N==512,"N = %d, not done yet\n",polarParams->N); + 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 * sizeof(int64_t *)); @@ -371,14 +353,18 @@ void build_polar_tables(t_nrPolar_params *polarParams) { int iplast=polarParams->rate_matching_pattern[0]; int ccnt=0; int groupcnt=0; +#ifdef DEBUG_POLAR_ENCODER int firstingroup_out=0; int firstingroup_in=iplast; +#endif int mingroupsize = 1024; // compute minimum group size of rate-matching pattern for (int outpos=1; outpos<polarParams->encoderLength; outpos++) { ip=polarParams->rate_matching_pattern[outpos]; - +#ifdef DEBUG_POLAR_ENCODER + printf("rm: outpos %d, inpos %d\n",outpos,ip); +#endif if ((ip - iplast) == 1) ccnt++; else { groupcnt++; @@ -391,18 +377,27 @@ void build_polar_tables(t_nrPolar_params *polarParams) { if ((ccnt+1)<mingroupsize) mingroupsize=ccnt+1; ccnt=0; +#ifdef DEBUG_POLAR_ENCODER firstingroup_out=outpos; firstingroup_in=ip; +#endif } iplast=ip; } - - AssertFatal(mingroupsize==8 || mingroupsize==16,"mingroupsize %d, needs to be handled\n",mingroupsize); + groupcnt++; + if ((ccnt+1)<mingroupsize) mingroupsize=ccnt+1; +#ifdef DEBUG_POLAR_ENCODER + printf("group %d (size %d): (%d:%d) => (%d:%d)\n",groupcnt,ccnt+1, + firstingroup_in,firstingroup_in+ccnt, + firstingroup_out,firstingroup_out+ccnt); +#endif + AssertFatal(mingroupsize==4 || mingroupsize==8 || mingroupsize==16,"mingroupsize %d, needs to be handled\n",mingroupsize); polarParams->groupsize=mingroupsize; int shift=3; if (mingroupsize == 16) shift=4; + else if (mingroupsize == 4) shift=2; polarParams->rm_tab=(int *)malloc(sizeof(int)*polarParams->encoderLength/mingroupsize); // rerun again to create groups @@ -427,10 +422,11 @@ void polar_encoder_fast(uint64_t *A, //int bitlen0=bitlen; uint64_t tcrc=0; - // A bitstring should be stored as a_{N-1} a_{N-2} ... a_{N-A} 0 .... 0, where N=64,128,192,..., N is smallest multiple of 64 greater than or equal to A + // A bit string should be stored as 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, + //???a'_{N-1} a'_{N-2} ... a'_{N-A} 0 .... 0, where N=64,128,192,..., N is smallest multiple of 64 greater than or equal to A // First flip A bitstring byte endian for CRC routines (optimized for DLSCH/ULSCH, not PBCH/PDCCH) - // CRC reads in each byte in bit positions 7 downto 0, for PBCH/PDCCH we need to read in a_{A-1} downto a_{0}, A = length of bit string (e.g. 32 for PBCH) + // CRC reads in each byte in bit positions 7 down to 0, for PBCH/PDCCH we need to read in a_{A-1} down to a_{0}, A = length of bit string (e.g. 32 for PBCH) if (bitlen<=32) { uint8_t A32_flip[4]; uint32_t Aprime= (uint32_t)(((uint32_t)*A)<<(32-bitlen)); @@ -452,6 +448,19 @@ void polar_encoder_fast(uint64_t *A, A64_flip[7]=((uint8_t *)&Aprime)[0]; tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,bitlen)>>8))); } + else if (bitlen<=128) { + uint8_t A128_flip[16]; + uint128_t Aprime= (uint32_t)(((uint128_t)*A)<<(128-bitlen)); + A128_flip[0]=((uint8_t*)&Aprime)[15]; A128_flip[1]=((uint8_t*)&Aprime)[14]; + A128_flip[2]=((uint8_t*)&Aprime)[13]; A128_flip[3]=((uint8_t*)&Aprime)[12]; + A128_flip[4]=((uint8_t*)&Aprime)[11]; A128_flip[5]=((uint8_t*)&Aprime)[10]; + A128_flip[6] =((uint8_t*)&Aprime)[9]; A128_flip[7] =((uint8_t*)&Aprime)[8]; + A128_flip[8] =((uint8_t*)&Aprime)[7]; A128_flip[9] =((uint8_t*)&Aprime)[6]; + A128_flip[10]=((uint8_t*)&Aprime)[5]; A128_flip[11]=((uint8_t*)&Aprime)[4]; + A128_flip[12]=((uint8_t*)&Aprime)[3]; A128_flip[13]=((uint8_t*)&Aprime)[2]; + A128_flip[14]=((uint8_t*)&Aprime)[1]; A128_flip[15]=((uint8_t*)&Aprime)[0]; + tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,bitlen)>>8))); + } int n; // this is number of quadwords in the bit string @@ -459,11 +468,14 @@ void polar_encoder_fast(uint64_t *A, if ((polarParams->K&63) > 0) quadwlen++; - // Create the B bitstring as - // 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 + // 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)); + else B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits)); uint8_t *Bbyte = (uint8_t *)B; @@ -484,6 +496,11 @@ void polar_encoder_fast(uint64_t *A, } } +#ifdef DEBUG_POLAR_MATLAB + // Cprime = pbchCprime + for (int i = 0; i < quadwlen; i++) printf("[polar_encoder_fast]C'[%d]= 0x%llx\n", i, (unsigned long long)(Cprime[i])); +#endif + #ifdef DEBUG_POLAR_ENCODER if (polarParams->K<65) @@ -536,45 +553,104 @@ void polar_encoder_fast(uint64_t *A, int off=0; int len=polarParams->K; - for (int j=0; j<(1+(polarParams->K>>6)); j++,off+=64,len-=64) { - for (int i=0; i<((len>63) ? 64 : len); i++) { - Cprime_i = -((Cprime[j]>>i)&1); // this converts bit 0 as, 0 => 0000x00, 1 => 1111x11 - /* - #ifdef DEBUG_POLAR_ENCODER - printf("%llx Cprime_%d (%llx) G %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", - Cprime_i,off+i,(Cprime[j]>>i) &1, - polarParams->G_N_tab[off+i][0], - polarParams->G_N_tab[off+i][1], - polarParams->G_N_tab[off+i][2], - polarParams->G_N_tab[off+i][3], - polarParams->G_N_tab[off+i][4], - polarParams->G_N_tab[off+i][5], - polarParams->G_N_tab[off+i][6], - polarParams->G_N_tab[off+i][7]); - #endif - */ - uint64_t *Gi=polarParams->G_N_tab[off+i]; - D[0] ^= (Cprime_i & Gi[0]); - D[1] ^= (Cprime_i & Gi[1]); - D[2] ^= (Cprime_i & Gi[2]); - D[3] ^= (Cprime_i & Gi[3]); - D[4] ^= (Cprime_i & Gi[4]); - D[5] ^= (Cprime_i & Gi[5]); - D[6] ^= (Cprime_i & Gi[6]); - D[7] ^= (Cprime_i & Gi[7]); + if (polarParams->N==512) { + for (int j=0; j<(1+(polarParams->K>>6)); j++,off+=64,len-=64) { + for (int i=0; i<((len>63) ? 64 : len); i++) { + Cprime_i = -((Cprime[j]>>i)&1); // this converts bit 0 as, 0 => 0000x00, 1 => 1111x11 + /* + #ifdef DEBUG_POLAR_ENCODER + printf("%llx Cprime_%d (%llx) G %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", + Cprime_i,off+i,(Cprime[j]>>i) &1, + polarParams->G_N_tab[off+i][0], + polarParams->G_N_tab[off+i][1], + polarParams->G_N_tab[off+i][2], + polarParams->G_N_tab[off+i][3], + polarParams->G_N_tab[off+i][4], + polarParams->G_N_tab[off+i][5], + polarParams->G_N_tab[off+i][6], + polarParams->G_N_tab[off+i][7]); + #endif + */ + uint64_t *Gi=polarParams->G_N_tab[off+i]; + D[0] ^= (Cprime_i & Gi[0]); + D[1] ^= (Cprime_i & Gi[1]); + D[2] ^= (Cprime_i & Gi[2]); + D[3] ^= (Cprime_i & Gi[3]); + D[4] ^= (Cprime_i & Gi[4]); + D[5] ^= (Cprime_i & Gi[5]); + D[6] ^= (Cprime_i & Gi[6]); + D[7] ^= (Cprime_i & Gi[7]); + +#ifdef DEBUG_POLAR_ENCODER + printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", + D[0], + D[1], + D[2], + D[3], + D[4], + D[5], + D[6], + D[7]); +#endif + } } } - + else if (polarParams->N==256) { + for (int j=0; j<(1+(polarParams->K>>6)); j++,off+=64,len-=64) { + for (int i=0; i<((len>63) ? 64 : len); i++) { + Cprime_i = -((Cprime[j]>>i)&1); // this converts bit 0 as, 0 => 0000x00, 1 => 1111x11 + /* + #ifdef DEBUG_POLAR_ENCODER + printf("%llx Cprime_%d (%llx) G %llx,%llx,%llx,%llx\n", + Cprime_i,off+i,(Cprime[j]>>i) &1, + polarParams->G_N_tab[off+i][0], + polarParams->G_N_tab[off+i][1], + polarParams->G_N_tab[off+i][2], + polarParams->G_N_tab[off+i][3], + #endif + */ + uint64_t *Gi=polarParams->G_N_tab[off+i]; + D[0] ^= (Cprime_i & Gi[0]); + D[1] ^= (Cprime_i & Gi[1]); + D[2] ^= (Cprime_i & Gi[2]); + D[3] ^= (Cprime_i & Gi[3]); + + #ifdef DEBUG_POLAR_ENCODER - printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", - D[0], - D[1], - D[2], - D[3], - D[4], - D[5], - D[6], - D[7]); + printf("D %llx,%llx,%llx,%llx\n", + D[0], + D[1], + D[2], + D[3]); #endif + } + } + } + else if (polarParams->N==128) { + for (int j=0; j<(1+(polarParams->K>>6)); j++,off+=64,len-=64) { + for (int i=0; i<((len>63) ? 64 : len); i++) { + Cprime_i = -((Cprime[j]>>i)&1); // this converts bit 0 as, 0 => 0000x00, 1 => 1111x11 + + #ifdef DEBUG_POLAR_ENCODER + printf("%llx Cprime_%d (%d+%d) (%llx) G %llx,%llx\n", + Cprime_i,off+i,off,i,(Cprime[j]>>i) &1, + polarParams->G_N_tab[off+i][0], + polarParams->G_N_tab[off+i][1]); + #endif + + uint64_t *Gi=polarParams->G_N_tab[off+i]; + D[0] ^= (Cprime_i & Gi[0]); + D[1] ^= (Cprime_i & Gi[1]); + + +#ifdef DEBUG_POLAR_ENCODER + printf("D %llx,%llx\n", + D[0], + D[1]); +#endif + } + } + } + memset((void*)out,0,polarParams->encoderLength>>3); polar_rate_matching(polarParams,(void *)D,(void *)out); } diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c index 985266447b6bb8b57eeea6fd069e6706a4bc1cbe..26832fd70ca3f01d11ba4396ebbab8acca0201b2 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c @@ -28,7 +28,7 @@ * \email turker.yilmaz@eurecom.fr * \note * \warning -*/ + */ #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" @@ -43,295 +43,305 @@ void nr_polar_bit_insertion(uint8_t *input, uint16_t k=0; uint8_t flag; - if (n_PC>0) { - /* - * - */ - } else { - for (int n=0; n<=N-1; n++) { - flag=0; - for (int m=0; m<=(K+n_PC)-1; m++) { - if ( n == Q_I_N[m]) { - flag=1; - break; - } - } - if (flag) { // n ϵ Q_I_N - output[n]=input[k]; - k++; - } else { - output[n] = 0; - } - } + if (n_PC>0) { + /* + * + */ + } else { + for (int n=0; n<=N-1; n++) { + flag=0; + for (int m=0; m<=(K+n_PC)-1; m++) { + if ( n == Q_I_N[m]) { + flag=1; + break; } + } + if (flag) { // n ϵ Q_I_N + output[n]=input[k]; + k++; + } else { + output[n] = 0; + } + } + } } uint32_t nr_polar_output_length(uint16_t K, - uint16_t E, - uint8_t n_max) + uint16_t E, + uint8_t n_max) { - uint8_t n_1, n_2, n_min=5, n; - double R_min=1.0/8; - - if ( (E <= (9.0/8)*pow(2,ceil(log2(E))-1)) && (K/E < 9.0/16) ) { - n_1 = ceil(log2(E))-1; - } else { - n_1 = ceil(log2(E)); - } - - n_2 = ceil(log2(K/R_min)); - - n=n_max; - if (n>n_1) n=n_1; - if (n>n_2) n=n_2; - if (n<n_min) n=n_min; - - return ((uint32_t) pow(2.0,n)); //=polar_code_output_length + uint8_t n_1, n_2, n_min=5, n; + double R_min=1.0/8; + + if ( (E <= (9.0/8)*pow(2,ceil(log2(E))-1)) && (K/E < 9.0/16) ) { + n_1 = ceil(log2(E))-1; + } else { + n_1 = ceil(log2(E)); + } + + n_2 = ceil(log2(K/R_min)); + + n=n_max; + if (n>n_1) n=n_1; + if (n>n_2) n=n_2; + if (n<n_min) n=n_min; + + /*printf("nr_polar_output_length: K %d, E %d, n %d (n_max %d,n_min %d, n_1 %d,n_2 %d)\n", + K,E,n,n_max,n_min,n_1,n_2); + exit(-1);*/ + return ((uint32_t) pow(2.0,n)); //=polar_code_output_length } void nr_polar_channel_interleaver_pattern(uint16_t *cip, - uint8_t I_BIL, - uint16_t E) + uint8_t I_BIL, + uint16_t E) { - if (I_BIL == 1) { - uint16_t T=0, k; - while( ((T/2)*(T+1)) < E ) T++; - - int16_t **v = malloc(T * sizeof(*v)); - for (int i = 0; i <= T-1; i++) v[i] = malloc((T-i) * sizeof(*(v[i]))); - - k=0; - for (int i = 0; i <= T-1; i++) { - for (int j = 0; j <= (T-1)-i; j++) { - if (k<E) { - v[i][j] = k; - } else { - v[i][j] = (-1); - } - k++; - } - } - - k=0; - for (int j = 0; j <= T-1; j++) { - for (int i = 0; i <= (T-1)-j; i++) { - if ( v[i][j] != (-1) ) { - cip[k]=v[i][j]; - k++; - } - } - } - - for (int i = 0; i <= T-1; i++) free(v[i]); - free(v); - + if (I_BIL == 1) { + uint16_t T=0, k; + while( ((T/2)*(T+1)) < E ) T++; + + int16_t **v = malloc(T * sizeof(*v)); + for (int i = 0; i <= T-1; i++) v[i] = malloc((T-i) * sizeof(*(v[i]))); + + k=0; + for (int i = 0; i <= T-1; i++) { + for (int j = 0; j <= (T-1)-i; j++) { + if (k<E) { + v[i][j] = k; } else { - for (int i=0; i<=E-1; i++) cip[i]=i; + v[i][j] = (-1); } - + k++; + } + } + + k=0; + for (int j = 0; j <= T-1; j++) { + for (int i = 0; i <= (T-1)-j; i++) { + if ( v[i][j] != (-1) ) { + cip[k]=v[i][j]; + k++; + } + } + } + + for (int i = 0; i <= T-1; i++) free(v[i]); + free(v); + + } else { + for (int i=0; i<=E-1; i++) cip[i]=i; + } } void nr_polar_info_bit_pattern(uint8_t *ibp, - int16_t *Q_I_N, - int16_t *Q_F_N, - uint16_t *J, - const uint16_t *Q_0_Nminus1, - uint16_t K, - uint16_t N, - uint16_t E, - uint8_t n_PC) + int16_t *Q_I_N, + int16_t *Q_F_N, + uint16_t *J, + const uint16_t *Q_0_Nminus1, + uint16_t K, + uint16_t N, + uint16_t E, + uint8_t n_PC) { - int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final - int16_t *Q_Itmp_N = malloc(sizeof(int16_t) * (N + 1)); // array index assigned a value. + int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final + int16_t *Q_Itmp_N = malloc(sizeof(int16_t) * (N + 1)); // array index assigned a value. - for (int i = 0; i <= N; i++) { - Q_Ftmp_N[i] = -1; // Empty array. - Q_Itmp_N[i] = -1; - } + for (int i = 0; i <= N; i++) { + Q_Ftmp_N[i] = -1; // Empty array. + Q_Itmp_N[i] = -1; + } - uint8_t flag; - uint16_t limit, ind; - - if (E < N) { - if ((K / (double) E) <= (7.0 / 16)) { //puncturing - for (int n = 0; n <= N - E - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = J[n]; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - - if ((E / (double) N) >= (3.0 / 4)) { - limit = ceil((double) (3 * N - 2 * E) / 4); - for (int n = 0; n <= limit - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = n; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - } else { - limit = ceil((double) (9 * N - 4 * E) / 16); - for (int n = 0; n <= limit - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = n; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - } - } else { //shortening - for (int n = E; n <= N - 1; n++) { - ind = Q_Ftmp_N[N] + 1; - Q_Ftmp_N[ind] = J[n]; - Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; - } - } - } - - //Q_I,tmp_N = Q_0_N-1 \ Q_F,tmp_N - for (int n = 0; n <= N - 1; n++) { - flag = 1; - for (int m = 0; m <= Q_Ftmp_N[N]; m++) { - if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { - flag = 0; - break; - } - } - if (flag) { - Q_Itmp_N[Q_Itmp_N[N] + 1] = Q_0_Nminus1[n]; - Q_Itmp_N[N]++; - } - } - - //Q_I_N comprises (K+n_PC) most reliable bit indices in Q_I,tmp_N - for (int n = 0; n <= (K + n_PC) - 1; n++) { - ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1); - Q_I_N[n] = Q_Itmp_N[ind]; - } - - //Q_F_N = Q_0_N-1 \ Q_I_N - for (int n = 0; n <= N - 1; n++) { - flag = 1; - for (int m = 0; m <= (K + n_PC) - 1; m++) { - if (Q_0_Nminus1[n] == Q_I_N[m]) { - flag = 0; - break; - } - } - if (flag) { - Q_F_N[Q_F_N[N] + 1] = Q_0_Nminus1[n]; - Q_F_N[N]++; - } + uint8_t flag; + uint16_t limit, ind; + + if (E < N) { + if ((K / (double) E) <= (7.0 / 16)) { //puncturing + for (int n = 0; n <= N - E - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = J[n]; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } + + if ((E / (double) N) >= (3.0 / 4)) { + limit = ceil((double) (3 * N - 2 * E) / 4); + for (int n = 0; n <= limit - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = n; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; } - - //Information Bit Pattern - for (int n = 0; n <= N - 1; n++) { - ibp[n] = 0; - - for (int m = 0; m <= (K + n_PC) - 1; m++) { - if (n == Q_I_N[m]) { - ibp[n] = 1; - break; - } - } + } else { + limit = ceil((double) (9 * N - 4 * E) / 16); + for (int n = 0; n <= limit - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = n; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; } - - free(Q_Ftmp_N); - free(Q_Itmp_N); + } + } else { //shortening + for (int n = E; n <= N - 1; n++) { + ind = Q_Ftmp_N[N] + 1; + Q_Ftmp_N[ind] = J[n]; + Q_Ftmp_N[N] = Q_Ftmp_N[N] + 1; + } + } + } + + //Q_I,tmp_N = Q_0_N-1 \ Q_F,tmp_N + for (int n = 0; n <= N - 1; n++) { + flag = 1; + for (int m = 0; m <= Q_Ftmp_N[N]; m++) { + if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { + flag = 0; + break; + } + } + if (flag) { + Q_Itmp_N[Q_Itmp_N[N] + 1] = Q_0_Nminus1[n]; + Q_Itmp_N[N]++; + } + } + + //Q_I_N comprises (K+n_PC) most reliable bit indices in Q_I,tmp_N + for (int n = 0; n <= (K + n_PC) - 1; n++) { + ind = Q_Itmp_N[N] + n - ((K + n_PC) - 1); + Q_I_N[n] = Q_Itmp_N[ind]; + } + + //Q_F_N = Q_0_N-1 \ Q_I_N + for (int n = 0; n <= N - 1; n++) { + flag = 1; + for (int m = 0; m <= (K + n_PC) - 1; m++) { + if (Q_0_Nminus1[n] == Q_I_N[m]) { + flag = 0; + break; + } + } + if (flag) { + Q_F_N[Q_F_N[N] + 1] = Q_0_Nminus1[n]; + Q_F_N[N]++; + } + } + + //Information Bit Pattern + for (int n = 0; n <= N - 1; n++) { + ibp[n] = 0; + + for (int m = 0; m <= (K + n_PC) - 1; m++) { + if (n == Q_I_N[m]) { + ibp[n] = 1; + break; + } + } + } + + free(Q_Ftmp_N); + free(Q_Itmp_N); } void nr_polar_info_bit_extraction(uint8_t *input, - uint8_t *output, - uint8_t *pattern, - uint16_t size) + uint8_t *output, + uint8_t *pattern, + uint16_t size) { - uint16_t j = 0; - for (int i = 0; i < size; i++) { - if (pattern[i] > 0) { - output[j] = input[i]; - j++; - } - } + uint16_t j = 0; + for (int i = 0; i < size; i++) { + if (pattern[i] > 0) { + output[j] = input[i]; + j++; + } + } } -void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P_i_, uint16_t K, uint16_t N, uint16_t E){ - - uint8_t i; - uint16_t *d, *y, ind; - d = (uint16_t *)malloc(sizeof(uint16_t) * N); - y = (uint16_t *)malloc(sizeof(uint16_t) * N); - - for (int m=0; m<=N-1; m++) d[m]=m; - - for (int m=0; m<=N-1; m++){ - i=floor((32*m)/N); - J[m] = (P_i_[i]*(N/32)) + (m%(N/32)); - y[m] = d[J[m]]; - } - - if (E>=N) { //repetition - for (int k=0; k<=E-1; k++) { - ind = (k%N); - rmp[k]=y[ind]; - } - } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing - for (int k=0; k<=E-1; k++) { - rmp[k]=y[k+N-E]; - } - } else { //shortening - for (int k=0; k<=E-1; k++) { - rmp[k]=y[k]; - } - } - } - - free(d); - free(y); +void nr_polar_rate_matching_pattern(uint16_t *rmp, + uint16_t *J, + const uint8_t *P_i_, + uint16_t K, + uint16_t N, + uint16_t E) +{ + uint8_t i; + uint16_t *d, *y, ind; + d = (uint16_t *)malloc(sizeof(uint16_t) * N); + y = (uint16_t *)malloc(sizeof(uint16_t) * N); + + for (int m=0; m<=N-1; m++) d[m]=m; + + for (int m=0; m<=N-1; m++){ + i=floor((32*m)/N); + J[m] = (P_i_[i]*(N/32)) + (m%(N/32)); + y[m] = d[J[m]]; + } + + if (E>=N) { //repetition + for (int k=0; k<=E-1; k++) { + ind = (k%N); + rmp[k]=y[ind]; + } + } else { + if ( (K/(double)E) <= (7.0/16) ) { //puncturing + for (int k=0; k<=E-1; k++) { + rmp[k]=y[k+N-E]; + } + } else { //shortening + for (int k=0; k<=E-1; k++) { + rmp[k]=y[k]; + } + } + } + + free(d); + free(y); } -void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ - - if (E>=N) { //repetition - for (int i=0; i<=N-1; i++) output[i]=0; - for (int i=0; i<=E-1; i++){ - output[rmp[i]]+=input[i]; - } - } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing - for (int i=0; i<=N-1; i++) output[i]=0; - } else { //shortening - for (int i=0; i<=N-1; i++) output[i]=INFINITY; - } - - for (int i=0; i<=E-1; i++){ - output[rmp[i]]=input[i]; - } - } - +void nr_polar_rate_matching(double *input, + double *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E) +{ + if (E>=N) { //repetition + for (int i=0; i<=N-1; i++) output[i]=0; + for (int i=0; i<=E-1; i++){ + output[rmp[i]]+=input[i]; + } + } else { + if ( (K/(double)E) <= (7.0/16) ) { //puncturing + for (int i=0; i<=N-1; i++) output[i]=0; + } else { //shortening + for (int i=0; i<=N-1; i++) output[i]=INFINITY; + } + + for (int i=0; i<=E-1; i++){ + output[rmp[i]]=input[i]; + } + } } -void nr_polar_rate_matching_int16(int16_t *input, int16_t *output, uint16_t *rmp, uint16_t K, uint16_t N, uint16_t E){ - - if (E>=N) { //repetition - for (int i=0; i<=N-1; i++) output[i]=0; - for (int i=0; i<=E-1; i++){ - output[rmp[i]]+=input[i]; - } - } else { - if ( (K/(double)E) <= (7.0/16) ) { //puncturing - for (int i=0; i<=N-1; i++) output[i]=0; - } else { //shortening - for (int i=0; i<=N-1; i++) output[i]=32767;//instead of INFINITY, to prevent [-Woverflow] - } - - for (int i=0; i<=E-1; i++){ - output[rmp[i]]=input[i]; - } - } - +void nr_polar_rate_matching_int16(int16_t *input, + int16_t *output, + uint16_t *rmp, + uint16_t K, + uint16_t N, + uint16_t E) +{ + if (E>=N) { //repetition + memset((void*)output,0,N*sizeof(int16_t)); + for (int i=0; i<=E-1; i++) output[rmp[i]]+=input[i]; + } else { + if ( (K/(double)E) <= (7.0/16) ) memset((void*)output,0,N*sizeof(int16_t)); //puncturing + else { //shortening + for (int i=0; i<=N-1; i++) output[i]=32767;//instead of INFINITY, to prevent [-Woverflow] + } + + for (int i=0; i<=E-1; i++) output[rmp[i]]=input[i]; + + } } - diff --git a/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c new file mode 100644 index 0000000000000000000000000000000000000000..3dd570cc18212b685da17181ad565822e554cb3e --- /dev/null +++ b/openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c @@ -0,0 +1,156 @@ +/* + * 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 + */ + +/*!\file PHY/CODING/nrSmallBlock/decodeSmallBlock.c + * \brief + * \author Turker Yilmaz + * \date 2019 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" +#include "assertions.h" +#include "PHY/sse_intrin.h" + +//#define DEBUG_DECODESMALLBLOCK + +//input = [dÌ‚_0] [dÌ‚_1] [dÌ‚_2] ... [dÌ‚_31] +//output = [? ... ? ĉ_K-1 ... ĉ_2 ĉ_1 ĉ_0] + +uint16_t decodeSmallBlock(int8_t *in, uint8_t len){ + uint16_t out = 0; + + AssertFatal(len >= 3 && len <= 11, "[decodeSmallBlock] Message Length = %d (Small Block Coding is only defined for input lengths 3 to 11)", len); + + if(len<7) { + int16_t Rhat[NR_SMALL_BLOCK_CODED_BITS] = {0}, Rhatabs[NR_SMALL_BLOCK_CODED_BITS] = {0}; + uint16_t maxVal; + uint8_t maxInd = 0; + uint8_t jmax = (1<<(len-1)); + for (int j = 0; j < jmax; ++j) + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + Rhat[j] += in[k] * hadamard32InterleavedTransposed[j][k]; + +#if defined(__AVX2__) + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; i += 16) { + __m256i a15_a0 = _mm256_loadu_si256((__m256i*)&Rhat[i]); + a15_a0 = _mm256_abs_epi16(a15_a0); + _mm256_storeu_si256((__m256i*)(&Rhatabs[i]), a15_a0); + } +#else + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; i += 8) { + __m128i a7_a0 = _mm_loadu_si128((__m128i*)&Rhat[i]); + a7_a0 = _mm_abs_epi16(a7_a0); + _mm_storeu_si128((__m128i*)(&Rhatabs[i]), a7_a0); + } +#endif + maxVal = Rhatabs[0]; + for (int k = 1; k < jmax; ++k){ + if (Rhatabs[k] > maxVal){ + maxVal = Rhatabs[k]; + maxInd = k; + } + } + + out = properOrderedBasis[maxInd] | ( (Rhat[maxInd] > 0) ? (uint16_t)0 : (uint16_t)1 ); + +#ifdef DEBUG_DECODESMALLBLOCK + for (int k = 0; k < jmax; ++k) + printf("[decodeSmallBlock]Rhat[%d]=%d %d %d %d\n",k, Rhat[k], maxVal, maxInd, ((uint32_t)out>>k)&1); + printf("[decodeSmallBlock]0x%x 0x%x\n", out, properOrderedBasis[maxInd]); +#endif + + } else { + uint8_t maxRow = 0, maxCol = 0; + +#if defined(__AVX2__) + int16_t maxVal = 0; + int DmatrixElementVal = 0; + int8_t DmatrixElement[NR_SMALL_BLOCK_CODED_BITS] = {0}; + __m256i _in_256 = _mm256_loadu_si256 ((__m256i*)&in[0]); + __m256i _maskD_256, _Dmatrixj_256, _maskH_256, _DmatrixElement_256; + for (int j = 0; j < ( 1<<(len-6) ); ++j) { + _maskD_256 = _mm256_loadu_si256 ((__m256i*)(&maskD[j][0])); + _Dmatrixj_256 = _mm256_sign_epi8 (_in_256, _maskD_256); + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) { + _maskH_256 = _mm256_loadu_si256 ((__m256i*)(&hadamard32InterleavedTransposed[k][0])); + _DmatrixElement_256 = _mm256_sign_epi8 (_Dmatrixj_256, _maskH_256); +#if defined(__AVX512F__) + DmatrixElementVal = _mm512_reduce_add_epi32 ( + _mm512_add_epi32( + _mm512_cvtepi8_epi32 (_mm256_extracti128_si256 (_DmatrixElement_256, 1)), + _mm512_cvtepi8_epi32 (_mm256_castsi256_si128 (_DmatrixElement_256)) + ) + ); +#else + _mm256_storeu_si256((__m256i*)(&DmatrixElement[0]), _DmatrixElement_256); + for (int i = 0; i < NR_SMALL_BLOCK_CODED_BITS; ++i) + DmatrixElementVal += DmatrixElement[i]; +#endif + if (abs(DmatrixElementVal) > abs(maxVal)){ + maxVal = DmatrixElementVal; + maxRow = j; + maxCol = k; + } + DmatrixElementVal=0; + } + } + out = properOrderedBasisExtended[maxRow] | properOrderedBasis[maxCol] | ( (maxVal > 0) ? (uint16_t)0 : (uint16_t)1 ); +#else + int8_t Dmatrix[NR_SMALL_BLOCK_CODED_BITS][NR_SMALL_BLOCK_CODED_BITS] = {0}; + int16_t DmatrixFHT[NR_SMALL_BLOCK_CODED_BITS][NR_SMALL_BLOCK_CODED_BITS] = {0}; + uint16_t maxVal; + uint8_t rowLimit = 1<<(len-6); + + for (int j = 0; j < ( rowLimit ); ++j) + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + Dmatrix[j][k] = in[k] * maskD[j][k]; + + for (int i = 0; i < ( rowLimit ); ++i) + for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + DmatrixFHT[i][j] += Dmatrix[i][k] * hadamard32InterleavedTransposed[j][k]; + + maxVal = abs(DmatrixFHT[0][0]); + for (int i = 0; i < ( rowLimit ); ++i) + for (int j = 0; j < NR_SMALL_BLOCK_CODED_BITS; ++j) + if (abs(DmatrixFHT[i][j]) > maxVal){ + maxVal = abs(DmatrixFHT[i][j]); + maxRow = i; + maxCol = j; + } + + out = properOrderedBasisExtended[maxRow] | properOrderedBasis[maxCol] | ( (DmatrixFHT[maxRow][maxCol] > 0) ? (uint16_t)0 : (uint16_t)1 ); +#endif + +#ifdef DEBUG_DECODESMALLBLOCK + for (int k = 0; k < NR_SMALL_BLOCK_CODED_BITS; ++k) + printf("[decodeSmallBlock]maxRow = %d maxCol = %d out[%d]=%d\n", maxRow, maxCol, k, ((uint32_t)out>>k)&1); +#endif + + } + + return out; +} diff --git a/openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c b/openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c new file mode 100644 index 0000000000000000000000000000000000000000..8358bd270b98371437b1a240321189c327466c7b --- /dev/null +++ b/openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c @@ -0,0 +1,44 @@ +/* + * 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 + */ + +/*!\file PHY/CODING/nrSmallBlock/encodeSmallBlock.c + * \brief + * \author Turker Yilmaz + * \date 2019 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + +#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" + +//input = [0 ... 0 c_K-1 ... c_2 c_1 c_0] +//output = [d_31 d_30 ... d_2 d_1 d_0] +uint32_t encodeSmallBlock(uint16_t *in, uint8_t len){ + uint32_t out = 0; + for (uint16_t i=0; i<len; i++) + if ((*in & (1<<i)) > 0) + out^=nrSmallBlockBasis[i]; + + return out; +} diff --git a/openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h b/openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h new file mode 100644 index 0000000000000000000000000000000000000000..50559aa0d27740ddbbcd2abc53393ec22ac9e7c7 --- /dev/null +++ b/openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h @@ -0,0 +1,134 @@ +/* + * 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 + */ + +/*!\file PHY/CODING/nrSmallBlock/nr_small_block_defs.h + * \brief + * \author Turker Yilmaz + * \date 2019 + * \version 0.1 + * \company EURECOM + * \email turker.yilmaz@eurecom.fr + * \note + * \warning +*/ + +#ifndef __NR_SMALL_BLOCK_DEFS__H__ +#define __NR_SMALL_BLOCK_DEFS__H__ + +#include <math.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#define NR_SMALL_BLOCK_CODED_BITS 32 + +#define L1d_CLS 64 + +uint32_t encodeSmallBlock(uint16_t *in, uint8_t len); + +uint16_t decodeSmallBlock(int8_t *in, uint8_t len); + +static const uint32_t nrSmallBlockBasis[11] = {0xFFFFFFFF, 0x4BA5A933, 0x7D910E5A, 0x6D26339C, 0x71C7C3E0, + 0x7E0FFC00, 0x731D8E64, 0x6B44F5B0, 0x7DC218EC, 0x4DA1B746, 0x42F0FFFF}; + +static const uint16_t properOrderedBasis[32] = {0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000A, 0x000C, 0x000E, 0x0010, 0x0012, + 0x0014, 0x0016, 0x0018, 0x001A, 0x001C, 0x001E, 0x0020, 0x0022, 0x0024, 0x0026, + 0x0028, 0x002A, 0x002C, 0x002E, 0x0030, 0x0032, 0x0034, 0x0036, 0x0038, 0x003A, 0x003C, 0x003E}; + +static const uint16_t properOrderedBasisExtended[32] = {0x0000, 0x0040, 0x0080, 0x00C0, 0x0100, 0x0140, 0x0180, 0x01C0, 0x0200, 0x0240, + 0x0280, 0x02C0, 0x0300, 0x0340, 0x0380, 0x03C0, 0x0400, 0x0440, 0x0480, 0x04C0, + 0x0500, 0x0540, 0x0580, 0x05C0, 0x0600, 0x0640, 0x0680, 0x06C0, 0x0700, 0x0740, 0x0780, 0x07C0}; + +static const int8_t hadamard32InterleavedTransposed[32][32] __attribute__ ((aligned(32))) = { + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {-1,-1,1,1,-1,-1,1,1,-1,1,1,-1,1,-1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,-1,1}, + {1,-1,1,-1,-1,1,-1,1,1,-1,-1,-1,1,1,1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,-1,1}, + {-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,1}, + {1,1,-1,-1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1}, + {-1,-1,-1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,1,-1,1,1}, + {1,-1,-1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,1}, + {-1,1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,1,-1,1}, + {1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,1}, + {-1,-1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,1,-1,1,-1,-1,-1,1,1}, + {1,-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,-1,1,1,1,-1,-1,1,1,1,1}, + {-1,1,1,-1,1,1,1,-1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,-1,1}, + {1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,1,1,1}, + {-1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,-1,1,-1,-1,-1,1,-1,1,-1,1}, + {1,-1,-1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1}, + {-1,1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,1,1}, + {1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1}, + {-1,-1,1,1,-1,-1,1,1,-1,1,-1,1,-1,1,-1,1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,1,-1,-1,1,1}, + {1,-1,1,-1,-1,1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,1}, + {-1,1,1,-1,1,-1,-1,1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,1,-1,1}, + {1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1}, + {-1,-1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,1,1,1,-1,1,1,1,-1,-1,1,-1,1}, + {1,-1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,-1,1,-1,-1,1}, + {-1,1,-1,1,-1,-1,-1,-1,1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,1,1,-1,1,1}, + {1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1}, + {-1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,1,1,1,-1,1}, + {1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,1,1,-1,1,1,-1,-1,-1,1}, + {-1,1,1,-1,1,1,1,-1,1,1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1}, + {1,1,-1,-1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,1,1,1,-1,-1,1}, + {-1,-1,-1,-1,1,1,-1,1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,1,1,-1,1,-1,1,1}, + {1,-1,-1,1,1,-1,1,1,1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1}, + {-1,1,-1,1,-1,1,1,1,-1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,-1,1} +}; + +static const int8_t maskD[32][32] __attribute__ ((aligned(32))) = { + {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, + {1,1,-1,1,1,-1,-1,1,1,-1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,-1,1}, + {1,1,1,1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,1}, + {1,1,-1,1,-1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,1,-1,1,1,1,1,-1,-1,1,1,1}, + {1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,-1,1}, + {1,1,1,-1,1,1,1,-1,1,-1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,1,1,1,1}, + {1,1,-1,-1,-1,1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,-1,1,1,1}, + {1,1,1,-1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,1,1,-1,-1,1}, + {1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,-1,-1,1,1,-1,1}, + {1,-1,1,1,1,-1,1,1,-1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,-1,-1,1,1}, + {1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,1,1,-1,1,-1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,1,1}, + {1,-1,1,1,-1,1,1,-1,1,1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,-1,1}, + {1,-1,1,-1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,1,1}, + {1,-1,-1,-1,1,1,-1,-1,-1,1,1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,-1,1}, + {1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,-1,1,-1,1}, + {1,-1,-1,-1,-1,-1,-1,1,1,1,-1,1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,1,1}, + {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,-1,1,1,1,1,-1,1}, + {-1,-1,1,-1,-1,1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,-1,1,1,1,-1,-1,1,1}, + {-1,-1,-1,-1,1,1,-1,1,1,-1,1,-1,1,1,1,1,1,1,-1,1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1}, + {-1,-1,1,-1,1,-1,1,1,1,1,-1,1,1,1,1,-1,-1,1,1,-1,1,-1,1,-1,1,-1,1,-1,-1,1,-1,1}, + {-1,-1,1,1,-1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,1,-1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1}, + {-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,1,-1,1}, + {-1,-1,1,1,1,-1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,1,-1,1}, + {-1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,-1,1,1,-1,-1,-1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1}, + {-1,1,1,-1,-1,-1,1,-1,1,1,1,-1,1,1,-1,1,-1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,1,1,1,1}, + {-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,1}, + {-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1}, + {-1,1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,1,1,1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,1}, + {-1,1,-1,1,-1,1,-1,1,1,1,1,1,-1,1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,1,1,-1,-1,-1,1}, + {-1,1,1,1,-1,-1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,1,1,1,1,1,1,1}, + {-1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,1,1,1,}, + {-1,1,1,1,1,1,1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,-1,1,1,-1,-1,1,-1,1,-1,1,-1,-1,1} +}; + + + +#endif + diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index dd0056b3b5bcc69b267e2bd19e41739c34600cd0..f158d4430300be8c533326c3b20edc288845c70c 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -21,19 +21,16 @@ /*!\file PHY/CODING/nr_polar_init.h * \brief - * \author Turker Yilmaz + * \author Turker Yilmaz, Raymond Knopp * \date 2018 * \version 0.1 * \company EURECOM - * \email turker.yilmaz@eurecom.fr + * \email turker.yilmaz@eurecom.fr, raymond.knopp@eurecom.fr * \note * \warning */ -#include "nrPolar_tools/nr_polar_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" -#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h" +#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/NR_TRANSPORT/nr_dci.h" static int intcmp(const void *p1,const void *p2) { @@ -95,7 +92,9 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, } 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 = 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: @@ -182,9 +181,9 @@ 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) { +t_nrPolar_params *nr_polar_params (int8_t messageType, + uint16_t messageLength, + uint8_t aggregation_level) { static t_nrPolar_params *polarList = NULL; nr_polar_init(&polarList, messageType,messageLength,aggregation_level); t_nrPolar_params *polarParams=polarList; diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 4172ad0306f480687dcc37da0882352e660491ec..0954939a581b6cea5cee196f07d09d9dbb0f8c31 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -26,6 +26,7 @@ #include "PHY/defs_gNB.h" #include "PHY/defs_nr_UE.h" +#include "PHY/CODING/coding_defs.h" //#define RM_DEBUG 1 diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index bcdd782073f47b16e8be9050b547065d9d3f1342..9c9d67bdc296ca458667faf6a754babe6a24ca2a 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -355,7 +355,9 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, #endif -void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, +void phy_config_harq_ue(module_id_t Mod_id, + int CC_id, + uint8_t eNB_id, uint16_t max_harq_tx ) { diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index ef555c0f20705dce4607d05d49074ace1cf55dee..397f20633698fb8f4865381ee041790e86eafa52 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -40,6 +40,7 @@ extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn); extern int32_t get_uldl_offset(int nr_bandP); +extern openair0_config_t openair0_cfg[MAX_CARDS]; int l1_north_init_gNB() { int i,j; @@ -417,7 +418,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { RC.gNB[Mod_id][CC_id]->mac_enabled = 1; fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); - fp->threequarter_fs = 0; + fp->threequarter_fs = openair0_cfg[0].threequarter_fs; LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d, N_RB_UL %d, Nid_cell %d,DL freq %u)\n", Mod_id, CC_id, diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index b2be51f6a246189fce57b98d380951180d135c08..f5f6ca152381eb86f9f422167f028a88fbe192f6 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -357,8 +357,10 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, } #endif -void phy_config_harq_ue(module_id_t Mod_id,int CC_id,uint8_t eNB_id, - uint16_t max_harq_tx ) +void phy_config_harq_ue(module_id_t Mod_id, + int CC_id, + uint8_t eNB_id, + uint16_t max_harq_tx) { int num_of_threads,num_of_code_words; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h index 98e6f90a53cb7ee30ed3dbf996851cb722e42451..4c433a5683b05be6a2899bb74c0ce449abe0bb25 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -194,7 +194,7 @@ typedef struct { /// allocated CBA RNTI uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; /// UL max-harq-retransmission - uint8_t Mlimit; + uint16_t Mlimit; } LTE_UE_ULSCH_t; diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index 929ac823ddf4c2ea9d554ae1e21bee3908ab3b19..15e31d9728840ba4981e656757e49940716081e4 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -31,6 +31,7 @@ */ #include "nr_dci.h" +#include "nr_dlsch.h" //#define DEBUG_PDCCH_DMRS //#define DEBUG_DCI diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.h b/openair1/PHY/NR_TRANSPORT/nr_dci.h index 21fcd06c09bcd5fcb4bee2520ce12fea32e7a90a..f53f5be28277bff42fd1bd6f7b1c2bf1a3a6b2d3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.h @@ -25,8 +25,6 @@ #include "PHY/defs_gNB.h" #include "PHY/NR_REFSIG/nr_refsig.h" -typedef unsigned __int128 uint128_t; - uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format, nfapi_nr_rnti_type_e rnti_type, uint16_t N_RB, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 14d8958811d887322360a7a1f97fb8d3c1591d3d..b3925060953332ec506afba59a6a2a371dc2315b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -64,9 +64,9 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m } if (pdcch_params->cr_mapping_type == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - AssertFatal((N_reg % (bsize*R))==0, "CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n", - N_reg, bsize, R); - C = N_reg/(bsize*R); + uint16_t assertFatalCond = (N_reg%(bsize*R)); + AssertFatal(assertFatalCond == 0,"CCE to REG interleaving: Invalid configuration leading to non integer C (N_reg %us, bsize %d R %d)\n",N_reg, bsize, R); + C = N_reg/(bsize*R); } tmp = L * (( Y + (m*N_cce)/(L*M_s_max) + n_CI ) % CEILIDIV(N_cce,L)); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h index 06969eded03422b43f0454a63d4924bac2e79a6d..f5f1ba3d0a451b35ba46a73718f74a94af021b85 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.h @@ -67,6 +67,11 @@ void nr_pdsch_codeword_scrambling(uint8_t *in, uint32_t n_RNTI, uint32_t* out); +void nr_modulation(uint32_t *in, + uint16_t length, + nr_mod_t modulation_type, + int16_t *out); + void nr_pdsch_codeword_modulation(uint32_t *in, uint8_t Qm, uint32_t length, @@ -96,6 +101,8 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); +void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch); + int nr_dlsch_encoding(unsigned char *a, uint8_t subframe, NR_gNB_DLSCH_t *dlsch, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 50e836fe5843798c05d0f1052540efbf50e8f7ba..0a2927d881d5d79bc2af6f5e5de78ceb063e2239 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -282,8 +282,8 @@ int nr_dlsch_encoding(unsigned char *a, uint32_t A, Z, F=0; uint32_t *pz = &Z; uint8_t mod_order = rel15.modulation_order; - uint16_t Kr=0,r,r_offset=0,Kr_bytes; - uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; + uint16_t Kr=0,r,r_offset=0; + //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; uint8_t BG=1; uint32_t E; uint8_t Ilbrm = 0; @@ -354,13 +354,16 @@ int nr_dlsch_encoding(unsigned char *a, } Kr = dlsch->harq_processes[harq_pid]->K; +#ifdef DEBUG_DLSCH_CODING + uint16_t Kr_bytes; Kr_bytes = Kr>>3; +#endif //printf("segment Z %d k %d Kr %d BG %d\n", *pz,dlsch->harq_processes[harq_pid]->K,Kr,BG); //start_meas(te_stats); for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { - d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; + //d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; //channel_input[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; #ifdef DEBUG_DLSCH_CODING printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F); @@ -393,7 +396,6 @@ int nr_dlsch_encoding(unsigned char *a, //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); - //write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); #ifdef DEBUG_DLSCH_CODING write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4); diff --git a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c index 9fb73fa9940e46f73c496349aaeec40898f3ffc1..83d0d72b2857d3fd1f0bd550959052ab02fd19c3 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_tbs_tools.c @@ -112,12 +112,9 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, nfapi_nr_dl_config_pdcch_parameters_rel15_t params_rel15 = dci_pdu.pdcch_params_rel15; nfapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_rel15 = &dlsch_pdu->dlsch_pdu_rel15; uint8_t rnti_type = params_rel15.rnti_type; - uint8_t dci_format = params_rel15.dci_format; - uint8_t ss_type = params_rel15.search_space_type; uint8_t N_PRB_oh = ((rnti_type==NFAPI_NR_RNTI_SI)||(rnti_type==NFAPI_NR_RNTI_RA)||(rnti_type==NFAPI_NR_RNTI_P))? 0 : \ (config.pdsch_config.x_overhead.value); uint8_t N_PRB_DMRS = (config.pdsch_config.dmrs_type.value == NFAPI_NR_DMRS_TYPE1)?6:4; //This only works for antenna port 1000 - uint8_t mcs_table = config.pdsch_config.mcs_table.value; uint8_t N_sh_symb = dlsch_rel15->nb_symbols; uint8_t Imcs = dlsch_rel15->mcs_idx; uint16_t N_RE_prime = NR_NB_SC_PER_RB*N_sh_symb - N_PRB_DMRS - N_PRB_oh; @@ -126,7 +123,11 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, uint16_t N_RE, Ninfo, Ninfo_prime, C, TBS=0, R; uint8_t table_idx, Qm, n, scale; - table_idx = 1; //get_table_idx(mcs_table, dci_format, rnti_type, ss_type); + /*uint8_t mcs_table = config.pdsch_config.mcs_table.value; + uint8_t ss_type = params_rel15.search_space_type; + uint8_t dci_format = params_rel15.dci_format; + get_table_idx(mcs_table, dci_format, rnti_type, ss_type);*/ + table_idx = 1; scale = ((table_idx==2)&&((Imcs==20)||(Imcs==26)))?11:10; N_RE = min(156, N_RE_prime)*dlsch_rel15->n_prb; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index ace93e4ee3879240ce891e0fe665fcbf72e1ee5e..f9d82914234200649435a7931c80dccb3a3c3f23 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -171,6 +171,104 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 return(NULL); } +void clean_gNB_ulsch(NR_gNB_ULSCH_t *ulsch) +{ + unsigned char i, j; + + if (ulsch) { + ulsch->harq_mask = 0; + ulsch->bundling = 0; + ulsch->beta_offset_cqi_times8 = 0; + ulsch->beta_offset_ri_times8 = 0; + ulsch->beta_offset_harqack_times8 = 0; + ulsch->Msg3_active = 0; + ulsch->Msg3_flag = 0; + ulsch->Msg3_subframe = 0; + ulsch->Msg3_frame = 0; + ulsch->rnti = 0; + ulsch->rnti_type = 0; + ulsch->cyclicShift = 0; + ulsch->cooperation_flag = 0; + ulsch->Mlimit = 0; + ulsch->max_ldpc_iterations = 0; + ulsch->last_iteration_cnt = 0; + ulsch->num_active_cba_groups = 0; + for (i=0;i<NUM_MAX_CBA_GROUP;i++) ulsch->cba_rnti[i] = 0; + for (i=0;i<NR_MAX_SLOTS_PER_FRAME;i++) ulsch->harq_process_id[i] = 0; + + for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) { + if (ulsch->harq_processes[i]){ + /// Nfapi ULSCH PDU + //nfapi_nr_ul_config_ulsch_pdu ulsch_pdu; + ulsch->harq_processes[i]->frame=0; + ulsch->harq_processes[i]->subframe=0; + ulsch->harq_processes[i]->round=0; + ulsch->harq_processes[i]->TPC=0; + ulsch->harq_processes[i]->mimo_mode=0; + ulsch->harq_processes[i]->dci_alloc=0; + ulsch->harq_processes[i]->rar_alloc=0; + ulsch->harq_processes[i]->status=0; + ulsch->harq_processes[i]->subframe_scheduling_flag=0; + ulsch->harq_processes[i]->subframe_cba_scheduling_flag=0; + ulsch->harq_processes[i]->phich_active=0; + ulsch->harq_processes[i]->phich_ACK=0; + ulsch->harq_processes[i]->previous_first_rb=0; + ulsch->harq_processes[i]->handled=0; + ulsch->harq_processes[i]->delta_TF=0; + + ulsch->harq_processes[i]->TBS=0; + /// Pointer to the payload (38.212 V15.4.0 section 5.1) + //uint8_t *b; + ulsch->harq_processes[i]->B=0; + /// Pointers to code blocks after code block segmentation and CRC attachment (38.212 V15.4.0 section 5.2.2) + //uint8_t *c[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->K=0; + ulsch->harq_processes[i]->F=0; + ulsch->harq_processes[i]->C=0; + /// Pointers to code blocks after LDPC coding (38.212 V15.4.0 section 5.3.2) + //int16_t *d[MAX_NUM_NR_ULSCH_SEGMENTS]; + /// LDPC processing buffer + //t_nrLDPC_procBuf* p_nrLDPC_procBuf[MAX_NUM_NR_ULSCH_SEGMENTS]; + ulsch->harq_processes[i]->Z=0; + /// code blocks after bit selection in rate matching for LDPC code (38.212 V15.4.0 section 5.4.2.1) + //int16_t e[MAX_NUM_NR_DLSCH_SEGMENTS][3*8448]; + ulsch->harq_processes[i]->E=0; + ulsch->harq_processes[i]->G=0; + + + ulsch->harq_processes[i]->n_DMRS=0; + ulsch->harq_processes[i]->n_DMRS2=0; + ulsch->harq_processes[i]->previous_n_DMRS=0; + + + ulsch->harq_processes[i]->cqi_crc_status=0; + for (j=0;j<MAX_CQI_BYTES;j++) ulsch->harq_processes[i]->o[j]=0; + ulsch->harq_processes[i]->uci_format=0; + ulsch->harq_processes[i]->Or1=0; + ulsch->harq_processes[i]->Or2=0; + ulsch->harq_processes[i]->o_RI[0]=0; ulsch->harq_processes[i]->o_RI[1]=0; + ulsch->harq_processes[i]->O_RI=0; + ulsch->harq_processes[i]->o_ACK[0]=0; ulsch->harq_processes[i]->o_ACK[1]=0; + ulsch->harq_processes[i]->o_ACK[2]=0; ulsch->harq_processes[i]->o_ACK[3]=0; + ulsch->harq_processes[i]->O_ACK=0; + ulsch->harq_processes[i]->V_UL_DAI=0; + /// "q" sequences for CQI/PMI (for definition see 36-212 V8.6 2009-03, p.27) + //int8_t q[MAX_CQI_PAYLOAD]; + ulsch->harq_processes[i]->o_RCC=0; + /// coded and interleaved CQI bits + //int8_t o_w[(MAX_CQI_BITS+8)*3]; + /// coded CQI bits + //int8_t o_d[96+((MAX_CQI_BITS+8)*3)]; + for (j=0;j<MAX_ACK_PAYLOAD;j++) ulsch->harq_processes[i]->q_ACK[j]=0; + for (j=0;j<MAX_RI_PAYLOAD;j++) ulsch->harq_processes[i]->q_RI[j]=0; + /// Temporary h sequence to flag PUSCH_x/PUSCH_y symbols which are not scrambled + //uint8_t h[MAX_NUM_CHANNEL_BITS]; + /// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15) + //int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)]; + } + } + } +} uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint8_t UE_id, @@ -205,7 +303,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, int16_t z [68*384]; int8_t l [68*384]; - int16_t inv_d [68*384]; + //int16_t inv_d [68*384]; uint8_t kc; uint8_t Ilbrm = 0; uint32_t Tbslbrm = 950984; @@ -608,4 +706,4 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ulsch->last_iteration_cnt = ret; return(ret); -} \ No newline at end of file +} diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index f01a5ef60a6d8bb7fd85cdd2c7010609832d834a..9b309983b1903f58f5ced120587ee6f6312b9790 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -332,7 +332,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, //uint8_t rb_count_bit; uint8_t i, j, aarx, bitcnt_coreset_freq_dom=0; int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; +#ifdef NR_PDCCH_DCI_DEBUG int nushiftmod3 = frame_parms->nushift % 3; +#endif uint8_t symbol_mod; symbol_mod = (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol; c_rb = n_BWP_start; // c_rb is the common resource block: RB within the BWP @@ -809,8 +811,6 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, // indicates the number of active CORESETs for the current BWP to decode PDCCH: max is 3 (this variable is not useful here, to be removed) //uint8_t coreset_nbr_act; // indicates the number of REG contained in the PDCCH (number of RBs * number of symbols, in CORESET) - uint8_t coreset_nbr_reg; - uint32_t coreset_C; uint32_t coreset_nbr_rb = 0; // for (int j=0; j < coreset_nbr_act; j++) { // for each active CORESET (max number of active CORESETs in a BWP is 3), @@ -829,9 +829,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue, #ifdef NR_PDCCH_DCI_DEBUG printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_freq_dom=(%ld,%lx), coreset_nbr_rb=%d\n", coreset_freq_dom,coreset_freq_dom,coreset_nbr_rb); #endif - coreset_nbr_reg = coreset_time_dur * coreset_nbr_rb; - coreset_C = (uint32_t)(coreset_nbr_reg / (reg_bundle_size_L * coreset_interleaver_size_R)); #ifdef NR_PDCCH_DCI_DEBUG + uint8_t coreset_nbr_reg = coreset_time_dur * coreset_nbr_rb; + uint32_t coreset_C = (uint32_t)(coreset_nbr_reg / (reg_bundle_size_L * coreset_interleaver_size_R)); printf("\t<-NR_PDCCH_DCI_DEBUG (nr_rx_pdcch)-> coreset_nbr_rb=%d, coreset_nbr_reg=%d, coreset_C=(%d/(%d*%d))=%d\n", coreset_nbr_rb, coreset_nbr_reg, coreset_nbr_reg, reg_bundle_size_L,coreset_interleaver_size_R, coreset_C); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index e56ccd8af750c0c985af2c65a3640ca7bc553b74..73c5c3ef6f7060299c26f622f70cf5d9d7e47e40 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -231,14 +231,16 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, int16_t z [68*384]; int8_t l [68*384]; //__m128i l; - int16_t inv_d [68*384]; + //int16_t inv_d [68*384]; uint8_t kc; uint8_t Ilbrm = 0; uint32_t Tbslbrm = 950984; - uint16_t nb_rb = 30; //to update - uint8_t nb_re_dmrs = 6; - uint16_t length_dmrs = 1; + uint16_t nb_rb = 30; double Coderate = 0.0; + nfapi_nr_config_request_t *cfg = &phy_vars_ue->nrUE_config; + uint8_t dmrs_type = cfg->pdsch_config.dmrs_type.value; + uint8_t nb_re_dmrs = (dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4; + uint16_t length_dmrs = 1; //cfg->pdsch_config.dmrs_max_length.value; uint32_t i,j; @@ -312,15 +314,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, &harq_process->Z, // [hna] Z is Zc &harq_process->F); - p_decParams->Z = harq_process->Z; - #ifdef DEBUG_DLSCH_DECODING - printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z); if (!frame%100) printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl); #endif } + p_decParams->Z = harq_process->Z; + //printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z); + Coderate = (float) A /(float) G; if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 6c4fc3db10427e334dc7618404d8bfe0af257ccb..56f4d7cb1e33897792592b5d0e1003cb61f9f302 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -85,19 +85,19 @@ unsigned char offset_mumimo_llr_drange[29][3]={{8,8,8},{7,7,7},{7,7,7},{7,7,7},{ extern void print_shorts(char *s,int16_t *x); static void nr_dlsch_dual_stream_correlation_core(int **dl_ch_estimates_ext, - int **dl_ch_estimates_ext_i, - int **dl_ch_rho_ext, - unsigned char n_tx, - unsigned char n_rx, - unsigned char output_shift, - int length, - int start_point); + int **dl_ch_estimates_ext_i, + int **dl_ch_rho_ext, + unsigned char n_tx, + unsigned char n_rx, + unsigned char output_shift, + int length, + int start_point); static void nr_dlsch_layer_demapping(int16_t **llr_cw, - uint8_t Nl, - uint8_t mod_order, - uint16_t length, - int16_t **llr_layers); + uint8_t Nl, + uint8_t mod_order, + uint16_t length, + int16_t **llr_layers); int nr_rx_pdsch(PHY_VARS_NR_UE *ue, PDSCH_t type, @@ -128,7 +128,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, unsigned char aatx=0,aarx=0; - unsigned short nb_rb = 0, nb_re =0, round; + unsigned short nb_rb = 0, round; int avgs = 0;// rb; NR_DL_UE_HARQ_t *dlsch0_harq,*dlsch1_harq = 0; @@ -151,9 +151,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, //int16_t *pllr_symbol_cw1_deint; uint32_t llr_offset_symbol; //uint16_t bundle_L = 2; - uint8_t l0 =2; + uint8_t l0 =2, pilots=0; uint16_t n_tx=1, n_rx=1; int32_t median[16]; + uint32_t len; switch (type) { case SI_PDSCH: @@ -173,16 +174,9 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, case PDSCH: pdsch_vars = ue->pdsch_vars[ue->current_thread_id[nr_tti_rx]]; dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id]; - - - //set active for testing -> to be removed - dlsch[0]->harq_processes[harq_pid]->status = ACTIVE; - dlsch[0]->harq_processes[harq_pid]->Qm = 2; - dlsch[0]->harq_processes[harq_pid]->mcs = 9; - dlsch[0]->harq_processes[harq_pid]->Nl=1; - dlsch[0]->harq_processes[harq_pid]->round=0; - dlsch[0]->harq_processes[harq_pid]->nb_rb = nb_rb_pdsch; - frame_parms->nushift = 0; + + + dlsch[0]->harq_processes[harq_pid]->Qm = nr_get_Qm(dlsch[0]->harq_processes[harq_pid]->mcs, 1);; //printf("status TB0 = %d, status TB1 = %d \n", dlsch[0]->harq_processes[harq_pid]->status, dlsch[1]->harq_processes[harq_pid]->status); LOG_D(PHY,"AbsSubframe %d.%d / Sym %d harq_pid %d, harq status %d.%d \n", @@ -237,6 +231,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, printf("[DEMOD] cw for TB0 = %d, cw for TB1 = %d\n", codeword_TB0, codeword_TB1); #endif + start_rb = dlsch0_harq->start_rb; + nb_rb_pdsch = dlsch0_harq->nb_rb; + l0 = dlsch0_harq->start_symbol; + DevAssert(dlsch0_harq); round = dlsch0_harq->round; //printf("round = %d\n", round); @@ -298,9 +296,11 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, printf("Demod dlsch0_harq->pmi_alloc %d\n", dlsch0_harq->pmi_alloc); #endif + pilots = (symbol==l0) ? 1 : 0; + if (frame_parms->nb_antenna_ports_eNB>1 && beamforming_mode==0) { #ifdef DEBUG_DLSCH_MOD - LOG_I(PHY,"dlsch: using pmi %x (%p), rb_alloc %x\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0],dlsch0_harq->rb_alloc_even[0]); + LOG_I(PHY,"dlsch: using pmi %x (%p)\n",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),dlsch[0]); #endif #if UE_TIMING_TRACE @@ -312,8 +312,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->dl_ch_estimates_ext, dlsch0_harq->pmi_alloc, pdsch_vars[eNB_id]->pmi_ext, - rballoc, symbol, + pilots, start_rb, nb_rb_pdsch, nr_tti_rx, @@ -321,7 +321,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, frame_parms, dlsch0_harq->mimo_mode); #ifdef DEBUG_DLSCH_MOD - printf("dlsch: using pmi %lx, rb_alloc %x, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc),*rballoc); + printf("dlsch: using pmi %lx, pmi_ext ",pmi2hex_2Ar1(dlsch0_harq->pmi_alloc)); for (rb=0;rb<nb_rb;rb++) printf("%d",pdsch_vars[eNB_id]->pmi_ext[rb]); printf("\n"); @@ -335,8 +335,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id_i]->dl_ch_estimates_ext, dlsch0_harq->pmi_alloc, pdsch_vars[eNB_id_i]->pmi_ext, - rballoc, symbol, + pilots, start_rb, nb_rb_pdsch, nr_tti_rx, @@ -350,8 +350,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id_i]->dl_ch_estimates_ext, dlsch0_harq->pmi_alloc, pdsch_vars[eNB_id_i]->pmi_ext, - rballoc, symbol, + pilots, start_rb, nb_rb_pdsch, nr_tti_rx, @@ -367,8 +367,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->dl_ch_estimates_ext, dlsch0_harq->pmi_alloc, pdsch_vars[eNB_id]->pmi_ext, - rballoc, symbol, + pilots, start_rb, nb_rb_pdsch, nr_tti_rx, @@ -424,6 +424,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, return(-1); } + len = (symbol==l0)? (nb_rb*6):(nb_rb*12); + #if UE_TIMING_TRACE stop_meas(&ue->generic_stat_bis[ue->current_thread_id[nr_tti_rx]][slot]); #if DISABLE_LOG_X @@ -440,12 +442,12 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, #endif n_tx = frame_parms->nb_antenna_ports_eNB; n_rx = frame_parms->nb_antennas_rx; - nb_re= (symbol==l0)? (nb_rb*6):(nb_rb*12); nr_dlsch_scale_channel(pdsch_vars[eNB_id]->dl_ch_estimates_ext, frame_parms, dlsch, symbol, + pilots, nb_rb); if ((dlsch0_harq->mimo_mode<DUALSTREAM_UNIFORM_PRECODING1) && @@ -458,6 +460,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, frame_parms, dlsch, symbol, + pilots, nb_rb); } @@ -480,6 +483,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, frame_parms, avg, symbol, + len, nb_rb); avgs = 0; for (aatx=0;aatx<frame_parms->nb_antenna_ports_eNB;aatx++) @@ -496,7 +500,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, median, n_tx, n_rx, - 2*nb_re,// subcarriers Re Im + 2*len,// subcarriers Re Im 0); for (aatx = 0; aatx < n_tx; ++aatx) @@ -602,6 +606,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, (aatx>1) ? pdsch_vars[eNB_id]->rho : NULL, frame_parms, symbol, + pilots, first_symbol_flag, dlsch0_harq->Qm, nb_rb, @@ -655,7 +660,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, n_rx, dlsch0_harq->Qm, pdsch_vars[eNB_id]->log2_maxh, - 2*nb_re, // subcarriers Re Im + 2*len, // subcarriers Re Im 0); // we start from the beginning of the vector /* if (symbol == 5) { write_output("rxF_comp_d00.m","rxF_c_d00",&pdsch_vars[eNB_id]->rxdataF_comp0[0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM @@ -670,7 +675,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, n_tx, n_rx, pdsch_vars[eNB_id]->log2_maxh, - 2*nb_re, + 2*len, 0); //printf("rho stream1 =%d\n", &pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round] ); nr_dlsch_dual_stream_correlation_core(&(pdsch_vars[eNB_id]->dl_ch_estimates_ext[2]), @@ -679,7 +684,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, n_tx, n_rx, pdsch_vars[eNB_id]->log2_maxh, - 2*nb_re, + 2*len, 0); // printf("rho stream2 =%d\n",&pdsch_vars[eNB_id]->dl_ch_rho2_ext ); //printf("TM3 log2_maxh : %d\n",pdsch_vars[eNB_id]->log2_maxh); @@ -719,7 +724,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, NULL, n_tx, n_rx, - 2*nb_re, + 2*len, 0); /* if (symbol == 5) { write_output("rho0_mrc.m","rho0_0",&pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round][0][symbol*frame_parms->N_RB_DL*12],frame_parms->N_RB_DL*12,1,1);// should be QAM @@ -792,7 +797,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pllr_symbol_cw0 += llr_offset_symbol; pllr_symbol_cw1 += llr_offset_symbol; - pdsch_vars[eNB_id]->llr_offset[symbol] = nb_re*dlsch0_harq->Qm + llr_offset_symbol; + pdsch_vars[eNB_id]->llr_offset[symbol] = len*dlsch0_harq->Qm + llr_offset_symbol; /*LOG_I(PHY,"compute LLRs [symbol %d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %x @LLR Buff(symb) %x\n", symbol, @@ -817,6 +822,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, pllr_symbol_cw0, symbol, + len, first_symbol_flag, nb_rb, beamforming_mode); @@ -827,6 +833,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, pllr_symbol_cw1, symbol, + len, first_symbol_flag, nb_rb, beamforming_mode); @@ -838,7 +845,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, rxdataF_comp_ptr, pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->layer_llr[0], - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,2,nr_tti_rx,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -847,7 +854,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->layer_llr[1], - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,2,nr_tti_rx,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } @@ -904,7 +911,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, pdsch_vars[eNB_id]->llr[0], pdsch_vars[eNB_id]->dl_ch_mag0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, pdsch_vars[eNB_id]->llr128, beamforming_mode); } else if (codeword_TB0 == -1){ @@ -912,7 +919,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, pdsch_vars[eNB_id]->llr[1], pdsch_vars[eNB_id]->dl_ch_mag0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, pdsch_vars[eNB_id]->llr128_2ndstream, beamforming_mode); } @@ -947,7 +954,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dl_ch_mag_ptr,//i pdsch_vars[eNB_id]->dl_ch_rho2_ext, pdsch_vars[eNB_id]->layer_llr[0], - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,4,nr_tti_rx,symbol), pdsch_vars[eNB_id]->llr128); if (rx_type==rx_IC_dual_stream) { @@ -958,7 +965,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->dl_ch_mag0,//i pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pdsch_vars[eNB_id]->layer_llr[1], - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,4,nr_tti_rx,symbol), pdsch_vars[eNB_id]->llr128_2ndstream); } @@ -996,7 +1003,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, (int16_t*)pllr_symbol_cw0, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } else if (codeword_TB0 == -1){ @@ -1005,7 +1012,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pllr_symbol_cw1, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } @@ -1064,7 +1071,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, dl_ch_mag_ptr,//i pdsch_vars[eNB_id]->dl_ch_rho2_ext, (int16_t*)pllr_symbol_layer0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch0_harq->rb_alloc_even,6,nr_tti_rx,symbol), pdsch_vars[eNB_id]->llr_offset[symbol]); if (rx_type==rx_IC_dual_stream) { @@ -1075,7 +1082,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->dl_ch_mag0,//i pdsch_vars[eNB_id]->dl_ch_rho_ext[harq_pid][round], pllr_symbol_layer1, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, adjust_G2(frame_parms,dlsch1_harq->rb_alloc_even,6,nr_tti_rx,symbol), pdsch_vars[eNB_id]->llr_offset[symbol]); } @@ -1094,7 +1101,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, nr_dlsch_qpsk_llr(frame_parms, pdsch_vars[eNB_id]->rxdataF_comp0, pllr_symbol_cw0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, beamforming_mode); } break; @@ -1104,7 +1111,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pdsch_vars[eNB_id]->rxdataF_comp0, pdsch_vars[eNB_id]->llr[0], pdsch_vars[eNB_id]->dl_ch_mag0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, pdsch_vars[eNB_id]->llr128, beamforming_mode); } @@ -1116,7 +1123,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, pllr_symbol_cw0, pdsch_vars[eNB_id]->dl_ch_mag0, pdsch_vars[eNB_id]->dl_ch_magb0, - symbol,first_symbol_flag,nb_rb, + symbol,len,first_symbol_flag,nb_rb, pdsch_vars[eNB_id]->llr_offset[symbol], beamforming_mode); } @@ -1132,10 +1139,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, if (rx_type==rx_IC_dual_stream) { nr_dlsch_layer_demapping(pdsch_vars[eNB_id]->llr, - dlsch[0]->harq_processes[harq_pid]->Nl, - dlsch[0]->harq_processes[harq_pid]->G, - -1, - pdsch_vars[eNB_id]->layer_llr); + dlsch[0]->harq_processes[harq_pid]->Nl, + dlsch[0]->harq_processes[harq_pid]->Qm, + dlsch[0]->harq_processes[harq_pid]->G, + pdsch_vars[eNB_id]->layer_llr); } #if UE_TIMING_TRACE @@ -1197,6 +1204,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } void nr_dlsch_deinterleaving(uint8_t symbol, + uint8_t start_symbol, uint16_t L, uint16_t *llr, uint16_t *llr_deint, @@ -1215,7 +1223,7 @@ void nr_dlsch_deinterleaving(uint8_t symbol, printf("N_bundle %d L %d nb_rb_pdsch %d\n",N_bundle, L,nb_rb_pdsch); - if (symbol==2) + if (symbol==start_symbol) nb_re = 6; else nb_re = 12; @@ -1253,6 +1261,7 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, int **rho, NR_DL_FRAME_PARMS *frame_parms, unsigned char symbol, + uint8_t pilots, uint8_t first_symbol_flag, unsigned char mod_order, unsigned short nb_rb, @@ -1263,16 +1272,11 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext, #if defined(__i386) || defined(__x86_64) unsigned short rb; - unsigned char aatx,aarx,pilots=0; + unsigned char aatx,aarx; __m128i *dl_ch128,*dl_ch128_2,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128; __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; QAM_amp128b = _mm_setzero_si128(); - if (symbol == 2){ - pilots=1; - } - - for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { if (mod_order == 4) { QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) @@ -1917,19 +1921,19 @@ void nr_dlsch_scale_channel(int **dl_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, NR_UE_DLSCH_t **dlsch_ue, uint8_t symbol, + uint8_t pilots, unsigned short nb_rb) { #if defined(__x86_64__)||defined(__i386__) short rb, ch_amp; - unsigned char aatx,aarx,pilots=0; + unsigned char aatx,aarx; __m128i *dl_ch128, ch_amp128; - if (symbol==2){ + if (pilots==1){ nb_rb = nb_rb>>1; - pilots=1; } // Determine scaling amplitude based the symbol @@ -1977,6 +1981,7 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, int32_t *avg, uint8_t symbol, + uint32_t len, unsigned short nb_rb) { @@ -1986,14 +1991,9 @@ void nr_dlsch_channel_level(int **dl_ch_estimates_ext, unsigned char aatx,aarx,nre=12; __m128i *dl_ch128, avg128D; - if (symbol==2) //assume start symbol 2 - nre=6; - else - nre=12; - //nb_rb*nre = y * 2^x - int16_t x = factor2(nb_rb*nre); - int16_t y = (nb_rb*nre)>>x; + int16_t x = factor2(len); + int16_t y = (len)>>x; //printf("nb_rb*nre = %d = %d * 2^(%d)\n",nb_rb*nre,y,x); for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) @@ -2492,8 +2492,8 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, int **dl_ch_estimates_ext, unsigned short pmi, unsigned char *pmi_ext, - unsigned int *rb_alloc, //unused in NR unsigned char symbol, + uint8_t pilots, unsigned short start_rb, unsigned short nb_rb_pdsch, unsigned char nr_tti_rx, @@ -2508,9 +2508,8 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, - unsigned char pilots=0,j=0; + unsigned char j=0; - pilots = (symbol==2) ? 1 : 0; //to updated from config!!! k = frame_parms->first_carrier_offset + 12*start_rb; for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { @@ -2593,8 +2592,8 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, int **dl_ch_estimates_ext, unsigned short pmi, unsigned char *pmi_ext, - unsigned int *rb_alloc, unsigned char symbol, + uint8_t pilots, unsigned short start_rb, unsigned short nb_rb_pdsch, unsigned char nr_tti_rx, @@ -2604,19 +2603,11 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, int prb,nb_rb=0; unsigned short k; - //int prb_off,prb_off2; - int skip_half=0,l;//sss_symb,pss_symb=0,nsymb - int i,aarx; + int i,j,aarx; int32_t *dl_ch0=NULL,*dl_ch0p=NULL,*dl_ch0_ext=NULL,*dl_ch1=NULL,*dl_ch1p=NULL,*dl_ch1_ext=NULL,*rxF=NULL,*rxF_ext=NULL; - int symbol_mod,pilots=0,j=0; - unsigned char *pmi_loc=NULL; - pilots = (symbol==2) ? 1 : 0; //to updated from config k = frame_parms->first_carrier_offset + 516; //0 - //nsymb = (frame_parms->Ncp==NORMAL) ? 14:12; - l=symbol; - for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { if (high_speed_flag==1) { @@ -2627,7 +2618,7 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, dl_ch1 = &dl_ch_estimates[2+aarx][0]; } - pmi_loc = pmi_ext; + //pmi_loc = pmi_ext; // pointers to extracted RX signals and channel estimates rxF_ext = &rxdataF_ext[aarx][symbol*(nb_rb_pdsch*12)]; @@ -2635,13 +2626,13 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, dl_ch1_ext = &dl_ch_estimates_ext[2+aarx][symbol*(nb_rb_pdsch*12)]; for (prb=0; prb<frame_parms->N_RB_DL; prb++) { - skip_half=0; + //skip_half=0; if ((frame_parms->N_RB_DL&1) == 0) { // even number of RBs // For second half of RBs skip DC carrier if (k>=frame_parms->ofdm_symbol_size) { - rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))]; + rxF = &rxdataF[aarx][(symbol*(frame_parms->ofdm_symbol_size))]; k=k-(frame_parms->ofdm_symbol_size); } @@ -2688,11 +2679,12 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, return(nb_rb/frame_parms->nb_antennas_rx); } + static void nr_dlsch_layer_demapping(int16_t **llr_cw, - uint8_t Nl, - uint8_t mod_order, - uint16_t length, - int16_t **llr_layers) { + uint8_t Nl, + uint8_t mod_order, + uint16_t length, + int16_t **llr_layers) { switch (Nl) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c index 29f3ffd758c118b441a802ad774a11d8c91d9b8c..a02efd9a82fd5236de57c73fe502b8f42f009b15 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_llr_computation.c @@ -632,6 +632,7 @@ int nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, int16_t *dlsch_llr, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint8_t beamforming_mode) @@ -639,7 +640,7 @@ int nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, uint32_t *rxF = (uint32_t*)&rxdataF_comp[0][((int32_t)symbol*nb_rb*12)]; uint32_t *llr32; - int i,len; + int i; llr32 = (uint32_t*)dlsch_llr; if (!llr32) { @@ -647,10 +648,6 @@ int nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, return(-1); } - if (symbol ==2) //to update from config - len = nb_rb*6; - else - len = nb_rb*12; /* LOG_I(PHY,"dlsch_qpsk_llr: [symb %d / Length %d]: @LLR Buff %x, @LLR Buff(symb) %x \n", symbol, @@ -677,6 +674,7 @@ void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, int16_t *dlsch_llr, int32_t **dl_ch_mag, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, int16_t **llr32p, @@ -696,7 +694,7 @@ void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, #endif - int i,len; + int i; unsigned char len_mod4=0; @@ -720,11 +718,6 @@ void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, ch_mag = (int16x8_t*)&dl_ch_mag[0][(symbol*nb_rb*12)]; #endif - if (symbol ==2) //to update from config - len = nb_rb*6; - else - len = nb_rb*12; - // update output pointer according to number of REs in this symbol (<<2 because 4 bits per RE) if (first_symbol_flag == 1) *llr32p = dlsch_llr + (len<<2); @@ -798,6 +791,7 @@ void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **dl_ch_mag, int32_t **dl_ch_magb, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint32_t llr_offset, @@ -810,7 +804,7 @@ void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, int16x8_t *rxF = (int16x8_t*)&rxdataF_comp[0][(symbol*nb_rb*12)]; int16x8_t *ch_mag,*ch_magb,xmm1,xmm2; #endif - int i,len,len2; + int i,len2; unsigned char len_mod4; short *llr; int16_t *llr2; @@ -835,11 +829,6 @@ void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, ch_magb = (int16x8_t*)&dl_ch_magb[0][(symbol*frame_parms->N_RB_DL*12)]; #endif - if (symbol ==2) //to update from config - len = nb_rb*6; - else - len = nb_rb*12; - // printf("nr_dlsch_64qam_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); /* LOG_I(PHY,"nr_dlsch_64qam_llr [symb %d / FirstSym %d / Length %d]: @LLR Buff %x \n", @@ -1131,6 +1120,7 @@ int nr_dlsch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int **rho_i, short *dlsch_llr, unsigned char symbol, + uint32_t len, unsigned char first_symbol_flag, unsigned short nb_rb, uint16_t pbch_pss_sss_adjust, @@ -1141,8 +1131,6 @@ int nr_dlsch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int16_t *rxF_i=(int16_t*)&rxdataF_comp_i[0][(symbol*nb_rb*12)]; int16_t *rho=(int16_t*)&rho_i[0][(symbol*nb_rb*12)]; int16_t *llr16; - int len; - //uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; if (first_symbol_flag == 1) { llr16 = (int16_t*)dlsch_llr; @@ -1152,11 +1140,6 @@ int nr_dlsch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, AssertFatal(llr16!=NULL,"nr_dlsch_qpsk_qpsk_llr: llr is null, symbol %d\n",symbol); - if (symbol ==2) //to update from config - len = nb_rb*6; - else - len = nb_rb*12; - // printf("nr_dlsch_qpsk_qpsk_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); // printf("qpsk_qpsk: len %d, llr16 %p\n",len,llr16); qpsk_qpsk((short *)rxF, @@ -2972,6 +2955,7 @@ int nr_dlsch_16qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rho_i, int16_t *dlsch_llr, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adjust, @@ -2984,8 +2968,6 @@ int nr_dlsch_16qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*nb_rb*12)]; int16_t *rho = (int16_t*)&rho_i[0][(symbol*nb_rb*12)]; int16_t *llr16; - int len; - //uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; // first symbol has different structure due to more pilots if (first_symbol_flag == 1) { @@ -2997,11 +2979,6 @@ int nr_dlsch_16qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, AssertFatal(llr16!=NULL,"nr_dlsch_16qam_16qam_llr: llr is null, symbol %d\n",symbol); - if (symbol ==2) //to update from config - len = nb_rb*6; - else - len = nb_rb*12; - // printf("symbol %d: qam16_llr, len %d (llr16 %p)\n",symbol,len,llr16); qam16_qam16((short *)rxF, @@ -8514,6 +8491,7 @@ int nr_dlsch_64qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rho_i, int16_t *dlsch_llr, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adjust, @@ -8521,15 +8499,13 @@ int nr_dlsch_64qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, uint32_t llr_offset) { - int16_t *rxF = (int16_t*)&rxdataF_comp[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rxF_i = (int16_t*)&rxdataF_comp_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *ch_mag = (int16_t*)&dl_ch_mag[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*frame_parms->N_RB_DL*12)]; - int16_t *rho = (int16_t*)&rho_i[0][(symbol*frame_parms->N_RB_DL*12)]; + int16_t *rxF = (int16_t*)&rxdataF_comp[0][(symbol*nb_rb*12)]; + int16_t *rxF_i = (int16_t*)&rxdataF_comp_i[0][(symbol*nb_rb*12)]; + int16_t *ch_mag = (int16_t*)&dl_ch_mag[0][(symbol*nb_rb*12)]; + int16_t *ch_mag_i = (int16_t*)&dl_ch_mag_i[0][(symbol*nb_rb*12)]; + int16_t *rho = (int16_t*)&rho_i[0][(symbol*nb_rb*12)]; int16_t *llr16; int8_t *pllr_symbol; // pointer where llrs should filled for this ofdm symbol - int len; - uint8_t symbol_mod = (symbol >= (7-frame_parms->Ncp))? (symbol-(7-frame_parms->Ncp)) : symbol; //first symbol has different structure due to more pilots /*if (first_symbol_flag == 1) { @@ -8543,19 +8519,6 @@ int nr_dlsch_64qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, AssertFatal(llr16!=NULL,"nr_dlsch_16qam_64qam_llr:llr is null, symbol %d\n",symbol); - if ((symbol_mod==0) || (symbol_mod==(4-frame_parms->Ncp))) { - // if symbol has pilots - if (frame_parms->nb_antenna_ports_eNB!=1) - // in 2 antenna ports we have 8 REs per symbol per RB - len = (nb_rb*8) - (2*pbch_pss_sss_adjust/3); - else - // for 1 antenna port we have 10 REs per symbol per RB - len = (nb_rb*10) - (5*pbch_pss_sss_adjust/6); - } else { - // symbol has no pilots - len = (nb_rb*12) - pbch_pss_sss_adjust; - } - pllr_symbol = (int8_t*)dlsch_llr; pllr_symbol += llr_offset; //printf("nr_dlsch_64qam_64qam_llr: symbol %d,nb_rb %d, len %d,pbch_pss_sss_adjust %d\n",symbol,nb_rb,len,pbch_pss_sss_adjust); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h index 48cf637529e6ceac224ac46444c6d1c0c8fdbc76..e7af6323277b05b70cc85096775e69e869b8c9ef 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h @@ -113,6 +113,7 @@ int32_t nr_dlsch_qpsk_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rho_i, int16_t *dlsch_llr, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint16_t pbch_pss_sss_adj, @@ -268,6 +269,7 @@ int nr_dlsch_16qam_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, int **rho_i, short *dlsch_llr, unsigned char symbol, + uint32_t len, unsigned char first_symbol_flag, unsigned short nb_rb, uint16_t pbch_pss_sss_adjust, @@ -464,6 +466,7 @@ int nr_dlsch_64qam_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, int **rho_i, short *dlsch_llr, unsigned char symbol, + uint32_t len, unsigned char first_symbol_flag, unsigned short nb_rb, uint16_t pbch_pss_sss_adjust, @@ -486,6 +489,7 @@ int32_t nr_dlsch_qpsk_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, int16_t *dlsch_llr, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint8_t beamforming_mode); @@ -520,6 +524,7 @@ void nr_dlsch_16qam_llr(NR_DL_FRAME_PARMS *frame_parms, int16_t *dlsch_llr, int32_t **dl_ch_mag, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, int16_t **llr32p, @@ -568,6 +573,7 @@ void nr_dlsch_64qam_llr(NR_DL_FRAME_PARMS *frame_parms, int32_t **dl_ch_mag, int32_t **dl_ch_magb, uint8_t symbol, + uint32_t len, uint8_t first_symbol_flag, uint16_t nb_rb, uint32_t llr_offset, @@ -722,8 +728,8 @@ unsigned short nr_dlsch_extract_rbs_single(int **rxdataF, int **dl_ch_estimates_ext, unsigned short pmi, unsigned char *pmi_ext, - unsigned int *rb_alloc, unsigned char symbol, + uint8_t pilots, unsigned short start_rb, unsigned short nb_pdsch_rb, unsigned char nr_tti_rx, @@ -759,8 +765,8 @@ unsigned short nr_dlsch_extract_rbs_dual(int **rxdataF, int **dl_ch_estimates_ext, unsigned short pmi, unsigned char *pmi_ext, - unsigned int *rb_alloc, unsigned char symbol, + uint8_t pilots, unsigned short start_rb, unsigned short nb_rb_pdsch, unsigned char nr_tti_rx, @@ -822,6 +828,7 @@ void nr_dlsch_channel_compensation(int32_t **rxdataF_ext, int32_t **rho, NR_DL_FRAME_PARMS *frame_parms, uint8_t symbol, + uint8_t start_symbol, uint8_t first_symbol_flag, uint8_t mod_order, uint16_t nb_rb, @@ -842,6 +849,7 @@ void nr_dlsch_channel_compensation_core(int **rxdataF_ext, int start_point); void nr_dlsch_deinterleaving(uint8_t symbol, + uint8_t start_symbol, uint16_t L, uint16_t *llr, uint16_t *llr_deint, @@ -974,11 +982,12 @@ void dlsch_channel_compensation_TM34(NR_DL_FRAME_PARMS *frame_parms, @param pilots_flag Flag to indicate pilots in symbol @param nb_rb Number of allocated RBs */ -void nr_dlsch_channel_level(int32_t **dl_ch_estimates_ext, +void nr_dlsch_channel_level(int **dl_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, int32_t *avg, - uint8_t pilots_flag, - uint16_t nb_rb); + uint8_t symbol, + uint32_t len, + unsigned short nb_rb); void dlsch_channel_level_TM34(int **dl_ch_estimates_ext, @@ -1007,7 +1016,8 @@ void dlsch_channel_level_TM7(int32_t **dl_bf_ch_estimates_ext, void nr_dlsch_scale_channel(int32_t **dl_ch_estimates_ext, NR_DL_FRAME_PARMS *frame_parms, NR_UE_DLSCH_t **dlsch_ue, - uint8_t symbol_mod, + uint8_t symbol, + uint8_t start_symbol, uint16_t nb_rb); /** \brief This is the top-level entry point for DLSCH decoding in UE. It should be replicated on several diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 2facd85babf3525981767cb88b13ec4e1cf031ab..7d2abd999302101ffdb04dd9f949a9e1314d0496 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -246,7 +246,7 @@ typedef struct { /// allocated CBA RNTI //uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; /// UL max-harq-retransmission - uint8_t Mlimit; + uint16_t Mlimit; } NR_UE_ULSCH_t; typedef struct { diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 70a34f2c66f142b4841fa571f16c31605c4f4635..95ca86959f92eeaef39620731114150aeb25d10b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -39,6 +39,7 @@ #include "PHY/CODING/nrLDPC_encoder/defs.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "common/utils/LOG/vcd_signal_dumper.h" +#include "PHY/NR_TRANSPORT/nr_dlsch.h" @@ -92,7 +93,7 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, int number_of_harq_pids, u { NR_UE_ULSCH_t *ulsch; - unsigned char exit_flag = 0,i,j,r; + unsigned char exit_flag = 0,i,r; unsigned char bw_scaling =1; switch (N_RB_UL) { @@ -203,15 +204,14 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, uint32_t A, Z, F; uint32_t *pz; uint8_t mod_order; - uint16_t Kr,r,r_offset,Kr_bytes; - uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; + uint16_t Kr,r,r_offset; + //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; uint8_t BG; uint32_t E; uint8_t Ilbrm; uint32_t Tbslbrm; uint8_t nb_re_dmrs; uint16_t length_dmrs; - int i; float Coderate; /////////// @@ -311,8 +311,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, } Kr = harq_process->K; +#ifdef DEBUG_DLSCH_CODING + uint16_t Kr_bytes; Kr_bytes = Kr>>3; - +#endif /////////// ///////////////////////////////////////////////////////////////////////////////////// @@ -325,7 +327,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //start_meas(te_stats); for (r=0; r<harq_process->C; r++) { - d_tmp[r] = &harq_process->d[r][0]; + //d_tmp[r] = &harq_process->d[r][0]; //channel_input[r] = &harq_process->d[r][0]; #ifdef DEBUG_DLSCH_CODING printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F); @@ -357,7 +359,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, //stop_meas(te_stats); //printf("end ldpc encoder -- output\n"); - //write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); #ifdef DEBUG_DLSCH_CODING write_output("ulsch_enc_input0.m","enc_in0",&harq_process->c[0][0],Kr_bytes,1,4); write_output("ulsch_enc_output0.m","enc0",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,4); diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 2327a5036bdf54718bdb9570f233eec3080a2bd6..41b055a7ff84d890c1cb64de67afc2ff6b87d3f4 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -990,7 +990,7 @@ void nr_uci_encoding(uint64_t payload, // A is the payload size, to be provided in function call uint8_t A = nr_bit; // L is the CRC size - uint8_t L; + //uint8_t L; // E is the rate matching output sequence length as given in TS 38.212 subclause 6.3.1.4.1 uint16_t E=0,E_init; @@ -1047,7 +1047,7 @@ void nr_uci_encoding(uint64_t payload, } *M_bit = E; - int I_seg; + //int I_seg; #ifdef DEBUG_NR_PUCCH_TX printf("\t\t [nr_uci_encoding] start function with fmt=%d, encoding A=%d bits into M_bit=%d (where nrofSymbols=%d,nrofPRB=%d)\n",fmt,A,*M_bit,nrofSymbols,nrofPRB); #endif @@ -1057,19 +1057,19 @@ void nr_uci_encoding(uint64_t payload, // CRC bits are not attached, and coding small block lengths (subclause 5.3.3) } else if (A>=12) { // procedure in subclause 6.3.1.2.1 (UCI encoded by Polar code -> subclause 6.3.1.3.1) - if ((A>=360 && E>=1088)||(A>=1013)) { + /*if ((A>=360 && E>=1088)||(A>=1013)) { I_seg = 1; } else { I_seg = 0; - } + }*/ - if (A>=20) { + /*if (A>=20) { // parity bits (subclause 5.2.1) computed by setting L=11 and using generator polynomial gCRC11(D) (subclause 5.1) L=11; } else if (A<=19) { // parity bits (subclause 5.2.1) computed by setting L=6 and using generator polynomial gCRC6(D) (subclause 5.1) L=6; - } + }*/ // code block segmentation and CRC attachment is performed according to subclause 5.2.1 // polar coding subclause 5.3.1 diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 1ea5814e8d1592bf90b89e2796b6329f33d76093..8f463b59b54de0618dfd6d6493c585cad5094645 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -916,6 +916,7 @@ typedef struct { NR_UE_COMMON common_vars; nr_ue_if_module_t *if_inst; + nfapi_nr_config_request_t nrUE_config; nr_downlink_indication_t dl_indication; nr_uplink_indication_t ul_indication; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 6adb2271e2af41a3e3bec7c34a2e3872d2b30ad8..591d6094547c44011dc8b92e2b1342d6ea7501be 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -333,5 +333,4 @@ typedef struct nr_band_info_s { nr_bandentry_t band_info[100]; } nr_band_info_t; - #endif diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 139d48ffa9d94cfe3a35a8b66e04e3a3e7e46ffb..0432ded427be5699c8f21ac3ed7434b342f9eeed 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -56,7 +56,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ NR_UE_PDCCH *pdcch_vars2 = PHY_vars_UE_g[module_id][cc_id]->pdcch_vars[thread_id][0]; NR_UE_DLSCH_t *dlsch0 = PHY_vars_UE_g[module_id][cc_id]->dlsch[thread_id][0][0]; NR_UE_ULSCH_t *ulsch0 = PHY_vars_UE_g[module_id][cc_id]->ulsch[thread_id][0][0]; - NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms; + //NR_DL_FRAME_PARMS frame_parms = PHY_vars_UE_g[module_id][cc_id]->frame_parms; PRACH_RESOURCES_t *prach_resources = PHY_vars_UE_g[module_id][cc_id]->prach_resources[0]; // PUCCH_ConfigCommon_nr_t *pucch_config_common = PHY_vars_UE_g[module_id][cc_id]->pucch_config_common_nr[0]; @@ -123,7 +123,10 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ dlsch0->g_pucch = dlsch_config_pdu->accumulated_delta_PUCCH; dlsch0_harq->harq_ack.pucch_resource_indicator = dlsch_config_pdu->pucch_resource_id; dlsch0_harq->harq_ack.slot_for_feedback_ack = dlsch_config_pdu->pdsch_to_harq_feedback_time_ind; + dlsch0_harq->Nl=1; + dlsch0_harq->status = ACTIVE; LOG_D(MAC,">>>> \tdlsch0->g_pucch=%d\tdlsch0_harq.mcs=%d\n",dlsch0->g_pucch,dlsch0_harq->mcs); + } } }else{ @@ -185,11 +188,11 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ if(ul_config->ul_config_list[i].pdu_type == FAPI_NR_UL_CONFIG_TYPE_PRACH){ // prach config pdu fapi_nr_ul_config_prach_pdu *prach_config_pdu = &ul_config->ul_config_list[i].prach_config_pdu; - frame_parms.prach_config_common.rootSequenceIndex = prach_config_pdu->root_sequence_index; + /*frame_parms.prach_config_common.rootSequenceIndex = prach_config_pdu->root_sequence_index; frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = prach_config_pdu->prach_configuration_index; frame_parms.prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = prach_config_pdu->zero_correlation_zone_config; frame_parms.prach_config_common.prach_ConfigInfo.highSpeedFlag = prach_config_pdu->restrictedset_config; - frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = prach_config_pdu->prach_freq_offset; + frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset = prach_config_pdu->prach_freq_offset;*/ prach_resources->ra_PreambleIndex = prach_config_pdu->preamble_index; } } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index b5f19814f7c2faf088486eb21cc6cfbd0684d475..f26468fb0315d2884aa7a366102723dd011bda9d 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1560,25 +1560,26 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDUR #endif -void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { - - int harq_pid; - int frame_tx=proc->frame_tx; +void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint8_t abstraction_flag) +{ int nr_tti_tx=proc->nr_tti_tx; - unsigned int input_buffer_length; - int i; - int aa; - int tx_amp; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_IN); /* reset harq for tx of current rx slot because it is sure that transmission has already been achieved for this slot */ set_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], NR_MAX_HARQ_PROCESSES, proc->nr_tti_rx); +#if 0 + int frame_tx=proc->frame_tx; + int harq_pid; /* get harq pid related to this next tx slot */ harq_pid = get_tx_harq_id(ue->ulsch[ue->current_thread_id[nr_tti_tx]][eNB_id][0], nr_tti_tx); -#if 0 - + int tx_amp; + unsigned int input_buffer_length; int Mod_id = ue->Mod_id; int CC_id = ue->CC_id; uint8_t Msg3_flag=0; @@ -1599,9 +1600,9 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) - generate_ue_ulsch_params_from_rar(ue, - proc, - eNB_id); + generate_ue_ulsch_params_from_rar(ue, + proc, + eNB_id); ue->ulsch[eNB_id]->power_offset = 14; LOG_D(PHY,"[UE %d][RAPROC] Frame %d: Setting Msg3_flag in nr_tti_rx %d, for harq_pid %d\n", @@ -1864,7 +1865,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 #ifdef DEBUG_ULSCH LOG_D(PHY,"[UE] Frame %d, nr_tti_rx %d : ULSCH SDU (TX harq_pid %d) (%d bytes) : \n",frame_tx,nr_tti_tx,harq_pid, ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); - for (i=0; i<ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) + for (int i=0; i<ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) LOG_T(PHY,"%x.",ulsch_input_buffer[i]); LOG_T(PHY,"\n"); @@ -1874,7 +1875,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 else { unsigned int taus(void); - for (i=0; i<input_buffer_length; i++) + for (int i=0; i<input_buffer_length; i++) ulsch_input_buffer[i]= (uint8_t)(taus()&0xff); } @@ -1956,7 +1957,7 @@ if (abstraction_flag == 0) { nr_tti_tx, &ue->frame_parms, ue->ulsch[eNB_id]); - for (aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) + for (int aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) generate_drs_pusch(ue, proc, eNB_id, @@ -2670,22 +2671,18 @@ void phy_procedures_UE_S_TX(PHY_VARS_NR_UE *ue,uint8_t eNB_id,uint8_t abstractio #endif -void nr_ue_measurement_procedures( - uint16_t l, // symbol index of each slot [0..6] - PHY_VARS_NR_UE *ue, - UE_nr_rxtx_proc_t *proc, - uint8_t eNB_id, - uint16_t slot, // slot index of each radio frame [0..19] - runmode_t mode) +void nr_ue_measurement_procedures(uint16_t l, // symbol index of each slot [0..6] + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint16_t slot, // slot index of each radio frame [0..19] + runmode_t mode) { - LOG_D(PHY,"ue_measurement_procedures l %u Ncp %d\n",l,ue->frame_parms.Ncp); +#if 0 NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - int nr_tti_rx = proc->nr_tti_rx; - -#if 0 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_IN); if (l==0) { @@ -2806,15 +2803,17 @@ void restart_phy(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t eNB_id,uint } #endif //(0) -void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc, uint8_t abstraction_flag) +void nr_ue_pbch_procedures(uint8_t eNB_id, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t abstraction_flag) { - // int i; //int pbch_tx_ant=0; //uint8_t pbch_phase; int ret = 0; - uint16_t frame_tx; - uint8_t pbch_trials = 0; + //static uint8_t first_run = 1; + //uint8_t pbch_trials = 0; DevAssert(ue); @@ -2837,6 +2836,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #ifdef DEBUG_PHY_PROC + uint16_t frame_tx; LOG_D(PHY,"[UE %d] frame %d, nr_tti_rx %d, Received PBCH (MIB): frame_tx %d. N_RB_DL %d\n", ue->Mod_id, frame_rx, @@ -2907,9 +2907,10 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb #ifdef NR_PDCCH_SCHED -int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc) +int nr_ue_pdcch_procedures(uint8_t eNB_id, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc) { - // unsigned int dci_cnt=0, i; //removed for nr_ue_pdcch_procedures and added in the loop for nb_coreset_active #ifdef NR_PDCCH_SCHED_DEBUG printf("<-NR_PDCCH_PHY_PROCEDURES_LTE_UE (nr_ue_pdcch_procedures)-> Entering function nr_ue_pdcch_procedures() \n"); @@ -2939,7 +2940,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * pdcch_vars[eNB_id]->crnti = 0x1234; //to be check how to set when using loop memory uint16_t c_rnti=pdcch_vars[eNB_id]->crnti; - uint16_t cs_rnti=0,new_rnti=0,tc_rnti; + uint16_t cs_rnti=0,new_rnti=0,tc_rnti=0; uint16_t p_rnti=P_RNTI; uint16_t si_rnti=SI_RNTI; uint16_t ra_rnti=99; @@ -2957,10 +2958,10 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * #endif // p in TS 38.212 Subclause 10.1, for each active BWP the UE can deal with 3 different CORESETs (including coresetId 0 for common search space) - int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; + //int nb_coreset_total = NR_NBR_CORESET_ACT_BWP; unsigned int dci_cnt=0; // this table contains 56 (NBR_NR_DCI_FIELDS) elements for each dci field and format described in TS 38.212. Each element represents the size in bits for each dci field - uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; + //uint8_t dci_fields_sizes[NBR_NR_DCI_FIELDS][NBR_NR_FORMATS] = {{0}}; // this is the UL bandwidth part. FIXME! To be defined where this value comes from // uint16_t n_RB_ULBWP = 106; // this is the DL bandwidth part. FIXME! To be defined where this value comes from @@ -2969,7 +2970,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // Up to 10 searchSpaces can be configured to UE (s<=10) for (nb_searchspace_active=0; nb_searchspace_active<nb_searchspace_total; nb_searchspace_active++){ int nb_coreset_active=nb_searchspace_active; - int do_pdcch_monitoring_current_slot=1; // this variable can be removed and fapi is handling + //int do_pdcch_monitoring_current_slot=1; // this variable can be removed and fapi is handling /* * The following code has been removed as it is handled by higher layers (fapi) * @@ -2987,7 +2988,7 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * * To be implemented LATER !!! */ //int _offset,_index,_M; - int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; + //int searchSpace_id = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceId; #ifdef NR_PDCCH_SCHED_DEBUG @@ -3000,16 +3001,16 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * // the searchSpace indicates that we need to monitor PDCCH in current nr_tti_rx // get the parameters describing the current SEARCHSPACE // the CORESET id applicable to the current SearchSpace - int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; + //int searchSpace_coreset_id = pdcch_vars2->searchSpace[nb_searchspace_active].controlResourceSetId; // FIXME this variable is a bit string (14 bits) identifying every OFDM symbol in a slot. // at the moment we will not take into consideration this variable and we will consider that the OFDM symbol offset is always the first OFDM in a symbol uint16_t symbol_within_slot_mon = pdcch_vars2->searchSpace[nb_searchspace_active].monitoringSymbolWithinSlot; // get the remaining parameters describing the current SEARCHSPACE: // FIXME! To be defined where we get this information from - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; + /*NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L1 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel1; NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L2 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel2; NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L4 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel4; NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L8 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel8; - NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16; + NR_UE_SEARCHSPACE_nbrCAND_t num_cand_L16 = pdcch_vars2->searchSpace[nb_searchspace_active].nrofCandidates_aggrlevel16;*/ // FIXME! A table of five enum elements // searchSpaceType indicates whether this is a common search space or a UE-specific search space //int searchSpaceType = pdcch_vars2->searchSpace[nb_searchspace_active].searchSpaceType.type; @@ -3126,9 +3127,8 @@ int nr_ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d nr_tti_rx %d PHICH RX\n",ue->Mod_id,frame_rx,nr_tti_rx); - - uint8_t *nCCE_current = &ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->nCCE[nr_tti_rx]; /* + uint8_t *nCCE_current = &ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][eNB_id]->nCCE[nr_tti_rx]; uint8_t *nCCE_dest = &ue->pdcch_vars[next1_thread_id][eNB_id]->nCCE[nr_tti_rx]; uint8_t *nCCE_dest1 = &ue->pdcch_vars[next2_thread_id][eNB_id]->nCCE[nr_tti_rx]; memcpy(nCCE_dest, nCCE_current, sizeof(uint8_t)); @@ -3779,13 +3779,14 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; int ret=0, ret1=0; - int CC_id = ue->CC_id; + //int CC_id = ue->CC_id; NR_UE_PDSCH *pdsch_vars; uint8_t is_cw0_active = 0; uint8_t is_cw1_active = 0; - // to be updated by higher layer - uint8_t nb_re_dmrs = 6; - uint16_t length_dmrs = 1; + nfapi_nr_config_request_t *cfg = &ue->nrUE_config; + uint8_t dmrs_type = cfg->pdsch_config.dmrs_type.value; + uint8_t nb_re_dmrs = (dmrs_type==NFAPI_NR_DMRS_TYPE1)?6:4; + uint16_t length_dmrs = 1; //cfg->pdsch_config.dmrs_max_length.value; uint16_t nb_symb_sch = 9; if (dlsch0==NULL) @@ -3793,6 +3794,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid = dlsch0->current_harq_pid; is_cw0_active = dlsch0->harq_processes[harq_pid]->status; + nb_symb_sch = dlsch0->harq_processes[harq_pid]->nb_symbols; if(dlsch1) is_cw1_active = dlsch1->harq_processes[harq_pid]->status; @@ -3860,10 +3862,10 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, start_meas(&ue->dlsch_unscrambling_stats); #endif nr_dlsch_unscrambling(pdsch_vars->llr[0], - dlsch0->harq_processes[harq_pid]->G, - 0, - ue->frame_parms.Nid_cell, - dlsch0->rnti); + dlsch0->harq_processes[harq_pid]->G, + 0, + ue->frame_parms.Nid_cell, + dlsch0->rnti); #if UE_TIMING_TRACE @@ -3886,7 +3888,9 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, #endif #ifdef UE_DLSCH_PARALLELISATION - ret = nr_dlsch_decoding_mthread(ue,proc,eNB_id, + ret = nr_dlsch_decoding_mthread(ue, + proc, + eNB_id, pdsch_vars->llr[0], &ue->frame_parms, dlsch0, @@ -3897,6 +3901,7 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0, dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is defined, ret = %d\n", ret); #else ret = nr_dlsch_decoding(ue, pdsch_vars->llr[0], @@ -3907,8 +3912,9 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, nb_symb_sch, nr_tti_rx, harq_pid, - pdsch==PDSCH?1:0,//proc->decoder_switch, + pdsch==PDSCH?1:0, dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is NOT defined, ret = %d\n", ret); //printf("start cW0 dlsch decoding\n"); #endif @@ -3963,7 +3969,9 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, #endif #ifdef UE_DLSCH_PARALLELISATION - ret1 = nr_dlsch_decoding_mthread(ue,proc, eNB_id, + ret1 = nr_dlsch_decoding_mthread(ue, + proc, + eNB_id, pdsch_vars->llr[1], &ue->frame_parms, dlsch1, @@ -3974,19 +3982,20 @@ void nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, harq_pid, pdsch==PDSCH?1:0, dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is defined, ret1 = %d\n", ret1); #else - ret1 = nr_dlsch_decoding(ue, pdsch_vars->llr[1], &ue->frame_parms, dlsch1, dlsch1->harq_processes[harq_pid], frame_rx, - nb_symb_sch, + nb_symb_sch, nr_tti_rx, harq_pid, pdsch==PDSCH?1:0,//proc->decoder_switch, dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + LOG_T(PHY,"UE_DLSCH_PARALLELISATION is NOT defined, ret1 = %d\n", ret1); printf("start cw1 dlsch decoding\n"); #endif @@ -4316,18 +4325,19 @@ void *UE_thread_slot1_dl_processing(void *arg) { -int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t do_pdcch_flag,runmode_t mode) { - - - - int l,l2; - int pilot1; - +int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + uint8_t eNB_id, + uint8_t do_pdcch_flag, + runmode_t mode) +{ int frame_rx = proc->frame_rx; int nr_tti_rx = proc->nr_tti_rx; NR_UE_PDCCH *pdcch_vars = ue->pdcch_vars[ue->current_thread_id[nr_tti_rx]][0]; - uint16_t nb_symb_sch = 9; // to be updated by higher layer + NR_UE_DLSCH_t **dlsch = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id]; + uint8_t harq_pid = ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][0]->current_harq_pid; + NR_DL_UE_HARQ_t *dlsch0_harq = dlsch[0]->harq_processes[harq_pid]; + uint16_t nb_symb_sch = dlsch0_harq->nb_symbols; uint8_t nb_symb_pdcch = pdcch_vars->coreset[0].duration; uint8_t dci_cnt = 0; diff --git a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c index debb0d4ed5e564d7e8efcdddf155d8e59bb66a73..296d92969cf207fd7332fd440930341f05740bde 100644 --- a/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_power_control_ue_nr.c @@ -67,9 +67,19 @@ * *********************************************************************/ -int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t *proc, pucch_format_nr_t pucch_format, - int nb_of_prbs, int N_sc_ctrl_RB, int N_symb_PUCCH, int O_UCI, int O_SR, int O_CSI, int O_ACK, - int O_CRC, int n_HARQ_ACK) { +int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, + uint8_t gNB_id, + UE_nr_rxtx_proc_t *proc, + pucch_format_nr_t pucch_format, + int nb_of_prbs, + int N_sc_ctrl_RB, + int N_symb_PUCCH, + int O_UCI, + int O_SR, + int O_CSI, + int O_ACK, + int O_CRC, + int n_HARQ_ACK) { int16_t P_O_NOMINAL_PUCCH = ue->pucch_config_common_nr[gNB_id].p0_nominal; PUCCH_PowerControl_t *power_config = &ue->pucch_config_dedicated_nr[gNB_id].pucch_PowerControl; @@ -147,7 +157,6 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } } - int l = 0; int k2; if (power_config->twoPUCCH_PC_AdjustmentStates > 1) { @@ -156,11 +165,11 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } /* response to a detection by the UE of a DCI format 1_0 or DCI format 1_1 */ - int K_PUCCH = 0; + //int K_PUCCH = 0; if (O_ACK != 0) { /* it assumes that PDCCH is in the first symbol of receive slot FFS TDDO NR */ - int slots_gap = (proc->nr_tti_tx > proc->nr_tti_rx ? (proc->nr_tti_tx - proc->nr_tti_rx - 1) : ((proc->nr_tti_tx + ue->frame_parms.ttis_per_subframe) - proc->nr_tti_rx - 1)); - K_PUCCH = (slots_gap * (ue->frame_parms.symbols_per_tti)) - 1; + //int slots_gap = (proc->nr_tti_tx > proc->nr_tti_rx ? (proc->nr_tti_tx - proc->nr_tti_rx - 1) : ((proc->nr_tti_tx + ue->frame_parms.ttis_per_subframe) - proc->nr_tti_rx - 1)); + //K_PUCCH = (slots_gap * (ue->frame_parms.symbols_per_tti)) - 1; } else { /* field k2 is not present - to check k2 of pucch from upper layer FFS TDDO NR */ @@ -189,7 +198,7 @@ int16_t get_pucch_tx_power_ue(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_pro } while(ue->pusch_config.pusch_TimeDomainResourceAllocation[i] != NULL); k2 = k2_min; } - K_PUCCH = N_SYMB_SLOT * k2; /* the product of a number of symbols per slot and the minimum of the values provided by higher layer parameter k2 */ + //K_PUCCH = N_SYMB_SLOT * k2; /* the product of a number of symbols per slot and the minimum of the values provided by higher layer parameter k2 */ } int contributor = (10 * log10((double)(pow(2,(ue->frame_parms.numerology_index)) * nb_of_prbs))); diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 2a95768a3e08d6def68fda3f96206a4f58c450e2..0eed21c446e0262181872f098d966bae55d91618 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -103,6 +103,7 @@ void exit_function(const char *file, const char *function, const int line, // needed for some functions PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; uint16_t n_rnti = 0x1234; +openair0_config_t openair0_cfg[MAX_CARDS]; char quantize(double D, double x, unsigned char B) { double qxd; @@ -131,21 +132,22 @@ int main(int argc, char **argv) { // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file = 0; + //uint8_t write_output_file = 0; // int subframe_offset; // char fname[40], vname[40]; int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; - uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; + uint8_t n_tx = 1, n_rx = 1; + //uint8_t transmission_mode = 1; uint16_t Nid_cell = 0; channel_desc_t *gNB2UE; uint8_t extended_prefix_flag = 0; - int8_t interf1 = -21, interf2 = -21; + //int8_t interf1 = -21, interf2 = -21; FILE *input_fd = NULL, *pbch_file_fd = NULL; //char input_val_str[50],input_val_str2[50]; //uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, mu = 1; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame = 0, subframe = 0; int frame_length_complex_samples; @@ -176,7 +178,7 @@ int main(int argc, char **argv) { while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file = 1; output_fd = fopen(optarg, "w"); @@ -185,11 +187,11 @@ int main(int argc, char **argv) { exit(-1); } - break; + break;*/ - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch ((char) *optarg) { @@ -228,13 +230,13 @@ int main(int argc, char **argv) { break; - case 'i': + /*case 'i': interf1 = atoi(optarg); break; case 'j': interf2 = atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -331,33 +333,33 @@ int main(int argc, char **argv) { nb_rb = atoi(optarg); break; - case 'x': + /*case 'x': transmission_mode = atoi(optarg); - break; + break;*/ default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-t Delay spread for multipath channel\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); - printf("-x Transmission mode (1,2,6 for the moment)\n"); + //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); - printf("-M Multiple SSB positions in burst\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit(-1); break; @@ -493,12 +495,12 @@ int main(int argc, char **argv) { short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384); short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384); double errors_bit_uncoded = 0; - unsigned char *estimated_output; + //unsigned char *estimated_output; unsigned char *estimated_output_bit; unsigned char *test_input_bit; unsigned int errors_bit = 0; test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); - estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); + //estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0]; NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid]; @@ -514,7 +516,7 @@ int main(int argc, char **argv) { for (i = 0; i < TBS / 8; i++) test_input[i] = (unsigned char) rand(); - estimated_output = harq_process->b; + //estimated_output = harq_process->b; #ifdef DEBUG_DLSCHSIM for (i = 0; i < TBS / 8; i++) printf("test_input[i]=%d \n",test_input[i]); diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index b95ea7502e60ab390f3bbf416175f561a7e53fee..771b6ba7c631677d1183ca9c4cba8d2d1e28702d 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -46,6 +46,7 @@ #include "SCHED_NR/sched_nr.h" #include "SCHED_NR/fapi_nr_l1.h" +#include "SCHED_NR_UE/defs.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" #include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h" @@ -57,6 +58,12 @@ #include "NR_PHY_INTERFACE/NR_IF_Module.h" #include "NR_UE_PHY_INTERFACE/NR_IF_Module.h" +#include "LAYER2/NR_MAC_UE/mac_proto.h" +//#include "LAYER2/NR_MAC_gNB/mac_proto.h" +//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" +#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" +#include "RRC/NR/MESSAGES/asn1_msg.h" + PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; @@ -115,51 +122,53 @@ void config_common(int Mod_idP, // needed for some functions PHY_VARS_NR_UE ***PHY_vars_UE_g; short conjugate[8]__attribute__((aligned(32))) = {-1,1,-1,1,-1,1,-1,1}; +openair0_config_t openair0_cfg[MAX_CARDS]; int main(int argc, char **argv) { char c; - int i,l,aa; + int i,aa;//,l; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - double iqim = 0.0; - unsigned char pbch_pdu[6]; + //double iqim = 0.0; + //unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file=0; + //uint8_t write_output_file=0; //int result; - int freq_offset; + //int freq_offset; // int subframe_offset; // char fname[40], vname[40]; - int trial,n_trials=1,n_errors,n_errors2,n_alamouti; + int trial,n_trials=1,n_errors=0; + //int n_errors2, n_alamouti; uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint16_t Nid_cell=0; uint64_t SSB_positions=0x01; channel_desc_t *gNB2UE; - uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; - uint8_t extended_prefix_flag=0; - int8_t interf1=-21,interf2=-21; + //uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; + //uint8_t extended_prefix_flag=0; + //int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; - char input_val_str[50],input_val_str2[50]; + //char input_val_str[50],input_val_str2[50]; - uint8_t frame_mod4,num_pdcch_symbols = 0; + //uint8_t frame_mod4,num_pdcch_symbols = 0; SCM_t channel_model=AWGN;//Rayleigh1_anticorr; - double pbch_sinr; - int pbch_tx_ant; + //double pbch_sinr; + //int pbch_tx_ant; int N_RB_DL=273,mu=1; uint64_t ssb_pattern = 0x01; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame=0,slot=1; @@ -192,7 +201,7 @@ int main(int argc, char **argv) while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file=1; output_fd = fopen(optarg,"w"); @@ -200,12 +209,11 @@ int main(int argc, char **argv) printf("Error opening %s\n",optarg); exit(-1); } + break;*/ - break; - - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch((char)*optarg) { @@ -244,13 +252,13 @@ int main(int argc, char **argv) break; - case 'i': + /*case 'i': interf1=atoi(optarg); break; case 'j': interf2=atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -272,9 +280,9 @@ int main(int argc, char **argv) Td= atof(optarg); break; */ - case 'p': + /*case 'p': extended_prefix_flag=1; - break; + break;*/ /* case 'r': @@ -361,8 +369,8 @@ int main(int argc, char **argv) printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-p Use extended prefix mode\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); @@ -371,15 +379,15 @@ int main(int argc, char **argv) printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit (-1); break; @@ -676,8 +684,8 @@ int main(int argc, char **argv) for (SNR=snr0; SNR<snr1; SNR+=.2) { n_errors = 0; - n_errors2 = 0; - n_alamouti = 0; + //n_errors2 = 0; + //n_alamouti = 0; for (trial=0; trial<n_trials; trial++) { @@ -770,6 +778,3 @@ int main(int argc, char **argv) return(n_errors); } - - - diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 61d4c486f5e51d1afed3c92ee8099b0926719dfe..847fac3213f2ea29232f2279ba99245de9a245d0 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -80,6 +80,7 @@ void exit_function(const char* file, const char* function, const int line,const // needed for some functions PHY_VARS_NR_UE * PHY_vars_UE_g[1][1]={{NULL}}; +openair0_config_t openair0_cfg[MAX_CARDS]; int main(int argc, char **argv) { @@ -92,13 +93,13 @@ int main(int argc, char **argv) uint8_t snr1set=0; int **txdata; double **s_re,**s_im,**r_re,**r_im; - double iqim = 0.0; + //double iqim = 0.0; double ip =0.0; - unsigned char pbch_pdu[6]; + //unsigned char pbch_pdu[6]; // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file=0; + //uint8_t write_output_file=0; //int result; //int freq_offset; // int subframe_offset; @@ -110,8 +111,8 @@ int main(int argc, char **argv) channel_desc_t *gNB2UE; - uint8_t extended_prefix_flag=0; - int8_t interf1=-21,interf2=-21; + //uint8_t extended_prefix_flag=0; + //int8_t interf1=-21,interf2=-21; FILE *input_fd=NULL,*pbch_file_fd=NULL; @@ -126,7 +127,7 @@ int main(int argc, char **argv) int N_RB_DL=273,mu=1; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame=0; @@ -152,7 +153,7 @@ int main(int argc, char **argv) while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:o:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file=1; output_fd = fopen(optarg,"w"); @@ -161,11 +162,11 @@ int main(int argc, char **argv) exit(-1); } - break; + break;*/ - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch((char)*optarg) { @@ -204,13 +205,13 @@ int main(int argc, char **argv) break; - case 'i': + /*case 'i': interf1=atoi(optarg); break; case 'j': interf2=atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -237,9 +238,9 @@ int main(int argc, char **argv) Td= atof(optarg); break; */ - case 'p': + /*case 'p': extended_prefix_flag=1; - break; + break;*/ /* case 'r': @@ -326,8 +327,8 @@ int main(int argc, char **argv) printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); - printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-p Use extended prefix mode\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); @@ -336,16 +337,16 @@ int main(int argc, char **argv) printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-o Carrier frequency offset in Hz\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit (-1); break; @@ -537,10 +538,9 @@ int main(int argc, char **argv) if (output_fd) fwrite(txdata[0],sizeof(int32_t),frame_length_complex_samples,output_fd); - int txlev = signal_energy(&txdata[0][5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], - frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); - - // printf("txlev %d (%f)\n",txlev,10*log10(txlev)); + /*int txlev = signal_energy(&txdata[0][5*frame_parms->ofdm_symbol_size + 4*frame_parms->nb_prefix_samples + frame_parms->nb_prefix_samples0], + frame_parms->ofdm_symbol_size + frame_parms->nb_prefix_samples); + printf("txlev %d (%f)\n",txlev,10*log10(txlev));*/ for (i=0; i<frame_length_complex_samples; i++) { @@ -689,6 +689,3 @@ int main(int argc, char **argv) return(n_errors); } - - - diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index ca3860c5b0eb0982aff94251e6712c32020db3c5..e021683a433e41077de03a5e7b57fb7752d3e442 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -104,6 +104,7 @@ void exit_function(const char *file, const char *function, const int line, const // needed for some functions PHY_VARS_NR_UE *PHY_vars_UE_g[1][1] = { { NULL } }; uint16_t n_rnti = 0x1234; +openair0_config_t openair0_cfg[MAX_CARDS]; char quantize(double D, double x, unsigned char B) { double qxd; @@ -133,21 +134,22 @@ int main(int argc, char **argv) { // int sync_pos, sync_pos_slot; // FILE *rx_frame_file; FILE *output_fd = NULL; - uint8_t write_output_file = 0; + //uint8_t write_output_file = 0; // int subframe_offset; // char fname[40], vname[40]; int trial, n_trials = 1, n_errors = 0, n_false_positive = 0; - uint8_t transmission_mode = 1, n_tx = 1, n_rx = 1; + uint8_t n_tx = 1, n_rx = 1; + //uint8_t transmission_mode = 1; uint16_t Nid_cell = 0; channel_desc_t *gNB2UE; uint8_t extended_prefix_flag = 0; - int8_t interf1 = -21, interf2 = -21; + //int8_t interf1 = -21, interf2 = -21; FILE *input_fd = NULL, *pbch_file_fd = NULL; //char input_val_str[50],input_val_str2[50]; //uint16_t NB_RB=25; SCM_t channel_model = AWGN; //Rayleigh1_anticorr; uint16_t N_RB_DL = 106, N_RB_UL = 106, mu = 1; - unsigned char frame_type = 0; + //unsigned char frame_type = 0; unsigned char pbch_phase = 0; int frame = 0, subframe = 0; int frame_length_complex_samples; @@ -178,7 +180,7 @@ int main(int argc, char **argv) { while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { switch (c) { - case 'f': + /*case 'f': write_output_file = 1; output_fd = fopen(optarg, "w"); @@ -187,11 +189,11 @@ int main(int argc, char **argv) { exit(-1); } - break; + break;*/ - case 'd': + /*case 'd': frame_type = 1; - break; + break;*/ case 'g': switch ((char) *optarg) { @@ -230,13 +232,13 @@ int main(int argc, char **argv) { break; - case 'i': + /*case 'i': interf1 = atoi(optarg); break; case 'j': interf2 = atoi(optarg); - break; + break;*/ case 'n': n_trials = atoi(optarg); @@ -330,33 +332,33 @@ int main(int argc, char **argv) { nb_rb = atoi(optarg); break; - case 'x': + /*case 'x': transmission_mode = atoi(optarg); - break; + break;*/ default: case 'h': printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n", argv[0]); printf("-h This message\n"); printf("-p Use extended prefix mode\n"); - printf("-d Use TDD\n"); + //printf("-d Use TDD\n"); printf("-n Number of frames to simulate\n"); printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n"); printf("-S Ending SNR, runs from SNR0 to SNR1\n"); printf("-t Delay spread for multipath channel\n"); printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n"); - printf("-x Transmission mode (1,2,6 for the moment)\n"); + //printf("-x Transmission mode (1,2,6 for the moment)\n"); printf("-y Number of TX antennas used in eNB\n"); printf("-z Number of RX antennas used in UE\n"); - printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); - printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); + //printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); + //printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-M Multiple SSB positions in burst\n"); printf("-N Nid_cell\n"); printf("-R N_RB_DL\n"); printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n"); - // printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); - printf("-f Output filename (.txt format) for Pe/SNR results\n"); + //printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n"); + //printf("-f Output filename (.txt format) for Pe/SNR results\n"); printf("-F Input filename (.txt format) for RX conformance testing\n"); exit(-1); break; diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 99b62864833f491c85840bb06a314c8c064e1174..ab36765445fe6d5010cf36545214c048e2f3ff6b 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -56,7 +56,7 @@ #include "L1_paramdef.h" #include "MACRLC_paramdef.h" #include "common/config/config_userapi.h" -#include "RRC_config_tools.h" +//#include "RRC_config_tools.h" #include "gnb_paramdef.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" @@ -81,6 +81,8 @@ extern void set_parallel_conf(char *parallel_conf); extern void set_worker_conf(char *worker_conf); extern PARALLEL_CONF_t get_thread_parallel_conf(void); extern WORKER_CONF_t get_thread_worker_conf(void); +extern int config_check_band_frequencies(int ind, int16_t band, uint32_t downlink_frequency, + int32_t uplink_frequency_offset, uint32_t frame_type); void RCconfig_nr_flexran() { @@ -628,7 +630,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { paramdef_t GNBParams[] = GNBPARAMS_DESC; paramlist_def_t GNBParamList = {GNB_CONFIG_STRING_GNB_LIST,NULL,0}; ////////// Physical parameters - checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK; + //checkedparam_t config_check_CCparams[] = NRCCPARAMS_CHECK; paramdef_t CCsParams[] = NRCCPARAMS_DESC; paramlist_def_t CCsParamList = {GNB_CONFIG_STRING_COMPONENT_CARRIERS,NULL,0}; diff --git a/openair2/LAYER2/MAC/config_ue.c b/openair2/LAYER2/MAC/config_ue.c index c38c32a4de7706544112b277d8e0ffbd45d5ce61..12786f7095642e77214528d2c55ee3f332fe7b4a 100644 --- a/openair2/LAYER2/MAC/config_ue.c +++ b/openair2/LAYER2/MAC/config_ue.c @@ -238,8 +238,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP, } if(nfapi_mode!=3) phy_config_harq_ue(Mod_idP, 0, eNB_index, - UE_mac_inst[Mod_idP]. - scheduling_info.maxHARQ_Tx); + UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx); if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) { UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer = diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c5a569b781437aeff554ee1ad70309ca39d57af6..05e88e3ed9d254746908f8eb9ed0421e19ee843c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -65,11 +65,16 @@ uint8_t table_9_2_2_1[16][8]={ {1,0, 14,4, 0,3,6,9}, {1,0, 14,26,0,3,0,0} }; -int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, fapi_nr_dci_indication_t *dci_ind, void *pduP, uint32_t pdu_len){ - +int8_t nr_ue_process_dlsch(module_id_t module_id, + int cc_id, + uint8_t gNB_index, + fapi_nr_dci_indication_t *dci_ind, + void *pduP, + uint32_t pdu_len) +{ NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); fapi_nr_ul_config_request_t *ul_config = &mac->ul_config_request; - fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; + //fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request; nr_phy_config_t *phy_config = &mac->phy_config; //ul_config->ul_config_list[ul_config->number_pdus].ulsch_config_pdu.rnti = rnti; @@ -1087,7 +1092,7 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment( start_RB = riv%n_RB_DLBWP; // if (l_RB - 1) > floor (n_RB_DLBWP/2) we need to recalculate them using the following lines tmp_RIV = n_RB_DLBWP * (l_RB - 1) + start_RB; - if (tmp_RIV != riv) { // then (l_RB - 1) > floor (n_RB_DLBWP/2) and we need to recalculate l_RB and start_RB + if ((tmp_RIV != riv) || ((start_RB+l_RB)>n_RB_DLBWP)) { // then (l_RB - 1) > floor (n_RB_DLBWP/2) and we need to recalculate l_RB and start_RB l_RB = n_RB_DLBWP - l_RB + 2; start_RB = n_RB_DLBWP - start_RB - 1; } @@ -1149,7 +1154,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,4,7}, // row index 15 {0,8,4} // row index 16 }; - uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + /*uint8_t table_5_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?6:5}, // row index 1 {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?10:9}, // row index 2 {0,(dmrs_typeA_pos == 0)?2:3, (dmrs_typeA_pos == 0)?9:8}, // row index 3 @@ -1166,8 +1171,8 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,2,4}, // row index 14 {0,4,6}, // row index 15 {0,8,4} // row index 16 - }; - uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + };*/ + /*uint8_t table_5_1_2_1_1_4_time_dom_res_alloc_B[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,2,2}, // row index 1 {0,4,2}, // row index 2 {0,6,2}, // row index 3 @@ -1184,8 +1189,8 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11}, // row index 14 {1,2,4}, // row index 15 {0,0,0} // row index 16 - }; - uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 + };*/ + /*uint8_t table_5_1_2_1_1_5_time_dom_res_alloc_C[16][3]={ // for PDSCH from TS 38.214 subclause 5.1.2.1.1 {0,2,2}, // row index 1 {0,4,2}, // row index 2 {0,6,2}, // row index 3 @@ -1202,7 +1207,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {0,(dmrs_typeA_pos == 0)?2:3,(dmrs_typeA_pos == 0)?12:11}, // row index 14 {0,0,6}, // row index 15 {0,2,6} // row index 16 - }; + };*/ uint8_t mu_pusch = 1; // definition table j Table 6.1.2.1.1-4 uint8_t j = (mu_pusch==3)?3:(mu_pusch==2)?2:1; @@ -1224,7 +1229,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {j+3,0,14}, // row index 15 {j+3,0,10} // row index 16 }; - uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 + /*uint8_t table_6_1_2_1_1_3_time_dom_res_alloc_A_extCP[16][3]={ // for PUSCH from TS 38.214 subclause 6.1.2.1.1 {j, 0,8}, // row index 1 {j, 0,12}, // row index 2 {j, 0,10}, // row index 3 @@ -1241,7 +1246,7 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment( {j, 8,4}, // row index 14 {j+3,0,8}, // row index 15 {j+3,0,10} // row index 16 - }; + };*/ /* * TS 38.214 subclause 5.1.2.1 Resource allocation in time domain (downlink) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index def897433ea6604fb390b32d9c23ed62067690bd..02c27930d3a462e22f8835123cdd75a3f972fad7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -48,6 +48,7 @@ #include "pdcp.h" #include "openair1/PHY/defs_gNB.h" +#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" //Agent-related headers #include "flexran_agent_extern.h" @@ -335,7 +336,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); - int spf = get_spf(cfg); + //int spf = get_spf(cfg); if (((frameP&127) == 0) && (slotP == 0)) { LOG_I(MAC, @@ -388,7 +389,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, NR_gNB_ULSCH_t *ulsch = RC.gNB[module_idP][CC_id]->ulsch[ii][0]; if((ulsch != NULL) && (ulsch->rnti == rnti)){ LOG_W(MAC, "TODO: clean_eNb_ulsch UE %x \n", rnti); - //clean_eNb_ulsch(ulsch); + clean_gNB_ulsch(ulsch); } } @@ -396,7 +397,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, NR_gNB_DLSCH_t *dlsch = RC.gNB[module_idP][CC_id]->dlsch[ii][0]; if((dlsch != NULL) && (dlsch->rnti == rnti)){ LOG_W(MAC, "TODO: clean_eNb_dlsch UE %x \n", rnti); - //clean_eNb_dlsch(dlsch); + clean_gNB_dlsch(dlsch); } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index 5a57bc2846267e66bca680902202692c636e2c59..ce18158f186dd59c186b0c9d7ad89de37965531e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -203,8 +203,8 @@ void nr_schedule_uss_dlsch_phytest(module_id_t module_idP, int dl_carrier_bandwidth = cfg->rf_config.dl_carrier_bandwidth.value; // everything here is hard-coded to 30 kHz - int scs = get_dlscs(cfg); - int slots_per_frame = get_spf(cfg); + //int scs = get_dlscs(cfg); + //int slots_per_frame = get_spf(cfg); for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { LOG_I(MAC, "Scheduling UE specific search space DCI type 1 for CC_id %d\n",CC_id); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 97a417fea1da2d28b0c94b32fa571da893dbebd7..9e70ae7025ac90c8ebab85a0cf692d16829da3ae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -36,6 +36,14 @@ void mac_top_init_gNB(void); +void config_common(int Mod_idP, + int CC_idP, + int Nid_cell, + int nr_bandP, + uint64_t ssb_pattern, + uint64_t dl_CarrierFreqP, + uint32_t dl_BandwidthP); + int rrc_mac_config_req_gNB(module_id_t Mod_idP, int CC_id, int cellid, diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 6cd15fd32bdf82e2987bd764f4bc92162f1d175f..456f06a5ed914b07b7c3626e5cab50e9531ac2ba 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -171,8 +171,4 @@ typedef struct gNB_MAC_INST_s { time_stats_t schedule_pch; } gNB_MAC_INST; -void nr_schedule_css_dlsch_phytest(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP); - #endif /*__LAYER2_NR_MAC_GNB_H__ */ diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 2cb5414ed0f1557e22c4a2e3a2b3b19a08cede71..749320b3572662a1c4cb7754b7046f4010211603 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -140,17 +140,18 @@ void rrc_gNB_process_SgNBAdditionRequest( void rrc_gNB_generate_SgNBAdditionRequestAcknowledge( const protocol_ctxt_t *const ctxt_pP, - rrc_gNB_ue_context_t *const ue_context_pP - ){ - - int CC_id = ue_context_pP->ue_context.primaryCC_id; - OCTET_STRING_t *secondaryCellGroup; + rrc_gNB_ue_context_t *const ue_context_pP) +{ + //uint8_t size; + //uint8_t buffer[100]; + //int CC_id = ue_context_pP->ue_context.primaryCC_id; + //OCTET_STRING_t *secondaryCellGroup; NR_CellGroupConfig_t *cellGroupconfig; struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_BearerToAddModList; struct NR_MAC_CellGroupConfig *mac_CellGroupConfig; struct NR_PhysicalCellGroupConfig *physicalCellGroupConfig; struct NR_SpCellConfig *spCellConfig; - struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; + //struct NR_CellGroupConfig__sCellToAddModList *sCellToAddModList; cellGroupconfig = CALLOC(1,sizeof(NR_CellGroupConfig_t)); cellGroupconfig->rlc_BearerToAddModList = CALLOC(1,sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 09ad515324b823b86ba416236923ae696e611019..5530a68f9b88dacdc2df6f1a0dd1c22793c76c54 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -229,6 +229,8 @@ typedef struct { double rx_sample_rate; //! the sample rate for transmit. double tx_sample_rate; + //! check for threequarter sampling rate + int8_t threequarter_fs; } openair0_config_t; diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 8a012b39de5da4c9813ed8f0d731a42d5a820f20..890561f385995140ade691d2dc8e9151421b23bb 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -1131,7 +1131,15 @@ extern "C" { openair0_cfg[0].rx_bw = 80e6; break; - case 61440000: + case 92160000: + // from usrp_time_offset + //openair0_cfg[0].samples_per_packet = 2048; + openair0_cfg[0].tx_sample_advance = 15; //to be checked + openair0_cfg[0].tx_bw = 80e6; + openair0_cfg[0].rx_bw = 80e6; + break; + + case 61440000: // from usrp_time_offset //openair0_cfg[0].samples_per_packet = 2048; openair0_cfg[0].tx_sample_advance = 15; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf new file mode 100644 index 0000000000000000000000000000000000000000..51910091f7348811048e48bc7e714252562e2cd4 --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf @@ -0,0 +1,298 @@ +Active_gNBs = ( "gNB-Eurecom-5GNRBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + + cell_type = "CELL_MACRO_GNB"; + + gNB_name = "gNB-Eurecom-5GNRBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + + plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "3GPP_gNODEB"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + DL_prefix_type = "NORMAL"; + UL_prefix_type = "NORMAL"; + eutra_band = 78; + downlink_frequency = 3510000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 217; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + MIB_subCarrierSpacingCommon = 30; + MIB_ssb_SubcarrierOffset = 0; + MIB_dmrs_TypeA_Position = 2; + pdcch_ConfigSIB1 = 0; + SIB1_frequencyOffsetSSB = "khz5"; + SIB1_ssb_PeriodicityServingCell = 5; + SIB1_ss_PBCH_BlockPower = -60; + absoluteFrequencySSB = 0; + DL_FreqBandIndicatorNR = 15; + DL_absoluteFrequencyPointA = 15; + DL_offsetToCarrier = 15; + DL_SCS_SubcarrierSpacing = "kHz30"; + DL_SCS_SpecificCarrier_k0 = 0; + DL_carrierBandwidth = 15; + DL_locationAndBandwidth = 15; + DL_BWP_SubcarrierSpacing = "kHz30"; + DL_BWP_prefix_type = "NORMAL"; + UL_FreqBandIndicatorNR = 15; + UL_absoluteFrequencyPointA = 13; + UL_additionalSpectrumEmission = 3; + UL_p_Max = -1; + UL_frequencyShift7p5khz = "TRUE"; + UL_offsetToCarrier = 10; + UL_SCS_SubcarrierSpacing = "kHz30"; + UL_SCS_SpecificCarrier_k0 = 0; + UL_carrierBandwidth = 15; + UL_locationAndBandwidth = 15; + UL_BWP_SubcarrierSpacing = "kHz30"; + UL_BWP_prefix_type = "NORMAL"; + UL_timeAlignmentTimerCommon = "infinity"; + ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" + ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; + ServingCellConfigCommon_ssb_periodicityServingCell = 10; + ServingCellConfigCommon_dmrs_TypeA_Position = 2; + NIA_SubcarrierSpacing = "kHz15"; + ServingCellConfigCommon_ss_PBCH_BlockPower = -60; + referenceSubcarrierSpacing = "kHz15"; + dl_UL_TransmissionPeriodicity = "ms0p5"; + nrofDownlinkSlots = 10; + nrofDownlinkSymbols = 10; + nrofUplinkSlots = 10; + nrofUplinkSymbols = 10; + rach_totalNumberOfRA_Preambles = 63; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice = "oneEighth"; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth = 4; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth = 8; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf = 16; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one = 24; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two = 32; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four = 8; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight = 4; + rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen = 2; + rach_groupBconfigured = "ENABLE"; + rach_ra_Msg3SizeGroupA = 56; + rach_messagePowerOffsetGroupB = "dB0"; + rach_numberOfRA_PreamblesGroupA = 32; + rach_ra_ContentionResolutionTimer = 8; + rsrp_ThresholdSSB = 64; + rsrp_ThresholdSSB_SUL = 64; + prach_RootSequenceIndex_choice = "l839"; + prach_RootSequenceIndex_l839 = 0; + prach_RootSequenceIndex_l139 = 0; + prach_msg1_SubcarrierSpacing = "kHz30"; + restrictedSetConfig = "unrestrictedSet"; + msg3_transformPrecoding = "ENABLE"; + prach_ConfigurationIndex = 10; + prach_msg1_FDM = "one"; + prach_msg1_FrequencyStart = 10; + zeroCorrelationZoneConfig = 10; + preambleReceivedTargetPower = -150; + preambleTransMax = 6; + powerRampingStep = "dB0"; + ra_ResponseWindow = 8; + groupHoppingEnabledTransformPrecoding = "ENABLE"; + msg3_DeltaPreamble = 0; + p0_NominalWithGrant = 0; + PUSCH_TimeDomainResourceAllocation_k2 = 0; + PUSCH_TimeDomainResourceAllocation_mappingType = "typeA"; + PUSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; + pucch_ResourceCommon = 0; + pucch_GroupHopping = "neither"; + hoppingId = 0; + p0_nominal = -30; + PDSCH_TimeDomainResourceAllocation_k0 = 2; + PDSCH_TimeDomainResourceAllocation_mappingType = "typeA"; + PDSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; + rateMatchPatternId = 0; + RateMatchPattern_patternType = "bitmaps"; + symbolsInResourceBlock = "oneSlot"; + periodicityAndPattern = 2; + RateMatchPattern_controlResourceSet = 5; + RateMatchPattern_subcarrierSpacing = "kHz30"; + RateMatchPattern_mode = "dynamic"; + controlResourceSetZero = 0; + searchSpaceZero = 0; + searchSpaceSIB1 = 10; + searchSpaceOtherSystemInformation = 10; + pagingSearchSpace = 10; + ra_SearchSpace = 10; + PDCCH_common_controlResourceSetId = 5; + PDCCH_common_ControlResourceSet_duration = 2; + PDCCH_cce_REG_MappingType = "nonInterleaved"; + PDCCH_reg_BundleSize = 3; + PDCCH_interleaverSize = 3; + PDCCH_shiftIndex = 10; + PDCCH_precoderGranularity = "sameAsREG-bundle"; + PDCCH_TCI_StateId = 32; + tci_PresentInDCI = "ENABLE"; + PDCCH_DMRS_ScramblingID = 0; + SearchSpaceId = 10; + commonSearchSpaces_controlResourceSetId = 5; + SearchSpace_monitoringSlotPeriodicityAndOffset_choice = "sl1"; + SearchSpace_monitoringSlotPeriodicityAndOffset_value = 0; + SearchSpace_duration = 2; + SearchSpace_nrofCandidates_aggregationLevel1 = 0; + SearchSpace_nrofCandidates_aggregationLevel2 = 0; + SearchSpace_nrofCandidates_aggregationLevel4 = 0; + SearchSpace_nrofCandidates_aggregationLevel8 = 0; + SearchSpace_nrofCandidates_aggregationLevel16 = 0; + SearchSpace_searchSpaceType = "common"; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 = 1; + Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 = 1; + Common_dci_Format2_3_monitoringPeriodicity = 1; + Common_dci_Format2_3_nrofPDCCH_Candidates = 1; + ue_Specific__dci_Formats = "formats0-0-And-1-0"; + RateMatchPatternLTE_CRS_carrierFreqDL = 6; + RateMatchPatternLTE_CRS_carrierBandwidthDL = 6; + RateMatchPatternLTE_CRS_nrofCRS_Ports = 1; + RateMatchPatternLTE_CRS_v_Shift = 0; + RateMatchPatternLTE_CRS_radioframeAllocationPeriod = 1; + RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0; + RateMatchPatternLTE_CRS_subframeAllocation_choice = "oneFrame"; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + GNB_INTERFACE_NAME_FOR_S1U = "eth0"; + GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + sdr_addrs = "addr=192.168.30.2"; + + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_DISABLE"; + } +); + +NETWORK_CONTROLLER : +{ + FLEXRAN_ENABLED = "no"; + FLEXRAN_INTERFACE_NAME = "lo"; + FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; + FLEXRAN_PORT = 2210; + FLEXRAN_CACHE = "/mnt/oai_agent_cache"; + FLEXRAN_AWAIT_RECONF = "no"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c index 55612586943252ed71f7465f272710a2cbbb5c7b..411281d72a28086f389a96228cb00bcd51e3eaae 100644 --- a/targets/RT/USER/nr-softmodem.c +++ b/targets/RT/USER/nr-softmodem.c @@ -961,6 +961,7 @@ int main( int argc, char **argv ) fprintf(stderr,"Getting configuration failed\n"); exit(-1); } + openair0_cfg[0].threequarter_fs = threequarter_fs; #if T_TRACER