Пример #1
0
int main() {
	time_stats_t ts;
	int16_t x[16];
	int16_t y[16];
	int16_t z[16];
	int N = 16;
	int i;
	
	time_t t;
	srand((unsigned) time(&t));
	for(i=0; i<16; i++){
		x[i] = rand()%1000;
		y[i] = rand()%1000;
		z[i] = 0;
		printf("%d ",x[i]);
	}
	printf("\nThat was x, now y: \n");

		
	for(i=0; i<16; i++){
		printf("%d ",y[i]);
	}
	printf("\n");	
	reset_meas(&ts);
	start_meas(&ts);
	m16_vv(x, y, z, N);
	stop_meas(&ts);
	printf("z:\n");	
	for(i=0; i<16; i++){
		printf("%d ",z[i]);
	}
	printf("\nTimemeasure: %lld \n",ts.diff);	

	return 0;
}
Пример #2
0
int main() {


	int16_t x[2048]; int16_t y[2048]; int16_t z[2048];
	int i,j;


	time_t t; 
	/* Intializes random number generator */
    srand((unsigned) time(&t));
	for( j = 0 ; j < 2048 ; j++ ){ 
		x[j] = rand()%1000;
		y[j] = rand()%1000; 
		z[j] = 0;
   	}

	printf("x = [ ");
	for( j = 0 ; j < 2048 ; j++ ){ 
		printf("%d, ", x[j]);
	
	}
	printf(" ] \n");
	printf("y = [ ");

	for( j = 0 ; j < 2048 ; j++ ){ 
		printf("%d, ", y[j]);	
	}
	printf("]\n");

	m16_vv(x,y,z,2048);
	printf("z = [ ");
	for (i=0;i<16; i++){
	printf("%d, ", z[i]);
    }

	printf(" ]\n");

	printf("should be ");
	
	printf(" = [ ");
	for (i=0;i<16; i++){
		printf("%d, ", (int)((x[i]*y[i])/pow(2,16)) *2  );	
	}
	printf(" ]\n");
	time_stats_t ts;
	reset_meas (&ts);
	start_meas (&ts);

	unsigned long long k;
	for(k=0;k< 4000000; k++){
		m16_vv(x,y,z,2048);

	}
	stop_meas (&ts);
	printf("difference:  %lld \n", ts.diff);

return 0;
}
Пример #3
0
void start_meas(int32_t *time) {
	TimeInternal t;
	stop_meas();
	t.seconds = time[0];
	t.nanoseconds = time[1];
	set_current_Time(&t);
	Delay(10000); //10s
	t.seconds += REL_TARGET_TIME;
	t.nanoseconds = 0;
	init_current_state(&cur, &t);
	return;
}
void freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
{


  int16_t f,f2,d;
  uint8_t aarx,aatx,l;
  double *clut,*s**t;
  static int freq_channel_init=0;
  static int n_samples_max=0;

  // printf("no of samples:%d,",n_samples);
  // printf("no of taps:%d,",(int)desc->nb_taps);

  if (freq_channel_init == 0) {
    // we are initializing the lut for the largets possible n_samples=12*nb_rb+1
    // if called with n_samples<12*nb_rb+1, we decimate the lut
    n_samples_max=12*nb_rb+1;
    init_freq_channel(desc,nb_rb,n_samples_max);
    freq_channel_init=1;
  }

  d=n_samples_max/n_samples;

  start_meas(&desc->interp_freq);

  for (f=-n_samples_max/2,f2=-n_samples/2; f<n_samples_max/2; f+=d,f2++) {
    clut = cos_lut[n_samples_max/2+f];
    s**t = sin_lut[n_samples_max/2+f];

    for (aarx=0; aarx<desc->nb_rx; aarx++) {
      for (aatx=0; aatx<desc->nb_tx; aatx++) {
        desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].x=0.0;
        desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].y=0.0;

        for (l=0; l<(int)desc->nb_taps; l++) {

          desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].x+=(desc->a[l][aarx+(aatx*desc->nb_rx)].x*clut[l]+
              desc->a[l][aarx+(aatx*desc->nb_rx)].y*s**t[l]);
          desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].y+=(-desc->a[l][aarx+(aatx*desc->nb_rx)].x*s**t[l]+
              desc->a[l][aarx+(aatx*desc->nb_rx)].y*clut[l]);
        }
      }
    }
  }

  stop_meas(&desc->interp_freq);
}
Пример #5
0
int main(int argc, char *argv[]){
    reset_meas(&ts);
    
    N = atoi(argv[1]);
    x = malloc(N*sizeof(int16_t));
    y = malloc(N*sizeof(int16_t));
    z = malloc(N*sizeof(int16_t));
    
    start_meas(&ts);
    
    for (j=0; j<1000; j++){
        operation(x,y,z,N);
    }
    stop_meas(&ts);
    printf("%llu\n", (ts.diff)/1000);
    return(0);
}
Пример #6
0
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP)  //, int calibration_flag) {
{

  unsigned int nprb[MAX_NUM_CCs];
  unsigned int nCCE[MAX_NUM_CCs];
  int mbsfn_status[MAX_NUM_CCs];
  uint32_t RBalloc[MAX_NUM_CCs];
  protocol_ctxt_t   ctxt;
#ifdef EXMIMO
  int ret;
#endif
#if defined(ENABLE_ITTI)
  MessageDef   *msg_p;
  const char   *msg_name;
  instance_t    instance;
  int           result;
#endif
  DCI_PDU *DCI_pdu[MAX_NUM_CCs];
  int CC_id,i,next_i;
  UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list;
  rnti_t rnti;

  LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head);

  start_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN);

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
    DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu;
    nCCE[CC_id]=0;
    nprb[CC_id]=0;
    RBalloc[CC_id]=0;
    mbsfn_status[CC_id]=0;
  }

  // refresh UE list based on UEs dropped by PHY in previous subframe
  i = UE_list->head;

  while (i>=0) {
    rnti = UE_RNTI(module_idP, i);
    CC_id = UE_PCCID(module_idP, i);
    LOG_D(MAC,"UE %d: rnti %x (%p)\n", i, rnti,
          mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti));
    next_i= UE_list->next[i];

    if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) {
      mac_remove_ue(module_idP, i, frameP, subframeP);
    }
    i = next_i;
  }

