Commit df18f593 authored by Florian Kaltenberger's avatar Florian Kaltenberger

adding first version of the pbchsim. so far only freq domain signal generated.

not all regression tests done (had to touch some header files)
parent 471b5efe
...@@ -543,7 +543,9 @@ set (CONFIG_SOURCES ...@@ -543,7 +543,9 @@ set (CONFIG_SOURCES
) )
set (CONFIG_LIBCONFIG_SOURCES set (CONFIG_LIBCONFIG_SOURCES
${CONFIG_ROOTDIR}/libconfig/config_libconfig.c ${CONFIG_ROOTDIR}/libconfig/config_libconfig.c
) )
add_library(CONFIG_LIB ${CONFIG_SOURCES})
set(CONFIG_LIBRARIES CONFIG_LIB)
add_library(params_libconfig MODULE ${CONFIG_LIBCONFIG_SOURCES} ) add_library(params_libconfig MODULE ${CONFIG_LIBCONFIG_SOURCES} )
target_link_libraries(params_libconfig config) target_link_libraries(params_libconfig config)
# shared library loader # shared library loader
...@@ -2517,10 +2519,14 @@ target_link_libraries (dlsim_tm4 ...@@ -2517,10 +2519,14 @@ target_link_libraries (dlsim_tm4
) )
add_executable(polartest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c) add_executable(polartest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c)
target_link_libraries(polartest m SIMU PHY PHY_NR PHY_COMMON -lm ${ATLAS_LIBRARIES}) target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES})
add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c) add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c)
target_link_libraries(ldpctest m SIMU PHY PHY_NR ${ATLAS_LIBRARIES}) target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES})
add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c )
target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY PHY_COMMON PHY_NR SCHED_NR_LIB ${CONFIG_LIBRARIES} -Wl,--end-group m pthread dl ${ATLAS_LIBRARIES})
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)
......
...@@ -671,7 +671,7 @@ function main() { ...@@ -671,7 +671,7 @@ function main() {
fi fi
if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
cd $OPENAIR_DIR/cmake_targets/lte-simulators cd $OPENAIR_DIR/cmake_targets/phy_simulators
[ "$CLEAN" = "1" ] && rm -rf build [ "$CLEAN" = "1" ] && rm -rf build
mkdir -p build mkdir -p build
cd build cd build
...@@ -687,11 +687,11 @@ function main() { ...@@ -687,11 +687,11 @@ function main() {
simlist="dlsim ulsim polartest ldpctest" simlist="dlsim ulsim polartest ldpctest"
for f in $simlist ; do for f in $simlist ; do
compilations \ compilations \
lte-simulators $f \ phy_simulators $f \
$f $dbin/$f.$REL $f $dbin/$f.$REL
done done
compilations \ compilations \
lte-simulators coding \ phy_simulators coding \
libcoding.so $dbin/libcoding.so libcoding.so $dbin/libcoding.so
fi fi
...@@ -703,7 +703,7 @@ function main() { ...@@ -703,7 +703,7 @@ function main() {
simlist="secu_knas_encrypt_eia1 secu_kenb aes128_ctr_encrypt aes128_ctr_decrypt secu_knas_encrypt_eea2 secu_knas secu_knas_encrypt_eea1 kdf aes128_cmac_encrypt secu_knas_encrypt_eia2" simlist="secu_knas_encrypt_eia1 secu_kenb aes128_ctr_encrypt aes128_ctr_decrypt secu_knas_encrypt_eea2 secu_knas secu_knas_encrypt_eea1 kdf aes128_cmac_encrypt secu_knas_encrypt_eia2"
for f in $simlist ; do for f in $simlist ; do
compilations \ compilations \
lte-simulators test_$f \ phy_simulators test_$f \
test_$f $dbin/test_$f.$REL test_$f $dbin/test_$f.$REL
done done
fi fi
......
...@@ -9,4 +9,5 @@ set(MU_RECIEVER False) ...@@ -9,4 +9,5 @@ set(MU_RECIEVER False)
set(NAS_UE False) set(NAS_UE False)
set(MESSAGE_CHART_GENERATOR False) set(MESSAGE_CHART_GENERATOR False)
set(RRC_ASN1_VERSION "Rel14") set(RRC_ASN1_VERSION "Rel14")
set(T_TRACER False)
include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt) include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)
...@@ -345,10 +345,10 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int ...@@ -345,10 +345,10 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
/* define variable only used in LOG macro's */ /* define variable only used in LOG macro's */
# define LOG_VAR(A,B) A B # define LOG_VAR(A,B) A B
# else /* T_TRACER: remove all debugging and tracing messages, except errors */ # else /* T_TRACER: remove all debugging and tracing messages, except errors */
# define LOG_I(c, x...) /* */ # define LOG_I(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_INFO, x) ; } while(0)/* */
# define LOG_W(c, x...) /* */ # define LOG_W(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_WARNING, x) ; } while(0)/* */
# define LOG_E(c, x...) /* */ # define LOG_E(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_ERR, x) ; } while(0)/* */
# define LOG_D(c, x...) /* */ # define LOG_D(c, x...) do {logRecord_mt(__FILE__, __FUNCTION__, __LINE__,c, OAILOG_DEBUG, x) ; } while(0)/* */
# define LOG_T(c, x...) /* */ # define LOG_T(c, x...) /* */
# define LOG_F(c, x...) /* */ # define LOG_F(c, x...) /* */
# define nfapi_log(FILE, FNC, LN, COMP, LVL, FMT...) # define nfapi_log(FILE, FNC, LN, COMP, LVL, FMT...)
...@@ -356,7 +356,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int ...@@ -356,7 +356,7 @@ int32_t write_file_matlab(const char *fname, const char *vname, void *data, int
# define LOG_DEBUG_END } # define LOG_DEBUG_END }
# define LOG_M_BEGIN(D) if (0) { # define LOG_M_BEGIN(D) if (0) {
# define LOG_M_END } # define LOG_M_END }
# define LOG_M(file, vector, data, len, dec, format) # define LOG_M(file, vector, data, len, dec, format) do { write_file_matlab(file, vector, data, len, dec, format);} while(0)
# define LOG_VAR(A,B) # define LOG_VAR(A,B)
# endif /* T_TRACER */ # endif /* T_TRACER */
/* avoid warnings for variables only used in LOG macro's but set outside debug section */ /* avoid warnings for variables only used in LOG macro's but set outside debug section */
......
...@@ -298,7 +298,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) ...@@ -298,7 +298,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time); free_and_zero(srs_vars[UE_id].srs_ch_estimates_time);
} //UE_id } //UE_id
free_ul_ref_sigs(); //free_ul_ref_sigs();
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) free_and_zero(srs_vars[UE_id].srs); for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) free_and_zero(srs_vars[UE_id].srs);
...@@ -341,7 +341,7 @@ void install_schedule_handlers(IF_Module_t *if_inst) ...@@ -341,7 +341,7 @@ 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(PHY_VARS_gNB *gNB) void nr_phy_config_request_sim(PHY_VARS_gNB *gNB)
{ {
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;
...@@ -370,7 +370,7 @@ void install_schedule_handlers(IF_Module_t *if_inst) ...@@ -370,7 +370,7 @@ void install_schedule_handlers(IF_Module_t *if_inst)
gNB->configured = 1; gNB->configured = 1;
LOG_I(PHY,"gNB configured\n"); LOG_I(PHY,"gNB configured\n");
}*/ }
void nr_phy_config_request(NR_PHY_Config_t *phy_config) void nr_phy_config_request(NR_PHY_Config_t *phy_config)
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
//#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_ENCODING
//#define DEBUG_PBCH_DMRS //#define DEBUG_PBCH_DMRS
extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT]; //extern short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT];
#include "PHY/NR_REFSIG/nr_mod_table.h"
int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs, int nr_generate_pbch_dmrs(uint32_t *gold_pbch_dmrs,
int32_t **txdataF, int32_t **txdataF,
......
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
/*#ifndef __INIT_DEFS_NR__H__ #ifndef __INIT_DEFS_NR__H__
#define __INIT_DEFS_NR__H__ #define __INIT_DEFS_NR__H__
/*
#define _GNU_SOURCE #define _GNU_SOURCE
#include <sched.h> #include <sched.h>
#include <stdio.h> #include <stdio.h>
...@@ -44,6 +45,7 @@ ...@@ -44,6 +45,7 @@
#include "defs.h" #include "defs.h"
#include "assertions.h"*/ #include "assertions.h"*/
#include "impl_defs_nr.h" #include "impl_defs_nr.h"
#include "defs_nr_common.h"
#define MAX_NUM_SUBCARRIER_SPACING 5 #define MAX_NUM_SUBCARRIER_SPACING 5
...@@ -58,6 +60,7 @@ ...@@ -58,6 +60,7 @@
#define MOD_TABLE_SIZE_SHORT 6 #define MOD_TABLE_SIZE_SHORT 6
#define MOD_TABLE_BPSK_OFFSET 1 #define MOD_TABLE_BPSK_OFFSET 1
/*
typedef enum { typedef enum {
NR_MU_0=0, NR_MU_0=0,
NR_MU_1, NR_MU_1,
...@@ -93,6 +96,7 @@ typedef struct { ...@@ -93,6 +96,7 @@ typedef struct {
uint32_t samples_per_frame_wCP; uint32_t samples_per_frame_wCP;
} NR_DL_FRAME_PARMS; } NR_DL_FRAME_PARMS;
*/
/// Top-level PHY Data Structure for gNB /// Top-level PHY Data Structure for gNB
typedef struct PHY_VARS_gNB_s { typedef struct PHY_VARS_gNB_s {
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
lte_subframe_t nr_subframe_select (nfapi_nr_config_request_t *cfg, unsigned char subframe); lte_subframe_t nr_subframe_select (nfapi_nr_config_request_t *cfg, unsigned char subframe);
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);
void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, gNB_rxtx_proc_t *proc, int do_meas); void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, gNB_rxtx_proc_t *proc, int do_meas);
void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int subframe);
void nr_init_feptx_thread(RU_t *ru,pthread_attr_t *attr_feptx); void nr_init_feptx_thread(RU_t *ru,pthread_attr_t *attr_feptx);
void nr_feptx_ofdm(RU_t *ru); void nr_feptx_ofdm(RU_t *ru);
void nr_feptx_ofdm_2thread(RU_t *ru); void nr_feptx_ofdm_2thread(RU_t *ru);
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "SIMULATION/TOOLS/sim.h"
#include "SIMULATION/RF/rf.h"
#include "PHY/types.h"
#include "PHY/defs_nr_common.h"
#include "PHY/defs_nr_UE.h"
#include "PHY/defs_gNB.h"
#include "PHY/INIT/phy_init.h"
#include "SCHED_NR/sched_nr.h"
#include "common/ran_context.h"
PHY_VARS_gNB *gNB;
PHY_VARS_NR_UE *UE;
RAN_CONTEXT_t RC;
double cpuf;
// dummy functions
int nfapi_mode=0;
int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0);}
int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); }
int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { return(0); }
int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req) { return(0); }
int oai_nfapi_nr_dl_config_req(nfapi_nr_dl_config_request_t *dl_config_req) {return(0);}
uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn) {return(0);}
int32_t get_uldl_offset(int eutra_bandP) {return(0);}
NR_IF_Module_t *NR_IF_Module_init(int Mod_id){return(NULL);}
void exit_fun(const char *s) { exit(-1); }
int main(int argc, char **argv)
{
char c;
int i,l,aa;
double sigma2, sigma2_dB=0,SNR,snr0=-2.0,snr1;
uint8_t snr1set=0;
int **txdata,**txdata1,**txdata2;
double **s_re,**s_im,**s_re1,**s_im1,**s_re2,**s_im2,**r_re,**r_im,**r_re1,**r_im1,**r_re2,**r_im2;
double iqim = 0.0;
unsigned char pbch_pdu[6];
// int sync_pos, sync_pos_slot;
// FILE *rx_frame_file;
FILE *output_fd = NULL;
uint8_t write_output_file=0;
//int result;
int freq_offset;
// int subframe_offset;
// char fname[40], vname[40];
int trial, n_trials, ntrials=1, n_errors,n_errors2,n_alamouti;
uint8_t transmission_mode = 1,n_tx=1,n_rx=1;
uint16_t Nid_cell=0;
int n_frames=1;
channel_desc_t *gNB2UE;
uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
uint8_t extended_prefix_flag=0;
int8_t interf1=-21,interf2=-21;
FILE *input_fd=NULL,*pbch_file_fd=NULL;
char input_val_str[50],input_val_str2[50];
// double input_val1,input_val2;
// uint16_t amask=0;
uint8_t frame_mod4,num_pdcch_symbols = 0;
uint16_t NB_RB=25;
SCM_t channel_model=AWGN;//Rayleigh1_anticorr;
//DCI_ALLOC_t dci_alloc[8];
uint8_t abstraction_flag=0;//,calibration_flag=0;
double pbch_sinr;
int pbch_tx_ant;
uint8_t N_RB_DL=106,mu=1;
unsigned char frame_type = 0;
unsigned char pbch_phase = 0;
int frame=0,subframe=0;
int frame_length_complex_samples;
int frame_length_complex_samples_no_prefix;
NR_DL_FRAME_PARMS *frame_parms;
cpuf = get_cpu_freq_GHz();
if ( load_configmodule(argc,argv) == 0) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
}
logInit();
while ((c = getopt (argc, argv, "f:hA:pf:g:i:j:n:s:S:t:x:y:z:N:F:GR:dP:")) != -1) {
switch (c) {
case 'f':
write_output_file=1;
output_fd = fopen(optarg,"w");
if (output_fd==NULL) {
printf("Error opening %s\n",optarg);
exit(-1);
}
break;
case 'd':
frame_type = 1;
break;
case 'g':
switch((char)*optarg) {
case 'A':
channel_model=SCM_A;
break;
case 'B':
channel_model=SCM_B;
break;
case 'C':
channel_model=SCM_C;
break;
case 'D':
channel_model=SCM_D;
break;
case 'E':
channel_model=EPA;
break;
case 'F':
channel_model=EVA;
break;
case 'G':
channel_model=ETU;
break;
default:
msg("Unsupported channel model!\n");
exit(-1);
}
break;
case 'i':
interf1=atoi(optarg);
break;
case 'j':
interf2=atoi(optarg);
break;
case 'n':
n_frames = atoi(optarg);
break;
case 's':
snr0 = atof(optarg);
msg("Setting SNR0 to %f\n",snr0);
break;
case 'S':
snr1 = atof(optarg);
snr1set=1;
msg("Setting SNR1 to %f\n",snr1);
break;
/*
case 't':
Td= atof(optarg);
break;
*/
case 'p':
extended_prefix_flag=1;
break;
/*
case 'r':
ricean_factor = pow(10,-.1*atof(optarg));
if (ricean_factor>1) {
printf("Ricean factor must be between 0 and 1\n");
exit(-1);
}
break;
*/
case 'x':
transmission_mode=atoi(optarg);
if ((transmission_mode!=1) &&
(transmission_mode!=2) &&
(transmission_mode!=6)) {
msg("Unsupported transmission mode %d\n",transmission_mode);
exit(-1);
}
break;
case 'y':
n_tx=atoi(optarg);
if ((n_tx==0) || (n_tx>2)) {
msg("Unsupported number of tx antennas %d\n",n_tx);
exit(-1);
}
break;
case 'z':
n_rx=atoi(optarg);
if ((n_rx==0) || (n_rx>2)) {
msg("Unsupported number of rx antennas %d\n",n_rx);
exit(-1);
}
break;
case 'A':
abstraction_flag=1;
ntrials=10000;
msg("Running Abstraction test\n");
pbch_file_fd=fopen(optarg,"r");
if (pbch_file_fd==NULL) {
printf("Problem with filename %s\n",optarg);
exit(-1);
}
break;
// case 'C':
// calibration_flag=1;
// msg("Running Abstraction calibration for Bias removal\n");
// break;
case 'N':
Nid_cell = atoi(optarg);
break;
case 'R':
N_RB_DL = atoi(optarg);
break;
case 'F':
input_fd = fopen(optarg,"r");
if (input_fd==NULL) {
printf("Problem with filename %s\n",optarg);
exit(-1);
}
break;
case 'P':
pbch_phase = atoi(optarg);
if (pbch_phase>3)
printf("Illegal PBCH phase (0-3) got %d\n",pbch_phase);
break;
default:
case 'h':
printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n",
argv[0]);
printf("-h This message\n");
printf("-p Use extended prefix mode\n");
printf("-d Use TDD\n");
printf("-n Number of frames to simulate\n");
printf("-s Starting SNR, runs from SNR0 to SNR0 + 5 dB. If n_frames is 1 then just SNR is simulated\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-t Delay spread for multipath channel\n");
printf("-g [A,B,C,D,E,F,G] Use 3GPP SCM (A,B,C,D) or 36-101 (E-EPA,F-EVA,G-ETU) models (ignores delay spread and Ricean factor)\n");
printf("-x Transmission mode (1,2,6 for the moment)\n");
printf("-y Number of TX antennas used in eNB\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("-j Relative strength of second intefering eNB (in dB) - cell_id mod 3 = 2\n");
printf("-N Nid_cell\n");
printf("-R N_RB_DL\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-A Interpolation_filname Run with Abstraction to generate Scatter plot using interpolation polynomial in file\n");
// printf("-C Generate Calibration information for Abstraction (effective SNR adjustment to remove Pe bias w.r.t. AWGN)\n");
printf("-f Output filename (.txt format) for Pe/SNR results\n");
printf("-F Input filename (.txt format) for RX conformance testing\n");
exit (-1);
break;
}
}
s_re = malloc(2*sizeof(double*));
s_im = malloc(2*sizeof(double*));
s_re1 = malloc(2*sizeof(double*));
s_im1 = malloc(2*sizeof(double*));
s_re2 = malloc(2*sizeof(double*));
s_im2 = malloc(2*sizeof(double*));
r_re = malloc(2*sizeof(double*));
r_im = malloc(2*sizeof(double*));
r_re1 = malloc(2*sizeof(double*));
r_im1 = malloc(2*sizeof(double*));
r_re2 = malloc(2*sizeof(double*));
r_im2 = malloc(2*sizeof(double*));
gNB2UE = new_channel_desc_scm(n_tx,
n_rx,
channel_model,
61.44e6, //N_RB2sampling_rate(N_RB_DL),
40e6, //N_RB2channel_bandwidth(N_RB_DL),
0,
0,
0);
if (gNB2UE==NULL) {
msg("Problem generating channel model. Exiting.\n");
exit(-1);
}
RC.gNB = (PHY_VARS_gNB***) malloc(sizeof(PHY_VARS_gNB **));
RC.gNB[0] = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0][0] = malloc(sizeof(PHY_VARS_gNB));
gNB = RC.gNB[0][0];
frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH)
//NR_PHY_Config_t *phy_config = malloc(sizeof(NR_PHY_Config_t));
nr_phy_config_request_sim(gNB);
phy_init_nr_gNB(gNB,0,0);
frame_length_complex_samples = frame_parms->samples_per_subframe;
frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP;
for (i=0; i<2; i++) {
s_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(s_re[i],frame_length_complex_samples*sizeof(double));
s_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(s_im[i],frame_length_complex_samples*sizeof(double));
r_re[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_re[i],frame_length_complex_samples*sizeof(double));
r_im[i] = malloc(frame_length_complex_samples*sizeof(double));
bzero(r_im[i],frame_length_complex_samples*sizeof(double));
}
if (pbch_file_fd!=NULL) {
load_pbch_desc(pbch_file_fd);
}
if (input_fd==NULL) {
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);
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);
// multipath channel
/*
for (i=0; i<frame_length_complex_samples; i++) {
for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
s_re[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)]);
s_im[aa][i] = ((double)(((short *)txdata[aa]))[(i<<1)+1]);
}
}
*/
for (SNR=snr0; SNR<snr1; SNR+=.2) {
n_errors = 0;
n_errors2 = 0;
n_alamouti = 0;
for (trial=0; trial<n_trials; trial++) {
multipath_channel(gNB2UE,s_re,s_im,r_re,r_im,frame_length_complex_samples,0);
sigma2_dB = 10*log10((double)tx_lev) +10*log10((double)gNB->frame_parms.ofdm_symbol_size/(double)(12*NB_RB)) - SNR;
if (n_frames==1)
printf("sigma2_dB %f (SNR %f dB) tx_lev_dB %f,%f,%f\n",sigma2_dB,SNR,
10*log10((double)tx_lev),
10*log10((double)tx_lev1),
10*log10((double)tx_lev2));
//AWGN
sigma2 = pow(10,sigma2_dB/10);
//printf("n_trial %d\n",n_trials);
for (i=0; i<frame_length_complex_samples; i++) {
for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
((short*) UE->common_vars.rxdata[aa])[2*i] = (short) ((r_re[aa][i] +sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
((short*) UE->common_vars.rxdata[aa])[2*i+1] = (short) ((r_im[aa][i] + (iqim*r_re[aa][i]) + sqrt(sigma2/2)*gaussdouble(0.0,1.0)));
}
}
} //noise trials
} // NSR
for (i=0; i<2; i++) {
free(s_re[i]);
free(s_im[i]);
free(r_re[i]);
free(r_im[i]);
}
free(s_re);
free(s_im);
free(r_re);
free(r_im);
if (write_output_file)
fclose(output_fd);
return(n_errors);
}
...@@ -39,9 +39,10 @@ typedef int nfapi_nr_pfcch_commonSearchSpaces_t; ...@@ -39,9 +39,10 @@ typedef int nfapi_nr_pfcch_commonSearchSpaces_t;
#include "../nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h" #include "../nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h"
#include "PHY/defs_nr_UE.h" #include "PHY/defs_nr_UE.h"
#include "PHY/INIT/init_extern.h"
#include "PHY/phy_extern_nr_ue.h" #include "PHY/phy_extern_nr_ue.h"
#include "PHY/NR_TRANSPORT/nr_transport.h" #include "PHY/INIT/init_extern.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
#include "PHY/NR_REFSIG/ss_pbch_nr.h" #include "PHY/NR_REFSIG/ss_pbch_nr.h"
#include "PHY/NR_REFSIG/pss_nr.h" #include "PHY/NR_REFSIG/pss_nr.h"
...@@ -222,7 +223,7 @@ void set_sequence_sss(PHY_VARS_NR_UE *PHY_vars_UE, int offset, int slot_offset) ...@@ -222,7 +223,7 @@ void set_sequence_sss(PHY_VARS_NR_UE *PHY_vars_UE, int offset, int slot_offset)
} }
#else #else
insert_sss_nr(&tmp, frame_parms); insert_sss_nr(tmp, frame_parms);
#endif #endif
} }
...@@ -393,7 +394,7 @@ int main(int argc, char *argv[]) ...@@ -393,7 +394,7 @@ int main(int argc, char *argv[])
int size_test_position; int size_test_position;
/* this is a pointer to the function in charge of the test */ /* this is a pointer to the function in charge of the test */
int (*p_test_synchro_pss_sss)(PHY_VARS_NR_UE *PHY_vars_UE, int position_symbol, int sequence_number, test_t *test) = test_synchro_pss_sss; int (*p_test_synchro_pss_sss)(PHY_VARS_NR_UE *PHY_vars_UE, int position_symbol, int sequence_number) = test_synchro_pss_sss_nr;
#if 0 #if 0
int Nid_cell[] = { (3*0+0), (3*71+0), (3*21+2), (3*21+2), (3*55+1), (3*111+2) }; int Nid_cell[] = { (3*0+0), (3*71+0), (3*21+2), (3*21+2), (3*55+1), (3*111+2) };
...@@ -413,21 +414,19 @@ int main(int argc, char *argv[]) ...@@ -413,21 +414,19 @@ int main(int argc, char *argv[])
size_test_position = sizeof(test_position)/sizeof(int); size_test_position = sizeof(test_position)/sizeof(int);
printf("***********************************\n"); printf("***********************************\n");
printf(" %s Test NR synchronisation \n", test.test_current); printf(" %s Test NR synchroisation \n", test.test_current);
printf("***********************************\n"); printf("***********************************\n");
for (unsigned int index = 0; index < (sizeof(Nid_cell)/sizeof(int)); index++) { for (unsigned int index = 0; index < (sizeof(Nid_cell)/sizeof(int)); index++) {
PHY_vars_eNB->frame_parms.Nid_cell = Nid_cell[index]; Nid2 = GET_NID2(Nid_cell[index]);
Nid1 = GET_NID1(Nid_cell[index]);
Nid2 = GET_NID2(PHY_vars_eNB->frame_parms.Nid_cell);
Nid1 = GET_NID1(PHY_vars_eNB->frame_parms.Nid_cell);
for (int position = 0; position < size_test_position; position++) { for (int position = 0; position < size_test_position; position++) {
PHY_vars_UE->frame_parms.Nid_cell = (3 * N_ID_1_NUMBER) + N_ID_2_NUMBER; /* set to unvalid value */ PHY_vars_UE->frame_parms.Nid_cell = (3 * N_ID_1_NUMBER) + N_ID_2_NUMBER; /* set to unvalid value */
decoded_pbch = (*p_test_synchro_pss_sss)(PHY_vars_UE, test_position[position], Nid2, &test); /* return phase index which gives phase error from an array */ decoded_pbch = (*p_test_synchro_pss_sss)(PHY_vars_UE, test_position[position], Nid2); /* return phase index which gives phase error from an array */
test.number_of_tests++; test.number_of_tests++;
printf("\n%s ", test.test_current); printf("\n%s ", test.test_current);
......
...@@ -398,7 +398,7 @@ void multipath_tv_channel(channel_desc_t *desc, ...@@ -398,7 +398,7 @@ void multipath_tv_channel(channel_desc_t *desc,
double N_RB2sampling_rate(uint16_t N_RB); double N_RB2sampling_rate(uint16_t N_RB);
double N_RB2channel_bandwidth(uint16_t N_RB); double N_RB2channel_bandwidth(uint16_t N_RB);
#include "targets/RT/USER/rfsim.h" //#include "targets/RT/USER/rfsim.h"
void do_DL_sig(sim_t *sim, void do_DL_sig(sim_t *sim,
uint16_t subframe, uint16_t subframe,
......
...@@ -94,8 +94,6 @@ unsigned short config_frames[4] = {2,9,11,13}; ...@@ -94,8 +94,6 @@ unsigned short config_frames[4] = {2,9,11,13};
// current status is that every UE has a DL scope for a SINGLE eNB (gnb_id=0) // current status is that every UE has a DL scope for a SINGLE eNB (gnb_id=0)
// at eNB 0, an UL scope for every UE // at eNB 0, an UL scope for every UE
short nr_mod_table[NR_MOD_TABLE_SIZE_SHORT] = {0,0,23170,23170,-23170,-23170,23170,23170,23170,-23170,-23170,23170,-23170,-23170};
FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX];
FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
......
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