Commit 118eb3f7 authored by francescomani's avatar francescomani

fix compilation of phy simulators

parent a9ed3baa
...@@ -158,6 +158,7 @@ int nr_derive_key(int alg_type, uint8_t alg_id, ...@@ -158,6 +158,7 @@ int nr_derive_key(int alg_type, uint8_t alg_id,
} }
void config_common(int Mod_idP, void config_common(int Mod_idP,
int ssb_SubcarrierOffset,
int pdsch_AntennaPorts, int pdsch_AntennaPorts,
NR_ServingCellConfigCommon_t *scc NR_ServingCellConfigCommon_t *scc
); );
...@@ -661,7 +662,7 @@ int main(int argc, char **argv) ...@@ -661,7 +662,7 @@ int main(int argc, char **argv)
NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon; NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon;
NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup)); NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup));
prepare_scc(rrc.carrier.servingcellconfigcommon); prepare_scc(rrc.carrier.servingcellconfigcommon);
uint64_t ssb_bitmap; uint64_t ssb_bitmap = 1;
fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu); fill_scc(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu);
fix_scc(scc,ssb_bitmap); fix_scc(scc,ssb_bitmap);
...@@ -834,7 +835,8 @@ int main(int argc, char **argv) ...@@ -834,7 +835,8 @@ int main(int argc, char **argv)
// generate signal // generate signal
AssertFatal(input_fd==NULL,"Not ready for input signal file\n"); AssertFatal(input_fd==NULL,"Not ready for input signal file\n");
gNB->pbch_configured = 1; gNB->pbch_configured = 1;
gNB->ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234; gNB->ssb[0].ssb_pdu.ssb_pdu_rel15.bchPayload=0x001234;
gNB->ssb[0].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = 0;
//Configure UE //Configure UE
rrc.carrier.MIB = (uint8_t*) malloc(4); rrc.carrier.MIB = (uint8_t*) malloc(4);
...@@ -960,7 +962,7 @@ int main(int argc, char **argv) ...@@ -960,7 +962,7 @@ int main(int argc, char **argv)
printf("[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb ); printf("[DLSIM] PTRS Symbols in a slot: %2u, RE per Symbol: %3u, RE in a slot %4d\n", ptrsSymbPerSlot,ptrsRePerSymb, ptrsSymbPerSlot*ptrsRePerSymb );
} }
if (run_initial_sync) if (run_initial_sync)
nr_common_signal_procedures(gNB,frame,slot); nr_common_signal_procedures(gNB,frame,slot,gNB->ssb[0].ssb_pdu);
else else
phy_procedures_gNB_TX(gNB,frame,slot,0); phy_procedures_gNB_TX(gNB,frame,slot,0);
......
...@@ -119,7 +119,7 @@ void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB, ...@@ -119,7 +119,7 @@ void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char c; char c;
int i,aa;//,l; int i,aa,start_symbol;
double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0; double sigma2, sigma2_dB=10,SNR,snr0=-2.0,snr1=2.0;
double cfo=0; double cfo=0;
uint8_t snr1set=0; uint8_t snr1set=0;
...@@ -426,29 +426,28 @@ int main(int argc, char **argv) ...@@ -426,29 +426,28 @@ int main(int argc, char **argv)
switch (mu) { switch (mu) {
case 1: case 1:
scs = 30000; scs = 30000;
if (N_RB_DL == 217) { frame_parms->Lmax = 8;
fs = 122.88e6; if (N_RB_DL == 217) {
bw = 80e6; fs = 122.88e6;
bw = 80e6;
} }
else if (N_RB_DL == 245) { else if (N_RB_DL == 245) {
fs = 122.88e6; fs = 122.88e6;
bw = 90e6; bw = 90e6;
} }
else if (N_RB_DL == 273) { else if (N_RB_DL == 273) {
fs = 122.88e6; fs = 122.88e6;
bw = 100e6; bw = 100e6;
} }
else if (N_RB_DL == 106) { else if (N_RB_DL == 106) {
fs = 61.44e6; fs = 61.44e6;
bw = 40e6; bw = 40e6;
} }
else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
break; break;
case 3: case 3:
frame_parms->Lmax = 64;
scs = 120000; scs = 120000;
if (N_RB_DL == 66) { if (N_RB_DL == 66) {
fs = 122.88e6; fs = 122.88e6;
...@@ -457,6 +456,7 @@ int main(int argc, char **argv) ...@@ -457,6 +456,7 @@ int main(int argc, char **argv)
else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL); else AssertFatal(1==0,"Unsupported numerology for mu %d, N_RB %d\n",mu, N_RB_DL);
break; break;
} }
// cfo with respect to sub-carrier spacing // cfo with respect to sub-carrier spacing
eps = cfo/scs; eps = cfo/scs;
...@@ -510,7 +510,6 @@ int main(int argc, char **argv) ...@@ -510,7 +510,6 @@ int main(int argc, char **argv)
printf("Allocating %d samples for txdata\n",frame_length_complex_samples); printf("Allocating %d samples for txdata\n",frame_length_complex_samples);
txdata[i] = malloc(frame_length_complex_samples*sizeof(int)); txdata[i] = malloc(frame_length_complex_samples*sizeof(int));
bzero(r_re[i],frame_length_complex_samples*sizeof(int)); bzero(r_re[i],frame_length_complex_samples*sizeof(int));
} }
if (pbch_file_fd!=NULL) { if (pbch_file_fd!=NULL) {
...@@ -536,60 +535,68 @@ int main(int argc, char **argv) ...@@ -536,60 +535,68 @@ int main(int argc, char **argv)
} }
nr_gold_pbch(UE); nr_gold_pbch(UE);
// generate signal // generate signal
if (input_fd==NULL) { if (input_fd==NULL) {
gNB->pbch_configured = 1;
gNB->ssb_pdu.ssb_pdu_rel15.bchPayload = 0;
for (int slot=0;slot<frame_parms->slots_per_frame;slot++) { for (i=0; i<frame_parms->Lmax; i++) {
for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) if((SSB_positions >> i) & 0x01) {
memset(gNB->common_vars.txdataF[aa],0,frame_parms->samples_per_slot_wCP*sizeof(int32_t));
gNB->ssb[i].ssb_pdu.ssb_pdu_rel15.bchPayload = 0;
nr_common_signal_procedures (gNB,frame,slot); gNB->ssb[i].ssb_pdu.ssb_pdu_rel15.SsbBlockIndex = i;
for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) { start_symbol = nr_get_ssb_start_symbol(frame_parms,i);
if (cyclic_prefix_type == 1) { int slot = start_symbol/14;
PHY_ofdm_mod(gNB->common_vars.txdataF[aa],
&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++)
frame_parms->ofdm_symbol_size, memset(gNB->common_vars.txdataF[aa],0,frame_parms->samples_per_slot_wCP*sizeof(int32_t));
12,
frame_parms->nb_prefix_samples, nr_common_signal_procedures (gNB,frame,slot,gNB->ssb[i].ssb_pdu);
CYCLIC_PREFIX);
} else { for (aa=0; aa<gNB->frame_parms.nb_antennas_tx; aa++) {
/* nr_normal_prefix_mod(gNB->common_vars.txdataF[aa], if (cyclic_prefix_type == 1) {
&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], PHY_ofdm_mod(gNB->common_vars.txdataF[aa],
14, &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)],
frame_parms);*/ frame_parms->ofdm_symbol_size,
PHY_ofdm_mod(gNB->common_vars.txdataF[aa], 12,
(int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], frame_parms->nb_prefix_samples,
frame_parms->ofdm_symbol_size, CYCLIC_PREFIX);
1, } else {
frame_parms->nb_prefix_samples0, /*nr_normal_prefix_mod(gNB->common_vars.txdataF[aa],
CYCLIC_PREFIX); &txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)],
14,
apply_nr_rotation(frame_parms, frame_parms);*/
(int16_t*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)], PHY_ofdm_mod(gNB->common_vars.txdataF[aa],
slot, (int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)],
0, frame_parms->ofdm_symbol_size,
1, 1,
frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples0); frame_parms->nb_prefix_samples0,
PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][frame_parms->ofdm_symbol_size], CYCLIC_PREFIX);
(int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size],
frame_parms->ofdm_symbol_size, apply_nr_rotation(frame_parms,
13, (int16_t*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)],
frame_parms->nb_prefix_samples, slot,
CYCLIC_PREFIX); 0,
apply_nr_rotation(frame_parms, 1,
(int16_t*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size], frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples0);
slot,
1, PHY_ofdm_mod(&gNB->common_vars.txdataF[aa][frame_parms->ofdm_symbol_size],
13, (int*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size],
frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples); frame_parms->ofdm_symbol_size,
} 13,
} frame_parms->nb_prefix_samples,
CYCLIC_PREFIX);
apply_nr_rotation(frame_parms,
(int16_t*)&txdata[aa][frame_parms->get_samples_slot_timestamp(slot,frame_parms,0)+frame_parms->nb_prefix_samples0+frame_parms->ofdm_symbol_size],
slot,
1,
13,
frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples);
}
}
}
} }
LOG_M("txsigF0.m","txsF0", gNB->common_vars.txdataF[0],frame_length_complex_samples_no_prefix,1,1); 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) 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); LOG_M("txsigF1.m","txsF1", gNB->common_vars.txdataF[1],frame_length_complex_samples_no_prefix,1,1);
...@@ -598,9 +605,9 @@ int main(int argc, char **argv) ...@@ -598,9 +605,9 @@ int main(int argc, char **argv)
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 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,
input_fd) != frame_length_complex_samples) { input_fd) != frame_length_complex_samples) {
printf("error reading from file\n"); printf("error reading from file\n");
//exit(-1); //exit(-1);
} }
...@@ -684,10 +691,9 @@ int main(int argc, char **argv) ...@@ -684,10 +691,9 @@ int main(int argc, char **argv)
UE->rx_offset=0; UE->rx_offset=0;
uint8_t ssb_index = 0; uint8_t ssb_index = 0;
while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb
frame_parms->ssb_index = ssb_index; UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index);
UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms);
int ssb_slot = (ssb_index>>1)+(n_hf*frame_parms->slots_per_frame); int ssb_slot = (UE->symbol_offset/14)+(n_hf*(frame_parms->slots_per_frame>>1));
for (int i=UE->symbol_offset+1; i<UE->symbol_offset+4; i++) { for (int i=UE->symbol_offset+1; i<UE->symbol_offset+4; i++) {
nr_slot_fep(UE, nr_slot_fep(UE,
&proc, &proc,
...@@ -718,7 +724,7 @@ int main(int argc, char **argv) ...@@ -718,7 +724,7 @@ int main(int argc, char **argv)
payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte); payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte);
for (i=0;i<3;i++){ for (i=0;i<3;i++){
payload_ret += (UE->pbch_vars[0]->decoded_output[i] == (gNB->ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i))); payload_ret += (UE->pbch_vars[0]->decoded_output[i] == (gNB->ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)));
} }
//printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->rx_ind.rx_indication_body->mib_pdu.additional_bits); //printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->rx_ind.rx_indication_body->mib_pdu.additional_bits);
//printf("ret %d\n", payload_ret); //printf("ret %d\n", payload_ret);
......
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