Commit afb9e6b4 authored by Florian Kaltenberger's avatar Florian Kaltenberger

Merge remote-tracking branch 'origin/develop-nr' into develop-nr-less-logging

parents ab0e6d24 29b57703
...@@ -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"
......
...@@ -1118,15 +1118,19 @@ set(PHY_POLARSRC ...@@ -1118,15 +1118,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
...@@ -1292,6 +1296,7 @@ set(PHY_SRC_UE ...@@ -1292,6 +1296,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}
) )
...@@ -1336,6 +1341,7 @@ set(PHY_SRC_UE ...@@ -1336,6 +1341,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}
) )
...@@ -2504,6 +2510,12 @@ add_executable(polartest ...@@ -2504,6 +2510,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
...@@ -691,7 +689,7 @@ function main() { ...@@ -691,7 +689,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)*/
/* @}*/ /* @}*/
......
This diff is collapsed.
#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);
}
...@@ -106,17 +106,6 @@ void crcTableInit (void) ...@@ -106,17 +106,6 @@ void crcTableInit (void)
} while (++c); } 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, Byte by byte implementations,
...@@ -236,30 +225,10 @@ crc8 (unsigned char * inptr, int bitlen) ...@@ -236,30 +225,10 @@ crc8 (unsigned char * inptr, int bitlen)
return crc; 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) int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type)
{ {
uint32_t crc=0,oldcrc=0; uint32_t crc=0,oldcrc=0;
uint8_t crc_len,temp; uint8_t crc_len=0;
switch (crc_type) { switch (crc_type) {
case CRC24_A: case CRC24_A:
...@@ -335,7 +304,7 @@ main() ...@@ -335,7 +304,7 @@ main()
{ {
unsigned char test[] = "Thebigredfox"; unsigned char test[] = "Thebigredfox";
crcTableInit(); 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", crc24(test, (sizeof(test) - 1)*8));
printf("%x\n", crcbit(test, sizeof(test) - 1, poly8)); printf("%x\n", crcbit(test, sizeof(test) - 1, poly8));
printf("%x\n", crc8(test, (sizeof(test) - 1)*8)); printf("%x\n", crc8(test, (sizeof(test) - 1)*8));
......
/*
* 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;
}
/*
* 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
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#ifndef __NR_LDPC_TYPES__H__ #ifndef __NR_LDPC_TYPES__H__
#define __NR_LDPC_TYPES__H__ #define __NR_LDPC_TYPES__H__
#include "./nrLDPC_tools/time_meas.h" #include "PHY/TOOLS/time_meas.h"
// ============================================================================== // ==============================================================================
// TYPES // TYPES
......
...@@ -19,9 +19,20 @@ ...@@ -19,9 +19,20 @@
* contact@openairinterface.org * 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" #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); uint8_t arrayInd = ceil(arraySize / 32.0);
for (int i = 0; i < (arrayInd-1); i++) { for (int i = 0; i < (arrayInd-1); i++) {
for (int j = 0; j < 32; j++) { 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) { ...@@ -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); uint8_t arrayInd = ceil(arraySize / 32.0);
for (int i = 0; i < arrayInd; i++) { for (int i = 0; i < arrayInd; i++) {
out[i]=0; out[i]=0;
...@@ -43,16 +55,3 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) { ...@@ -43,16 +55,3 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) {
out[i]|=in[(i*32)]; 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;
}
}
...@@ -21,43 +21,36 @@ ...@@ -21,43 +21,36 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
// ----- Old implementation ---- // ----- Old implementation ----
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){ 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}; 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 // 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 temp1[crcPolynomialSize], temp2[crcPolynomialSize];
uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *));
if (crc_generator_matrix) if (crc_generator_matrix)
{
for (int i = 0; i < payloadSizeBits; i++) for (int i = 0; i < payloadSizeBits; i++)
{
crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); 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 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; 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++){ 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; crc_generator_matrix[i][j]=1;
} else { else
crc_generator_matrix[i][j]=0; crc_generator_matrix[i][j]=0;
}
} }
} }
return crc_generator_matrix; return crc_generator_matrix;
} }
...@@ -70,30 +63,26 @@ uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits){ ...@@ -70,30 +63,26 @@ uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits){
uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *));
if (crc_generator_matrix) if (crc_generator_matrix)
{
for (int i = 0; i < payloadSizeBits; i++) for (int i = 0; i < payloadSizeBits; i++)
{
crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); 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 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; 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++){ 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; crc_generator_matrix[i][j]=1;
} else { else
crc_generator_matrix[i][j]=0; crc_generator_matrix[i][j]=0;
}
} }
} }
return crc_generator_matrix; return crc_generator_matrix;
...@@ -105,33 +94,30 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits){ ...@@ -105,33 +94,30 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits){
// 0110 0001 D^6 + D^5 + 1 // 0110 0001 D^6 + D^5 + 1
uint8_t crcPolynomialSize = 6; uint8_t crcPolynomialSize = 6;
uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize]; uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize];
uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *)); uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *));
if (crc_generator_matrix) if (crc_generator_matrix)
{
for (int i = 0; i < payloadSizeBits; i++) for (int i = 0; i < payloadSizeBits; i++)
{
crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t)); 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 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; 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++){ 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; crc_generator_matrix[i][j]=1;
} else { else
crc_generator_matrix[i][j]=0; crc_generator_matrix[i][j]=0;
}
} }
} }
return crc_generator_matrix; return crc_generator_matrix;
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
/*!\file PHY/CODING/nrPolar_tools/nr_polar_defs.h /*!\file PHY/CODING/nrPolar_tools/nr_polar_defs.h
* \brief * \brief
* \author Turker Yilmaz * \author Raymond Knopp, Turker Yilmaz
* \date 2018 * \date 2018
* \version 0.1 * \version 0.1
* \company EURECOM * \company EURECOM
* \email turker.yilmaz@eurecom.fr * \email raymond.knopp@eurecom.fr, turker.yilmaz@eurecom.fr
* \note * \note
* \warning * \warning
*/ */
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
//#include "SIMULATION/TOOLS/sim.h" //#include "SIMULATION/TOOLS/sim.h"
#define NR_POLAR_DECODER_LISTSIZE 8 //uint8_t #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_1_PRIME 149 //uint16_t
#define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 //uint16_t #define NR_POLAR_AGGREGATION_LEVEL_2_PRIME 151 //uint16_t
...@@ -54,12 +53,13 @@ ...@@ -54,12 +53,13 @@
#define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 //uint16_t #define NR_POLAR_AGGREGATION_LEVEL_8_PRIME 163 //uint16_t
#define NR_POLAR_AGGREGATION_LEVEL_16_PRIME 167 //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 1024
#define nmax 10 #define nmax 10
#define uint128_t __uint128_t
typedef struct decoder_node_t_s { typedef struct decoder_node_t_s {
struct decoder_node_t_s *left; struct decoder_node_t_s *left;
struct decoder_node_t_s *right; struct decoder_node_t_s *right;
...@@ -106,18 +106,17 @@ struct nrPolar_params { ...@@ -106,18 +106,17 @@ struct nrPolar_params {
int16_t *Q_PC_N; int16_t *Q_PC_N;
uint8_t *information_bit_pattern; uint8_t *information_bit_pattern;
uint16_t *channel_interleaver_pattern; uint16_t *channel_interleaver_pattern;
uint32_t crc_polynomial; //uint32_t crc_polynomial;
uint8_t **crc_generator_matrix; //G_P uint8_t **crc_generator_matrix; //G_P
uint8_t **G_N; uint8_t **G_N;
uint64_t **G_N_tab; uint64_t **G_N_tab;
int groupsize; int groupsize;
int *rm_tab; int *rm_tab;
uint64_t cprime_tab0[32][256]; uint64_t cprime_tab0[32][256];
uint64_t cprime_tab1[32][256]; uint64_t cprime_tab1[32][256];
uint64_t B_tab0[32][256]; uint64_t B_tab0[32][256];
uint64_t B_tab1[32][256]; uint64_t B_tab1[32][256];
uint32_t *crc256Table;
uint8_t **extended_crc_generator_matrix; uint8_t **extended_crc_generator_matrix;
//lowercase: bits, Uppercase: Bits stored in bytes //lowercase: bits, Uppercase: Bits stored in bytes
//polar_encoder vectors //polar_encoder vectors
...@@ -152,40 +151,31 @@ void polar_encoder_fast(uint64_t *A, ...@@ -152,40 +151,31 @@ void polar_encoder_fast(uint64_t *A,
t_nrPolar_params *polarParams); t_nrPolar_params *polarParams);
int8_t polar_decoder(double *input, int8_t polar_decoder(double *input,
uint8_t *output, uint32_t *output,
t_nrPolar_params *polarParams, t_nrPolar_params *polarParams,
uint8_t listSize, uint8_t listSize);
uint8_t pathMetricAppr);
uint32_t polar_decoder_int16(int16_t *input, uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out, uint64_t *out,
const t_nrPolar_params *polarParams); 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, int8_t polar_decoder_dci(double *input,
uint32_t *out, uint32_t *out,
t_nrPolar_params *polarParams, t_nrPolar_params *polarParams,
uint8_t listSize, uint8_t listSize,
uint8_t pathMetricAppr,
uint16_t n_RNTI); uint16_t n_RNTI);
void generic_polar_decoder(const t_nrPolar_params *, void generic_polar_decoder(const t_nrPolar_params *pp,
decoder_node_t *); 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_decoder_tree(t_nrPolar_params *pp);
void build_polar_tables(t_nrPolar_params *polarParams); void build_polar_tables(t_nrPolar_params *polarParams);
...@@ -193,9 +183,9 @@ void init_polar_deinterleaver_table(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); void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
t_nrPolar_params *nr_polar_params ( int8_t messageType, t_nrPolar_params *nr_polar_params (int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level); uint8_t aggregation_level);
uint16_t nr_polar_aggregation_prime (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, ...@@ -256,17 +246,19 @@ void nr_polar_info_bit_extraction(uint8_t *input,
uint8_t *pattern, uint8_t *pattern,
uint16_t size); uint16_t size);
void nr_bit2byte_uint32_8_t(uint32_t *in, void nr_bit2byte_uint32_8(uint32_t *in,
uint16_t arraySize, uint16_t arraySize,
uint8_t *out); uint8_t *out);
void nr_byte2bit_uint8_32_t(uint8_t *in, void nr_byte2bit_uint8_32(uint8_t *in,
uint16_t arraySize, uint16_t arraySize,
uint32_t *out); uint32_t *out);
void nr_crc_bit2bit_uint32_8_t(uint32_t *in, uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits);
uint16_t arraySize,
uint8_t *out); uint8_t **crc11_generator_matrix(uint16_t payloadSizeBits);
uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits);
void nr_polar_bit_insertion(uint8_t *input, void nr_polar_bit_insertion(uint8_t *input,
uint8_t *output, uint8_t *output,
...@@ -320,7 +312,6 @@ void nr_sort_asc_int16_1D_array_ind(int32_t *matrix, ...@@ -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 nr_free_double_2D_array(double **input, uint16_t xlen);
void updateLLR(double ***llr, void updateLLR(double ***llr,
uint8_t **llrU, uint8_t **llrU,
uint8_t ***bit, uint8_t ***bit,
...@@ -329,8 +320,7 @@ void updateLLR(double ***llr, ...@@ -329,8 +320,7 @@ void updateLLR(double ***llr,
uint16_t row, uint16_t row,
uint16_t col, uint16_t col,
uint16_t xlen, uint16_t xlen,
uint8_t ylen, uint8_t ylen);
uint8_t approximation);
void updateBit(uint8_t ***bit, void updateBit(uint8_t ***bit,
uint8_t **bitU, uint8_t **bitU,
...@@ -344,21 +334,18 @@ void updatePathMetric(double *pathMetric, ...@@ -344,21 +334,18 @@ void updatePathMetric(double *pathMetric,
double ***llr, double ***llr,
uint8_t listSize, uint8_t listSize,
uint8_t bitValue, uint8_t bitValue,
uint16_t row, uint16_t row);
uint8_t approximation);
void updatePathMetric2(double *pathMetric, void updatePathMetric2(double *pathMetric,
double ***llr, double ***llr,
uint8_t listSize, uint8_t listSize,
uint16_t row, uint16_t row);
uint8_t approximation);
void computeLLR(double ***llr, void computeLLR(double ***llr,
uint16_t row, uint16_t row,
uint16_t col, uint16_t col,
uint8_t i, uint8_t i,
uint16_t offset, uint16_t offset);
uint8_t approximation);
void updateCrcChecksum(uint8_t **crcChecksum, void updateCrcChecksum(uint8_t **crcChecksum,
uint8_t **crcGen, uint8_t **crcGen,
...@@ -372,12 +359,6 @@ void updateCrcChecksum2(uint8_t **crcChecksum, ...@@ -372,12 +359,6 @@ void updateCrcChecksum2(uint8_t **crcChecksum,
uint32_t i2, uint32_t i2,
uint8_t len); 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 //Also nr_polar_rate_matcher
static inline void nr_polar_interleaver(uint8_t *input, static inline void nr_polar_interleaver(uint8_t *input,
uint8_t *output, uint8_t *output,
...@@ -387,14 +368,10 @@ static inline void nr_polar_interleaver(uint8_t *input, ...@@ -387,14 +368,10 @@ static inline void nr_polar_interleaver(uint8_t *input,
} }
static inline void nr_polar_deinterleaver(uint8_t *input, static inline void nr_polar_deinterleaver(uint8_t *input,
uint8_t *output, uint8_t *output,
uint16_t *pattern, uint16_t *pattern,
uint16_t size) { uint16_t size) {
for (int i=0; i<size; i++) { for (int i=0; i<size; i++) output[pattern[i]]=input[i];
output[pattern[i]]=input[i];
}
} }
void build_decoder_tree(t_nrPolar_params *pp);
#endif #endif
/*
* 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;
}
/*
* 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;
}
/*
* 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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,1,-1,1,-1,1,1,-1,-1,1,-1,1,-1,1,-1,-1,1}
};
#endif
...@@ -21,19 +21,16 @@ ...@@ -21,19 +21,16 @@
/*!\file PHY/CODING/nr_polar_init.h /*!\file PHY/CODING/nr_polar_init.h
* \brief * \brief
* \author Turker Yilmaz * \author Turker Yilmaz, Raymond Knopp
* \date 2018 * \date 2018
* \version 0.1 * \version 0.1
* \company EURECOM * \company EURECOM
* \email turker.yilmaz@eurecom.fr * \email turker.yilmaz@eurecom.fr, raymond.knopp@eurecom.fr
* \note * \note
* \warning * \warning
*/ */
#include "nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/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/NR_TRANSPORT/nr_dci.h" #include "PHY/NR_TRANSPORT/nr_dci.h"
static int intcmp(const void *p1,const void *p2) { static int intcmp(const void *p1,const void *p2) {
...@@ -95,7 +92,9 @@ static void nr_polar_init(t_nrPolar_params * *polarParams, ...@@ -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->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->n = log2(newPolarInitNode->N);
newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n); newPolarInitNode->G_N = nr_polar_kronecker_power_matrices(newPolarInitNode->n);
//polar_encoder vectors: //polar_encoder vectors:
...@@ -182,9 +181,9 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) { ...@@ -182,9 +181,9 @@ void nr_polar_print_polarParams(t_nrPolar_params *polarParams) {
return; return;
} }
t_nrPolar_params *nr_polar_params ( int8_t messageType, t_nrPolar_params *nr_polar_params (int8_t messageType,
uint16_t messageLength, uint16_t messageLength,
uint8_t aggregation_level) { uint8_t aggregation_level) {
static t_nrPolar_params *polarList = NULL; static t_nrPolar_params *polarList = NULL;
nr_polar_init(&polarList, messageType,messageLength,aggregation_level); nr_polar_init(&polarList, messageType,messageLength,aggregation_level);
t_nrPolar_params *polarParams=polarList; t_nrPolar_params *polarParams=polarList;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "PHY/defs_gNB.h" #include "PHY/defs_gNB.h"
#include "PHY/defs_nr_UE.h" #include "PHY/defs_nr_UE.h"
#include "PHY/CODING/coding_defs.h"
//#define RM_DEBUG 1 //#define RM_DEBUG 1
......
...@@ -355,7 +355,9 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, ...@@ -355,7 +355,9 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id,
#endif #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 ) uint16_t max_harq_tx )
{ {
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn); extern uint32_t from_nrarfcn(int nr_bandP,uint32_t dl_nrarfcn);
extern int32_t get_uldl_offset(int nr_bandP); extern int32_t get_uldl_offset(int nr_bandP);
extern openair0_config_t openair0_cfg[MAX_CARDS];
int l1_north_init_gNB() { int l1_north_init_gNB() {
int i,j; int i,j;
...@@ -408,7 +409,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { ...@@ -408,7 +409,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
RC.gNB[Mod_id][CC_id]->mac_enabled = 1; 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->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->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", 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, Mod_id,
CC_id, CC_id,
......
...@@ -357,8 +357,10 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id, ...@@ -357,8 +357,10 @@ void phy_config_dedicated_scell_ue(uint8_t Mod_id,
} }
#endif #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,
uint16_t max_harq_tx ) int CC_id,
uint8_t eNB_id,
uint16_t max_harq_tx)
{ {
int num_of_threads,num_of_code_words; int num_of_threads,num_of_code_words;
......
...@@ -194,7 +194,7 @@ typedef struct { ...@@ -194,7 +194,7 @@ typedef struct {
/// allocated CBA RNTI /// allocated CBA RNTI
uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
/// UL max-harq-retransmission /// UL max-harq-retransmission
uint8_t Mlimit; uint16_t Mlimit;
} LTE_UE_ULSCH_t; } LTE_UE_ULSCH_t;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
*/ */
#include "nr_dci.h" #include "nr_dci.h"
#include "nr_dlsch.h"
//#define DEBUG_PDCCH_DMRS //#define DEBUG_PDCCH_DMRS
//#define DEBUG_DCI //#define DEBUG_DCI
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include "PHY/defs_gNB.h" #include "PHY/defs_gNB.h"
#include "PHY/NR_REFSIG/nr_refsig.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, uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
nfapi_nr_rnti_type_e rnti_type, nfapi_nr_rnti_type_e rnti_type,
uint16_t N_RB, uint16_t N_RB,
......
...@@ -64,9 +64,9 @@ void nr_fill_cce_list(NR_gNB_DCI_ALLOC_t* dci_alloc, uint16_t n_shift, uint8_t m ...@@ -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) { 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", uint16_t assertFatalCond = (N_reg%(bsize*R));
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); C = N_reg/(bsize*R);
} }
tmp = L * (( Y + (m*N_cce)/(L*M_s_max) + n_CI ) % CEILIDIV(N_cce,L)); tmp = L * (( Y + (m*N_cce)/(L*M_s_max) + n_CI ) % CEILIDIV(N_cce,L));
......
...@@ -67,6 +67,11 @@ void nr_pdsch_codeword_scrambling(uint8_t *in, ...@@ -67,6 +67,11 @@ void nr_pdsch_codeword_scrambling(uint8_t *in,
uint32_t n_RNTI, uint32_t n_RNTI,
uint32_t* out); 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, void nr_pdsch_codeword_modulation(uint32_t *in,
uint8_t Qm, uint8_t Qm,
uint32_t length, uint32_t length,
...@@ -103,6 +108,8 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); ...@@ -103,6 +108,8 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
void clean_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);
int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type);
int nr_dlsch_encoding(unsigned char *a,int frame, int nr_dlsch_encoding(unsigned char *a,int frame,
...@@ -110,5 +117,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame, ...@@ -110,5 +117,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame,
NR_gNB_DLSCH_t *dlsch, NR_gNB_DLSCH_t *dlsch,
NR_DL_FRAME_PARMS* frame_parms); NR_DL_FRAME_PARMS* frame_parms);
void nr_emulate_dlsch_payload(uint8_t* payload, uint16_t size); void nr_emulate_dlsch_payload(uint8_t* payload, uint16_t size);
...@@ -285,8 +285,8 @@ int nr_dlsch_encoding(unsigned char *a,int frame, ...@@ -285,8 +285,8 @@ int nr_dlsch_encoding(unsigned char *a,int frame,
uint32_t A, Z, F=0; uint32_t A, Z, F=0;
uint32_t *pz = &Z; uint32_t *pz = &Z;
uint8_t mod_order = rel15.modulation_order; uint8_t mod_order = rel15.modulation_order;
uint16_t Kr=0,r,r_offset=0,Kr_bytes; uint16_t Kr=0,r,r_offset=0;
uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS];
uint8_t BG=1; uint8_t BG=1;
uint32_t E; uint32_t E;
uint8_t Ilbrm = 0; uint8_t Ilbrm = 0;
...@@ -359,13 +359,16 @@ int nr_dlsch_encoding(unsigned char *a,int frame, ...@@ -359,13 +359,16 @@ int nr_dlsch_encoding(unsigned char *a,int frame,
} }
Kr = dlsch->harq_processes[harq_pid]->K; Kr = dlsch->harq_processes[harq_pid]->K;
#ifdef DEBUG_DLSCH_CODING
uint16_t Kr_bytes;
Kr_bytes = Kr>>3; 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); //printf("segment Z %d k %d Kr %d BG %d\n", *pz,dlsch->harq_processes[harq_pid]->K,Kr,BG);
//start_meas(te_stats); //start_meas(te_stats);
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { 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]; //channel_input[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F); printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
...@@ -398,7 +401,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame, ...@@ -398,7 +401,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame,
//stop_meas(te_stats); //stop_meas(te_stats);
//printf("end ldpc encoder -- output\n"); //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 #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_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); write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4);
......
...@@ -112,12 +112,9 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, ...@@ -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_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; 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 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 : \ 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); (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 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 N_sh_symb = dlsch_rel15->nb_symbols;
uint8_t Imcs = dlsch_rel15->mcs_idx; 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; 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, ...@@ -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; uint16_t N_RE, Ninfo, Ninfo_prime, C, TBS=0, R;
uint8_t table_idx, Qm, n, scale; 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; scale = ((table_idx==2)&&((Imcs==20)||(Imcs==26)))?11:10;
N_RE = min(156, N_RE_prime)*dlsch_rel15->n_prb; N_RE = min(156, N_RE_prime)*dlsch_rel15->n_prb;
......
...@@ -171,6 +171,104 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 ...@@ -171,6 +171,104 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
return(NULL); 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, uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint8_t UE_id, uint8_t UE_id,
...@@ -205,7 +303,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -205,7 +303,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
int16_t z [68*384]; int16_t z [68*384];
int8_t l [68*384]; int8_t l [68*384];
int16_t inv_d [68*384]; //int16_t inv_d [68*384];
uint8_t kc; uint8_t kc;
uint8_t Ilbrm = 0; uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984; uint32_t Tbslbrm = 950984;
...@@ -608,4 +706,4 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -608,4 +706,4 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
ulsch->last_iteration_cnt = ret; ulsch->last_iteration_cnt = ret;
return(ret); return(ret);
} }
\ No newline at end of file
...@@ -332,7 +332,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF, ...@@ -332,7 +332,9 @@ void nr_pdcch_extract_rbs_single(int32_t **rxdataF,
//uint8_t rb_count_bit; //uint8_t rb_count_bit;
uint8_t i, j, aarx, bitcnt_coreset_freq_dom=0; uint8_t i, j, aarx, bitcnt_coreset_freq_dom=0;
int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext; int32_t *dl_ch0, *dl_ch0_ext, *rxF, *rxF_ext;
#ifdef NR_PDCCH_DCI_DEBUG
int nushiftmod3 = frame_parms->nushift % 3; int nushiftmod3 = frame_parms->nushift % 3;
#endif
uint8_t symbol_mod; uint8_t symbol_mod;
symbol_mod = (symbol >= (7 - frame_parms->Ncp)) ? symbol - (7 - frame_parms->Ncp) : symbol; 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 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, ...@@ -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) // 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; //uint8_t coreset_nbr_act;
// indicates the number of REG contained in the PDCCH (number of RBs * number of symbols, in CORESET) // 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; uint32_t coreset_nbr_rb = 0;
// for (int j=0; j < coreset_nbr_act; j++) { // for (int j=0; j < coreset_nbr_act; j++) {
// for each active CORESET (max number of active CORESETs in a BWP is 3), // 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, ...@@ -829,9 +829,9 @@ int32_t nr_rx_pdcch(PHY_VARS_NR_UE *ue,
#ifdef NR_PDCCH_DCI_DEBUG #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); 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 #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 #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", 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); coreset_nbr_rb, coreset_nbr_reg, coreset_nbr_reg, reg_bundle_size_L,coreset_interleaver_size_R, coreset_C);
#endif #endif
......
...@@ -231,14 +231,16 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -231,14 +231,16 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
int16_t z [68*384]; int16_t z [68*384];
int8_t l [68*384]; int8_t l [68*384];
//__m128i l; //__m128i l;
int16_t inv_d [68*384]; //int16_t inv_d [68*384];
uint8_t kc; uint8_t kc;
uint8_t Ilbrm = 0; uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984; uint32_t Tbslbrm = 950984;
uint16_t nb_rb = 30; //to update uint16_t nb_rb = 30;
uint8_t nb_re_dmrs = 6;
uint16_t length_dmrs = 1;
double Coderate = 0.0; 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; uint32_t i,j;
...@@ -312,15 +314,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -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->Z, // [hna] Z is Zc
&harq_process->F); &harq_process->F);
p_decParams->Z = harq_process->Z;
#ifdef DEBUG_DLSCH_DECODING #ifdef DEBUG_DLSCH_DECODING
printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z);
if (!frame%100) 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); printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl);
#endif #endif
} }
p_decParams->Z = harq_process->Z;
//printf("dlsch decoding nr segmentation Z %d\n", p_decParams->Z);
Coderate = (float) A /(float) G; Coderate = (float) A /(float) G;
if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25) if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25)
{ {
......
...@@ -246,7 +246,7 @@ typedef struct { ...@@ -246,7 +246,7 @@ typedef struct {
/// allocated CBA RNTI /// allocated CBA RNTI
//uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP]; //uint16_t cba_rnti[4];//NUM_MAX_CBA_GROUP];
/// UL max-harq-retransmission /// UL max-harq-retransmission
uint8_t Mlimit; uint16_t Mlimit;
} NR_UE_ULSCH_t; } NR_UE_ULSCH_t;
typedef struct { typedef struct {
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "PHY/CODING/nrLDPC_encoder/defs.h" #include "PHY/CODING/nrLDPC_encoder/defs.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
#include "common/utils/LOG/vcd_signal_dumper.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 ...@@ -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; 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; unsigned char bw_scaling =1;
switch (N_RB_UL) { switch (N_RB_UL) {
...@@ -203,15 +204,14 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ...@@ -203,15 +204,14 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
uint32_t A, Z, F; uint32_t A, Z, F;
uint32_t *pz; uint32_t *pz;
uint8_t mod_order; uint8_t mod_order;
uint16_t Kr,r,r_offset,Kr_bytes; uint16_t Kr,r,r_offset;
uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS]; //uint8_t *d_tmp[MAX_NUM_DLSCH_SEGMENTS];
uint8_t BG; uint8_t BG;
uint32_t E; uint32_t E;
uint8_t Ilbrm; uint8_t Ilbrm;
uint32_t Tbslbrm; uint32_t Tbslbrm;
uint8_t nb_re_dmrs; uint8_t nb_re_dmrs;
uint16_t length_dmrs; uint16_t length_dmrs;
int i;
float Coderate; float Coderate;
/////////// ///////////
...@@ -311,8 +311,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ...@@ -311,8 +311,10 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
} }
Kr = harq_process->K; Kr = harq_process->K;
#ifdef DEBUG_DLSCH_CODING
uint16_t Kr_bytes;
Kr_bytes = Kr>>3; Kr_bytes = Kr>>3;
#endif
/////////// ///////////
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
...@@ -325,7 +327,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ...@@ -325,7 +327,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
//start_meas(te_stats); //start_meas(te_stats);
for (r=0; r<harq_process->C; r++) { 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]; //channel_input[r] = &harq_process->d[r][0];
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("Encoder: B %d F %d \n",harq_process->B, harq_process->F); 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, ...@@ -357,7 +359,6 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
//stop_meas(te_stats); //stop_meas(te_stats);
//printf("end ldpc encoder -- output\n"); //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 #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_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); write_output("ulsch_enc_output0.m","enc0",&harq_process->d[0][0],(3*8*Kr_bytes)+12,1,4);
......
This diff is collapsed.
...@@ -916,6 +916,7 @@ typedef struct { ...@@ -916,6 +916,7 @@ typedef struct {
NR_UE_COMMON common_vars; NR_UE_COMMON common_vars;
nr_ue_if_module_t *if_inst; nr_ue_if_module_t *if_inst;
nfapi_nr_config_request_t nrUE_config;
nr_downlink_indication_t dl_indication; nr_downlink_indication_t dl_indication;
nr_uplink_indication_t ul_indication; nr_uplink_indication_t ul_indication;
......
...@@ -333,5 +333,4 @@ typedef struct nr_band_info_s { ...@@ -333,5 +333,4 @@ typedef struct nr_band_info_s {
nr_bandentry_t band_info[100]; nr_bandentry_t band_info[100];
} nr_band_info_t; } nr_band_info_t;
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment