Esempio n. 1
0
void base_init() {
  
  /* init memory */
  sf_buffer = malloc(sizeof(cf_t) * sf_n_re);
  if (!sf_buffer) {
    perror("malloc");
    exit(-1);
  }
  output_buffer = malloc(sizeof(cf_t) * sf_n_samples);
  if (!output_buffer) {
    perror("malloc");
    exit(-1);
  }
  /* open file or USRP */
  if (output_file_name) {
    if (filesink_init(&fsink, output_file_name, COMPLEX_FLOAT_BIN)) {
      fprintf(stderr, "Error opening file %s\n", output_file_name);
      exit(-1);
    }
  } else {
#ifndef DISABLE_UHD
    printf("Opening UHD device...\n");
    if (cuhd_open(uhd_args, &uhd)) {
      fprintf(stderr, "Error opening uhd\n");
      exit(-1);
    }
#else
    printf("Error UHD not available. Select an output file\n");
    exit(-1);
#endif
  }

  /* create ifft object */
  if (lte_ifft_init(&ifft, CPNORM, cell.nof_prb)) {
    fprintf(stderr, "Error creating iFFT object\n");
    exit(-1);
  }
  if (pbch_init(&pbch, cell)) {
    fprintf(stderr, "Error creating PBCH object\n");
    exit(-1);
  }

  if (regs_init(&regs, R_1, PHICH_NORM, cell)) {
    fprintf(stderr, "Error initiating regs\n");
    exit(-1);
  }

  if (pcfich_init(&pcfich, &regs, cell)) {
    fprintf(stderr, "Error creating PBCH object\n");
    exit(-1);
  }

  if (regs_set_cfi(&regs, cfi)) {
    fprintf(stderr, "Error setting CFI\n");
    exit(-1);
  }

  if (pdcch_init(&pdcch, &regs, cell)) {
    fprintf(stderr, "Error creating PDCCH object\n");
    exit(-1);
  }

  if (pdsch_init(&pdsch, cell)) {
    fprintf(stderr, "Error creating PDSCH object\n");
    exit(-1);
  }
  
  pdsch_set_rnti(&pdsch, 1234);
  
  if (pdsch_harq_init(&harq_process, &pdsch)) {
    fprintf(stderr, "Error initiating HARQ process\n");
    exit(-1);
  }
}
Esempio n. 2
0
int main(int argc, char **argv) {
  int i, n, np, r;
  ra_prb_t prb_alloc;
  int ret = -1;
  pdsch_t pdsch;
  lte_cell_t cell;
  
  while (getopt(argc, argv, "v") == 'v') {
    verbose++;
  }

  for (i=0;i<110;i++) {
    prb_alloc.slot[0].prb_idx[i] = i;
    prb_alloc.slot[1].prb_idx[i] = i;
  }

  for (i=0;i<N_TESTS;i++) {
    cell.id = 0;
    cell.nof_prb = test_re_prb[i];
    cell.nof_ports = test_re_ports[i];
    cell.cp = test_re_cp[i];

    pdsch_init(&pdsch, cell);
    pdsch_set_rnti(&pdsch, 0);

    memset(prb_alloc.re_sf, 0, sizeof(uint32_t) * 10);
    prb_alloc.slot[0].nof_prb = test_re_prb[i];
    prb_alloc.slot[1].nof_prb = test_re_prb[i];
    ra_prb_get_re_dl(&prb_alloc, test_re_prb[i], test_re_ports[i], test_re_csymb[i], test_re_cp[i]);
    for (n=0;n<10;n++) {
      switch(n) {
      case 0:
        np = 0;
        break;
      case 5:
        np = 1;
        break;
      default:
        np = 2;
        break;
      }
      r = pdsch_get(&pdsch, in, out, &prb_alloc, n);
      
      if (prb_alloc.re_sf[n] != test_re_num[i][np]) {
        goto go_out;
      }
      if (r != prb_alloc.re_sf[n]) {
        goto go_out;
      }
    }
    pdsch_free(&pdsch);
  }
  ret = 0;
go_out:
  if (ret) {
    printf("Error in SF %d test %d. %d PRB, %d ports, RE is %d, get %d and should be %d\n",
        n, i, test_re_prb[i], test_re_ports[i], prb_alloc.re_sf[n], r, test_re_num[i][np]);
  } else {
    printf("Ok\n");
  }
  exit(ret);
}
Esempio n. 3
0
int srslte_pdsch_init_enb(srslte_pdsch_t *q, uint32_t max_prb)
{
  return pdsch_init(q, max_prb, false, 0);
}
Esempio n. 4
0
int srslte_pdsch_init_ue(srslte_pdsch_t *q, uint32_t max_prb, uint32_t nof_antennas)
{
  return pdsch_init(q, max_prb, true, nof_antennas);
}
Esempio n. 5
0
int main(int argc, char **argv) {
  pdsch_t pdsch;
  uint32_t i, j;
  char *data = NULL;
  cf_t *ce[MAX_PORTS];
  uint32_t nof_re;
  cf_t *slot_symbols[MAX_PORTS];
  int ret = -1;
  struct timeval t[3];
  ra_mcs_t mcs;
  ra_prb_t prb_alloc;
  pdsch_harq_t harq_process;
  uint32_t rv;

  parse_args(argc,argv);

  nof_re = 2 * CPNORM_NSYMB * cell.nof_prb * RE_X_RB;

  mcs.tbs = tbs;
  mcs.mod = modulation;
  prb_alloc.slot[0].nof_prb = cell.nof_prb;
  for (i=0;i<prb_alloc.slot[0].nof_prb;i++) {
    prb_alloc.slot[0].prb_idx[i] = i;
  }
  memcpy(&prb_alloc.slot[1], &prb_alloc.slot[0], sizeof(ra_prb_slot_t));

  ra_prb_get_re_dl(&prb_alloc, cell.nof_prb, cell.nof_ports, 2, CPNORM);

  /* init memory */
  for (i=0;i<cell.nof_ports;i++) {
    ce[i] = malloc(sizeof(cf_t) * nof_re);
    if (!ce[i]) {
      perror("malloc");
      goto quit;
    }
    for (j=0;j<nof_re;j++) {
      ce[i][j] = 1;
    }
    slot_symbols[i] = calloc(sizeof(cf_t) , nof_re);
    if (!slot_symbols[i]) {
      perror("malloc");
      goto quit;
    }
  }

  data = malloc(sizeof(char) * mcs.tbs);
  if (!data) {
    perror("malloc");
    goto quit;
  }

  if (pdsch_init(&pdsch, cell)) {
    fprintf(stderr, "Error creating PDSCH object\n");
    goto quit;
  }
  
  pdsch_set_rnti(&pdsch, 1234);
  
  if (pdsch_harq_init(&harq_process, &pdsch)) {
    fprintf(stderr, "Error initiating HARQ process\n");
    goto quit;
  }
  
  if (pdsch_harq_setup(&harq_process, mcs, &prb_alloc)) {
    fprintf(stderr, "Error configuring HARQ process\n");
    goto quit;
  }

  for (i=0;i<mcs.tbs;i++) {
    data[i] = rand()%2;
  }

  for (rv=0;rv<=rv_idx;rv++) {
    printf("Encoding rv_idx=%d\n",rv);
    if (pdsch_encode(&pdsch, data, slot_symbols, subframe, &harq_process, rv)) {
      fprintf(stderr, "Error encoding PDSCH\n");
      goto quit;
    }

    /* combine outputs */
    for (i=0;i<cell.nof_ports;i++) {
      for (j=0;j<nof_re;j++) {
        if (i > 0) {
          slot_symbols[0][j] += slot_symbols[i][j];
        }
        ce[i][j] = 1;
      }
    }
    
    gettimeofday(&t[1], NULL);
    int r = pdsch_decode(&pdsch, slot_symbols[0], ce, data, subframe, &harq_process, rv);
    gettimeofday(&t[2], NULL);
    get_time_interval(t);
    if (r) {
      printf("Error decoding\n");
      ret = -1;
      goto quit;
    } else {
      printf("DECODED OK in %d:%d (%.2f Mbps)\n", (int) t[0].tv_sec, (int) t[0].tv_usec, (float) mcs.tbs/t[0].tv_usec);
    }
    
  }
  ret = 0;
quit:
  pdsch_free(&pdsch);

  for (i=0;i<cell.nof_ports;i++) {
    if (ce[i]) {
      free(ce[i]);
    }
    if (slot_symbols[i]) {
      free(slot_symbols[i]);
    }
  }
  if (data) {
    free(data);
  }
  if (ret) {
    printf("Error\n");
  } else {
    printf("Ok\n");
  }
  exit(ret);
}
Esempio n. 6
0
int base_init() {
  int i;

  if (filesource_init(&fsrc, input_file_name, COMPLEX_FLOAT_BIN)) {
    fprintf(stderr, "Error opening file %s\n", input_file_name);
    exit(-1);
  }

  if (matlab_file_name) {
    fmatlab = fopen(matlab_file_name, "w");
    if (!fmatlab) {
      perror("fopen");
      return -1;
    }
  } else {
    fmatlab = NULL;
  }

  flen = 2 * (SLOT_LEN(lte_symbol_sz(cell.nof_prb)));

  input_buffer = malloc(flen * sizeof(cf_t));
  if (!input_buffer) {
    perror("malloc");
    exit(-1);
  }

  fft_buffer = malloc(2 * CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB * sizeof(cf_t));
  if (!fft_buffer) {
    perror("malloc");
    return -1;
  }

  for (i=0;i<MAX_PORTS;i++) {
    ce[i] = malloc(2 * CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB * sizeof(cf_t));
    if (!ce[i]) {
      perror("malloc");
      return -1;
    }
  }

  if (chest_init_LTEDL(&chest, cell)) {
    fprintf(stderr, "Error initializing equalizer\n");
    return -1;
  }

  if (lte_fft_init(&fft, cell.cp, cell.nof_prb)) {
    fprintf(stderr, "Error initializing FFT\n");
    return -1;
  }

  if (regs_init(&regs, R_1, PHICH_NORM, cell)) {
    fprintf(stderr, "Error initiating regs\n");
    return -1;
  }

  if (regs_set_cfi(&regs, cfi)) {
    fprintf(stderr, "Error setting CFI %d\n", cfi);
    return -1;
  }

  if (pdcch_init(&pdcch, &regs, cell)) {
    fprintf(stderr, "Error creating PDCCH object\n");
    exit(-1);
  }

  if (pdsch_init(&pdsch, cell)) {
    fprintf(stderr, "Error creating PDSCH object\n");
    exit(-1);
  }
  pdsch_set_rnti(&pdsch, rnti);
  
  if (pdsch_harq_init(&harq_process, &pdsch)) {
    fprintf(stderr, "Error initiating HARQ process\n");
    exit(-1);
  }

  DEBUG("Memory init OK\n",0);
  return 0;
}