Example #1
0
/** Finds the CFI with minimum distance with the vector of received 32 bits.
 * Saves the CFI value in the cfi pointer and returns the distance.
 */
float srslte_pcfich_cfi_decode(srslte_pcfich_t *q, uint32_t *cfi) {
  int i;
  int index = 0;
  float max_corr = 0;
  
  for (i = 0; i < 3; i++) {
    float corr = fabsf(srslte_vec_dot_prod_fff(q->cfi_table_float[i], q->data_f, PCFICH_CFI_LEN));
    if (corr > max_corr) {
      max_corr = corr; 
      index = i; 
    }
  }
  if (cfi) {
    *cfi = index + 1;
  }
  return max_corr;
}
Example #2
0
/* Decodes ACK
 *
 */
uint8_t srslte_phich_ack_decode(float bits[SRSLTE_PHICH_NBITS], float *distance) {
  int i;
  float ack_table[2][3] = {{-1.0, -1.0, -1.0}, {1.0, 1.0, 1.0}}; 
  float max_corr = -9999; 
  uint8_t index=0; 
  
  if (SRSLTE_VERBOSE_ISINFO()) {
    INFO("Received bits: ", 0);
    srslte_vec_fprint_f(stdout, bits, SRSLTE_PHICH_NBITS);
  }
  
  for (i = 0; i < 2; i++) {
    float corr = srslte_vec_dot_prod_fff(ack_table[i], bits, SRSLTE_PHICH_NBITS);
    INFO("Corr%d=%f\n", i, corr);
    if (corr > max_corr) {
      max_corr = corr; 
      if (distance) {
        *distance = max_corr;
      }
      index = i; 
    }
  }  
  return index;
}