From 3a9f224f40a25b5551c4a887889b3d1e19b618cb Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Thu, 19 Jul 2018 11:53:17 +0200 Subject: [PATCH] Turbo Coder LUT not a function of CB size --- lib/src/phy/fec/turbocoder.c | 66 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/src/phy/fec/turbocoder.c b/lib/src/phy/fec/turbocoder.c index c8fd5ffb4..09d484c58 100644 --- a/lib/src/phy/fec/turbocoder.c +++ b/lib/src/phy/fec/turbocoder.c @@ -46,7 +46,7 @@ typedef struct { uint8_t output; } tcod_lut_t; -static tcod_lut_t tcod_lut[188][8][256]; +static tcod_lut_t tcod_lut[8][256]; static uint16_t tcod_per_fw[188][6144]; static srslte_bit_interleaver_t tcod_interleavers[188]; @@ -219,7 +219,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t *h, srslte_crc_t *crc, uint8_t *input, srslte_crc_checksum_put_byte(crc, in); /* Run actual encoder */ - tcod_lut_t l = tcod_lut[cblen_idx][state0][in]; + tcod_lut_t l = tcod_lut[state0][in]; parity[i] = l.output; state0 = l.next_state; } @@ -231,7 +231,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t *h, srslte_crc_t *crc, uint8_t *input, uint8_t in = (uint8_t) ((checksum >> mask_shift) & 0xff); input[idx] = in; - tcod_lut_t l = tcod_lut[cblen_idx][state0][in]; + tcod_lut_t l = tcod_lut[state0][in]; parity[idx] = l.output; state0 = l.next_state; } @@ -239,7 +239,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t *h, srslte_crc_t *crc, uint8_t *input, } else { /* No CRC given */ for (uint32_t i = 0; i < long_cb / 8; i++) { - tcod_lut_t l = tcod_lut[cblen_idx][state0][input[i]]; + tcod_lut_t l = tcod_lut[state0][input[i]]; parity[i] = l.output; state0 = l.next_state; } @@ -253,7 +253,7 @@ int srslte_tcod_encode_lut(srslte_tcod_t *h, srslte_crc_t *crc, uint8_t *input, /* Parity bits for the 2nd constituent encoders */ uint8_t state1 = 0; for (uint32_t i=0;itemp[i]]; + tcod_lut_t l = tcod_lut[state1][h->temp[i]]; uint8_t out = l.output; parity[long_cb/8+i] |= (out&0xf0)>>4; parity[long_cb/8+i+1] = (out&0xf)<<4; @@ -344,40 +344,40 @@ void srslte_tcod_gentable() { return; } // Save fw/bw permutation tables - for (uint32_t i=0;i>2; - reg_1 = (state&2)>>1; - reg_2 = state&1; - - tcod_lut[len][state][data].output = 0; - uint8_t bit, in, out; - for (uint32_t i = 0; i < 8; i++) { - bit = (data&(1<<(7-i)))?1:0; - - in = bit ^ (reg_2 ^ reg_1); - out = reg_2 ^ (reg_0 ^ in); - - reg_2 = reg_1; - reg_1 = reg_0; - reg_0 = in; - - tcod_lut[len][state][data].output |= out<<(7-i); - - } - tcod_lut[len][state][data].next_state = (uint8_t) ((reg_0 << 2 | reg_1 << 1 | reg_2) % 8); + } + // Compute state transitions + for (uint32_t state=0;state<8;state++) { + for (uint32_t data=0;data<256;data++) { + + uint8_t reg_0, reg_1, reg_2; + reg_0 = (state&4)>>2; + reg_1 = (state&2)>>1; + reg_2 = state&1; + + tcod_lut[state][data].output = 0; + uint8_t bit, in, out; + for (uint32_t i = 0; i < 8; i++) { + bit = (data&(1<<(7-i)))?1:0; + + in = bit ^ (reg_2 ^ reg_1); + out = reg_2 ^ (reg_0 ^ in); + + reg_2 = reg_1; + reg_1 = reg_0; + reg_0 = in; + + tcod_lut[state][data].output |= out<<(7-i); + } - } + tcod_lut[state][data].next_state = (uint8_t) ((reg_0 << 2 | reg_1 << 1 | reg_2) % 8); + } } srslte_tc_interl_free(&interl);