#if defined(ENABLE_ITTI)

  do {
    // Checks if a message has been sent to MAC sub-task
    itti_poll_msg (TASK_MAC_ENB, &msg_p);

    if (msg_p != NULL) {
      msg_name = ITTI_MSG_NAME (msg_p);
      instance = ITTI_MSG_INSTANCE (msg_p);

      switch (ITTI_MSG_ID(msg_p)) {
      case MESSAGE_TEST:
        LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p));
        break;

      case RRC_MAC_BCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index);

        // TODO process BCCH data req.
        break;

      case RRC_MAC_CCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index);

        // TODO process CCCH data req.
        break;

#ifdef Rel10

      case RRC_MAC_MCCH_DATA_REQ:
        LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d, mbsfn_sync_area %d\n",
              msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
              RRC_MAC_MCCH_DATA_REQ (msg_p).frame, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area);

        // TODO process MCCH data req.
        break;
#endif

      default:
        LOG_E(MAC, "Received unexpected message %s\n", msg_name);
        break;
      }

      result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
      AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
    }
  } while(msg_p != NULL);

#endif

  // clear DCI and BCCH contents before scheduling
  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
    DCI_pdu[CC_id]->Num_common_dci  = 0;
    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
    eNB_mac_inst[module_idP].common_channels[CC_id].bcch_active = 0;

#ifdef Rel10
    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
#endif

    eNB_mac_inst[module_idP].frame    = frameP;
    eNB_mac_inst[module_idP].subframe = subframeP;
  }

  //if (subframeP%5 == 0)
  //#ifdef EXMIMO
  PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP);
  pdcp_run(&ctxt);
  //#endif

  // check HO
  rrc_rx_tx(&ctxt,
            0, // eNB index, unused in eNB
            CC_id);

#ifdef Rel10

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
    if (eNB_mac_inst[module_idP].common_channels[CC_id].MBMS_flag >0) {
      start_meas(&eNB_mac_inst[module_idP].schedule_mch);
      mbsfn_status[CC_id] = schedule_MBMS(module_idP,CC_id,frameP,subframeP);
      stop_meas(&eNB_mac_inst[module_idP].schedule_mch);
    }
  }

