Commit 380bac3e authored by yilmazt's avatar yilmazt
Browse files

Warning removals and first update of small block coding

parent 151fced6
......@@ -583,7 +583,7 @@ typedef struct {
} nfapi_pnf_phy_rf_config_t;
#define NFAPI_PNF_PHY_RF_TAG 0x1003
// Generic strucutre for single tlv value.
// Generic structure for single tlv value.
typedef struct {
nfapi_tl_t tl;
uint16_t value;
......
......@@ -72,7 +72,7 @@ typedef struct
// These TLVs are used by the VNF to configure the RF in the PNF
// nfapi_uint16_tlv_t max_transmit_power;
nfapi_uint16_tlv_t nrarfcn;
nfapi_uint32_tlv_t nrarfcn;
// nfapi_nmm_frequency_bands_t nmm_gsm_frequency_bands;
// nfapi_nmm_frequency_bands_t nmm_umts_frequency_bands;
......
......@@ -11,10 +11,36 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h"
#include "PHY/CODING/coding_defs.h"
#include "SIMULATION/TOOLS/sim.h"
//#include "PHY/NR_TRANSPORT/nr_transport.h"
//#include "common/utils/LOG/log.h"
//#define DEBUG_DCI_POLAR_PARAMS
//#define DEBUG_POLAR_TIMING
//#define DEBUG_CRC
//#define DEBUG_POLARTEST
uint8_t nr_pbch_payload_interleaving_pattern[32] = {16, 23, 18, 17, 8, 30, 10, 6, 24, 7, 0, 5, 3, 2, 1, 4,
9, 11, 12, 13, 14, 15, 19, 20, 21, 22, 25, 26, 27, 28, 29, 31};
void nr_init_pbch_interleaver(uint8_t *interleaver) {
uint8_t j_sfn=0, j_hrf=10, j_ssb=11, j_other=14;
memset((void*)interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS);
for (uint8_t i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
if (!i) // choice bit:1
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_other++);
else if (i<7) //Sfn bits:6
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_sfn++);
else if (i<24) // other:17
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_other++);
else if (i<28) // Sfn:4
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_sfn++);
else if (i==28) // Hrf bit:1
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_hrf);
else // Ssb bits:3
*(interleaver+i) = *(nr_pbch_payload_interleaving_pattern+j_ssb++);
}
int main(int argc, char *argv[]) {
......@@ -37,9 +63,9 @@ int main(int argc, char *argv[]) {
uint32_t decoderState=0, blockErrorState=0; //0 = Success, -1 = Decoding failed, 1 = Block Error.
uint16_t testLength = 0, coderLength = 0, blockErrorCumulative=0, bitErrorCumulative=0;
double timeEncoderCumulative = 0, timeDecoderCumulative = 0;
uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0;
uint8_t aggregation_level = 8, decoderListSize = 8, pathMetricAppr = 0, matlabDebug = 0;
while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:hqg")) != -1)
while ((arguments = getopt (argc, argv, "s:d:f:c:i:l:a:hqgm")) != -1)
switch (arguments)
{
case 's':
......@@ -54,7 +80,7 @@ int main(int argc, char *argv[]) {
SNRstop = atof(optarg);
break;
case 'm':
case 'c':
polarMessageType = atoi(optarg);
break;
......@@ -74,6 +100,11 @@ int main(int argc, char *argv[]) {
decoder_int16 = 1;
break;
case 'm':
matlabDebug = 1;
//#define DEBUG_POLAR_MATLAB
break;
case 'g':
iterations = 1;
SNRstart = -6.0;
......@@ -82,7 +113,7 @@ int main(int argc, char *argv[]) {
break;
case 'h':
printf("./polartest -s SNRstart -d SNRinc -f SNRstop -m [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr\n");
printf("./polartest -s SNRstart -d SNRinc -f SNRstop -c [0=PBCH|1=DCI|2=UCI] -i iterations -l decoderListSize -a pathMetricAppr -m Matlab Debug\n");
exit(-1);
default:
......@@ -91,7 +122,7 @@ int main(int argc, char *argv[]) {
}
if (polarMessageType == 0) { //PBCH
testLength = 64;//NR_POLAR_PBCH_PAYLOAD_BITS;
testLength = NR_POLAR_PBCH_PAYLOAD_BITS;
coderLength = NR_POLAR_PBCH_E;
aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL;
} else if (polarMessageType == 1) { //DCI
......@@ -320,20 +351,87 @@ int main(int argc, char *argv[]) {
testInput[i] |= ( ((uint32_t) (rand()%2)) &1);
}
/*printf("testInput: [0]->0x%08x\n", testInput[0]);
for (int i=0; i<32; i++)
printf("%d\n",(testInput[0]>>i)&1);*/
#ifdef DEBUG_POLARTEST
printf("testInput: ");
for (int i = 0; i < testArrayLength; i++) printf("[%d]->0x%08x\t",i, testInput[i]);
printf("\n");
printf("testInput[0]: ");
for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[0]>>i)&1);
printf("\n");
printf("testInput[1]: ");
for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[1]>>i)&1);
printf("\n");
#endif
int len_mod64=currentPtr->payloadBits&63;
((uint64_t*)testInput)[currentPtr->payloadBits/64]&=((((uint64_t)1)<<len_mod64)-1);
#ifdef DEBUG_POLARTEST
printf("testInput: ");
for (int i = 0; i < testArrayLength; i++) printf("[%d]->0x%08x\t",i, testInput[i]);
printf("\n");
printf("testInput[0]: ");
for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[0]>>i)&1);
printf("\n");
printf("testInput[1]: ");
for (int i=0; i<32; i++) printf("[%d]=%d-",i,(testInput[1]>>i)&1);
printf("\n");
#endif
if (matlabDebug == 1){
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
/*testInput[0] |= ((uint32_t)1 << 31); testInput[0] |= ((uint32_t)1 << 28); testInput[0] |= ((uint32_t)1 << 26);
testInput[0] |= ((uint32_t)1 << 25); testInput[0] |= ((uint32_t)1 << 22); testInput[0] |= ((uint32_t)1 << 21);
testInput[0] |= ((uint32_t)1 << 19); testInput[0] |= ((uint32_t)1 << 17); testInput[0] |= ((uint32_t)1 << 15);
testInput[0] |= ((uint32_t)1 << 14); testInput[0] |= ((uint32_t)1 << 12); testInput[0] |= ((uint32_t)1 << 10);
testInput[0] |= ((uint32_t)1 << 8); testInput[0] |= ((uint32_t)1 << 5); testInput[0] |= ((uint32_t)1 << 3);
testInput[0] |= ((uint32_t)1 << 2); testInput[0] |= ((uint32_t)1 << 1);*/
testInput[0] |= ((uint32_t)1 << 30); testInput[0] |= ((uint32_t)1 << 29); testInput[0] |= ((uint32_t)1 << 28);
testInput[0] |= ((uint32_t)1 << 26); testInput[0] |= ((uint32_t)1 << 23); testInput[0] |= ((uint32_t)1 << 21);
testInput[0] |= ((uint32_t)1 << 19); testInput[0] |= ((uint32_t)1 << 17); testInput[0] |= ((uint32_t)1 << 16);
testInput[0] |= ((uint32_t)1 << 14); testInput[0] |= ((uint32_t)1 << 12); testInput[0] |= ((uint32_t)1 << 10);
testInput[0] |= ((uint32_t)1 << 9); testInput[0] |= ((uint32_t)1 << 6); testInput[0] |= ((uint32_t)1 << 5);
testInput[0] |= ((uint32_t)1 << 3); testInput[0] |= ((uint32_t)1);
/*printf("testInput (a_31,..., a_0): ");
for (int i=31; i>=0; i--) printf("%d-",(testInput[0]>>i)&1); //a_31, a_30, ..., a_0
printf("testInput = 0x%llx\n", testInput[0]);
printf("\n");*/
/*for (int i=0;i<32;i++){
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
testInput[0] |= ((uint32_t)1 << i);
int crc = crc24c(testInput,32);
printf("[i=%d]testInput = 0x%08lx, crc = 0x%lx\n", i,testInput[0], crc);
}
memset(testInput,0,sizeof(uint32_t) * testArrayLength);
int crc = crc24c(testInput,32);
printf("testInput = 0x%08lx, crc = 0x%lx\n", testInput[0], crc);*/
}
uint8_t nr_pbch_interleaver[NR_POLAR_PBCH_PAYLOAD_BITS];
memset((void*)nr_pbch_interleaver,0, NR_POLAR_PBCH_PAYLOAD_BITS);
nr_init_pbch_interleaver(nr_pbch_interleaver);
for (int i=0; i<=31;i++)
printf("nr_pbch_interleaver[%d]=%d\n",i,nr_pbch_interleaver[i]);
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
printf("nr_pbch_interleaver_operation[%d]=%d\n",i,(*(nr_pbch_interleaver+i)));
start_meas(&timeEncoder);
if (decoder_int16==0)
polar_encoder(testInput, encoderOutput, currentPtr);
if (decoder_int16==1)
polar_encoder_fast((uint64_t*)testInput, encoderOutput, 0, currentPtr);
else
polar_encoder_fast((uint64_t*)testInput, encoderOutput,0, currentPtr);
polar_encoder(testInput, encoderOutput, currentPtr);
//polar_encoder_fast((uint64_t*)testInput, (uint64_t*)encoderOutput,0, currentPtr);
stop_meas(&timeEncoder);
/*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]);
......
......@@ -30,6 +30,8 @@
#include <stdint.h>
#include <PHY/defs_common.h>
typedef unsigned __int128 uint128_t;
#define CRC24_A 0
#define CRC24_B 1
#define CRC16 2
......
......@@ -258,7 +258,7 @@ unsigned int crcPayload(unsigned char * inptr, int bitlen, uint32_t* crc256Table
int check_crc(uint8_t* decoded_bytes, uint32_t n, uint32_t F, uint8_t crc_type)
{
uint32_t crc=0,oldcrc=0;
uint8_t crc_len,temp;
uint8_t crc_len;
switch (crc_type) {
case CRC24_A:
......
......@@ -147,7 +147,7 @@ void polar_encoder_dci(uint32_t *in,
t_nrPolar_paramsPtr polarParams,
uint16_t n_RNTI);
void polar_encoder_fast(uint64_t *A,
void polar_encoder_fast(uint64_t *Aprime,
uint32_t *out,
int32_t crcmask,
t_nrPolar_paramsPtr polarParams);
......
......@@ -33,6 +33,7 @@
//#define DEBUG_POLAR_ENCODER
//#define DEBUG_POLAR_ENCODER_DCI
//#define DEBUG_POLAR_ENCODER_TIMING
#define DEBUG_POLAR_MATLAB
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "assertions.h"
......@@ -336,8 +337,8 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) {
if (polarParams->information_bit_pattern[i] > 0) {
polarParams->G_N_tab[k] = (uint64_t*)memalign(32,(polarParams->N/64)*sizeof(uint64_t));
memset((void*)polarParams->G_N_tab[k],0,(polarParams->N/64)*sizeof(uint64_t));
for (int j=0;j<polarParams->N;j++)
polarParams->G_N_tab[k][j/64] |= ((uint64_t)polarParams->G_N[i][j])<<(j&63);
for (int j=0;j<polarParams->N;j++)
polarParams->G_N_tab[k][j/64] |= ((uint64_t)polarParams->G_N[i][j])<<(j&63);
#ifdef DEBUG_POLAR_ENCODER
printf("Bit %d Selecting row %d of G : ",k,i);
for (int j=0;j<polarParams->N;j+=4) printf("%1x",polarParams->G_N[i][j]+(polarParams->G_N[i][j+1]*2)+(polarParams->G_N[i][j+2]*4)+(polarParams->G_N[i][j+3]*8));
......@@ -385,7 +386,7 @@ void build_polar_tables(t_nrPolar_paramsPtr polarParams) {
}
void polar_encoder_fast(uint64_t *A,
void polar_encoder_fast(uint64_t *Aprime,
uint32_t *out,
int32_t crcmask,
t_nrPolar_paramsPtr polarParams) {
......@@ -394,9 +395,13 @@ void polar_encoder_fast(uint64_t *A,
AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K);
AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits);
uint64_t B[4]={0,0,0,0},Cprime[4]={0,0,0,0};
uint64_t B[4]={0,0,0,0}, Cprime[4]={0,0,0,0};
int bitlen = polarParams->payloadBits;
#ifdef DEBUG_POLAR_MATLAB
if (polarParams->K<65) printf("[polar_encoder_fast]A[0] = 0x%llx\n", (unsigned long long)(Aprime[0])); //(unsigned long long)(Aprime[0]&(((uint64_t)1<<bitlen)-1)),
#endif
// append crc
AssertFatal(bitlen<129,"support for payloads <= 128 bits\n");
......@@ -406,45 +411,65 @@ void polar_encoder_fast(uint64_t *A,
uint64_t tcrc=0;
// A bitstring should be stored as a_{N-1} a_{N-2} ... a_{N-A} 0 .... 0, where N=64,128,192,..., N is smallest multiple of 64 greater than or equal to A
// A bit string should be stored as 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1,
//???a'_{N-1} a'_{N-2} ... a'_{N-A} 0 .... 0, where N=64,128,192,..., N is smallest multiple of 64 greater than or equal to A
// First flip A bitstring byte endian for CRC routines (optimized for DLSCH/ULSCH, not PBCH/PDCCH)
// CRC reads in each byte in bit positions 7 downto 0, for PBCH/PDCCH we need to read in a_{A-1} downto a_{0}, A = length of bit string (e.g. 32 for PBCH)
// CRC reads in each byte in bit positions 7 down to 0, for PBCH/PDCCH we need to read in a_{A-1} down to a_{0}, A = length of bit string (e.g. 32 for PBCH)
if (bitlen<=32) {
uint8_t A32_flip[4];
uint32_t Aprime= (uint32_t)(((uint32_t)*A)<<(32-bitlen));
A32_flip[0]=((uint8_t*)&Aprime)[3];
A32_flip[1]=((uint8_t*)&Aprime)[2];
A32_flip[2]=((uint8_t*)&Aprime)[1];
A32_flip[3]=((uint8_t*)&Aprime)[0];
uint32_t AprimeTmp= (uint32_t)(((uint32_t)*Aprime)<<(32-bitlen));
A32_flip[0]=((uint8_t*)&AprimeTmp)[3]; //a'_0, a'_1, ..., a'_7
A32_flip[1]=((uint8_t*)&AprimeTmp)[2];
A32_flip[2]=((uint8_t*)&AprimeTmp)[1];
A32_flip[3]=((uint8_t*)&AprimeTmp)[0];
tcrc = (uint64_t)((crcmask^(crc24c(A32_flip,bitlen)>>8)));
}
else if (bitlen<=64) {
uint8_t A64_flip[8];
uint64_t Aprime= (uint32_t)(((uint64_t)*A)<<(64-bitlen));
A64_flip[0]=((uint8_t*)&Aprime)[7];
A64_flip[1]=((uint8_t*)&Aprime)[6];
A64_flip[2]=((uint8_t*)&Aprime)[5];
A64_flip[3]=((uint8_t*)&Aprime)[4];
A64_flip[4]=((uint8_t*)&Aprime)[3];
A64_flip[5]=((uint8_t*)&Aprime)[2];
A64_flip[6]=((uint8_t*)&Aprime)[1];
A64_flip[7]=((uint8_t*)&Aprime)[0];
uint64_t AprimeTmp= (uint32_t)(((uint64_t)*Aprime)<<(64-bitlen));
A64_flip[0]=((uint8_t*)&AprimeTmp)[7];
A64_flip[1]=((uint8_t*)&AprimeTmp)[6];
A64_flip[2]=((uint8_t*)&AprimeTmp)[5];
A64_flip[3]=((uint8_t*)&AprimeTmp)[4];
A64_flip[4]=((uint8_t*)&AprimeTmp)[3];
A64_flip[5]=((uint8_t*)&AprimeTmp)[2];
A64_flip[6]=((uint8_t*)&AprimeTmp)[1];
A64_flip[7]=((uint8_t*)&AprimeTmp)[0];
tcrc = (uint64_t)((crcmask^(crc24c(A64_flip,bitlen)>>8)));
}
else if (bitlen<=128) {
uint8_t A128_flip[16];
uint128_t AprimeTmp= (uint32_t)(((uint128_t)*Aprime)<<(128-bitlen));
A128_flip[0]=((uint8_t*)&AprimeTmp)[15]; A128_flip[1]=((uint8_t*)&AprimeTmp)[14];
A128_flip[2]=((uint8_t*)&AprimeTmp)[13]; A128_flip[3]=((uint8_t*)&AprimeTmp)[12];
A128_flip[4]=((uint8_t*)&AprimeTmp)[11]; A128_flip[5]=((uint8_t*)&AprimeTmp)[10];
A128_flip[6] =((uint8_t*)&AprimeTmp)[9]; A128_flip[7] =((uint8_t*)&AprimeTmp)[8];
A128_flip[8] =((uint8_t*)&AprimeTmp)[7]; A128_flip[9] =((uint8_t*)&AprimeTmp)[6];
A128_flip[10]=((uint8_t*)&AprimeTmp)[5]; A128_flip[11]=((uint8_t*)&AprimeTmp)[4];
A128_flip[12]=((uint8_t*)&AprimeTmp)[3]; A128_flip[13]=((uint8_t*)&AprimeTmp)[2];
A128_flip[14]=((uint8_t*)&AprimeTmp)[1]; A128_flip[15]=((uint8_t*)&AprimeTmp)[0];
tcrc = (uint64_t)((crcmask^(crc24c(A128_flip,bitlen)>>8)));
}
int n;
// this is number of quadwords in the bit string
int quadwlen = (polarParams->K>>6);
int quadwlen = (polarParams->K>>6); // this is number of quadwords (64-bits) in the bit string
if ((polarParams->K&63) > 0) quadwlen++;
// Create the B bitstring as
// b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0
// Create the B bit string as
// 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, p_0, p_1, ..., p_{N_parity-1}
//??? b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0
for (n=0;n<quadwlen;n++) if (n==0) B[n] = (A[n] << polarParams->crcParityBits) | tcrc;
else B[n] = (A[n] << polarParams->crcParityBits) | (A[n-1]>>(64-polarParams->crcParityBits));
for (n=0;n<quadwlen;n++) if (n==0) B[n] = (Aprime[n] << polarParams->crcParityBits) | tcrc;
else B[n] = (Aprime[n] << polarParams->crcParityBits) | (Aprime[n-1]>>(64-polarParams->crcParityBits));
#ifdef DEBUG_POLAR_MATLAB
// B = pbchB
for (int i = 0; i < quadwlen; i++) printf("[polar_encoder_fast]B[%d] = 0x%llx\n", i, (unsigned long long)(B[i]));
#endif
uint8_t *Bbyte = (uint8_t*)B;
// for each byte of B, lookup in corresponding table for 64-bit word corresponding to that byte and its position
if (polarParams->K<65)
......@@ -464,10 +489,15 @@ void polar_encoder_fast(uint64_t *A,
}
}
#ifdef DEBUG_POLAR_MATLAB
// Cprime = pbchCprime
for (int i = 0; i < quadwlen; i++) printf("[polar_encoder_fast]C'[%d]= 0x%llx\n", i, (unsigned long long)(Cprime[i]));
#endif
#ifdef DEBUG_POLAR_ENCODER
if (polarParams->K<65)
printf("A %llx B %llx Cprime %llx (payload bits %d,crc %x)\n",
(unsigned long long)(A[0]&(((uint64_t)1<<bitlen)-1)),
(unsigned long long)(Aprime[0]&(((uint64_t)1<<bitlen)-1)),
(unsigned long long)(B[0]),
(unsigned long long)(Cprime[0]),
polarParams->payloadBits,
......@@ -475,52 +505,35 @@ void polar_encoder_fast(uint64_t *A,
else if (polarParams->K<129) {
if (bitlen<64)
printf("A %llx B %llx|%llx Cprime %llx|%llx (payload bits %d,crc %x)\n",
(unsigned long long)(A[0]&(((uint64_t)1<<bitlen)-1)),
(unsigned long long)(Aprime[0]&(((uint64_t)1<<bitlen)-1)),
(unsigned long long)(B[1]),(unsigned long long)(B[0]),
(unsigned long long)(Cprime[1]),(unsigned long long)(Cprime[0]),
polarParams->payloadBits,
tcrc);
else
printf("A %llx|%llx B %llx|%llx Cprime %llx|%llx (payload bits %d,crc %x)\n",
(unsigned long long)(A[1]&(((uint64_t)1<<(bitlen-64))-1)),(unsigned long long)(A[0]),
(unsigned long long)(Aprime[1]&(((uint64_t)1<<(bitlen-64))-1)),(unsigned long long)(Aprime[0]),
(unsigned long long)(B[1]),(unsigned long long)(B[0]),
(unsigned long long)(Cprime[1]),(unsigned long long)(Cprime[0]),
polarParams->payloadBits,
crc24c((uint8_t*)A,bitlen)>>8);
crc24c((uint8_t*)Aprime,bitlen)>>8);
}
#endif
/* printf("Bbytes : %x.%x.%x.%x.%x.%x.%x.%x\n",Bbyte[0],Bbyte[1],Bbyte[2],Bbyte[3],Bbyte[4],Bbyte[5],Bbyte[6],Bbyte[7]);
printf("%llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",polarParams->cprime_tab[0][Bbyte[0]] ,
polarParams->cprime_tab[1][Bbyte[1]] ,
polarParams->cprime_tab[2][Bbyte[2]] ,
polarParams->cprime_tab[3][Bbyte[3]] ,
polarParams->cprime_tab[4][Bbyte[4]] ,
polarParams->cprime_tab[5][Bbyte[5]] ,
polarParams->cprime_tab[6][Bbyte[6]] ,
polarParams->cprime_tab[7][Bbyte[7]]);*/
// now do Gu product (here using 64-bit XORs, we can also do with SIMD after)
// here we're reading out the bits LSB -> MSB, is this correct w.r.t. 3GPP ?
uint64_t Cprime_i;
/* printf("%llx Cprime_0 (%llx) G %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",Cprime_i,Cprime &1,
polarParams->G_N_tab[0][0],
polarParams->G_N_tab[0][1],
polarParams->G_N_tab[0][2],
polarParams->G_N_tab[0][3],
polarParams->G_N_tab[0][4],
polarParams->G_N_tab[0][5],
polarParams->G_N_tab[0][6],
polarParams->G_N_tab[0][7]);*/
uint64_t D[8]={0,0,0,0,0,0,0,0};
int off=0;
int len=polarParams->K;
for (int j=0;j<(1+(polarParams->K>>6));j++,off+=64,len-=64) {
for (int i=0;i<((len>63) ? 64 : len);i++) {
Cprime_i = -((Cprime[j]>>i)&1); // this converts bit 0 as, 0 => 0000x00, 1 => 1111x11
/*
#ifdef DEBUG_POLAR_ENCODER
#ifdef DEBUG_POLAR_ENCODER
printf("%llx Cprime_%d (%llx) G %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",
Cprime_i,off+i,(Cprime[j]>>i) &1,
polarParams->G_N_tab[off+i][0],
......@@ -531,8 +544,8 @@ void polar_encoder_fast(uint64_t *A,
polarParams->G_N_tab[off+i][5],
polarParams->G_N_tab[off+i][6],
polarParams->G_N_tab[off+i][7]);
#endif
*/
#endif
uint64_t *Gi=polarParams->G_N_tab[off+i];
D[0] ^= (Cprime_i & Gi[0]);
D[1] ^= (Cprime_i & Gi[1]);
......@@ -545,17 +558,17 @@ void polar_encoder_fast(uint64_t *A,
}
}
#ifdef DEBUG_POLAR_ENCODER
printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",
D[0],
D[1],
D[2],
D[3],
D[4],
D[5],
D[6],
D[7]);
printf("D %llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n", D[0], D[1], D[2], D[3], D[4], D[5], D[6], D[7]);
#endif
polar_rate_matching(polarParams,(void*)D,(void*)out);
#ifdef DEBUG_POLAR_MATLAB
// D = pbchD
for (int i = 0; i < 8; i++) printf("[polar_encoder_fast]D[%d] = 0x%016llx\n", i, (unsigned long long)(D[i]));
#endif
polar_rate_matching(polarParams,(void*)D,(void*)out);
#ifdef DEBUG_POLAR_MATLAB
// out = pbchF
for (int i = 0; i < (NR_POLAR_PBCH_E/32); i++) printf("[polar_encoder_fast]F[%d] = 0x%08lx\n", i, (unsigned long)(out[i]));
#endif
}
......@@ -26,6 +26,7 @@
#include "PHY/defs_gNB.h"
#include "PHY/defs_nr_UE.h"
#include "PHY/CODING/coding_defs.h"
//#define RM_DEBUG 1
......
......@@ -703,7 +703,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB,
int dlsch_encoding(PHY_VARS_eNB *eNB,
unsigned char *a,
unsigned char *a,
uint8_t num_pdcch_symbols,
LTE_eNB_DLSCH_t *dlsch,
int frame,
......
......@@ -33,6 +33,8 @@
#include "SCHED_NR_UE/pucch_uci_ue_nr.h"
#include "SCHED_NR_UE/pucch_power_control_ue_nr.h"
int16_t get_PL(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
/**************** defines **************************************/
/**************** variables **************************************/
......
......@@ -36,6 +36,7 @@
#include "PHY/NR_REFSIG/ss_pbch_nr.h"
#include "PHY/defs_nr_UE.h"
#include "PHY/NR_UE_TRANSPORT/pucch_nr.h"
#ifndef NO_RAT_NR
......@@ -51,57 +52,7 @@
int8_t nr_ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP, uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe);
uint8_t is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id);
uint8_t is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id);
/*
void nr_generate_pucch0(int32_t **txdataF,
NR_DL_FRAME_PARMS *frame_parms,
PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
int16_t amp,
int nr_tti_tx,
uint8_t mcs,
uint8_t nrofSymbols,
uint8_t startingSymbolIndex,
uint16_t startingPRB);
void nr_generate_pucch1(int32_t **txdataF,
NR_DL_FRAME_PARMS *frame_parms,
PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
uint64_t payload,
int16_t amp,
int nr_tti_tx,
uint8_t nrofSymbols,
uint8_t startingSymbolIndex,
uint16_t startingPRB,
uint16_t startingPRB_intraSlotHopping,
uint8_t timeDomainOCC,
uint8_t nr_bit);
void nr_generate_pucch2(int32_t **txdataF,
NR_DL_FRAME_PARMS *frame_parms,
PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
uint64_t payload,
int16_t amp,
int nr_tti_tx,
uint8_t nrofSymbols,
uint8_t startingSymbolIndex,
uint8_t nrofPRB,
uint16_t startingPRB,
uint8_t nr_bit);
void nr_generate_pucch3_4(int32_t **txdataF,
NR_DL_FRAME_PARMS *frame_parms,
pucch_format_nr_t fmt,
PUCCH_CONFIG_DEDICATED *pucch_config_dedicated,
uint64_t payload,
int16_t amp,
int nr_tti_tx,
uint8_t nrofSymbols,
uint8_t startingSymbolIndex,
uint8_t nrofPRB,
uint16_t startingPRB,
uint8_t nr_bit,
uint8_t occ_length_format4,
uint8_t occ_index_format4);
*/
/**************** variables **************************************/
......@@ -556,7 +507,8 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_
switch(format) {
case pucch_format0_nr:
{
nr_generate_pucch0(ue,ue->common_vars.txdataF,
nr_generate_pucch0(ue,
ue->common_vars.txdataF,
&ue->frame_parms,