Remove dependency of init_codebook_gNB on mac parameters

This commit is contained in:
sfn
2021-12-09 10:36:01 +01:00
parent 2242c6a8a9
commit a778f69a76
6 changed files with 438 additions and 445 deletions
+1 -2
View File
@@ -505,10 +505,9 @@ void init_eNB_afterRU(void) {
for (inst=0; inst<RC.nb_nr_inst; inst++) {
LOG_I(PHY,"RC.nb_nr_CC[inst:%d]:%p\n", inst, RC.gNB[inst]);
gNB = RC.gNB[inst];
mac = RC.nrmac[gNB->UL_INFO.module_id];
phy_init_nr_gNB(gNB,0,0);
init_codebook_gNB(gNB,mac);
init_codebook_gNB(gNB);
// map antennas and PRACH signals to gNB RX
if (0) AssertFatal(gNB->num_RU>0,"Number of RU attached to gNB %d is zero\n",gNB->Mod_id);
+421 -440
View File
@@ -72,471 +72,456 @@ int l1_north_init_gNB() {
return(0);
}
int init_codebook_gNB(PHY_VARS_gNB *gNB,
gNB_MAC_INST *mac) {
//get RRC Codebook configuration
struct NR_CSI_ReportConfig *csi_reportconfig = mac->UE_info.CellGroup[0]->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->csi_ReportConfigToAddModList->list.array[0];
int init_codebook_gNB(PHY_VARS_gNB *gNB) {
if(gNB->frame_parms.nb_antennas_tx>1){
LOG_D(PHY, "NR init_codebook_gNB: codebookType present %d\n",csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.present);
if(csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.present==NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel) {
int N1=1;
int N2=1;
int O1=0;
int O2=0;
int CSI_RS_antenna_ports=1;
//NR Codebook Generation for codebook type1 SinglePanel
//csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.present
int N1;
int N2;
int O1;
int O2;
int CSI_RS_antenna_ports;
//Uniform Planner Array: UPA
// X X X X ... X
// X X X X ... X
// N2 . . . . ... .
// X X X X ... X
// |<-----N1---->|
if (gNB->frame_parms.nb_antennas_tx == 2) {//nrOfAntennaPorts = two
N1=1;
N2=1;
O1=1;
O2=1;
CSI_RS_antenna_ports=2;
LOG_D(PHY, "NR Codebook Config: antenna ports: %d\n",CSI_RS_antenna_ports);
} else if(gNB->frame_parms.nb_antennas_tx > 2) {//nrOfAntennaPorts moreThanTwo
//Type 1 Single Panel : Based on 38.214 v15.3-Table 5.2.2.2.1-2: Supported configurations of (N1,N2) and (O1,O2)
switch(gNB->frame_parms.antennas_tx_n1_n2) {
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction:
N1=2;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=4;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_two_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_two_TypeI_SinglePanel_Restriction:
N1=2;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=8;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_two_two_TypeI\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction:
N1=4;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=8;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_three_two_TypeI_SinglePanel_Restriction:
N1=3;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=12;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_three_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction:
N1=6;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=12;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_six_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_two_TypeI_SinglePanel_Restriction:
N1=4;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=16;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_one_TypeI_SinglePanel_Restriction:
N1=8;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=16;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_eight_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_three_TypeI_SinglePanel_Restriction:
N1=4;
N2=3;
O1=4;
O2=4;
CSI_RS_antenna_ports=24;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_three\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_two_TypeI_SinglePanel_Restriction:
N1=6;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=24;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_six_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_twelve_one_TypeI_SinglePanel_Restriction:
N1=12;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=24;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_twelve_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_four_TypeI_SinglePanel_Restriction:
N1=4;
N2=4;
O1=4;
O2=4;
CSI_RS_antenna_ports=32;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_four\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_two_TypeI_SinglePanel_Restriction:
N1=8;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=32;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_eight_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_sixteen_one_TypeI_SinglePanel_Restriction:
N1=16;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=32;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_sixteen_one\n",CSI_RS_antenna_ports);
break;
default:
N1=1;
N2=1;
O1=1;
O2=1;
CSI_RS_antenna_ports=2;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d \n",CSI_RS_antenna_ports);
break;
}
}
//Uniform Planner Array: UPA
// X X X X ... X
// X X X X ... X
// N2 . . . . ... .
// X X X X ... X
// |<-----N1---->|
LOG_D(PHY, "NR Codebook Config: codebookType, type1, subType_PR_typeI_SinglePanel\n");
struct NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel *type1single = csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel;
if (type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two) {
N1=1;
N2=1;
O1=1;
O2=1;
CSI_RS_antenna_ports=2;
LOG_D(PHY, "NR Codebook Config: antenna ports: %d\n",CSI_RS_antenna_ports);
} else if(type1single->nrOfAntennaPorts.present == NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo) {
//Type 1 Single Panel : Based on 38.214 v15.3-Table 5.2.2.2.1-2: Supported configurations of (N1,N2) and (O1,O2)
switch(type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present) {
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction:
N1=2;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=4;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_two_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_two_TypeI_SinglePanel_Restriction:
N1=2;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=8;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_two_two_TypeI\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction:
N1=4;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=8;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_three_two_TypeI_SinglePanel_Restriction:
N1=3;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=12;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_three_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction:
N1=6;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=12;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_six_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_two_TypeI_SinglePanel_Restriction:
N1=4;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=16;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_one_TypeI_SinglePanel_Restriction:
N1=8;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=16;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_eight_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_three_TypeI_SinglePanel_Restriction:
N1=4;
N2=3;
O1=4;
O2=4;
CSI_RS_antenna_ports=24;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_three\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_two_TypeI_SinglePanel_Restriction:
N1=6;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=24;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_six_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_twelve_one_TypeI_SinglePanel_Restriction:
N1=12;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=24;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_twelve_one\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_four_TypeI_SinglePanel_Restriction:
N1=4;
N2=4;
O1=4;
O2=4;
CSI_RS_antenna_ports=32;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_four_four\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_two_TypeI_SinglePanel_Restriction:
N1=8;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=32;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_eight_two\n",CSI_RS_antenna_ports);
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_sixteen_one_TypeI_SinglePanel_Restriction:
N1=16;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=32;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2_PR_sixteen_one\n",CSI_RS_antenna_ports);
break;
default:
N1=1;
N2=1;
O1=1;
O2=1;
CSI_RS_antenna_ports=2;
LOG_D(PHY, "NR Codebook Config: codebookType: type1, antenna ports: %d n1_n2 %d\n",CSI_RS_antenna_ports,type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present);
break;
// Generation of codebook Type1 with codebookMode 1 (CSI_RS_antenna_ports < 16)
if (CSI_RS_antenna_ports < 16) {
//Generate DFT vertical beams
//ll: index of a vertical beams vector (represented by i1_1 in TS 38.214)
double complex v[N1*O1][N1];
for (int ll=0; ll<N1*O1; ll++) { //i1_1
for (int nn=0; nn<N1; nn++) {
v[ll][nn] = cexp(I*(2*M_PI*nn*ll)/(N1*O1));
//printf("v[%d][%d] = %f +j %f\n", ll,nn, creal(v[ll][nn]),cimag(v[ll][nn]));
}
}
if(csi_reportconfig->codebookConfig->codebookType.choice.type1->codebookMode==1){
if (CSI_RS_antenna_ports < 16) {
//Generate DFT vertical beams
//ll: index of a vertical beams vector (represented by i1_1 in TS 38.214)
double complex v[N1*O1][N1];
for (int ll=0; ll<N1*O1; ll++) { //i1_1
for (int nn=0; nn<N1; nn++) {
v[ll][nn] = cexp(I*(2*M_PI*nn*ll)/(N1*O1));
//printf("v[%d][%d] = %f +j %f\n", ll,nn, creal(v[ll][nn]),cimag(v[ll][nn]));
}
}
//Generate DFT Horizontal beams
//mm: index of a Horizontal beams vector (represented by i1_2 in TS 38.214)
double complex u[N2*O2][N2];
for (int mm=0; mm<N2*O2; mm++) { //i1_2
for (int nn=0; nn<N2; nn++) {
u[mm][nn] = cexp(I*(2*M_PI*nn*mm)/(N2*O2));
//Generate DFT Horizontal beams
//mm: index of a Horizontal beams vector (represented by i1_2 in TS 38.214)
double complex u[N2*O2][N2];
for (int mm=0; mm<N2*O2; mm++) { //i1_2
for (int nn=0; nn<N2; nn++) {
u[mm][nn] = cexp(I*(2*M_PI*nn*mm)/(N2*O2));
//printf("u[%d][%d] = %f +j %f\n", mm,nn, creal(u[mm][nn]),cimag(u[mm][nn]));
}
}
//Generate co-phasing angles
//i_2: index of a co-phasing vector
//i1_1, i1_2, and i_2 are reported from UEs
double complex theta_n[4];
for (int nn=0; nn<4; nn++) {
theta_n[nn] = cexp(I*M_PI*nn/2);
//printf("theta_n[%d] = %f +j %f\n", nn, creal(theta_n[nn]),cimag(theta_n[nn]));
}
//Kronecker product v_lm
double complex v_lm[N1*O1][N2*O2][N2*N1];
//v_ll_mm_codebook denotes the elements of a precoding matrix W_i1,1_i_1,2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn1=0; nn1<N1; nn1++) {
for (int nn2=0; nn2<N2; nn2++) {
//printf("indx %d \n",nn1*N2+nn2);
v_lm[ll][mm][nn1*N2+nn2] = v[ll][nn1]*u[mm][nn2];
//printf("v_lm[%d][%d][%d] = %f +j %f\n",ll,mm, nn1*N2+nn2, creal(v_lm[ll][mm][nn1*N2+nn2]),cimag(v_lm[ll][mm][nn1*N2+nn2]));
}
}
//Generate co-phasing angles
//i_2: index of a co-phasing vector
//i1_1, i1_2, and i_2 are reported from UEs
double complex theta_n[4];
}
}
gNB->nr_mimo_precoding_matrix = (int32_t ***)malloc16(4* sizeof(int32_t **));
int32_t ***mat = gNB->nr_mimo_precoding_matrix;
double complex res_code;
//Table 5.2.2.2.1-5:
//Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
int pmiq_size = N1*O1*N2*O2*4+1;
mat[0] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[0][0] = (int32_t *)calloc(2*N1*N2,sizeof(int32_t));
for(int j_col=0; j_col<1; j_col++) { //1 layer
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[0][0][i_rows+j_col])[0] = 32768;
}
}
}
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<4; nn++) {
theta_n[nn] = cexp(I*M_PI*nn/2);
//printf("theta_n[%d] = %f +j %f\n", nn, creal(theta_n[nn]),cimag(theta_n[nn]));
int pmiq = 1+ll*N2*O2*4+mm*4+nn;
mat[0][pmiq] = (int32_t *)malloc16((2*N1*N2)*1*sizeof(int32_t));
LOG_D(PHY, "layer 1 Codebook pmiq = %d\n",pmiq);
for (int len=0; len<N1*N2; len++) {
res_code=sqrt(1/(double)CSI_RS_antenna_ports)*v_lm[ll][mm][len];
if (creal(res_code)>0)
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq, len, creal(res_code), cimag(res_code),((short*) &mat[0][pmiq][len])[0],((short*) &mat[0][pmiq][len])[1]);
}
for(int len=N1*N2; len<2*N1*N2; len++) {
res_code=sqrt(1/(double)CSI_RS_antenna_ports)*theta_n[nn]*v_lm[ll][mm][len-N1*N2];
if (creal(res_code)>0)
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq, len, creal(res_code), cimag(res_code),((short*) &mat[0][pmiq][len])[0],((short*) &mat[0][pmiq][len])[1]);
}
}
//Kronecker product v_lm
double complex v_lm[N1*O1][N2*O2][N2*N1];
//v_ll_mm_codebook denotes the elements of a precoding matrix W_i1,1_i_1,2
}
}
int llc;
int mmc;
double complex phase_sign;
//Table 5.2.2.2.1-6:
//Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
pmiq_size = N1*O1*N2*O2*N1*O1*N2*O2*2+1;
mat[1] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[1][0] = (int32_t *)calloc((2*N1*N2)*(2),sizeof(int32_t));
for(int j_col=0; j_col<2; j_col++) { //2 layers
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[1][0][i_rows*2+j_col])[0] = 32768;
}
}
}
//pmi=1,...,pmi_size are computed as follows
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn1=0; nn1<N1; nn1++) {
for (int nn2=0; nn2<N2; nn2++) {
//printf("indx %d \n",nn1*N2+nn2);
v_lm[ll][mm][nn1*N2+nn2] = v[ll][nn1]*u[mm][nn2];
//printf("v_lm[%d][%d][%d] = %f +j %f\n",ll,mm, nn1*N2+nn2, creal(v_lm[ll][mm][nn1*N2+nn2]),cimag(v_lm[ll][mm][nn1*N2+nn2]));
}
}
}
}
gNB->nr_mimo_precoding_matrix = (int32_t ***)malloc16(4* sizeof(int32_t **));
int32_t ***mat = gNB->nr_mimo_precoding_matrix;
double complex res_code;
//Table 5.2.2.2.1-5:
//Codebook for 1-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
int pmiq_size = N1*O1*N2*O2*4+1;
mat[0] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[0][0] = (int32_t *)calloc(2*N1*N2,sizeof(int32_t));
for(int j_col=0; j_col<1; j_col++) { //1 layer
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[0][0][i_rows+j_col])[0] = 32768;
}
}
}
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<4; nn++) {
int pmiq = 1+ll*N2*O2*4+mm*4+nn;
mat[0][pmiq] = (int32_t *)malloc16((2*N1*N2)*1*sizeof(int32_t));
LOG_D(PHY, "layer 1 Codebook pmiq = %d\n",pmiq);
for (int len=0; len<N1*N2; len++) {
res_code=sqrt(1/(double)CSI_RS_antenna_ports)*v_lm[ll][mm][len];
if (creal(res_code)>0)
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq, len, creal(res_code), cimag(res_code),((short*) &mat[0][pmiq][len])[0],((short*) &mat[0][pmiq][len])[1]);
}
for(int len=N1*N2; len<2*N1*N2; len++) {
res_code=sqrt(1/(double)CSI_RS_antenna_ports)*theta_n[nn]*v_lm[ll][mm][len-N1*N2];
if (creal(res_code)>0)
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[0][pmiq][len])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "1 Layer Precoding Matrix[0][pmi %d][antPort %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq, len, creal(res_code), cimag(res_code),((short*) &mat[0][pmiq][len])[0],((short*) &mat[0][pmiq][len])[1]);
}
}
}
}
int llc;
int mmc;
double complex phase_sign;
//Table 5.2.2.2.1-6:
//Codebook for 2-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
pmiq_size = N1*O1*N2*O2*N1*O1*N2*O2*2+1;
mat[1] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[1][0] = (int32_t *)calloc((2*N1*N2)*(2),sizeof(int32_t));
for(int j_col=0; j_col<2; j_col++) { //2 layers
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[1][0][i_rows*2+j_col])[0] = 32768;
}
}
}
//pmi=1,...,pmi_size are computed as follows
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
int pmiq = 1+llb*N2*O2*N1*O1*N2*O2*2+mmb*N1*O1*N2*O2*2+ll*N2*O2*2+mm*2+nn;
mat[1][pmiq] = (int32_t *)malloc16((2*N1*N2)*(2)*sizeof(int32_t));
LOG_D(PHY, "layer 2 Codebook pmiq = %d\n",pmiq);
for(int j_col=0; j_col<2; j_col++) {
if (j_col==0) {
llc = llb;
mmc = mmb;
phase_sign = 1;
}
if (j_col==1) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
for (int i_rows=0; i_rows<N1*N2; i_rows++) {
res_code=sqrt(1/(double)(2*CSI_RS_antenna_ports))*v_lm[llc][mmc][i_rows];
if (creal(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[1][pmiq][i_rows*2+j_col])[0],((short*) &mat[1][pmiq][i_rows*2+j_col])[1]);
}
for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) {
res_code=sqrt(1/(double)(2*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2];
if (creal(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[1][pmiq][i_rows*2+j_col])[0],((short*) &mat[1][pmiq][i_rows*2+j_col])[1]);
}
}
for (int nn=0; nn<2; nn++) {
int pmiq = 1+llb*N2*O2*N1*O1*N2*O2*2+mmb*N1*O1*N2*O2*2+ll*N2*O2*2+mm*2+nn;
mat[1][pmiq] = (int32_t *)malloc16((2*N1*N2)*(2)*sizeof(int32_t));
LOG_D(PHY, "layer 2 Codebook pmiq = %d\n",pmiq);
for(int j_col=0; j_col<2; j_col++) {
if (j_col==0) {
llc = llb;
mmc = mmb;
phase_sign = 1;
}
if (j_col==1) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
for (int i_rows=0; i_rows<N1*N2; i_rows++) {
res_code=sqrt(1/(double)(2*CSI_RS_antenna_ports))*v_lm[llc][mmc][i_rows];
if (creal(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[1][pmiq][i_rows*2+j_col])[0],((short*) &mat[1][pmiq][i_rows*2+j_col])[1]);
}
for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) {
res_code=sqrt(1/(double)(2*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2];
if (creal(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[1][pmiq][i_rows*2+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "2 Layer Precoding Matrix[1][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[1][pmiq][i_rows*2+j_col])[0],((short*) &mat[1][pmiq][i_rows*2+j_col])[1]);
}
}
}
}
}
}
}
//Table 5.2.2.2.1-7:
//Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
if(CSI_RS_antenna_ports>=3) {
pmiq_size = N1*O1*N2*O2*N1*O1*N2*O2*2+1;
mat[2] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//Table 5.2.2.2.1-7:
//Codebook for 3-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
if(CSI_RS_antenna_ports>=3) {
pmiq_size = N1*O1*N2*O2*N1*O1*N2*O2*2+1;
mat[2] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[2][0] = (int32_t *)calloc((2*N1*N2)*(3),sizeof(int32_t));
for(int j_col=0; j_col<3; j_col++) { //3 layers
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[2][0][i_rows*3+j_col])[0] = 32768;
}
}
}
//pmi=1,...,pmi_size are computed as follows
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
int pmiq = llb*N2*O2*N1*O1*N2*O2*2+mmb*N1*O1*N2*O2*2+ll*N2*O2*2+mm*2+nn+1;
mat[2][pmiq] = (int32_t *)malloc16((2*N1*N2)*(3)*sizeof(int32_t));
LOG_D(PHY, "layer 3 Codebook pmiq = %d\n",pmiq);
for(int j_col=0; j_col<3; j_col++) {
if (j_col==0) {
llc = llb;
mmc = mmb;
phase_sign = 1;
}
if (j_col==1) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col==3) {
llc = llb;
mmc = mmb;
phase_sign = -1;
}
for (int i_rows=0; i_rows<N1*N2; i_rows++) {
res_code=sqrt(1/(double)(3*CSI_RS_antenna_ports))*v_lm[llc][mmc][i_rows];
if (creal(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "3 Layer Precoding Matrix[2][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[2][pmiq][i_rows*3+j_col])[0],((short*) &mat[2][pmiq][i_rows*3+j_col])[1]);
}
for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) {
res_code=sqrt(1/(double)(3*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2];
if (creal(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "3 Layer Precoding Matrix[2][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[2][pmiq][i_rows*3+j_col])[0],((short*) &mat[2][pmiq][i_rows*3+j_col])[1]);
}
}
}
}
}
}
//pmi=0 corresponds to unit matrix
mat[2][0] = (int32_t *)calloc((2*N1*N2)*(3),sizeof(int32_t));
for(int j_col=0; j_col<3; j_col++) { //3 layers
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[2][0][i_rows*3+j_col])[0] = 32768;
}
}
}
//Table 5.2.2.2.1-8:
//Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
if(CSI_RS_antenna_ports>=4) {
pmiq_size = N1*O1*N2*O2*N1*O1*N2*O2*2+1;
mat[3] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
//pmi=0 corresponds to unit matrix
mat[3][0] = (int32_t *)calloc((2*N1*N2)*(4),sizeof(int32_t));
for(int j_col=0; j_col<4; j_col++) { //4 layers
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[3][0][i_rows*4+j_col])[0] = 32768;
//pmi=1,...,pmi_size are computed as follows
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
int pmiq = llb*N2*O2*N1*O1*N2*O2*2+mmb*N1*O1*N2*O2*2+ll*N2*O2*2+mm*2+nn+1;
mat[2][pmiq] = (int32_t *)malloc16((2*N1*N2)*(3)*sizeof(int32_t));
LOG_D(PHY, "layer 3 Codebook pmiq = %d\n",pmiq);
for(int j_col=0; j_col<3; j_col++) {
if (j_col==0) {
llc = llb;
mmc = mmb;
phase_sign = 1;
}
if (j_col==1) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col==3) {
llc = llb;
mmc = mmb;
phase_sign = -1;
}
for (int i_rows=0; i_rows<N1*N2; i_rows++) {
res_code=sqrt(1/(double)(3*CSI_RS_antenna_ports))*v_lm[llc][mmc][i_rows];
if (creal(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "3 Layer Precoding Matrix[2][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[2][pmiq][i_rows*3+j_col])[0],((short*) &mat[2][pmiq][i_rows*3+j_col])[1]);
}
for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) {
res_code=sqrt(1/(double)(3*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2];
if (creal(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[2][pmiq][i_rows*3+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "3 Layer Precoding Matrix[2][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[2][pmiq][i_rows*3+j_col])[0],((short*) &mat[2][pmiq][i_rows*3+j_col])[1]);
}
}
}
}
}
}
}
}
//pmi=1,...,pmi_size are computed as follows
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
int pmiq = llb*N2*O2*N1*O1*N2*O2*2+mmb*N1*O1*N2*O2*2+ll*N2*O2*2+mm*2+nn+1;
mat[3][pmiq] = (int32_t *)malloc16((2*N1*N2)*4*sizeof(int32_t));
LOG_D(PHY, "layer 4 pmiq = %d\n",pmiq);
for(int j_col=0; j_col<4; j_col++) {
if (j_col==0) {
llc = llb;
mmc = mmb;
phase_sign = 1;
}
if (j_col==1) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col==3) {
llc = llb;
mmc = mmb;
phase_sign = -1;
}
if (j_col==4) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
for (int i_rows=0; i_rows<N1*N2; i_rows++) {
res_code=sqrt(1/(double)(4*CSI_RS_antenna_ports))*v_lm[llc][mmc][i_rows];
if (creal(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
//Table 5.2.2.2.1-8:
//Codebook for 4-layer CSI reporting using antenna ports 3000 to 2999+PCSI-RS
if(CSI_RS_antenna_ports>=4) {
pmiq_size = N1*O1*N2*O2*N1*O1*N2*O2*2+1;
mat[3] = (int32_t **)malloc16(pmiq_size*sizeof(int32_t *));
LOG_D(PHY, "4 Layer Precoding Matrix[3][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[3][pmiq][i_rows*4+j_col])[0],((short*) &mat[3][pmiq][i_rows*4+j_col])[1]);
}
//pmi=0 corresponds to unit matrix
mat[3][0] = (int32_t *)calloc((2*N1*N2)*(4),sizeof(int32_t));
for(int j_col=0; j_col<4; j_col++) { //4 layers
for (int i_rows=0; i_rows<2*N1*N2; i_rows++) { //2-x polarized antenna
if(j_col==i_rows) {
((short*) &mat[3][0][i_rows*4+j_col])[0] = 32768;
}
}
}
for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) {
res_code=sqrt(1/(double)(4*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2];
if (creal(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
//pmi=1,...,pmi_size are computed as follows
for(int llb=0; llb<N1*O1; llb++) { //i_1_1
for (int mmb=0; mmb<N2*O2; mmb++) { //i_1_2
for(int ll=0; ll<N1*O1; ll++) { //i_1_1
for (int mm=0; mm<N2*O2; mm++) { //i_1_2
for (int nn=0; nn<2; nn++) {
int pmiq = llb*N2*O2*N1*O1*N2*O2*2+mmb*N1*O1*N2*O2*2+ll*N2*O2*2+mm*2+nn+1;
mat[3][pmiq] = (int32_t *)malloc16((2*N1*N2)*4*sizeof(int32_t));
LOG_D(PHY, "layer 4 pmiq = %d\n",pmiq);
for(int j_col=0; j_col<4; j_col++) {
if (j_col==0) {
llc = llb;
mmc = mmb;
phase_sign = 1;
}
if (j_col==1) {
llc = ll;
mmc = mm;
phase_sign = 1;
}
if (j_col==3) {
llc = llb;
mmc = mmb;
phase_sign = -1;
}
if (j_col==4) {
llc = ll;
mmc = mm;
phase_sign = -1;
}
for (int i_rows=0; i_rows<N1*N2; i_rows++) {
res_code=sqrt(1/(double)(4*CSI_RS_antenna_ports))*v_lm[llc][mmc][i_rows];
if (creal(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "4 Layer Precoding Matrix[3][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[3][pmiq][i_rows*4+j_col])[0],((short*) &mat[3][pmiq][i_rows*4+j_col])[1]);
}
LOG_D(PHY, "4 Layer Precoding Matrix[3][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[3][pmiq][i_rows*4+j_col])[0],((short*) &mat[3][pmiq][i_rows*4+j_col])[1]);
}
}
for (int i_rows=N1*N2; i_rows<2*N1*N2; i_rows++) {
res_code=sqrt(1/(double)(4*CSI_RS_antenna_ports))*(phase_sign)*theta_n[nn]*v_lm[llc][mmc][i_rows-N1*N2];
if (creal(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[0] = (short) ((creal(res_code)*32768)-0.5);//convert to Q15
if (cimag(res_code)>0)
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)+0.5);//convert to Q15
else
((short*) &mat[3][pmiq][i_rows*4+j_col])[1] = (short) ((cimag(res_code)*32768)-0.5);//convert to Q15
LOG_D(PHY, "4 Layer Precoding Matrix[3][pmi %d][antPort %d][layerIdx %d]= %f+j %f -> Fixed Point %d+j %d \n",pmiq,i_rows,j_col, creal(res_code), cimag(res_code),((short*) &mat[3][pmiq][i_rows*4+j_col])[0],((short*) &mat[3][pmiq][i_rows*4+j_col])[1]);
}
}
}
@@ -544,11 +529,7 @@ int init_codebook_gNB(PHY_VARS_gNB *gNB,
}
}
}
} else {//codebookMode 2
AssertFatal(1==0, "CodeBook Type 1, CodebookMode %ld is not supported\n",csi_reportconfig->codebookConfig->codebookType.choice.type1->codebookMode);
}
} else {
AssertFatal(1==0, "subType_PR_typeI %d is not supported\n",csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.present);
}
}
return 0;
+9
View File
@@ -269,6 +269,15 @@ int nr_init_frame_parms(nfapi_nr_config_request_scf_t* cfg,
fp->nb_antennas_rx = cfg->carrier_config.num_rx_ant.value; // It denotes the number of rx antennas at gNB
fp->nb_antennas_tx = cfg->carrier_config.num_tx_ant.value; // It corresponds to pdsch_AntennaPorts (logical antenna ports)
//RRC Parameters: depends on the physical structure of the gNB Uniform planner array
if (fp->nb_antennas_tx == 4)
fp->antennas_tx_n1_n2 = 1;//NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_one_TypeI_SinglePanel_Restriction;
else if (fp->nb_antennas_tx == 8)
fp->antennas_tx_n1_n2 = 3;//NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction;
else if (fp->nb_antennas_tx == 12)
fp->antennas_tx_n1_n2 = 5;//NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction;
else//We currently support codebook 1 for nrOfAntennaPorts < 16
fp->antennas_tx_n1_n2 = 0;//NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_NOTHING;
fp->symbols_per_slot = ((Ncp == NORMAL)? 14 : 12); // to redefine for different slot formats
fp->samples_per_subframe_wCP = fp->ofdm_symbol_size * fp->symbols_per_slot * fp->slots_per_subframe;
+1 -1
View File
@@ -402,7 +402,7 @@ void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag);
void init_N_TA_offset(PHY_VARS_NR_UE *ue);
void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms);
int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char lowmem_flag);
int init_codebook_gNB(PHY_VARS_gNB *gNB, gNB_MAC_INST *mac);
int init_codebook_gNB(PHY_VARS_gNB *gNB);
void nr_phy_config_request(NR_PHY_Config_t *gNB);
void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst);
void phy_free_nr_gNB(PHY_VARS_gNB *gNB);
+5 -1
View File
@@ -318,8 +318,12 @@ struct NR_DL_FRAME_PARMS {
uint32_t samples_per_frame_wCP;
/// NR numerology index [0..5] as specified in 38.211 Section 4 (mu). 0=15khZ SCS, 1=30khZ, 2=60kHz, etc
uint8_t numerology_index;
/// Number of Physical transmit antennas in node
/// Number of Physical transmit antennas in node (corresponds to nrOfAntennaPorts)
uint8_t nb_antennas_tx;
/// UPA Panel Antenna configuration: two_one, two_two, four_one, three_two, six_one, etc
uint8_t antennas_tx_n1_n2;
/// UPA Panel Antenna Type: non, Single panel, or multiple
uint8_t antennas_tx_panel_type;
/// Number of Receive antennas in node
uint8_t nb_antennas_rx;
/// Number of common transmit antenna ports in eNodeB (1 or 2)
+1 -1
View File
@@ -794,7 +794,7 @@ int main(int argc, char **argv)
// rrc_mac_config_req_gNB
gNB_mac->pre_processor_dl = nr_dlsim_preprocessor;
phy_init_nr_gNB(gNB,0,1);
init_codebook_gNB(gNB,gNB_mac);
init_codebook_gNB(gNB);
N_RB_DL = gNB->frame_parms.N_RB_DL;
NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info;
UE_info->num_UEs=1;