Compare commits

...

1 Commits

Author SHA1 Message Date
sfn
6a02803a78 Add codebook type I precoding matrices generation function 2021-08-03 12:39:33 +02:00
5 changed files with 266 additions and 4 deletions

View File

@@ -73,7 +73,7 @@
#include "UTIL/OPT/opt.h"
#include "enb_config.h"
#include "gnb_paramdef.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#ifndef OPENAIR2
#include "UTIL/OTG/otg_extern.h"
@@ -449,12 +449,16 @@ void print_opp_meas(void) {
void init_eNB_afterRU(void) {
int inst,ru_id,i,aa;
PHY_VARS_gNB *gNB;
gNB_MAC_INST *mac;
LOG_I(PHY,"%s() RC.nb_nr_inst:%d\n", __FUNCTION__, RC.nb_nr_inst);
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];
gNB = RC.gNB[inst];
mac = RC.nrmac[gNB->UL_INFO.module_id];
phy_init_nr_gNB(gNB,0,0);
mac_init_codebook_gNB(gNB,mac);
// 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);

View File

@@ -36,9 +36,10 @@
#include "openair1/PHY/defs_RU.h"
#include "openair1/PHY/CODING/nrLDPC_extern.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "assertions.h"
#include <math.h>
#include <complex.h>
#include "PHY/NR_TRANSPORT/nr_ulsch.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
#include "SCHED_NR/fapi_nr_l1.h"
@@ -107,6 +108,219 @@ int l1_north_init_gNB() {
return(0);
}
int mac_init_codebook_gNB(PHY_VARS_gNB *gNB,
gNB_MAC_INST *mac) {
int N1, N2, O1, O2;
int CSI_RS_antenna_ports;
//UE_id = 0
//count = 0
//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 rrc_count = mac->UE_info.CellGroup[0]->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup->csi_ReportConfigToAddModList->list.count;
if(csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.present==NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel) {
//Uniform Planner Array: UPA
// X X X X ... X
// X X X X ... X
// N2 . . . . ... .
// X X X X ... X
// |<-----N1---->|
printf("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;
} 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:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_two_one\n");
N1=2;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=4;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_two_two_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_two_two_TypeI\n");
N1=2;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=8;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_one_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_four_one\n");
N1=4;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=8;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_three_two_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_three_two\n");
N1=3;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=12;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_one_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_six_one\n");
N1=6;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=12;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_two_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_four_two\n");
N1=4;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=16;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_one_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_eight_one\n");
N1=8;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=16;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_three_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_four_three\n");
N1=4;
N2=3;
O1=4;
O2=4;
CSI_RS_antenna_ports=24;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_six_two_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_six_two_\n");
N1=6;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=24;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_twelve_one_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_twelve_one\n");
N1=12;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=24;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_four_four_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_four_four\n");
N1=4;
N2=4;
O1=4;
O2=4;
CSI_RS_antenna_ports=32;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_eight_two_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_eight_two\n");
N1=8;
N2=2;
O1=4;
O2=4;
CSI_RS_antenna_ports=32;
break;
case NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_sixteen_one_TypeI_SinglePanel_Restriction:
printf("NR Codebook Config: codebookType, type1, n1_n2_PR_sixteen_one\n");
N1=16;
N2=1;
O1=4;
O2=1;
CSI_RS_antenna_ports=32;
break;
default:
printf("n1 n2 is %d\n",type1single->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present);
N1=1;
N2=1;
O1=1;
O2=1;
CSI_RS_antenna_ports=2;
break;
}
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));
//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];
gNB->nr_co_phasing_angles = (int32_t *)malloc16(4*sizeof(int32_t));
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]));
((short*) &gNB->nr_co_phasing_angles[nn])[0] = (short) ((creal(theta_n[nn])*32768)+0.5);//convert to Q15
((short*) &gNB->nr_co_phasing_angles[nn])[1] = (short) ((cimag(theta_n[nn])*32768)+0.5);//convert to Q15
//printf("nr_co_phasing_angles[%d] = %d +j %d\n",nn, ((short*) &gNB->nr_co_phasing_angles[nn])[0],((short*) &gNB->nr_co_phasing_angles[nn])[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
//Table 5.2.2.2.1-5 Codebook for 1 -layer CSI reporting using antenna ports 3000 to 2999 + CSI_RS_antenna_ports
//Table 5.2.2.2.1-6 Codebook for 2 -layer CSI reporting using antenna ports 3000 to 2999 + CSI_RS_antenna_ports
//Table 5.2.2.2.1-7 Codebook for 3 -layer CSI reporting using antenna ports 3000 to 2999 + CSI_RS_antenna_ports
//Table 5.2.2.2.1-8 Codebook for 4 -layer CSI reporting using antenna ports 3000 to 2999 + CSI_RS_antenna_ports
gNB->nr_vertical_hornontal_beam_codebook = (int32_t ***)malloc16(N1*O1*sizeof(int32_t **));
int32_t ***v_ll_mm_codebook = gNB->nr_vertical_hornontal_beam_codebook;
for(int ll=0; ll<N1*O1; ll++) {
v_ll_mm_codebook[ll] = (int32_t **)malloc16(N2*O2*sizeof(int32_t *));
for (int mm=0; mm<N2*O2; mm++) {
v_ll_mm_codebook[ll][mm] = (int32_t *)malloc16(N2*N1*sizeof(int32_t));
AssertFatal(v_ll_mm_codebook[ll][mm]!=NULL, "NR init: nr_vertical_hornontal_beam_codebook for vertical %d Horizontal %d - malloc failed\n", ll, mm);
}
}
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]));
((short*) v_ll_mm_codebook[ll][mm])[2*(nn1*N2+nn2)] = (short) ((creal(v_lm[ll][mm][nn1*N2+nn2])*32768)+0.5);//convert to Q15
((short*) v_ll_mm_codebook[ll][mm])[2*(nn1*N2+nn2)+1] = (short) ((cimag(v_lm[ll][mm][nn1*N2+nn2])*32768)+0.5);//convert to Q15
//printf("v_ll_mm_codebook[%d][%d][%d] = %d +j %d\n",ll,mm, nn1*N2+nn2, ((short*) v_ll_mm_codebook[ll][mm])[2*(nn1*N2+nn2)],((short*) v_ll_mm_codebook[ll][mm])[2*(nn1*N2+nn2)+1]);
}
}
} else {//codebookMode 2
printf("CodeBook Type 1, CodebookMode %ld is not supported\n",csi_reportconfig->codebookConfig->codebookType.choice.type1->codebookMode);
}
}
} else {
printf("subType_PR_typeI %d is not supported\n",csi_reportconfig->codebookConfig->codebookType.choice.type1->subType.present);
}
return (0);
}
int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
unsigned char is_secondary_gNB,

