Commit b472d97b authored by Florian Kaltenberger's avatar Florian Kaltenberger
Browse files

Merge remote-tracking branch 'origin/develop-nr' into test-x310

parents 0061daeb 7e99e1f6
...@@ -252,7 +252,7 @@ case $key in ...@@ -252,7 +252,7 @@ case $key in
VM_NAME=ci-phy-sim VM_NAME=ci-phy-sim
ARCHIVES_LOC=phy_sim ARCHIVES_LOC=phy_sim
LOG_PATTERN=.Rel15.txt LOG_PATTERN=.Rel15.txt
NB_PATTERN_FILES=9 NB_PATTERN_FILES=10
BUILD_OPTIONS="--phy_simulators" BUILD_OPTIONS="--phy_simulators"
VM_MEMORY=8192 VM_MEMORY=8192
RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b"
...@@ -331,7 +331,7 @@ case $key in ...@@ -331,7 +331,7 @@ case $key in
VM_NAME=ci-phy-sim VM_NAME=ci-phy-sim
ARCHIVES_LOC=phy_sim ARCHIVES_LOC=phy_sim
LOG_PATTERN=.Rel15.txt LOG_PATTERN=.Rel15.txt
NB_PATTERN_FILES=9 NB_PATTERN_FILES=10
BUILD_OPTIONS="--phy_simulators" BUILD_OPTIONS="--phy_simulators"
VM_MEMORY=8192 VM_MEMORY=8192
RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b" RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b"
......
...@@ -1116,15 +1116,19 @@ set(PHY_POLARSRC ...@@ -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_procedures.c
${OPENAIR1_DIR}/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.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 set(PHY_TURBOIF
${OPENAIR1_DIR}/PHY/CODING/coding_load.c ${OPENAIR1_DIR}/PHY/CODING/coding_load.c
) )
set(PHY_LDPCSRC set(PHY_LDPCSRC
${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c ${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_encoder.c
${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
) )
add_library(coding MODULE ${PHY_TURBOSRC} ) add_library(coding MODULE ${PHY_TURBOSRC} )
set(PHY_SRC_COMMON set(PHY_SRC_COMMON
...@@ -1290,6 +1294,7 @@ set(PHY_SRC_UE ...@@ -1290,6 +1294,7 @@ set(PHY_SRC_UE
${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c ${OPENAIR1_DIR}/PHY/TOOLS/time_meas.c
${OPENAIR1_DIR}/PHY/TOOLS/lut.c ${OPENAIR1_DIR}/PHY/TOOLS/lut.c
${PHY_POLARSRC} ${PHY_POLARSRC}
${PHY_SMALLBLOCKSRC}
${PHY_LDPCSRC} ${PHY_LDPCSRC}
) )
...@@ -1334,6 +1339,7 @@ set(PHY_SRC_UE ...@@ -1334,6 +1339,7 @@ set(PHY_SRC_UE
${OPENAIR1_DIR}/PHY/INIT/nr_init_ue.c ${OPENAIR1_DIR}/PHY/INIT/nr_init_ue.c
# ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c # ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
${PHY_POLARSRC} ${PHY_POLARSRC}
${PHY_SMALLBLOCKSRC}
${PHY_LDPCSRC} ${PHY_LDPCSRC}
) )
...@@ -2513,6 +2519,12 @@ add_executable(polartest ...@@ -2513,6 +2519,12 @@ add_executable(polartest
${OPENAIR_DIR}/common/utils/backtrace.c) ${OPENAIR_DIR}/common/utils/backtrace.c)
target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) 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 add_executable(ldpctest
${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c
${OPENAIR_DIR}/common/utils/backtrace.c) ${OPENAIR_DIR}/common/utils/backtrace.c)
......
...@@ -1116,8 +1116,31 @@ ...@@ -1116,8 +1116,31 @@
<search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false> <search_expr_false>segmentation fault|assertion|exiting|fatal</search_expr_false>
<nruns>3</nruns> <nruns>3</nruns>
</testCase> </testCase>
<testCase id="015107"> <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> <class>execution</class>
<desc>nr_ulschsim Test cases. (Test1: 106 PRB), <desc>nr_ulschsim Test cases. (Test1: 106 PRB),
(Test2: 217 PRB), (Test2: 217 PRB),
......
...@@ -80,8 +80,6 @@ function print_help() { ...@@ -80,8 +80,6 @@ function print_help() {
This program installs OpenAirInterface Software This program installs OpenAirInterface Software
You should have ubuntu 16.xx or 18.04 updated You should have ubuntu 16.xx or 18.04 updated
Options Options
-h
This help
-c | --clean -c | --clean
Erase all files to make a rebuild from start Erase all files to make a rebuild from start
-C | --clean-all -C | --clean-all
...@@ -686,7 +684,7 @@ function main() { ...@@ -686,7 +684,7 @@ function main() {
echo_info "Compiling unitary tests simulators" echo_info "Compiling unitary tests simulators"
# TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
#simlist="dlsim_tm4 dlsim ulsim 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 for f in $simlist ; do
compilations \ compilations \
phy_simulators $f \ phy_simulators $f \
......
...@@ -683,7 +683,7 @@ install_asn1c_from_source(){ ...@@ -683,7 +683,7 @@ install_asn1c_from_source(){
# better to use a given commit than a branch in case the branch # better to use a given commit than a branch in case the branch
# is updated and requires modifications in the source of OAI # is updated and requires modifications in the source of OAI
#git checkout velichkov_s1ap_plus_option_group #git checkout velichkov_s1ap_plus_option_group
git checkout d3aed06bb2bec7df1b5c6d0333f8c7dfc5993372 git checkout f12568d617dbf48497588f8e227d70388fa217c9
autoreconf -iv autoreconf -iv
./configure ./configure
make -j`nproc` make -j`nproc`
......
...@@ -83,11 +83,11 @@ extern "C" { ...@@ -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 * @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_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_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_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_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_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)*/ #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)*/
/* @}*/ /* @}*/
......
...@@ -11,116 +11,137 @@ ...@@ -11,116 +11,137 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h"
#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/coding_defs.h"
#include "SIMULATION/TOOLS/sim.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_DCI_POLAR_PARAMS
//#define DEBUG_POLAR_TIMING //#define DEBUG_POLAR_TIMING
//#define DEBUG_CRC //#define DEBUG_POLARTEST
int main(int argc, char *argv[]) { 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.) //Default simulation values (Aim for iterations = 1000000.)
int decoder_int16=0;
int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI 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 SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB
double SNR, SNR_lin; double SNR, SNR_lin;
int16_t nBitError = 0; // -1 = Decoding failed (All list entries have failed the CRC checks). 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. 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; 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) { switch (arguments) {
case 's': case 's':
SNRstart = atof(optarg); SNRstart = atof(optarg);
break; break;
case 'd': case 'd':
SNRinc = atof(optarg); SNRinc = atof(optarg);
break; break;
case 'f': case 'f':
SNRstop = atof(optarg); SNRstop = atof(optarg);
break; break;
case 'm': case 'm':
polarMessageType = atoi(optarg); polarMessageType = atoi(optarg);
break; if (polarMessageType!=0 && polarMessageType!=1 && polarMessageType!=2)
printf("Illegal polar message type %d (should be 0,1 or 2)\n", polarMessageType);
case 'i': break;
iterations = atoi(optarg);
break; case 'i':
iterations = atoi(optarg);
case 'l': break;
decoderListSize = (uint8_t) atoi(optarg);
break; case 'l':
decoderListSize = (uint8_t) atoi(optarg);
case 'a': break;
pathMetricAppr = (uint8_t) atoi(optarg);
break; case 'q':
decoder_int16 = 1;
case 'q': break;
decoder_int16 = 1;
break; case 'g':
iterations = 1;
case 'g': SNRstart = -6.0;
iterations = 1; SNRstop = -6.0;
SNRstart = -6.0; decoder_int16 = 1;
SNRstop = -6.0; break;
decoder_int16 = 1;
break; case 'F':
logFlag = 1;
case 'h': break;
printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr\n");
exit(-1); case 'L':
aggregation_level=atoi(optarg);
default: if (aggregation_level != 1 && aggregation_level != 2 && aggregation_level != 4 && aggregation_level != 8 && aggregation_level != 16) {
perror("[polartest.c] Problem at argument parsing with getopt"); printf("Illegal aggregation level %d \n",aggregation_level);
exit(-1); 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 if (polarMessageType == 0) { //PBCH
testLength = 64;//NR_POLAR_PBCH_PAYLOAD_BITS; aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL;
coderLength = NR_POLAR_PBCH_E;
aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL;
} else if (polarMessageType == 1) { //DCI } else if (polarMessageType == 1) { //DCI
//testLength = nr_get_dci_size(params_rel15->dci_format, params_rel15->rnti_type, &fp->initial_bwp_dl, cfg); coderLength = 108*aggregation_level;
testLength = 41; //20;
coderLength = 108*8; //to be changed by aggregate level function.
} else if (polarMessageType == -1) { //UCI } else if (polarMessageType == -1) { //UCI
//testLength = ; printf("UCI testing not supported yet\n");
//coderLength = ; exit(-1);
} }
//Logging //Logging
time_t currentTime; time_t currentTime;
time (&currentTime);
char fileName[512], currentTimeInfo[25]; char fileName[512], currentTimeInfo[25];
char folderName[] = "."; char folderName[] = ".";
/* FILE *logFile;
folderName=getenv("HOME"); /*folderName=getenv("HOME");
strcat(folderName,"/Desktop/polartestResults"); strcat(folderName,"/Desktop/polartestResults");*/
*/
if (logFlag){
time (&currentTime);
#ifdef DEBUG_POLAR_TIMING #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 #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 #endif
strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(&currentTime)); strftime(currentTimeInfo, 25, "_%Y-%m-%d-%H-%M-%S.csv", localtime(&currentTime));
strcat(fileName,currentTimeInfo); strcat(fileName,currentTimeInfo);
//Create "~/Desktop/polartestResults" folder if it doesn't already exist. //Create "~/Desktop/polartestResults" folder if it doesn't already exist.
/* /*struct stat folder = {0};
struct stat folder = {0}; if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);*/
if (stat(folderName, &folder) == -1) mkdir(folderName, S_IRWXU | S_IRWXG | S_IRWXO);
*/
FILE *logFile;
logFile = fopen(fileName, "w"); logFile = fopen(fileName, "w");
if (logFile==NULL) { if (logFile==NULL) {
...@@ -129,11 +150,12 @@ int main(int argc, char *argv[]) { ...@@ -129,11 +150,12 @@ int main(int argc, char *argv[]) {
} }
#ifdef DEBUG_POLAR_TIMING #ifdef DEBUG_POLAR_TIMING
fprintf(logFile, fprintf(logFile,",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n");
",timeEncoderCRCByte[us],timeEncoderCRCBit[us],timeEncoderInterleaver[us],timeEncoderBitInsertion[us],timeEncoder1[us],timeEncoder2[us],timeEncoderRateMatching[us],timeEncoderByte2Bit[us]\n");
#else #else
fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n"); fprintf(logFile,",SNR,nBitError,blockErrorState,t_encoder[us],t_decoder[us]\n");
#endif #endif
}
uint8_t testArrayLength = ceil(testLength / 32.0); uint8_t testArrayLength = ceil(testLength / 32.0);
uint8_t coderArrayLength = ceil(coderLength / 32.0); uint8_t coderArrayLength = ceil(coderLength / 32.0);
uint32_t testInput[testArrayLength]; //generate randomly uint32_t testInput[testArrayLength]; //generate randomly
...@@ -146,253 +168,156 @@ int main(int argc, char *argv[]) { ...@@ -146,253 +168,156 @@ int main(int argc, char *argv[]) {
double modulatedInput[coderLength]; //channel input double modulatedInput[coderLength]; //channel input
double channelOutput[coderLength]; //add noise double channelOutput[coderLength]; //add noise
int16_t channelOutput_int16[coderLength]; int16_t channelOutput_int16[coderLength];
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level); t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level);
#ifdef DEBUG_DCI_POLAR_PARAMS #ifdef DEBUG_DCI_POLAR_PARAMS
uint32_t dci_pdu[4]; uint32_t dci_pdu[4];
memset(dci_pdu,0,sizeof(uint32_t)*4); memset(dci_pdu,0,sizeof(uint32_t)*4);
dci_pdu[0]=0x01189400; dci_pdu[0]=0x01189400;
printf("dci_pdu: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", 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]);
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);
uint16_t size=41; uint16_t size=41;
uint16_t rnti=3; rnti=3;
aggregation_level=8; 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); 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++) polar_encoder_dci(dci_pdu, encoder_output, currentPtrDCI, rnti);
printf("encoder_output: [%2d]->0x%08x \n",i, encoder_output[i]); 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); uint8_t *encoder_outputByte = malloc(sizeof(uint8_t) * currentPtrDCI->encoderLength);
double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength); double *modulated_input = malloc (sizeof(double) * currentPtrDCI->encoderLength);
uint32_t dci_estimation[4]; double *channel_output = malloc (sizeof(double) * currentPtrDCI->encoderLength);
memset(dci_estimation,0,sizeof(uint32_t)*4); uint32_t dci_est[4];
printf("dci_estimation: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", memset(dci_est,0,sizeof(uint32_t)*4);
dci_estimation[0], dci_estimation[1], dci_estimation[2], dci_estimation[3]); 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_t(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte); nr_bit2byte_uint32_8(encoder_output, currentPtrDCI->encoderLength, encoder_outputByte);
printf("[polartest] 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]); SNR_lin = pow(10, 0/10); //SNR = 0 dB
printf("\n");
for(int i=0; i<currentPtrDCI->encoderLength; i++) { for(int i=0; i<currentPtrDCI->encoderLength; i++) {
if (encoder_outputByte[i] == 0) { if (encoder_outputByte[i] == 0)
channel_output[i]=1/sqrt(2); modulated_input[i]=1/sqrt(2);
} else { else
channel_output[i]=(-1)/sqrt(2); modulated_input[i]=(-1)/sqrt(2);
} channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
} }
decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, rnti);
decoderState = polar_decoder_dci(channel_output, 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]);
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]);
free(encoder_outputByte); free(encoder_outputByte);
free(channel_output); free(channel_output);
free(modulated_input);
return 0; return 0;
#endif #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;