Commit ac122452 authored by Bo Zhao's avatar Bo Zhao Committed by cig

Bugfix: 1. fix the initial memory allocation; 2. correct the generation of the...

Bugfix: 1. fix the initial memory allocation; 2. correct the generation of the prach signal according to specs
parent f2eb2141
...@@ -39,6 +39,9 @@ int nr_phy_init_RU(RU_t *ru) { ...@@ -39,6 +39,9 @@ int nr_phy_init_RU(RU_t *ru) {
int p; int p;
int re; int re;
// For memory allocation of ru->prach_rxsigF
int mu = fp->numerology_index;
LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d\n",ru_if_types[ru->if_south],ru->nb_tx); LOG_I(PHY,"Initializing RU signal buffers (if_south %s) nb_tx %d\n",ru_if_types[ru->if_south],ru->nb_tx);
nfapi_nr_config_request_scf_t *cfg; nfapi_nr_config_request_scf_t *cfg;
...@@ -107,7 +110,8 @@ int nr_phy_init_RU(RU_t *ru) { ...@@ -107,7 +110,8 @@ int nr_phy_init_RU(RU_t *ru) {
ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*)); ru->prach_rxsigF = (int16_t**)malloc(ru->nb_rx * sizeof(int16_t*));
for (i=0; i<ru->nb_rx; i++) { for (i=0; i<ru->nb_rx; i++) {
ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*2*sizeof(int16_t) ); // for preamble format 1 and 2, more memory should be allocated
ru->prach_rxsigF[i] = (int16_t*)malloc16_clear( fp->ofdm_symbol_size*12*(1<<mu)*2*sizeof(int16_t) );
LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]); LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,ru->prach_rxsigF[i]);
} }
......
...@@ -337,7 +337,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -337,7 +337,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
break; break;
case 1: case 1:
Ncp = 2*21024; Ncp = 21024;
break; break;
case 2: case 2:
...@@ -400,7 +400,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -400,7 +400,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
if (prach_fmt == 0) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s if (prach_fmt == 0) { //24576 samples @ 30.72 Ms/s, 49152 samples @ 61.44 Ms/s
idft49152(prachF,prach2,1); idft49152(prachF,prach2,1);
// here we have |empty | Prach49152| // here we have |empty | Prach49152|
memmove(prach,prach+(49152<<1),(Ncp<<3)); memmove(prach,prach+(49152<<1),(Ncp<<2));
// here we have |Prefix | Prach49152| // here we have |Prefix | Prach49152|
prach_len = 49152+Ncp; prach_len = 49152+Ncp;
dftlen=49152; dftlen=49152;
...@@ -409,7 +409,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -409,7 +409,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
idft49152(prachF,prach2,1); idft49152(prachF,prach2,1);
memmove(prach2+(49152<<1),prach2,(49152<<2)); memmove(prach2+(49152<<1),prach2,(49152<<2));
// here we have |empty | Prach49152 | Prach49152| // here we have |empty | Prach49152 | Prach49152|
memmove(prach,prach+(49152<<2),(Ncp<<3)); memmove(prach,prach+(49152<<2),(Ncp<<2));
// here we have |Prefix | Prach49152 | Prach49152| // here we have |Prefix | Prach49152 | Prach49152|
prach_len = (49152*2)+Ncp; prach_len = (49152*2)+Ncp;
dftlen=49152; dftlen=49152;
...@@ -420,7 +420,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -420,7 +420,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
// here we have |empty | Prach49152 | Prach49152| empty49152 | empty49152 // here we have |empty | Prach49152 | Prach49152| empty49152 | empty49152
memmove(prach2+(49152<<2),prach2,(49152<<3)); memmove(prach2+(49152<<2),prach2,(49152<<3));
// here we have |empty | Prach49152 | Prach49152| Prach49152 | Prach49152 // here we have |empty | Prach49152 | Prach49152| Prach49152 | Prach49152
memmove(prach,prach+(49152<<3),(Ncp<<3)); memmove(prach,prach+(49152<<3),(Ncp<<2));
// here we have |Prefix | Prach49152 | Prach49152| Prach49152 | Prach49152 // here we have |Prefix | Prach49152 | Prach49152| Prach49152 | Prach49152
prach_len = (49152*4)+Ncp; prach_len = (49152*4)+Ncp;
dftlen=49152; dftlen=49152;
...@@ -431,7 +431,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -431,7 +431,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
// here we have |empty | Prach12288 | Prach12288| empty12288 | empty12288 // here we have |empty | Prach12288 | Prach12288| empty12288 | empty12288
memmove(prach2+(12288<<2),prach2,(12288<<3)); memmove(prach2+(12288<<2),prach2,(12288<<3));
// here we have |empty | Prach12288 | Prach12288| Prach12288 | Prach12288 // here we have |empty | Prach12288 | Prach12288| Prach12288 | Prach12288
memmove(prach,prach+(12288<<3),(Ncp<<3)); memmove(prach,prach+(12288<<3),(Ncp<<2));
// here we have |Prefix | Prach12288 | Prach12288| Prach12288 | Prach12288 // here we have |Prefix | Prach12288 | Prach12288| Prach12288 | Prach12288
prach_len = (12288*4)+Ncp; prach_len = (12288*4)+Ncp;
dftlen=12288; dftlen=12288;
...@@ -540,11 +540,14 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -540,11 +540,14 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
idft1536(prachF,prach2,1); idft1536(prachF,prach2,1);
dftlen=1536; dftlen=1536;
// here we have |empty | Prach1536 | // here we have |empty | Prach1536 |
if (prach_fmt != 0xc0) if (prach_fmt != 0xc0) {
memmove(prach2+(1536<<1),prach2,(1536<<2)); memmove(prach2+(1536<<1),prach2,(1536<<2));
prach_len = (1536*2)+Ncp;
}
else prach_len = (1536*1)+Ncp;
memmove(prach,prach+(1536<<1),(Ncp<<2)); memmove(prach,prach+(1536<<1),(Ncp<<2));
// here we have |Prefix | Prach1536 | Prach1536 (if ! 0xc0) | // here we have |Prefix | Prach1536 | Prach1536 (if ! 0xc0) |
prach_len = (1536*2)+Ncp;
} }
else if (prach_fmt == 0xa2 || prach_fmt == 0xb2) { // 6x1536 else if (prach_fmt == 0xa2 || prach_fmt == 0xb2) { // 6x1536
idft1536(prachF,prach2,1); idft1536(prachF,prach2,1);
...@@ -631,7 +634,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -631,7 +634,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
// here we have |empty | Prach24576 | Prach24576| Prach24576 | Prach24576 // here we have |empty | Prach24576 | Prach24576| Prach24576 | Prach24576
memmove(prach,prach+(24576<<3),(Ncp<<2)); memmove(prach,prach+(24576<<3),(Ncp<<2));
// here we have |Prefix | Prach24576 | Prach24576| Prach24576 | Prach24576 // here we have |Prefix | Prach24576 | Prach24576| Prach24576 | Prach24576
prach_len = (24576*4)+(Ncp<<1); prach_len = (24576*4)+Ncp;
} }
else if (prach_fmt == 0xa1 || prach_fmt == 0xb1 || prach_fmt == 0xc0) { else if (prach_fmt == 0xa1 || prach_fmt == 0xb1 || prach_fmt == 0xc0) {
idft4096(prachF,prach2,1); idft4096(prachF,prach2,1);
...@@ -696,7 +699,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -696,7 +699,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
idft73728(prachF,prach2,1); idft73728(prachF,prach2,1);
dftlen=73728; dftlen=73728;
// here we have |empty | Prach73728| // here we have |empty | Prach73728|
memmove(prach,prach+(73728<<1),(Ncp<<4)); memmove(prach,prach+(73728<<1),(Ncp<<2));
// here we have |Prefix | Prach73728| // here we have |Prefix | Prach73728|
prach_len = (73728*1)+Ncp; prach_len = (73728*1)+Ncp;
} }
...@@ -705,7 +708,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -705,7 +708,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
dftlen=73728; dftlen=73728;
memmove(prach2+(73728<<1),prach2,(73728<<2)); memmove(prach2+(73728<<1),prach2,(73728<<2));
// here we have |empty | Prach73728 | Prach73728| // here we have |empty | Prach73728 | Prach73728|
memmove(prach,prach+(73728<<2),(Ncp<<4)); memmove(prach,prach+(73728<<2),(Ncp<<2));
// here we have |Prefix | Prach73728 | Prach73728| // here we have |Prefix | Prach73728 | Prach73728|
prach_len = (73728*2)+Ncp; prach_len = (73728*2)+Ncp;
} }
...@@ -716,7 +719,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -716,7 +719,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
// here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728 // here we have |empty | Prach73728 | Prach73728| empty73728 | empty73728
memmove(prach2+(73728<<2),prach2,(73728<<3)); memmove(prach2+(73728<<2),prach2,(73728<<3));
// here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728 // here we have |empty | Prach73728 | Prach73728| Prach73728 | Prach73728
memmove(prach,prach+(73728<<3),(Ncp<<4)); memmove(prach,prach+(73728<<3),(Ncp<<2));
// here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728 // here we have |Prefix | Prach73728 | Prach73728| Prach73728 | Prach73728
prach_len = (73728*4)+Ncp; prach_len = (73728*4)+Ncp;
} }
...@@ -727,7 +730,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe, ...@@ -727,7 +730,7 @@ int32_t generate_nr_prach( PHY_VARS_NR_UE *ue, uint8_t eNB_id, uint8_t subframe,
// here we have |empty | Prach18432 | Prach18432| empty18432 | empty18432 // here we have |empty | Prach18432 | Prach18432| empty18432 | empty18432
memmove(prach2+(18432<<2),prach2,(18432<<3)); memmove(prach2+(18432<<2),prach2,(18432<<3));
// here we have |empty | Prach18432 | Prach18432| Prach18432 | Prach18432 // here we have |empty | Prach18432 | Prach18432| Prach18432 | Prach18432
memmove(prach,prach+(18432<<3),(Ncp<<4)); memmove(prach,prach+(18432<<3),(Ncp<<2));
// here we have |Prefix | Prach18432 | Prach18432| Prach18432 | Prach18432 // here we have |Prefix | Prach18432 | Prach18432| Prach18432 | Prach18432
prach_len = (18432*4)+Ncp; prach_len = (18432*4)+Ncp;
} }
......
...@@ -530,7 +530,7 @@ int main(int argc, char **argv) ...@@ -530,7 +530,7 @@ int main(int argc, char **argv)
// multipath channel // multipath channel
dump_nr_prach_config(&gNB->frame_parms,subframe); dump_nr_prach_config(&gNB->frame_parms,subframe);
for (i=0; i<2*frame_parms->samples_per_slot<<1; i++) { for (i=0; i<frame_parms->samples_per_slot<<1; i++) {
for (aa=0; aa<1; aa++) { for (aa=0; aa<1; aa++) {
if (awgn_flag == 0) { if (awgn_flag == 0) {
s_re[aa][i] = ((double)(((short *)&txdata[aa][subframe*frame_parms->samples_per_slot<<1]))[(i<<1)]); s_re[aa][i] = ((double)(((short *)&txdata[aa][subframe*frame_parms->samples_per_slot<<1]))[(i<<1)]);
...@@ -573,7 +573,7 @@ int main(int argc, char **argv) ...@@ -573,7 +573,7 @@ int main(int argc, char **argv)
if (awgn_flag == 0) { if (awgn_flag == 0) {
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*frame_parms->samples_per_slot<<1,0); frame_parms->samples_per_slot<<1,0);
} }
if (n_frames==1) { if (n_frames==1) {
......
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