View File

@@ -26,6 +26,7 @@
#include "PHY/defs_UE.h"
#include "PHY/defs_gNB.h"
#include "PHY/defs_nr_UE.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "LTE_SystemInformationBlockType2.h"
//#include "RadioResourceConfigCommonSIB.h"
@@ -400,6 +401,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 mac_init_codebook_gNB(PHY_VARS_gNB *gNB, gNB_MAC_INST *mac);
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);

View File

@@ -801,6 +801,10 @@ typedef struct PHY_VARS_gNB_s {
/// PDSCH DMRS sequence
uint32_t ****nr_gold_pdsch_dmrs;
/// PDSCH Codebook LUTs
int32_t ***nr_vertical_hornontal_beam_codebook;
int32_t *nr_co_phasing_angles;
/// PUSCH DMRS
uint32_t ****nr_gold_pusch_dmrs;

View File

@@ -1228,7 +1228,45 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco
csirep1->reportFreqConfiguration->csi_ReportingBand=NULL;
csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
csirep1->codebookConfig=NULL;
csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig));
csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1));
csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel));
if (n_physical_antenna_ports <= 2) {
csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two=
calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two));
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1);
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc;//'00111111'B
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1);
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0xc0; //'00000011'B
}
else if (n_physical_antenna_ports < 16) {
csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_moreThanTwo;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo=
calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo));
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.present=NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts__moreThanTwo__n1_n2_PR_three_two_TypeI_SinglePanel_Restriction;
/*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.size=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.bits_unused=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf=malloc(1);
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->n1_n2.choice.two_one_TypeI_SinglePanel_Restriction.buf[0]=0xc0; //'00000011'B
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->size = 1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->bits_unused=1;
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf=malloc(1);
csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.moreThanTwo->typeI_SinglePanel_codebookSubsetRestriction_i2->buf[0]=0xc0;*/
} else {//32 antennas are Not implemented yet
csirep1->codebookConfig->codebookType.choice.type1->codebookMode=2;
}
csirep1->dummy = NULL;
csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled));