Commit 413df163 authored by knopp's avatar knopp

first working version with oaisim. This is prior to MAC interface reworking

parent 63a18b81
......@@ -41,7 +41,7 @@ int N_RB_DL_array[6] = {6,15,25,50,75,100};
void phy_config_mib_eNB(int Mod_id,
int CC_id,
int eutra_band,
int eutra_band,
int dl_Bandwidth,
PHICH_Config_t *phich_config,
int Nid_cell,
......@@ -52,9 +52,10 @@ void phy_config_mib_eNB(int Mod_id,
LTE_DL_FRAME_PARMS *fp;
PHICH_RESOURCE_t phich_resource_table[4]={oneSixth,half,one,two};
LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u)\n",
Mod_id, CC_id, eutra_band, N_RB_DL_array[dl_Bandwidth], Nid_cell, p_eNB,dl_CarrierFreq);
LOG_I(PHY,"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n",
Mod_id, CC_id, eutra_band, N_RB_DL_array[dl_Bandwidth], Nid_cell, p_eNB,dl_CarrierFreq,phich_config->phich_Resource,phich_config->phich_Duration);
if (RC.eNB == NULL) {
RC.eNB = (PHY_VARS_eNB ***)malloc((1+NUMBER_OF_eNB_MAX)*sizeof(PHY_VARS_eNB***));
......@@ -84,7 +85,9 @@ void phy_config_mib_eNB(int Mod_id,
fp->eutra_band = eutra_band;
fp->Ncp = Ncp;
fp->nb_antenna_ports_eNB = p_eNB;
fp->phich_config_common.phich_resource = phich_config->phich_Resource;
AssertFatal(phich_config->phich_Resource < 4, "Illegal phich_Resource\n");
fp->phich_config_common.phich_resource = phich_resource_table[phich_config->phich_Resource];
fp->phich_config_common.phich_duration = phich_config->phich_Duration;
fp->dl_CarrierFreq = dl_CarrierFreq;
fp->ul_CarrierFreq = ul_CarrierFreq;
......@@ -168,6 +171,8 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
LOG_D(PHY,"prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig = %d\n",fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig);
fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset;
LOG_D(PHY,"prach_config_common.prach_ConfigInfo.prach_FreqOffset = %d\n",fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset);
init_prach_tables(839);
compute_prach_seq(&fp->prach_config_common,fp->frame_type,
RC.eNB[Mod_id][CC_id]->X_u);
......@@ -245,7 +250,6 @@ void phy_config_sib2_eNB(uint8_t Mod_id,
init_ul_hopping(fp);
// MBSFN
if (mbsfn_SubframeConfigList != NULL) {
fp->num_MBSFN_config = mbsfn_SubframeConfigList->list.count;
......@@ -1563,15 +1567,15 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
if (abstraction_flag==0) {
for (eNB_id=0; eNB_id<3; eNB_id++) {
pusch_vars[UE_id]->rxdataF_ext = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->rxdataF_ext2 = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->drs_ch_estimates = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->rxdataF_comp = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->ul_ch_mag = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->ul_ch_magb = (int32_t**)malloc16( fp->nb_antennas_rx*sizeof(int32_t*) );
pusch_vars[UE_id]->rxdataF_ext = (int32_t**)malloc16( 2*sizeof(int32_t*) );
pusch_vars[UE_id]->rxdataF_ext2 = (int32_t**)malloc16( 2*sizeof(int32_t*) );
pusch_vars[UE_id]->drs_ch_estimates = (int32_t**)malloc16( 2*sizeof(int32_t*) );
pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t**)malloc16( 2*sizeof(int32_t*) );
pusch_vars[UE_id]->rxdataF_comp = (int32_t**)malloc16( 2*sizeof(int32_t*) );
pusch_vars[UE_id]->ul_ch_mag = (int32_t**)malloc16( 2*sizeof(int32_t*) );
pusch_vars[UE_id]->ul_ch_magb = (int32_t**)malloc16( 2*sizeof(int32_t*) );
for (i=0; i<fp->nb_antennas_rx; i++) {
for (i=0; i<2; i++) {
// RK 2 times because of output format of FFT!
// FIXME We should get rid of this
pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t*)malloc16_clear( 2*sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti );
......@@ -1594,7 +1598,6 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
eNB->pdsch_config_dedicated->p_a = dB0; //defaul value until overwritten by RRCConnectionReconfiguration
init_prach_tables(839);
return (0);
......
......@@ -206,7 +206,7 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB* eNB,uint8_t UE_id)
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
LTE_eNB_PUSCH *eNB_pusch_vars = eNB->pusch_vars[UE_id];
int32_t **ul_ch_estimates_time= eNB_pusch_vars->drs_ch_estimates_time[0];
int32_t **ul_ch_estimates_time= eNB_pusch_vars->drs_ch_estimates_time;
uint8_t cyclic_shift = 0;
int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size);
......
......@@ -344,10 +344,10 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
for (l=0,nu=0; l<=(4-ue->frame_parms.Ncp); l+=(4-ue->frame_parms.Ncp),nu=3) {
k = (nu + nushift)%6;
#ifdef DEBUG_MEAS_RRC
LOG_I(PHY,"[UE %d] Frame %d subframe %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, nushift %d, eNB_offset %d, k %d, l %d)\n",ue->Mod_id,ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,Nid_cell,nushift,
//#ifdef DEBUG_MEAS_RRC
LOG_D(PHY,"[UE %d] Frame %d subframe %d Doing ue_rrc_measurements rsrp/rssi (Nid_cell %d, nushift %d, eNB_offset %d, k %d, l %d)\n",ue->Mod_id,ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,Nid_cell,nushift,
eNB_offset,k,l);
#endif
//#endif
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
rxF = (int16_t *)&ue->common_vars.common_vars_rx_data_per_thread[subframe&0x1].rxdataF[aarx][(l*ue->frame_parms.ofdm_symbol_size)];
......@@ -422,18 +422,18 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
}
#ifdef DEBUG_MEAS_RRC
//#ifdef DEBUG_MEAS_RRC
// if (slot == 0) {
if (eNB_offset == 0)
LOG_I(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB, gain %d), N0 %d dBm\n",ue->Mod_id,
LOG_D(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB, gain %d), N0 %d dBm\n",ue->Mod_id,
ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,10*log10(ue->measurements.rssi)-ue->rx_total_gain_dB,
10*log10(ue->measurements.rssi),
ue->rx_total_gain_dB,
ue->measurements.n0_power_tot_dBm);
LOG_I(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f dBm/RE (%d), rsrq: %3.1f dB\n",
LOG_D(PHY,"[UE %d] Frame %d, subframe %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f dBm/RE (%d), rsrq: %3.1f dB\n",
ue->Mod_id,
ue->proc.proc_rxtx[subframe&1].frame_rx,subframe,eNB_offset,
(eNB_offset>0) ? ue->measurements.adj_cell_id[eNB_offset-1] : ue->frame_parms.Nid_cell,
......@@ -448,7 +448,7 @@ void ue_rrc_measurements(PHY_VARS_UE *ue,
// }
#endif
//#endif
}
}
......
......@@ -42,6 +42,7 @@
#include "assertions.h"
#include "T.h"
#include "UTIL/LOG/log.h"
//#define DEBUG_DCI_ENCODING 1
//#define DEBUG_DCI_DECODING 1
......@@ -452,10 +453,7 @@ void pdcch_deinterleaving(LTE_DL_FRAME_PARMS *frame_parms,uint16_t *z, uint16_t
// printf("Mquad %d, RCC %d\n",Mquad,RCC);
if (!z) {
printf("dci.c: pdcch_deinterleaving: FATAL z is Null\n");
return;
}
AssertFatal(z!=NULL,"dci.c: pdcch_deinterleaving: FATAL z is Null\n");
// undo permutation
for (i=0; i<Mquad; i++) {
......@@ -1881,9 +1879,9 @@ int32_t rx_pdcch(LTE_UE_COMMON *common_vars,
#ifdef DEBUG_DCI_DECODING
printf("[PDCCH] subframe %d n_pdcch_symbols from PCFICH =%d\n",subframe,n_pdcch_symbols);
LOG_I(PHY,"[PDCCH] subframe %d n_pdcch_symbols from PCFICH =%d\n",subframe,n_pdcch_symbols);
printf("demapping: subframe %d, mi %d, tdd_config %d\n",subframe,get_mi(frame_parms,subframe),frame_parms->tdd_config);
LOG_I(PHY,"demapping: subframe %d, mi %d, tdd_config %d\n",subframe,get_mi(frame_parms,subframe),frame_parms->tdd_config);
#endif
pdcch_demapping(pdcch_vars[eNB_id]->llr,
......@@ -2020,7 +2018,7 @@ uint8_t get_num_pdcch_symbols(uint8_t num_dci,
}
LOG_I(PHY," dci.c: get_num_pdcch_symbols subframe %d FATAL, illegal numCCE %d (num_dci %d)\n",subframe,numCCE,num_dci);
// LOG_I(PHY," dci.c: get_num_pdcch_symbols subframe %d FATAL, illegal numCCE %d (num_dci %d)\n",subframe,numCCE,num_dci);
//for (i=0;i<num_dci;i++) {
// printf("dci_alloc[%d].L = %d\n",i,dci_alloc[i].L);
//}
......@@ -2114,7 +2112,7 @@ uint8_t generate_dci_top(uint8_t num_ue_spec_dci,
if (dci_alloc[i].L == (uint8_t)L) {
#ifdef DEBUG_DCI_ENCODING
printf("Generating common DCI %d/%d (nCCE %d) of length %d, aggregation %d (%x)\n",i,num_common_dci,dci_alloc[i].firstCCE,dci_alloc[i].dci_length,1<<dci_alloc[i].L,
LOG_I(PHY,"Generating common DCI %d/%d (nCCE %d) of length %d, aggregation %d (%x)\n",i,num_common_dci,dci_alloc[i].firstCCE,dci_alloc[i].dci_length,1<<dci_alloc[i].L,
*(unsigned int*)dci_alloc[i].dci_pdu);
dump_dci(frame_parms,&dci_alloc[i]);
#endif
......@@ -2792,14 +2790,13 @@ void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars,
// CCE is not allocated yet
if (CCEmap_cand == 0) {
#ifdef DEBUG_DCI_DECODING
if (do_common == 1)
LOG_I(PHY,"[DCI search - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n",m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask);
LOG_D(PHY,"[DCI search - common] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n",m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask);
else
LOG_I(PHY,"[DCI search - ue spec] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n",m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask);
LOG_D(PHY,"[DCI search - ue spec] Attempting candidate %d Aggregation Level %d DCI length %d at CCE %d/%d (CCEmap %x,CCEmap_cand %x)\n",m,L2,sizeof_bits,CCEind,nCCE,*CCEmap,CCEmap_mask);
#endif
dci_decoding(sizeof_bits,
L,
......@@ -2810,9 +2807,9 @@ void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars,
printf("dci_decoded_output[%d] => %x\n",i,dci_decoded_output[i]);
*/
crc = (crc16(dci_decoded_output,sizeof_bits)>>16) ^ extract_crc(dci_decoded_output,sizeof_bits);
#ifdef DEBUG_DCI_DECODING
printf("crc =>%x\n",crc);
#endif
//LOG_I(PHY,"crc =>%x\n",crc);
if (((L>1) && ((crc == si_rnti)||
(crc == p_rnti)||
......@@ -2828,9 +2825,9 @@ void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars,
dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[1];
dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[2];
dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[3];
#ifdef DEBUG_DCI_DECODING
printf("DCI => %x,%x,%x,%x\n",dci_decoded_output[0],dci_decoded_output[1],dci_decoded_output[2],dci_decoded_output[3]);
#endif
//LOG_I(PHY,"DCI => %x,%x,%x,%x\n",dci_decoded_output[0],dci_decoded_output[1],dci_decoded_output[2],dci_decoded_output[3]);
} else {
dci_alloc[*dci_cnt].dci_pdu[7] = dci_decoded_output[0];
dci_alloc[*dci_cnt].dci_pdu[6] = dci_decoded_output[1];
......@@ -2840,11 +2837,9 @@ void dci_decoding_procedure0(LTE_UE_PDCCH **pdcch_vars,
dci_alloc[*dci_cnt].dci_pdu[2] = dci_decoded_output[5];
dci_alloc[*dci_cnt].dci_pdu[1] = dci_decoded_output[6];
dci_alloc[*dci_cnt].dci_pdu[0] = dci_decoded_output[7];
#ifdef DEBUG_DCI_DECODING
printf("DCI => %x,%x,%x,%x,%x,%x,%x,%x\n",
dci_decoded_output[0],dci_decoded_output[1],dci_decoded_output[2],dci_decoded_output[3],
dci_decoded_output[4],dci_decoded_output[5],dci_decoded_output[6],dci_decoded_output[7]);
#endif
//LOG_I(PHY,"DCI => %x,%x,%x,%x,%x,%x,%x,%x\n",
// dci_decoded_output[0],dci_decoded_output[1],dci_decoded_output[2],dci_decoded_output[3],
// dci_decoded_output[4],dci_decoded_output[5],dci_decoded_output[6],dci_decoded_output[7]);
}
if (crc==si_rnti) {
......
......@@ -3039,14 +3039,14 @@ int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci)
break;
case 50:
LOG_D(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]);
LOG_D(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type);
LOG_D(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]);
LOG_D(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs);
LOG_D(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid);
LOG_D(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi);
LOG_D(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv);
LOG_D(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC);
LOG_I(PHY,"DCI format1A(FDD, 10MHz), rnti %x (%x)\n",dci->rnti,((uint32_t*)&dci->dci_pdu[0])[0]);
LOG_I(PHY,"VRB_TYPE %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->vrb_type);
LOG_I(PHY,"RB_ALLOC %x (NB_RB %d)\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc,RIV2nb_rb_LUT50[((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rballoc]);
LOG_I(PHY,"MCS %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->mcs);
LOG_I(PHY,"HARQ_PID %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->harq_pid);
LOG_I(PHY,"NDI %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->ndi);
LOG_I(PHY,"RV %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->rv);
LOG_I(PHY,"TPC %d\n",((DCI1A_10MHz_FDD_t *)&dci->dci_pdu[0])->TPC);
break;
case 100:
......@@ -3800,7 +3800,6 @@ int dump_dci(LTE_DL_FRAME_PARMS *frame_parms, DCI_ALLOC_t *dci)
return(0);
}
int generate_ue_dlsch_params_from_dci(int frame,
uint8_t subframe,
void *dci_pdu,
......
......@@ -39,7 +39,7 @@
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type, int k) {
void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
int32_t **txdataF = ru->common.txdataF_BF;
......@@ -132,7 +132,8 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type, int k)
if (packet_type == IF4p5_PULFFT) {
for (symbol_id=fp->symbols_per_tti-nsym; symbol_id<fp->symbols_per_tti; symbol_id++) {
LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id);
LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d: %d dB\n",frame,subframe,symbol_id,
dB_fixed(signal_energy((int32_t*)&rxdataF[0][blockoffsetF],db_halflength)));
for (element_id=0; element_id<db_halflength; element_id++) {
i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id];
data_block[element_id] = ((uint16_t) lin2alaw[*i]) | ((uint16_t)(lin2alaw[*(i+1)]<<8));
......@@ -172,7 +173,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type, int k)
} else if (packet_type == IF4p5_PRACH) {
// FIX: hard coded prach samples length
LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d\n",frame,subframe);
db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES;
db_fulllength = PRACH_NUM_SAMPLES;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES);
......@@ -185,11 +186,11 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type, int k)
if (eth->flags == ETH_RAW_IF4p5_MODE) {
memcpy((int16_t*)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t),
(&prach_rxsigF[0][k]),
(&prach_rxsigF[0][0]),
PRACH_BLOCK_SIZE_BYTES);
} else {
memcpy((int16_t*)(tx_buffer_prach + sizeof_IF4p5_header_t),
(&prach_rxsigF[0][k]),
(&prach_rxsigF[0][0]),
PRACH_BLOCK_SIZE_BYTES);
}
......@@ -209,6 +210,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type, int k)
return;
}
extern void wakeup_prach(PHY_VARS_eNB *eNB,RU_t *ru);
void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint32_t *symbol_number) {
LTE_DL_FRAME_PARMS *fp = &ru->frame_parms;
......@@ -221,6 +223,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
uint16_t db_fulllength, db_halflength;
int slotoffsetF=0, blockoffsetF=0;
eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv);
int idx;
if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );
......@@ -297,10 +300,9 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
}
} else if (*packet_type == IF4p5_PRACH) {
LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d\n",ru->idx,*frame,*subframe);
// FIX: hard coded prach samples length
db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES;
db_fulllength = PRACH_NUM_SAMPLES;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
memcpy((&prach_rxsigF[0][0]),
......@@ -311,6 +313,11 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
(int16_t*) (rx_buffer+sizeof_IF4p5_header_t),
PRACH_BLOCK_SIZE_BYTES);
}
LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe,
dB_fixed(signal_energy(&prach_rxsigF[0][0],839)));
for (idx=0;idx<ru->num_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru);
} else if (*packet_type == IF4p5_PULTICK) {
} else {
......
......@@ -62,7 +62,7 @@ void gen_IF4p5_ul_header(IF4p5_header_t*, uint16_t, int, int);
void gen_IF4p5_prach_header(IF4p5_header_t*, int, int);
void send_IF4p5(RU_t*, int, int, uint16_t, int);
void send_IF4p5(RU_t*, int, int, uint16_t);
void recv_IF4p5(RU_t*, int*, int*, uint16_t*, uint32_t*);
......
......@@ -31,9 +31,6 @@
*/
#include "PHY/defs.h"
//uint16_t pcfich_reg[4];
//uint8_t pcfich_first_reg_idx = 0;
//#define DEBUG_PCFICH
void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
......@@ -69,9 +66,9 @@ void generate_pcfich_reg_mapping(LTE_DL_FRAME_PARMS *frame_parms)
first_reg = pcfich_reg[3];
}
//#ifdef DEBUG_PCFICH
#ifdef DEBUG_PCFICH
printf("pcfich_reg : %d,%d,%d,%d\n",pcfich_reg[0],pcfich_reg[1],pcfich_reg[2],pcfich_reg[3]);
//#endif
#endif
}
void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
......@@ -95,7 +92,6 @@ void pcfich_scrambling(LTE_DL_FRAME_PARMS *frame_parms,
}
bt[i] = (b[i]&1) ^ ((s>>(i&0x1f))&1);
// printf("scrambling %d : b %d => bt %d, c %d\n",i,b[i],bt[i],((s>>(i&0x1f))&1));
}
}
......@@ -122,7 +118,6 @@ void pcfich_unscrambling(LTE_DL_FRAME_PARMS *frame_parms,
if (((s>>(i&0x1f))&1) == 1)
d[i]=-d[i];
// printf("scrambling %d : b %d => bt %d, c %d\n",i,b[i],bt[i],((s>>(i&0x1f))&1));
}
}
......@@ -148,7 +143,7 @@ void generate_pcfich(uint8_t num_pdcch_symbols,
int nushiftmod3 = frame_parms->nushift%3;
#ifdef DEBUG_PCFICH
msg("[PHY] Generating PCFICH for %d PDCCH symbols, AMP %d\n",num_pdcch_symbols,amp);
printf("[PHY] Generating PCFICH for %d PDCCH symbols, AMP %d\n",num_pdcch_symbols,amp);
#endif
// scrambling
......@@ -247,12 +242,12 @@ uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms,
pcfich_d_ptr[0] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[0]; // RE component
pcfich_d_ptr[1] = ((int16_t*)&rxdataF_comp[0][reg_offset+i])[1]; // IM component
/*
printf("rx_pcfich: quad %d, i %d, offset %d => m%d (%d,%d) => pcfich_d_ptr[0] %d \n",pcfich_quad,i,reg_offset+i,m,
#ifdef DEBUG_PCFICH
printf("rx_pcfich: quad %d, i %d, offset %d => (%d,%d) => pcfich_d_ptr[0] %d \n",pcfich_quad,i,reg_offset+i,
((int16_t*)&rxdataF_comp[0][reg_offset+i])[0],
((int16_t*)&rxdataF_comp[0][reg_offset+i])[1],
pcfich_d_ptr[0]);
*/
#endif
pcfich_d_ptr+=2;
}
......@@ -295,12 +290,12 @@ uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms,
metric = 0;
for (j=0; j<32; j++) {
//printf("pcfich_b[%d][%d] %d => pcfich_d[%d] %d\n",i,j,pcfich_b[i][j],j,pcfich_d[j]);
// printf("pcfich_b[%d][%d] %d => pcfich_d[%d] %d\n",i,j,pcfich_b[i][j],j,pcfich_d[j]);
metric += (int32_t)(((pcfich_b[i][j]==0) ? (pcfich_d[j]) : (-pcfich_d[j])));
}
#ifdef DEBUG_PCFICH
msg("metric %d : %d\n",i,metric);
printf("metric %d : %d\n",i,metric);
#endif
if (metric > old_metric) {
......@@ -310,7 +305,7 @@ uint8_t rx_pcfich(LTE_DL_FRAME_PARMS *frame_parms,
}
#ifdef DEBUG_PCFICH
msg("[PHY] PCFICH detected for %d PDCCH symbols\n",num_pdcch_symbols);
printf("[PHY] PCFICH detected for %d PDCCH symbols\n",num_pdcch_symbols);
#endif
return(num_pdcch_symbols);
}
......@@ -1077,7 +1077,7 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1
}
#ifdef PRACH_DEBUG
#if 0
write_output("prach_txF0.m","prachtxF0",prachF,prach_len-Ncp,1,1);
write_output("prach_tx0.m","prachtx0",prach+(Ncp<<1),prach_len-Ncp,1,1);
write_output("txsig.m","txs",(int16_t*)(&ue->common_vars.txdata[0][0]),2*ue->frame_parms.samples_per_tti,1,1);
......@@ -1109,9 +1109,16 @@ void rx_prach(PHY_VARS_eNB *eNB,
int16_t *prachF=NULL;
int16_t **rxsigF=NULL;
int16_t **prach_ifft=NULL;
int nb_rx;
if (ru) fp = &ru->frame_parms;
else if (eNB) fp = &eNB->frame_parms;
if (ru) {
fp = &ru->frame_parms;
nb_rx = ru->nb_rx;
}
else if (eNB) {
fp = &eNB->frame_parms;
nb_rx = fp->nb_antennas_rx;
}
else AssertFatal(1==0,"rx_prach called without valid RU or eNB descriptor\n");
frame_type = fp->frame_type;
......@@ -1119,7 +1126,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
prach_ConfigIndex = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
Ncs_config = fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig;
restricted_set = fp->prach_config_common.prach_ConfigInfo.highSpeedFlag;
int16_t *prach[fp->nb_antennas_rx];
int16_t *prach[nb_rx];
if (eNB) {
subframe = eNB->proc.subframe_prach;
......@@ -1130,6 +1137,8 @@ void rx_prach(PHY_VARS_eNB *eNB,
else {
subframe = ru->proc.subframe_prach;
rxsigF = ru->prach_rxsigF;
LOG_D(PHY,"PRACH (RU) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n",
subframe,fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex);
}
int16_t *prach2;
......@@ -1157,14 +1166,19 @@ void rx_prach(PHY_VARS_eNB *eNB,
int32_t lev;
int16_t levdB;
int fft_size,log2_ifft_size;
uint8_t nb_ant_rx = 1; //eNB->frame_parms.nb_antennas_rx;
#ifdef PRACH_DEBUG
int en;
int en,en0=0;
#endif
for (aa=0; aa<nb_ant_rx; aa++) {
if (ru) prach[aa] = (int16_t*)&ru->common.rxdata[aa][subframe*fp->samples_per_tti-ru->N_TA_offset];
for (aa=0; aa<nb_rx; aa++) {
if ((eNB==NULL) &&
(ru!=NULL)) {
prach[aa] = (int16_t*)&ru->common.rxdata[aa][(subframe*fp->samples_per_tti)-ru->N_TA_offset];
#ifdef PRACH_DEBUG
LOG_D(PHY,"RU %d, subframe %d, : prach %p (energy %d)\n",ru->idx,subframe,prach[aa],dB_fixed(en0=signal_energy(prach[aa],fp->samples_per_tti)));
#endif
}
}
// First compute physical root sequence
......@@ -1250,10 +1264,11 @@ void rx_prach(PHY_VARS_eNB *eNB,
}
if (((eNB!=NULL) && (ru!=NULL) && (ru->function != NGFI_RRU_IF4p5))||
if (((eNB!=NULL) && (ru!=NULL) && (ru->function != NGFI_RAU_IF4p5))||
((eNB==NULL) && (ru!=NULL) && (ru->function == NGFI_RRU_IF4p5))) { // compute the DFTs of the PRACH temporal resources
// Do forward transform
for (aa=0; aa<nb_ant_rx; aa++) {
LOG_D(PHY,"rx_prach: Doing FFT for N_RB_UL %d\n",fp->N_RB_UL);
for (aa=0; aa<nb_rx; aa++) {
prach2 = prach[aa] + (Ncp<<1);
// do DFT
......@@ -1345,49 +1360,53 @@ void rx_prach(PHY_VARS_eNB *eNB,
break;
}
k = (12*n_ra_prb) - 6*fp->N_RB_UL;
if (k<0) {
k+=(fp->ofdm_symbol_size);
}
k*=12;
k+=13;
k*=2;
int dftsize_x2 = fp->ofdm_symbol_size*24;
LOG_D(PHY,"Shifting prach_rxF from %d to 0\n",k);
if ((k+(839*2)) > dftsize_x2) { // PRACH signal is split around DC
memmove((void*)&rxsigF[aa][dftsize_x2-k],(void*)&rxsigF[aa][0],(k+(839*2)-dftsize_x2)*2);
memmove((void*)&rxsigF[aa][0],(void*)(&rxsigF[aa][k]),(dftsize_x2-k)*2);
}
else // PRACH signal is not split around DC
memmove((void*)&rxsigF[aa][0],(void*)(&rxsigF[aa][k]),839*4);
}
}
if ((eNB==NULL) && (ru!=NULL) && ru->function == NGFI_RRU_IF4p5) {
k = (12*n_ra_prb) - 6*fp->N_RB_UL;
if (k<0) {
k+=(fp->ofdm_symbol_size);
}
k*=12;
k+=13;
k*=2;
/// **** send_IF4 of rxsigF to RAU **** ///
send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH, k);
send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH);
#if 0
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
if (en>60)
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
if (dB_fixed(en0)>30) {
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
// if (en>60)
printf("PRACH (if4p5), k %d, n_ra_prb %d: Frame %d, Subframe %d => %d dB\n",k,n_ra_prb,ru->proc.frame_rx,ru->proc.subframe_rx,en);
write_output("rxsigF.m","prach_rxF",rxsigF[0],12288,1,1);
exit(-1);
}
#endif
return;
} else if (eNB!=NULL) {
k = (12*n_ra_prb) - 6*fp->N_RB_UL;
if (k<0) k+=fp->ofdm_symbol_size;
k*=12;
k+=13;
k*=2;
// Adjust received rxsigF offset
memmove((&rxsigF[0][k]),
(&rxsigF[0][0]),
839*2*sizeof(int16_t));
#if 0
en = dB_fixed(signal_energy(&rxsigF[0][k],840));
/*if (en>60)
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);*/
en = dB_fixed(signal_energy(&rxsigF[0][0],840));
/*if (en>60)*/
printf("PRACH: Frame %d, Subframe %d => %d dB\n",eNB->proc.frame_rx,eNB->proc.subframe_rx,en);
#endif
}
......@@ -1493,18 +1512,6 @@ void rx_prach(PHY_VARS_eNB *eNB,
k = (12*n_ra_prb) - 6*fp->N_RB_UL;
if (k<0)
k+=fp->ofdm_symbol_size;
k*=12;
k+=13; // phi + K/2
k*=2;
memset( prachF, 0, sizeof(int16_t)*2*1024 );
#ifdef PRACH_DEBUG
if (prach[0]!= NULL) write_output("prach_rx0.m","prach_rx0",prach[0],6144+792,1,1);
......@@ -1513,30 +1520,14 @@ void rx_prach(PHY_VARS_eNB *eNB,
// write_output("prach_rxF0.m","prach_rxF0",rxsigF[0],24576,1,1);
// write_output("prach_rxF1.m","prach_rxF1",rxsigF[1],6144,1,1);
for (aa=0;aa<nb_ant_rx; aa++) {
for (aa=0;aa<nb_rx; aa++) {
// Do componentwise product with Xu*
k=0;
for (offset=0; offset<(N_ZC<<1); offset+=2) {
prachF[offset] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][k] + (int32_t)Xu[offset+1]*rxsigF[aa][k+1])>>15);
prachF[offset+1] = (int16_t)(((int32_t)Xu[offset]*rxsigF[aa][k+1] - (int32_t)Xu[offset+1]*rxsigF[aa][k])>>15);
/*
if (offset<16)
printf("Xu[%d] %d %d, rxsigF[%d][%d] %d %d\n",offset,Xu[offset],Xu[offset+1],aa,k,rxsigF[aa][k],rxsigF[aa][k+1]);
*/
/*
mmtmpX0 = _mm_madd_epi16(*(__m128i*)&Xu[offset],*(__m128i*)&rxsigF[aa][k<<1]);
mmtmpX1 = _mm_shufflelo_epi16(*(__m128i*)&Xu[offset],_MM_SHUFFLE(2,3,0,1));
mmtmpX1 = _mm_shufflehi_epi16(mmtmpX1,_MM_SHUFFLE(2,3,0,1));
mmtmpX1 = _mm_sign_epi16(mmtmpX1,*(__m128i*)&conjugate[0]);
mmtmpX1 = _mm_madd_epi16(mmtmpX1,*(__m128i*)&rxsigF[aa][k<<1]);
mmtmpX0 = _mm_srai_epi32(mmtmpX0,15);
mmtmpX1 = _mm_srai_epi32(mmtmpX1,15);
mmtmpX2 = _mm_unpacklo_epi32(mmtmpX0,mmtmpX1);
mmtmpX3 = _mm_unpackhi_epi32(mmtmpX0,mmtmpX1);
*(__m128i*)&prachF[offset] = _mm_packs_epi32(mmtmpX2,mmtmpX3);
*/
k+=2;
if (k==(12*2*fp->ofdm_symbol_size))
k=0;
}
......@@ -1566,8 +1557,9 @@ void rx_prach(PHY_VARS_eNB *eNB,
k+=13;
k*=2;
printf("Dumping prach, k = %d (n_ra_prb %d)\n",k,n_ra_prb);
write_output("rxsigF.m","prach_rxF",&rxsigF[0][k],840,1,1);
write_output("rxsigF.m","prach_rxF",&rxsigF[0][0],12288,1,1);
write_output("prach_rxF_comp0.m","prach_rxF_comp0",prachF,1024,1,1);
write_output("Xu.m","xu",Xu,N_ZC,1,1);
write_output("prach_ifft0.m","prach_t0",prach_ifft[0],1024,1,1);
exit(-1);
}
......@@ -1581,7 +1573,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
for (i=0; i<NCS2; i++) {
lev = 0;
for (aa=0; aa<nb_ant_rx; aa++) {
for (aa=0; aa<nb_rx; aa++) {
lev += (int32_t)prach_ifft[aa][(preamble_shift2+i)<<1]*prach_ifft[aa][(preamble_shift2+i)<<1] + (int32_t)prach_ifft[aa][1+((preamble_shift2+i)<<1)]*prach_ifft[aa][1+((preamble_shift2+i)<<1)];
}
......
......@@ -550,7 +550,7 @@ int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char* buffer, int length
return len;
} // is_clusterhead
/*