Пример #1
0
void srslte_enb_dl_put_phich(srslte_enb_dl_t* q, srslte_phich_grant_t* grant, bool ack)
{
  srslte_phich_resource_t resource;
  srslte_phich_calc(&q->phich, grant, &resource);
  srslte_phich_encode(&q->phich, &q->dl_sf, resource, ack, q->sf_symbols);
}
Пример #2
0
int main(int argc, char **argv) {
  srslte_phich_t phich;
  srslte_regs_t regs;
  int i, j;
  cf_t *ce[SRSLTE_MAX_PORTS];
  int nof_re;
  cf_t *slot_symbols[SRSLTE_MAX_PORTS];
  uint8_t ack[50][SRSLTE_PHICH_NORM_NSEQUENCES], ack_rx;
  uint32_t nsf; 
  float distance;
  int cid, max_cid;
  uint32_t ngroup, nseq, max_nseq;

  parse_args(argc,argv);

  max_nseq = SRSLTE_CP_ISNORM(cell.cp)?SRSLTE_PHICH_NORM_NSEQUENCES:SRSLTE_PHICH_EXT_NSEQUENCES;

  nof_re = SRSLTE_CP_NORM_NSYMB * cell.nof_prb * SRSLTE_NRE;

  /* init memory */
  for (i=0;i<SRSLTE_MAX_PORTS;i++) {
    ce[i] = malloc(sizeof(cf_t) * nof_re);
    if (!ce[i]) {
      perror("malloc");
      exit(-1);
    }
    for (j=0;j<nof_re;j++) {
      ce[i][j] = 1;
    }
    slot_symbols[i] = malloc(sizeof(cf_t) * nof_re);
    if (!slot_symbols[i]) {
      perror("malloc");
      exit(-1);
    }
  }

  if (cell.id == 1000) {
    cid = 0;
    max_cid = 503;
  } else {
    cid = cell.id;
    max_cid = cell.id;
  }
  while(cid <= max_cid) {
    cell.id = cid;
    
    printf("Testing CellID=%d...\n", cid);

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

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

    for (nsf=0;nsf<10;nsf++) {

      srslte_phich_reset(&phich, slot_symbols);

      /* Transmit all PHICH groups and sequence numbers */
      for (ngroup=0;ngroup<srslte_phich_ngroups(&phich);ngroup++) {
        for (nseq=0;nseq<max_nseq;nseq++) {

          ack[ngroup][nseq] = rand()%2;

          srslte_phich_encode(&phich, ack[ngroup][nseq], ngroup, nseq, nsf, slot_symbols);
        }
      }
      /* combine outputs */
      for (i=1;i<cell.nof_ports;i++) {
        for (j=0;j<nof_re;j++) {
          slot_symbols[0][j] += slot_symbols[i][j];
        }
      }

      /* Receive all PHICH groups and sequence numbers */
      for (ngroup=0;ngroup<srslte_phich_ngroups(&phich);ngroup++) {
        for (nseq=0;nseq<max_nseq;nseq++) {

          if (srslte_phich_decode(&phich, slot_symbols[0], ce, 0, ngroup, nseq, nsf, &ack_rx, &distance)<0) {
            printf("Error decoding ACK\n");
            exit(-1);
          }
          INFO("%d/%d, ack_tx: %d, ack_rx: %d, ns: %d, distance: %f\n",
              ngroup, nseq, ack[ngroup][nseq], ack_rx, nsf, distance);
          if (ack[ngroup][nseq] != ack_rx) {
            printf("Invalid received ACK: %d!=%d\n", ack[ngroup][nseq], ack_rx);
            exit(-1);
          }
          if (distance < 1.5) {
            printf("Error\n");
            exit(-1);
          }
        }
      }
    }
    srslte_phich_free(&phich);
    srslte_regs_free(&regs);
    cid++;
  }

  for (i=0;i<SRSLTE_MAX_PORTS;i++) {
    free(ce[i]);
    free(slot_symbols[i]);
  }
  printf("OK\n");
  exit(0);
}