Exemple #1
0
/** This function can be called in a subframe (1ms) basis */
int rm_conv_work(rm_conv_hl* hl) {
	if (hl->init.direction) {
		//rm_conv_tx(hl->input, hl->output, hl->in_len, hl->ctrl_in.S);
		hl->out_len = hl->ctrl_in.S;
	} else {
		rm_conv_rx(hl->input, hl->output, hl->in_len, hl->ctrl_in.E);
		hl->out_len = hl->ctrl_in.E;
	}
	return 0;
}
Exemple #2
0
int pbch_decode_frame(pbch_t *q, pbch_mib_t *mib, uint32_t src, uint32_t dst, uint32_t n,
    uint32_t nof_bits, uint32_t nof_ports) {
  int j;

  memcpy(&q->temp[dst * nof_bits], &q->pbch_llr[src * nof_bits],
      n * nof_bits * sizeof(float));

  /* descramble */
  scrambling_f_offset(&q->seq_pbch, &q->temp[dst * nof_bits], dst * nof_bits,
      n * nof_bits);

  for (j = 0; j < dst * nof_bits; j++) {
    q->temp[j] = RX_NULL;
  }
  for (j = (dst + n) * nof_bits; j < 4 * nof_bits; j++) {
    q->temp[j] = RX_NULL;
  }

  /* unrate matching */
  rm_conv_rx(q->temp, 4 * nof_bits, q->pbch_rm_f, 120);

  /* FIXME: If channel estimates are zero, received LLR are NaN. Check and return error */
  for (j = 0; j < 120; j++) {
    if (isnan(q->pbch_rm_f[j]) || isinf(q->pbch_rm_f[j])) {
      return 0;
    }
  }

  /* decode */
  viterbi_decode_f(&q->decoder, q->pbch_rm_f, q->data, 40);

  int c = 0;
  for (j = 0; j < 40; j++) {
    c += q->data[j];
  }
  if (!c) {
    c = 1;
  }

  if (!pbch_crc_check(q, q->data, nof_ports)) {
    /* unpack MIB */
    pbch_mib_unpack(q->data, mib);

    mib->nof_ports = nof_ports;
    mib->sfn += dst - src;

    return 1;
  } else {
    return 0;
  }
}