Commit aef2d908 authored by Florian Kaltenberger's avatar Florian Kaltenberger

Merge branch 'multiple-ssb-detection' into 'develop-nr'

Multiple ssb detection

See merge request oai/openairinterface5g!530
parents 0ba1958e ab299dd2
...@@ -167,7 +167,7 @@ endif() ...@@ -167,7 +167,7 @@ endif()
# #
set(CMAKE_C_FLAGS set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC ") "${CMAKE_C_FLAGS} ${C_FLAGS_PROCESSOR} -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing -rdynamic -funroll-loops -Wno-packed-bitfield-compat -fPIC")
# add autotools definitions that were maybe used! # add autotools definitions that were maybe used!
set(MKVER "'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'") set(MKVER "'MAKE_VERSION(a,b,c)=((a)*256+(b)*16+c)'")
set(CMAKE_C_FLAGS set(CMAKE_C_FLAGS
...@@ -1575,6 +1575,7 @@ add_library(L2 ...@@ -1575,6 +1575,7 @@ add_library(L2
${ENB_APP_SRC} ${ENB_APP_SRC}
) )
add_dependencies(L2 rrc_flag s1ap_flag x2_flag) add_dependencies(L2 rrc_flag s1ap_flag x2_flag)
add_library(MAC_NR add_library(MAC_NR
${MAC_NR_SRC} ${MAC_NR_SRC}
) )
...@@ -1593,7 +1594,6 @@ add_dependencies(S1AP_LIB nr_rrc_flag s1ap_flag) ...@@ -1593,7 +1594,6 @@ add_dependencies(S1AP_LIB nr_rrc_flag s1ap_flag)
add_library(L2_UE add_library(L2_UE
${L2_SRC_UE} ${L2_SRC_UE}
${MAC_SRC_UE} ${MAC_SRC_UE}
#${MAC_NR_SRC_UE}
) )
if (NOT ${NOS1}) if (NOT ${NOS1})
target_compile_definitions(L2_UE PUBLIC -DPDCP_USE_NETLINK) target_compile_definitions(L2_UE PUBLIC -DPDCP_USE_NETLINK)
...@@ -1602,44 +1602,13 @@ endif() ...@@ -1602,44 +1602,13 @@ endif()
add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag) add_dependencies(L2_UE rrc_flag s1ap_flag x2_flag)
add_library( NR_L2_UE add_library( NR_L2_UE
#${L2_SRC_UE}
${NR_L2_SRC_UE} ${NR_L2_SRC_UE}
${MAC_NR_SRC_UE} ${MAC_NR_SRC_UE}
#${MAC_SRC_UE} )
)
add_library( MAC_NR_COMMON
set ( NR_LTE_UE_REUSE_SRC ${OPENAIR2_DIR}/LAYER2/NR_MAC_gNB/nr_mac_common.c
${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.c )
${OPENAIR1_DIR}/SCHED/phy_procedures_lte_common.c
#${OPENAIR1_DIR}/SCHED_UE/phy_procedures_lte_ue.c
${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/lte_mcs.c
#${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/pmch_common.c
#${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_dl_cell_spec.c
#${OPENAIR1_DIR}/PHY/CODING/lte_segmentation.c
#${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/prach_common.c
# ${OPENAIR1_DIR}/PHY/INIT/lte_init_ue.c
${OPENAIR1_DIR}/PHY/CODING/crc_byte.c
${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c
${OPENAIR1_DIR}/PHY/CODING/viterbi.c
#${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/phich_common.c
${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation.c
# ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/dci_tools_common.c
# ${OPENAIR1_DIR}/PHY/CODING/lte_rate_matching.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte_lte.c
${OPENAIR1_DIR}/PHY/CODING/ccoding_byte.c
${OPENAIR1_DIR}/PHY/LTE_REFSIG/lte_gold.c
${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_est_freq_offset.c
${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_dl_channel_estimation.c
${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_ue_measurements.c
#${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c
#${OPENAIR1_DIR}/PHY/LTE_UE_TRANSPORT/dlsch_llr_computation_avx2.c
)
add_library( NR_LTE_UE_REUSE_LIB
${NR_LTE_UE_REUSE_SRC}
)
include_directories("${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE") include_directories("${OPENAIR2_DIR}/NR_UE_PHY_INTERFACE")
include_directories("${OPENAIR2_DIR}/LAYER2/NR_MAC_UE") include_directories("${OPENAIR2_DIR}/LAYER2/NR_MAC_UE")
...@@ -2368,7 +2337,7 @@ target_link_libraries (nr-softmodem ...@@ -2368,7 +2337,7 @@ target_link_libraries (nr-softmodem
-Wl,--start-group -Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB}
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2409,7 +2378,7 @@ target_link_libraries (nr-softmodem-nos1 ...@@ -2409,7 +2378,7 @@ target_link_libraries (nr-softmodem-nos1
-Wl,--start-group -Wl,--start-group
UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_RU LFDS GTPV1U SECU_CN SECU_OSA
${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${MIH_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${MIH_LIB}
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 L2_NR MAC_NR_COMMON
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2444,7 +2413,7 @@ add_executable(nr-uesoftmodem ...@@ -2444,7 +2413,7 @@ add_executable(nr-uesoftmodem
target_link_libraries (nr-uesoftmodem target_link_libraries (nr-uesoftmodem
-Wl,--start-group -Wl,--start-group
RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_RU LFDS NR_L2_UE #NR_LTE_UE_REUSE_LIB RRC_LIB NR_RRC_LIB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_RU LFDS NR_L2_UE MAC_NR_COMMON
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2478,7 +2447,7 @@ add_executable(nr-uesoftmodem-nos1 ...@@ -2478,7 +2447,7 @@ add_executable(nr-uesoftmodem-nos1
target_link_libraries (nr-uesoftmodem-nos1 target_link_libraries (nr-uesoftmodem-nos1
-Wl,--start-group -Wl,--start-group
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_UE PHY_RU LFDS NR_L2_UE RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_UE PHY_UE PHY_RU LFDS NR_L2_UE MAC_NR_COMMON
${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} ${MSC_LIB} ${RAL_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES}
-Wl,--end-group z dl) -Wl,--end-group z dl)
...@@ -2555,7 +2524,7 @@ add_executable(nr_dlsim ...@@ -2555,7 +2524,7 @@ add_executable(nr_dlsim
${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c
${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/backtrace.c
${T_SOURCE}) ${T_SOURCE})
target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl) target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_NR -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} dl)
foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
...@@ -2688,7 +2657,9 @@ L2 ...@@ -2688,7 +2657,9 @@ L2
L2_NR L2_NR
L2_UE L2_UE
NR_L2_UE NR_L2_UE
NR_LTE_UE_REUSE_LIB MAC_NR_COMMON
MAC_NR
MAC_UE_NR
CN_UTILS CN_UTILS
GTPV1U GTPV1U
SCTP_CLIENT SCTP_CLIENT
......
...@@ -31,12 +31,12 @@ typedef struct { ...@@ -31,12 +31,12 @@ typedef struct {
/*typedef struct { /*typedef struct {
nfapi_tl_t tl; nfapi_tl_t tl;
int64_t value; int64_t value;
} nfapi_int64_tlv_t; } nfapi_int64_tlv_t;*/
typedef struct { typedef struct {
nfapi_tl_t tl; nfapi_tl_t tl;
uint64_t value; uint64_t value;
} nfapi_uint64_tlv_t;*/ } nfapi_uint64_tlv_t;
// nFAPI enums // nFAPI enums
typedef enum { typedef enum {
...@@ -75,7 +75,7 @@ typedef struct ...@@ -75,7 +75,7 @@ typedef struct
// These TLVs are used by the VNF to configure the RF in the PNF // These TLVs are used by the VNF to configure the RF in the PNF
// nfapi_uint16_tlv_t max_transmit_power; // nfapi_uint16_tlv_t max_transmit_power;
nfapi_uint16_tlv_t nrarfcn; nfapi_uint32_tlv_t nrarfcn;
// nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands; // nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands;
// nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands; // nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands;
...@@ -178,8 +178,8 @@ typedef struct { ...@@ -178,8 +178,8 @@ typedef struct {
nfapi_uint16_tlv_t physical_cell_id; nfapi_uint16_tlv_t physical_cell_id;
nfapi_uint16_tlv_t half_frame_index; nfapi_uint16_tlv_t half_frame_index;
nfapi_uint16_tlv_t ssb_subcarrier_offset; nfapi_uint16_tlv_t ssb_subcarrier_offset;
nfapi_uint16_tlv_t ssb_sib1_position_in_burst; nfapi_uint16_tlv_t ssb_sib1_position_in_burst; // in sib1
nfapi_uint16_tlv_t ssb_scg_position_in_burst; nfapi_uint64_tlv_t ssb_scg_position_in_burst; // in servingcellconfigcommon
nfapi_uint16_tlv_t ssb_periodicity; nfapi_uint16_tlv_t ssb_periodicity;
nfapi_uint16_tlv_t ss_pbch_block_power; nfapi_uint16_tlv_t ss_pbch_block_power;
nfapi_uint16_tlv_t n_ssb_crb; nfapi_uint16_tlv_t n_ssb_crb;
......
...@@ -357,7 +357,9 @@ void install_schedule_handlers(IF_Module_t *if_inst) ...@@ -357,7 +357,9 @@ void install_schedule_handlers(IF_Module_t *if_inst)
/// this function is a temporary addition for NR configuration /// this function is a temporary addition for NR configuration
void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell) {
void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst) {
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
nfapi_nr_config_request_t *gNB_config = &gNB->gNB_config; nfapi_nr_config_request_t *gNB_config = &gNB->gNB_config;
//overwrite for new NR parameters //overwrite for new NR parameters
...@@ -372,15 +374,17 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu, ...@@ -372,15 +374,17 @@ void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,
gNB_config->sch_config.n_ssb_crb.value = (N_RB_DL-20); gNB_config->sch_config.n_ssb_crb.value = (N_RB_DL-20);
gNB_config->sch_config.ssb_subcarrier_offset.value = 0; gNB_config->sch_config.ssb_subcarrier_offset.value = 0;
gNB_config->sch_config.physical_cell_id.value=Nid_cell; gNB_config->sch_config.physical_cell_id.value=Nid_cell;
gNB_config->sch_config.ssb_scg_position_in_burst.value=position_in_burst;
gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED; gNB_config->subframe_config.dl_cyclic_prefix_type.value = (fp->Ncp == NORMAL) ? NFAPI_CP_NORMAL : NFAPI_CP_EXTENDED;
gNB->mac_enabled = 1; gNB->mac_enabled = 1;
fp->dl_CarrierFreq = from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value); fp->dl_CarrierFreq = 3500000000;//from_nrarfcn(gNB_config->nfapi_config.rf_bands.rf_band[0],gNB_config->nfapi_config.nrarfcn.value);
fp->ul_CarrierFreq = fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000); fp->ul_CarrierFreq = 3500000000;//fp->dl_CarrierFreq - (get_uldl_offset(gNB_config->nfapi_config.rf_bands.rf_band[0])*100000);
fp->threequarter_fs = 0; fp->threequarter_fs = 0;
nr_init_frame_parms(gNB_config, fp); nr_init_frame_parms(gNB_config, fp);
gNB->configured = 1; gNB->configured = 1;
LOG_I(PHY,"gNB configured\n"); LOG_I(PHY,"gNB configured\n");
} }
...@@ -398,6 +402,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { ...@@ -398,6 +402,7 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
gNB_config->sch_config.ssb_subcarrier_offset.value = phy_config->cfg->sch_config.ssb_subcarrier_offset.value;//0; gNB_config->sch_config.ssb_subcarrier_offset.value = phy_config->cfg->sch_config.ssb_subcarrier_offset.value;//0;
gNB_config->sch_config.n_ssb_crb.value = (phy_config->cfg->rf_config.dl_carrier_bandwidth.value-20); gNB_config->sch_config.n_ssb_crb.value = (phy_config->cfg->rf_config.dl_carrier_bandwidth.value-20);
gNB_config->sch_config.physical_cell_id.value = phy_config->cfg->sch_config.physical_cell_id.value; gNB_config->sch_config.physical_cell_id.value = phy_config->cfg->sch_config.physical_cell_id.value;
gNB_config->sch_config.ssb_scg_position_in_burst.value= phy_config->cfg->sch_config.ssb_scg_position_in_burst.value;
if (phy_config->cfg->subframe_config.duplex_mode.value == 0) { if (phy_config->cfg->subframe_config.duplex_mode.value == 0) {
gNB_config->subframe_config.duplex_mode.value = TDD; gNB_config->subframe_config.duplex_mode.value = TDD;
......
...@@ -27,6 +27,59 @@ uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, ...@@ -27,6 +27,59 @@ uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3,
uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 16, 32}; uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 16, 32};
int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index)
{
int mu = fp->numerology_index;
int symbol = 0;
uint8_t n, n_temp;
nr_ssb_type_e type = fp->ssb_type;
int case_AC[2] = {2,8};
int case_BD[4] = {4,8,16,20};
int case_E[8] = {8, 12, 16, 20, 32, 36, 40, 44};
switch(mu) {
case NR_MU_0: // case A
n = i_ssb >> 1;
symbol = case_AC[i_ssb % 2] + 14*n;
break;
case NR_MU_1:
if (type == 1){ // case B
n = i_ssb >> 2;
symbol = case_BD[i_ssb % 4] + 28*n;
}
if (type == 2){ // case C
n = i_ssb >> 1;
symbol = case_AC[i_ssb % 2] + 14*n;
}
break;
case NR_MU_3: // case D
n_temp = i_ssb >> 2;
n = n_temp + (n_temp >> 2);
symbol = case_BD[i_ssb % 4] + 28*n;
break;
case NR_MU_4: // case E
n_temp = i_ssb >> 3;
n = n_temp + (n_temp >> 2);
symbol = case_E[i_ssb % 8] + 56*n;
break;
default:
AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu);
}
if (half_frame_index)
symbol += (5 * fp->symbols_per_slot * fp->slots_per_subframe);
return symbol;
}
int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
int mu, int mu,
int Ncp, int Ncp,
...@@ -46,18 +99,29 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, ...@@ -46,18 +99,29 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
fp->numerology_index = mu; fp->numerology_index = mu;
fp->Ncp = Ncp; fp->Ncp = Ncp;
fp->N_RB_DL = N_RB_DL; fp->N_RB_DL = N_RB_DL;
switch(mu) { switch(mu) {
case NR_MU_0: //15kHz scs case NR_MU_0: //15kHz scs
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_0]; fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_0];
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_0]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_0];
fp->ssb_type = nr_ssb_type_A;
break; break;
case NR_MU_1: //30kHz scs case NR_MU_1: //30kHz scs
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_1]; fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_1];
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_1]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_1];
// selection of SS block pattern according to TS 38101-1 Table 5.4.3.3-1 for SCS 30kHz
if (fp->eutra_band == 5 || fp->eutra_band == 66)
fp->ssb_type = nr_ssb_type_B;
else{
if (fp->eutra_band == 41 || ( fp->eutra_band > 76 && fp->eutra_band < 80) )
fp->ssb_type = nr_ssb_type_C;
else
AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->eutra_band, mu);
}
switch(N_RB_DL){ switch(N_RB_DL){
case 11: case 11:
case 24: case 24:
...@@ -144,11 +208,13 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, ...@@ -144,11 +208,13 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
case NR_MU_3: case NR_MU_3:
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_3]; fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_3];
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_3]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_3];
fp->ssb_type = nr_ssb_type_D;
break; break;
case NR_MU_4: case NR_MU_4:
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_4]; fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_4];
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_4]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_4];
fp->ssb_type = nr_ssb_type_E;
break; break;
default: default:
...@@ -169,6 +235,16 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp, ...@@ -169,6 +235,16 @@ int nr_init_frame_parms0(NR_DL_FRAME_PARMS *fp,
fp->samples_per_frame = 10 * fp->samples_per_subframe; fp->samples_per_frame = 10 * fp->samples_per_subframe;
fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2; fp->freq_range = (fp->dl_CarrierFreq < 6e9)? nr_FR1 : nr_FR2;
// definition of Lmax according to ts 38.213 section 4.1
if (fp->dl_CarrierFreq < 6e9){
if(fp->frame_type && (fp->ssb_type==2))
fp->Lmax = (fp->dl_CarrierFreq < 2.4e9)? 4 : 8;
else
fp->Lmax = (fp->dl_CarrierFreq < 3e9)? 4 : 8;
}
else
fp->Lmax = 64;
// Initial bandwidth part configuration -- full carrier bandwidth // Initial bandwidth part configuration -- full carrier bandwidth
fp->initial_bwp_dl.bwp_id = 0; fp->initial_bwp_dl.bwp_id = 0;
fp->initial_bwp_dl.scs = fp->subcarrier_spacing; fp->initial_bwp_dl.scs = fp->subcarrier_spacing;
...@@ -184,7 +260,9 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config, ...@@ -184,7 +260,9 @@ int nr_init_frame_parms(nfapi_nr_config_request_t* config,
NR_DL_FRAME_PARMS *fp) NR_DL_FRAME_PARMS *fp)
{ {
fp->eutra_band = config->nfapi_config.rf_bands.rf_band[0];
fp->frame_type = !(config->subframe_config.duplex_mode.value);
fp->L_ssb = config->sch_config.ssb_scg_position_in_burst.value;
return nr_init_frame_parms0(fp, return nr_init_frame_parms0(fp,
config->subframe_config.numerology_index_mu.value, config->subframe_config.numerology_index_mu.value,
config->subframe_config.dl_cyclic_prefix_type.value, config->subframe_config.dl_cyclic_prefix_type.value,
...@@ -222,3 +300,6 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp) ...@@ -222,3 +300,6 @@ void nr_dump_frame_parms(NR_DL_FRAME_PARMS *fp)
LOG_I(PHY,"fp->initial_bwp_dl.location=%d\n",fp->initial_bwp_dl.location); LOG_I(PHY,"fp->initial_bwp_dl.location=%d\n",fp->initial_bwp_dl.location);
LOG_I(PHY,"fp->initial_bwp_dl.ofdm_symbol_size=%d\n",fp->initial_bwp_dl.ofdm_symbol_size); LOG_I(PHY,"fp->initial_bwp_dl.ofdm_symbol_size=%d\n",fp->initial_bwp_dl.ofdm_symbol_size);
} }
...@@ -376,6 +376,7 @@ void phy_config_request(PHY_Config_t *phy_config); ...@@ -376,6 +376,7 @@ void phy_config_request(PHY_Config_t *phy_config);
int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf); int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf);
void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms); void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms);
int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp, uint8_t i_ssb, uint8_t half_frame_index);
int nr_init_frame_parms(nfapi_nr_config_request_t* config, NR_DL_FRAME_PARMS *frame_parms); int nr_init_frame_parms(nfapi_nr_config_request_t* config, NR_DL_FRAME_PARMS *frame_parms);
int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,int mu,int Ncp,int N_RB_DL,int n_ssb_crb,int ssb_subcarrier_offset); int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *frame_parms,int mu,int Ncp,int N_RB_DL,int n_ssb_crb,int ssb_subcarrier_offset);
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,uint8_t abstraction_flag);
...@@ -383,13 +384,14 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag); ...@@ -383,13 +384,14 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag);
void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms); 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 abstraction_flag); int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char abstraction_flag);
void nr_phy_config_request(NR_PHY_Config_t *gNB); void nr_phy_config_request(NR_PHY_Config_t *gNB);
void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell); void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst);
void phy_free_nr_gNB(PHY_VARS_gNB *gNB); void phy_free_nr_gNB(PHY_VARS_gNB *gNB);
int l1_north_init_gNB(void); int l1_north_init_gNB(void);
void init_nr_transport(PHY_VARS_gNB *gNB); void init_nr_transport(PHY_VARS_gNB *gNB);
void init_dfts(void); void init_dfts(void);
/** @} */ /** @} */
#endif #endif
...@@ -53,8 +53,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -53,8 +53,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *phy_vars_ue,
unsigned char Ns, unsigned char Ns,
int sample_offset, int sample_offset,
int no_prefix, int no_prefix,
int reset_freq_est, NR_CHANNEL_EST_t channel);
NR_CHANNEL_EST_t channel);
int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue, int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
unsigned char l, unsigned char l,
......
...@@ -39,16 +39,22 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -39,16 +39,22 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
unsigned char Ns, unsigned char Ns,
int sample_offset, int sample_offset,
int no_prefix, int no_prefix,
int reset_freq_est,
NR_CHANNEL_EST_t channel) NR_CHANNEL_EST_t channel)
{ {
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
NR_UE_COMMON *common_vars = &ue->common_vars; NR_UE_COMMON *common_vars = &ue->common_vars;
uint8_t eNB_id = 0;//ue_common_vars->eNb_id;
unsigned char aa; unsigned char aa;
unsigned char symbol = l;//+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame unsigned char symbol = l;//+((7-frame_parms->Ncp)*(Ns&1)); ///symbol within sub-frame
unsigned int nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples); unsigned int nb_prefix_samples;
unsigned int nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0); unsigned int nb_prefix_samples0;
if (ue->is_synchronized) {
nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples0);
}
else {
nb_prefix_samples = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
nb_prefix_samples0 = (no_prefix ? 0 : frame_parms->nb_prefix_samples);
}
//unsigned int subframe_offset;//,subframe_offset_F; //unsigned int subframe_offset;//,subframe_offset_F;
unsigned int slot_offset; unsigned int slot_offset;
//int i; //int i;
...@@ -204,56 +210,17 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -204,56 +210,17 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
switch(channel){ switch(channel){
case NR_PBCH_EST: case NR_PBCH_EST:
#ifdef DEBUG_FEP
printf("Channel estimation eNB %d, slot %d, symbol %d\n",eNB_id,Ns,l);
#endif
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats);
#endif
nr_pbch_channel_estimation(ue,eNB_id,0,
Ns,
l,
symbol);
//}
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
// do frequency offset estimation here!
// use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1})
#ifdef DEBUG_FEP
printf("Frequency offset estimation\n");
#endif
if (l==(4-frame_parms->Ncp)) {
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_freq_offset_estimation_stats);
#endif
/*lte_est_freq_offset(common_vars->common_vars_rx_data_per_thread[ue->current_thread_id[Ns>>1]].dl_ch_estimates[0],
frame_parms,
l,
&common_vars->freq_offset,
reset_freq_est);*/
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_freq_offset_estimation_stats);
#endif
}
break; break;
case NR_PDCCH_EST: case NR_PDCCH_EST:
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
printf("PDCCH Channel estimation eNB %d, aatx %d, slot %d, symbol %d start_sc %d\n",eNB_id,aa,Ns,l,coreset_start_subcarrier); printf("PDCCH Channel estimation aatx %d, slot %d, symbol %d start_sc %d\n",aa,Ns,l,coreset_start_subcarrier);
#endif #endif
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
#endif #endif
nr_pdcch_channel_estimation(ue,eNB_id,0, nr_pdcch_channel_estimation(ue,0,
Ns, Ns,
l, l,
symbol, symbol,
...@@ -267,7 +234,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -267,7 +234,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
case NR_PDSCH_EST: case NR_PDSCH_EST:
#ifdef DEBUG_FEP #ifdef DEBUG_FEP
printf("Channel estimation eNB %d, aatx %d, slot %d, symbol %d\n",eNB_id,aa,Ns,l); printf("Channel estimation aatx %d, slot %d, symbol %d\n",aa,Ns,l);
#endif #endif
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
...@@ -276,7 +243,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue, ...@@ -276,7 +243,7 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
ue->frame_parms.nushift = (p>>1)&1;; ue->frame_parms.nushift = (p>>1)&1;;
if (symbol ==l0) if (symbol ==l0)
nr_pdsch_channel_estimation(ue,eNB_id,0, nr_pdsch_channel_estimation(ue,0,
Ns, Ns,
p, p,
l, l,
......
...@@ -32,13 +32,13 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB) ...@@ -32,13 +32,13 @@ void nr_init_pbch_dmrs(PHY_VARS_gNB* gNB)
Nid = cfg->sch_config.physical_cell_id.value; Nid = cfg->sch_config.physical_cell_id.value;
Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8; Lmax = fp->Lmax;
N_hf = (Lmax == 4)? 2:1; N_hf = (Lmax == 4)? 2:1;
for (n_hf = 0; n_hf < N_hf; n_hf++) { for (n_hf = 0; n_hf < N_hf; n_hf++) {
for (l = 0; l < Lmax ; l++) { for (l = 0; l < Lmax ; l++) {
i_ssb = l & (Lmax-1); i_ssb = l & (Lmax-1);
i_ssb2 = (i_ssb<<2) + n_hf; i_ssb2 = i_ssb + (n_hf<<2);
reset = 1; reset = 1;
x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3); x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3);
......
...@@ -29,15 +29,14 @@ void nr_gold_pbch(PHY_VARS_NR_UE* ue) ...@@ -29,15 +29,14 @@ void nr_gold_pbch(PHY_VARS_NR_UE* ue)
unsigned char Lmax, l, n_hf, N_hf; unsigned char Lmax, l, n_hf, N_hf;
Nid = ue->frame_parms.Nid_cell; Nid = ue->frame_parms.Nid_cell;
Lmax = ue->frame_parms.Lmax;
Lmax = 8; //(fp->dl_CarrierFreq < 3e9)? 4:8;
N_hf = (Lmax == 4)? 2:1; N_hf = (Lmax == 4)? 2:1;
for (n_hf = 0; n_hf < N_hf; n_hf++) { for (n_hf = 0; n_hf < N_hf; n_hf++) {
for (l = 0; l < Lmax ; l++) { for (l = 0; l < Lmax ; l++) {
i_ssb = l & (Lmax-1); i_ssb = l & (Lmax-1);
i_ssb2 = (i_ssb<<2) + n_hf; i_ssb2 = i_ssb + (n_hf<<2);
x1 = 1 + (1<<31); x1 = 1 + (1<<31);
x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3); x2 = (1<<11) * (i_ssb2 + 1) * ((Nid>>2) + 1) + (1<<6) * (i_ssb2 + 1) + (Nid&3);
......
...@@ -425,9 +425,11 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch, ...@@ -425,9 +425,11 @@ int nr_generate_pbch(NR_gNB_PBCH *pbch,
m++; m++;
} }
if (k >= frame_parms->ofdm_symbol_size) if (k >= frame_parms->ofdm_symbol_size)
k-=frame_parms->ofdm_symbol_size; k-=frame_parms->ofdm_symbol_size;
} }
return 0; return 0;
} }
...@@ -59,7 +59,6 @@ int nr_generate_pss( int16_t *d_pss, ...@@ -59,7 +59,6 @@ int nr_generate_pss( int16_t *d_pss,
/// Resource mapping /// Resource mapping
a = amp; a = amp;
// PSS occupies a predefined position (subcarriers 56-182, symbol 0) within the SSB block starting from // PSS occupies a predefined position (subcarriers 56-182, symbol 0) within the SSB block starting from
k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and k = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier + 56; //and
if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size; if (k>= frame_parms->ofdm_symbol_size) k-=frame_parms->ofdm_symbol_size;
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
\param symbol symbol within frame \param symbol symbol within frame
*/ */
int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
uint8_t eNB_id,
uint8_t eNB_offset, uint8_t eNB_offset,
unsigned char Ns, unsigned char Ns,
unsigned char l, unsigned char l,
...@@ -51,22 +50,30 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -51,22 +50,30 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
unsigned short coreset_start_subcarrier, unsigned short coreset_start_subcarrier,
unsigned short nb_rb_coreset); unsigned short nb_rb_coreset);
int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
uint8_t eNB_offset,
unsigned char Ns,
unsigned char symbol,
int dmrss,
NR_UE_SSB *current_ssb);
int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
uint8_t eNB_id, uint8_t eNB_offset,
uint8_t eNB_offset, unsigned char Ns,
unsigned char Ns, unsigned char symbol,
unsigned char l, int dmrss,
unsigned char symbol); uint8_t ssb_index,
uint8_t n_hf);
int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
uint8_t eNB_id,
uint8_t eNB_offset, uint8_t eNB_offset,
unsigned char Ns, unsigned char Ns,
unsigned short p, unsigned short p,
unsigned char l, unsigned char l,
unsigned char symbol, unsigned char symbol,
unsigned short bwp_start_subcarrier, unsigned short bwp_start_subcarrier,
unsigned short nb_rb_pdsch); unsigned short nb_rb_pdsch);
void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
......
...@@ -1418,27 +1418,25 @@ void nr_dci_decoding_procedure0(int s, ...@@ -1418,27 +1418,25 @@ void nr_dci_decoding_procedure0(int s,
*format_found=_format_2_3_found; *format_found=_format_2_3_found;
} }
#ifdef NR_PDCCH_DCI_DEBUG #ifdef NR_PDCCH_DCI_DEBUG
printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d\n",*format_found); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> format_found=%d\n",*format_found);
printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled); printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> crc_scrambled=%d\n",*crc_scrambled);
#endif #endif
if (*format_found!=255) { if (*format_found!=255) {
dci_alloc[*dci_cnt].dci_length = sizeof_bits; dci_alloc[*dci_cnt].dci_length = sizeof_bits;
dci_alloc[*dci_cnt].rnti = crc; dci_alloc[*dci_cnt].rnti = crc;
dci_alloc[*dci_cnt].L = L; dci_alloc[*dci_cnt].L = L;
dci_alloc[*dci_cnt].firstCCE = CCEind; dci_alloc[*dci_cnt].firstCCE = CCEind;
dci_alloc[*dci_cnt].dci_pdu[0] = dci_estimation[0]; memcpy(&dci_alloc[*dci_cnt].dci_pdu[0],dci_estimation,8);
dci_alloc[*dci_cnt].dci_pdu[1] = dci_estimation[1];
//dci_alloc[*dci_cnt].dci_pdu[2] = dci_estimation[2]; #ifdef NR_PDCCH_DCI_DEBUG
//dci_alloc[*dci_cnt].dci_pdu[3] = dci_estimation[3];
//#ifdef NR_PDCCH_DCI_DEBUG
printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> rnti matches -> DCI FOUND !!! crc =>0x%x, sizeof_bits %d, sizeof_bytes %d \n", printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> rnti matches -> DCI FOUND !!! crc =>0x%x, sizeof_bits %d, sizeof_bytes %d \n",
dci_alloc[*dci_cnt].rnti, dci_alloc[*dci_cnt].dci_length, sizeof_bytes); dci_alloc[*dci_cnt].rnti, dci_alloc[*dci_cnt].dci_length, sizeof_bytes);
printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> dci_cnt %d (format_css %d crc_scrambled %d) L %d, firstCCE %d pdu[0] 0x%lx pdu[1] 0x%lx \n", printf ("\t\t<-NR_PDCCH_DCI_DEBUG (nr_dci_decoding_procedure0)-> dci_cnt %d (format_css %d crc_scrambled %d) L %d, firstCCE %d pdu[0] 0x%lx pdu[1] 0x%lx \n",
*dci_cnt, format_css,*crc_scrambled,dci_alloc[*dci_cnt].L, dci_alloc[*dci_cnt].firstCCE,dci_alloc[*dci_cnt].dci_pdu[0],dci_alloc[*dci_cnt].dci_pdu[1]); *dci_cnt, format_css,*crc_scrambled,dci_alloc[*dci_cnt].L, dci_alloc[*dci_cnt].firstCCE,dci_alloc[*dci_cnt].dci_pdu[0],dci_alloc[*dci_cnt].dci_pdu[1]);
#endif
//#endif
if ((format_css == cformat0_0_and_1_0) || (format_uss == uformat0_0_and_1_0)) { if ((format_css == cformat0_0_and_1_0) || (format_uss == uformat0_0_and_1_0)) {
if ((*crc_scrambled == _p_rnti) || (*crc_scrambled == _si_rnti) || (*crc_scrambled == _ra_rnti)) { if ((*crc_scrambled == _p_rnti) || (*crc_scrambled == _si_rnti) || (*crc_scrambled == _ra_rnti)) {
dci_alloc[*dci_cnt].format = format1_0; dci_alloc[*dci_cnt].format = format1_0;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "PHY/INIT/phy_init.h" #include "PHY/INIT/phy_init.h"
#include "PHY/MODULATION/modulation_UE.h" #include "PHY/MODULATION/modulation_UE.h"
#include "nr_transport_proto_ue.h" #include "nr_transport_proto_ue.h"
#include "PHY/NR_UE_ESTIMATION/nr_estimation.h"
//#include "SCHED/defs.h" //#include "SCHED/defs.h"
//#include "SCHED/extern.h" //#include "SCHED/extern.h"
...@@ -52,61 +53,126 @@ int cnt=0; ...@@ -52,61 +53,126 @@ int cnt=0;
#define DEBUG_INITIAL_SYNCH #define DEBUG_INITIAL_SYNCH
int nr_pbch_detection(PHY_VARS_NR_UE *ue, runmode_t mode)
// create a new node of SSB structure
NR_UE_SSB* create_ssb_node(uint8_t i, uint8_t h) {
NR_UE_SSB *new_node = (NR_UE_SSB*)malloc(sizeof(NR_UE_SSB));
new_node->i_ssb = i;
new_node->n_hf = h;
new_node->c_re = 0;
new_node->c_im = 0;
new_node->metric = 0;
new_node->next_ssb = NULL;
return new_node;
}
// insertion of the structure in the ordered list (highest metric first)
NR_UE_SSB* insert_into_list(NR_UE_SSB *head, NR_UE_SSB *node) {
if (node->metric > head->metric) {
node->next_ssb = head;
head = node;
return head;
}
NR_UE_SSB *current = head;
while (current->next_ssb !=NULL) {
NR_UE_SSB *temp=current->next_ssb;
if(node->metric > temp->metric) {
node->next_ssb = temp;
current->next_ssb = node;
return head;
}
else
current = temp;
}
current->next_ssb = node;
return head;
}
void free_list(NR_UE_SSB *node) {
if (node->next_ssb != NULL)
free_list(node->next_ssb);
free(node);
}
int nr_pbch_detection(PHY_VARS_NR_UE *ue, int pbch_initial_symbol, runmode_t mode)
{ {
NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms=&ue->frame_parms;
int ret =-1; int ret =-1;
NR_UE_SSB *best_ssb = NULL;
NR_UE_SSB *current_ssb;
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"[UE%d] Initial sync: starting PBCH detection (rx_offset %d)\n",ue->Mod_id, LOG_I(PHY,"[UE%d] Initial sync: starting PBCH detection (rx_offset %d)\n",ue->Mod_id,
ue->rx_offset); ue->rx_offset);
#endif #endif
// save the nb_prefix_samples0 since we are not synchronized to subframes yet and the SSB has all symbols with nb_prefix_samples uint8_t N_L = (frame_parms->Lmax == 4)? 4:8;
int nb_prefix_samples0 = frame_parms->nb_prefix_samples0; uint8_t N_hf = (frame_parms->Lmax == 4)? 2:1;
frame_parms->nb_prefix_samples0 = frame_parms->nb_prefix_samples;
// loops over possible pbch dmrs cases to retrive best estimated i_ssb (and n_hf for Lmax=4) for multiple ssb detection
for (int hf = 0; hf < N_hf; hf++) {
for (int l = 0; l < N_L ; l++) {
// initialization of structure
current_ssb = create_ssb_node(l,hf);
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats);
#endif
// computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_dmrs_correlation(ue,0,0,i,i-pbch_initial_symbol,current_ssb);
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im+current_ssb->c_re;
// generate a list of SSB structures
if (best_ssb == NULL)
best_ssb = current_ssb;
else
best_ssb = insert_into_list(best_ssb,current_ssb);
}
}
NR_UE_SSB *temp_ptr=best_ssb;
while (ret!=0 && temp_ptr != NULL) {
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats);
#endif
// computing channel estimation for selected best ssb
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_channel_estimation(ue,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf);
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
ret = nr_rx_pbch(ue,
0,
ue->pbch_vars[0],
frame_parms,
0,
temp_ptr->i_ssb,
SISO,
ue->high_speed_flag);
temp_ptr=temp_ptr->next_ssb;
}
free_list(best_ssb);
//symbol 1
nr_slot_fep(ue,
1,
0,
ue->ssb_offset,
0,
1,
NR_PBCH_EST);
//symbol 2
nr_slot_fep(ue,
2,
0,
ue->ssb_offset,
0,
1,
NR_PBCH_EST);
//symbol 3
nr_slot_fep(ue,
3,
0,
ue->ssb_offset,
0,
1,
NR_PBCH_EST);
//put back nb_prefix_samples0
frame_parms->nb_prefix_samples0 = nb_prefix_samples0;
ret = nr_rx_pbch(ue,
0,
ue->pbch_vars[0],
frame_parms,
0,
SISO,
ue->high_speed_flag);
if (ret==0) { if (ret==0) {
...@@ -143,7 +209,7 @@ char prefix_string[2][9] = {"NORMAL","EXTENDED"}; ...@@ -143,7 +209,7 @@ char prefix_string[2][9] = {"NORMAL","EXTENDED"};
int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode)
{ {
int32_t sync_pos, sync_pos_slot; // k_ssb, N_ssb_crb, sync_pos2, int32_t sync_pos, sync_pos_frame; // k_ssb, N_ssb_crb, sync_pos2,
int32_t metric_tdd_ncp=0; int32_t metric_tdd_ncp=0;
uint8_t phase_tdd_ncp; uint8_t phase_tdd_ncp;
double im, re; double im, re;
...@@ -186,20 +252,17 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -186,20 +252,17 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode)
/* process pss search on received buffer */ /* process pss search on received buffer */
sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE); sync_pos = pss_synchro_nr(ue, NO_RATE_CHANGE);
sync_pos_slot = (fp->samples_per_subframe/fp->slots_per_subframe) - 10*(fp->ofdm_symbol_size + fp->nb_prefix_samples); if (sync_pos >= fp->nb_prefix_samples)
ue->ssb_offset = sync_pos - fp->nb_prefix_samples;
else
ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples;
if (sync_pos >= fp->nb_prefix_samples){
ue->ssb_offset = sync_pos - fp->nb_prefix_samples;}
else{
ue->ssb_offset = sync_pos + (fp->samples_per_subframe * 10) - fp->nb_prefix_samples;}
ue->rx_offset = ue->ssb_offset - sync_pos_slot;
//write_output("rxdata1.m","rxd1",ue->common_vars.rxdata[0],10*fp->samples_per_subframe,1,1); //write_output("rxdata1.m","rxd1",ue->common_vars.rxdata[0],10*fp->samples_per_subframe,1,1);
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id); LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id);
LOG_I(PHY,"sync_pos %d ssb_offset %d sync_pos_slot %d \n",sync_pos,ue->ssb_offset,sync_pos_slot); LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset);
#endif #endif
// digital compensation of FFO for SSB symbols // digital compensation of FFO for SSB symbols
...@@ -224,6 +287,23 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -224,6 +287,23 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode)
/* check that SSS/PBCH block is continuous inside the received buffer */ /* check that SSS/PBCH block is continuous inside the received buffer */
if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) { if (sync_pos < (NR_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_subframe - (NB_SYMBOLS_PBCH * fp->ofdm_symbol_size))) {
/* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */
/* for NR this is not the case but slot_fep is still used for computing FFT of samples */
/* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */
/* symbol number are from beginning of SS/PBCH blocks as below: */
/* Signal PSS PBCH SSS PBCH */
/* symbol number 0 1 2 3 */
/* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
/* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
for(int i=0; i<4;i++)
nr_slot_fep(ue,
i,
0,
ue->ssb_offset,
0,
NR_PBCH_EST);
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"Calling sss detection (normal CP)\n"); LOG_I(PHY,"Calling sss detection (normal CP)\n");
#endif #endif
...@@ -234,15 +314,22 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -234,15 +314,22 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode)
//nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0); //nr_init_frame_parms_ue(fp,NR_MU_1,NORMAL,n_ssb_crb,0);
nr_gold_pbch(ue); nr_gold_pbch(ue);
ret = nr_pbch_detection(ue,mode); ret = nr_pbch_detection(ue,1,mode); // start pbch detection at first symbol after pss
if (ret == 0) {
// sync at symbol ue->symbol_offset
// computing the offset wrt the beginning of the frame
sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
ue->rx_offset = ue->ssb_offset - sync_pos_frame;
}
nr_gold_pdcch(ue,0, 2); nr_gold_pdcch(ue,0, 2);
/* /*
int nb_prefix_samples0 = fp->nb_prefix_samples0; int nb_prefix_samples0 = fp->nb_prefix_samples0;
fp->nb_prefix_samples0 = fp->nb_prefix_samples; fp->nb_prefix_samples0 = fp->nb_prefix_samples;
nr_slot_fep(ue,0, 0, ue->ssb_offset, 0, 1, NR_PDCCH_EST); nr_slot_fep(ue,0, 0, ue->ssb_offset, 0, NR_PDCCH_EST);
nr_slot_fep(ue,1, 0, ue->ssb_offset, 0, 1, NR_PDCCH_EST); nr_slot_fep(ue,1, 0, ue->ssb_offset, 0, NR_PDCCH_EST);
fp->nb_prefix_samples0 = nb_prefix_samples0; fp->nb_prefix_samples0 = nb_prefix_samples0;
LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n", LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n",
...@@ -259,7 +346,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode) ...@@ -259,7 +346,7 @@ int nr_initial_sync(PHY_VARS_NR_UE *ue, runmode_t mode)
} }
else { else {
#ifdef DEBUG_INITIAL_SYNCH #ifdef DEBUG_INITIAL_SYNCH
LOG_I(PHY,"TDD Normal prefix: SSS error condition: sync_pos %d, sync_pos_slot %d\n", sync_pos, sync_pos_slot); LOG_I(PHY,"TDD Normal prefix: SSS error condition: sync_pos %d\n", sync_pos);
#endif #endif
} }
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "PHY/phy_extern_nr_ue.h" #include "PHY/phy_extern_nr_ue.h"
#include "PHY/sse_intrin.h" #include "PHY/sse_intrin.h"
#include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/LTE_REFSIG/lte_refsig.h"
#include "PHY/INIT/phy_init.h"
//#define DEBUG_PBCH 1 //#define DEBUG_PBCH 1
//#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_ENCODING
...@@ -413,6 +414,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -413,6 +414,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
NR_UE_PBCH *nr_ue_pbch_vars, NR_UE_PBCH *nr_ue_pbch_vars,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint8_t eNB_id, uint8_t eNB_id,
uint8_t i_ssb,
MIMO_mode_t mimo_mode, MIMO_mode_t mimo_mode,
uint32_t high_speed_flag) { uint32_t high_speed_flag) {
NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars;
...@@ -423,10 +425,9 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -423,10 +425,9 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
//uint32_t pbch_a_prime; //uint32_t pbch_a_prime;
int16_t *pbch_e_rx; int16_t *pbch_e_rx;
uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output; uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output;
uint8_t nushift; uint8_t nushift,n_hf,ssb_index;
uint16_t M; uint16_t M;
uint8_t Lmax=8; //to update uint8_t Lmax=frame_parms->Lmax;
uint8_t ssb_index=0;
//uint16_t crc; //uint16_t crc;
//unsigned short idx_demod =0; //unsigned short idx_demod =0;
uint32_t decoderState=0; uint32_t decoderState=0;
...@@ -442,7 +443,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -442,7 +443,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
int symbol_offset=1; int symbol_offset=1;
if (ue->is_synchronized > 0) if (ue->is_synchronized > 0)
symbol_offset=4; symbol_offset=ue->symbol_offset;
else else
symbol_offset=0; symbol_offset=0;
...@@ -526,7 +527,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -526,7 +527,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
#endif #endif
//un-scrambling //un-scrambling
M = NR_POLAR_PBCH_E; M = NR_POLAR_PBCH_E;
nushift = (Lmax==4)? ssb_index&3 : ssb_index&7; nushift = (Lmax==4)? i_ssb&3 : i_ssb&7;
uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041; uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041;
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0); nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0);
//polar decoding de-rate matching //polar decoding de-rate matching
...@@ -570,6 +571,16 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -570,6 +571,16 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
for (int i=0; i<3; i++) for (int i=0; i<3; i++)
decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
n_hf = ((xtra_byte>>4)&0x01); // computing the half frame index from the extra byte
ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8
if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte
for (int i=0; i<3; i++)
ssb_index += (((xtra_byte>>(7-i))&0x01)<<(3+i));
}
ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf);
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("xtra_byte %x payload %x\n", xtra_byte, payload); printf("xtra_byte %x payload %x\n", xtra_byte, payload);
...@@ -577,14 +588,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -577,14 +588,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
// printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); // printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]);
printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]); printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]);
} }
#endif #endif
ue->dl_indication.rx_ind = &ue->rx_ind; // hang on rx_ind instance ue->dl_indication.rx_ind = &ue->rx_ind; // hang on rx_ind instance
//ue->rx_ind.sfn_slot = 0; //should be set by higher-1-layer, i.e. clean_and_set_if_instance() //ue->rx_ind.sfn_slot = 0; //should be set by higher-1-layer, i.e. clean_and_set_if_instance()
ue->rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_MIB; ue->rx_ind.rx_indication_body[0].pdu_type = FAPI_NR_RX_PDU_TYPE_MIB;
ue->rx_ind.rx_indication_body[0].mib_pdu.pdu = &decoded_output[0]; ue->rx_ind.rx_indication_body[0].mib_pdu.pdu = &decoded_output[0];
ue->rx_ind.rx_indication_body[0].mib_pdu.additional_bits = xtra_byte; ue->rx_ind.rx_indication_body[0].mib_pdu.additional_bits = xtra_byte;
ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index = ssb_index; // confirm with TCL ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index = i_ssb; // confirm with TCL
ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_length = Lmax; // confirm with TCL ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_length = Lmax; // confirm with TCL
ue->rx_ind.rx_indication_body[0].mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL ue->rx_ind.rx_indication_body[0].mib_pdu.cell_id = frame_parms->Nid_cell; // confirm with TCL
ue->rx_ind.number_pdus = 1; ue->rx_ind.number_pdus = 1;
......
...@@ -1122,9 +1122,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -1122,9 +1122,14 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
NR_UE_PBCH *nr_ue_pbch_vars, NR_UE_PBCH *nr_ue_pbch_vars,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint8_t eNB_id, uint8_t eNB_id,
uint8_t i_ssb,
MIMO_mode_t mimo_mode, MIMO_mode_t mimo_mode,
uint32_t high_speed_flag); uint32_t high_speed_flag);
int nr_pbch_detection(PHY_VARS_NR_UE *ue,
int pbch_initial_symbol,
runmode_t mode);
uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue, uint16_t rx_pbch_emul(PHY_VARS_NR_UE *phy_vars_ue,
uint8_t eNB_id, uint8_t eNB_id,
uint8_t pbch_phase); uint8_t pbch_phase);
......
...@@ -898,7 +898,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -898,7 +898,8 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
} }
if (fo_flag){ if (fo_flag){
// fractional frequency offser computation according to Cross-correlation Synchronization Algorithm Using PSS
// fractional frequency offset computation according to Cross-correlation Synchronization Algorithm Using PSS
// Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012. // Shoujun Huang, Yongtao Su, Ying He and Shan Tang, "Joint time and frequency offset estimation in LTE downlink," 7th International Conference on Communications and Networking in China, 2012.
int64_t result1,result2; int64_t result1,result2;
...@@ -922,7 +923,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -922,7 +923,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
// estimation of fractional frequency offset: angle[(result1)'*(result2)]/pi // estimation of fractional frequency offset: angle[(result1)'*(result2)]/pi
ffo_est=atan2(re1*im2-re2*im1,re1*re2+im1*im2)/M_PI; ffo_est=atan2(re1*im2-re2*im1,re1*re2+im1*im2)/M_PI;
#ifdef DBG_PSS_NR #ifdef DBG_PSS_NR
printf("ffo %lf\n",ffo_est); printf("ffo %lf\n",ffo_est);
#endif #endif
......
...@@ -430,39 +430,6 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric,uint8_t *phase_max) ...@@ -430,39 +430,6 @@ int rx_sss_nr(PHY_VARS_NR_UE *ue, int32_t *tot_metric,uint8_t *phase_max)
int32_t metric, metric_re; int32_t metric, metric_re;
int16_t *d; int16_t *d;
/* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */
/* for NR this is not the case but slot_fep is still used for computing FFT of samples */
/* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */
/* symbol number are from beginning of SS/PBCH blocks as below: */
/* Signal PSS PBCH SSS PBCH */
/* symbol number 0 1 2 3 */
/* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
/* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
int nb_prefix_samples0 = frame_parms->nb_prefix_samples0;
// For now, symbol 0 = PSS/PBCH and it is never in symbol 0 or 7*2^mu (i.e. always shorter prefix)
frame_parms->nb_prefix_samples0 = frame_parms->nb_prefix_samples;
// Do FFTs for SSS/PSS
// SSS
nr_slot_fep(ue,
SSS_SYMBOL_NB-PSS_SYMBOL_NB, // symbol number w.r.t. PSS
0, // Ns slot number
ue->ssb_offset, // sample_offset of int16_t
0, // no_prefix
1, // reset frequency estimation
NR_SSS_EST);
// PSS
nr_slot_fep(ue,
0,
0,
ue->ssb_offset,
0,
1,
NR_SSS_EST);
frame_parms->nb_prefix_samples0 = nb_prefix_samples0;
// pss sss extraction // pss sss extraction
pss_sss_extract_nr(ue, pss_sss_extract_nr(ue,
......
...@@ -950,6 +950,16 @@ typedef struct { ...@@ -950,6 +950,16 @@ typedef struct {
int16_t *prach; int16_t *prach;
} NR_UE_PRACH; } NR_UE_PRACH;
// structure used for multiple SSB detection
typedef struct NR_UE_SSB {
uint8_t i_ssb; // i_ssb between 0 and 7 (it corresponds to ssb_index only for Lmax=4,8)
uint8_t n_hf; // n_hf = 0,1 for Lmax =4 or n_hf = 0 for Lmax =8,64
uint32_t metric; // metric to order SSB hypothesis
uint32_t c_re;
uint32_t c_im;
struct NR_UE_SSB *next_ssb;
} NR_UE_SSB;
/*typedef enum { /*typedef enum {
/// do not detect any DCIs in the current subframe /// do not detect any DCIs in the current subframe
NO_DCI = 0x0, NO_DCI = 0x0,
...@@ -1143,6 +1153,7 @@ typedef struct { ...@@ -1143,6 +1153,7 @@ typedef struct {
uint8_t decode_MIB; uint8_t decode_MIB;
/// temporary offset during cell search prior to MIB decoding /// temporary offset during cell search prior to MIB decoding
int ssb_offset; int ssb_offset;
uint16_t symbol_offset; // offset in terms of symbols for detected ssb in sync
int rx_offset; /// Timing offset int rx_offset; /// Timing offset
int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP
int time_sync_cell; int time_sync_cell;
...@@ -1307,6 +1318,7 @@ typedef struct { ...@@ -1307,6 +1318,7 @@ typedef struct {
} PHY_VARS_NR_UE; } PHY_VARS_NR_UE;
/* this structure is used to pass both UE phy vars and /* this structure is used to pass both UE phy vars and
* proc to the function UE_thread_rxn_txnp4 * proc to the function UE_thread_rxn_txnp4
*/ */
......
...@@ -303,11 +303,15 @@ typedef struct NR_DL_FRAME_PARMS { ...@@ -303,11 +303,15 @@ typedef struct NR_DL_FRAME_PARMS {
/// TDD configuration /// TDD configuration
uint16_t tdd_uplink_nr[2*NR_MAX_SLOTS_PER_FRAME]; /* this is a bitmap of symbol of each slot given for 2 frames */ uint16_t tdd_uplink_nr[2*NR_MAX_SLOTS_PER_FRAME]; /* this is a bitmap of symbol of each slot given for 2 frames */
//SSB related params //SSB related params
/// Start in Subcarrier index of the SSB block /// Start in Subcarrier index of the SSB block
uint16_t ssb_start_subcarrier; uint16_t ssb_start_subcarrier;
/// SSB type /// SSB type
nr_ssb_type_e ssb_type; nr_ssb_type_e ssb_type;
/// Max number of SSB in frame
uint8_t Lmax;
/// SS block pattern (max 64 ssb, each bit is on/off ssb)
uint64_t L_ssb;
/// PBCH polar encoder params /// PBCH polar encoder params
t_nrPolar_params pbch_polar_params; t_nrPolar_params pbch_polar_params;
...@@ -317,5 +321,23 @@ typedef struct NR_DL_FRAME_PARMS { ...@@ -317,5 +321,23 @@ typedef struct NR_DL_FRAME_PARMS {
} NR_DL_FRAME_PARMS; } NR_DL_FRAME_PARMS;
#define KHz (1000UL)
#define MHz (1000*KHz)
typedef struct nr_bandentry_s {
int16_t band;
uint64_t ul_min;
uint64_t ul_max;
uint64_t dl_min;
uint64_t dl_max;
uint64_t N_OFFs_DL;
uint64_t step_size;
} nr_bandentry_t;
typedef struct nr_band_info_s {
int nbands;
nr_bandentry_t band_info[100];
} nr_band_info_t;
#endif #endif
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "SCHED/fapi_l1.h" #include "SCHED/fapi_l1.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/vcd_signal_dumper.h"
#include "PHY/INIT/phy_init.h"
#include "T.h" #include "T.h"
...@@ -76,37 +77,7 @@ int return_ssb_type(nfapi_config_request_t *cfg) ...@@ -76,37 +77,7 @@ int return_ssb_type(nfapi_config_request_t *cfg)
}*/ }*/
// First SSB starting symbol candidate is used and type B is chosen for 30kHz SCS
int nr_get_ssb_start_symbol(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) {
int mu = cfg->subframe_config.numerology_index_mu.value;
int symbol = 0;
switch(mu) {
case NR_MU_0:
symbol = 2;
break;
case NR_MU_1: // case B
symbol = 4;
break;
case NR_MU_3:
symbol = 4;
break;
case NR_MU_4:
symbol = 8;
break;
default:
AssertFatal(0==1, "Invalid numerology index %d for the synchronization block\n", mu);
}
if (cfg->sch_config.half_frame_index.value)
symbol += (5 * fp->symbols_per_slot * fp->slots_per_subframe);
return symbol;
}
void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) { void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PARMS *fp) {
fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<<cfg->subframe_config.numerology_index_mu.value); fp->ssb_start_subcarrier = (12 * cfg->sch_config.n_ssb_crb.value + cfg->sch_config.ssb_subcarrier_offset.value)/(1<<cfg->subframe_config.numerology_index_mu.value);
...@@ -118,36 +89,43 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) { ...@@ -118,36 +89,43 @@ void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot) {
nfapi_nr_config_request_t *cfg = &gNB->gNB_config; nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
int **txdataF = gNB->common_vars.txdataF; int **txdataF = gNB->common_vars.txdataF;
uint8_t *pbch_pdu=&gNB->pbch_pdu[0]; uint8_t *pbch_pdu=&gNB->pbch_pdu[0];
int ss_slot = (cfg->sch_config.half_frame_index.value)? 10 : 0; uint8_t ssb_index, n_hf;
uint8_t Lmax, ssb_index=0, n_hf=0; int ssb_start_symbol, rel_slot;
LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot);
int ssb_start_symbol = nr_get_ssb_start_symbol(cfg, fp);
nr_set_ssb_first_subcarrier(cfg, fp);
Lmax = (fp->dl_CarrierFreq < 3e9)? 4:8;
if (slot == ss_slot) {
// Current implementation is based on SSB in first half frame, first candidate
LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol);
nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp);
if (!(frame&7)) { n_hf = cfg->sch_config.half_frame_index.value;
LOG_D(PHY,"%d.%d : pbch_configured %d\n",frame,slot,gNB->pbch_configured); // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be
rel_slot = (n_hf)? (slot-10) : slot;
if (gNB->pbch_configured != 1)return;
LOG_D(PHY,"common_signal_procedures: frame %d, slot %d\n",frame,slot);
gNB->pbch_configured = 0;
}
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp); if(rel_slot<10 && rel_slot>=0) {
nr_generate_pbch(&gNB->pbch, for (int i=0; i<2; i++) { // max two SSB per frame
pbch_pdu,
gNB->nr_pbch_interleaver, ssb_index = i + 2*rel_slot; // computing the ssb_index
txdataF[0], if ((fp->L_ssb >> ssb_index) & 0x01) { // generating the ssb only if the bit of L_ssb at current ssb index is 1
AMP,
ssb_start_symbol, int ssb_start_symbol_abs = nr_get_ssb_start_symbol(fp, ssb_index, n_hf); // computing the starting symbol for current ssb
n_hf,Lmax,ssb_index, ssb_start_symbol = ssb_start_symbol_abs % 14; // start symbol wrt slot
frame, cfg, fp);
nr_set_ssb_first_subcarrier(cfg, fp); // setting the first subcarrier
LOG_D(PHY,"SS TX: frame %d, slot %d, start_symbol %d\n",frame,slot, ssb_start_symbol);
nr_generate_pss(gNB->d_pss, txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_sss(gNB->d_sss, txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_pbch_dmrs(gNB->nr_gold_pbch_dmrs[n_hf][ssb_index],txdataF[0], AMP, ssb_start_symbol, cfg, fp);
nr_generate_pbch(&gNB->pbch,
pbch_pdu,
gNB->nr_pbch_interleaver,
txdataF[0],
AMP,
ssb_start_symbol,
n_hf,fp->Lmax,ssb_index,
frame, cfg, fp);
}
}
} }
} }
......
...@@ -2942,6 +2942,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t * ...@@ -2942,6 +2942,7 @@ void nr_ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *
ue->pbch_vars[eNB_id], ue->pbch_vars[eNB_id],
&ue->frame_parms, &ue->frame_parms,
eNB_id, eNB_id,
ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index,
SISO, SISO,
ue->high_speed_flag); ue->high_speed_flag);
...@@ -4961,7 +4962,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ...@@ -4961,7 +4962,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN
nr_tti_rx, nr_tti_rx,
0, 0,
0, 0,
1,
NR_PDCCH_EST); NR_PDCCH_EST);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
...@@ -5006,7 +5006,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ...@@ -5006,7 +5006,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN
nr_tti_rx, nr_tti_rx,
0, 0,
0, 0,
1,
NR_PDSCH_EST); NR_PDSCH_EST);
//printf("phy procedure pdsch start measurement\n"); //printf("phy procedure pdsch start measurement\n");
...@@ -5084,15 +5083,27 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN ...@@ -5084,15 +5083,27 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN
if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1)) if ( (nr_tti_rx == 0) && (ue->decode_MIB == 1))
{ {
LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_tti_rx);
for (int i=0; i<3; i++)
uint8_t i_ssb = ue->rx_ind.rx_indication_body[0].mib_pdu.ssb_index;
uint8_t n_hf = (((ue->rx_ind.rx_indication_body[0].mib_pdu.additional_bits)>>4)&0x01);
for (int i=1; i<4; i++) {
nr_slot_fep(ue, nr_slot_fep(ue,
(5+i), //mu=1 case B (ue->symbol_offset+i), //mu=1 case B
nr_tti_rx, nr_tti_rx,
0, 0,
0, 0,
1,
NR_PBCH_EST); NR_PBCH_EST);
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats);
#endif
nr_pbch_channel_estimation(ue,0,0,ue->symbol_offset+i,i-1,i_ssb,n_hf);
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
}
nr_ue_pbch_procedures(eNB_id,ue,proc,0); nr_ue_pbch_procedures(eNB_id,ue,proc,0);
} }
......
...@@ -160,7 +160,7 @@ int main(int argc, char **argv) { ...@@ -160,7 +160,7 @@ int main(int argc, char **argv) {
//int run_initial_sync=0; //int run_initial_sync=0;
int loglvl = OAILOG_WARNING; int loglvl = OAILOG_WARNING;
float target_error_rate = 0.01; float target_error_rate = 0.01;
uint64_t SSB_positions=0x01;
uint16_t nb_symb_sch = 12; uint16_t nb_symb_sch = 12;
uint16_t nb_rb = 50; uint16_t nb_rb = 50;
uint8_t Imcs = 9; uint8_t Imcs = 9;
...@@ -174,7 +174,7 @@ int main(int argc, char **argv) { ...@@ -174,7 +174,7 @@ int main(int argc, char **argv) {
//logInit(); //logInit();
randominit(0); randominit(0);
while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:N:F:R:P:")) != -1) { while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) {
switch (c) { switch (c) {
case 'f': case 'f':
write_output_file = 1; write_output_file = 1;
...@@ -285,6 +285,10 @@ int main(int argc, char **argv) { ...@@ -285,6 +285,10 @@ int main(int argc, char **argv) {
break; break;
case 'M':
SSB_positions = atoi(optarg);
break;
case 'N': case 'N':
Nid_cell = atoi(optarg); Nid_cell = atoi(optarg);
break; break;
...@@ -343,6 +347,7 @@ int main(int argc, char **argv) { ...@@ -343,6 +347,7 @@ int main(int argc, char **argv) {
printf("-z Number of RX antennas used in UE\n"); printf("-z Number of RX antennas used in UE\n");
printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n");
printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n"); printf("-N Nid_cell\n");
printf("-R N_RB_DL\n"); printf("-R N_RB_DL\n");
printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-O oversampling factor (1,2,4,8,16)\n");
...@@ -383,7 +388,7 @@ int main(int argc, char **argv) { ...@@ -383,7 +388,7 @@ int main(int argc, char **argv) {
frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_DL = N_RB_DL;
frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL;
crcTableInit(); crcTableInit();
nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell); nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell,SSB_positions);
phy_init_nr_gNB(gNB, 0, 0); phy_init_nr_gNB(gNB, 0, 0);
//init_eNB_afterRU(); //init_eNB_afterRU();
frame_length_complex_samples = frame_parms->samples_per_subframe; frame_length_complex_samples = frame_parms->samples_per_subframe;
......
...@@ -101,7 +101,9 @@ int rrc_init_nr_global_param(void){return(0);} ...@@ -101,7 +101,9 @@ int rrc_init_nr_global_param(void){return(0);}
void config_common(int Mod_idP, void config_common(int Mod_idP,
int CC_idP, int CC_idP,
int Nid_cell,
int nr_bandP, int nr_bandP,
uint64_t ssb_pattern,
uint64_t dl_CarrierFreqP, uint64_t dl_CarrierFreqP,
uint32_t dl_BandwidthP uint32_t dl_BandwidthP
); );
...@@ -134,6 +136,7 @@ int main(int argc, char **argv) ...@@ -134,6 +136,7 @@ int main(int argc, char **argv)
int trial,n_trials=1,n_errors,n_errors2,n_alamouti; int trial,n_trials=1,n_errors,n_errors2,n_alamouti;
uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint8_t transmission_mode = 1,n_tx=1,n_rx=1;
uint16_t Nid_cell=0; uint16_t Nid_cell=0;
uint64_t SSB_positions=0x01;
channel_desc_t *gNB2UE; channel_desc_t *gNB2UE;
uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0; uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
...@@ -151,6 +154,8 @@ int main(int argc, char **argv) ...@@ -151,6 +154,8 @@ int main(int argc, char **argv)
int pbch_tx_ant; int pbch_tx_ant;
int N_RB_DL=273,mu=1; int N_RB_DL=273,mu=1;
uint64_t ssb_pattern = 0x01;
unsigned char frame_type = 0; unsigned char frame_type = 0;
unsigned char pbch_phase = 0; unsigned char pbch_phase = 0;
...@@ -182,7 +187,7 @@ int main(int argc, char **argv) ...@@ -182,7 +187,7 @@ int main(int argc, char **argv)
randominit(0); randominit(0);
while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:N:F:GR:dP:IL:")) != -1) { while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) {
switch (c) { switch (c) {
case 'f': case 'f':
write_output_file=1; write_output_file=1;
...@@ -309,6 +314,10 @@ int main(int argc, char **argv) ...@@ -309,6 +314,10 @@ int main(int argc, char **argv)
break; break;
case 'M':
SSB_positions = atoi(optarg);
break;
case 'N': case 'N':
Nid_cell = atoi(optarg); Nid_cell = atoi(optarg);
break; break;
...@@ -361,6 +370,7 @@ int main(int argc, char **argv) ...@@ -361,6 +370,7 @@ int main(int argc, char **argv)
printf("-z Number of RX antennas used in UE\n"); printf("-z Number of RX antennas used in UE\n");
printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n");
printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n"); printf("-N Nid_cell\n");
printf("-R N_RB_DL\n"); printf("-R N_RB_DL\n");
printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-O oversampling factor (1,2,4,8,16)\n");
...@@ -396,7 +406,7 @@ int main(int argc, char **argv) ...@@ -396,7 +406,7 @@ int main(int argc, char **argv)
frame_parms->N_RB_UL = N_RB_DL; frame_parms->N_RB_UL = N_RB_DL;
// stub to configure frame_parms // stub to configure frame_parms
nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell); nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
// call MAC to configure common parameters // call MAC to configure common parameters
phy_init_nr_gNB(gNB,0,0); phy_init_nr_gNB(gNB,0,0);
...@@ -499,7 +509,7 @@ int main(int argc, char **argv) ...@@ -499,7 +509,7 @@ int main(int argc, char **argv)
mac_top_init_gNB(); mac_top_init_gNB();
gNB_mac = RC.nrmac[0]; gNB_mac = RC.nrmac[0];
config_common(0,0,78,(uint64_t)3640000000L,N_RB_DL); config_common(0,0,Nid_cell,78,ssb_pattern,(uint64_t)3640000000L,N_RB_DL);
config_nr_mib(0,0,1,kHz30,0,0,0,0); config_nr_mib(0,0,1,kHz30,0,0,0,0);
nr_l2_init_ue(); nr_l2_init_ue();
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "PHY/INIT/phy_init.h" #include "PHY/INIT/phy_init.h"
#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/NR_TRANSPORT/nr_transport.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
#include "PHY/NR_UE_ESTIMATION/nr_estimation.h"
#include "SCHED_NR/sched_nr.h" #include "SCHED_NR/sched_nr.h"
...@@ -105,6 +106,7 @@ int main(int argc, char **argv) ...@@ -105,6 +106,7 @@ int main(int argc, char **argv)
int trial,n_trials=1,n_errors=0,n_errors_payload=0; int trial,n_trials=1,n_errors=0,n_errors_payload=0;
uint8_t transmission_mode = 1,n_tx=1,n_rx=1; uint8_t transmission_mode = 1,n_tx=1,n_rx=1;
uint16_t Nid_cell=0; uint16_t Nid_cell=0;
uint64_t SSB_positions=0x01;
channel_desc_t *gNB2UE; channel_desc_t *gNB2UE;
...@@ -127,7 +129,7 @@ int main(int argc, char **argv) ...@@ -127,7 +129,7 @@ int main(int argc, char **argv)
unsigned char frame_type = 0; unsigned char frame_type = 0;
unsigned char pbch_phase = 0; unsigned char pbch_phase = 0;
int frame=0,subframe=0; int frame=0;
int frame_length_complex_samples; int frame_length_complex_samples;
int frame_length_complex_samples_no_prefix; int frame_length_complex_samples_no_prefix;
NR_DL_FRAME_PARMS *frame_parms; NR_DL_FRAME_PARMS *frame_parms;
...@@ -148,7 +150,7 @@ int main(int argc, char **argv) ...@@ -148,7 +150,7 @@ int main(int argc, char **argv)
randominit(0); randominit(0);
while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:o:s:S:t:x:y:z:N:F:GR:dP:IL:")) != -1) { while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:o:s:S:t:x:y:z:M:N:F:GR:dP:IL:")) != -1) {
switch (c) { switch (c) {
case 'f': case 'f':
write_output_file=1; write_output_file=1;
...@@ -280,6 +282,10 @@ int main(int argc, char **argv) ...@@ -280,6 +282,10 @@ int main(int argc, char **argv)
break; break;
case 'M':
SSB_positions = atoi(optarg);
break;
case 'N': case 'N':
Nid_cell = atoi(optarg); Nid_cell = atoi(optarg);
break; break;
...@@ -333,6 +339,7 @@ int main(int argc, char **argv) ...@@ -333,6 +339,7 @@ int main(int argc, char **argv)
printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n"); printf("-i Relative strength of first intefering eNB (in dB) - cell_id mod 3 = 1\n");
printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n"); printf("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-o Carrier frequency offset in Hz\n"); printf("-o Carrier frequency offset in Hz\n");
printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n"); printf("-N Nid_cell\n");
printf("-R N_RB_DL\n"); printf("-R N_RB_DL\n");
printf("-O oversampling factor (1,2,4,8,16)\n"); printf("-O oversampling factor (1,2,4,8,16)\n");
...@@ -365,33 +372,39 @@ int main(int argc, char **argv) ...@@ -365,33 +372,39 @@ int main(int argc, char **argv)
frame_parms->N_RB_DL = N_RB_DL; frame_parms->N_RB_DL = N_RB_DL;
frame_parms->N_RB_UL = N_RB_DL; frame_parms->N_RB_UL = N_RB_DL;
frame_parms->Nid_cell = Nid_cell; frame_parms->Nid_cell = Nid_cell;
frame_parms->nushift = Nid_cell%4;
frame_parms->ssb_type = nr_ssb_type_C;
nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell); nr_phy_config_request_sim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions);
phy_init_nr_gNB(gNB,0,0); phy_init_nr_gNB(gNB,0,0);
double fs,bw,scs,eps; uint8_t n_hf = gNB_config->sch_config.half_frame_index.value;
if (mu == 1 && N_RB_DL == 217) { double fs,bw,scs,eps;
fs = 122.88e6;
bw = 80e6; switch (mu) {
scs = 30000; case 1:
} scs = 30000;
else if (mu == 1 && N_RB_DL == 245) { if (N_RB_DL == 217) {
fs = 122.88e6; fs = 122.88e6;
bw = 90e6; bw = 80e6;
scs = 30000;
} }
else if (mu == 1 && N_RB_DL == 273) { else if (N_RB_DL == 245) {
fs = 122.88e6; fs = 122.88e6;
bw = 100e6; bw = 90e6;
scs = 30000; }
} else if (N_RB_DL == 273) {
else if (mu == 1 && N_RB_DL == 106) { fs = 122.88e6;
fs = 61.44e6; bw = 100e6;
bw = 40e6; }
scs = 30000; else if (N_RB_DL == 106) {
fs = 61.44e6;
bw = 40e6;
}
else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
break;
} }
else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
// cfo with respect to sub-carrier spacing // cfo with respect to sub-carrier spacing
eps = cfo/scs; eps = cfo/scs;
...@@ -476,31 +489,38 @@ int main(int argc, char **argv) ...@@ -476,31 +489,38 @@ int main(int argc, char **argv)
if (input_fd==NULL) { if (input_fd==NULL) {
gNB->pbch_configured = 1; gNB->pbch_configured = 1;
for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1; for (int i=0;i<4;i++) gNB->pbch_pdu[i]=i+1;
nr_common_signal_procedures (gNB,frame,subframe);
LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); for (int slot=0;slot<frame_parms->slots_per_frame;slot++) {
if (gNB->frame_parms.nb_antennas_tx>1) for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++)
LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1); memset(gNB->common_vars.txdataF[aa],0,frame_parms->samples_per_slot_wCP*sizeof(int32_t));
//TODO: loop over slots nr_common_signal_procedures (gNB,frame,slot);
for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) { for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
PHY_ofdm_mod(gNB->common_vars.txdataF[aa], if (gNB_config->subframe_config.dl_cyclic_prefix_type.value == 1) {
txdata[aa], PHY_ofdm_mod(gNB->common_vars.txdataF[aa],
frame_parms->ofdm_symbol_size, &txdata[aa][slot*frame_parms->samples_per_slot],
12, frame_parms->ofdm_symbol_size,
frame_parms->nb_prefix_samples, 12,
CYCLIC_PREFIX); frame_parms->nb_prefix_samples,
} else { CYCLIC_PREFIX);
nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], } else {
txdata[aa], nr_normal_prefix_mod(gNB->common_vars.txdataF[aa],
14, &txdata[aa][slot*frame_parms->samples_per_slot],
frame_parms); 14,
frame_parms);
}
} }
} }
LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1);
if (gNB->frame_parms.nb_antennas_tx>1)
LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);
} else { } else {
printf("Reading %d samples from file to antenna buffer %d\n",frame_length_complex_samples,0); printf("Reading %d samples from file to antenna buffer %d\n",frame_length_complex_samples,0);
UE->UE_fo_compensation = 1; // perform fo compensation when samples from file are used
if (fread(txdata[0], if (fread(txdata[0],
sizeof(int32_t), sizeof(int32_t),
frame_length_complex_samples, frame_length_complex_samples,
...@@ -536,7 +556,6 @@ int main(int argc, char **argv) ...@@ -536,7 +556,6 @@ int main(int argc, char **argv)
n_errors_payload = 0; n_errors_payload = 0;
for (trial=0; trial<n_trials; trial++) { for (trial=0; trial<n_trials; trial++) {
// multipath channel // multipath channel
//multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0); //multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0);
...@@ -575,9 +594,9 @@ int main(int argc, char **argv) ...@@ -575,9 +594,9 @@ int main(int argc, char **argv)
} }
if (n_trials==1) { if (n_trials==1) {
LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0],frame_parms->samples_per_subframe,1,1); LOG_M("rxsig0.m","rxs0", UE->common_vars.rxdata[0],frame_parms->samples_per_frame,1,1);
if (gNB->frame_parms.nb_antennas_tx>1) if (gNB->frame_parms.nb_antennas_tx>1)
LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1],frame_parms->samples_per_subframe,1,1); LOG_M("rxsig1.m","rxs1", UE->common_vars.rxdata[1],frame_parms->samples_per_frame,1,1);
} }
if (UE->is_synchronized == 0) { if (UE->is_synchronized == 0) {
...@@ -587,40 +606,30 @@ int main(int argc, char **argv) ...@@ -587,40 +606,30 @@ int main(int argc, char **argv)
} }
else { else {
UE->rx_offset=0; UE->rx_offset=0;
//symbol 1
nr_slot_fep(UE,
5,
0,
0,
0,
1,
NR_PBCH_EST);
//symbol 2 uint8_t ssb_index = 0;
nr_slot_fep(UE, while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb
6,
0, UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms, ssb_index, n_hf);
0, for (int i=UE->symbol_offset+1; i<UE->symbol_offset+4; i++) {
0, nr_slot_fep(UE,
1, i,
NR_PBCH_EST); 0,
0,
//symbol 3 0,
nr_slot_fep(UE, NR_PBCH_EST);
7,
0, nr_pbch_channel_estimation(UE,0,0,i,i-(UE->symbol_offset+1),ssb_index%8,n_hf);
0, }
0,
1, ret = nr_rx_pbch(UE,
NR_PBCH_EST); 0,
UE->pbch_vars[0],
ret = nr_rx_pbch(UE, frame_parms,
0, 0,
UE->pbch_vars[0], ssb_index%8,
frame_parms, SISO,
0, UE->high_speed_flag);
SISO,
UE->high_speed_flag);
if (ret==0) { if (ret==0) {
//UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically
...@@ -643,11 +652,11 @@ int main(int argc, char **argv) ...@@ -643,11 +652,11 @@ int main(int argc, char **argv)
if (ret!=0) n_errors++; if (ret!=0) n_errors++;
} }
} //noise trials } //noise trials
printf("SNR %f: trials %d, n_errors_crc = %d, n_errors_payload %d\n", SNR,n_trials,n_errors,n_errors_payload); printf("SNR %f: trials %d, n_errors_crc = %d, n_errors_payload %d\n", SNR,n_trials,n_errors,n_errors_payload);
if (((float)n_errors/(float)n_trials <= target_error_rate) && (n_errors_payload==0)) { if (((float)n_errors/(float)n_trials <= target_error_rate) && (n_errors_payload==0)) {
printf("PBCH test OK\n"); printf("PBCH test OK\n");
printf("Synchronization obtained for i_ssb = %d\n",UE->rx_ind.rx_indication_body[0].mib_pdu.ssb_index);
break; break;
} }
......
...@@ -361,7 +361,7 @@ typedef struct NRRrcConfigurationReq_s { ...@@ -361,7 +361,7 @@ typedef struct NRRrcConfigurationReq_s {
lte_prefix_type_t UL_BWP_prefix_type[MAX_NUM_CCs]; lte_prefix_type_t UL_BWP_prefix_type[MAX_NUM_CCs];
long UL_timeAlignmentTimerCommon[MAX_NUM_CCs]; long UL_timeAlignmentTimerCommon[MAX_NUM_CCs];
long ServingCellConfigCommon_n_TimingAdvanceOffset[MAX_NUM_CCs]; long ServingCellConfigCommon_n_TimingAdvanceOffset[MAX_NUM_CCs];
long ServingCellConfigCommon_ssb_PositionsInBurst_PR[MAX_NUM_CCs]; uint64_t ServingCellConfigCommon_ssb_PositionsInBurst_PR[MAX_NUM_CCs];
long ServingCellConfigCommon_ssb_periodicityServingCell[MAX_NUM_CCs]; //ServingCellConfigCommon long ServingCellConfigCommon_ssb_periodicityServingCell[MAX_NUM_CCs]; //ServingCellConfigCommon
long ServingCellConfigCommon_dmrs_TypeA_Position[MAX_NUM_CCs]; //ServingCellConfigCommon long ServingCellConfigCommon_dmrs_TypeA_Position[MAX_NUM_CCs]; //ServingCellConfigCommon
long NIA_SubcarrierSpacing[MAX_NUM_CCs]; //ServingCellConfigCommon Used only for non-initial access long NIA_SubcarrierSpacing[MAX_NUM_CCs]; //ServingCellConfigCommon Used only for non-initial access
......
...@@ -103,7 +103,6 @@ void RCconfig_nr_flexran() ...@@ -103,7 +103,6 @@ void RCconfig_nr_flexran()
*UL_frequencyShift7p5khz, *UL_SCS_SubcarrierSpacing, *UL_BWP_SubcarrierSpacing, *UL_frequencyShift7p5khz, *UL_SCS_SubcarrierSpacing, *UL_BWP_SubcarrierSpacing,
*UL_BWP_prefix_type, *UL_timeAlignmentTimerCommon, *UL_BWP_prefix_type, *UL_timeAlignmentTimerCommon,
*ServingCellConfigCommon_n_TimingAdvanceOffset, *ServingCellConfigCommon_n_TimingAdvanceOffset,
*ServingCellConfigCommon_ssb_PositionsInBurst_PR,
*NIA_SubcarrierSpacing, *referenceSubcarrierSpacing, *dl_UL_TransmissionPeriodicity, *NIA_SubcarrierSpacing, *referenceSubcarrierSpacing, *dl_UL_TransmissionPeriodicity,
*rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice, *rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice,
*rach_groupBconfigured, *rach_messagePowerOffsetGroupB, *rach_groupBconfigured, *rach_messagePowerOffsetGroupB,
...@@ -118,7 +117,7 @@ void RCconfig_nr_flexran() ...@@ -118,7 +117,7 @@ void RCconfig_nr_flexran()
*SearchSpace_searchSpaceType, *ue_Specific__dci_Formats, *SearchSpace_searchSpaceType, *ue_Specific__dci_Formats,
*RateMatchPatternLTE_CRS_subframeAllocation_choice; *RateMatchPatternLTE_CRS_subframeAllocation_choice;
uint64_t downlink_frequency; uint64_t downlink_frequency, ServingCellConfigCommon_ssb_PositionsInBurst_PR;
int32_t nr_band, uplink_frequency_offset, N_RB_DL, nb_antenna_ports, int32_t nr_band, uplink_frequency_offset, N_RB_DL, nb_antenna_ports,
MIB_subCarrierSpacingCommon, MIB_ssb_SubcarrierOffset, MIB_dmrs_TypeA_Position, MIB_subCarrierSpacingCommon, MIB_ssb_SubcarrierOffset, MIB_dmrs_TypeA_Position,
...@@ -484,7 +483,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { ...@@ -484,7 +483,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
char* UL_timeAlignmentTimerCommon = 0; char* UL_timeAlignmentTimerCommon = 0;
char* ServingCellConfigCommon_n_TimingAdvanceOffset = 0; char* ServingCellConfigCommon_n_TimingAdvanceOffset = 0;
char* ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0; uint64_t ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0;
int32_t ServingCellConfigCommon_ssb_periodicityServingCell = 0; int32_t ServingCellConfigCommon_ssb_periodicityServingCell = 0;
int32_t ServingCellConfigCommon_dmrs_TypeA_Position = 0; int32_t ServingCellConfigCommon_dmrs_TypeA_Position = 0;
char* NIA_SubcarrierSpacing = 0; char* NIA_SubcarrierSpacing = 0;
...@@ -1125,19 +1124,23 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { ...@@ -1125,19 +1124,23 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) {
RC.config_file_name, i, ServingCellConfigCommon_n_TimingAdvanceOffset); RC.config_file_name, i, ServingCellConfigCommon_n_TimingAdvanceOffset);
} }
if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"shortBitmap")==0) {
NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap;
}else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"mediumBitmap")==0) {
NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap;
}else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"longBitmap")==0) {
NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap;
}else if (strcmp(ServingCellConfigCommon_ssb_PositionsInBurst_PR,"NOTHING")==0) {
NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_NOTHING;
}else {
AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unknown value \"%s\" for ServingCellConfigCommon_ssb_PositionsInBurst_PR choice !\n",
RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR);
}
uint64_t t_freq;
if(nr_band == 41 || (nr_band > 76 && nr_band < 80))
t_freq = 2400000000;
else
t_freq = 3000000000;
if (downlink_frequency<t_freq && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 15))
AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n",
RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency);
else {
if(downlink_frequency<6000000000 && (ServingCellConfigCommon_ssb_PositionsInBurst_PR > 255))
AssertFatal (0,"Failed to parse gNB configuration file %s, gnb %d unvalid value \"%ld\" for ssb_PositionsInBurst at DL frequency %ld !\n",
RC.config_file_name, i, ServingCellConfigCommon_ssb_PositionsInBurst_PR, downlink_frequency);
else
NRRRC_CONFIGURATION_REQ (msg_p).ServingCellConfigCommon_ssb_PositionsInBurst_PR[j] = ServingCellConfigCommon_ssb_PositionsInBurst_PR;
}
switch (ServingCellConfigCommon_ssb_periodicityServingCell) { switch (ServingCellConfigCommon_ssb_periodicityServingCell) {
case 5: case 5:
......
...@@ -640,7 +640,7 @@ typedef enum { ...@@ -640,7 +640,7 @@ typedef enum {
{GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE, NULL, 0, strptr:&UL_BWP_prefix_type, defstrval:"NORMAL", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_UL_BWP_PREFIX_TYPE, NULL, 0, strptr:&UL_BWP_prefix_type, defstrval:"NORMAL", TYPE_STRING, 0}, \
{GNB_CONFIG_STRING_UL_TIMEALIGNMENTTIMERCOMMON, NULL, 0, strptr:&UL_timeAlignmentTimerCommon, defstrval:"infinity", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_UL_TIMEALIGNMENTTIMERCOMMON, NULL, 0, strptr:&UL_timeAlignmentTimerCommon, defstrval:"infinity", TYPE_STRING, 0}, \
{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_N_TIMINGADVANCEOFFSET, NULL, 0, strptr:&ServingCellConfigCommon_n_TimingAdvanceOffset, defstrval:"n0", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_N_TIMINGADVANCEOFFSET, NULL, 0, strptr:&ServingCellConfigCommon_n_TimingAdvanceOffset, defstrval:"n0", TYPE_STRING, 0}, \
{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR, NULL, 0, strptr:&ServingCellConfigCommon_ssb_PositionsInBurst_PR, defstrval:"shortBitmap", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_POSITIONSINBURST_PR, NULL, 0, i64ptr:(int64_t *)&ServingCellConfigCommon_ssb_PositionsInBurst_PR, defint64val:0, TYPE_UINT64, 0}, \
{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL, NULL, 0, iptr:&ServingCellConfigCommon_ssb_periodicityServingCell, defintval:10, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_SSB_PERIODICITYSERVINGCELL, NULL, 0, iptr:&ServingCellConfigCommon_ssb_periodicityServingCell, defintval:10, TYPE_UINT, 0}, \
{GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION, NULL, 0, iptr:&ServingCellConfigCommon_dmrs_TypeA_Position, defintval:0, TYPE_UINT, 0}, \ {GNB_CONFIG_STRING_SERVINGCELLCONFIGCOMMON_DMRS_TYPEA_POSITION, NULL, 0, iptr:&ServingCellConfigCommon_dmrs_TypeA_Position, defintval:0, TYPE_UINT, 0}, \
{GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING, NULL, 0, strptr:&NIA_SubcarrierSpacing, defstrval:"kHz15", TYPE_STRING, 0}, \ {GNB_CONFIG_STRING_NIA_SUBCARRIERSPACING, NULL, 0, strptr:&NIA_SubcarrierSpacing, defstrval:"kHz15", TYPE_STRING, 0}, \
......
...@@ -49,110 +49,6 @@ extern RAN_CONTEXT_t RC; ...@@ -49,110 +49,6 @@ extern RAN_CONTEXT_t RC;
extern void mac_top_init_gNB(void); extern void mac_top_init_gNB(void);
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
int32_t **rxdata;
int32_t **txdata;
typedef struct nr_bandentry_s {
int16_t band;
uint64_t ul_min;
uint64_t ul_max;
uint64_t dl_min;
uint64_t dl_max;
uint64_t N_OFFs_DL;
uint64_t step_size;
} nr_bandentry_t;
typedef struct band_info_s {
int nbands;
nr_bandentry_t band_info[100];
} nr_band_info_t;
static const nr_bandentry_t nr_bandtable[] = {
{1, 1920000, 1980000, 2110000, 2170000, 20, 422000},
{2, 1850000, 1910000, 1930000, 1990000, 20, 386000},
{3, 1710000, 1785000, 1805000, 1880000, 20, 361000},
{5, 824000, 849000, 869000, 894000, 20, 173800},
{7, 2500000, 2570000, 2620000, 2690000, 20, 524000},
{8, 880000, 915000, 925000, 960000, 20, 185000},
{12, 698000, 716000, 728000, 746000, 20, 145800},
{20, 832000, 862000, 791000, 821000, 20, 158200},
{25, 1850000, 1915000, 1930000, 1995000, 20, 386000},
{28, 703000, 758000, 758000, 813000, 20, 151600},
{34, 2010000, 2025000, 2010000, 2025000, 20, 402000},
{38, 2570000, 2620000, 2570000, 2630000, 20, 514000},
{39, 1880000, 1920000, 1880000, 1920000, 20, 376000},
{40, 2300000, 2400000, 2300000, 2400000, 20, 460000},
{41, 2496000, 2690000, 2496000, 2690000, 3, 499200},
{50, 1432000, 1517000, 1432000, 1517000, 20, 286400},
{51, 1427000, 1432000, 1427000, 1432000, 20, 285400},
{66, 1710000, 1780000, 2110000, 2200000, 20, 422000},
{70, 1695000, 1710000, 1995000, 2020000, 20, 399000},
{71, 663000, 698000, 617000, 652000, 20, 123400},
{74, 1427000, 1470000, 1475000, 1518000, 20, 295000},
{75, 000, 000, 1432000, 1517000, 20, 286400},
{76, 000, 000, 1427000, 1432000, 20, 285400},
{77, 3300000, 4200000, 3300000, 4200000, 1, 620000},
{78, 3300000, 3800000, 3300000, 3800000, 1, 620000},
{79, 4400000, 5000000, 4400000, 5000000, 2, 693334},
{80, 1710000, 1785000, 000, 000, 20, 342000},
{81, 860000, 915000, 000, 000, 20, 176000},
{82, 832000, 862000, 000, 000, 20, 166400},
{83, 703000, 748000, 000, 000, 20, 140600},
{84, 1920000, 1980000, 000, 000, 20, 384000},
{86, 1710000, 1785000, 000, 000, 20, 342000}
};
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw)
{
uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000;
int bw_kHz = bw / 1000;
int i;
LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw);
AssertFatal(nr_bandP < 86, "nr_band %d > 86\n", nr_bandP);
for (i = 0; i < 30 && nr_bandtable[i].band != nr_bandP; i++);
AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min,
"Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n",
nr_bandP, bw, (long long unsigned int)dl_CarrierFreq_by_1k,
(long long unsigned int)nr_bandtable[i].dl_min);
AssertFatal(dl_CarrierFreq_by_1k <=
(nr_bandtable[i].dl_max - bw_kHz),
"Band %d, dl_CarrierFreq %llu bw %u: DL carrier frequency %llu kHz > %llu\n",
nr_bandP, (long long unsigned int)dl_CarrierFreq,bw, (long long unsigned int)dl_CarrierFreq_by_1k,
(long long unsigned int)(nr_bandtable[i].dl_max - bw_kHz));
int deltaFglobal;
if (dl_CarrierFreq < 3e9) deltaFglobal = 5;
else deltaFglobal = 15;
// This is equation before Table 5.4.2.1-1 in 38101-1-f30
// F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs)
return (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal) +
nr_bandtable[i].N_OFFs_DL);
}
uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn)
{
int i;
int deltaFglobal;
if (nr_bandP < 77 || nr_bandP > 79) deltaFglobal = 5;
else deltaFglobal = 15;
AssertFatal(nr_bandP < 87, "nr_band %d > 86\n", nr_bandP);
for (i = 0; i < 31 && nr_bandtable[i].band != nr_bandP; i++);
AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL %llu\n",dl_nrarfcn, (long long unsigned int)nr_bandtable[i].N_OFFs_DL);
return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal);
}
void config_nr_mib(int Mod_idP, void config_nr_mib(int Mod_idP,
int CC_idP, int CC_idP,
...@@ -184,8 +80,10 @@ void config_nr_mib(int Mod_idP, ...@@ -184,8 +80,10 @@ void config_nr_mib(int Mod_idP,
void config_common(int Mod_idP, void config_common(int Mod_idP,
int CC_idP, int CC_idP,
int cellid,
int nr_bandP, int nr_bandP,
uint64_t dl_CarrierFreqP, uint64_t ssb_pattern,
uint64_t dl_CarrierFreqP,
uint32_t dl_BandwidthP uint32_t dl_BandwidthP
){ ){
...@@ -193,6 +91,9 @@ void config_common(int Mod_idP, ...@@ -193,6 +91,9 @@ void config_common(int Mod_idP,
int mu = 1; int mu = 1;
cfg->sch_config.physical_cell_id.value = cellid;
cfg->sch_config.ssb_scg_position_in_burst.value = ssb_pattern;
// FDD // FDD
cfg->subframe_config.duplex_mode.value = 1; cfg->subframe_config.duplex_mode.value = 1;
cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG; cfg->subframe_config.duplex_mode.tl.tag = NFAPI_SUBFRAME_CONFIG_DUPLEX_MODE_TAG;
...@@ -232,8 +133,10 @@ void config_common(int Mod_idP, ...@@ -232,8 +133,10 @@ void config_common(int Mod_idP,
int rrc_mac_config_req_gNB(module_id_t Mod_idP, int rrc_mac_config_req_gNB(module_id_t Mod_idP,
int CC_idP, int CC_idP,
int cellid,
int p_gNB, int p_gNB,
int nr_bandP, int nr_bandP,
uint64_t ssb_pattern,
uint64_t dl_CarrierFreqP, uint64_t dl_CarrierFreqP,
int dl_BandwidthP, int dl_BandwidthP,
NR_BCCH_BCH_Message_t *mib, NR_BCCH_BCH_Message_t *mib,
...@@ -258,10 +161,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, ...@@ -258,10 +161,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP,
); );
}// END if( mib != NULL ) }// END if( mib != NULL )
if( servingcellconfigcommon != NULL ){ if( servingcellconfigcommon != NULL ){
config_common(Mod_idP, config_common(Mod_idP,
CC_idP, CC_idP,
cellid,
nr_bandP, nr_bandP,
ssb_pattern,
dl_CarrierFreqP, dl_CarrierFreqP,
dl_BandwidthP dl_BandwidthP
); );
......
...@@ -38,8 +38,10 @@ void mac_top_init_gNB(void); ...@@ -38,8 +38,10 @@ void mac_top_init_gNB(void);
int rrc_mac_config_req_gNB(module_id_t Mod_idP, int rrc_mac_config_req_gNB(module_id_t Mod_idP,
int CC_id, int CC_id,
int cellid,
int p_gNB, int p_gNB,
int nr_bandP, int nr_bandP,
uint64_t ssb_pattern,
uint64_t dl_CarrierFreqP, uint64_t dl_CarrierFreqP,
int dl_BandwidthP, int dl_BandwidthP,
NR_BCCH_BCH_Message_t *mib, NR_BCCH_BCH_Message_t *mib,
...@@ -100,4 +102,10 @@ int to_absslot(nfapi_nr_config_request_t *cfg,int frame,int slot); ...@@ -100,4 +102,10 @@ int to_absslot(nfapi_nr_config_request_t *cfg,int frame,int slot);
int get_symbolsperslot(nfapi_nr_config_request_t *cfg); int get_symbolsperslot(nfapi_nr_config_request_t *cfg);
void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type);
uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn);
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw);
#endif /*__LAYER2_NR_MAC_PROTO_H__*/ #endif /*__LAYER2_NR_MAC_PROTO_H__*/
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file nr_mac_common.c
* \brief Common MAC functions for NR UE and gNB
* \author Florian Kaltenberger and Raymond Knopp
* \date 2019
* \version 0.1
* \company Eurecom, NTUST
* \email: florian.kalteberger@eurecom.fr, raymond.knopp@eurecom.fr
* @ingroup _mac
*/
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
nr_bandentry_t nr_bandtable[] = {
{1, 1920000, 1980000, 2110000, 2170000, 20, 422000},
{2, 1850000, 1910000, 1930000, 1990000, 20, 386000},
{3, 1710000, 1785000, 1805000, 1880000, 20, 361000},
{5, 824000, 849000, 869000, 894000, 20, 173800},
{7, 2500000, 2570000, 2620000, 2690000, 20, 524000},
{8, 880000, 915000, 925000, 960000, 20, 185000},
{12, 698000, 716000, 728000, 746000, 20, 145800},
{20, 832000, 862000, 791000, 821000, 20, 158200},
{25, 1850000, 1915000, 1930000, 1995000, 20, 386000},
{28, 703000, 758000, 758000, 813000, 20, 151600},
{34, 2010000, 2025000, 2010000, 2025000, 20, 402000},
{38, 2570000, 2620000, 2570000, 2630000, 20, 514000},
{39, 1880000, 1920000, 1880000, 1920000, 20, 376000},
{40, 2300000, 2400000, 2300000, 2400000, 20, 460000},
{41, 2496000, 2690000, 2496000, 2690000, 3, 499200},
{50, 1432000, 1517000, 1432000, 1517000, 20, 286400},
{51, 1427000, 1432000, 1427000, 1432000, 20, 285400},
{66, 1710000, 1780000, 2110000, 2200000, 20, 422000},
{70, 1695000, 1710000, 1995000, 2020000, 20, 399000},
{71, 663000, 698000, 617000, 652000, 20, 123400},
{74, 1427000, 1470000, 1475000, 1518000, 20, 295000},
{75, 000, 000, 1432000, 1517000, 20, 286400},
{76, 000, 000, 1427000, 1432000, 20, 285400},
{77, 3300000, 4200000, 3300000, 4200000, 1, 620000},
{78, 3300000, 3800000, 3300000, 3800000, 1, 620000},
{79, 4400000, 5000000, 4400000, 5000000, 2, 693334},
{80, 1710000, 1785000, 000, 000, 20, 342000},
{81, 860000, 915000, 000, 000, 20, 176000},
{82, 832000, 862000, 000, 000, 20, 166400},
{83, 703000, 748000, 000, 000, 20, 140600},
{84, 1920000, 1980000, 000, 000, 20, 384000},
{86, 1710000, 1785000, 000, 000, 20, 342000}
};
void get_band(uint32_t downlink_frequency, uint8_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type) {
int ind;
int64_t dl_freq_khz = downlink_frequency/1000;
for ( ind=0;
ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]);
ind++) {
*current_band = nr_bandtable[ind].band;
LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", ind, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min);
if ( nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz ) {
*current_offset = (nr_bandtable[ind].ul_min - nr_bandtable[ind].dl_min)*1000;
if (*current_offset == 0)
*current_type = TDD;
else
*current_type = FDD;
LOG_I( PHY, "DL frequency %"PRIu32": band %d, frame_type %d, UL frequency %"PRIu32"\n",
downlink_frequency, *current_band, *current_type, downlink_frequency+*current_offset);
break;
}
}
AssertFatal(ind != (sizeof(nr_bandtable) / sizeof(nr_bandtable[0])),
"Can't find EUTRA band for frequency %d\n", downlink_frequency);
}
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint32_t bw)
{
uint64_t dl_CarrierFreq_by_1k = dl_CarrierFreq / 1000;
int bw_kHz = bw / 1000;
int i;
LOG_I(MAC,"Searching for nr band %d DL Carrier frequency %llu bw %u\n",nr_bandP,(long long unsigned int)dl_CarrierFreq,bw);
AssertFatal(nr_bandP < 86, "nr_band %d > 86\n", nr_bandP);
for (i = 0; i < 30 && nr_bandtable[i].band != nr_bandP; i++);
AssertFatal(dl_CarrierFreq_by_1k >= nr_bandtable[i].dl_min,
"Band %d, bw %u : DL carrier frequency %llu kHz < %llu\n",
nr_bandP, bw, (long long unsigned int)dl_CarrierFreq_by_1k,
(long long unsigned int)nr_bandtable[i].dl_min);
AssertFatal(dl_CarrierFreq_by_1k <=
(nr_bandtable[i].dl_max - bw_kHz),
"Band %d, dl_CarrierFreq %llu bw %u: DL carrier frequency %llu kHz > %llu\n",
nr_bandP, (long long unsigned int)dl_CarrierFreq,bw, (long long unsigned int)dl_CarrierFreq_by_1k,
(long long unsigned int)(nr_bandtable[i].dl_max - bw_kHz));
int deltaFglobal;
if (dl_CarrierFreq < 3e9) deltaFglobal = 5;
else deltaFglobal = 15;
// This is equation before Table 5.4.2.1-1 in 38101-1-f30
// F_REF=F_REF_Offs + deltaF_Global(N_REF-NREF_REF_Offs)
return (((dl_CarrierFreq_by_1k - nr_bandtable[i].dl_min)/deltaFglobal) +
nr_bandtable[i].N_OFFs_DL);
}
uint64_t from_nrarfcn(int nr_bandP, uint32_t dl_nrarfcn)
{
int i;
int deltaFglobal;
if (nr_bandP < 77 || nr_bandP > 79) deltaFglobal = 5;
else deltaFglobal = 15;
AssertFatal(nr_bandP < 87, "nr_band %d > 86\n", nr_bandP);
for (i = 0; i < 31 && nr_bandtable[i].band != nr_bandP; i++);
AssertFatal(dl_nrarfcn>=nr_bandtable[i].N_OFFs_DL,"dl_nrarfcn %u < N_OFFs_DL %llu\n",dl_nrarfcn, (long long unsigned int)nr_bandtable[i].N_OFFs_DL);
return 1000*(nr_bandtable[i].dl_min + (dl_nrarfcn - nr_bandtable[i].N_OFFs_DL) * deltaFglobal);
}
...@@ -747,15 +747,21 @@ void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id, ...@@ -747,15 +747,21 @@ void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id,
//ssb_PositionsInBurst //ssb_PositionsInBurst
(*servingcellconfigcommon)->ssb_PositionsInBurst->present = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id]; (*servingcellconfigcommon)->ssb_PositionsInBurst->present = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
if((*servingcellconfigcommon)->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap){ uint64_t t_freq;
if(configuration->nr_band[CC_id] == 41 || (configuration->nr_band[CC_id] > 76 && configuration->nr_band[CC_id] < 80))
t_freq = 2400000000;
else
t_freq = 3000000000;
if(configuration->downlink_frequency[CC_id]<t_freq){
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.size = 1; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.size = 1;
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.bits_unused = 4; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.bits_unused = 4;
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.buf[0] = 0x0f; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.shortBitmap.buf[0] = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
}else if((*servingcellconfigcommon)->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap){ }else if(configuration->downlink_frequency[CC_id]<6000000000){
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.size = 1; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.size = 1;
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.bits_unused = 0; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.bits_unused = 0;
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] = 0xff; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.mediumBitmap.buf[0] = configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id];
}else if((*servingcellconfigcommon)->ssb_PositionsInBurst->present == NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap){ }else {
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.size = 8; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.size = 8;
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.bits_unused = 0; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.bits_unused = 0;
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[0] = 0xff; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[0] = 0xff;
...@@ -768,6 +774,7 @@ void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id, ...@@ -768,6 +774,7 @@ void do_SERVINGCELLCONFIGCOMMON(uint8_t Mod_id,
(*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[7] = 0xff; (*servingcellconfigcommon)->ssb_PositionsInBurst->choice.longBitmap.buf[7] = 0xff;
} }
//ssb_periodicityServingCell //ssb_periodicityServingCell
*(*servingcellconfigcommon)->ssb_periodicityServingCell = configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id]; *(*servingcellconfigcommon)->ssb_periodicityServingCell = configuration->ServingCellConfigCommon_ssb_periodicityServingCell[CC_id];
//dmrs_TypeA_Position //dmrs_TypeA_Position
......
...@@ -236,7 +236,7 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, ...@@ -236,7 +236,7 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP,
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp_UL = configuration->UL_prefix_type[CC_id]; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Ncp_UL = configuration->UL_prefix_type[CC_id];
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq = configuration->downlink_frequency[CC_id]; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq = configuration->downlink_frequency[CC_id];
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id]; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq = configuration->downlink_frequency[CC_id]+ configuration->uplink_frequency_offset[CC_id];
///MIB ///MIB
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB = 0; RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_MIB = 0;
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4); RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4);
...@@ -261,11 +261,13 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP, ...@@ -261,11 +261,13 @@ static void init_NR_SI(const protocol_ctxt_t* const ctxt_pP,
LOG_I(NR_RRC,"Done init_NR_SI\n"); LOG_I(NR_RRC,"Done init_NR_SI\n");
rrc_mac_config_req_gNB(ctxt_pP->module_id, rrc_mac_config_req_gNB(ctxt_pP->module_id,
CC_id, CC_id,
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].physCellId,
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].p_gNB,
configuration->nr_band[CC_id], configuration->nr_band[CC_id],
configuration->ServingCellConfigCommon_ssb_PositionsInBurst_PR[CC_id],
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq,
configuration->N_RB_DL[CC_id], configuration->N_RB_DL[CC_id],
(NR_BCCH_BCH_Message_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].mib, (NR_BCCH_BCH_Message_t *)&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].mib,
......
...@@ -26,10 +26,10 @@ gNBs = ...@@ -26,10 +26,10 @@ gNBs =
node_function = "3GPP_gNODEB"; node_function = "3GPP_gNODEB";
node_timing = "synch_to_ext_device"; node_timing = "synch_to_ext_device";
node_synch_ref = 0; node_synch_ref = 0;
frame_type = "FDD"; frame_type = "TDD";
DL_prefix_type = "NORMAL"; DL_prefix_type = "NORMAL";
UL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL";
eutra_band = 22; eutra_band = 78;
downlink_frequency = 3510000000L; downlink_frequency = 3510000000L;
uplink_frequency_offset = -120000000; uplink_frequency_offset = -120000000;
Nid_cell = 0; Nid_cell = 0;
...@@ -70,7 +70,7 @@ gNBs = ...@@ -70,7 +70,7 @@ gNBs =
UL_BWP_prefix_type = "NORMAL"; UL_BWP_prefix_type = "NORMAL";
UL_timeAlignmentTimerCommon = "infinity"; UL_timeAlignmentTimerCommon = "infinity";
ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_n_TimingAdvanceOffset = "n0"
ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01;
ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_ssb_periodicityServingCell = 10;
ServingCellConfigCommon_dmrs_TypeA_Position = 2; ServingCellConfigCommon_dmrs_TypeA_Position = 2;
NIA_SubcarrierSpacing = "kHz15"; NIA_SubcarrierSpacing = "kHz15";
......
...@@ -26,10 +26,10 @@ gNBs = ...@@ -26,10 +26,10 @@ gNBs =
node_function = "3GPP_gNODEB"; node_function = "3GPP_gNODEB";
node_timing = "synch_to_ext_device"; node_timing = "synch_to_ext_device";
node_synch_ref = 0; node_synch_ref = 0;
frame_type = "FDD"; frame_type = "TDD";
DL_prefix_type = "NORMAL"; DL_prefix_type = "NORMAL";
UL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL";
eutra_band = 22; eutra_band = 78;
downlink_frequency = 3510000000L; downlink_frequency = 3510000000L;
uplink_frequency_offset = -120000000; uplink_frequency_offset = -120000000;
Nid_cell = 0; Nid_cell = 0;
...@@ -70,7 +70,7 @@ gNBs = ...@@ -70,7 +70,7 @@ gNBs =
UL_BWP_prefix_type = "NORMAL"; UL_BWP_prefix_type = "NORMAL";
UL_timeAlignmentTimerCommon = "infinity"; UL_timeAlignmentTimerCommon = "infinity";
ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_n_TimingAdvanceOffset = "n0"
ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01;
ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_ssb_periodicityServingCell = 10;
ServingCellConfigCommon_dmrs_TypeA_Position = 2; ServingCellConfigCommon_dmrs_TypeA_Position = 2;
NIA_SubcarrierSpacing = "kHz15"; NIA_SubcarrierSpacing = "kHz15";
......
...@@ -26,10 +26,10 @@ gNBs = ...@@ -26,10 +26,10 @@ gNBs =
node_function = "3GPP_gNODEB"; node_function = "3GPP_gNODEB";
node_timing = "synch_to_ext_device"; node_timing = "synch_to_ext_device";
node_synch_ref = 0; node_synch_ref = 0;
frame_type = "FDD"; frame_type = "TDD";
DL_prefix_type = "NORMAL"; DL_prefix_type = "NORMAL";
UL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL";
eutra_band = 22; eutra_band = 78;
downlink_frequency = 3510000000L; downlink_frequency = 3510000000L;
uplink_frequency_offset = -120000000; uplink_frequency_offset = -120000000;
Nid_cell = 0; Nid_cell = 0;
...@@ -70,7 +70,7 @@ gNBs = ...@@ -70,7 +70,7 @@ gNBs =
UL_BWP_prefix_type = "NORMAL"; UL_BWP_prefix_type = "NORMAL";
UL_timeAlignmentTimerCommon = "infinity"; UL_timeAlignmentTimerCommon = "infinity";
ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_n_TimingAdvanceOffset = "n0"
ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01;
ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_ssb_periodicityServingCell = 10;
ServingCellConfigCommon_dmrs_TypeA_Position = 2; ServingCellConfigCommon_dmrs_TypeA_Position = 2;
NIA_SubcarrierSpacing = "kHz15"; NIA_SubcarrierSpacing = "kHz15";
......
...@@ -26,10 +26,10 @@ gNBs = ...@@ -26,10 +26,10 @@ gNBs =
node_function = "3GPP_gNODEB"; node_function = "3GPP_gNODEB";
node_timing = "synch_to_ext_device"; node_timing = "synch_to_ext_device";
node_synch_ref = 0; node_synch_ref = 0;
frame_type = "FDD"; frame_type = "TDD";
DL_prefix_type = "NORMAL"; DL_prefix_type = "NORMAL";
UL_prefix_type = "NORMAL"; UL_prefix_type = "NORMAL";
eutra_band = 22; eutra_band = 78;
downlink_frequency = 3510000000L; downlink_frequency = 3510000000L;
uplink_frequency_offset = -120000000; uplink_frequency_offset = -120000000;
Nid_cell = 0; Nid_cell = 0;
...@@ -70,7 +70,7 @@ gNBs = ...@@ -70,7 +70,7 @@ gNBs =
UL_BWP_prefix_type = "NORMAL"; UL_BWP_prefix_type = "NORMAL";
UL_timeAlignmentTimerCommon = "infinity"; UL_timeAlignmentTimerCommon = "infinity";
ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" ServingCellConfigCommon_n_TimingAdvanceOffset = "n0"
ServingCellConfigCommon_ssb_PositionsInBurst_PR = "shortBitmap"; ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01;
ServingCellConfigCommon_ssb_periodicityServingCell = 10; ServingCellConfigCommon_ssb_periodicityServingCell = 10;
ServingCellConfigCommon_dmrs_TypeA_Position = 2; ServingCellConfigCommon_dmrs_TypeA_Position = 2;
NIA_SubcarrierSpacing = "kHz15"; NIA_SubcarrierSpacing = "kHz15";
......
...@@ -150,61 +150,12 @@ void init_UE(int nb_inst); ...@@ -150,61 +150,12 @@ void init_UE(int nb_inst);
int32_t **rxdata; int32_t **rxdata;
int32_t **txdata; int32_t **txdata;
#define KHz (1000UL)
#define MHz (1000*KHz)
#define SAIF_ENABLED #define SAIF_ENABLED
#ifdef SAIF_ENABLED #ifdef SAIF_ENABLED
uint64_t g_ue_rx_thread_busy = 0; uint64_t g_ue_rx_thread_busy = 0;
#endif #endif
typedef struct eutra_band_s {
int16_t band;
uint32_t ul_min;
uint32_t ul_max;
uint32_t dl_min;
uint32_t dl_max;
lte_frame_type_t frame_type;
} eutra_band_t;
typedef struct band_info_s {
int nbands;
eutra_band_t band_info[100];
} band_info_t;
band_info_t bands_to_scan;
static const eutra_band_t eutra_bands[] = {
{ 1, 1920 * MHz, 1980 * MHz, 2110 * MHz, 2170 * MHz, FDD},
{ 2, 1850 * MHz, 1910 * MHz, 1930 * MHz, 1990 * MHz, FDD},
{ 3, 1710 * MHz, 1785 * MHz, 1805 * MHz, 1880 * MHz, FDD},
{ 4, 1710 * MHz, 1755 * MHz, 2110 * MHz, 2155 * MHz, FDD},
{ 5, 824 * MHz, 849 * MHz, 869 * MHz, 894 * MHz, FDD},
{ 6, 830 * MHz, 840 * MHz, 875 * MHz, 885 * MHz, FDD},
{ 7, 2500 * MHz, 2570 * MHz, 2620 * MHz, 2690 * MHz, FDD},
{ 8, 880 * MHz, 915 * MHz, 925 * MHz, 960 * MHz, FDD},
{ 9, 1749900 * KHz, 1784900 * KHz, 1844900 * KHz, 1879900 * KHz, FDD},
{10, 1710 * MHz, 1770 * MHz, 2110 * MHz, 2170 * MHz, FDD},
{11, 1427900 * KHz, 1452900 * KHz, 1475900 * KHz, 1500900 * KHz, FDD},
{12, 698 * MHz, 716 * MHz, 728 * MHz, 746 * MHz, FDD},
{13, 777 * MHz, 787 * MHz, 746 * MHz, 756 * MHz, FDD},
{14, 788 * MHz, 798 * MHz, 758 * MHz, 768 * MHz, FDD},
{17, 704 * MHz, 716 * MHz, 734 * MHz, 746 * MHz, FDD},
{20, 832 * MHz, 862 * MHz, 791 * MHz, 821 * MHz, FDD},
{22, 3510 * MHz, 3590 * MHz, 3410 * MHz, 3490 * MHz, FDD},
{33, 1900 * MHz, 1920 * MHz, 1900 * MHz, 1920 * MHz, TDD},
{34, 2010 * MHz, 2025 * MHz, 2010 * MHz, 2025 * MHz, TDD},
{35, 1850 * MHz, 1910 * MHz, 1850 * MHz, 1910 * MHz, TDD},
{36, 1930 * MHz, 1990 * MHz, 1930 * MHz, 1990 * MHz, TDD},
{37, 1910 * MHz, 1930 * MHz, 1910 * MHz, 1930 * MHz, TDD},
{38, 2570 * MHz, 2620 * MHz, 2570 * MHz, 2630 * MHz, TDD},
{39, 1880 * MHz, 1920 * MHz, 1880 * MHz, 1920 * MHz, TDD},
{40, 2300 * MHz, 2400 * MHz, 2300 * MHz, 2400 * MHz, TDD},
{41, 2496 * MHz, 2690 * MHz, 2496 * MHz, 2690 * MHz, TDD},
{42, 3400 * MHz, 3600 * MHz, 3400 * MHz, 3600 * MHz, TDD},
{43, 3600 * MHz, 3800 * MHz, 3600 * MHz, 3800 * MHz, TDD},
{44, 703 * MHz, 803 * MHz, 703 * MHz, 803 * MHz, TDD},
};
PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms, PHY_VARS_NR_UE *init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms,
uint8_t UE_id, uint8_t UE_id,
...@@ -329,11 +280,13 @@ void init_UE(int nb_inst) { ...@@ -329,11 +280,13 @@ void init_UE(int nb_inst) {
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
static void *UE_thread_synch(void *arg) { static void *UE_thread_synch(void *arg) {
static int __thread UE_thread_synch_retval; static int __thread UE_thread_synch_retval;
int i, hw_slot_offset; int i, hw_slot_offset;
PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg; PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg;
int current_band = 0; int current_band = 0;
int current_offset = 0; int current_offset = 0;
lte_frame_type_t current_type;
sync_mode_t sync_mode = pbch; sync_mode_t sync_mode = pbch;
int CC_id = UE->CC_id; int CC_id = UE->CC_id;
int freq_offset=0; int freq_offset=0;
...@@ -349,24 +302,12 @@ static void *UE_thread_synch(void *arg) { ...@@ -349,24 +302,12 @@ static void *UE_thread_synch(void *arg) {
init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname); init_thread(100000, 500000, FIFO_PRIORITY-1, &cpuset, threadname);
UE->is_synchronized = 0; UE->is_synchronized = 0;
if (UE->UE_scan == 0) { printf("UE_scan %d\n",UE->UE_scan);
int ind;
for ( ind=0; if (UE->UE_scan == 0) {
ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]);
ind++) {
current_band = eutra_bands[ind].band;
LOG_D(PHY, "Scanning band %d, dl_min %"PRIu32", ul_min %"PRIu32"\n", current_band, eutra_bands[ind].dl_min,eutra_bands[ind].ul_min);
if ( eutra_bands[ind].dl_min <= downlink_frequency[0][0] && eutra_bands[ind].dl_max >= downlink_frequency[0][0] ) { get_band(downlink_frequency[CC_id][0], &UE->frame_parms.eutra_band, &uplink_frequency_offset[CC_id][0], &UE->frame_parms.frame_type);
for (i=0; i<4; i++)
uplink_frequency_offset[CC_id][i] = eutra_bands[ind].ul_min - eutra_bands[ind].dl_min;
break;
}
}
AssertFatal( ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]), "Can't find EUTRA band for frequency");
LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n", LOG_I( PHY, "[SCHED][UE] Check absolute frequency DL %"PRIu32", UL %"PRIu32" (oai_exit %d, rx_num_channels %d)\n",
downlink_frequency[0][0], downlink_frequency[0][0]+uplink_frequency_offset[0][0], downlink_frequency[0][0], downlink_frequency[0][0]+uplink_frequency_offset[0][0],
oai_exit, openair0_cfg[0].rx_num_channels); oai_exit, openair0_cfg[0].rx_num_channels);
...@@ -386,7 +327,8 @@ static void *UE_thread_synch(void *arg) { ...@@ -386,7 +327,8 @@ static void *UE_thread_synch(void *arg) {
sync_mode = pbch; sync_mode = pbch;
} else { } else {
current_band=0; current_band=0;
LOG_E(PHY,"Fixme!\n");
/*
for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) { for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[CC_id].dl_min; downlink_frequency[UE->rf_map.card][UE->rf_map.chain+i] = bands_to_scan.band_info[CC_id].dl_min;
uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] = uplink_frequency_offset[UE->rf_map.card][UE->rf_map.chain+i] =
...@@ -396,6 +338,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -396,6 +338,7 @@ static void *UE_thread_synch(void *arg) {
downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i]; downlink_frequency[CC_id][i]+uplink_frequency_offset[CC_id][i];
openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB; openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;
} }
*/
} }
// AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n"); // AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n");
...@@ -410,6 +353,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -410,6 +353,7 @@ static void *UE_thread_synch(void *arg) {
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
switch (sync_mode) { switch (sync_mode) {
/*
case pss: case pss:
LOG_I(PHY,"[SCHED][UE] Scanning band %d (%d), freq %u\n",bands_to_scan.band_info[current_band].band, current_band,bands_to_scan.band_info[current_band].dl_min+current_offset); LOG_I(PHY,"[SCHED][UE] Scanning band %d (%d), freq %u\n",bands_to_scan.band_info[current_band].band, current_band,bands_to_scan.band_info[current_band].dl_min+current_offset);
//lte_sync_timefreq(UE,current_band,bands_to_scan.band_info[current_band].dl_min+current_offset); //lte_sync_timefreq(UE,current_band,bands_to_scan.band_info[current_band].dl_min+current_offset);
...@@ -438,7 +382,7 @@ static void *UE_thread_synch(void *arg) { ...@@ -438,7 +382,7 @@ static void *UE_thread_synch(void *arg) {
} }
break; break;
*/
case pbch: case pbch:
#if DISABLE_LOG_X #if DISABLE_LOG_X
printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode); printf("[UE thread Synch] Running Initial Synch (mode %d)\n",UE->mode);
...@@ -934,7 +878,7 @@ void *UE_thread(void *arg) { ...@@ -934,7 +878,7 @@ void *UE_thread(void *arg) {
UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0, UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0,
UE->frame_parms.nb_antennas_rx),"first symbol read error"); UE->frame_parms.nb_antennas_rx),"first symbol read error");
//write_output("txdata_sym.m", "txdata_sym", UE->common_vars.rxdata[0], (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0), 1, 1); //write_output("txdata_sym.m", "txdata_sym", UE->common_vars.rxdata[0], (UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0), 1, 1);
//nr_slot_fep(UE,0, 0, 0, 1, 1, NR_PDCCH_EST); //nr_slot_fep(UE,0, 0, 0, 1, NR_PDCCH_EST);
} //UE->mode != loop_through_memory } //UE->mode != loop_through_memory
else else
rt_sleep_ns(1000*1000); rt_sleep_ns(1000*1000);
......
...@@ -661,7 +661,7 @@ void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { ...@@ -661,7 +661,7 @@ void set_default_frame_parms(NR_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
config[CC_id]->rf_config.dl_carrier_bandwidth.value = 106; config[CC_id]->rf_config.dl_carrier_bandwidth.value = 106;
config[CC_id]->rf_config.ul_carrier_bandwidth.value = 106; config[CC_id]->rf_config.ul_carrier_bandwidth.value = 106;
config[CC_id]->sch_config.physical_cell_id.value = 0; config[CC_id]->sch_config.physical_cell_id.value = 0;
frame_parms[CC_id]->eutra_band = 78;
frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->frame_type = FDD;
frame_parms[CC_id]->tdd_config = 3; frame_parms[CC_id]->tdd_config = 3;
//frame_parms[CC_id]->tdd_config_S = 0; //frame_parms[CC_id]->tdd_config_S = 0;
...@@ -932,14 +932,14 @@ int main( int argc, char **argv ) { ...@@ -932,14 +932,14 @@ int main( int argc, char **argv ) {
LOG_I(PHY,"Set nb_rx_antenna %d , nb_tx_antenna %d \n",frame_parms[CC_id]->nb_antennas_rx, frame_parms[CC_id]->nb_antennas_tx); LOG_I(PHY,"Set nb_rx_antenna %d , nb_tx_antenna %d \n",frame_parms[CC_id]->nb_antennas_rx, frame_parms[CC_id]->nb_antennas_tx);
//init_ul_hopping(frame_parms[CC_id]); get_band(downlink_frequency[CC_id][0], &frame_parms[CC_id]->eutra_band, &uplink_frequency_offset[CC_id][0], &frame_parms[CC_id]->frame_type);
//phy_init_nr_top(frame_parms[CC_id]);
}
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { //init_ul_hopping(frame_parms[CC_id]);
//init prach for openair1 test //phy_init_nr_top(frame_parms[CC_id]);
// prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type);
// N_ZC = (prach_fmt <4)?839:139; //init prach for openair1 test
// prach_fmt = get_prach_fmt(frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, frame_parms->frame_type);
// N_ZC = (prach_fmt <4)?839:139;
} }
NB_UE_INST=1; NB_UE_INST=1;
......
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