Commit 3eb2b4d7 authored by Thomas Schlichter's avatar Thomas Schlichter

Generalize some frame parameter calculations

Enabling more numerology combinations and 100 MHz support with 3/4 sampling for USRP X300/X310, too.
parent 3743ead9
...@@ -1049,46 +1049,94 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { ...@@ -1049,46 +1049,94 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
int mu = config->ssb_config.scs_common.value; int mu = config->ssb_config.scs_common.value;
int N_RB = config->carrier_config.dl_grid_size[config->ssb_config.scs_common.value].value; int N_RB = config->carrier_config.dl_grid_size[config->ssb_config.scs_common.value].value;
if (mu == NR_MU_0) { //or if LTE if (mu == NR_MU_0) {
if(N_RB == 100) { switch(N_RB) {
case 270:
if (fp->threequarter_fs) {
cfg->sample_rate=92.16e6;
cfg->samples_per_frame = 921600;
cfg->tx_bw = 50e6;
cfg->rx_bw = 50e6;
} else {
cfg->sample_rate=61.44e6;
cfg->samples_per_frame = 614400;
cfg->tx_bw = 50e6;
cfg->rx_bw = 50e6;
}
case 216:
if (fp->threequarter_fs) {
cfg->sample_rate=46.08e6;
cfg->samples_per_frame = 460800;
cfg->tx_bw = 40e6;
cfg->rx_bw = 40e6;
}
else {
cfg->sample_rate=61.44e6;
cfg->samples_per_frame = 614400;
cfg->tx_bw = 40e6;
cfg->rx_bw = 40e6;
}
break;
case 106:
if (fp->threequarter_fs) { if (fp->threequarter_fs) {
cfg->sample_rate=23.04e6; cfg->sample_rate=23.04e6;
cfg->samples_per_frame = 230400; cfg->samples_per_frame = 230400;
cfg->tx_bw = 10e6; cfg->tx_bw = 20e6;
cfg->rx_bw = 10e6; cfg->rx_bw = 20e6;
} else { }
else {
cfg->sample_rate=30.72e6; cfg->sample_rate=30.72e6;
cfg->samples_per_frame = 307200; cfg->samples_per_frame = 307200;
cfg->tx_bw = 20e6;
cfg->rx_bw = 20e6;
}
break;
case 52:
if (fp->threequarter_fs) {
cfg->sample_rate=11.52e6;
cfg->samples_per_frame = 115200;
cfg->tx_bw = 10e6;
cfg->rx_bw = 10e6;
}
else {
cfg->sample_rate=15.36e6;
cfg->samples_per_frame = 153600;
cfg->tx_bw = 10e6; cfg->tx_bw = 10e6;
cfg->rx_bw = 10e6; cfg->rx_bw = 10e6;
} }
} else if(N_RB == 50) { case 25:
cfg->sample_rate=15.36e6; if (fp->threequarter_fs) {
cfg->samples_per_frame = 153600; cfg->sample_rate=5.76e6;
cfg->tx_bw = 5e6; cfg->samples_per_frame = 57600;
cfg->rx_bw = 5e6; cfg->tx_bw = 5e6;
} else if (N_RB == 25) { cfg->rx_bw = 5e6;
cfg->sample_rate=7.68e6; }
cfg->samples_per_frame = 76800; else {
cfg->tx_bw = 2.5e6; cfg->sample_rate=7.68e6;
cfg->rx_bw = 2.5e6; cfg->samples_per_frame = 76800;
} else if (N_RB == 6) { cfg->tx_bw = 5e6;
cfg->sample_rate=1.92e6; cfg->rx_bw = 5e6;
cfg->samples_per_frame = 19200; }
cfg->tx_bw = 1.5e6; break;
cfg->rx_bw = 1.5e6; default:
} else AssertFatal(1==0,"Unknown N_RB %d\n",N_RB); AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu);
}
} else if (mu == NR_MU_1) { } else if (mu == NR_MU_1) {
if(N_RB == 273) { switch(N_RB) {
case 273:
if (fp->threequarter_fs) { if (fp->threequarter_fs) {
AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n"); cfg->sample_rate=184.32e6;
cfg->samples_per_frame = 1843200;
cfg->tx_bw = 100e6;
cfg->rx_bw = 100e6;
} else { } else {
cfg->sample_rate=122.88e6; cfg->sample_rate=122.88e6;
cfg->samples_per_frame = 1228800; cfg->samples_per_frame = 1228800;
cfg->tx_bw = 100e6; cfg->tx_bw = 100e6;
cfg->rx_bw = 100e6; cfg->rx_bw = 100e6;
} }
} else if(N_RB == 217) { break;
case 217:
if (fp->threequarter_fs) { if (fp->threequarter_fs) {
cfg->sample_rate=92.16e6; cfg->sample_rate=92.16e6;
cfg->samples_per_frame = 921600; cfg->samples_per_frame = 921600;
...@@ -1100,7 +1148,8 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { ...@@ -1100,7 +1148,8 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
cfg->tx_bw = 80e6; cfg->tx_bw = 80e6;
cfg->rx_bw = 80e6; cfg->rx_bw = 80e6;
} }
} else if(N_RB == 106) { break;
case 106:
if (fp->threequarter_fs) { if (fp->threequarter_fs) {
cfg->sample_rate=46.08e6; cfg->sample_rate=46.08e6;
cfg->samples_per_frame = 460800; cfg->samples_per_frame = 460800;
...@@ -1113,29 +1162,68 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { ...@@ -1113,29 +1162,68 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
cfg->tx_bw = 40e6; cfg->tx_bw = 40e6;
cfg->rx_bw = 40e6; cfg->rx_bw = 40e6;
} }
} else if(N_RB == 24) { break;
case 51:
if (fp->threequarter_fs) {
cfg->sample_rate=23.04e6;
cfg->samples_per_frame = 230400;
cfg->tx_bw = 20e6;
cfg->rx_bw = 20e6;
}
else {
cfg->sample_rate=30.72e6;
cfg->samples_per_frame = 307200;
cfg->tx_bw = 20e6;
cfg->rx_bw = 20e6;
}
break;
case 24:
if (fp->threequarter_fs) { if (fp->threequarter_fs) {
AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 24\n"); cfg->sample_rate=11.52e6;
} else { cfg->samples_per_frame = 115200;
cfg->tx_bw = 10e6;
cfg->rx_bw = 10e6;
}
else {
cfg->sample_rate=15.36e6; cfg->sample_rate=15.36e6;
cfg->samples_per_frame = 153600; cfg->samples_per_frame = 153600;
cfg->tx_bw = 10e6; cfg->tx_bw = 10e6;
cfg->rx_bw = 10e6; cfg->rx_bw = 10e6;
} }
} else { break;
default:
AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu); AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu);
} }
} else if (mu == NR_MU_3) { } else if (mu == NR_MU_3) {
if (N_RB == 66) { switch(N_RB) {
cfg->sample_rate = 122.88e6; case 66:
cfg->samples_per_frame = 1228800; if (fp->threequarter_fs) {
cfg->tx_bw = 100e6; cfg->sample_rate=184.32e6;
cfg->rx_bw = 100e6; cfg->samples_per_frame = 1843200;
} else if(N_RB == 32) { cfg->tx_bw = 100e6;
cfg->sample_rate=61.44e6; cfg->rx_bw = 100e6;
cfg->samples_per_frame = 614400; } else {
cfg->tx_bw = 50e6; cfg->sample_rate = 122.88e6;
cfg->rx_bw = 50e6; cfg->samples_per_frame = 1228800;
cfg->tx_bw = 100e6;
cfg->rx_bw = 100e6;
}
break;
case 32:
if (fp->threequarter_fs) {
cfg->sample_rate=92.16e6;
cfg->samples_per_frame = 921600;
cfg->tx_bw = 50e6;
cfg->rx_bw = 50e6;
} else {
cfg->sample_rate=61.44e6;
cfg->samples_per_frame = 614400;
cfg->tx_bw = 50e6;
cfg->rx_bw = 50e6;
}
break;
default:
AssertFatal(0==1,"N_RB %d not yet supported for numerology %d\n",N_RB,mu);
} }
} else { } else {
AssertFatal(0 == 1,"Numerology %d not supported for the moment\n",mu); AssertFatal(0 == 1,"Numerology %d not supported for the moment\n",mu);
...@@ -1182,60 +1270,52 @@ int setup_RU_buffers(RU_t *ru) { ...@@ -1182,60 +1270,52 @@ int setup_RU_buffers(RU_t *ru) {
int i,j; int i,j;
int card,ant; int card,ant;
//uint16_t N_TA_offset = 0; //uint16_t N_TA_offset = 0;
NR_DL_FRAME_PARMS *frame_parms; NR_DL_FRAME_PARMS *fp;
nfapi_nr_config_request_scf_t *config = &ru->config; nfapi_nr_config_request_scf_t *config = &ru->config;
if (ru) { if (ru) {
frame_parms = ru->nr_frame_parms; fp = ru->nr_frame_parms;
printf("setup_RU_buffers: frame_parms = %p\n",frame_parms); printf("setup_RU_buffers: frame_parms = %p\n",fp);
} else { } else {
printf("ru pointer is NULL\n"); printf("ru pointer is NULL\n");
return(-1); return(-1);
} }
int mu = config->ssb_config.scs_common.value; int mu = config->ssb_config.scs_common.value;
int N_RB = config->carrier_config.dl_grid_size[config->ssb_config.scs_common.value].value; int N_RB = config->carrier_config.dl_grid_size[config->ssb_config.scs_common.value].value;
if (config->cell_config.frame_duplex_type.value == TDD) { if (config->cell_config.frame_duplex_type.value == TDD) {
int N_TA_offset = config->carrier_config.uplink_frequency.value < 6000000 ? 400 : 431; // reference samples for 25600Tc @ 30.72 Ms/s for FR1, same @ 61.44 Ms/s for FR2 int N_TA_offset = config->carrier_config.uplink_frequency.value < 6000000 ? 400 : 431; // reference samples for 25600Tc @ 30.72 Ms/s for FR1, same @ 61.44 Ms/s for FR2
double factor=1; double factor=1;
switch (mu) { switch (mu) {
case 0: //15 kHz scs case 0: //15 kHz scs
AssertFatal(N_TA_offset == 400,"scs_common 15kHz only for FR1\n"); AssertFatal(N_TA_offset == 400, "scs_common 15kHz only for FR1\n");
if (N_RB <= 25) factor = .25; // 7.68 Ms/s factor = fp->samples_per_subframe / 30720.0;
else if (N_RB <=50) factor = .5; // 15.36 Ms/s break;
else if (N_RB <=75) factor = 1.0; // 30.72 Ms/s case 1: //30 kHz sc
else if (N_RB <=100) factor = 1.0; // 30.72 Ms/s AssertFatal(N_TA_offset == 400, "scs_common 30kHz only for FR1\n");
else AssertFatal(1==0,"Too many PRBS for mu=0\n"); factor = fp->samples_per_subframe / 30720.0;
break; break;
case 1: //30 kHz sc case 2: //60 kHz scs
AssertFatal(N_TA_offset == 400,"scs_common 30kHz only for FR1\n"); AssertFatal(1==0, "scs_common should not be 60 kHz\n");
if (N_RB <= 106) factor = 2.0; // 61.44 Ms/s break;
else if (N_RB <= 275) factor = 4.0; // 122.88 Ms/s case 3: //120 kHz scs
break; AssertFatal(N_TA_offset == 431, "scs_common 120kHz only for FR2\n");
case 2: //60 kHz scs factor = fp->samples_per_subframe / 61440.0;
AssertFatal(1==0,"scs_common should not be 60 kHz\n"); break;
break; case 4: //240 kHz scs
case 3: //120 kHz scs AssertFatal(N_TA_offset == 431, "scs_common 240kHz only for FR2\n");
AssertFatal(N_TA_offset == 431,"scs_common 120kHz only for FR2\n"); factor = fp->samples_per_subframe / 61440.0;
break; break;
case 4: //240 kHz scs default:
AssertFatal(1==0,"scs_common should not be 60 kHz\n"); AssertFatal(1==0, "Invalid scs_common!\n");
if (N_RB <= 32) factor = 1.0; // 61.44 Ms/s
else if (N_RB <= 66) factor = 2.0; // 122.88 Ms/s
else AssertFatal(1==0,"N_RB %d is too big for curretn FR2 implementation\n",N_RB);
break;
if (N_RB == 100) ru->N_TA_offset = 624;
else if (N_RB == 50) ru->N_TA_offset = 624/2;
else if (N_RB == 25) ru->N_TA_offset = 624/4;
} }
if (frame_parms->threequarter_fs == 1) factor = factor*.75;
ru->N_TA_offset = (int)(N_TA_offset * factor); ru->N_TA_offset = (int)(N_TA_offset * factor);
LOG_I(PHY,"RU %d Setting N_TA_offset to %d samples (factor %f, UL Freq %d, N_RB %d)\n",ru->idx,ru->N_TA_offset,factor,
config->carrier_config.uplink_frequency.value, N_RB); LOG_I(PHY,"RU %d Setting N_TA_offset to %d samples (factor %f, UL Freq %d, N_RB %d, mu %d)\n",ru->idx,ru->N_TA_offset,factor,
config->carrier_config.uplink_frequency.value, N_RB, mu);
} }
else ru->N_TA_offset = 0; else ru->N_TA_offset = 0;
......
...@@ -135,9 +135,6 @@ double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0},{20,0,0,0}}; ...@@ -135,9 +135,6 @@ double rx_gain[MAX_NUM_CCs][4] = {{110,0,0,0},{20,0,0,0}};
double rx_gain_off = 0.0; double rx_gain_off = 0.0;
double sample_rate=30.72e6;
double bw = 10.0e6;
static int tx_max_power[MAX_NUM_CCs]; /* = {0,0}*/; static int tx_max_power[MAX_NUM_CCs]; /* = {0,0}*/;
...@@ -475,93 +472,6 @@ void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs], ...@@ -475,93 +472,6 @@ void set_default_frame_parms(nfapi_nr_config_request_scf_t *config[MAX_NUM_CCs],
} }
} }
/*
void init_openair0(void) {
int card;
int i;
for (card=0; card<MAX_CARDS; card++) {
openair0_cfg[card].mmapped_dma=mmapped_dma;
openair0_cfg[card].configFilename = NULL;
if(config[0]->rf_config.dl_carrier_bandwidth.value == 100) {
if (frame_parms[0]->threequarter_fs) {
openair0_cfg[card].sample_rate=23.04e6;
openair0_cfg[card].samples_per_frame = 230400;
openair0_cfg[card].tx_bw = 10e6;
openair0_cfg[card].rx_bw = 10e6;
} else {
openair0_cfg[card].sample_rate=30.72e6;
openair0_cfg[card].samples_per_frame = 307200;
openair0_cfg[card].tx_bw = 10e6;
openair0_cfg[card].rx_bw = 10e6;
}
} else if(config[0]->rf_config.dl_carrier_bandwidth.value == 50) {
openair0_cfg[card].sample_rate=15.36e6;
openair0_cfg[card].samples_per_frame = 153600;
openair0_cfg[card].tx_bw = 5e6;
openair0_cfg[card].rx_bw = 5e6;
} else if (config[0]->rf_config.dl_carrier_bandwidth.value == 25) {
openair0_cfg[card].sample_rate=7.68e6;
openair0_cfg[card].samples_per_frame = 76800;
openair0_cfg[card].tx_bw = 2.5e6;
openair0_cfg[card].rx_bw = 2.5e6;
} else if (config[0]->rf_config.dl_carrier_bandwidth.value == 6) {
openair0_cfg[card].sample_rate=1.92e6;
openair0_cfg[card].samples_per_frame = 19200;
openair0_cfg[card].tx_bw = 1.5e6;
openair0_cfg[card].rx_bw = 1.5e6;
}
if (config[0]->subframe_config.duplex_mode.value==TDD)
openair0_cfg[card].duplex_mode = duplex_mode_TDD;
else //FDD
openair0_cfg[card].duplex_mode = duplex_mode_FDD;
printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value,
RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value );
openair0_cfg[card].Mod_id = 0;
openair0_cfg[card].num_rb_dl=config[0]->rf_config.dl_carrier_bandwidth.value;
openair0_cfg[card].clock_source = clock_source;
openair0_cfg[card].tx_num_channels=min(2,RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value );
openair0_cfg[card].rx_num_channels=min(2,RC.gNB[0]->gNB_config.rf_config.tx_antenna_ports.value );
for (i=0; i<4; i++) {
if (i<openair0_cfg[card].tx_num_channels)
openair0_cfg[card].tx_freq[i] = downlink_frequency[0][i] ;
else
openair0_cfg[card].tx_freq[i]=0.0;
if (i<openair0_cfg[card].rx_num_channels)
openair0_cfg[card].rx_freq[i] =downlink_frequency[0][i] + uplink_frequency_offset[0][i] ;
else
openair0_cfg[card].rx_freq[i]=0.0;
openair0_cfg[card].autocal[i] = 1;
openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
openair0_cfg[card].rx_gain[i] = RC.gNB[0]->rx_total_gain_dB;
openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file;
printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
card,i, openair0_cfg[card].tx_gain[i],
openair0_cfg[card].rx_gain[i],
openair0_cfg[card].tx_freq[i],
openair0_cfg[card].rx_freq[i]);
}
} // for loop on cards
}
*/
void wait_RUs(void) { void wait_RUs(void) {
LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask); LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask);
// wait for all RUs to be configured over fronthaul // wait for all RUs to be configured over fronthaul
......
...@@ -237,43 +237,6 @@ static void UE_synch(void *arg) { ...@@ -237,43 +237,6 @@ static void UE_synch(void *arg) {
openair0_cfg[UE->rf_map.card].rx_freq[0], openair0_cfg[UE->rf_map.card].rx_freq[0],
openair0_cfg[UE->rf_map.card].tx_freq[0]); openair0_cfg[UE->rf_map.card].tx_freq[0]);
// reconfigure for potentially different bandwidth
switch(UE->frame_parms.N_RB_DL) {
case 6:
openair0_cfg[UE->rf_map.card].sample_rate =1.92e6;
openair0_cfg[UE->rf_map.card].rx_bw =.96e6;
openair0_cfg[UE->rf_map.card].tx_bw =.96e6;
// openair0_cfg[0].rx_gain[0] -= 12;
break;
case 25:
openair0_cfg[UE->rf_map.card].sample_rate =7.68e6;
openair0_cfg[UE->rf_map.card].rx_bw =2.5e6;
openair0_cfg[UE->rf_map.card].tx_bw =2.5e6;
// openair0_cfg[0].rx_gain[0] -= 6;
break;
case 50:
openair0_cfg[UE->rf_map.card].sample_rate =15.36e6;
openair0_cfg[UE->rf_map.card].rx_bw =5.0e6;
openair0_cfg[UE->rf_map.card].tx_bw =5.0e6;
// openair0_cfg[0].rx_gain[0] -= 3;
break;
case 100:
openair0_cfg[UE->rf_map.card].sample_rate=30.72e6;
openair0_cfg[UE->rf_map.card].rx_bw=10.0e6;
openair0_cfg[UE->rf_map.card].tx_bw=10.0e6;
// openair0_cfg[0].rx_gain[0] -= 0;
break;
case 66:
openair0_cfg[UE->rf_map.card].sample_rate=122.88e6;
openair0_cfg[UE->rf_map.card].rx_bw=100.e6;
openair0_cfg[UE->rf_map.card].tx_bw=100.e6;
break;
}
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0); UE->rfdevice.trx_set_freq_func(&UE->rfdevice,&openair0_cfg[0],0);
//UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]); //UE->rfdevice.trx_set_gains_func(&openair0,&openair0_cfg[0]);
......
...@@ -145,7 +145,6 @@ int chain_offset = 0; ...@@ -145,7 +145,6 @@ int chain_offset = 0;
int card_offset = 0; int card_offset = 0;
uint64_t num_missed_slots = 0; // counter for the number of missed slots uint64_t num_missed_slots = 0; // counter for the number of missed slots
int transmission_mode = 1; int transmission_mode = 1;
int numerology = 0;
int usrp_tx_thread = 0; int usrp_tx_thread = 0;
int oaisim_flag = 0; int oaisim_flag = 0;
int emulate_rf = 0; int emulate_rf = 0;
...@@ -316,90 +315,10 @@ void init_openair0(void) { ...@@ -316,90 +315,10 @@ void init_openair0(void) {
for (card=0; card<MAX_CARDS; card++) { for (card=0; card<MAX_CARDS; card++) {
uint64_t dl_carrier, ul_carrier; uint64_t dl_carrier, ul_carrier;
openair0_cfg[card].configFilename = NULL; openair0_cfg[card].configFilename = NULL;
openair0_cfg[card].threequarter_fs = frame_parms->threequarter_fs; openair0_cfg[card].threequarter_fs = frame_parms->threequarter_fs;
numerology = frame_parms->numerology_index; openair0_cfg[card].sample_rate = frame_parms->samples_per_subframe * 1e3;
if(frame_parms->N_RB_DL == 24) { openair0_cfg[card].samples_per_frame = frame_parms->samples_per_frame;
if (numerology==1) {
openair0_cfg[card].sample_rate=15.36e6;
openair0_cfg[card].samples_per_frame = 153600;
} else {
LOG_E(PHY,"Unsupported numerology!\n");
exit(-1);
}
}else if(frame_parms->N_RB_DL == 66) {
if (numerology==3) {
openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800;
} else {
LOG_E(PHY,"Unsupported numerology! FR2 supports only 120KHz SCS for now.\n");
exit(-1);
}
}else if(frame_parms->N_RB_DL == 32) {
if (numerology==3) {
openair0_cfg[card].sample_rate=61.44e6;
openair0_cfg[card].samples_per_frame = 614400;
} else {
LOG_E(PHY,"Unsupported numerology! FR2 supports only 120KHz SCS for now.\n");
exit(-1);
}
}else if(frame_parms->N_RB_DL == 217) {
if (numerology==1) {
if (frame_parms->threequarter_fs) {
openair0_cfg[card].sample_rate=92.16e6;
openair0_cfg[card].samples_per_frame = 921600;
}
else {
openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800;
}
} else {
LOG_E(PHY,"Unsupported numerology!\n");
exit(-1);
}
} else if(frame_parms->N_RB_DL == 273) {
if (numerology==1) {
if (frame_parms->threequarter_fs) {
AssertFatal(0 == 1,"three quarter sampling not supported for N_RB 273\n");
}
else {
openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800;
}
} else {
LOG_E(PHY,"Unsupported numerology!\n");
exit(-1);
}
} else if(frame_parms->N_RB_DL == 106) {
if (numerology==0) {
if (frame_parms->threequarter_fs) {
openair0_cfg[card].sample_rate=23.04e6;
openair0_cfg[card].samples_per_frame = 230400;
} else {
openair0_cfg[card].sample_rate=30.72e6;
openair0_cfg[card].samples_per_frame = 307200;
}
} else if (numerology==1) {
if (frame_parms->threequarter_fs) {
openair0_cfg[card].sample_rate=46.08e6;
openair0_cfg[card].samples_per_frame = 460800;
}
else {
openair0_cfg[card].sample_rate=61.44e6;
openair0_cfg[card].samples_per_frame = 614400;
}
} else if (numerology==2) {
openair0_cfg[card].sample_rate=122.88e6;
openair0_cfg[card].samples_per_frame = 1228800;
} else {
LOG_E(PHY,"Unsupported numerology!\n");
exit(-1);
}
}
else {
LOG_E(PHY,"Unknown NB_RB %d!\n",frame_parms->N_RB_DL);
exit(-1);
}
if (frame_parms->frame_type==TDD) if (frame_parms->frame_type==TDD)
openair0_cfg[card].duplex_mode = duplex_mode_TDD; openair0_cfg[card].duplex_mode = duplex_mode_TDD;
...@@ -413,8 +332,9 @@ void init_openair0(void) { ...@@ -413,8 +332,9 @@ void init_openair0(void) {
openair0_cfg[card].tx_num_channels = min(2, frame_parms->nb_antennas_tx); openair0_cfg[card].tx_num_channels = min(2, frame_parms->nb_antennas_tx);
openair0_cfg[card].rx_num_channels = min(2, frame_parms->nb_antennas_rx); openair0_cfg[card].rx_num_channels = min(2, frame_parms->nb_antennas_rx);
LOG_I(PHY, "HW: Configuring card %d, tx/rx num_channels %d/%d, duplex_mode %s\n", LOG_I(PHY, "HW: Configuring card %d, sample_rate %f, tx/rx num_channels %d/%d, duplex_mode %s\n",
card, card,
openair0_cfg[card].sample_rate,
openair0_cfg[card].tx_num_channels, openair0_cfg[card].tx_num_channels,
openair0_cfg[card].rx_num_channels, openair0_cfg[card].rx_num_channels,
duplex_mode[openair0_cfg[card].duplex_mode]); duplex_mode[openair0_cfg[card].duplex_mode]);
......
...@@ -507,50 +507,36 @@ void init_N_TA_offset(PHY_VARS_NR_UE *ue){ ...@@ -507,50 +507,36 @@ void init_N_TA_offset(PHY_VARS_NR_UE *ue){
if (fp->frame_type == FDD) { if (fp->frame_type == FDD) {
ue->N_TA_offset = 0; ue->N_TA_offset = 0;
} else { } else {
int N_RB = fp->N_RB_DL;
int N_TA_offset = fp->ul_CarrierFreq < 6e9 ? 400 : 431; // reference samples for 25600Tc @ 30.72 Ms/s for FR1, same @ 61.44 Ms/s for FR2 int N_TA_offset = fp->ul_CarrierFreq < 6e9 ? 400 : 431; // reference samples for 25600Tc @ 30.72 Ms/s for FR1, same @ 61.44 Ms/s for FR2
double factor = 1;
double factor = 1.0;
switch (fp->numerology_index) { switch (fp->numerology_index) {
case 0: //15 kHz scs case 0: //15 kHz scs
AssertFatal(N_TA_offset == 400, "scs_common 15kHz only for FR1\n"); AssertFatal(N_TA_offset == 400, "scs_common 15kHz only for FR1\n");
if (N_RB <= 25) factor = .25; // 7.68 Ms/s factor = fp->samples_per_subframe / 30720.0;
else if (N_RB <=50) factor = .5; // 15.36 Ms/s
else if (N_RB <=75) factor = 1.0; // 30.72 Ms/s
else if (N_RB <=100) factor = 1.0; // 30.72 Ms/s
else AssertFatal(1==0, "Too many PRBS for mu=0\n");
break; break;
case 1: //30 kHz sc case 1: //30 kHz sc
AssertFatal(N_TA_offset == 400, "scs_common 30kHz only for FR1\n"); AssertFatal(N_TA_offset == 400, "scs_common 30kHz only for FR1\n");
if (N_RB <= 106) factor = 2.0; // 61.44 Ms/s factor = fp->samples_per_subframe / 30720.0;
else if (N_RB <= 275) factor = 4.0; // 122.88 Ms/s
break; break;
case 2: //60 kHz scs case 2: //60 kHz scs
AssertFatal(1==0, "scs_common should not be 60 kHz\n"); AssertFatal(1==0, "scs_common should not be 60 kHz\n");
break; break;
case 3: //120 kHz scs case 3: //120 kHz scs
AssertFatal(N_TA_offset == 431, "scs_common 120kHz only for FR2\n"); AssertFatal(N_TA_offset == 431, "scs_common 120kHz only for FR2\n");
factor = fp->samples_per_subframe / 61440.0;
break; break;
case 4: //240 kHz scs case 4: //240 kHz scs
AssertFatal(1==0, "scs_common should not be 60 kHz\n"); AssertFatal(N_TA_offset == 431, "scs_common 240kHz only for FR2\n");
if (N_RB <= 32) factor = 1.0; // 61.44 Ms/s factor = fp->samples_per_subframe / 61440.0;
else if (N_RB <= 66) factor = 2.0; // 122.88 Ms/s
else AssertFatal(1==0, "N_RB %d is too big for curretn FR2 implementation\n", N_RB);
break; break;
default:
if (N_RB == 100) AssertFatal(1==0, "Invalid scs_common!\n");
ue->N_TA_offset = 624;
else if (N_RB == 50)
ue->N_TA_offset = 624/2;
else if (N_RB == 25)
ue->N_TA_offset = 624/4;
} }
if (fp->threequarter_fs == 1)
factor = factor*.75;
ue->N_TA_offset = (int)(N_TA_offset * factor); ue->N_TA_offset = (int)(N_TA_offset * factor);
LOG_I(PHY,"UE %d Setting N_TA_offset to %d samples (factor %f, UL Freq %lu, N_RB %d)\n", ue->Mod_id, ue->N_TA_offset, factor, fp->ul_CarrierFreq, N_RB); LOG_I(PHY,"UE %d Setting N_TA_offset to %d samples (factor %f, UL Freq %lu, N_RB %d, mu %d)\n", ue->Mod_id, ue->N_TA_offset, factor, fp->ul_CarrierFreq, fp->N_RB_DL, fp->numerology_index);
} }
} }
......
...@@ -75,9 +75,8 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp) ...@@ -75,9 +75,8 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp)
return symbol; return symbol;
} }
void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw) void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, int N_RB_DL)
{ {
switch(mu) { switch(mu) {
case NR_MU_0: //15kHz scs case NR_MU_0: //15kHz scs
...@@ -99,114 +98,17 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw) ...@@ -99,114 +98,17 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw)
else else
AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->nr_band, mu); AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->nr_band, mu);
} }
switch(bw){
case 5:
case 10:
fp->ofdm_symbol_size = 512;
fp->first_carrier_offset = 368; //512 - ( (24*12) / 2 )
fp->nb_prefix_samples0 = 44;
fp->nb_prefix_samples = 36;
break;
case 15:
case 20:
case 25:
case 30:
case 40: //40 MHz
if (fp->threequarter_fs) {
fp->ofdm_symbol_size = 1536;
fp->first_carrier_offset = 900; //1536 - ( (106*12) / 2 )
fp->nb_prefix_samples0 = 132;
fp->nb_prefix_samples = 108;
}
else {
fp->ofdm_symbol_size = 2048;
fp->first_carrier_offset = 1412; //2048 - ( (106*12) / 2 )
fp->nb_prefix_samples0 = 176;
fp->nb_prefix_samples = 144;
}
break;
case 50:
case 60:
case 70:
case 80: //80 MHz
if (fp->threequarter_fs) {
fp->ofdm_symbol_size = 3072;
fp->first_carrier_offset = 1770; //3072 - ( (217*12) / 2 )
fp->nb_prefix_samples0 = 264;
fp->nb_prefix_samples = 216;
}
else {
fp->ofdm_symbol_size = 4096;
fp->first_carrier_offset = 2794; //4096 - ( (217*12) / 2 )
fp->nb_prefix_samples0 = 352;
fp->nb_prefix_samples = 288;
}
break;
case 90:
AssertFatal(fp->threequarter_fs==0,"3/4 sampling impossible for %d MHz band and MU %d\n",bw,mu);
fp->ofdm_symbol_size = 4096;
fp->first_carrier_offset = 2626; //4096 - ( (245*12) / 2 )
fp->nb_prefix_samples0 = 352;
fp->nb_prefix_samples = 288;
break;
case 100:
AssertFatal(fp->threequarter_fs==0,"3/4 sampling impossible for %d MHz band and MU %d\n",bw,mu);
fp->ofdm_symbol_size = 4096;
fp->first_carrier_offset = 2458; //4096 - ( (273*12) / 2 )
fp->nb_prefix_samples0 = 352;
fp->nb_prefix_samples = 288;
break;
default:
AssertFatal(1==0,"%d MHz band undefined for mu %d, frame parms = %p\n", bw, mu, fp);
}
break; break;
case NR_MU_2: //60kHz scs case NR_MU_2: //60kHz scs
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_2]; fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_2];
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_2]; fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_2];
switch(bw){ //FR1 bands only
case 10:
case 15:
case 20:
case 25:
case 30:
case 40:
case 50:
case 60:
case 70:
case 80:
case 90:
case 100:
default:
AssertFatal(1==0,"%d MHz band undefined for mu %d, frame parms = %p\n", bw, mu, fp);
}
break; break;
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; fp->ssb_type = nr_ssb_type_D;
switch(bw){
case 100:
fp->ofdm_symbol_size = 1024;
fp->first_carrier_offset = 628; //1024 - ( (66*12) / 2 )
fp->nb_prefix_samples0 = 136;
fp->nb_prefix_samples = 72;
break;
case 50:
fp->ofdm_symbol_size = 512;
fp->first_carrier_offset = 320; //512 - ( (32*12) / 2 )
fp->nb_prefix_samples0 = 68;
fp->nb_prefix_samples = 36;
break;
default:
AssertFatal(1==0,"%d MHz band undefined for mu %d, frame parms = %p\n", bw, mu, fp);
}
break; break;
case NR_MU_4: case NR_MU_4:
...@@ -215,9 +117,21 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw) ...@@ -215,9 +117,21 @@ void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, uint16_t bw)
fp->ssb_type = nr_ssb_type_E; fp->ssb_type = nr_ssb_type_E;
break; break;
default: default:
AssertFatal(1==0,"Invalid numerology index %d", mu); AssertFatal(1==0,"Invalid numerology index %d", mu);
} }
if(fp->threequarter_fs)
fp->ofdm_symbol_size = 3 * 128;
else
fp->ofdm_symbol_size = 4 * 128;
while(fp->ofdm_symbol_size < N_RB_DL * 12)
fp->ofdm_symbol_size <<= 1;
fp->first_carrier_offset = fp->ofdm_symbol_size - (N_RB_DL * 12 / 2);
fp->nb_prefix_samples = fp->ofdm_symbol_size / 128 * 9;
fp->nb_prefix_samples0 = fp->ofdm_symbol_size / 128 * (9 + (1 << mu));
} }
uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp) uint32_t get_samples_per_slot(int slot, NR_DL_FRAME_PARMS* fp)
...@@ -286,7 +200,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg, ...@@ -286,7 +200,7 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg,
fp->half_frame_bit = 0; // half frame bit initialized to 0 here fp->half_frame_bit = 0; // half frame bit initialized to 0 here
fp->numerology_index = mu; fp->numerology_index = mu;
set_scs_parameters(fp, mu, cfg->carrier_config.dl_bandwidth.value); set_scs_parameters(fp, mu, fp->N_RB_DL);
fp->slots_per_frame = 10* fp->slots_per_subframe; fp->slots_per_frame = 10* fp->slots_per_subframe;
...@@ -380,7 +294,7 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, ...@@ -380,7 +294,7 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp,
fp->Ncp = Ncp; fp->Ncp = Ncp;
set_scs_parameters(fp,fp->numerology_index,config->carrier_config.dl_bandwidth); set_scs_parameters(fp, fp->numerology_index, fp->N_RB_DL);
fp->slots_per_frame = 10* fp->slots_per_subframe; fp->slots_per_frame = 10* fp->slots_per_subframe;
fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats
......
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