Commit 83b36317 authored by Florian Kaltenberger's avatar Florian Kaltenberger

cleaning up some unused code + adding crcTableInit everywhere

parent 703d1898
...@@ -255,48 +255,6 @@ unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table ...@@ -255,48 +255,6 @@ unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table
return crc; return crc;
} }
void nr_crc_computation(uint8_t* input, uint8_t* output, uint16_t payloadBits, uint16_t crcParityBits, uint32_t* crc256Table)
{
//Create payload in bit
uint8_t* input2 = (uint8_t*)malloc(payloadBits); //divided by 8 (in bits)
uint8_t mask = 128; // 10000000
for(uint8_t ind=0; ind<(payloadBits/8); ind++)
{
input2[ind]=0;
for(uint8_t ind2=0; ind2<8; ind2++)
{
if(input[8*ind+ind2])
{
input2[ind] = input2[ind] | mask;
}
mask= mask >> 1;
}
mask=128;
}
//crcTable256Init(poly);
unsigned int crcBits;
crcBits = crcPayload(input2, payloadBits, crc256Table);
//create crc in byte
unsigned int mask2=0x80000000; //100...
for(uint8_t ind=0; ind<crcParityBits; ind++)
{
if(crcBits & mask2)
output[ind]=1;
else
output[ind]=0;
mask2 = mask2 >> 1;
}
}
#ifdef DEBUG_CRC #ifdef DEBUG_CRC
......
...@@ -21,132 +21,7 @@ ...@@ -21,132 +21,7 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
/*
// ----- New implementation ----
uint32_t poly6 = 0x84000000; // 10000100000... -> D^6+D^5+1
uint32_t poly11 = 0xc4200000; //11000100001000... -> D^11+D^10+D^9+D^5+1
uint32_t poly16 = 0x10210000; //00100000010000100... - > D^16+D^12+D^5+1
uint32_t poly24a = 0x864cfb00; //100001100100110011111011 -> D^24+D^23+D^18+D^17+D^14+D^11+D^10+D^7+D^6+D^5+D^4+D^3+D+1
uint32_t poly24b = 0x80006300; //100000000000000001100011 -> D^24+D^23+D^6+D^5+D+1
uint32_t poly24c = 0xB2B11700; //101100101011000100010111 -> D^24...
//static unsigned int crc256Table[256];
void nr_crc_computation(uint8_t* input, uint8_t* output, uint16_t payloadBits, uint16_t crcParityBits, uint32_t* crc256Table)
{
//Create payload in bit
uint8_t* input2 = (uint8_t*)malloc(payloadBits); //divided by 8 (in bits)
uint8_t mask = 128; // 10000000
for(uint8_t ind=0; ind<(payloadBits/8); ind++)
{
input2[ind]=0;
for(uint8_t ind2=0; ind2<8; ind2++)
{
if(input[8*ind+ind2])
{
input2[ind] = input2[ind] | mask;
}
mask= mask >> 1;
}
mask=128;
}
//crcTable256Init(poly);
unsigned int crcBits;
crcBits = crcPayload(input2, payloadBits, crc256Table);
//create crc in byte
unsigned int mask2=0x80000000; //100...
output = (uint8_t*)malloc(sizeof(uint8_t)*crcParityBits);
for(uint8_t ind=0; ind<crcParityBits; ind++)
{
if(crcBits & mask2)
output[ind]=1;
else
output[ind]=0;
mask2 = mask2 >> 1;
}
}
unsigned int crcbit (unsigned char* inputptr, int octetlen, unsigned int poly)
{
unsigned int i, crc = 0, c;
while (octetlen-- > 0) {
c = (*inputptr++) << 24;
for (i = 8; i != 0; i--) {
if ((1 << 31) & (c ^ crc))
crc = (crc << 1) ^ poly;
else
crc <<= 1;
c <<= 1;
}
}
return crc;
}
void crcTableInit (void)
{
unsigned char c = 0;
do {
crc6Table[c] = crcbit(&c, 1, poly6);
crc11Table[c]= crcbit(&c, 1, poly11);
crc16Table[c] =crcbit(&c, 1, poly16);
crc24aTable[c]=crcbit(&c, 1, poly24a);
crc24bTable[c]=crcbit(&c, 1, poly24b);
crc24cTable[c]=crcbit(&c, 1, poly24c);
} while (++c);
}
void crcTable256Init (uint32_t poly, uint32_t* crc256Table)
{
unsigned char c = 0;
// crc256Table = malloc(sizeof(uint32_t)*256);
do {
crc256Table[c] = crcbit(&c, 1, poly);
// crc6Table[c] = crcbit(&c, 1, poly6);
// crc11Table[c]= crcbit(&c, 1, poly11);
// crc16Table[c] =crcbit(&c, 1, poly16);
// crc24aTable[c]=crcbit(&c, 1, poly24a);
// crc24bTable[c]=crcbit(&c, 1, poly24b);
// crc24cTable[c]=crcbit(&c, 1, poly24c);
} while (++c);
//return crc256Table;
}
unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table)
{
int octetlen, resbit;
unsigned int crc = 0;
octetlen = bitlen/8; // Change in bytes
resbit = (bitlen % 8);
while (octetlen-- > 0)
{
crc = (crc << 8) ^ crc256Table[(*inptr++) ^ (crc >> 24)];
}
if (resbit > 0)
{
crc = (crc << resbit) ^ crc256Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
}
return crc;
}
*/
// ----- Old implementation ---- // ----- Old implementation ----
uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){ uint8_t **crc24c_generator_matrix(uint16_t payloadSizeBits){
......
...@@ -72,6 +72,7 @@ void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) ...@@ -72,6 +72,7 @@ void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms)
init_dfts(); init_dfts();
crcTableInit();
phy_generate_viterbi_tables_lte(); phy_generate_viterbi_tables_lte();
......
...@@ -115,6 +115,10 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, ...@@ -115,6 +115,10 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
);*/ );*/
LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_gNB][MOD %02"PRIu8"][]\n", gNB->Mod_id); LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_gNB][MOD %02"PRIu8"][]\n", gNB->Mod_id);
crcTableInit();
init_dfts();
// PBCH DMRS gold sequences generation // PBCH DMRS gold sequences generation
nr_init_pbch_dmrs(gNB); nr_init_pbch_dmrs(gNB);
// Polar encoder init for PBCH // Polar encoder init for PBCH
......
...@@ -947,6 +947,8 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue) ...@@ -947,6 +947,8 @@ void phy_init_nr_top(PHY_VARS_NR_UE *ue)
crcTableInit(); crcTableInit();
init_dfts();
ccodedot11_init(); ccodedot11_init();
ccodedot11_init_inv(); ccodedot11_init_inv();
......
...@@ -886,7 +886,6 @@ static void wait_nfapi_init(char *thread_name) { ...@@ -886,7 +886,6 @@ static void wait_nfapi_init(char *thread_name) {
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
crcTableInit();
int i; int i;
#if defined (XFORMS) #if defined (XFORMS)
//void *status; //void *status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment