Commit 7ff37059 authored by Florian Kaltenberger's avatar Florian Kaltenberger

adding basic simulator support to nr softmodems. however, simulator not yet functional.

parent d326da0d
Pipeline #10517 failed with stage
in 0 seconds
......@@ -1453,6 +1453,9 @@ set(L2_SRC
${RRC_DIR}/L2_interface.c
${RRC_DIR}/L2_interface_common.c
${RRC_DIR}/L2_interface_ue.c
)
set(NR_L2_SRC
${NR_RRC_DIR}/rrc_gNB.c
${NR_RRC_DIR}/nr_rrc_common.c
${NR_RRC_DIR}/L2_nr_interface.c
......@@ -1529,7 +1532,10 @@ set (MAC_SRC
${MAC_DIR}/eNB_scheduler_phytest.c
${MAC_DIR}/pre_processor.c
${MAC_DIR}/config.c
#${MAC_DIR}/config_ue.c
${MAC_DIR}/config_ue.c
)
set (NR_MAC_SRC
${NR_PHY_INTERFACE_DIR}/NR_IF_Module.c
${NR_MAC_DIR}/main.c
${NR_MAC_DIR}/config.c
......@@ -1573,8 +1579,13 @@ add_library(L2
${L2_SRC}
${MAC_SRC}
${ENB_APP_SRC}
${GNB_APP_SRC})
# ${OPENAIR2_DIR}/RRC/L2_INTERFACE/openair_rrc_L2_interface.c)
)
add_library(NR_L2
${NR_L2_SRC}
${NR_MAC_SRC}
${GNB_APP_SRC}
)
add_library(L2_UE
${L2_SRC_UE}
......@@ -1590,7 +1601,7 @@ add_library( NR_L2_UE
)
set ( NR_LTE_UE_REUSE_SRC
${OPENAIR1_DIR}/PHY/LTE_ESTIMATION/lte_sync_timefreq.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
......@@ -2345,7 +2356,7 @@ target_link_libraries (nr-softmodem
-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
${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ATLAS_LIBRARIES}
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 NR_L2
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl)
......@@ -2385,7 +2396,7 @@ target_link_libraries (nr-softmodem-nos1
-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
${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
RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB L2 NR_L2
NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB
-Wl,--end-group z dl)
......
......@@ -667,7 +667,8 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
/*
if((subframeP == 0) && (frameP & 7) == 0){
schedule_nr_mib(module_idP, frameP, subframeP);
}*/
}
*/
if (phy_test == 0){
// This schedules SI for legacy LTE and eMTC starting in subframeP
......
......@@ -250,10 +250,11 @@ int device_init(openair0_device* device, openair0_config_t *openair0_cfg)
memset(tcp_bridge, 0, sizeof(tcp_bridge_state_t));
/* only 25 or 50 PRBs handled for the moment */
if (openair0_cfg[0].sample_rate != 30720000 &&
if (openair0_cfg[0].sample_rate != 61440000 &&
openair0_cfg[0].sample_rate != 30720000 &&
openair0_cfg[0].sample_rate != 15360000 &&
openair0_cfg[0].sample_rate != 7680000) {
printf("tcp_bridge: ERROR: only 25, 50 or 100 PRBs supported\n");
printf("tcp_bridge: ERROR: only sample rate 61.44, 30.72, 15.36, and 7.68 Msps supported\n");
exit(1);
}
......@@ -270,6 +271,7 @@ int device_init(openair0_device* device, openair0_config_t *openair0_cfg)
device->priv = tcp_bridge;
switch ((int)openair0_cfg[0].sample_rate) {
case 61440000: tcp_bridge->samples_per_subframe = 61440; break;
case 30720000: tcp_bridge->samples_per_subframe = 30720; break;
case 15360000: tcp_bridge->samples_per_subframe = 15360; break;
case 7680000: tcp_bridge->samples_per_subframe = 7680; break;
......
......@@ -280,11 +280,11 @@ int device_init(openair0_device* device, openair0_config_t *openair0_cfg)
printf("tcp_bridge: running as %s\n", tcp_bridge->is_enb ? "eNB" : "UE");
/* only 25, 50 or 100 PRBs handled for the moment */
if (openair0_cfg[0].sample_rate != 30720000 &&
if (openair0_cfg[0].sample_rate != 61440000 &&
openair0_cfg[0].sample_rate != 30720000 &&
openair0_cfg[0].sample_rate != 15360000 &&
openair0_cfg[0].sample_rate != 7680000) {
printf("tcp_bridge: ERROR: only 25, 50 or 100 PRBs supported\n");
printf("tcp_bridge: ERROR: only sample rate 61.44, 30.72, 15.36, and 7.68 Msps supported\n");
exit(1);
}
......@@ -306,6 +306,7 @@ int device_init(openair0_device* device, openair0_config_t *openair0_cfg)
device->priv = tcp_bridge;
switch ((int)openair0_cfg[0].sample_rate) {
case 61440000: tcp_bridge->samples_per_subframe = 61440; break;
case 30720000: tcp_bridge->samples_per_subframe = 30720; break;
case 15360000: tcp_bridge->samples_per_subframe = 15360; break;
case 7680000: tcp_bridge->samples_per_subframe = 7680; break;
......
......@@ -443,16 +443,16 @@ static void *UE_thread_synch(void *arg) {
for (i=0; i<openair0_cfg[UE->rf_map.card].rx_num_channels; i++) {
openair0_cfg[UE->rf_map.card].rx_gain[UE->rf_map.chain+i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
if (UE->UE_scan_carrier == 1) {
if (freq_offset >= 0)
if (freq_offset >= 0)
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] += abs(UE->common_vars.freq_offset);
else
else
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i] -= abs(UE->common_vars.freq_offset);
openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =
openair0_cfg[UE->rf_map.card].tx_freq[UE->rf_map.chain+i] =
openair0_cfg[UE->rf_map.card].rx_freq[UE->rf_map.chain+i]+uplink_frequency_offset[CC_id][i];
downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i];
freq_offset=0;
}
}
downlink_frequency[CC_id][i] = openair0_cfg[CC_id].rx_freq[i];
freq_offset=0;
}
}
// reconfigure for potentially different bandwidth
switch(UE->frame_parms.N_RB_DL) {
......@@ -755,6 +755,9 @@ static void *UE_thread_rxn_txnp4(void *arg) {
exit_fun("noting to add");
}
proc->instance_cnt_rxtx--;
#if BASIC_SIMULATOR
if (pthread_cond_signal(&proc->cond_rxtx) != 0) abort();
#endif
if (pthread_mutex_unlock(&proc->mutex_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE RXTX\n" );
exit_fun("noting to add");
......@@ -822,6 +825,12 @@ void *UE_thread(void *arg) {
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if (is_synchronized == 0) {
#if BASIC_SIMULATOR
while (!((instance_cnt_synch = UE->proc.instance_cnt_synch) < 0)) {
printf("ue sync not ready\n");
usleep(500*1000);
}
#endif
if (instance_cnt_synch < 0) { // we can invoke the synch
// grab 10 ms of signal and wakeup synch thread
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
......@@ -834,6 +843,7 @@ void *UE_thread(void *arg) {
rxp,
UE->frame_parms.samples_per_subframe*10,
UE->frame_parms.nb_antennas_rx), "");
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
instance_cnt_synch = ++UE->proc.instance_cnt_synch;
if (instance_cnt_synch == 0) {
......@@ -869,28 +879,13 @@ void *UE_thread(void *arg) {
start_rx_stream=1;
if (UE->mode != loop_through_memory) {
if (UE->no_timing_correction==0) {
printf("before resync\n");
//nr_slot_fep(UE,0, 0, UE->rx_offset, 1, 1, NR_PDCCH_EST);
//nr_slot_fep(UE,1, 0, UE->rx_offset, 1, 1, NR_PDCCH_EST);
//write_output("txdata_pre.m", "txdata_pre", UE->common_vars.rxdata[0], UE->frame_parms.samples_per_subframe*10, 1, 1);
/*LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
AssertFatal(UE->rx_offset ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
(void**)UE->common_vars.rxdata,
UE->rx_offset,
UE->frame_parms.nb_antennas_rx),"");
AssertFatal(UE->frame_parms.samples_per_subframe*10 ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
(void**)UE->common_vars.rxdata,
UE->frame_parms.samples_per_subframe*10,
UE->frame_parms.nb_antennas_rx),"");*/
//write_output("txdataF_ue.m", "txdataF_ue", UE->common_vars.rxdata[0], UE->frame_parms.samples_per_subframe*10, 1, 1);
}
UE->rx_offset=0;
UE->time_sync_cell=0;
......@@ -923,6 +918,17 @@ void *UE_thread(void *arg) {
// update thread index for received subframe
UE->current_thread_id[tti_nr] = thread_idx;
#if BASIC_SIMULATOR
{
int t;
for (t = 0; t < 2; t++) {
UE_rxtx_proc_t *proc = &UE->proc.proc_rxtx[t];
pthread_mutex_lock(&proc->mutex_rxtx);
while (proc->instance_cnt_rxtx >= 0) pthread_cond_wait( &proc->cond_rxtx, &proc->mutex_rxtx );
pthread_mutex_unlock(&proc->mutex_rxtx);
}
}
#endif
LOG_D(PHY,"Process TTI %d thread Idx %d \n", tti_nr, UE->current_thread_id[tti_nr]);
thread_idx++;
......@@ -962,7 +968,7 @@ void *UE_thread(void *arg) {
UE->rx_offset_diff;
}
/*AssertFatal(readBlockSize ==
AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp,
rxp,
......@@ -977,17 +983,18 @@ void *UE_thread(void *arg) {
txp,
writeBlockSize,
UE->frame_parms.nb_antennas_tx,
1),"");*/
1),"");
if( tti_nr==(ttis_per_frame-1)) {
// read in first symbol of next frame and adjust for timing drift
int first_symbols=writeBlockSize-readBlockSize;
if ( first_symbols > 0 )
/*AssertFatal(first_symbols ==
AssertFatal(first_symbols ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp1,
(void**)UE->common_vars.rxdata,
first_symbols,
UE->frame_parms.nb_antennas_rx),"");*/
UE->frame_parms.nb_antennas_rx),"");
if ( first_symbols <0 )
LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols);
}
......
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