Commit 9e26621d authored by francescomani's avatar francescomani

Merge remote-tracking branch 'origin/develop' into bupt-ulmimo-4

parents faf38c7e bf70a3bf
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -33,7 +33,9 @@ podSecurityContext:
securityContext:
privileged: true
# capabilities:
capabilities:
add:
- SYS_CAP_PTRACE
# drop:
# - ALL
# readOnlyRootFilesystem: true
......
......@@ -246,7 +246,7 @@ class PhySim:
isFinished = False
# doing a deep copy!
tmpPodNames = podNames.copy()
while(count < 32 and isFinished == False):
while(count < 50 and isFinished == False):
time.sleep(60)
for podName in tmpPodNames:
mySSH.command2(f'oc logs --tail=1 {podName} 2>&1', 6, silent=True)
......
......@@ -21,8 +21,10 @@
# Author: laurent THOMAS, Lionel GAUTHIER
cmake_minimum_required (VERSION 3.0)
cmake_minimum_required (VERSION 2.8)
project (OpenAirInterface LANGUAGES C CXX)
include("macros.cmake")
# System packages that are required
# We use either the cmake buildin, in ubuntu are in: /usr/share/cmake*/Modules/
......@@ -48,6 +50,7 @@ include_directories(${CRYPTO_INCLUDE_DIRS})
#uhd 4.0 and iris installs by default in /usr/local
include_directories("/usr/local/include/")
#use native cmake method as this package is not in pkg-config
add_list2_option(RF_BOARD "None" "RF head type" "None" "OAI_USRP" "OAI_BLADERF" "OAI_LMSSDR" "OAI_SIMU" "EXMIMO")
if (${RF_BOARD} STREQUAL "OAI_USRP")
find_package(Boost REQUIRED)
include_directories(${LIBBOOST_INCLUDE_DIR})
......@@ -184,106 +187,6 @@ else (CUDA_FOUND)
message ("No CUDA tool installed")
endif ()
###########################################
# macros to define options as there is numerous options in oai
################################################
macro(add_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
add_definitions("-D${name}=${value}")
endmacro(add_option)
macro(add_boolean_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY TYPE BOOL)
if (${value})
add_definitions("-D${name}")
endif (${value})
endmacro(add_boolean_option)
macro(add_integer_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
add_definitions("-D${name}=${value}")
endmacro(add_integer_option)
macro(add_list1_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${name}=${value}")
endif()
endmacro(add_list1_option)
macro(add_list2_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${value}=1")
endif()
endmacro(add_list2_option)
macro(add_list_string_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${name}=\"${value}\"")
endif()
endmacro(add_list_string_option)
# this function should produce the same value as the macro MAKE_VERSION defined in the C code (file types.h)
function(make_version VERSION_VALUE)
math(EXPR RESULT "0")
foreach (ARG ${ARGN})
math(EXPR RESULT "${RESULT} * 16 + ${ARG}")
endforeach()
set(${VERSION_VALUE} "${RESULT}" PARENT_SCOPE)
endfunction()
macro(compile_asn1 asn1Source asn1cCmd ResultFlag)
# Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
execute_process(COMMAND ${asn1cCmd} ${asn1Source} RESULT_VARIABLE ret)
if (NOT ${ret} STREQUAL 0)
message(FATAL_ERROR "${ret}: error")
endif (NOT ${ret} STREQUAL 0)
add_custom_target (
${ResultFlag} ALL
${asn1cCmd} ${asn1Source}
DEPENDS ${asn1Source}
)
endmacro(compile_asn1)
####################################################
# compilation flags
#############################################
......@@ -341,10 +244,10 @@ set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} ${commonOpts} -std=c++11")
add_boolean_option(SANITIZE_ADDRESS False "enable the address sanitizer (ASan)")
if (SANITIZE_ADDRESS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -static-libasan -fno-common")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -static-libasan -fno-common")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-common")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-common")
endif ()
add_definitions("-DASN_DISABLE_OER_SUPPORT")
......@@ -786,9 +689,6 @@ add_library(F1AP ${F1AP_C_FILES} )
add_list1_option(NB_ANTENNAS_RX "4" "Number of antennas in reception" "1" "2" "4")
add_list1_option(NB_ANTENNAS_TX "4" "Number of antennas in transmission" "1" "2" "4")
add_list2_option(RF_BOARD "EXMIMO" "RF head type" "None" "OAI_USRP" "OAI_BLADERF" "OAI_LMSSDR" "OAI_SIMU")
add_list2_option(TRANSP_PRO "None" "Transport protocol type" "None" "ETHERNET")
#NOKIA config enhancement
set (CONFIG_ROOTDIR
${OPENAIR_DIR}/common/config
......
This diff is collapsed.
......@@ -86,6 +86,7 @@ check_supported_distribution() {
"ubuntu20.04") return 0 ;;
"ubuntu20.10") return 0 ;;
"ubuntu21.04") return 0 ;;
"ubuntu21.10") return 0 ;;
esac
return 1
}
......
###########################################
# macros to define options as there is numerous options in oai
################################################
macro(add_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
add_definitions("-D${name}=${value}")
endmacro(add_option)
macro(add_boolean_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY TYPE BOOL)
if (${value})
add_definitions("-D${name}")
endif (${value})
endmacro(add_boolean_option)
macro(add_integer_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
add_definitions("-D${name}=${value}")
endmacro(add_integer_option)
macro(add_list1_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${name}=${value}")
endif()
endmacro(add_list1_option)
macro(add_list2_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${value}=1")
endif()
endmacro(add_list2_option)
macro(add_list_string_option name val helpstr)
if(DEFINED ${name})
set(value ${${name}})
else(DEFINED ${name})
set(value ${val})
endif()
set(${name} ${value} CACHE STRING "${helpstr}")
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
if(NOT "${value}" STREQUAL "False")
add_definitions("-D${name}=\"${value}\"")
endif()
endmacro(add_list_string_option)
# this function should produce the same value as the macro MAKE_VERSION defined in the C code (file types.h)
function(make_version VERSION_VALUE)
math(EXPR RESULT "0")
foreach (ARG ${ARGN})
math(EXPR RESULT "${RESULT} * 16 + ${ARG}")
endforeach()
set(${VERSION_VALUE} "${RESULT}" PARENT_SCOPE)
endfunction()
macro(compile_asn1 asn1Source asn1cCmd ResultFlag)
# Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make
execute_process(COMMAND ${asn1cCmd} ${asn1Source} RESULT_VARIABLE ret)
if (NOT ${ret} STREQUAL 0)
message(FATAL_ERROR "${ret}: error")
endif (NOT ${ret} STREQUAL 0)
add_custom_target (
${ResultFlag} ALL
${asn1cCmd} ${asn1Source}
DEPENDS ${asn1Source}
)
endmacro(compile_asn1)
......@@ -411,6 +411,16 @@ int register_log_component(char *name,
return computed_compidx;
}
static void unregister_all_log_components(void)
{
log_component_t* lc = &g_log->log_component[0];
while (lc->name) {
free((char *)lc->name); // defined as const, but assigned through strdup()
free(lc->filelog_name);
lc++;
}
}
int isLogInitDone (void)
{
if (g_log == NULL)
......@@ -502,6 +512,12 @@ int logInit (void)
return 0;
}
void logTerm(void)
{
unregister_all_log_components();
free_and_zero(g_log);
}
#include <sys/syscall.h>
static inline int log_header(log_component_t *c,
char *log_buffer,
......
......@@ -302,6 +302,7 @@ extern "C" {
# include "log_if.h"
/*----------------------------------------------------------------------------*/
int logInit (void);
void logTerm (void);
int isLogInitDone (void);
void logRecord_mt(const char *file, const char *func, int line,int comp, int level, const char *format, ...) __attribute__ ((format (printf, 6, 7)));
void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args );
......
......@@ -69,7 +69,6 @@ char *loader_format_shlibpath(char *modname, char *version)
char *tmpstr;
char *shlibpath =NULL;
char *shlibversion=NULL;
char *cfgprefix;
paramdef_t LoaderParams[] ={{"shlibpath", NULL, 0, strptr:&shlibpath, defstrval:NULL, TYPE_STRING, 0, NULL},
{"shlibversion", NULL, 0, strptr:&shlibversion, defstrval:"", TYPE_STRING, 0, NULL}};
......@@ -81,16 +80,11 @@ int ret;
/* looks for specific path for this module in the config file */
/* specific value for a module path and version is located in a modname subsection of the loader section */
/* shared lib name is formatted as lib<module name><module version>.so */
cfgprefix = malloc(sizeof(LOADER_CONFIG_PREFIX)+strlen(modname)+16);
if (cfgprefix == NULL) {
fprintf(stderr,"[LOADER] %s %d malloc error loading module %s, %s\n",__FILE__, __LINE__, modname, strerror(errno));
exit_fun("[LOADER] unrecoverable error");
} else {
sprintf(cfgprefix,LOADER_CONFIG_PREFIX ".%s",modname);
int ret = config_get( LoaderParams,sizeof(LoaderParams)/sizeof(paramdef_t),cfgprefix);
if (ret <0) {
fprintf(stderr,"[LOADER] %s %d couldn't retrieve config from section %s\n",__FILE__, __LINE__,cfgprefix);
}
char cfgprefix[sizeof(LOADER_CONFIG_PREFIX)+strlen(modname)+16];
sprintf(cfgprefix,LOADER_CONFIG_PREFIX ".%s",modname);
ret = config_get( LoaderParams,sizeof(LoaderParams)/sizeof(paramdef_t),cfgprefix);
if (ret <0) {
fprintf(stderr,"[LOADER] %s %d couldn't retrieve config from section %s\n",__FILE__, __LINE__,cfgprefix);
}
/* no specific path, use loader default shared lib path */
if (shlibpath == NULL) {
......@@ -142,6 +136,7 @@ int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *
}
shlib_path = loader_format_shlibpath(modname, version);
printf("shlib_path %s\n", shlib_path);
for (int i = 0; i < loader_data.numshlibs; i++) {
if (strcmp(loader_data.shlibs[i].name, modname) == 0) {
......@@ -198,15 +193,17 @@ int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *
}
if (farray) {
if (!loader_data.shlibs[lib_idx].funcarray) {
loader_data.shlibs[lib_idx].funcarray = malloc(numf*sizeof(loader_shlibfunc_t));
if (!loader_data.shlibs[lib_idx].funcarray) {
loader_shlibdesc_t *shlib = &loader_data.shlibs[lib_idx];
if (!shlib->funcarray) {
shlib->funcarray = calloc(numf, sizeof(loader_shlibfunc_t));
if (!shlib->funcarray) {
fprintf(stderr, "[LOADER] load_module_shlib(): unable to allocate memory\n");
ret = -1;
goto load_module_shlib_exit;
}
shlib->len_funcarray = numf;
shlib->numfunc = 0;
}
loader_data.shlibs[lib_idx].numfunc = 0;
for (int i = 0; i < numf; i++) {
farray[i].fptr = dlsym(lib_handle,farray[i].fname);
if (!farray[i].fptr) {
......@@ -215,9 +212,32 @@ int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *
ret = -1;
goto load_module_shlib_exit;
}
loader_data.shlibs[lib_idx].funcarray[i].fname=strdup(farray[i].fname);
loader_data.shlibs[lib_idx].funcarray[i].fptr = farray[i].fptr;
loader_data.shlibs[lib_idx].numfunc++;
/* check whether this function has been loaded before */
int j = 0;
for (; j < shlib->numfunc; ++j) {
if (shlib->funcarray[j].fptr == farray[i].fptr) {
int rc = strcmp(shlib->funcarray[i].fname, farray[i].fname);
AssertFatal(rc == 0,
"reloading the same fptr with different fnames (%s, %s)\n",
shlib->funcarray[i].fname, farray[i].fname);
break;
}
}
if (j == shlib->numfunc) {
if (shlib->numfunc == shlib->len_funcarray) {
loader_shlibfunc_t *n = realloc(shlib->funcarray, shlib->numfunc * 2 * sizeof(loader_shlibfunc_t));
if (!n) {
fprintf(stderr, "[LOADER] %s(): unable to allocate memory\n", __func__);
ret = -1;
goto load_module_shlib_exit;
}
shlib->funcarray = n;
shlib->len_funcarray = shlib->numfunc * 2;
}
shlib->funcarray[j].fname = strdup(farray[i].fname);
shlib->funcarray[j].fptr = farray[i].fptr;
shlib->numfunc++;
}
} /* for int i... */
} else { /* farray ! NULL */
sprintf(afname,"%s_getfarray",modname);
......@@ -248,3 +268,18 @@ void * get_shlibmodule_fptr(char *modname, char *fname)
} /* for i loop on modules */
return NULL;
}
void loader_reset()
{
for (int i = 0; i < loader_data.numshlibs && loader_data.shlibs[i].name != NULL; i++) {
loader_shlibdesc_t *shlib = &loader_data.shlibs[i];
free(shlib->name);
free(shlib->thisshlib_path);
for (int j = 0; j < shlib->numfunc; ++j)
free(shlib->funcarray[j].fname);
free(shlib->funcarray);
shlib->numfunc = 0;
shlib->len_funcarray = 0;
}
free(loader_data.shlibs);
}
......@@ -47,6 +47,7 @@ typedef struct {
char *thisshlib_path;
uint32_t numfunc;
loader_shlibfunc_t *funcarray;
uint32_t len_funcarray;
}loader_shlibdesc_t;
typedef struct {
......@@ -90,5 +91,6 @@ extern void * get_shlibmodule_fptr(char *modname, char *fname);
extern loader_data_t loader_data;
#endif /* LOAD_MODULE_SHLIB_MAIN */
#define load_module_shlib(M, F, N, I) load_module_version_shlib(M, NULL, F, N, I)
void loader_reset();
#endif
......@@ -169,8 +169,7 @@ MACRLCs = (
At the point of writing this document the control-plane exchanges between the CU and the DU over *F1-C* interface, as well as some IP traffic tests over *F1-U* have been validated using the OAI gNB/nrUE in RFSIMULATOR mode.
*These extensions are not yet fully integrated into develop branch, as they are under merge request. Until they get fully integrated, the CU/DU functionalities can be tested in [NR_F1C_F1U_extensions](https://gitlab.eurecom.fr/oai/openairinterface5g/-/tree/NR_F1C_F1U_extensions) branch.*
## 1.2 OAI 5G Core Network installation and configuration
The instructions for the installation of OAI CN components (AMF, SMF, NRF, UPF) using `docker-compose` can be found [here](https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed/-/blob/master/README.md).
......@@ -264,12 +263,12 @@ the gNB can be launched in 2 modes:
1. Launch the CU component:
```bash
sudo RFSIMULATOR=server ./nr-softmodem --rfsim --sa \
-O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/cu_gnb.conf
-O ../../../ci-scripts/conf_files/gNB_SA_CU.conf
```
2. Launch the DU component:
```bash
sudo RFSIMULATOR=server ./nr-softmodem --rfsim --sa \
-O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/du_gnb.conf
-O ../../../ci-scripts/conf_files/gNB_SA_DU.conf
```
- To launch the OAI UE (valid in `monolithic` gNB and `CU/DU split` gNB):
......
......@@ -31,11 +31,14 @@ RUN rm -Rf /oai-ran
WORKDIR /oai-ran
COPY . .
#only install address sanitizer for this container, the others don't need it
RUN yum install -y libasan
#run build_oai to build the target image
RUN /bin/sh oaienv && \
cd cmake_targets && \
mkdir -p log && \
./build_oai --phy_simulators --ninja --verbose-ci
./build_oai --phy_simulators --ninja --verbose-ci --sanitize-address
#start from scratch for target executable
FROM registry.access.redhat.com/ubi8/ubi:latest as oai-physim
......@@ -85,6 +88,7 @@ COPY --from=phy-sim-build \
/lib64/liblapack.so.3 \
/lib64/libexslt.so.0 \
/lib64/libxslt.so.1 \
/usr/lib64/libasan.so.5 \
/oai-ran/cmake_targets/ran_build/build/libdfts.so \
/oai-ran/cmake_targets/ran_build/build/libSIMU.so \
/oai-ran/cmake_targets/ran_build/build/libldpc.so \
......
......@@ -593,6 +593,7 @@ void init_pdcp(void) {
if (!get_softmodem_params()->nsa) {
if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) {
pdcp_layer_init();
nr_pdcp_module_init(pdcp_initmask, 0);
}
} else {
......
......@@ -168,10 +168,10 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
}
// initialize all signal buffers
init_nr_ue_signal(ue, nb_connected_gNB, abstraction_flag);
init_nr_ue_signal(ue, nb_connected_gNB);
// intialize transport
init_nr_ue_transport(ue, abstraction_flag);
init_nr_ue_transport(ue);
// init N_TA offset
init_N_TA_offset(ue);
......
......@@ -25,6 +25,7 @@
#include <string.h>
#include "assertions.h"
#include "SIMULATION/TOOLS/sim.h"
#include "common/utils/load_module_shlib.h"
#include "PHY/CODING/nrLDPC_extern.h"
//#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
#include "openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h"
......@@ -118,15 +119,13 @@ int test_ldpc(short No_iteration,
//short test_input[block_length];
unsigned char *test_input[MAX_NUM_NR_DLSCH_SEGMENTS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};;
//short *c; //padded codeword
unsigned char *estimated_output[MAX_NUM_DLSCH_SEGMENTS];
unsigned char *estimated_output_bit[MAX_NUM_DLSCH_SEGMENTS];
unsigned char *test_input_bit;
unsigned char estimated_output[MAX_NUM_DLSCH_SEGMENTS][block_length];
memset(estimated_output, 0, sizeof(estimated_output));
unsigned char *channel_input[MAX_NUM_DLSCH_SEGMENTS];
unsigned char *channel_output_uncoded[MAX_NUM_DLSCH_SEGMENTS];
unsigned char *channel_input_optim[MAX_NUM_DLSCH_SEGMENTS];
double *channel_output;
double *modulated_input[MAX_NUM_DLSCH_SEGMENTS];
char *channel_output_fixed[MAX_NUM_DLSCH_SEGMENTS];
//double channel_output[68 * 384];
double modulated_input[MAX_NUM_DLSCH_SEGMENTS][68 * 384] = { 0 };
char channel_output_fixed[MAX_NUM_DLSCH_SEGMENTS][68 * 384] = { 0 };
unsigned int i,j,trial=0;
short BG=0,nrows=0;//,ncols;
int no_punctured_columns,removed_bit;
......@@ -155,24 +154,12 @@ int test_ldpc(short No_iteration,
// generate input block
for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
test_input[j]=(unsigned char *)malloc16(sizeof(unsigned char) * block_length/8);
memset(test_input[j], 0, sizeof(unsigned char) * block_length / 8);
channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
memset(channel_input[j], 0, sizeof(unsigned char) * 68 * 384);
channel_input_optim[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
channel_output_uncoded[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
estimated_output[j] = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
estimated_output_bit[j] = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
modulated_input[j] = (double *)malloc16(sizeof(double) * 68*384);
channel_output_fixed[j] = (char *)malloc16(sizeof( char) * 68*384);
memset(channel_input_optim[j], 0, sizeof(unsigned char) * 68 * 384);
}
//modulated_input = (double *)malloc(sizeof(double) * 68*384);
//channel_output = (double *)malloc(sizeof(double) * 68*384);
//channel_output_fixed = (char *)malloc16(sizeof(char) * 68*384);
//modulated_input = (double *)calloc(68*384, sizeof(double));
channel_output = (double *)calloc(68*384, sizeof(double));
//channel_output_fixed = (double *)calloc(68*384, sizeof(double));
//channel_output_fixed = (unsigned char*)calloc(68*384, sizeof(unsigned char*));
//estimated_output = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);///8);
//estimated_output_bit = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
test_input_bit = (unsigned char*) malloc16(sizeof(unsigned char) * block_length);
reset_meas(&time);
reset_meas(time_optim);
......@@ -319,7 +306,6 @@ int test_ldpc(short No_iteration,
for (i = 0; i < block_length+(nrows-no_punctured_columns) * Zc - removed_bit; i++)
if (channel_input[j][i]!=channel_input_optim[j][i]) {
printf("differ in seg %u pos %u (%u,%u)\n", j, i, channel_input[j][i], channel_input_optim[j][i]);
free(channel_output);
return (-1);
}
//else{
......@@ -367,12 +353,9 @@ int test_ldpc(short No_iteration,
//channel_output_fixed[i] = (char)quantize(1,channel_output_fixed[i],qbits);
//Uncoded BER
if (channel_output_fixed[j][i]<0)
channel_output_uncoded[j][i]=1; //QPSK demod
else
channel_output_uncoded[j][i]=0;
unsigned char channel_output_uncoded = channel_output_fixed[j][i]<0 ? 1 /* QPSK demod */ : 0;
if (channel_output_uncoded[j][i] != channel_input_optim[j][i-2*Zc])
if (channel_output_uncoded != channel_input_optim[j][i-2*Zc])
*errors_bit_uncoded = (*errors_bit_uncoded) + 1;
}
......@@ -423,12 +406,10 @@ int test_ldpc(short No_iteration,
for (i=0; i<block_length; i++)
{
estimated_output_bit[j][i] = (estimated_output[j][i/8]&(1<<(i&7)))>>(i&7);
test_input_bit[i] = (test_input[j][i/8]&(1<<(i&7)))>>(i&7); // Further correct for multiple segments
if (estimated_output_bit[j][i] != test_input_bit[i])
{
unsigned char estoutputbit = (estimated_output[j][i/8]&(1<<(i&7)))>>(i&7);
unsigned char inputbit = (test_input[j][i/8]&(1<<(i&7)))>>(i&7); // Further correct for multiple segments
if (estoutputbit != inputbit)
*errors_bit = (*errors_bit) + 1;
}
}
//if (*errors == 1000)
......@@ -460,17 +441,8 @@ int test_ldpc(short No_iteration,
for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
free(test_input[j]);
free(channel_input[j]);
free(channel_output_uncoded[j]);
free(channel_input_optim[j]);
free(modulated_input[j]);
free(channel_output_fixed[j]);
free(estimated_output[j]);
free(estimated_output_bit[j]);
}
//free(modulated_input);
free(channel_output);
//free(channel_output_fixed);
//free(estimated_output);
nrLDPC_free_mem(p_nrLDPC_procBuf);
......@@ -728,5 +700,8 @@ int main(int argc, char *argv[])
}
fclose(fd);
loader_reset();
logTerm();
return(0);
}
......@@ -20,7 +20,7 @@
int main(int argc, char *argv[])
{
//Default simulation values (Aim for iterations = 1000000.)
//Default simulation values (Aim for iterations = 1000000.)
int decoder_int16=0;
int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, 2=UCI
double SNRstart = -20.0, SNRstop = 0.0, SNRinc= 0.5; //dB
......@@ -158,20 +158,25 @@ if (logFlag){
#endif
}
uint8_t testArrayLength = ceil(testLength / 32.0);
uint8_t coderArrayLength = ceil(coderLength / 32.0);
uint32_t testInput[testArrayLength]; //generate randomly
const uint8_t testArrayLength = ceil(testLength / 32.0);
const uint8_t coderArrayLength = ceil(coderLength / 32.0);
// in the polar code, often uint64_t arrays are used, but we work with
// uint32_t arrays below, so realArrayLength is the length that always
// satisfies uint64_t array length
const uint8_t realArrayLength = ((testArrayLength + 1) / 2) * 2;
printf("testArrayLength %d realArrayLength %d\n", testArrayLength, realArrayLength);
uint32_t testInput[realArrayLength]; //generate randomly
uint32_t encoderOutput[coderArrayLength];
uint32_t estimatedOutput[testArrayLength]; //decoder output
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
uint32_t estimatedOutput[realArrayLength]; //decoder output
memset(testInput,0,sizeof(uint32_t) * realArrayLength); // does not reset all
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength);
memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength);
uint8_t encoderOutputByte[coderLength];
double modulatedInput[coderLength]; //channel input
double channelOutput[coderLength]; //add noise
int16_t channelOutput_int16[coderLength];
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, 1, NULL);
t_nrPolar_params *currentPtr = nr_polar_params(polarMessageType, testLength, aggregation_level, true);
#ifdef DEBUG_DCI_POLAR_PARAMS
uint32_t dci_pdu[4];
......@@ -206,7 +211,8 @@ if (logFlag){
modulated_input[i]=(-1)/sqrt(2);
channel_output[i] = modulated_input[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
}
decoderState = polar_decoder_dci(channel_output, dci_est, currentPtrDCI, NR_POLAR_DECODER_LISTSIZE, rnti);
decoderState = polar_decoder_dci(channel_output, dci_est, NR_POLAR_DECODER_LISTSIZE, rnti,
1, size, aggregation_level);
printf("dci_est: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", dci_est[0], dci_est[1], dci_est[2], dci_est[3]);
free(encoder_outputByte);
free(channel_output);
......@@ -239,13 +245,13 @@ if (logFlag){
start_meas(&timeEncoder);
if (decoder_int16==1) {
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, currentPtr);
polar_encoder_fast((uint64_t *)testInput, encoderOutput, 0, 0, polarMessageType, testLength, aggregation_level);
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0,0,currentPtr);
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
if (polarMessageType == 0)
polar_encoder(testInput, encoderOutput, currentPtr);
polar_encoder(testInput, encoderOutput, polarMessageType, testLength, aggregation_level);
else if (polarMessageType == 1)
polar_encoder_dci(testInput, encoderOutput, currentPtr, rnti);
polar_encoder_dci(testInput, encoderOutput, rnti, polarMessageType, testLength, aggregation_level);
}
stop_meas(&timeEncoder);
......@@ -276,19 +282,20 @@ if (logFlag){
start_meas(&timeDecoder);
if (decoder_int16==1) {
decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0, currentPtr);
decoderState = polar_decoder_int16(channelOutput_int16, (uint64_t *)estimatedOutput, 0,
polarMessageType, testLength, aggregation_level);
} else { //0 --> PBCH, 1 --> DCI, -1 --> UCI
if (polarMessageType == 0) {
decoderState = polar_decoder(channelOutput,
estimatedOutput,
currentPtr,
decoderListSize);
decoderState = polar_decoder(channelOutput,
estimatedOutput,
decoderListSize,
polarMessageType, testLength, aggregation_level);
} else if (polarMessageType == 1) {
decoderState = polar_decoder_dci(channelOutput,
estimatedOutput,
currentPtr,
decoderListSize,
rnti);
decoderState = polar_decoder_dci(channelOutput,
estimatedOutput,
decoderListSize,
rnti,
polarMessageType, testLength, aggregation_level);
}
}
stop_meas(&timeDecoder);
......@@ -334,9 +341,9 @@ if (logFlag){
decoderState=0;
nBitError=0;
blockErrorState=0;
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
memset(testInput,0,sizeof(uint32_t) * realArrayLength);
memset(encoderOutput,0,sizeof(uint32_t) * coderArrayLength);
memset(estimatedOutput,0,sizeof(uint32_t) * testArrayLength);
memset(estimatedOutput,0,sizeof(uint32_t) * realArrayLength);
}
//Calculate error statistics for the SNR.
......
......@@ -29,12 +29,13 @@ uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){
uint8_t crcPolynomialSize = 24;
uint8_t temp1[crcPolynomialSize], temp2[crcPolynomialSize];
uint8_t **crc_generator_matrix = malloc(payloadSizeBits * sizeof(uint8_t *));
uint8_t **crc_generator_matrix = malloc(payloadSizeBits*sizeof(uint8_t *) + payloadSizeBits*crcPolynomialSize*sizeof(uint8_t));
if (crc_generator_matrix)
for (int i = 0; i < payloadSizeBits; i++)
crc_generator_matrix[i] = malloc(crcPolynomialSize * sizeof(uint8_t));
crc_generator_matrix[i] = ((uint8_t*)&crc_generator_matrix[payloadSizeBits])+i*crcPolynomialSize;
for (int i = 0; i < crcPolynomialSize; i++) crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1];
for (int i = 0; i < crcPolynomialSize; i++)
crc_generator_matrix[payloadSizeBits-1][i]=crcPolynomialPattern[i+1];
for (int i = payloadSizeBits-2; i >= 0; i--){
for (int j = 0; j < crcPolynomialSize-1; j++) temp1[j]=crc_generator_matrix[i+1][j+1];
......
......@@ -36,63 +36,86 @@
//#define DEBUG_NEW_IMPL 1
void updateLLR(double ***llr,
uint8_t **llrU,
uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen)
static inline void updateBit(uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen,
int zlen,
uint8_t bit[xlen][ylen][zlen],
uint8_t bitU[xlen][ylen])
{
uint16_t offset = (xlen/(pow(2,(ylen-col-1))));
uint16_t offset = ( xlen/(pow(2,(ylen-col))) );
for (uint8_t i=0; i<listSize; i++) {
if (( (row) % (2*offset) ) >= offset ) {
if(bitU[row-offset][col]==0) updateBit(bit, bitU, listSize, (row-offset), col, xlen, ylen);
if(llrU[row-offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row-offset), (col+1), xlen, ylen);
if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen);
llr[row][col][i] = (pow((-1),bit[row-offset][col][i])*llr[row-offset][col+1][i]) + llr[row][col+1][i];
if (bitU[row][col-1]==0) updateBit(listSize, row, (col-1), xlen, ylen, zlen, bit, bitU);
bit[row][col][i] = bit[row][col-1][i];
} else {
if(llrU[row][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, row, (col+1), xlen, ylen);
if(llrU[row+offset][col+1]==0) updateLLR(llr, llrU, bit, bitU, listSize, (row+offset), (col+1), xlen, ylen);
computeLLR(llr, row, col, i, offset);
if (bitU[row][col-1]==0) updateBit(listSize, row, (col-1), xlen, ylen, zlen, bit, bitU);
if (bitU[row+offset][col-1]==0) updateBit(listSize, (row+offset), (col-1), xlen, ylen, zlen, bit, bitU);
bit[row][col][i] = ( (bit[row][col-1][i]+bit[row+offset][col-1][i]) % 2);
}
}
llrU[row][col]=1;
// printf("LLR (a %f, b %f): llr[%d][%d] %f\n",32*a,32*b,col,row,32*llr[col][row]);
bitU[row][col]=1;
}
void updateBit(uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen)
static inline void computeLLR(uint16_t row,
uint16_t col,
uint8_t i,
uint16_t offset,
int xlen,
int ylen,
int zlen,
double llr[xlen][ylen][zlen])
{
uint16_t offset = ( xlen/(pow(2,(ylen-col))) );
double a = llr[row][col + 1][i];
double b = llr[row + offset][col + 1][i];
llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); //eq. (8a)
}
void updateLLR(uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen,
int zlen,
double llr[xlen][ylen][zlen],
uint8_t llrU[xlen][ylen],
uint8_t bit[xlen][ylen][zlen],
uint8_t bitU[xlen][ylen]
)
{
uint16_t offset = (xlen/(pow(2,(ylen-col-1))));
for (uint8_t i=0; i<listSize; i++) {
if (( (row) % (2*offset) ) >= offset ) {
if (bitU[row][col-1]==0) updateBit(bit, bitU, listSize, row, (col-1), xlen, ylen);
bit[row][col][i] = bit[row][col-1][i];
if(bitU[row-offset][col]==0) updateBit(listSize, (row-offset), col, xlen, ylen, zlen, bit, bitU);
if(llrU[row-offset][col+1]==0) updateLLR(listSize, (row-offset), (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU );
if(llrU[row][col+1]==0) updateLLR(listSize, row, (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU);
llr[row][col][i] = (pow((-1),bit[row-offset][col][i])*llr[row-offset][col+1][i]) + llr[row][col+1][i];
} else {
if (bitU[row][col-1]==0) updateBit(bit, bitU, listSize, row, (col-1), xlen, ylen);
if (bitU[row+offset][col-1]==0) updateBit(bit, bitU, listSize, (row+offset), (col-1), xlen, ylen);
bit[row][col][i] = ( (bit[row][col-1][i]+bit[row+offset][col-1][i]) % 2);
if(llrU[row][col+1]==0) updateLLR(listSize, row, (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU );
if(llrU[row+offset][col+1]==0) updateLLR(listSize, (row+offset), (col+1), xlen, ylen, zlen, llr, llrU, bit, bitU );
computeLLR(row, col, i, offset, xlen, ylen, zlen, llr);
}
}
llrU[row][col]=1;
bitU[row][col]=1;
// printf("LLR (a %f, b %f): llr[%d][%d] %f\n",32*a,32*b,col,row,32*llr[col][row]);
}
void updatePathMetric(double *pathMetric,
double ***llr,
uint8_t listSize,
uint8_t bitValue,
uint16_t row)
uint8_t listSize,
uint8_t bitValue,
uint16_t row,
int xlen,
int ylen,
int zlen,
double llr[xlen][ylen][zlen]
)
{
int8_t multiplier = (2*bitValue) - 1;
for (uint8_t i=0; i<listSize; i++)
......@@ -101,11 +124,14 @@ void updatePathMetric(double *pathMetric,
}
void updatePathMetric2(double *pathMetric,
double ***llr,
uint8_t listSize,
uint16_t row)
uint8_t listSize,
uint16_t row,
int xlen,
int ylen,
int zlen,
double llr[xlen][ylen][zlen])
{
double *tempPM = malloc(sizeof(double) * listSize);
double tempPM[listSize];
memcpy(tempPM, pathMetric, (sizeof(double) * listSize));
uint8_t bitValue = 0;
......@@ -118,48 +144,8 @@ void updatePathMetric2(double *pathMetric,
for (uint8_t i = listSize; i < 2*listSize; i++)
pathMetric[i] = tempPM[(i-listSize)] + log(1 + exp(multiplier * llr[row][0][(i-listSize)])); //eq. (11b)
free(tempPM);
}
void computeLLR(double ***llr,
uint16_t row,
uint16_t col,
uint8_t i,
uint16_t offset)
{
double a = llr[row][col + 1][i];
double b = llr[row + offset][col + 1][i];
llr[row][col][i] = log((exp(a + b) + 1) / (exp(a) + exp(b))); //eq. (8a)
}
void updateCrcChecksum(uint8_t **crcChecksum,
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len)
{
for (uint8_t i = 0; i < listSize; i++) {
for (uint8_t j = 0; j < len; j++) {
crcChecksum[j][i] = ( (crcChecksum[j][i] + crcGen[i2][j]) % 2 );
}
}
}
void updateCrcChecksum2(uint8_t **crcChecksum,
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len)
{
for (uint8_t i = 0; i < listSize; i++) {
for (uint8_t j = 0; j < len; j++) {
crcChecksum[j][i+listSize] = ( (crcChecksum[j][i] + crcGen[i2][j]) % 2 );
}
}
}
decoder_node_t *new_decoder_node(int first_leaf_index, int level) {
decoder_node_t *node=(decoder_node_t *)malloc(sizeof(decoder_node_t));
......@@ -222,6 +208,23 @@ decoder_node_t *add_nodes(int level, int first_leaf_index, t_nrPolar_params *pol
return(new_node);
}
void delete_nodes(decoder_node_t * n) {
if (n) {
if(n->left)
delete_nodes(n->left);
if(n->right)
delete_nodes(n->right);
free(n->alpha);
free(n->beta);
free(n);
}
}
void delete_decoder_tree(t_nrPolar_params *polarParams) {
if (polarParams->tree.root)
delete_nodes(polarParams->tree.root);
}
void build_decoder_tree(t_nrPolar_params *polarParams)
{
polarParams->tree.num_nodes=0;
......
......@@ -79,9 +79,10 @@ typedef struct decoder_tree_t_s {
struct nrPolar_params {
//messageType: 0=PBCH, 1=DCI, -1=UCI
int idx; //idx = (messageType * messageLength * aggregation_prime);
struct nrPolar_params *nextPtr;
struct nrPolar_params *nextPtr __attribute__((aligned(16)));
bool busy;
uint32_t idx;
uint8_t n_max;
uint8_t i_il;
uint8_t i_seg;
......@@ -138,34 +139,46 @@ typedef struct nrPolar_params t_nrPolar_params;
void polar_encoder(uint32_t *input,
uint32_t *output,
const t_nrPolar_params *polarParams);
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
void polar_encoder_dci(uint32_t *in,
uint32_t *out,
const t_nrPolar_params *polarParams,
uint16_t n_RNTI);
uint16_t n_RNTI,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
void polar_encoder_fast(uint64_t *A,
void *out,
int32_t crcmask,
uint8_t ones_flag,
const t_nrPolar_params *polarParams);
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
int8_t polar_decoder(double *input,
uint32_t *output,
const t_nrPolar_params *polarParams,
uint8_t listSize);
uint8_t listSize,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
uint32_t polar_decoder_int16(int16_t *input,
uint64_t *out,
uint8_t ones_flag,
const t_nrPolar_params *polarParams);
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
int8_t polar_decoder_dci(double *input,
uint32_t *out,
const t_nrPolar_params *polarParams,
uint8_t listSize,
uint16_t n_RNTI);
uint16_t n_RNTI,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
void generic_polar_decoder(const t_nrPolar_params *pp,
decoder_node_t *node);
......@@ -183,13 +196,12 @@ void build_decoder_tree(t_nrPolar_params *pp);
void build_polar_tables(t_nrPolar_params *polarParams);
void init_polar_deinterleaver_table(t_nrPolar_params *polarParams);
void nr_polar_print_polarParams(t_nrPolar_params *polarParams);
void nr_polar_print_polarParams(void);
t_nrPolar_params *nr_polar_params (int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level,
int decoder_flag,
t_nrPolar_params **polarList_ext);
int decoder_flag);
uint16_t nr_polar_aggregation_prime (uint8_t aggregation_level);
......@@ -278,34 +290,6 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1,
uint16_t row,
uint16_t col);
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen,
uint16_t ylen,
uint16_t zlen);
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen,
uint16_t ylen);
double ***nr_alloc_double_3D_array(uint16_t xlen,
uint16_t ylen,
uint16_t zlen);
double **nr_alloc_double_2D_array(uint16_t xlen,
uint16_t ylen);
void nr_free_double_3D_array(double ***input,
uint16_t xlen,
uint16_t ylen);
void nr_free_double_2D_array(double **input,
uint16_t xlen);
void nr_free_uint8_3D_array(uint8_t ***input,
uint16_t xlen,
uint16_t ylen);
void nr_free_uint8_2D_array(uint8_t **input,
uint16_t xlen);
void nr_sort_asc_double_1D_array_ind(double *matrix,
uint8_t *ind,
uint8_t len);
......@@ -316,52 +300,33 @@ void nr_sort_asc_int16_1D_array_ind(int32_t *matrix,
void nr_free_double_2D_array(double **input, uint16_t xlen);
void updateLLR(double ***llr,
uint8_t **llrU,
uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen);
void updateBit(uint8_t ***bit,
uint8_t **bitU,
uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen);
void updateLLR(uint8_t listSize,
uint16_t row,
uint16_t col,
uint16_t xlen,
uint8_t ylen,
int zlen,
double llr[xlen][ylen][zlen],
uint8_t llrU[xlen][ylen],
uint8_t bit[xlen][ylen][zlen],
uint8_t bitU[xlen][ylen]
);
void updatePathMetric(double *pathMetric,
double ***llr,
uint8_t listSize,
uint8_t bitValue,
uint16_t row);
uint8_t listSize,
uint8_t bitValue,
uint16_t row,
int xlen,
int ylen,
int zlen,
double llr[xlen][ylen][zlen]
);
void updatePathMetric2(double *pathMetric,
double ***llr,
uint8_t listSize,
uint16_t row);
void computeLLR(double ***llr,
uint16_t row,
uint16_t col,
uint8_t i,
uint16_t offset);
void updateCrcChecksum(uint8_t **crcChecksum,
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len);
void updateCrcChecksum2(uint8_t **crcChecksum,
uint8_t **crcGen,
uint8_t listSize,
uint32_t i2,
uint8_t len);
uint8_t listSize,
uint16_t row,
int xlen,
int ylen,
int zlen,
double llr[xlen][ylen][zlen]);
//Also nr_polar_rate_matcher
static inline void nr_polar_interleaver(uint8_t *input,
......@@ -379,5 +344,13 @@ static inline void nr_polar_deinterleaver(uint8_t *input,
{
for (int i=0; i<size; i++) output[pattern[i]]=input[i];
}
void delete_decoder_tree(t_nrPolar_params *);
extern pthread_mutex_t PolarListMutex;
#define polarReturn \
pthread_mutex_lock(&PolarListMutex); \
polarParams->busy=false; \
pthread_mutex_unlock(&PolarListMutex); \
return
#endif
......@@ -43,7 +43,10 @@
void polar_encoder(uint32_t *in,
uint32_t *out,
const t_nrPolar_params *polarParams) {
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level) {
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
if (1) {//polarParams->idx == 0 || polarParams->idx == 1) { //PBCH or PDCCH
/*
uint64_t B = (((uint64_t)*in)&((((uint64_t)1)<<32)-1)) | (((uint64_t)crc24c((uint8_t*)in,polarParams->payloadBits)>>8)<<polarParams->payloadBits);
......@@ -57,10 +60,10 @@ void polar_encoder(uint32_t *in,
*/
//Calculate CRC.
nr_matrix_multiplication_uint8_1D_uint8_2D(polarParams->nr_polar_A,
polarParams->crc_generator_matrix,
polarParams->nr_polar_crc,
polarParams->payloadBits,
polarParams->crcParityBits);
polarParams->crc_generator_matrix,
polarParams->nr_polar_crc,
polarParams->payloadBits,
polarParams->crcParityBits);
for (uint8_t i = 0; i < polarParams->crcParityBits; i++)
polarParams->nr_polar_crc[i] = (polarParams->nr_polar_crc[i] % 2);
......@@ -150,12 +153,19 @@ void polar_encoder(uint32_t *in,
#endif
nr_byte2bit_uint8_32(polarParams->nr_polar_E, polarParams->encoderLength, out);
polarReturn;
}
void polar_encoder_dci(uint32_t *in,
uint32_t *out,
const t_nrPolar_params *polarParams,
uint16_t n_RNTI) {
uint16_t n_RNTI,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level) {
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
#ifdef DEBUG_POLAR_ENCODER_DCI
printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]);
#endif
......@@ -249,6 +259,7 @@ void polar_encoder_dci(uint32_t *in,
printf("\n[polar_encoder_dci] out: ");
for (int i = 0; i < outputInd; i++) printf("[%d]->0x%08x\t", i, out[i]);
#endif
polarReturn;
}
static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void *in,void *out) __attribute__((always_inline));
......@@ -334,7 +345,7 @@ void build_polar_tables(t_nrPolar_params *polarParams) {
AssertFatal(polarParams->N==512 || polarParams->N==256 || polarParams->N==128,"N = %d, not done yet\n",polarParams->N);
// build G bit vectors for information bit positions and convert the bit as bytes tables in nr_polar_kronecker_power_matrices.c to 64 bit packed vectors.
// keep only rows of G which correspond to information/crc bits
polarParams->G_N_tab = (uint64_t **)malloc((polarParams->K + polarParams->n_pc) * sizeof(int64_t *));
polarParams->G_N_tab = (uint64_t **)calloc((polarParams->K + polarParams->n_pc),sizeof(int64_t *));
int k=0;
for (int i=0; i<polarParams->N; i++) {
......@@ -418,11 +429,14 @@ void polar_encoder_fast(uint64_t *A,
void *out,
int32_t crcmask,
uint8_t ones_flag,
const t_nrPolar_params *polarParams) {
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level) {
t_nrPolar_params *polarParams=nr_polar_params(messageType, messageLength, aggregation_level, false);
// AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K);
AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K);
AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits);
uint64_t B[4]= {0,0,0,0},Cprime[4]= {0,0,0,0};
int bitlen = polarParams->payloadBits;
// append crc
AssertFatal(bitlen<129,"support for payloads <= 128 bits\n");
......@@ -451,9 +465,12 @@ void polar_encoder_fast(uint64_t *A,
A32_flip[1+offset]=((uint8_t *)&Aprime)[2];
A32_flip[2+offset]=((uint8_t *)&Aprime)[1];
A32_flip[3+offset]=((uint8_t *)&Aprime)[0];
if (polarParams->crcParityBits == 24) tcrc = (uint64_t)(((crcmask^(crc24c(A32_flip,8*offset+bitlen)>>8)))&0xffffff);
else if (polarParams->crcParityBits == 11) tcrc = (uint64_t)(((crcmask^(crc11(A32_flip,bitlen)>>21)))&0x7ff);
else if (polarParams->crcParityBits == 6) tcrc = (uint64_t)(((crcmask^(crc6(A32_flip,bitlen)>>26)))&0x3f);
if (polarParams->crcParityBits == 24)
tcrc = (uint64_t)(((crcmask^(crc24c(A32_flip,8*offset+bitlen)>>8)))&0xffffff);
else if (polarParams->crcParityBits == 11)
tcrc = (uint64_t)(((crcmask^(crc11(A32_flip,bitlen)>>21)))&0x7ff);
else if (polarParams->crcParityBits == 6)
tcrc = (uint64_t)(((crcmask^(crc6(A32_flip,bitlen)>>26)))&0x3f);
} else if (bitlen<=64) {
uint8_t A64_flip[8+offset];
if (ones_flag) {
......@@ -470,8 +487,10 @@ void polar_encoder_fast(uint64_t *A,
A64_flip[5+offset]=((uint8_t *)&Aprime)[2];
A64_flip[6+offset]=((uint8_t *)&Aprime)[1];
A64_flip[7+offset]=((uint8_t *)&Aprime)[0];
if (polarParams->crcParityBits == 24) tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,8*offset+bitlen)>>8)))&0xffffff;
else if (polarParams->crcParityBits == 11) tcrc = (uint64_t)((crcmask^(crc11(A64_flip,bitlen)>>21)))&0x7ff;
if (polarParams->crcParityBits == 24)
tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,8*offset+bitlen)>>8)))&0xffffff;
else if (polarParams->crcParityBits == 11)
tcrc = (uint64_t)((crcmask^(crc11(A64_flip,bitlen)>>21)))&0x7ff;
}
else if (bitlen<=128) {
uint8_t A128_flip[16+offset];
......@@ -481,38 +500,37 @@ void polar_encoder_fast(uint64_t *A,
A128_flip[2] = 0xff;
}
uint128_t Aprime= (uint128_t)(((uint128_t)*A)<<(128-bitlen));
A128_flip[0+offset]=((uint8_t*)&Aprime)[15]; A128_flip[1+offset]=((uint8_t*)&Aprime)[14];
A128_flip[2+offset]=((uint8_t*)&Aprime)[13]; A128_flip[3+offset]=((uint8_t*)&Aprime)[12];
A128_flip[4+offset]=((uint8_t*)&Aprime)[11]; A128_flip[5+offset]=((uint8_t*)&Aprime)[10];
A128_flip[6+offset] =((uint8_t*)&Aprime)[9]; A128_flip[7+offset] =((uint8_t*)&Aprime)[8];
A128_flip[8+offset] =((uint8_t*)&Aprime)[7]; A128_flip[9+offset] =((uint8_t*)&Aprime)[6];
A128_flip[10+offset]=((uint8_t*)&Aprime)[5]; A128_flip[11+offset]=((uint8_t*)&Aprime)[4];
A128_flip[12+offset]=((uint8_t*)&Aprime)[3]; A128_flip[13+offset]=((uint8_t*)&Aprime)[2];
A128_flip[14+offset]=((uint8_t*)&Aprime)[1]; A128_flip[15+offset]=((uint8_t*)&Aprime)[0];
if (polarParams->crcParityBits == 24) tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,8*offset+bitlen)>>8)))&0xffffff;
else if (polarParams->crcParityBits == 11) tcrc = (uint64_t)((crcmask^(crc11(A128_flip,bitlen)>>21)))&0x7ff;
for (int i=0; i<16 ; i++)
A128_flip[i+offset]=((uint8_t*)&Aprime)[15-i];
if (polarParams->crcParityBits == 24)
tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,8*offset+bitlen)>>8)))&0xffffff;
else if (polarParams->crcParityBits == 11)
tcrc = (uint64_t)((crcmask^(crc11(A128_flip,bitlen)>>21)))&0x7ff;
}
int n;
// this is number of quadwords in the bit string
int quadwlen = (polarParams->K>>6);
if ((polarParams->K&63) > 0) quadwlen++;
int quadwlen = (polarParams->K+63)/64;
// Create the B bit string as
// 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, p_0, p_1, ..., p_{N_parity-1}
//??? b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0
for (n=0; n<quadwlen; n++) if (n==0) B[n] = (A[n] << polarParams->crcParityBits) | tcrc;
else B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits));
uint64_t B[4]= {0};
B[0] = (A[0] << polarParams->crcParityBits) | tcrc;
for (n=1; n<quadwlen; n++)
if ((bitlen+63)/64 > n)
B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits));
else
B[n] = (A[n-1]>>(64-polarParams->crcParityBits));
uint8_t *Bbyte = (uint8_t *)B;
// for each byte of B, lookup in corresponding table for 64-bit word corresponding to that byte and its position
uint64_t Cprime[4]= {0};
if (polarParams->K<65)
Cprime[0] = polarParams->cprime_tab0[0][Bbyte[0]] |
polarParams->cprime_tab0[1][Bbyte[1]] |
polarParams->cprime_tab0[1][Bbyte[1]] |
polarParams->cprime_tab0[2][Bbyte[2]] |
polarParams->cprime_tab0[3][Bbyte[3]] |
polarParams->cprime_tab0[4][Bbyte[4]] |
......@@ -684,4 +702,7 @@ void polar_encoder_fast(uint64_t *A,
}
memset((void*)out,0,polarParams->encoderLength>>3);
polar_rate_matching(polarParams,(void *)D, out);
polarReturn;
}
......@@ -43,163 +43,6 @@ void nr_matrix_multiplication_uint8_1D_uint8_2D(uint8_t *matrix1, uint8_t **matr
}
}
uint8_t ***nr_alloc_uint8_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
uint8_t ***output;
int i, j;
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
perror("[nr_alloc_uint8_3D_array] Problem at 1D allocation");
return NULL;
}
for (i = 0; i < xlen; i++)
output[i] = NULL;
for (i = 0; i < xlen; i++)
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
perror("[nr_alloc_uint8_3D_array] Problem at 2D allocation");
nr_free_uint8_3D_array(output, xlen, ylen);
return NULL;
}
for (i = 0; i < xlen; i++)
for (j = 0; j < ylen; j++)
output[i][j] = NULL;
for (i = 0; i < xlen; i++)
for (j = 0; j < ylen; j++)
if ((output[i][j] = malloc(zlen * sizeof *output[i][j])) == NULL) {
perror("[nr_alloc_uint8_3D_array] Problem at 3D allocation");
nr_free_uint8_3D_array(output, xlen, ylen);
return NULL;
}
return output;
}
uint8_t **nr_alloc_uint8_2D_array(uint16_t xlen, uint16_t ylen) {
uint8_t **output;
int i, j;
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
perror("[nr_alloc_uint8_2D_array] Problem at 1D allocation");
return NULL;
}
for (i = 0; i < xlen; i++)
output[i] = NULL;
for (i = 0; i < xlen; i++)
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
perror("[nr_alloc_uint8_2D_array] Problem at 2D allocation");
nr_free_uint8_2D_array(output, xlen);
return NULL;
}
for (i = 0; i < xlen; i++)
for (j = 0; j < ylen; j++)
output[i][j] = 0;
return output;
}
double ***nr_alloc_double_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen) {
double ***output;
int i, j;
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
perror("[nr_alloc_double_3D_array] Problem at 1D allocation");
return NULL;
}
for (i = 0; i < xlen; i++)
output[i] = NULL;
for (i = 0; i < xlen; i++)
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
perror("[nr_alloc_double_3D_array] Problem at 2D allocation");
nr_free_double_3D_array(output, xlen, ylen);
return NULL;
}
for (i = 0; i < xlen; i++)
for (j = 0; j < ylen; j++)
output[i][j] = NULL;
for (i = 0; i < xlen; i++)
for (j = 0; j < ylen; j++)
if ((output[i][j] = malloc(zlen * sizeof *output[i][j])) == NULL) {
perror("[nr_alloc_double_3D_array] Problem at 3D allocation");
nr_free_double_3D_array(output, xlen, ylen);
return NULL;
}
return output;
}
double **nr_alloc_double_2D_array(uint16_t xlen, uint16_t ylen) {
double **output;
int i, j;
if ((output = malloc(xlen * sizeof(*output))) == NULL) {
perror("[nr_alloc_double_3D_array] Problem at 1D allocation");
return NULL;
}
for (i = 0; i < xlen; i++)
output[i] = NULL;
for (i = 0; i < xlen; i++)
if ((output[i] = malloc(ylen * sizeof *output[i])) == NULL) {
perror("[nr_alloc_double_2D_array] Problem at 2D allocation");
nr_free_double_2D_array(output, xlen);
return NULL;
}
for (i = 0; i < xlen; i++)
for (j = 0; j < ylen; j++)
output[i][j] = 0;
return output;
}
void nr_free_double_3D_array(double ***input, uint16_t xlen, uint16_t ylen) {
int i, j;
for (i = 0; i < xlen; i++) {
for (j = 0; j < ylen; j++) {
free(input[i][j]);
}
free(input[i]);
}
free(input);
}
void nr_free_double_2D_array(double **input, uint16_t xlen) {
int i;
for (i = 0; i < xlen; i++) {
free(input[i]);
}
free(input);
}
void nr_free_uint8_3D_array(uint8_t ***input, uint16_t xlen, uint16_t ylen) {
int i, j;
for (i = 0; i < xlen; i++) {
for (j = 0; j < ylen; j++) {
free(input[i][j]);
}
free(input[i]);
}
free(input);
}
void nr_free_uint8_2D_array(uint8_t **input, uint16_t xlen) {
for (int i = 0; i < xlen; i++) free(input[i]);
free(input);
}
// Modified Bubble Sort.
void nr_sort_asc_double_1D_array_ind(double *matrix, uint8_t *ind, uint8_t len) {
int swaps;
......
This diff is collapsed.
......@@ -242,37 +242,9 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
common_vars->debugBuff = (int32_t*)malloc16_clear(fp->samples_per_frame*sizeof(int32_t)*100);
common_vars->debugBuff_sample_offset = 0;
// Channel estimates for SRS
/*
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
srs_vars[UE_id].srs_ch_estimates = (int32_t **)malloc16( 64*sizeof(int32_t *) );
srs_vars[UE_id].srs_ch_estimates_time = (int32_t **)malloc16( 64*sizeof(int32_t *) );
for (i=0; i<64; i++) {
srs_vars[UE_id].srs_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size );
srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->ofdm_symbol_size*2 );
}
} //UE_id
*/
/*generate_ul_ref_sigs_rx();
init_ulsch_power_LUT();*/
/*
// SRS
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
srs_vars[UE_id].srs = (int32_t *)malloc16_clear(2*fp->ofdm_symbol_size*sizeof(int32_t));
}
*/
// PRACH
prach_vars->prachF = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
prach_vars->rxsigF = (int16_t **)malloc16_clear(Prx*sizeof(int16_t*));
/*
for (i=0;i<Prx;i++){
prach_vars->rxsigF[i] = (int16_t *)malloc16_clear( 1024*2*sizeof(int16_t) );
}
*/
prach_vars->prach_ifft = (int32_t *)malloc16_clear(1024*2*sizeof(int32_t));
init_prach_list(gNB);
......@@ -339,52 +311,103 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
{
NR_DL_FRAME_PARMS* const fp = &gNB->frame_parms;
NR_gNB_COMMON *const common_vars = &gNB->common_vars;
NR_gNB_PUSCH **const pusch_vars = gNB->pusch_vars;
/*LTE_eNB_SRS *const srs_vars = gNB->srs_vars;
LTE_eNB_PRACH *const prach_vars = &gNB->prach_vars;*/
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
int Ptx=gNB->gNB_config.carrier_config.num_tx_ant.value;
const int Ptx = gNB->gNB_config.carrier_config.num_tx_ant.value;
const int Prx = gNB->gNB_config.carrier_config.num_rx_ant.value;
const int max_ul_mimo_layers = 4; // taken from phy_init_nr_gNB()
const int n_buf = Prx * max_ul_mimo_layers;
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
free_and_zero(pdcch_dmrs[slot][symb]);
free_and_zero(pdcch_dmrs[slot]);
}
free_and_zero(pdcch_dmrs);
uint32_t ****pdsch_dmrs = gNB->nr_gold_pdsch_dmrs;
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++) {
for (int q = 0; q < NR_MAX_NB_CODEWORDS; q++)
free_and_zero(pdsch_dmrs[slot][symb][q]);
free_and_zero(pdsch_dmrs[slot][symb]);
}
free_and_zero(pdsch_dmrs[slot]);
}
free_and_zero(gNB->nr_gold_pdsch_dmrs);
uint32_t ****pusch_dmrs = gNB->nr_gold_pusch_dmrs;
for(int nscid = 0; nscid < 2; nscid++) {
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
free_and_zero(pusch_dmrs[nscid][slot][symb]);
free_and_zero(pusch_dmrs[nscid][slot]);
}
free_and_zero(pusch_dmrs[nscid]);
}
free_and_zero(pusch_dmrs);
uint32_t ***csi_rs = gNB->nr_gold_csi_rs;
for (int slot = 0; slot < fp->slots_per_frame; slot++) {
for (int symb = 0; symb < fp->symbols_per_slot; symb++)
free_and_zero(csi_rs[slot][symb]);
free_and_zero(csi_rs[slot]);
}
free_and_zero(csi_rs);
for (int id = 0; id < NUMBER_OF_NR_SRS_MAX; id++) {
for (int i = 0; i < Prx; i++){
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time[i]);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted[i]);
}
free_and_zero(gNB->nr_srs_info[id]->srs_generated_signal);
free_and_zero(gNB->nr_srs_info[id]->noise_power);
free_and_zero(gNB->nr_srs_info[id]->srs_received_signal);
free_and_zero(gNB->nr_srs_info[id]->srs_ls_estimated_channel);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_freq);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time);
free_and_zero(gNB->nr_srs_info[id]->srs_estimated_channel_time_shifted);
free_and_zero(gNB->nr_srs_info[id]);
}
free_ul_reference_signal_sequences();
free_gnb_lowpapr_sequences();
reset_nr_transport(gNB);
NR_gNB_COMMON * common_vars = &gNB->common_vars;
for (int i = 0; i < Ptx; i++) {
free_and_zero(common_vars->txdataF[i]);
/* rxdataF[i] is not allocated -> don't free */
free_and_zero(common_vars->beam_id[i]);
}
for (int i = 0; i < Prx; ++i) {
free_and_zero(common_vars->rxdataF[i]);
free_and_zero(common_vars->rxdata[i]);
}
free_and_zero(common_vars->txdataF);
free_and_zero(common_vars->rxdata);
free_and_zero(common_vars->rxdataF);
// PDCCH DMRS sequences
free_and_zero(pdcch_dmrs);
/*
// Channel estimates for SRS
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
for (i=0; i<64; i++) {
free_and_zero(srs_vars[UE_id].srs_ch_estimates[i]);
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time[i]);
}
free_and_zero(srs_vars[UE_id].srs_ch_estimates);
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time);
} //UE_id
free_and_zero(common_vars->beam_id);
//free_ul_ref_sigs();
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) free_and_zero(srs_vars[UE_id].srs);
free_and_zero(common_vars->debugBuff);
NR_gNB_PRACH* prach_vars = &gNB->prach_vars;
free_and_zero(prach_vars->prachF);
free_and_zero(prach_vars->rxsigF);
free_and_zero(prach_vars->prach_ifft);
for (i = 0; i < 64; i++) free_and_zero(prach_vars->prach_ifft[0][i]);
free_and_zero(prach_vars->prach_ifft[0]);
free_and_zero(prach_vars->rxsigF[0]);
*/
NR_gNB_PUSCH** pusch_vars = gNB->pusch_vars;
for (int ULSCH_id=0; ULSCH_id<gNB->number_of_nr_ulsch_max; ULSCH_id++) {
for (int i = 0; i < fp->nb_antennas_rx; i++) {
for (int i = 0; i < Prx; i++) {
free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]);
free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]);
free_and_zero(pusch_vars[ULSCH_id]->rho[i]);
}
for (int i = 0; i < 4*fp->nb_antennas_rx; i++) {
for (int i = 0; i < n_buf; i++) {
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates[i]);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext[i]);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time[i]);
......@@ -403,8 +426,8 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_ext);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_ptrs_estimates_ext);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time);
free_and_zero(pusch_vars[ULSCH_id]->ptrs_phase_per_slot);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_estimates_time);
free_and_zero(pusch_vars[ULSCH_id]->ul_valid_re_per_slot);
free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp);
free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag0);
......@@ -416,14 +439,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
free_and_zero(pusch_vars[ULSCH_id]->llr);
free_and_zero(pusch_vars[ULSCH_id]);
} //ULSCH_id
/*
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) gNB->UE_stats_ptr[UE_id] = NULL;
*/
free_gnb_lowpapr_sequences();
}
//Adding nr_schedule_handler
......@@ -564,6 +579,16 @@ void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg) {
}
}
void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg)
{
const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
const nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config;
const uint16_t grid_size = cfg->carrier_config.dl_grid_size[fp->numerology_index].value;
for (int i=0; i<gNB->number_of_nr_dlsch_max; i++)
for (int j=0; j<2; j++)
free_gNB_dlsch(&msg->dlsch[i][j], grid_size);
}
void init_nr_transport(PHY_VARS_gNB *gNB) {
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
LOG_I(PHY, "Initialise nr transport\n");
......@@ -588,7 +613,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
for (int j=0; j<2; j++) {
// ULSCH for data
gNB->ulsch[i][j] = new_gNB_ulsch(MAX_LDPC_ITERATIONS, fp->N_RB_UL, 0);
gNB->ulsch[i][j] = new_gNB_ulsch(MAX_LDPC_ITERATIONS, fp->N_RB_UL);
if (!gNB->ulsch[i][j]) {
LOG_E(PHY,"Can't get gNB ulsch structures\n");
......@@ -604,3 +629,18 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
//fp->pucch_config_common.deltaPUCCH_Shift = 1;
}
void reset_nr_transport(PHY_VARS_gNB *gNB)
{
const NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
for (int i = 0; i < NUMBER_OF_NR_PUCCH_MAX; i++)
free_gNB_pucch(gNB->pucch[i]);
for (int i = 0; i < NUMBER_OF_NR_SRS_MAX; i++)
free_gNB_srs(gNB->srs[i]);
for (int i=0; i<gNB->number_of_nr_ulsch_max; i++)
for (int j=0; j<2; j++)
free_gNB_ulsch(&gNB->ulsch[i][j], fp->N_RB_UL);
}
......@@ -174,17 +174,13 @@ void nr_phy_free_RU(RU_t *ru)
LOG_I(PHY, "Feeing RU signal buffers (if_south %s) nb_tx %d\n", ru_if_types[ru->if_south], ru->nb_tx);
free_and_zero(ru->nr_frame_parms);
free_and_zero(ru->frame_parms);
if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so free memory for time-domain signals
int32_t *ptr;
for (i = 0; i < ru->nb_tx; i++) {
ptr=&ru->common.txdata[i][-ru->sf_extension];
free_and_zero(ptr);
}
for (i = 0; i < ru->nb_rx; i++) free_and_zero(ru->common.rxdata[i]);
for (i = 0; i < ru->nb_tx; i++)
free_and_zero(ru->common.txdata[i]);
free_and_zero(ru->common.txdata);
for (i = 0; i < ru->nb_rx; i++)
free_and_zero(ru->common.rxdata[i]);
free_and_zero(ru->common.rxdata);
} // else: IF5 or local RF -> nothing to free()
......@@ -205,9 +201,9 @@ void nr_phy_free_RU(RU_t *ru)
free_and_zero(ru->common.rxdataF);
for (j=0;j<NUMBER_OF_NR_RU_PRACH_OCCASIONS_MAX;j++) {
for (i = 0; i < ru->nb_rx; i++) {
for (i = 0; i < ru->nb_rx; i++)
free_and_zero(ru->prach_rxsigF[j][i]);
}
free_and_zero(ru->prach_rxsigF[j]);
}
if (ru->do_precoding == 1) {
for (i = 0; i < ru->num_gNB; i++) {
......@@ -216,6 +212,9 @@ void nr_phy_free_RU(RU_t *ru)
free_and_zero(ru->beam_weights[i][p]);
}
}
for(i=0; i< ru->nb_tx; ++i)
free_and_zero(ru->common.beam_id[i]);
free_and_zero(ru->common.beam_id);
}
}
free_and_zero(ru->common.sync_corr);
......
This diff is collapsed.
......@@ -57,6 +57,7 @@ int l1_north_init_eNB(void);
int phy_init_top(LTE_DL_FRAME_PARMS *frame_parms);
void phy_init_nr_top(PHY_VARS_NR_UE *ue);
void phy_term_nr_top(void);
/*!
......@@ -395,8 +396,9 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp,uint8_t i_ssb);
int nr_init_frame_parms(nfapi_nr_config_request_scf_t *config, NR_DL_FRAME_PARMS *frame_parms);
int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms, fapi_nr_config_request_t *config, uint16_t nr_band);
void nr_init_frame_parms_ue_sa(NR_DL_FRAME_PARMS *frame_parms, uint64_t downlink_frequency, int32_t uplink_frequency_offset, uint8_t mu, uint16_t nr_band);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstraction_flag);
void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB);
void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB);
void init_nr_ue_transport(PHY_VARS_NR_UE *ue);
void init_N_TA_offset(PHY_VARS_NR_UE *ue);
void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms);
int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char lowmem_flag);
......@@ -405,11 +407,13 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,
void phy_free_nr_gNB(PHY_VARS_gNB *gNB);
int l1_north_init_gNB(void);
void init_nr_transport(PHY_VARS_gNB *gNB);
void reset_nr_transport(PHY_VARS_gNB *gNB);
void init_dfts(void);
void fill_subframe_mask(PHY_VARS_eNB *eNB);
void init_DLSCH_struct(PHY_VARS_gNB *gNB, processingData_L1tx_t *msg);
void reset_DLSCH_struct(const PHY_VARS_gNB *gNB, processingData_L1tx_t *msg);
/** @} */
#endif
......
......@@ -6481,7 +6481,7 @@ void dump_dlsch2(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t subframe,unsigned int *c
sprintf(fname,"dlsch%d_rxF_r%d_uespec0.m",eNB_id,round);
sprintf(vname,"dl%d_rxF_r%d_uespec0",eNB_id,round);
LOG_M(fname,vname,ue->pdsch_vars[ue->current_thread_id[subframe]][eNB_id]->rxdataF_uespec_pilots[0],
12*(ue->frame_parms.N_RB_DL)*NSYMB,1,1);
12*(ue->frame_parms.N_RB_DL),1,1);
/*
LOG_M("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*NSYMB,1,1);
LOG_M("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[eNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*NSYMB,1,1);
......
......@@ -122,23 +122,20 @@ int16_t *base_sequence_less_than_36(unsigned int M_ZC,
*********************************************************************/
int16_t get_index_for_dmrs_lowpapr_seq(int16_t num_dmrs_res) {
int16_t index = -1;
if (num_dmrs_res >= dmrs_ul_allocated_res[(MAX_INDEX_DMRS_UL_ALLOCATED_REs-1)])
int16_t index = num_dmrs_res/6 - 1;
if (index >= MAX_INDEX_DMRS_UL_ALLOCATED_REs)
index = MAX_INDEX_DMRS_UL_ALLOCATED_REs-1;
else
index = (num_dmrs_res/6) -1;
for (;index >= 0; index--) {
if (dmrs_ul_allocated_res[index] == num_dmrs_res)
break;
}
LOG_D(PHY, "num_dmrs_res: %d INDEX RETURNED: %d", num_dmrs_res, index);
return index;
LOG_D(PHY, "num_dmrs_res: %d INDEX RETURNED: %d", num_dmrs_res, index);
return index;
}
/*******************************************************************
......@@ -204,6 +201,11 @@ int16_t *base_sequence_36_or_larger(unsigned int Msc_RS,
void generate_lowpapr_typ1_refsig_sequences(unsigned int scaling)
{
/* prevent multiple calls, relevant when both UE & gNB initialize this */
static bool already_called = false;
if (already_called) return;
already_called = true;
unsigned int u,Msc_RS;
unsigned int v = 0; // sequence hopping and group hopping are not supported yet
......@@ -223,6 +225,11 @@ void generate_lowpapr_typ1_refsig_sequences(unsigned int scaling)
void generate_ul_reference_signal_sequences(unsigned int scaling)
{
/* prevent multiple calls, relevant when both UE & gNB initialize this */
static bool already_called = false;
if (already_called) return;
already_called = true;
unsigned int u,v,Msc_RS;
#if 0
......@@ -295,10 +302,10 @@ void free_ul_reference_signal_sequences(void)
for (u=0; u < U_GROUP_NUMBER; u++) {
for (v=0; v < V_BASE_SEQUENCE_NUMBER; v++) {
if (rv_ul_ref_sig[u][v][Msc_RS])
free16(rv_ul_ref_sig[u][v][Msc_RS],2*sizeof(int16_t)*ul_allocated_re[Msc_RS]);
free_and_zero(rv_ul_ref_sig[u][v][Msc_RS]);
if ((v==0) && (Msc_RS < MAX_INDEX_DMRS_UL_ALLOCATED_REs))
if (dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS])
free16(dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS],2*sizeof(int16_t)*dmrs_ul_allocated_res[Msc_RS]);
free_and_zero(dmrs_lowpaprtype1_ul_ref_sig[u][v][Msc_RS]);
}
}
}
......@@ -321,7 +328,7 @@ void free_gnb_lowpapr_sequences(void)
v=0;
for (u=0; u < U_GROUP_NUMBER; u++) {
if (gNB_dmrs_lowpaprtype1_sequence[u][v][Msc_RS])
free16(gNB_dmrs_lowpaprtype1_sequence[u][v][Msc_RS],2*sizeof(int16_t)*dmrs_ul_allocated_res[Msc_RS]);
free_and_zero(gNB_dmrs_lowpaprtype1_sequence[u][v][Msc_RS]);
}
}
}
......
......@@ -130,11 +130,8 @@ void nr_generate_dci(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15,
uint16_t Nid = dci_pdu->ScramblingId;
uint16_t scrambling_RNTI = dci_pdu->ScramblingRNTI;
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE,
dci_pdu->PayloadSizeBits,
dci_pdu->AggregationLevel,
0,NULL);
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI,1,currentPtr);
polar_encoder_fast((uint64_t*)dci_pdu->Payload, (void*)encoder_output, n_RNTI, 1,
NR_POLAR_DCI_MESSAGE_TYPE, dci_pdu->PayloadSizeBits, dci_pdu->AggregationLevel);
#ifdef DEBUG_CHANNEL_CODING
printf("polar rnti %x,length %d, L %d\n",n_RNTI, dci_pdu->PayloadSizeBits,pdcch_pdu_rel15->dci_pdu->AggregationLevel);
printf("DCI PDU: [0]->0x%lx \t [1]->0x%lx\n",
......
......@@ -55,42 +55,39 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) {
NR_gNB_DLSCH_t *dlsch = *dlschptr;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
if (dlsch) {
if (N_RB != 273) {
a_segments = a_segments*N_RB;
a_segments = a_segments/273 +1;
}
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY,"Freeing dlsch %p\n",dlsch);
#endif
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
if (harq->b) {
free16(harq->b, a_segments * 1056);
harq->b = NULL;
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY, "Freeing harq->b (%p)\n", harq->b);
#endif
}
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY, "Freeing dlsch process %d c (%p)\n", i, harq->c);
#endif
for (r = 0; r < a_segments; r++) {
#ifdef DEBUG_DLSCH_FREE
LOG_D(PHY, "Freeing dlsch process %d c[%d] (%p)\n", i, r, harq->c[r]);
#endif
if (harq->c[r]) {
free16(harq->c[r], 1056);
harq->c[r] = NULL;
}
}
free16(dlsch, sizeof(NR_gNB_DLSCH_t));
*dlschptr = NULL;
if (N_RB != 273) {
a_segments = a_segments*N_RB;
a_segments = a_segments/273 +1;
}
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
if (harq->b) {
free16(harq->b, a_segments * 1056);
harq->b = NULL;
}
for (r = 0; r < a_segments; r++) {
free(harq->c[r]);
harq->c[r] = NULL;
}
free(harq->pdu);
for (int aa = 0; aa < 64; aa++)
free(dlsch->calib_dl_ch_estimates[aa]);
free(dlsch->calib_dl_ch_estimates);
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
free(dlsch->mod_symbs[q]);
for (int layer = 0; layer < NR_MAX_NB_LAYERS; layer++) {
free(dlsch->txdataF_precoding[layer]);
free(dlsch->txdataF[layer]);
for (int aa = 0; aa < 64; aa++)
free(dlsch->ue_spec_bf_weights[layer][aa]);
free(dlsch->ue_spec_bf_weights[layer]);
}
free(dlsch);
*dlschptr = NULL;
}
NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
......
......@@ -299,8 +299,8 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
/// CRC, coding and rate matching
polar_encoder_fast (&a_reversed, (void*)pbch->pbch_e, 0, 0,
nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,0,NULL)
);
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
#ifdef DEBUG_PBCH_ENCODING
printf("Channel coding:\n");
......
......@@ -106,6 +106,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
uint8_t abstraction_flag,
uint16_t N_RB);
void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB);
/** \brief This function is the top-level entry point to PUSCH demodulation, after frequency-domain transformation and channel estimation. It performs
- RB extraction (signal and channel estimates)
- channel compensation (matched filtering)
......@@ -298,6 +300,7 @@ int16_t find_nr_prach(PHY_VARS_gNB *gNB,int frame,int slot, find_type_t type);
int16_t find_nr_prach_ru(RU_t *ru,int frame,int slot, find_type_t type);
NR_gNB_PUCCH_t *new_gNB_pucch(void);
void free_gNB_pucch(NR_gNB_PUCCH_t *pucch);
void nr_fill_pucch(PHY_VARS_gNB *gNB,
int frame,
......@@ -310,6 +313,7 @@ int nr_find_pucch(uint16_t rnti,
PHY_VARS_gNB *gNB);
NR_gNB_SRS_t *new_gNB_srs(void);
void free_gNB_srs(NR_gNB_SRS_t *srs);
int nr_find_srs(uint16_t rnti,
int frame,
......
......@@ -33,9 +33,9 @@
#include "PHY/defs_gNB.h"
#include "common/utils/threadPool/thread-pool.h"
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch,uint8_t N_RB_UL);
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulsch, uint16_t N_RB_UL);
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint8_t abstraction_flag);
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL);
/*! \brief Perform PUSCH decoding. TS 38.212 V15.4.0 subclause 6.2
......
......@@ -54,60 +54,40 @@
//extern double cpuf;
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr,uint8_t N_RB_UL)
void free_gNB_ulsch(NR_gNB_ULSCH_t **ulschptr, uint16_t N_RB_UL)
{
int i,r;
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
NR_gNB_ULSCH_t *ulsch = *ulschptr;
if (ulsch) {
if (N_RB_UL != 273) {
a_segments = a_segments*N_RB_UL;
a_segments = a_segments/273 +1;
}
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
if (N_RB_UL != 273) {
a_segments = a_segments*N_RB_UL;
a_segments = a_segments/273 +1;
}
if (ulsch->harq_processes[i]) {
if (ulsch->harq_processes[i]->b) {
free16(ulsch->harq_processes[i]->b,a_segments*1056);
ulsch->harq_processes[i]->b = NULL;
}
for (r=0; r<a_segments; r++) {
free16(ulsch->harq_processes[i]->c[r],(8448)*sizeof(uint8_t));
ulsch->harq_processes[i]->c[r] = NULL;
}
for (r=0; r<a_segments; r++) {
if (ulsch->harq_processes[i]->d[r]) {
free16(ulsch->harq_processes[i]->d[r],(68*384)*sizeof(int16_t));
ulsch->harq_processes[i]->d[r] = NULL;
}
}
for (r=0; r<a_segments; r++) {
if (ulsch->harq_processes[i]->w[r]) {
free16(ulsch->harq_processes[i]->w[r],(3*(6144+64))*sizeof(int16_t));
ulsch->harq_processes[i]->w[r] = NULL;
}
}
for (r=0; r<a_segments; r++) {
if (ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]){
nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
}
}
free16(ulsch->harq_processes[i],sizeof(NR_UL_gNB_HARQ_t));
ulsch->harq_processes[i] = NULL;
for (i=0; i<NR_MAX_ULSCH_HARQ_PROCESSES; i++) {
if (ulsch->harq_processes[i]) {
if (ulsch->harq_processes[i]->b) {
free_and_zero(ulsch->harq_processes[i]->b);
ulsch->harq_processes[i]->b = NULL;
}
for (r=0; r<a_segments; r++) {
free_and_zero(ulsch->harq_processes[i]->c[r]);
free_and_zero(ulsch->harq_processes[i]->d[r]);
free_and_zero(ulsch->harq_processes[i]->w[r]);
nrLDPC_free_mem(ulsch->harq_processes[i]->p_nrLDPC_procBuf[r]);
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = NULL;
}
free_and_zero(ulsch->harq_processes[i]);
ulsch->harq_processes[i] = NULL;
}
free16(ulsch,sizeof(NR_gNB_ULSCH_t));
*ulschptr = NULL;
}
free_and_zero(*ulschptr);
}
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint8_t abstraction_flag)
NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL)
{
NR_gNB_ULSCH_t *ulsch;
......@@ -129,13 +109,11 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint16_t N_RB_UL, uint
ulsch->harq_processes[i] = (NR_UL_gNB_HARQ_t *)malloc16_clear(sizeof(NR_UL_gNB_HARQ_t));
ulsch->harq_processes[i]->b = (uint8_t*)malloc16_clear(ulsch_bytes);
if (abstraction_flag == 0) {
for (r=0; r<a_segments; r++) {
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16_clear(8448*sizeof(uint8_t));
ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16_clear((68*384)*sizeof(int16_t));
ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16_clear((3*(6144+64))*sizeof(int16_t));
}
for (r=0; r<a_segments; r++) {
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16_clear(8448*sizeof(uint8_t));
ulsch->harq_processes[i]->d[r] = (int16_t*)malloc16_clear((68*384)*sizeof(int16_t));
ulsch->harq_processes[i]->w[r] = (int16_t*)malloc16_clear((3*(6144+64))*sizeof(int16_t));
}
}
......
......@@ -62,6 +62,11 @@ NR_gNB_PUCCH_t *new_gNB_pucch(void){
return (pucch);
}
void free_gNB_pucch(NR_gNB_PUCCH_t *pucch)
{
free_and_zero(pucch);
}
int nr_find_pucch(uint16_t rnti,
int frame,
int slot,
......@@ -1533,7 +1538,6 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
}
else { // polar coded case
t_nrPolar_params *currentPtr = nr_polar_params(2,nb_bit,pucch_pdu->prb_size,1,&gNB->uci_polarParams);
__m64 *rp_re[Prx2][2];
__m64 *rp2_re[Prx2][2];
__m64 *rp_im[Prx2][2];
......@@ -1660,7 +1664,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
} // half_prb
} // symb
// run polar decoder on llrs
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, currentPtr);
decoderState = polar_decoder_int16((int16_t*)llrs, decodedPayload, 0, 2,nb_bit,pucch_pdu->prb_size);
LOG_D(PHY,"UCI decoderState %d, payload[0] %llu\n",decoderState,(unsigned long long)decodedPayload[0]);
if (decoderState>0) decoderState=1;
corr_dB = dB_fixed64(corr);
......
......@@ -49,6 +49,11 @@ NR_gNB_SRS_t *new_gNB_srs(void){
return (srs);
}
void free_gNB_srs(NR_gNB_SRS_t *srs)
{
free_and_zero(srs);
}
int nr_find_srs(uint16_t rnti,
int frame,
int slot,
......
......@@ -832,14 +832,18 @@ void nr_pdcch_unscrambling(int16_t *z,
/* This function compares the received DCI bits with
* re-encoded DCI bits and returns the number of mismatched bits
*/
uint16_t nr_dci_false_detection(uint64_t *dci,
int16_t *soft_in,
const t_nrPolar_params *polar_param,
int encoded_length,
int rnti) {
static uint16_t nr_dci_false_detection(uint64_t *dci,
int16_t *soft_in,
int encoded_length,
int rnti,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level
) {
uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD];
polar_encoder_fast(dci, (void*)encoder_output, rnti, 1, (t_nrPolar_params *)polar_param);
polar_encoder_fast(dci, (void*)encoder_output, rnti, 1,
messageType, messageLength, aggregation_level);
uint8_t *enout_p = (uint8_t*)encoder_output;
uint16_t x = 0;
......@@ -886,7 +890,6 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
if (dci_found==1) continue;
int dci_length = rel15->dci_length_options[k];
uint64_t dci_estimation[2]= {0};
const t_nrPolar_params *currentPtrDCI = nr_polar_params(NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L, 1, &ue->polarList);
LOG_D(PHY, "Trying DCI candidate %d of %d number of candidates, CCE %d (%d), L %d, length %d, format %s\n",
j, rel15->number_of_candidates, CCEind, CCEind*9*6*2, L, dci_length,nr_dci_format_string[rel15->dci_format_options[k]]);
......@@ -901,11 +904,10 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
}
}
#endif
uint16_t crc = polar_decoder_int16(tmp_e,
dci_estimation,
1,
currentPtrDCI);
NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
n_rnti = rel15->rnti;
LOG_D(PHY, "(%i.%i) dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d)\n",
......@@ -913,7 +915,7 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue,
if (crc == n_rnti) {
LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n",
proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation);
uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,currentPtrDCI,L*108,n_rnti);
uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,L*108,n_rnti, NR_POLAR_DCI_MESSAGE_TYPE, dci_length, L);
ue->dci_thres = (ue->dci_thres + mb) / 2;
if (mb > (ue->dci_thres+20)) {
LOG_W(PHY,"DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n",j,mb,L*108,ue->dci_thres);
......
......@@ -79,7 +79,7 @@ void init_dlsch_tpool(uint8_t num_dlsch_threads) {
free(params);
}
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr,uint8_t N_RB_DL) {
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr, uint16_t N_RB_DL) {
int i,r;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
NR_UE_DLSCH_t *dlsch=*dlschptr;
......@@ -131,7 +131,7 @@ void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlschptr,uint8_t N_RB_DL) {
}
}
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL, uint8_t abstraction_flag) {
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_ldpc_iterations,uint16_t N_RB_DL) {
NR_UE_DLSCH_t *dlsch;
uint8_t exit_flag = 0,i,r;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
......@@ -167,30 +167,28 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
else
exit_flag=3;
if (abstraction_flag == 0) {
for (r=0; r<a_segments; r++) {
dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(1056);
for (r=0; r<a_segments; r++) {
dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(1056);
if (dlsch->harq_processes[i]->c[r])
memset(dlsch->harq_processes[i]->c[r],0,1056);
else
exit_flag=2;
if (dlsch->harq_processes[i]->c[r])
memset(dlsch->harq_processes[i]->c[r],0,1056);
else
exit_flag=2;
dlsch->harq_processes[i]->d[r] = (short *)malloc16((5*8448)*sizeof(short));
dlsch->harq_processes[i]->d[r] = (short *)malloc16((5*8448)*sizeof(short));
if (dlsch->harq_processes[i]->d[r])
memset(dlsch->harq_processes[i]->d[r],0,(5*8448)*sizeof(short));
else
exit_flag=2;
if (dlsch->harq_processes[i]->d[r])
memset(dlsch->harq_processes[i]->d[r],0,(5*8448)*sizeof(short));
else
exit_flag=2;
dlsch->harq_processes[i]->w[r] = (short *)malloc16((5*8448)*sizeof(short));
dlsch->harq_processes[i]->w[r] = (short *)malloc16((5*8448)*sizeof(short));
if (dlsch->harq_processes[i]->w[r])
memset(dlsch->harq_processes[i]->w[r],0,(5*8448)*sizeof(short));
else
exit_flag=2;
}
if (dlsch->harq_processes[i]->w[r])
memset(dlsch->harq_processes[i]->w[r],0,(5*8448)*sizeof(short));
else
exit_flag=2;
}
} else {
exit_flag=1;
......
......@@ -931,12 +931,12 @@ void nr_dlsch_channel_compensation(int **rxdataF_ext,
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
for (aatx=0; aatx<nb_aatx; aatx++) {
dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12];
for (atx=0; atx<nb_aatx; atx++) {
avg_rho_re[aarx][aatx*nb_aatx+atx] = 0;
avg_rho_im[aarx][aatx*nb_aatx+atx] = 0;
rho128 = (__m128i *)&rho[aarx][aatx*nb_aatx+atx][symbol*nb_rb*12];
dl_ch128 = (__m128i *)&dl_ch_estimates_ext[aatx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12];
dl_ch128_2 = (__m128i *)&dl_ch_estimates_ext[atx*frame_parms->nb_antennas_rx+aarx][symbol*nb_rb*12];
for (rb=0; rb<nb_rb_0; rb++) {
......
......@@ -337,6 +337,22 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
sync_pos_frame = n_symb_prefix0*(fp->ofdm_symbol_size + fp->nb_prefix_samples0)+(ue->symbol_offset-n_symb_prefix0)*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
// for a correct computation of frame number to sync with the one decoded at MIB we need to take into account in which of the n_frames we got sync
ue->init_sync_frame = n_frames - 1 - is;
// compute the scramblingID_pdcch and the gold pdcch
ue->scramblingID_pdcch = fp->Nid_cell;
nr_gold_pdcch(ue,fp->Nid_cell);
// compute the scrambling IDs for PDSCH DMRS
for (int i=0; i<2; i++)
ue->scramblingID[i]=fp->Nid_cell;
nr_gold_pdsch(ue,ue->scramblingID);
// initialize the pusch dmrs
uint16_t N_n_scid[2] = {fp->Nid_cell,fp->Nid_cell};
int n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization
nr_init_pusch_dmrs(ue, N_n_scid, n_scid);
// we also need to take into account the shift by samples_per_frame in case the if is true
if (ue->ssb_offset < sync_pos_frame){
ue->rx_offset = fp->samples_per_frame - sync_pos_frame + ue->ssb_offset;
......
......@@ -533,8 +533,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
//polar decoding de-rate matching
const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList);
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,currentPtr);
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0,
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
if(decoderState) return(decoderState);
......@@ -601,7 +601,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
#endif
nr_downlink_indication_t dl_indication;
fapi_nr_rx_indication_t *rx_ind = calloc(1, sizeof(*rx_ind));
fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1);
uint16_t number_pdus = 1;
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
......@@ -609,6 +609,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
if (ue->if_inst && ue->if_inst->dl_indication)
ue->if_inst->dl_indication(&dl_indication, NULL);
else
free(rx_ind); // dl_indication would free(), so free() here if not called
return 0;
}
......@@ -50,24 +50,23 @@
\brief This function frees memory allocated for a particular DLSCH at UE
@param dlsch Pointer to DLSCH to be removed
*/
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch,uint8_t N_RB_DL);
void free_nr_ue_dlsch(NR_UE_DLSCH_t **dlsch, uint16_t N_RB_DL);
/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t abstraction_flag)
/** \fn new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft)
\brief This function allocates structures for a particular DLSCH at UE
@returns Pointer to DLSCH to be removed
@param Kmimo Kmimo factor from 36-212/36-213
@param Mdlharq Maximum number of HARQ rounds (36-212/36-213)
@param Nsoft Soft-LLR buffer size from UE-Category
@params N_RB_DL total number of resource blocks (determine the operating BW)
@param abstraction_flag Flag to indicate abstracted interface
*/
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL, uint8_t abstraction_flag);
NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_t max_turbo_iterations,uint16_t N_RB_DL);
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch,unsigned char N_RB_UL);
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulsch, uint16_t N_RB_UL);
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids, uint8_t abstraction_flag);
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids);
/** \brief This function computes the LLRs for ML (max-logsum approximation) dual-stream QPSK/QPSK reception.
@param stream0_in Input from channel compensated (MR combined) stream 0
......
......@@ -43,7 +43,7 @@
//#define DEBUG_ULSCH_CODING
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL)
void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr, uint16_t N_RB_UL)
{
int i, r;
......@@ -105,12 +105,8 @@ void free_nr_ue_ulsch(NR_UE_ULSCH_t **ulschptr,unsigned char N_RB_UL)
}
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL,
int number_of_harq_pids,
uint8_t abstraction_flag)
NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL, int number_of_harq_pids)
{
NR_UE_ULSCH_t *ulsch;
unsigned char exit_flag = 0,i,r;
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
if (N_RB_UL != 273) {
......@@ -120,97 +116,54 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(uint16_t N_RB_UL,
uint32_t ulsch_bytes = a_segments*1056; // allocated bytes per segment
ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t));
NR_UE_ULSCH_t *ulsch = malloc16(sizeof(NR_UE_ULSCH_t));
DevAssert(ulsch);
memset(ulsch, 0, sizeof(*ulsch));
if (ulsch) {
memset(ulsch,0,sizeof(NR_UE_ULSCH_t));
ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES;
ulsch->Mlimit = 4; // maximum harq retransmissions
ulsch->number_harq_processes_for_pusch = NR_MAX_ULSCH_HARQ_PROCESSES;
ulsch->Mlimit = 4; // maximum harq retransmissions
//for (i=0; i<10; i++)
//ulsch->harq_ids[i] = 0;
//for (i=0; i<10; i++)
//ulsch->harq_ids[i] = 0;
for (i=0; i<number_of_harq_pids; i++) {
for (int i = 0; i < number_of_harq_pids; i++) {
ulsch->harq_processes[i] = (NR_UL_UE_HARQ_t *)malloc16(sizeof(NR_UL_UE_HARQ_t));
ulsch->harq_processes[i] = malloc16(sizeof(NR_UL_UE_HARQ_t));
DevAssert(ulsch->harq_processes[i]);
memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t));
// printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]);
if (ulsch->harq_processes[i]) {
memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t));
ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes);
ulsch->harq_processes[i]->a = (unsigned char*)malloc16(ulsch_bytes);
ulsch->harq_processes[i]->a = malloc16(ulsch_bytes);
DevAssert(ulsch->harq_processes[i]->a);
bzero(ulsch->harq_processes[i]->a,ulsch_bytes);
if (ulsch->harq_processes[i]->a) {
bzero(ulsch->harq_processes[i]->a,ulsch_bytes);
} else {
printf("Can't allocate PDU\n");
exit_flag=1;
}
ulsch->harq_processes[i]->b = malloc16(ulsch_bytes);
DevAssert(ulsch->harq_processes[i]->b);
bzero(ulsch->harq_processes[i]->b,ulsch_bytes);
if (ulsch->harq_processes[i]->b)
bzero(ulsch->harq_processes[i]->b,ulsch_bytes);
else {
LOG_E(PHY,"Can't get b\n");
exit_flag=1;
}
if (abstraction_flag==0) {
for (r=0; r<a_segments; r++) {
// account for filler in first segment and CRCs for multiple segment case
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448);
ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output
if (ulsch->harq_processes[i]->c[r]) {
bzero(ulsch->harq_processes[i]->c[r],8448);
} else {
printf("Can't get c\n");
exit_flag=2;
}
if (ulsch->harq_processes[i]->d[r]) {
bzero(ulsch->harq_processes[i]->d[r],(68*384));
} else {
printf("Can't get d\n");
exit_flag=2;
}
}
ulsch->harq_processes[i]->e = (uint8_t*)malloc16(14*N_RB_UL*12*8);
if (ulsch->harq_processes[i]->e) {
bzero(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
} else {
printf("Can't get e\n");
exit_flag=1;
}
ulsch->harq_processes[i]->f = (uint8_t*)malloc16(14*N_RB_UL*12*8);
if (ulsch->harq_processes[i]->f) {
bzero(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
} else {
printf("Can't get f\n");
exit_flag=1;
}
}
for (int r = 0; r < a_segments; r++) {
// account for filler in first segment and CRCs for multiple segment case
ulsch->harq_processes[i]->c[r] = malloc16(8448);
DevAssert(ulsch->harq_processes[i]->c[r]);
bzero(ulsch->harq_processes[i]->c[r],8448);
ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
ulsch->harq_processes[i]->first_tx = 1;
} else {
LOG_E(PHY,"Can't get harq_p %d\n",i);
exit_flag=3;
}
ulsch->harq_processes[i]->d[r] = malloc16(68*384); //max size for coded output
DevAssert(ulsch->harq_processes[i]->d[r]);
bzero(ulsch->harq_processes[i]->d[r],(68*384));
}
if (exit_flag==0) {
for (i=0; i<number_of_harq_pids; i++) {
ulsch->harq_processes[i]->round=0;
}
return(ulsch);
}
}
ulsch->harq_processes[i]->e = malloc16(14*N_RB_UL*12*8);
DevAssert(ulsch->harq_processes[i]->e);
bzero(ulsch->harq_processes[i]->e,14*N_RB_UL*12*8);
LOG_E(PHY,"new_ue_ulsch exit flag, size of %d , %zu\n",exit_flag, sizeof(LTE_UE_ULSCH_t));
free_nr_ue_ulsch(&ulsch,N_RB_UL);
return(NULL);
ulsch->harq_processes[i]->f = malloc16(14*N_RB_UL*12*8);
DevAssert(ulsch->harq_processes[i]->f);
bzero(ulsch->harq_processes[i]->f,14*N_RB_UL*12*8);
ulsch->harq_processes[i]->subframe_scheduling_flag = 0;
ulsch->harq_processes[i]->first_tx = 1;
}
return(ulsch);
}
......
......@@ -130,7 +130,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int32_t **txdataF = UE->common_vars.txdataF;
uint8_t num_of_codewords = 1; // tmp assumption
int Nid_cell = 0;
int N_PRB_oh = 0; // higher layer (RRC) parameter xOverhead in PUSCH-ServingCellConfig
uint16_t number_dmrs_symbols = 0;
......@@ -155,7 +154,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
if (start_sc >= frame_parms->ofdm_symbol_size)
start_sc -= frame_parms->ofdm_symbol_size;
ulsch_ue->Nid_cell = Nid_cell;
ulsch_ue->Nid_cell = frame_parms->Nid_cell;
for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) {
if((ul_dmrs_symb_pos >> i) & 0x01)
......@@ -377,8 +376,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
// TODO: performance improvement, we can skip the modulation of DMRS symbols outside the bandwidth part
// Perform this on gold sequence, not required when SC FDMA operation is done,
LOG_D(PHY,"DMRS in symbol %d\n",l);
nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
LOG_D(PHY,"DMRS in symbol %d\n",l);
nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
}
else {
dmrs_idx = 0;
......
......@@ -440,33 +440,10 @@ void init_context_pss_nr(NR_DL_FRAME_PARMS *frame_parms_ue)
void free_context_pss_nr(void)
{
for (int i = 0; i < NUMBER_PSS_SEQUENCE; i++) {
if (primary_synchro_time_nr[i] != NULL) {
free(primary_synchro_time_nr[i]);
primary_synchro_time_nr[i] = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
if (primary_synchro_nr[i] != NULL) {
free(primary_synchro_nr[i]);
primary_synchro_nr[i] = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
if (pss_corr_ue[i] != NULL) {
free(pss_corr_ue[i]);
pss_corr_ue[i] = NULL;
}
else {
LOG_E(PHY,"Fatal memory deallocation problem \n");
assert(0);
}
free_and_zero(primary_synchro_nr[i]);
free_and_zero(primary_synchro_nr2[i]);
free_and_zero(primary_synchro_time_nr[i]);
free_and_zero(pss_corr_ue[i]);
}
}
......
......@@ -850,7 +850,7 @@ static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_
printf("\t\t [nr_pucch2_3_4_scrambling] scrambling M_bit=%d bits\n", M_bit);
#endif
}
void nr_uci_encoding(uint64_t payload,
static void nr_uci_encoding(uint64_t payload,
uint8_t nr_bit,
int fmt,
uint8_t is_pi_over_2_bpsk_enabled,
......@@ -946,12 +946,10 @@ void nr_uci_encoding(uint64_t payload,
AssertFatal(nrofPRB<=16,"Number of PRB >16\n");
} else if (A>=12) {
AssertFatal(A<65,"Polar encoding not supported yet for UCI with more than 64 bits\n");
t_nrPolar_params *currentPtr = nr_polar_params(NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
A,
nrofPRB,
1,
NULL);
polar_encoder_fast(&payload, b, 0,0,currentPtr);
polar_encoder_fast(&payload, b, 0,0,
NR_POLAR_UCI_PUCCH_MESSAGE_TYPE,
A,
nrofPRB);
}
}
......
......@@ -783,7 +783,7 @@ typedef struct PHY_VARS_gNB_s {
/// statistics for ULSCH measurement collection
NR_gNB_SCH_STATS_t ulsch_stats[NUMBER_OF_NR_SCH_STATS_MAX];
NR_gNB_UCI_STATS_t uci_stats[NUMBER_OF_NR_UCI_STATS_MAX];
t_nrPolar_params *uci_polarParams;
t_nrPolar_params **polarParams;
/// SRS variables
nr_srs_info_t *nr_srs_info[NUMBER_OF_NR_SRS_MAX];
......
......@@ -817,7 +817,6 @@ typedef struct {
fapi_nr_config_request_t nrUE_config;
t_nrPolar_params *polarList;
NR_UE_PDSCH *pdsch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX+1]; // two RxTx Threads
NR_UE_PBCH *pbch_vars[NUMBER_OF_CONNECTED_gNB_MAX];
NR_UE_PDCCH *pdcch_vars[RX_NB_TH_MAX][NUMBER_OF_CONNECTED_gNB_MAX];
......
......@@ -388,8 +388,6 @@ struct NR_DL_FRAME_PARMS {
uint8_t N_ssb;
/// SSB index
uint8_t ssb_index;
/// PBCH polar encoder params
t_nrPolar_params pbch_polar_params;
/// OFDM symbol offset divisor for UL
uint32_t ofdm_offset_divisor;
};
......
......@@ -54,5 +54,6 @@ void nr_fep_full(RU_t *ru, int slot);
void nr_fep_full_2thread(RU_t *ru, int slot);
void feptx_prec(RU_t *ru,int frame_tx,int tti_tx);
int nr_phy_init_RU(RU_t *ru);
void nr_phy_free_RU(RU_t *ru);
#endif
......@@ -295,9 +295,6 @@ uint8_t nr_pdcch_alloc2ul_subframe(NR_DL_FRAME_PARMS *frame_parms,uint8_t n);
uint32_t nr_pdcch_alloc2ul_frame(NR_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t n);
uint16_t nr_get_Np(uint8_t N_RB_DL,uint8_t nCCE,uint8_t plus1);
int8_t nr_find_ue(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB);
/*! \brief UL time alignment procedures for TA application
......
......@@ -90,8 +90,11 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
rx_ind->pdu_list[j].pdu = CALLOC(tx_req_body->pdu_length, sizeof(*rx_ind->pdu_list[j].pdu));
memcpy(rx_ind->pdu_list[j].pdu, tx_req_body->pdu, tx_req_body->pdu_length * sizeof(*rx_ind->pdu_list[j].pdu));
rx_ind->pdu_list[j].rnti = pusch_config_pdu->rnti;
rx_ind->pdu_list[j].timing_advance = scheduled_response->tx_request->tx_config.timing_advance;
rx_ind->pdu_list[j].ul_cqi = scheduled_response->tx_request->tx_config.ul_cqi;
/* TODO: Implement channel modeling to abstract TA and CQI. For now,
we hard code the values below since they are set in L1 and we are
abstracting L1. */
rx_ind->pdu_list[j].timing_advance = 31;
rx_ind->pdu_list[j].ul_cqi = 255;
char buffer[1024];
hexdump(rx_ind->pdu_list[j].pdu, rx_ind->pdu_list[j].pdu_length, buffer, sizeof(buffer));
LOG_D(NR_MAC, "Hexdump of pdu %s before queuing rx_ind\n",
......@@ -113,7 +116,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
crc_ind->crc_list[j].num_cb = pusch_config_pdu->pusch_data.num_cb;
crc_ind->crc_list[j].rnti = pusch_config_pdu->rnti;
crc_ind->crc_list[j].tb_crc_status = 0;
crc_ind->crc_list[j].timing_advance = scheduled_response->tx_request->tx_config.timing_advance;
crc_ind->crc_list[j].timing_advance = 31;
crc_ind->crc_list[j].ul_cqi = 255;
}
......@@ -204,6 +207,7 @@ int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response
}
}
}
dl_config->number_pdus = 0;
}
}
......
......@@ -64,6 +64,13 @@
void feptx_ofdm(RU_t *ru, int frame, int subframe);
void feptx_prec(RU_t *ru, int frame, int subframe);
const char *__asan_default_options()
{
/* don't do leak checking in nr_ulsim, not finished yet */
return "detect_leaks=0";
}
double cpuf;
#define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0))
//#define MCS_COUNT 23//added for PHY abstraction
......@@ -140,7 +147,7 @@ void do_OFDM_mod_l(int32_t **txdataF, int32_t **txdata, uint16_t next_slot, LTE_
}
void DL_channel(RU_t *ru,PHY_VARS_UE *UE,uint subframe,int awgn_flag,double SNR, int tx_lev,int hold_channel,int abstx, int num_rounds, int trials, int round, channel_desc_t *eNB2UE[4],
double *s_re[2],double *s_im[2],double *r_re[2],double *r_im[2],FILE *csv_fd) {
double *s_re[NB_ANTENNAS_TX],double *s_im[NB_ANTENNAS_TX],double *r_re[NB_ANTENNAS_RX],double *r_im[NB_ANTENNAS_RX],FILE *csv_fd) {
int i,u;
int aa,aarx,aatx;
double channelx,channely;
......@@ -1538,9 +1545,9 @@ int main(int argc, char **argv) {
LOG_M("txsig0.m","txs0", &ru->common.txdata[0][subframe* eNB->frame_parms.samples_per_tti], eNB->frame_parms.samples_per_tti,1,1);
if (transmission_mode<7) {
LOG_M("txsigF0.m","txsF0x", &ru->common.txdataF_BF[0][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
LOG_M("txsigF0.m","txsF0x", &ru->common.txdataF_BF[0][0],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
} else if (transmission_mode == 7) {
LOG_M("txsigF0.m","txsF0", &ru->common.txdataF_BF[5][subframe*nsymb*eNB->frame_parms.ofdm_symbol_size],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
LOG_M("txsigF0.m","txsF0", &ru->common.txdataF_BF[5][0],nsymb*eNB->frame_parms.ofdm_symbol_size,1,1);
LOG_M("txsigF0_BF.m","txsF0_BF", &ru->common.txdataF_BF[0][0],eNB->frame_parms.ofdm_symbol_size,1,1);
}
}
......
......@@ -58,6 +58,12 @@
#include "common/ran_context.h"
#include "PHY/LTE_ESTIMATION/lte_estimation.h"
const char *__asan_default_options()
{
/* don't do leak checking in ulsim, not finished yet */
return "detect_leaks=0";
}
double cpuf;
#define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0))
//#define MCS_COUNT 23//added for PHY abstraction
......@@ -334,10 +340,10 @@ int main(int argc, char **argv) {
double s_re1[30720],s_im1[30720],r_re1[30720],r_im1[30720];
double r_re2[30720],r_im2[30720];
double r_re3[30720],r_im3[30720];
double *s_re[2]= {s_re0,s_re1};
double *s_im[2]= {s_im0,s_im1};
double *r_re[4]= {r_re0,r_re1,r_re2,r_re3};
double *r_im[4]= {r_im0,r_im1,r_im2,r_im3};
double *s_re[NB_ANTENNAS_TX]= {s_re0,s_re1, NULL, NULL};
double *s_im[NB_ANTENNAS_TX]= {s_im0,s_im1, NULL, NULL};
double *r_re[NB_ANTENNAS_RX]= {r_re0,r_re1,r_re2,r_re3};
double *r_im[NB_ANTENNAS_RX]= {r_im0,r_im1,r_im2,r_im3};
double forgetting_factor=0.0; //in [0,1] 0 means a new channel every time, 1 means keep the same channel
double iqim=0.0;
int cqi_error,cqi_errors,ack_errors,cqi_crc_falsepositives,cqi_crc_falsenegatives;
......
......@@ -29,6 +29,7 @@
#include "common/config/config_userapi.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "common/utils/load_module_shlib.h"
#include "T.h"
#include "PHY/defs_gNB.h"
#include "PHY/defs_nr_common.h"
......@@ -358,7 +359,7 @@ int main(int argc, char **argv)
}
RC.gNB = (PHY_VARS_gNB **) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
RC.gNB[0] = calloc(1, sizeof(PHY_VARS_gNB));
gNB = RC.gNB[0];
gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
initTpool(gNBthreads, gNB->threadPool, true);
......@@ -415,7 +416,7 @@ int main(int argc, char **argv)
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(UE, 1, 0) != 0) {
if (init_nr_ue_signal(UE, 1) != 0) {
printf("Error at UE NR initialisation\n");
exit(-1);
}
......@@ -424,8 +425,7 @@ int main(int argc, char **argv)
//init_nr_ue_transport(UE, 0);
for (int sf = 0; sf < 2; sf++) {
for (i = 0; i < 2; i++) {
UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL,
0);
UE->dlsch[sf][0][i] = new_nr_ue_dlsch(Kmimo, 8, Nsoft, 5, N_RB_DL);
if (!UE->dlsch[sf][0][i]) {
printf("Can't get ue dlsch structures\n");
......@@ -436,8 +436,6 @@ int main(int argc, char **argv)
}
}
UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
unsigned char harq_pid = 0; //dlsch->harq_ids[subframe];
processingData_L1tx_t msgDataTx;
init_DLSCH_struct(gNB, &msgDataTx);
......@@ -475,16 +473,13 @@ int main(int argc, char **argv)
rel15->dlDmrsSymbPos = 4;
rel15->mcsIndex[0] = Imcs;
rel15->numDmrsCdmGrpsNoData = 1;
double *modulated_input = malloc16(sizeof(double) * 16 * 68 * 384); // [hna] 16 segments, 68*Zc
short *channel_output_fixed = malloc16(sizeof(short) * 16 * 68 * 384);
short *channel_output_uncoded = malloc16(sizeof(unsigned short) * 16 * 68 * 384);
double modulated_input[16 * 68 * 384]; // [hna] 16 segments, 68*Zc
short channel_output_fixed[16 * 68 * 384];
//unsigned char *estimated_output;
unsigned char *estimated_output_bit;
unsigned char *test_input_bit;
unsigned int errors_bit = 0;
test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
unsigned char test_input_bit[16 * 68 * 384];
//estimated_output = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384);
unsigned char estimated_output_bit[16 * 68 * 384];
NR_UE_DLSCH_t *dlsch0_ue = UE->dlsch[0][0][0];
NR_DL_UE_HARQ_t *harq_process = dlsch0_ue->harq_processes[harq_pid];
harq_process->mcs = Imcs;
......@@ -498,9 +493,10 @@ int main(int argc, char **argv)
harq_process->dlDmrsSymbPos = 4;
harq_process->n_dmrs_cdm_groups = 1;
printf("harq process ue mcs = %d Qm = %d, symb %d\n", harq_process->mcs, harq_process->Qm, nb_symb_sch);
unsigned char *test_input;
test_input = (unsigned char *) malloc16(sizeof(unsigned char) * TBS / 8);
//unsigned char test_input[TBS / 8] __attribute__ ((aligned(16)));
for (i = 0; i < TBS / 8; i++)
test_input[i] = (unsigned char) rand();
......@@ -557,12 +553,6 @@ int main(int argc, char **argv)
i,modulated_input[i],
i,channel_output_fixed[i]);
*/
//Uncoded BER
if (channel_output_fixed[i] < 0)
channel_output_uncoded[i] = 1; //QPSK demod
else
channel_output_uncoded[i] = 0;
}
#ifdef DEBUG_CODER
......@@ -644,12 +634,22 @@ int main(int argc, char **argv)
}
}*/
for (i = 0; i < 2; i++) {
printf("gNB %d\n", i);
free_gNB_dlsch(&(msgDataTx.dlsch[0][i]),N_RB_DL);
printf("UE %d\n", i);
free_nr_ue_dlsch(&(UE->dlsch[0][0][i]),N_RB_DL);
}
free(test_input);
free_channel_desc_scm(gNB2UE);
reset_DLSCH_struct(gNB, &msgDataTx);
phy_free_nr_gNB(gNB);
free(gNB->threadPool);
free(RC.gNB[0]);
free(RC.gNB);
for (int sf = 0; sf < 2; sf++)
for (int i = 0; i < 2; i++)
free_nr_ue_dlsch(&UE->dlsch[sf][0][i], N_RB_DL);
term_nr_ue_signal(UE, 1);
free(UE);
for (i = 0; i < 2; i++) {
free(s_re[i]);
......@@ -674,6 +674,9 @@ int main(int argc, char **argv)
if (ouput_vcd)
vcd_signal_dumper_close();
loader_reset();
logTerm();
return (n_errors);
}
......@@ -73,6 +73,12 @@
#include <executables/softmodem-common.h>
#include <openair3/ocp-gtpu/gtp_itf.h>
const char *__asan_default_options()
{
/* don't do leak checking in nr_ulsim, not finished yet */
return "detect_leaks=0";
}
LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC;
rlc_info_t Rlc_info_um,Rlc_info_am_config;
......@@ -916,16 +922,25 @@ int main(int argc, char **argv)
UE->perfect_ce = 0;
if (init_nr_ue_signal(UE, 1, 0) != 0)
if (init_nr_ue_signal(UE, 1) != 0)
{
printf("Error at UE NR initialisation\n");
exit(-1);
}
init_nr_ue_transport(UE,0);
init_nr_ue_transport(UE);
nr_gold_pbch(UE);
nr_gold_pdcch(UE,0);
// compute the scramblingID_pdcch and the gold pdcch
UE->scramblingID_pdcch = frame_parms->Nid_cell;
nr_gold_pdcch(UE, frame_parms->Nid_cell);
// compute the scrambling IDs for PDSCH DMRS
for (int i = 0; i < 2; i++)
UE->scramblingID[i] = frame_parms->Nid_cell;
nr_gold_pdsch(UE, UE->scramblingID);
nr_l2_init_ue(NULL);
UE_mac = get_mac_inst(0);
......
......@@ -27,6 +27,7 @@
#include <sys/mman.h>
#include "common/config/config_userapi.h"
#include "common/utils/LOG/log.h"
#include "common/utils/load_module_shlib.h"
#include "common/ran_context.h"
#include "common/utils/nr/nr_common.h"
#include "PHY/types.h"
......@@ -438,12 +439,13 @@ int main(int argc, char **argv)
printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB));
RC.gNB[0] = malloc16_clear(sizeof(*(RC.gNB[0])));
gNB = RC.gNB[0];
gNB->ofdm_offset_divisor = UINT_MAX;
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
frame_parms->nb_antennas_tx = n_tx;
frame_parms->nb_antennas_rx = n_rx;
frame_parms->nb_antenna_ports_gNB = n_tx;
frame_parms->N_RB_DL = N_RB_DL;
frame_parms->Nid_cell = Nid_cell;
frame_parms->nushift = Nid_cell%4;
......@@ -533,19 +535,13 @@ int main(int argc, char **argv)
for (i=0; i<2; i++) {
s_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(s_re[i],frame_length_complex_samples*sizeof(double));
s_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(s_im[i],frame_length_complex_samples*sizeof(double));
r_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_re[i],frame_length_complex_samples*sizeof(double));
r_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_im[i],frame_length_complex_samples*sizeof(double));
s_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
s_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
r_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
r_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
printf("Allocating %d samples for txdata\n",frame_length_complex_samples);
txdata[i] = malloc(frame_length_complex_samples*sizeof(int));
bzero(r_re[i],frame_length_complex_samples*sizeof(int));
txdata[i] = malloc16_clear(frame_length_complex_samples*sizeof(int));
}
if (pbch_file_fd!=NULL) {
......@@ -554,8 +550,8 @@ int main(int argc, char **argv)
//configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE));
memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS));
UE = malloc16_clear(sizeof(*UE));
memcpy(&UE->frame_parms,frame_parms,sizeof(UE->frame_parms));
//phy_init_nr_top(UE); //called from init_nr_ue_signal
if (run_initial_sync==1) UE->is_synchronized = 0;
else UE->is_synchronized = 1;
......@@ -565,7 +561,7 @@ int main(int argc, char **argv)
if(eps!=0.0)
UE->UE_fo_compensation = 1; // if a frequency offset is set then perform fo estimation and compensation
if (init_nr_ue_signal(UE, 1, 0) != 0) {
if (init_nr_ue_signal(UE, 1) != 0) {
printf("Error at UE NR initialisation\n");
exit(-1);
}
......@@ -780,6 +776,15 @@ int main(int argc, char **argv)
} // NSR
free_channel_desc_scm(gNB2UE);
phy_free_nr_gNB(gNB);
free(RC.gNB[0]);
free(RC.gNB);
term_nr_ue_signal(UE, 1);
free(UE);
for (i=0; i<2; i++) {
free(s_re[i]);
free(s_im[i]);
......@@ -800,6 +805,9 @@ int main(int argc, char **argv)
if (input_fd)
fclose(input_fd);
loader_reset();
logTerm();
return(n_errors);
}
......@@ -25,6 +25,7 @@
#include <pthread.h>
#include "common/config/config_userapi.h"
#include "common/utils/load_module_shlib.h"
#include "common/utils/LOG/log.h"
#include "common/ran_context.h"
......@@ -662,7 +663,6 @@ int main(int argc, char **argv){
RC.nb_nr_L1_inst=1;
phy_init_nr_gNB(gNB,0,1); //lowmem
nr_phy_init_RU(ru);
gNB->common_vars.rxdata = ru->common.rxdata;
set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4);
// Configure UE
......@@ -674,7 +674,7 @@ int main(int argc, char **argv){
memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS));
UE->nrUE_config.prach_config.num_prach_fd_occasions_list = (fapi_nr_num_prach_fd_occasions_t *) malloc(num_prach_fd_occasions*sizeof(fapi_nr_num_prach_fd_occasions_t));
if (init_nr_ue_signal(UE, 1, 0) != 0){
if (init_nr_ue_signal(UE, 1) != 0){
printf("Error at UE NR initialisation\n");
exit(-1);
}
......@@ -781,7 +781,7 @@ int main(int argc, char **argv){
// multipath channel
// dump_nr_prach_config(&gNB->frame_parms,subframe);
for (i = 0; i < frame_parms->samples_per_subframe<<1; i++) {
for (i = 0; i < frame_parms->samples_per_subframe; i++) {
for (aa=0; aa<1; aa++) {
if (awgn_flag == 0) {
s_re[aa][i] = ((double)(((short *)&txdata[aa][prach_start]))[(i<<1)]);
......@@ -879,7 +879,8 @@ int main(int argc, char **argv){
rx_nr_prach_ru(ru, prach_format, numRA, prachStartSymbol, prachOccasion, frame, slot);
gNB->prach_vars.rxsigF = ru->prach_rxsigF[prachOccasion];
for (int i = 0; i < ru->nb_rx; ++i)
gNB->prach_vars.rxsigF[i] = ru->prach_rxsigF[prachOccasion][i];
if (n_frames == 1) printf("ncs %d,num_seq %d\n",prach_pdu->num_cs, prach_config->num_prach_fd_occasions_list[fd_occasion].num_root_sequences.value);
rx_nr_prach(gNB, prach_pdu, prachOccasion, frame, subframe, &preamble_rx, &preamble_energy, &preamble_delay);
......@@ -897,7 +898,7 @@ int main(int argc, char **argv){
#ifdef NR_PRACH_DEBUG
LOG_M("prach0.m","prach0", &txdata[0][prach_start], frame_parms->samples_per_subframe, 1, 1);
LOG_M("prachF0.m","prachF0", &gNB->prach_vars.prachF[0], N_ZC, 1, 1);
LOG_M("rxsig0.m","rxs0", &gNB->common_vars.rxdata[0][subframe*frame_parms->samples_per_subframe], frame_parms->samples_per_subframe, 1, 1);
LOG_M("rxsig0.m","rxs0", &ru->common.rxdata[0][subframe*frame_parms->samples_per_subframe], frame_parms->samples_per_subframe, 1, 1);
LOG_M("ru_rxsig0.m","rxs0", &ru->common.rxdata[0][subframe*frame_parms->samples_per_subframe], frame_parms->samples_per_subframe, 1, 1);
LOG_M("ru_rxsigF0.m","rxsF0", ru->common.rxdataF[0], frame_parms->ofdm_symbol_size*frame_parms->symbols_per_slot, 1, 1);
LOG_M("ru_prach_rxsigF0.m","rxsF0", ru->prach_rxsigF[0][0], N_ZC, 1, 1);
......@@ -922,6 +923,28 @@ int main(int argc, char **argv){
break;
} //SNR loop
free_channel_desc_scm(UE2gNB);
nr_phy_free_RU(ru);
free(RC.ru[0]);
free(RC.ru);
phy_free_nr_gNB(gNB);
// allocated in set_tdd_config_nr()
int nb_slots_to_set = TDD_CONFIG_NB_FRAMES*(1<<mu)*NR_NUMBER_OF_SUBFRAMES_PER_FRAME;
free(gNB->gNB_config.prach_config.num_prach_fd_occasions_list);
for (int i = 0; i < nb_slots_to_set; ++i)
free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list[i].max_num_of_symbol_per_slot_list);
free(gNB->gNB_config.tdd_table.max_tdd_periodicity_list);
free(RC.gNB[0]);
free(RC.gNB);
term_nr_ue_signal(UE, 1);
free(UE->nrUE_config.prach_config.num_prach_fd_occasions_list);
free(UE);
free(PHY_vars_UE_g[0]);
free(PHY_vars_UE_g);
for (i=0; i<2; i++) {
free(s_re[i]);
free(s_im[i]);
......@@ -936,5 +959,8 @@ int main(int argc, char **argv){
if (input_fd) fclose(input_fd);
loader_reset();
logTerm();
return(0);
}
This diff is collapsed.
This diff is collapsed.
......@@ -68,6 +68,12 @@
#include <openair3/ocp-gtpu/gtp_itf.h>
//#define DEBUG_ULSIM
const char *__asan_default_options()
{
/* don't do leak checking in nr_ulsim, not finished yet */
return "detect_leaks=0";
}
LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC;
rlc_info_t Rlc_info_um,Rlc_info_am_config;
......@@ -757,28 +763,17 @@ int main(int argc, char **argv)
PHY_vars_UE_g[0][0] = UE;
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(UE, 1, 0) != 0) {
if (init_nr_ue_signal(UE, 1) != 0) {
printf("Error at UE NR initialisation\n");
exit(-1);
}
//nr_init_frame_parms_ue(&UE->frame_parms);
init_nr_ue_transport(UE, 0);
/*
for (int sf = 0; sf < 2; sf++) {
for (i = 0; i < 2; i++) {
init_nr_ue_transport(UE);
UE->ulsch[sf][0][i] = new_nr_ue_ulsch(N_RB_UL, 8, 0);
if (!UE->ulsch[sf][0][i]) {
printf("Can't get ue ulsch structures\n");
exit(-1);
}
}
}
*/
// initialize the pusch dmrs
uint16_t N_n_scid[2] = {frame_parms->Nid_cell,frame_parms->Nid_cell};
int n_scid = 0; // This quantity is indicated by higher layer parameter dmrs-SeqInitialization
nr_init_pusch_dmrs(UE, N_n_scid, n_scid);
//Configure UE
NR_UE_RRC_INST_t rrcue;
......
......@@ -71,7 +71,7 @@ static nfapi_config_request_t *config =&config_t;
/*************** FUNCTIONS ****************************************/
//void phy_init_nr_top(NR_DL_FRAME_PARMS *frame_parms);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_eNB, uint8_t abstraction_flag);
int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_eNB);
/*******************************************************************
*
......@@ -248,7 +248,7 @@ int init_test(unsigned char N_tx, unsigned char N_rx, unsigned char transmission
//phy_init_nr_top(frame_parms);
if (init_nr_ue_signal(PHY_vars_UE, 1, 0) != 0) {
if (init_nr_ue_signal(PHY_vars_UE, 1) != 0) {
LOG_E(PHY,"Error at UE NR initialisation : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
return (0);
}
......
......@@ -33,11 +33,26 @@
// NEW code with lookup table for sin/cos based on delay profile (TO BE TESTED)
double **cos_lut=NULL,* *sin_lut=NULL;
static int freq_channel_init = 0;
static int n_samples_max = 0;
//#if 1
void term_freq_channel(void)
{
for (int f = -(n_samples_max >> 1); f <= n_samples_max >> 1; f++) {
const int idx = f + (n_samples_max >> 1);
if (cos_lut[idx])
free_and_zero(cos_lut[idx]);
if (sin_lut[idx])
free_and_zero(sin_lut[idx]);
}
free_and_zero(cos_lut);
free_and_zero(sin_lut);
freq_channel_init = 0;
n_samples_max = 0;
}
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs) {
double delta_f,freq; // 90 kHz spacing
......@@ -78,8 +93,6 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs)
int16_t f,f2,d;
uint8_t aarx,aatx,l;
double *clut,*slut;
static int freq_channel_init=0;
static int n_samples_max=0;
// do some error checking
// n_samples has to be a odd number because we assume the spectrum is symmetric around the DC and includes the DC
......
......@@ -125,7 +125,7 @@ void fill_channel_desc(channel_desc_t *chan_desc,
chan_desc->ch[i] = (struct complexd *) malloc(channel_length * sizeof(struct complexd));
for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complexd *) malloc(12*257 * sizeof(struct complexd)); // allocate for up to 257 RBs, 12 samples per RB
chan_desc->chF[i] = (struct complexd *) malloc(275 * 12 * sizeof(struct complexd)); // allocate for up to 275 RBs, 12 symbols per RB
LOG_D(OCM,"[CHANNEL] Filling a (nb_taps %d)\n",nb_taps);
......
......@@ -479,6 +479,7 @@ void randominit(unsigned int seed_init);
double uniformrandom(void);
int freq_channel(channel_desc_t *desc,uint16_t nb_rb, int16_t n_samples,int scs);
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples,int scs);
void term_freq_channel(void);
uint8_t multipath_channel_nosigconv(channel_desc_t *desc);
void multipath_tv_channel(channel_desc_t *desc,
double **tx_sig_re,
......
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