#endif
  // refresh UE list based on UEs dropped by PHY in previous subframe
  /*
  i=UE_list->head;
  while (i>=0) {
    next_i = UE_list->next[i];
    LOG_T(MAC,"UE %d : rnti %x, stats %p\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i)));
    if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) {
      mac_remove_ue(module_idP,i,frameP);
    }
    i=next_i;
  }
  */

  switch (subframeP) {
  case 0:

    // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution)
    // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6)
    // Schedule Normal DLSCH

    schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE);

    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
      schedule_ulsch(module_idP,frameP,cooperation_flag,0,4,nCCE);//,calibration_flag);
    } else if  ((mac_xface->lte_frame_parms->tdd_config == TDD) || //TDD
                (mac_xface->lte_frame_parms->tdd_config == 3) ||
                (mac_xface->lte_frame_parms->tdd_config == 6)) {
      //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);//,calibration_flag);
    }

    // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);

    fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);

    break;

  case 1:

    // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6)
    // FDD, schedule normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
      case 1:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 6:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
      schedule_ulsch(module_idP,frameP,cooperation_flag,1,5,nCCE);
    }

    break;

  case 2:

    // TDD, nothing
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
      schedule_ulsch(module_idP,frameP,cooperation_flag,2,6,nCCE);
    }

    break;

  case 3:

    // TDD Config 2, ULSCH for subframeP 7
    // TDD Config 2/5 normal DLSCH
    // FDD, normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE);

        // no break here!
      case 5:
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
      schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,nCCE);

    }

    break;

  case 4:

    // TDD Config 1, ULSCH for subframeP 8
    // TDD Config 1/2/4/5 DLSCH
    // FDD UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
        //        schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE);

        // no break here!
      case 2:

        // no break here!
      case 4:

        // no break here!
      case 5:
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      default:
        break;
      }
    } else {
      if (mac_xface->lte_frame_parms->frame_type == FDD) {  //FDD
	//        schedule_RA(module_idP,frameP, subframeP, 0, nprb, nCCE);
        //  schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8, nCCE);
        schedule_ue_spec(module_idP, frameP, subframeP, nprb, nCCE, mbsfn_status);
        fill_DLSCH_dci(module_idP, frameP, subframeP, RBalloc, 1, mbsfn_status);

      }
    }

    break;

  case 5:
    // TDD/FDD Schedule SI
    // TDD Config 0,6 ULSCH for subframes 9,3 resp.
    // TDD normal DLSCH
    // FDD normal UL/DLSCH
    schedule_SI(module_idP,frameP,nprb,nCCE);

    //schedule_RA(module_idP,frameP,subframeP,5,nprb,nCCE);
    if (mac_xface->lte_frame_parms->frame_type == FDD) {
      schedule_RA(module_idP,frameP,subframeP,1,nprb,nCCE);
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,5,9,nCCE);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);

    } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0
               (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6
      //schedule_ulsch(module_idP,cooperation_flag,subframeP,nCCE);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    } else {
      //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    }

    break;

  case 6:

    // TDD Config 0,1,6 ULSCH for subframes 2,3
    // TDD Config 3,4,5 Normal DLSCH
    // FDD normal ULSCH/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 0:
        break;

      case 1:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE);
        //  schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 6:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
        //  schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 5:
        schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE);
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      case 3:
      case 4:
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      //      schedule_ulsch(module_idP,frameP,cooperation_flag,6,0,nCCE);
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    }

    break;

  case 7:

    // TDD Config 3,4,5 Normal DLSCH
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 3:
      case 4:
        schedule_RA(module_idP,frameP,subframeP,3,nprb,nCCE);  // 3 = Msg3 subframeP, not
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      case 5:
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1,nCCE);
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    }

    break;

  case 8:

    // TDD Config 2,3,4,5 ULSCH for subframeP 2
    //
    // FDD Normal UL/DLSCH
    if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 2:
      case 3:
      case 4:
      case 5:

        //  schedule_RA(module_idP,subframeP,nprb,nCCE);
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE);
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2,nCCE);
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    }

    break;

  case 9:

    // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4
    if (mac_xface->lte_frame_parms->frame_type == TDD) {
      switch (mac_xface->lte_frame_parms->tdd_config) {
      case 1:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
        schedule_RA(module_idP,frameP,subframeP,7,nprb,nCCE);  // 7 = Msg3 subframeP, not
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status);
        break;

      case 3:
      case 4:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE);
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 6:
        schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);
        //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      case 2:
      case 5:
        //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE);
        schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
        fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
        break;

      default:
        break;
      }
    } else { //FDD
      //     schedule_ulsch(module_idP,frameP,cooperation_flag,9,3,nCCE);
      schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status);
      fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status);
    }

    break;

  }

  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
    DCI_pdu[CC_id]->nCCE = nCCE[CC_id];
  }

  LOG_D(MAC,"frameP %d, subframeP %d nCCE %d\n",frameP,subframeP,nCCE[0]);

  stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler);
  VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT);

}
Пример #7
0
//-----------------------------------------------------------------------------
static
void *pdcp_netlink_thread_fct(void *arg)
//-----------------------------------------------------------------------------
{
    int                            len             = 0;
    struct pdcp_netlink_element_s *new_data_p      = NULL;
    uint8_t                        pdcp_thread_read_state ;
    eNB_flag_t                     eNB_flag        = 0;
    module_id_t                    module_id       = 0;
    pdcp_thread_read_state = 0;
    memset(nl_rx_buf, 0, NL_MAX_PAYLOAD);
    LOG_I(PDCP, "[NETLINK_THREAD] binding to fd  %d\n",nas_sock_fd);
    MSC_START_USE();
    while (1) {

        len = recvmsg(nas_sock_fd, &nas_msg_rx, 0);

        if (len == 0) {
            /* Other peer (kernel) has performed an orderly shutdown
             */
            LOG_E(PDCP, "[NETLINK_THREAD] Kernel module has closed the netlink\n");
            exit(EXIT_FAILURE);
        } else if (len < 0) {
            /* There was an error */
            LOG_E(PDCP, "[NETLINK_THREAD] An error occured while reading netlink (%d:%s)\n",
                  errno, strerror(errno));
            exit(EXIT_FAILURE);
        } else {
            /* Normal read.
             * NOTE: netlink messages can be assembled to form a multipart message
             */
            for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf;
                    NLMSG_OK(nas_nlh_rx, (unsigned int)len);
                    nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) {
                start_meas(&ip_pdcp_stats_tmp);

                /* There is no need to check for nlmsg_type because
                 * the header is not set in our drivers.
                 */
                if (pdcp_thread_read_state == 0) {
                    new_data_p = malloc(sizeof(struct pdcp_netlink_element_s));

                    if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) {
                        pdcp_thread_read_state = 1;
                        memcpy((void *)&new_data_p->pdcp_read_header, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t));
                        LOG_I(PDCP, "[NETLINK_THREAD] RX pdcp_data_req_header_t inst %u, "
                              "rb_id %u data_size %d\n",
                              new_data_p->pdcp_read_header.inst,
                              new_data_p->pdcp_read_header.rb_id,
                              new_data_p->pdcp_read_header.data_size);
                    } else {
                        LOG_E(PDCP, "[NETLINK_THREAD] WRONG size %d should be sizeof "
                              "%d ((pdcp_data_req_header_t) + sizeof(struct nlmsghdr))\n",
                              nas_nlh_rx->nlmsg_len,
                              sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr));
                    }
                } else {
                    pdcp_thread_read_state = 0;

#ifdef OAI_EMU

                    // LG: new_data_p->pdcp_read_header.inst will contain in fact a module id
                    if (new_data_p->pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) {
                        module_id = new_data_p->pdcp_read_header.inst
                                    - oai_emulation.info.nb_enb_local +
                                    + oai_emulation.info.first_ue_local;
                        eNB_flag = 0;
                    } else {
                        module_id = new_data_p->pdcp_read_header.inst
                                    + oai_emulation.info.first_enb_local;
                        eNB_flag = 1;
                    }

#else
                    module_id = 0;
#endif
                    new_data_p->data = malloc(sizeof(uint8_t) * new_data_p->pdcp_read_header.data_size);
                    /* Copy the data */
                    memcpy(new_data_p->data, NLMSG_DATA(nas_nlh_rx), new_data_p->pdcp_read_header.data_size);

                    if (eNB_flag) {
                        if (pdcp_netlink_nb_element_enb[module_id]
                                > PDCP_QUEUE_NB_ELEMENTS) {
                            LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in eNB pdcp queue (%d)\n",
                                  module_id, pdcp_netlink_nb_element_enb);
                        }

                        LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for eNB module id %d\n", module_id);

                        /* Enqueue the element in the right queue */
                        lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_enb[module_id], new_data_p);
                        stop_meas(&ip_pdcp_stats_tmp);
                        copy_meas(&eNB_pdcp_stats[module_id].pdcp_ip,&ip_pdcp_stats_tmp);
                    } else {
                        if (pdcp_netlink_nb_element_ue[module_id]
                                > PDCP_QUEUE_NB_ELEMENTS) {
                            LOG_E(PDCP, "[NETLINK_THREAD][Mod %02x] We reached maximum number of elements in UE pdcp queue (%d)\n",
                                  module_id, pdcp_netlink_nb_element_ue);
                        }

                        LOG_I(PDCP,"[NETLINK_THREAD] IP->PDCP : En-queueing packet for UE module id  %d\n", module_id);

                        /* Enqueue the element in the right queue */
                        lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_ue[module_id], new_data_p);
                        stop_meas(&ip_pdcp_stats_tmp);
                        copy_meas(&UE_pdcp_stats[module_id].pdcp_ip,&ip_pdcp_stats_tmp);
                    }
                }
            }
        }
    }

    return NULL;
}
Пример #8
0
void handl_command(struct b_pool* pbuf) {
	struct b_pool* ptbuf;
	struct timings_meas *t_meas;
	int* ans;
	int* comBuf = (int*)((char*)pbuf->pbuf + sizeof(struct head));
	switch(comBuf[0]) {
		case ENABLE_DEBUG:
			enable_Debug(comBuf[1], comBuf[2]);
			ptbuf = package_answer_to_bag(&ans, 2 * sizeof(int));
			ans[0] = ENABLE_DEBUG;
			ans[1] = OK;
			transPackage(ptbuf, eth_write);
			free_buf(ptbuf);
		break;
		case GET_ENABLE_DEBUG:
			ptbuf = package_answer_to_bag(&ans, 3 * sizeof(int));
			ans[0] = A_GET_ENABLE_DEBUG;
			get_enable_Debug(&ans[1], &ans[2]);
			transPackage(ptbuf, eth_write);
			free_buf(ptbuf);
		break;
		case DISABLE_DEBUG:
			disable_Debug();
			ptbuf = package_answer_to_bag(&ans, 2 * sizeof(int));
			ans[0] = DISABLE_DEBUG;
			ans[1] = OK;
			transPackage(ptbuf, eth_write);
			free_buf(ptbuf);
		case STOP_MEAS:
			stop_meas();
			ptbuf = package_answer_to_bag(&ans, 2 * sizeof(int));
			ans[0] = STOP_MEAS;
			ans[1] = OK;
			transPackage(ptbuf, eth_write);
			free_buf(ptbuf);
		break;
		case START_MEAS:
			start_meas(&comBuf[1]);
			ptbuf = package_answer_to_bag(&ans, 2 * sizeof(int));
			ans[0] = START_MEAS;
			ans[1] = OK;
			transPackage(ptbuf, eth_write);
			free_buf(ptbuf);
		case SET_TIMINGS:
			t_meas =(struct timings_meas*)&comBuf[1];
			stop_meas();
			if(t_meas->addtADC1 != -1)
				set_addtADC1((uint32_t*)&t_meas->addtADC1);
			if(t_meas->addtOfHyd != -1)
				set_addtOfHyd((uint32_t*)&t_meas->addtOfHyd);
			if(t_meas->tarTime_sec != -1) {
				set_tarTime((uint32_t*)&t_meas->tarTime_sec, (uint32_t*)&t_meas->tarTime_sec);
			}
			if(t_meas->subtOnAmp != -1)
				set_subtOnAmp((uint32_t*)&t_meas->subtOnAmp);
			if(t_meas->w_addtOfHyd != -1)
				set_w_addtOfHyd((uint32_t*)&t_meas->w_addtOfHyd);
			if(t_meas->w_subtOnAmp != -1)
				set_w_subtOnAmp((uint32_t*)&t_meas->w_subtOnAmp);
			if(t_meas->restart != -1) {
				int32_t buf[2];
				buf[0] = t_meas->cur_tarTime_sec;
				buf[1] = t_meas->cur_tarTime_sec;
				start_meas(buf);
			}
		break;
	}
}
void multipath_channel(channel_desc_t *desc,
                       double **tx_sig_re,
                       double **tx_sig_im,
                       double **rx_sig_re,
                       double **rx_sig_im,
                       uint32_t length,
                       uint8_t keep_channel)
{

  int i,ii,j,l;
  int length1, length2, tail;
  __m128d rx_tmp128_re_f,rx_tmp128_im_f,rx_tmp128_re,rx_tmp128_im, rx_tmp128_1,rx_tmp128_2,rx_tmp128_3,rx_tmp128_4,tx128_re,tx128_im,ch128_x,ch128_y,pathloss128;

  double path_loss = pow(10,desc->path_loss_dB/20);
  int dd = abs(desc->channel_offset);

  pathloss128 = _mm_set1_pd(path_loss);

#ifdef DEBUG_CH
  printf("[CHANNEL] keep = %d : path_loss = %g (%f), nb_rx %d, nb_tx %d, dd %d, len %d \n",keep_channel,path_loss,desc->path_loss_dB,desc->nb_rx,desc->nb_tx,dd,desc->channel_length);
#endif

  if (keep_channel) {
    // do nothing - keep channel
  } else {
    random_channel(desc,0);
  }

  start_meas(&desc->convolution);

#ifdef DEBUG_CH

  for (l = 0; l<(int)desc->channel_length; l++) {
    printf("%p (%f,%f) ",desc->ch[0],desc->ch[0][l].x,desc->ch[0][l].y);
  }

  printf("\n");
#endif

  tail = ((int)length-dd)%2;

  if(tail)
    length1 = ((int)length-dd)-1;
  else
    length1 = ((int)length-dd);

  length2 = length1/2;

  for (i=0; i<length2; i++) { //
    for (ii=0; ii<desc->nb_rx; ii++) {
      // rx_tmp.x = 0;
      // rx_tmp.y = 0;
      rx_tmp128_re_f = _mm_setzero_pd();
      rx_tmp128_im_f = _mm_setzero_pd();

      for (j=0; j<desc->nb_tx; j++) {
        for (l = 0; l<(int)desc->channel_length; l++) {
          if ((i>=0) && (i-l)>=0) { //SIMD correct only if length1 > 2*channel_length...which is almost always satisfied
            // tx.x = tx_sig_re[j][i-l];
            // tx.y = tx_sig_im[j][i-l];
            tx128_re = _mm_loadu_pd(&tx_sig_re[j][2*i-l]); // tx_sig_re[j][i-l+1], tx_sig_re[j][i-l]
            tx128_im = _mm_loadu_pd(&tx_sig_im[j][2*i-l]);
          } else {
            //tx.x =0;
            //tx.y =0;
            tx128_re = _mm_setzero_pd();
            tx128_im = _mm_setzero_pd();
          }

          ch128_x = _mm_set1_pd(desc->ch[ii+(j*desc->nb_rx)][l].x);
          ch128_y = _mm_set1_pd(desc->ch[ii+(j*desc->nb_rx)][l].y);
          //  rx_tmp.x += (tx.x * desc->ch[ii+(j*desc->nb_rx)][l].x) - (tx.y * desc->ch[ii+(j*desc->nb_rx)][l].y);
          //  rx_tmp.y += (tx.y * desc->ch[ii+(j*desc->nb_rx)][l].x) + (tx.x * desc->ch[ii+(j*desc->nb_rx)][l].y);
          rx_tmp128_1 = _mm_mul_pd(tx128_re,ch128_x);
          rx_tmp128_2 = _mm_mul_pd(tx128_re,ch128_y);
          rx_tmp128_3 = _mm_mul_pd(tx128_im,ch128_x);
          rx_tmp128_4 = _mm_mul_pd(tx128_im,ch128_y);
          rx_tmp128_re = _mm_sub_pd(rx_tmp128_1,rx_tmp128_4);
          rx_tmp128_im = _mm_add_pd(rx_tmp128_2,rx_tmp128_3);
          rx_tmp128_re_f = _mm_add_pd(rx_tmp128_re_f,rx_tmp128_re);
          rx_tmp128_im_f = _mm_add_pd(rx_tmp128_im_f,rx_tmp128_im);
        } //l
      }  // j

      //rx_sig_re[ii][i+dd] = rx_tmp.x*path_loss;
      //rx_sig_im[ii][i+dd] = rx_tmp.y*path_loss;
      rx_tmp128_re_f = _mm_mul_pd(rx_tmp128_re_f,pathloss128);
      rx_tmp128_im_f = _mm_mul_pd(rx_tmp128_im_f,pathloss128);
      _mm_storeu_pd(&rx_sig_re[ii][2*i+dd],rx_tmp128_re_f); // max index: length-dd -1 + dd = length -1
      _mm_storeu_pd(&rx_sig_im[ii][2*i+dd],rx_tmp128_im_f);
      /*
      if ((ii==0)&&((i%32)==0)) {
      printf("%p %p %f,%f => %e,%e\n",rx_sig_re[ii],rx_sig_im[ii],rx_tmp.x,rx_tmp.y,rx_sig_re[ii][i-dd],rx_sig_im[ii][i-dd]);
      }
      */
      //rx_sig_re[ii][i] = sqrt(.5)*(tx_sig_re[0][i] + tx_sig_re[1][i]);
      //rx_sig_im[ii][i] = sqrt(.5)*(tx_sig_im[0][i] + tx_sig_im[1][i]);

    } // ii
  } // i

  stop_meas(&desc->convolution);

}
int slot_fep_mbsfn(PHY_VARS_UE *phy_vars_ue,
                   unsigned char l,
                   int subframe,
                   int sample_offset,
                   int no_prefix)
{

  LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_ue->lte_frame_parms;
  LTE_UE_COMMON *ue_common_vars   = &phy_vars_ue->lte_ue_common_vars;
  uint8_t eNB_id = 0;//ue_common_vars->eNb_id;

  unsigned char aa;
  unsigned char frame_type = frame_parms->frame_type; // Frame Type: 0 - FDD, 1 - TDD;
  unsigned int nb_prefix_samples = frame_parms->ofdm_symbol_size>>2;//(no_prefix ? 0 : frame_parms->nb_prefix_samples);
  unsigned int nb_prefix_samples0 = frame_parms->ofdm_symbol_size>>2;//(no_prefix ? 0 : frame_parms->nb_prefix_samples0);
  unsigned int subframe_offset;

  //   int i;
  unsigned int frame_length_samples = frame_parms->samples_per_tti * 10;
  void (*dft)(int16_t *,int16_t *, int);

  switch (frame_parms->log2_symbol_size) {

  case 7:
    dft = dft128;
    break;

  case 8:
    dft = dft256;
    break;

  case 9:
    dft = dft512;
    break;

  case 10:
    dft = dft1024;
    break;

  case 11:
    dft = dft2048;
    break;

  default:
    dft = dft512;
    break;
  }

  if (no_prefix) {
    subframe_offset = frame_parms->ofdm_symbol_size * frame_parms->symbols_per_tti * subframe;

  } else {
    subframe_offset = frame_parms->samples_per_tti * subframe;

  }


  if (l<0 || l>=12) {
    msg("slot_fep_mbsfn: l must be between 0 and 11\n");
    return(-1);
  }

  if (((subframe == 0) || (subframe == 5) ||    // SFn 0,4,5,9;
       (subframe == 4) || (subframe == 9))
      && (frame_type==FDD) )    {   //check for valid MBSFN subframe
    msg("slot_fep_mbsfn: Subframe must be 1,2,3,6,7,8 for FDD, Got %d \n",subframe);
    return(-1);
  } else if (((subframe == 0) || (subframe == 1) || (subframe==2) ||  // SFn 0,4,5,9;
              (subframe == 5) || (subframe == 6))
             && (frame_type==TDD) )   {   //check for valid MBSFN subframe
    msg("slot_fep_mbsfn: Subframe must be 3,4,7,8,9 for TDD, Got %d \n",subframe);
    return(-1);
  }

#ifdef DEBUG_FEP
  msg("slot_fep_mbsfn: subframe %d, symbol %d, nb_prefix_samples %d, nb_prefix_samples0 %d, subframe_offset %d, sample_offset %d\n", subframe, l, nb_prefix_samples,nb_prefix_samples0,subframe_offset,
      sample_offset);
#endif


  for (aa=0; aa<frame_parms->nb_antennas_rx; aa++) {
    memset(&ue_common_vars->rxdataF[aa][2*frame_parms->ofdm_symbol_size*l],0,2*frame_parms->ofdm_symbol_size*sizeof(int));

    if (l==0) {
      start_meas(&phy_vars_ue->rx_dft_stats);
      dft((int16_t *)&ue_common_vars->rxdata[aa][(sample_offset +
          nb_prefix_samples0 +
          subframe_offset -
          SOFFSET) % frame_length_samples],
          (int16_t *)&ue_common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*l],1);
      stop_meas(&phy_vars_ue->rx_dft_stats);
    } else {
      if ((sample_offset +
           (frame_parms->ofdm_symbol_size+nb_prefix_samples0+nb_prefix_samples) +
           (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1) +
           subframe_offset-
           SOFFSET) > (frame_length_samples - frame_parms->ofdm_symbol_size))
        memcpy((short *)&ue_common_vars->rxdata[aa][frame_length_samples],
               (short *)&ue_common_vars->rxdata[aa][0],
               frame_parms->ofdm_symbol_size*sizeof(int));

      start_meas(&phy_vars_ue->rx_dft_stats);
      dft((int16_t *)&ue_common_vars->rxdata[aa][(sample_offset +
          (frame_parms->ofdm_symbol_size+nb_prefix_samples0+nb_prefix_samples) +
          (frame_parms->ofdm_symbol_size+nb_prefix_samples)*(l-1) +
          subframe_offset-
          SOFFSET) % frame_length_samples],
          (int16_t *)&ue_common_vars->rxdataF[aa][frame_parms->ofdm_symbol_size*l],1);
      stop_meas(&phy_vars_ue->rx_dft_stats);
    }

  }

  //if ((l==0) || (l==(4-frame_parms->Ncp))) {
  // changed to invoke MBSFN channel estimation in symbols 2,6,10
  if ((l==2)||(l==6)||(l==10)) {
    for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) {
      if (phy_vars_ue->perfect_ce == 0) {
#ifdef DEBUG_FEP
        msg("Channel estimation eNB %d, aatx %d, subframe %d, symbol %d\n",eNB_id,aa,subframe,l);
#endif

        lte_dl_mbsfn_channel_estimation(phy_vars_ue,
                                        eNB_id,
                                        0,
                                        subframe,
                                        l);
        /*   for (i=0;i<phy_vars_ue->PHY_measurements.n_adj_cells;i++) {
        lte_dl_mbsfn_channel_estimation(phy_vars_ue,
               eNB_id,
             i+1,
               subframe,
               l);
             lte_dl_channel_estimation(phy_vars_ue,eNB_id,0,
           Ns,
           aa,
           l,
           symbol);
           for (i=0;i<phy_vars_ue->PHY_measurements.n_adj_cells;i++) {
        lte_dl_channel_estimation(phy_vars_ue,eNB_id,i+1,
             Ns,
             aa,
             l,
             symbol); */
        //  }

        // do frequency offset estimation here!
        // use channel estimates from current symbol (=ch_t) and last symbol (ch_{t-1})
#ifdef DEBUG_FEP
        msg("Frequency offset estimation\n");
#endif
        // if ((l == 0) || (l==(4-frame_parms->Ncp)))
        /*    if ((l==2)||(l==6)||(l==10))
          lte_mbsfn_est_freq_offset(ue_common_vars->dl_ch_estimates[0],
                  frame_parms,
                  l,
                  &ue_common_vars->freq_offset); */
      }
    }
  }

#ifdef DEBUG_FEP
  msg("slot_fep_mbsfn: done\n");
#endif
  return(0);
}