Commit c16e5831 authored by Parminder Singh's avatar Parminder Singh

Added debug prints in ULSIM for PTRS RE calculations

- Added PTRS Symbols in a slot and Resource elements count in debug print
parent c9523b88
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h" #include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
#include "common/utils/threadPool/thread-pool.h" #include "common/utils/threadPool/thread-pool.h"
#include "PHY/NR_REFSIG/ptrs_nr.h"
#define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0)) #define inMicroS(a) (((double)(a))/(cpu_freq_GHz*1000.0))
#include "SIMULATION/LTE_PHY/common_sim.h" #include "SIMULATION/LTE_PHY/common_sim.h"
...@@ -197,7 +197,10 @@ int main(int argc, char **argv) ...@@ -197,7 +197,10 @@ int main(int argc, char **argv)
int ptrs_arg[2] = {-1,-1};// Invalid values int ptrs_arg[2] = {-1,-1};// Invalid values
/* DMRS TYPE = dmrs_arg[0], Add Pos = dmrs_arg[1] */ /* DMRS TYPE = dmrs_arg[0], Add Pos = dmrs_arg[1] */
int dmrs_arg[2] = {-1,-1};// Invalid values int dmrs_arg[2] = {-1,-1};// Invalid values
uint16_t ptrsSymPos = 0;
uint16_t ptrsSymbPerSlot = 0;
uint16_t ptrsRePerSymb = 0;
UE_nr_rxtx_proc_t UE_proc; UE_nr_rxtx_proc_t UE_proc;
FILE *scg_fd=NULL; FILE *scg_fd=NULL;
int file_offset = 0; int file_offset = 0;
...@@ -210,294 +213,294 @@ int main(int argc, char **argv) ...@@ -210,294 +213,294 @@ int main(int argc, char **argv)
int params_from_file = 0; int params_from_file = 0;
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) { if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) {
exit_fun("[NR_ULSIM] Error, configuration module init failed\n"); exit_fun("[NR_ULSIM] Error, configuration module init failed\n");
} }
//logInit(); //logInit();
randominit(0); randominit(0);
/* initialize the sin table */ /* initialize the sin table */
InitSinLUT(); InitSinLUT();
while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:j:kl:m:n:p:r:s:y:z:F:G:H:M:N:PR:S:T:U:L:")) != -1) { while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:j:kl:m:n:p:r:s:y:z:F:G:H:M:N:PR:S:T:U:L:")) != -1) {
printf("handling optarg %c\n",c); printf("handling optarg %c\n",c);
switch (c) { switch (c) {
/*case 'd': /*case 'd':
frame_type = 1; frame_type = 1;
break;*/ break;*/
case 'a': case 'a':
start_symbol = atoi(optarg); start_symbol = atoi(optarg);
AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol); AssertFatal(start_symbol >= 0 && start_symbol < 13,"start_symbol %d is not in 0..12\n",start_symbol);
break; break;
case 'b': case 'b':
nb_symb_sch = atoi(optarg); nb_symb_sch = atoi(optarg);
AssertFatal(nb_symb_sch > 0 && nb_symb_sch < 15,"start_symbol %d is not in 1..14\n",nb_symb_sch); AssertFatal(nb_symb_sch > 0 && nb_symb_sch < 15,"start_symbol %d is not in 1..14\n",nb_symb_sch);
break; break;
case 'c': case 'c':
n_rnti = atoi(optarg); n_rnti = atoi(optarg);
AssertFatal(n_rnti > 0 && n_rnti<=65535,"Illegal n_rnti %x\n",n_rnti); AssertFatal(n_rnti > 0 && n_rnti<=65535,"Illegal n_rnti %x\n",n_rnti);
break; break;
case 'd': case 'd':
delay = atoi(optarg); delay = atoi(optarg);
break; break;
case 'e': case 'e':
msg3_flag = 1; msg3_flag = 1;
break; break;
case 'f': case 'f':
scg_fd = fopen(optarg, "r"); scg_fd = fopen(optarg, "r");
if (scg_fd == NULL) { if (scg_fd == NULL) {
printf("Error opening %s\n", optarg); printf("Error opening %s\n", optarg);
exit(-1); exit(-1);
} }
break; break;
case 'g': case 'g':
switch ((char) *optarg) { switch ((char) *optarg) {
case 'A': case 'A':
channel_model = SCM_A; channel_model = SCM_A;
break; break;
case 'B': case 'B':
channel_model = SCM_B; channel_model = SCM_B;
break; break;
case 'C': case 'C':
channel_model = SCM_C; channel_model = SCM_C;
break; break;
case 'D': case 'D':
channel_model = SCM_D; channel_model = SCM_D;
break; break;
case 'E': case 'E':
channel_model = EPA; channel_model = EPA;
break; break;
case 'F': case 'F':
channel_model = EVA; channel_model = EVA;
break; break;
case 'G': case 'G':
channel_model = ETU; channel_model = ETU;
break; break;
case 'H': case 'H':
channel_model = TDL_C; channel_model = TDL_C;
DS_TDL = .030; // 30 ns DS_TDL = .030; // 30 ns
break; break;
case 'I': case 'I':
channel_model = TDL_C; channel_model = TDL_C;
DS_TDL = .3; // 300ns DS_TDL = .3; // 300ns
break; break;
case 'J': case 'J':
channel_model=TDL_D; channel_model=TDL_D;
DS_TDL = .03; DS_TDL = .03;
break; break;
default: default:
printf("Unsupported channel model!\n"); printf("Unsupported channel model!\n");
exit(-1); exit(-1);
} }
break; break;
/*case 'i': /*case 'i':
interf1 = atoi(optarg); interf1 = atoi(optarg);
break; break;
case 'j': case 'j':
interf2 = atoi(optarg); interf2 = atoi(optarg);
break;*/ break;*/
case 'k': case 'k':
printf("Setting threequarter_fs_flag\n"); printf("Setting threequarter_fs_flag\n");
openair0_cfg[0].threequarter_fs= 1; openair0_cfg[0].threequarter_fs= 1;
break; break;
case 'l': case 'l':
nb_symb_sch = atoi(optarg); nb_symb_sch = atoi(optarg);
break; break;
case 'm': case 'm':
Imcs = atoi(optarg); Imcs = atoi(optarg);
break; break;
case 'n': case 'n':
n_trials = atoi(optarg); n_trials = atoi(optarg);
break; break;
case 'p': case 'p':
extended_prefix_flag = 1; extended_prefix_flag = 1;
break; break;
case 'r': case 'r':
nb_rb = atoi(optarg); nb_rb = atoi(optarg);
break; break;
case 's': case 's':
snr0 = atof(optarg); snr0 = atof(optarg);
printf("Setting SNR0 to %f\n", snr0); printf("Setting SNR0 to %f\n", snr0);
break; break;
/* /*
case 't': case 't':
eff_tp_check = (float)atoi(optarg)/100; eff_tp_check = (float)atoi(optarg)/100;
break; break;
*/ */
/* /*
case 'r': case 'r':
ricean_factor = pow(10,-.1*atof(optarg)); ricean_factor = pow(10,-.1*atof(optarg));
if (ricean_factor>1) { if (ricean_factor>1) {
printf("Ricean factor must be between 0 and 1\n"); printf("Ricean factor must be between 0 and 1\n");
exit(-1); exit(-1);
} }
break; break;
*/ */
/*case 'x': /*case 'x':
transmission_mode = atoi(optarg); transmission_mode = atoi(optarg);
break;*/ break;*/
case 'y': case 'y':
n_tx = atoi(optarg); n_tx = atoi(optarg);
if ((n_tx == 0) || (n_tx > 2)) { if ((n_tx == 0) || (n_tx > 2)) {
printf("Unsupported number of tx antennas %d\n", n_tx); printf("Unsupported number of tx antennas %d\n", n_tx);
exit(-1); exit(-1);
} }
break; break;
case 'z': case 'z':
n_rx = atoi(optarg); n_rx = atoi(optarg);
if ((n_rx == 0) || (n_rx > 2)) { if ((n_rx == 0) || (n_rx > 2)) {
printf("Unsupported number of rx antennas %d\n", n_rx); printf("Unsupported number of rx antennas %d\n", n_rx);
exit(-1); exit(-1);
} }
break; break;
case 'F': case 'F':
input_fd = fopen(optarg, "r"); input_fd = fopen(optarg, "r");
if (input_fd == NULL) { if (input_fd == NULL) {
printf("Problem with filename %s\n", optarg); printf("Problem with filename %s\n", optarg);
exit(-1); exit(-1);
} }
break; break;
case 'G': case 'G':
file_offset = atoi(optarg); file_offset = atoi(optarg);
break; break;
case 'H': case 'H':
slot = atoi(optarg); slot = atoi(optarg);
break; break;
case 'M': case 'M':
// SSB_positions = atoi(optarg); // SSB_positions = atoi(optarg);
break; break;
case 'N': case 'N':
// Nid_cell = atoi(optarg); // Nid_cell = atoi(optarg);
break; break;
case 'R': case 'R':
N_RB_DL = atoi(optarg); N_RB_DL = atoi(optarg);
N_RB_UL = N_RB_DL; N_RB_UL = N_RB_DL;
break; break;
case 'S': case 'S':
snr1 = atof(optarg); snr1 = atof(optarg);
snr1set = 1; snr1set = 1;
printf("Setting SNR1 to %f\n", snr1); printf("Setting SNR1 to %f\n", snr1);
break; break;
case 'P': case 'P':
print_perf=1; print_perf=1;
opp_enabled=1; opp_enabled=1;
break; break;
case 'L': case 'L':
loglvl = atoi(optarg); loglvl = atoi(optarg);
break; break;
case 'T': case 'T':
enable_ptrs=1; enable_ptrs=1;
for(i=0; i < atoi(optarg); i++){ for(i=0; i < atoi(optarg); i++){
ptrs_arg[i] = atoi(argv[optind++]); ptrs_arg[i] = atoi(argv[optind++]);
} }
break; break;
case 'U':
modify_dmrs = 1;
for(i=0; i < atoi(optarg); i++){
dmrs_arg[i] = atoi(argv[optind++]);
}
break;
case 'Q':
params_from_file = 1;
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("-d Use TDD\n");
printf("-d Introduce delay in terms of number of samples\n");
printf("-f Number of frames to simulate\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("-h This message\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("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
printf("-m MCS value\n");
printf("-n Number of trials to simulate\n");
printf("-p Use extended prefix mode\n");
printf("-t Delay spread for multipath channel\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("-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 Input filename (.txt format) for RX conformance testing\n");
printf("-G Offset of samples to read from file (0 default)\n");
printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-R N_RB_DL\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-P Print ULSCH performances\n");
printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n");
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:3}, e.g. -U 2 0 2 \n");
printf("-Q If -F used, read parameters from file\n");
exit(-1);
break;
} case 'U':
} modify_dmrs = 1;
for(i=0; i < atoi(optarg); i++){
dmrs_arg[i] = atoi(argv[optind++]);
}
break;
case 'Q':
params_from_file = 1;
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("-d Use TDD\n");
printf("-d Introduce delay in terms of number of samples\n");
printf("-f Number of frames to simulate\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("-h This message\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("-s Starting SNR, runs from SNR0 to SNR0 + 10 dB if ending SNR isn't given\n");
printf("-m MCS value\n");
printf("-n Number of trials to simulate\n");
printf("-p Use extended prefix mode\n");
printf("-t Delay spread for multipath channel\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("-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 Input filename (.txt format) for RX conformance testing\n");
printf("-G Offset of samples to read from file (0 default)\n");
printf("-M Multiple SSB positions in burst\n");
printf("-N Nid_cell\n");
printf("-O oversampling factor (1,2,4,8,16)\n");
printf("-R N_RB_DL\n");
printf("-t Acceptable effective throughput (in percentage)\n");
printf("-S Ending SNR, runs from SNR0 to SNR1\n");
printf("-P Print ULSCH performances\n");
printf("-T Enable PTRS, arguments list L_PTRS{0,1,2} K_PTRS{2,4}, e.g. -T 2 0 2 \n");
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:3}, e.g. -U 2 0 2 \n");
printf("-Q If -F used, read parameters from file\n");
exit(-1);
break;
}
}
logInit(); logInit();
set_glog(loglvl); set_glog(loglvl);
T_stdout = 1; T_stdout = 1;
get_softmodem_params()->phy_test = 1; get_softmodem_params()->phy_test = 1;
get_softmodem_params()->do_ra = 0; get_softmodem_params()->do_ra = 0;
get_softmodem_params()->usim_test = 1; get_softmodem_params()->usim_test = 1;
if (snr1set == 0) if (snr1set == 0)
snr1 = snr0 + 10; snr1 = snr0 + 10;
double sampling_frequency; double sampling_frequency;
double bandwidth; double bandwidth;
...@@ -1004,18 +1007,30 @@ int main(int argc, char **argv) ...@@ -1004,18 +1007,30 @@ int main(int argc, char **argv)
multipath_tv_channel(UE2gNB,s_re,s_im,r_re,r_im, multipath_tv_channel(UE2gNB,s_re,s_im,r_re,r_im,
2*slot_length,0); 2*slot_length,0);
} }
for (i=0; i<slot_length; i++) { for (i=0; i<slot_length; i++) {
for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) { for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)] = (int16_t)((tx_gain*r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i) + (delay*2)] = (int16_t)((tx_gain*r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point
((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1 + (delay*2)] = (int16_t)((tx_gain*r_im[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); ((int16_t*) &gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1 + (delay*2)] = (int16_t)((tx_gain*r_im[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0)));
/* Add phase noise if enabled */ /* Add phase noise if enabled */
if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
phase_noise(ts, &((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)], phase_noise(ts, &((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)],
&((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1]); &((int16_t*)&gNB->common_vars.rxdata[ap][slot_offset])[(2*i)+1]);
} }
} }
} }
}
if(pusch_pdu->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS)
{
set_ptrs_symb_idx(&ptrsSymPos,
pusch_pdu->nr_of_symbols,
pusch_pdu->start_symbol_index,
1<<ptrs_time_density,
pusch_pdu->ul_dmrs_symb_pos);
ptrsSymbPerSlot = get_ptrs_symbols_in_slot(ptrsSymPos, pusch_pdu->start_symbol_index, pusch_pdu->nr_of_symbols);
ptrsRePerSymb = ((pusch_pdu->rb_size + ptrs_freq_density - 1)/ptrs_freq_density);
printf("[ULSIM] PTRS Symbols in a slot: %2d, RE per Symbol: %3d, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb );
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
...@@ -1082,7 +1097,7 @@ int main(int argc, char **argv) ...@@ -1082,7 +1097,7 @@ int main(int argc, char **argv)
} }
/* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */ /* 2*5*(50/2), for RB = 50,K = 2 for 5 OFDM PTRS symbols */
available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) /ptrs_freq_density); available_bits -= 2 * ptrs_symbols * ((nb_rb + ptrs_freq_density - 1) /ptrs_freq_density);
printf("After PTRS subtraction available_bits are : %u \n", available_bits); printf("[ULSIM][PTRS] Available bits are: %5d, removed PTRS bits are: %5d \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb * 2) );
} }
for (i = 0; i < available_bits; i++) { for (i = 0; i < available_bits; i++) {
......
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