fix ubsan detected errors
This commit is contained in:
@@ -814,7 +814,7 @@ uint8_t phy_threegpplte_turbo_decoder8(int16_t *y,
|
||||
llr_t *s1,*s2,*yp1,*yp2,*yp;
|
||||
unsigned int i,j,iind;//,pi;
|
||||
unsigned char iteration_cnt=0;
|
||||
unsigned int crc,oldcrc,crc_len;
|
||||
unsigned int crc, crc_len;
|
||||
uint8_t temp;
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
__m128i *yp128;
|
||||
@@ -1233,8 +1233,8 @@ uint8_t phy_threegpplte_turbo_decoder8(int16_t *y,
|
||||
}
|
||||
|
||||
// check the CRC
|
||||
oldcrc= *((unsigned int *)(&decoded_bytes[(n>>3)-crc_len]));
|
||||
|
||||
uint32_t oldcrc;
|
||||
memcpy(&oldcrc, &decoded_bytes[(n >> 3) - crc_len], crc_len);
|
||||
switch (crc_type) {
|
||||
case CRC24_A:
|
||||
oldcrc&=0x00ffffff;
|
||||
|
||||
@@ -244,11 +244,11 @@ crc16 (unsigned char * inptr, int bitlen)
|
||||
|
||||
while (octetlen-- > 0) {
|
||||
|
||||
crc = (crc << 8) ^ (crc16Table[(*inptr++) ^ (crc >> 24)] << 16);
|
||||
crc = (crc << 8) ^ (((uint32_t)crc16Table[(*inptr++) ^ (crc >> 24)]) << 16);
|
||||
}
|
||||
|
||||
if (resbit > 0)
|
||||
crc = (crc << resbit) ^ (crc16Table[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))] << 16);
|
||||
crc = (crc << resbit) ^ (((uint32_t)crc16Table[(*inptr) >> (8 - resbit) ^ (crc >> (32 - resbit))]) << 16);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
@@ -961,7 +961,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1028,7 +1029,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1096,7 +1098,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1163,7 +1166,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1230,7 +1234,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1297,7 +1302,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1364,7 +1370,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1431,7 +1438,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1498,7 +1506,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG1(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1593,7 +1602,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1660,7 +1670,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1727,7 +1738,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1794,7 +1806,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1861,7 +1874,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
@@ -1928,7 +1942,8 @@ static inline uint32_t nrLDPC_cnProcPc_BG2(t_nrLDPC_lut* p_lut, int8_t* cnProcBu
|
||||
|
||||
// If no error pcRes should be 0
|
||||
// Only use valid CNs
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
if (Mrem)
|
||||
pcResSum |= (pcRes&(0xFFFFFFFF>>(32-Mrem)));
|
||||
|
||||
// If PC failed we can stop here
|
||||
if (pcResSum > 0)
|
||||
|
||||
@@ -562,9 +562,9 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) {
|
||||
case 15:
|
||||
if (vrb<12) {
|
||||
if ((vrb&3) < 2) // even: 0->0, 1->4, 4->1, 5->5, 8->2, 9->6 odd: 0->7, 1->11
|
||||
return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14);
|
||||
return(((7*odd_slot) + 4*(vrb&3) + (vrb>>2))%14) + 14*(vrb/14);
|
||||
else if (vrb < 12) // even: 2->7, 3->11, 6->8, 7->12, 10->9, 11->13
|
||||
return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14);
|
||||
return (((7*odd_slot) + 4*(vrb&3) + (vrb>>2) +13 )%14) + 14*(vrb/14);
|
||||
}
|
||||
if (vrb==12)
|
||||
return (3+(7*odd_slot)) % 14;
|
||||
@@ -573,6 +573,8 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) {
|
||||
return 14;
|
||||
break;
|
||||
|
||||
// Formula in TS 36.211, chap 6.2.3.2
|
||||
// Fix me: returns a PRB number > 24 when vrb is 24
|
||||
case 25:
|
||||
return (((12*odd_slot) + 6*(vrb&3) + (vrb>>2))%24) + 24*(vrb/24);
|
||||
break;
|
||||
@@ -581,43 +583,44 @@ uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap) {
|
||||
if (Ngap==0) {
|
||||
// Nrow=12,Nnull=2,NVRBDL=46,Ngap1= 27
|
||||
if (vrb>=23)
|
||||
offset=4;
|
||||
offset=4;
|
||||
else
|
||||
offset=0;
|
||||
offset=0;
|
||||
if (vrb<44) {
|
||||
if ((vrb&3)>=2)
|
||||
return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46;
|
||||
else
|
||||
return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46;
|
||||
if ((vrb&3)>=2)
|
||||
return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2) + 45)%46;
|
||||
else
|
||||
return offset+((23*odd_slot) + 12*(vrb&3) + (vrb>>2))%46;
|
||||
}
|
||||
if (vrb==44) // even: 44->11, odd: 45->34
|
||||
return offset+((23*odd_slot) + 22-12+1);
|
||||
return offset+((23*odd_slot) + 22-12+1);
|
||||
if (vrb==45) // even: 45->10, odd: 45->33
|
||||
return offset+((23*odd_slot) + 22+12);
|
||||
return offset+((23*odd_slot) + 22+12);
|
||||
if (vrb==46)
|
||||
return offset+46+((23*odd_slot) + 23-12+1) % 46;
|
||||
return offset+46+((23*odd_slot) + 23-12+1) % 46;
|
||||
if (vrb==47)
|
||||
return offset+46+((23*odd_slot) + 23+12) % 46;
|
||||
return offset+46+((23*odd_slot) + 23+12) % 46;
|
||||
if (vrb==48)
|
||||
return offset+46+((23*odd_slot) + 23-12+1) % 46;
|
||||
return offset+46+((23*odd_slot) + 23-12+1) % 46;
|
||||
if (vrb==49)
|
||||
return offset+46+((23*odd_slot) + 23+12) % 46;
|
||||
return offset+46+((23*odd_slot) + 23+12) % 46;
|
||||
}
|
||||
else {
|
||||
// Nrow=6,Nnull=6,NVRBDL=18,Ngap1= 27
|
||||
if (vrb>=9)
|
||||
offset=18;
|
||||
offset=18;
|
||||
else
|
||||
offset=0;
|
||||
offset=0;
|
||||
|
||||
if (vrb<12) {
|
||||
if ((vrb&3)>=2)
|
||||
return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18;
|
||||
else
|
||||
return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18;
|
||||
if ((vrb&3)>=2)
|
||||
return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2) + 17)%18;
|
||||
else
|
||||
return offset+((9*odd_slot) + 6*(vrb&3) + (vrb>>2))%18;
|
||||
}
|
||||
else {
|
||||
return offset+((9*odd_slot) + 12*(vrb&1)+(vrb>>1) )%18 + 18*(vrb/18);
|
||||
// Same issue as for 25 PRB: returns larger than 0..49
|
||||
return ((9*odd_slot) + 12*(vrb&1) + (vrb>>1))%18 + 18*(vrb/18);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -677,7 +680,7 @@ void generate_RIV_tables(void)
|
||||
|
||||
// printf("RIV %d (%d) : first_rb %d NBRB %d\n",RIV,localRIV2alloc_LUT25[RIV],RBstart,Lcrbs);
|
||||
localRIV2alloc_LUT6[RIV] = alloc0;
|
||||
distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even;
|
||||
distRIV2alloc_even_LUT6[RIV] = allocdist0_0_even;
|
||||
distRIV2alloc_odd_LUT6[RIV] = allocdist0_0_odd;
|
||||
RIV2nb_rb_LUT6[RIV] = Lcrbs;
|
||||
RIV2first_rb_LUT6[RIV] = RBstart;
|
||||
@@ -693,15 +696,14 @@ void generate_RIV_tables(void)
|
||||
nVRB = Lcrbs-1+RBstart;
|
||||
//printf("RBstart %d, len %d --> ",RBstart,Lcrbs);
|
||||
alloc0 |= (1<<nVRB);
|
||||
allocdist0_0_even |= (1<<get_prb(25,0,nVRB,0));
|
||||
allocdist0_0_odd |= (1<<get_prb(25,1,nVRB,0));
|
||||
allocdist0_0_even |= 1U << get_prb(25, 0, nVRB, 0);
|
||||
allocdist0_0_odd |= 1U << get_prb(25, 1, nVRB, 0);
|
||||
|
||||
//printf("alloc 0 %x, allocdist0_even %x, allocdist0_odd %x\n",alloc0,allocdist0_0_even,allocdist0_0_odd);
|
||||
RIV=computeRIV(25,RBstart,Lcrbs);
|
||||
|
||||
if (RIV>RIV_max25)
|
||||
RIV_max25 = RIV;;
|
||||
|
||||
RIV_max25 = RIV;
|
||||
|
||||
localRIV2alloc_LUT25[RIV] = alloc0;
|
||||
distRIV2alloc_even_LUT25[RIV] = allocdist0_0_even;
|
||||
@@ -730,37 +732,37 @@ void generate_RIV_tables(void)
|
||||
|
||||
|
||||
if (nVRB<32)
|
||||
alloc0 |= (1<<nVRB);
|
||||
alloc0 |= 1U << nVRB;
|
||||
else
|
||||
alloc1 |= (1<<(nVRB-32));
|
||||
alloc1 |= 1U << (nVRB - 32);
|
||||
|
||||
// Distributed Gap1, even slot
|
||||
nVRB_even_dist = get_prb(50,0,nVRB,0);
|
||||
if (nVRB_even_dist<32)
|
||||
allocdist0_0_even |= (1<<nVRB_even_dist);
|
||||
allocdist0_0_even |= 1U << nVRB_even_dist;
|
||||
else
|
||||
allocdist1_0_even |= (1<<(nVRB_even_dist-32));
|
||||
allocdist1_0_even |= 1U << (nVRB_even_dist - 32);
|
||||
|
||||
// Distributed Gap1, odd slot
|
||||
nVRB_odd_dist = get_prb(50,1,nVRB,0);
|
||||
if (nVRB_odd_dist<32)
|
||||
allocdist0_0_odd |= (1<<nVRB_odd_dist);
|
||||
allocdist0_0_odd |= (1U <<nVRB_odd_dist);
|
||||
else
|
||||
allocdist1_0_odd |= (1<<(nVRB_odd_dist-32));
|
||||
allocdist1_0_odd |= (1U <<(nVRB_odd_dist-32));
|
||||
|
||||
// Distributed Gap2, even slot
|
||||
nVRB_even_dist = get_prb(50,0,nVRB,1);
|
||||
if (nVRB_even_dist<32)
|
||||
allocdist0_1_even |= (1<<nVRB_even_dist);
|
||||
allocdist0_1_even |= 1U << nVRB_even_dist;
|
||||
else
|
||||
allocdist1_1_even |= (1<<(nVRB_even_dist-32));
|
||||
allocdist1_1_even |= 1U << (nVRB_even_dist - 32);
|
||||
|
||||
// Distributed Gap2, odd slot
|
||||
nVRB_odd_dist = get_prb(50,1,nVRB,1);
|
||||
if (nVRB_odd_dist<32)
|
||||
allocdist0_1_odd |= (1<<nVRB_odd_dist);
|
||||
allocdist0_1_odd |= 1U << nVRB_odd_dist;
|
||||
else
|
||||
allocdist1_1_odd |= (1<<(nVRB_odd_dist-32));
|
||||
allocdist1_1_odd |= 1U << (nVRB_odd_dist - 32);
|
||||
|
||||
RIV=computeRIV(50,RBstart,Lcrbs);
|
||||
|
||||
@@ -811,13 +813,13 @@ void generate_RIV_tables(void)
|
||||
nVRB = Lcrbs-1+RBstart;
|
||||
|
||||
if (nVRB<32)
|
||||
alloc0 |= (1<<nVRB);
|
||||
alloc0 |= 1U << nVRB;
|
||||
else if (nVRB<64)
|
||||
alloc1 |= (1<<(nVRB-32));
|
||||
alloc1 |= 1U << (nVRB - 32);
|
||||
else if (nVRB<96)
|
||||
alloc2 |= (1<<(nVRB-64));
|
||||
alloc2 |= 1U << (nVRB - 64);
|
||||
else
|
||||
alloc3 |= (1<<(nVRB-96));
|
||||
alloc3 |= 1U << (nVRB - 96);
|
||||
|
||||
// Distributed Gap1, even slot
|
||||
nVRB_even_dist = get_prb(100,0,nVRB,0);
|
||||
@@ -825,15 +827,14 @@ void generate_RIV_tables(void)
|
||||
// if ((RBstart==0) && (Lcrbs<=8))
|
||||
// printf("nVRB %d => nVRB_even_dist %d\n",nVRB,nVRB_even_dist);
|
||||
|
||||
|
||||
if (nVRB_even_dist<32)
|
||||
allocdist0_0_even |= (1<<nVRB_even_dist);
|
||||
allocdist0_0_even |= 1U << nVRB_even_dist;
|
||||
else if (nVRB_even_dist<64)
|
||||
allocdist1_0_even |= (1<<(nVRB_even_dist-32));
|
||||
allocdist1_0_even |= 1U << (nVRB_even_dist - 32);
|
||||
else if (nVRB_even_dist<96)
|
||||
allocdist2_0_even |= (1<<(nVRB_even_dist-64));
|
||||
allocdist2_0_even |= 1U << (nVRB_even_dist - 64);
|
||||
else
|
||||
allocdist3_0_even |= (1<<(nVRB_even_dist-96));
|
||||
allocdist3_0_even |= 1U << (nVRB_even_dist - 96);
|
||||
/* if ((RBstart==0) && (Lcrbs<=8))
|
||||
printf("rballoc =>(%08x.%08x.%08x.%08x)\n",
|
||||
allocdist0_0_even,
|
||||
@@ -845,38 +846,37 @@ void generate_RIV_tables(void)
|
||||
// Distributed Gap1, odd slot
|
||||
nVRB_odd_dist = get_prb(100,1,nVRB,0);
|
||||
if (nVRB_odd_dist<32)
|
||||
allocdist0_0_odd |= (1<<nVRB_odd_dist);
|
||||
allocdist0_0_odd |= 1U << nVRB_odd_dist;
|
||||
else if (nVRB_odd_dist<64)
|
||||
allocdist1_0_odd |= (1<<(nVRB_odd_dist-32));
|
||||
allocdist1_0_odd |= 1U << (nVRB_odd_dist - 32);
|
||||
else if (nVRB_odd_dist<96)
|
||||
allocdist2_0_odd |= (1<<(nVRB_odd_dist-64));
|
||||
allocdist2_0_odd |= 1U << (nVRB_odd_dist - 64);
|
||||
else
|
||||
allocdist3_0_odd |= (1<<(nVRB_odd_dist-96));
|
||||
allocdist3_0_odd |= 1U << (nVRB_odd_dist - 96);
|
||||
|
||||
|
||||
// Distributed Gap2, even slot
|
||||
nVRB_even_dist = get_prb(100,0,nVRB,1);
|
||||
if (nVRB_even_dist<32)
|
||||
allocdist0_1_even |= (1<<nVRB_even_dist);
|
||||
allocdist0_1_even |= 1U << nVRB_even_dist;
|
||||
else if (nVRB_even_dist<64)
|
||||
allocdist1_1_even |= (1<<(nVRB_even_dist-32));
|
||||
allocdist1_1_even |= 1U << (nVRB_even_dist - 32);
|
||||
else if (nVRB_even_dist<96)
|
||||
allocdist2_1_even |= (1<<(nVRB_even_dist-64));
|
||||
allocdist2_1_even |= 1U << (nVRB_even_dist - 64);
|
||||
else
|
||||
allocdist3_1_even |= (1<<(nVRB_even_dist-96));
|
||||
allocdist3_1_even |= 1U << (nVRB_even_dist - 96);
|
||||
|
||||
|
||||
// Distributed Gap2, odd slot
|
||||
nVRB_odd_dist = get_prb(100,1,nVRB,1);
|
||||
if (nVRB_odd_dist<32)
|
||||
allocdist0_1_odd |= (1<<nVRB_odd_dist);
|
||||
allocdist0_1_odd |= 1U << nVRB_odd_dist;
|
||||
else if (nVRB_odd_dist<64)
|
||||
allocdist1_1_odd |= (1<<(nVRB_odd_dist-32));
|
||||
allocdist1_1_odd |= 1U << (nVRB_odd_dist - 32);
|
||||
else if (nVRB_odd_dist<96)
|
||||
allocdist2_1_odd |= (1<<(nVRB_odd_dist-64));
|
||||
allocdist2_1_odd |= 1U << (nVRB_odd_dist - 64);
|
||||
else
|
||||
allocdist3_1_odd |= (1<<(nVRB_odd_dist-96));
|
||||
|
||||
allocdist3_1_odd |= 1U << (nVRB_odd_dist - 96);
|
||||
|
||||
RIV=computeRIV(100,RBstart,Lcrbs);
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ static void TPencode(void * arg) {
|
||||
LTE_DL_eNB_HARQ_t *hadlsch=rdata->dlsch->harq_processes[harq_pid];
|
||||
|
||||
if ( rdata-> round == 0) {
|
||||
uint8_t tmp[96+12+3+3*6144];
|
||||
uint8_t tmp[96+12+3+3*6144] __attribute__((aligned(32)));
|
||||
memset(tmp,LTE_NULL, TURBO_SIMD_SOFTBITS);
|
||||
start_meas(rdata->te_stats);
|
||||
encoder(rdata->input,
|
||||
|
||||
@@ -1272,14 +1272,6 @@ uint32_t get_TBS_DL(uint8_t mcs, uint16_t nb_rb);
|
||||
@return Transport block size */
|
||||
uint32_t get_TBS_UL(uint8_t mcs, uint16_t nb_rb);
|
||||
|
||||
/* \brief Return bit-map of resource allocation for a given DCI rballoc (RIV format) and vrb type
|
||||
@param N_RB_DL number of PRB on DL
|
||||
@param indicator for even/odd slot
|
||||
@param vrb vrb index
|
||||
@param Ngap Gap indicator
|
||||
*/
|
||||
uint32_t get_prb(int N_RB_DL,int odd_slot,int vrb,int Ngap);
|
||||
|
||||
/* \brief Return prb for a given vrb index
|
||||
@param vrb_type VRB type (0=localized,1=distributed)
|
||||
@param rb_alloc_dci rballoc field from DCI
|
||||
|
||||
@@ -90,7 +90,7 @@ typedef struct {
|
||||
/// Redundancy-version of the current sub-frame
|
||||
uint8_t rvidx;
|
||||
/// Turbo-code outputs (36-212 V8.6 2009-03, p.12
|
||||
uint8_t d[MAX_NUM_ULSCH_SEGMENTS][(96+3+(3*6144))];
|
||||
uint8_t *d[MAX_NUM_ULSCH_SEGMENTS];
|
||||
/// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
|
||||
uint8_t w[MAX_NUM_ULSCH_SEGMENTS][3*6144];
|
||||
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
|
||||
|
||||
@@ -71,6 +71,7 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch) {
|
||||
for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++) {
|
||||
if (ulsch->harq_processes[i]->c[r]) {
|
||||
free16(ulsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
|
||||
free16(ulsch->harq_processes[i]->d[r],0);
|
||||
ulsch->harq_processes[i]->c[r] = NULL;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +87,7 @@ void free_ue_ulsch(LTE_UE_ULSCH_t *ulsch) {
|
||||
|
||||
LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) {
|
||||
LTE_UE_ULSCH_t *ulsch;
|
||||
unsigned char exit_flag = 0,i,j,r;
|
||||
unsigned char exit_flag = 0;
|
||||
unsigned char bw_scaling =1;
|
||||
|
||||
switch (N_RB_UL) {
|
||||
@@ -113,7 +114,7 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) {
|
||||
memset(ulsch,0,sizeof(LTE_UE_ULSCH_t));
|
||||
ulsch->Mlimit = 4;
|
||||
|
||||
for (i=0; i<8; i++) {
|
||||
for (int i=0; i<8; i++) {
|
||||
ulsch->harq_processes[i] = (LTE_UL_UE_HARQ_t *)malloc16(sizeof(LTE_UL_UE_HARQ_t));
|
||||
|
||||
// printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]);
|
||||
@@ -129,15 +130,11 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) {
|
||||
}
|
||||
|
||||
if (abstraction_flag==0) {
|
||||
for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++) {
|
||||
ulsch->harq_processes[i]->c[r] = (unsigned char *)malloc16(((r==0)?8:0) + 3+768); // account for filler in first segment and CRCs for multiple segment case
|
||||
|
||||
if (ulsch->harq_processes[i]->c[r])
|
||||
memset(ulsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+768);
|
||||
else {
|
||||
LOG_E(PHY,"Can't get c\n");
|
||||
exit_flag=2;
|
||||
}
|
||||
for (int r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++) {
|
||||
ulsch->harq_processes[i]->c[r] = malloc16_clear(((r==0)?8:0) + 3+768); // account for filler in first segment and CRCs for multiple segment case
|
||||
AssertFatal(ulsch->harq_processes[i]->c[r], "");
|
||||
ulsch->harq_processes[i]->d[r] = malloc16_clear(96+3+(3*6144));
|
||||
AssertFatal(ulsch->harq_processes[i]->d[r], "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,15 +145,7 @@ LTE_UE_ULSCH_t *new_ue_ulsch(unsigned char N_RB_UL, uint8_t abstraction_flag) {
|
||||
exit_flag=3;
|
||||
}
|
||||
}
|
||||
|
||||
if ((abstraction_flag == 0) && (exit_flag==0)) {
|
||||
for (i=0; i<8; i++)
|
||||
for (j=0; j<96; j++)
|
||||
for (r=0; r<MAX_NUM_ULSCH_SEGMENTS; r++)
|
||||
ulsch->harq_processes[i]->d[r][j] = LTE_NULL;
|
||||
|
||||
return(ulsch);
|
||||
} else if (abstraction_flag==1)
|
||||
if (!exit_flag)
|
||||
return(ulsch);
|
||||
}
|
||||
|
||||
@@ -191,7 +180,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
uint32_t Qprime_ACK=0,Qprime_CQI=0,Qprime_RI=0,len_ACK=0,len_RI=0;
|
||||
// uint32_t E;
|
||||
uint8_t ack_parity;
|
||||
uint32_t i,q,j,iprime,j2;
|
||||
uint32_t q,j,iprime,j2;
|
||||
uint16_t o_RCC;
|
||||
uint8_t o_flip[8];
|
||||
uint32_t wACK_idx;
|
||||
@@ -327,6 +316,8 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
#endif
|
||||
// offset=0;
|
||||
start_meas(te_stats);
|
||||
for (int z=0; z<96; z++)
|
||||
ulsch->harq_processes[harq_pid]->d[r][z] = LTE_NULL;
|
||||
encoder(ulsch->harq_processes[harq_pid]->c[r],
|
||||
Kr>>3,
|
||||
&ulsch->harq_processes[harq_pid]->d[r][96],
|
||||
@@ -539,8 +530,6 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
ulsch->q);
|
||||
}
|
||||
|
||||
i=0;
|
||||
|
||||
// Do RI coding
|
||||
if (ulsch->O_RI == 1) {
|
||||
switch (Q_m) {
|
||||
@@ -691,7 +680,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
|
||||
j=0;
|
||||
|
||||
for (i=0; i<Qprime_RI; i++) {
|
||||
for (int i=0; i<Qprime_RI; i++) {
|
||||
r = Rmux_prime - 1 - (i>>2);
|
||||
|
||||
for (q=0; q<Q_m; q++) {
|
||||
@@ -725,7 +714,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
}
|
||||
*/
|
||||
|
||||
for (i=0; i<Qprime_CQI; i++) {
|
||||
for (int i=0; i<Qprime_CQI; i++) {
|
||||
while (y[Q_m*j] != LTE_NULL) j++;
|
||||
|
||||
for (q=0; q<Q_m; q++) {
|
||||
@@ -788,7 +777,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
|
||||
j=0;
|
||||
|
||||
for (i=0; i<Qprime_ACK; i++) {
|
||||
for (int i=0; i<Qprime_ACK; i++) {
|
||||
r = Rmux_prime - 1 - (i>>2);
|
||||
|
||||
for (q=0; q<Q_m; q++) {
|
||||
@@ -808,7 +797,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
|
||||
switch (Q_m) {
|
||||
case 2:
|
||||
for (i=0; i<Cmux; i++)
|
||||
for (int i=0; i<Cmux; i++)
|
||||
for (r=0; r<Rmux_prime; r++) {
|
||||
yptr=&y[((r*Cmux)+i)<<1];
|
||||
ulsch->h[j++] = *yptr++;
|
||||
@@ -818,7 +807,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for (i=0; i<Cmux; i++)
|
||||
for (int i=0; i<Cmux; i++)
|
||||
for (r=0; r<Rmux_prime; r++) {
|
||||
yptr = &y[((r*Cmux)+i)<<2];
|
||||
ulsch->h[j++] = *yptr++;
|
||||
@@ -830,7 +819,7 @@ uint32_t ulsch_encoding(uint8_t *a,
|
||||
break;
|
||||
|
||||
case 6:
|
||||
for (i=0; i<Cmux; i++)
|
||||
for (int i=0; i<Cmux; i++)
|
||||
for (r=0; r<Rmux_prime; r++) {
|
||||
yptr = &y[((r*Cmux)+i)*6];
|
||||
ulsch->h[j++] = *yptr++;
|
||||
|
||||
@@ -226,10 +226,11 @@ void nr_modulation(uint32_t *in,
|
||||
i *= 24;
|
||||
bit_cnt = i * 8;
|
||||
while (bit_cnt < length) {
|
||||
x = *((uint32_t*)(in_bytes+i));
|
||||
x1 = x&4095;
|
||||
uint32_t xx;
|
||||
memcpy(&xx, in_bytes+i, sizeof(xx));
|
||||
x1 = xx & 4095;
|
||||
out64[j++] = nr_64qam_mod_table[x1];
|
||||
x1 = (x>>12)&4095;
|
||||
x1 = (xx >> 12) & 4095;
|
||||
out64[j++] = nr_64qam_mod_table[x1];
|
||||
i += 3;
|
||||
bit_cnt += 24;
|
||||
|
||||
@@ -119,7 +119,7 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb
|
||||
measurements->n0_subband_power[aarx][rb]=0;
|
||||
}
|
||||
int offset0 = (slot&3)*(frame_parms->symbols_per_slot * frame_parms->ofdm_symbol_size) + (frame_parms->first_carrier_offset + (rb*12))%frame_parms->ofdm_symbol_size;
|
||||
if ((gNB->rb_mask_ul[s][rb>>5]&(1<<(rb&31))) == 0) { // check that rb was not used in this subframe
|
||||
if ((gNB->rb_mask_ul[s][rb >> 5] & (1U << (rb & 31))) == 0) { // check that rb was not used in this subframe
|
||||
nb_symb[rb]++;
|
||||
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
|
||||
int offset = offset0 + (s*frame_parms->ofdm_symbol_size);
|
||||
|
||||
@@ -123,7 +123,6 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
rel15->dlDmrsSymbPos);
|
||||
n_ptrs = (rel15->rbSize + rel15->PTRSFreqDensity - 1)/rel15->PTRSFreqDensity;
|
||||
}
|
||||
int16_t mod_ptrs[n_ptrs<<1] __attribute__ ((aligned(16)));
|
||||
|
||||
/// CRC, coding, interleaving and rate matching
|
||||
AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n");
|
||||
@@ -302,12 +301,14 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
|
||||
/* calculate if current symbol is PTRS symbols */
|
||||
ptrs_idx = 0;
|
||||
|
||||
int16_t *mod_ptrs = NULL;
|
||||
if(rel15->pduBitmap & 0x1) {
|
||||
ptrs_symbol = is_ptrs_symbol(l,dlPtrsSymPos);
|
||||
if(ptrs_symbol) {
|
||||
/* PTRS QPSK Modulation for each OFDM symbol in a slot */
|
||||
LOG_D(PHY,"Doing ptrs modulation for symbol %d, n_ptrs %d\n",l,n_ptrs);
|
||||
int16_t mod_ptrsBuf[n_ptrs<<1] __attribute__ ((aligned(16)));
|
||||
mod_ptrs =mod_ptrsBuf;
|
||||
nr_modulation(pdsch_dmrs[l][rel15->SCID], (n_ptrs<<1), DMRS_MOD_ORDER, mod_ptrs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
|
||||
LOG_D(PHY,"symbol %d Filling rb_mask_ul rb_size %d\n",symbol,ulsch_harq->ulsch_pdu.rb_size);
|
||||
for (rb=0; rb<ulsch_harq->ulsch_pdu.rb_size; rb++) {
|
||||
rb2 = rb+ulsch_harq->ulsch_pdu.rb_start+ulsch_harq->ulsch_pdu.bwp_start;
|
||||
gNB->rb_mask_ul[symbol][rb2>>5] |= (1<<(rb2&31));
|
||||
gNB->rb_mask_ul[symbol][rb2 >> 5] |= 1U << (rb2 & 31);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1321,8 +1321,7 @@ int is_ssb_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL_
|
||||
//uint8_t half_frame_index = fp->half_frame_bit;
|
||||
//uint8_t i_ssb = fp->ssb_index;
|
||||
uint8_t Lmax = fp->Lmax;
|
||||
|
||||
if (!(frame%(1<<(config->ssb_table.ssb_period-1)))){
|
||||
if ((config->ssb_table.ssb_period > 0) && !(frame % (1 << (config->ssb_table.ssb_period - 1)))) {
|
||||
|
||||
if(Lmax <= 8) {
|
||||
if(slot <=3 && (((config->ssb_table.ssb_mask_list[0].ssb_mask << 2*slot)&0x80000000) == 0x80000000 || ((config->ssb_table.ssb_mask_list[0].ssb_mask << (2*slot +1))&0x80000000) == 0x80000000))
|
||||
|
||||
@@ -512,12 +512,16 @@ int main(int argc, char **argv) {
|
||||
int re;
|
||||
int s,Kr,Kr_bytes;
|
||||
LTE_DL_FRAME_PARMS *frame_parms;
|
||||
double s_re0[30720*NB_ANTENNAS_TX],s_im0[30720*NB_ANTENNAS_TX],r_re0[30720*NB_ANTENNAS_RX],r_im0[30720*NB_ANTENNAS_RX];
|
||||
double s_re1[30720*NB_ANTENNAS_TX],s_im1[30720*NB_ANTENNAS_TX],r_re1[30720*NB_ANTENNAS_RX],r_im1[30720*NB_ANTENNAS_RX];
|
||||
double *s_re[NB_ANTENNAS_TX]= {s_re0,s_re1};
|
||||
double *s_im[NB_ANTENNAS_TX]= {s_im0,s_im1};
|
||||
double *r_re[NB_ANTENNAS_RX]= {r_re0,r_re1};
|
||||
double *r_im[NB_ANTENNAS_RX]= {r_im0,r_im1};
|
||||
double *tmpTX[4], *tmpRX[4] ;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
tmpTX[i] = malloc(30720 * NB_ANTENNAS_TX * sizeof(*tmpTX));
|
||||
tmpRX[i] = malloc(30720 * NB_ANTENNAS_RX * sizeof(*tmpRX));
|
||||
}
|
||||
double *s_re[NB_ANTENNAS_TX] = {tmpTX[0], tmpTX[1]};
|
||||
double *s_im[NB_ANTENNAS_TX] = {tmpTX[2], tmpTX[3]};
|
||||
double *r_re[NB_ANTENNAS_RX] = {tmpRX[0], tmpRX[1]};
|
||||
double *r_im[NB_ANTENNAS_RX] = {tmpRX[2], tmpRX[3]};
|
||||
|
||||
uint8_t transmission_mode=1,n_tx_port=1,n_tx_phy=1,n_rx=2;
|
||||
int eNB_id = 0;
|
||||
unsigned char round;
|
||||
|
||||
@@ -358,7 +358,7 @@ int main(int argc, char **argv) {
|
||||
unsigned short input_buffer_length;
|
||||
unsigned int ret;
|
||||
unsigned int coded_bits_per_codeword,nsymb;
|
||||
unsigned int tx_lev=0,tx_lev_dB=0,trials,errs[5]= {0,0,0,0,0},round_trials[4]= {0,0,0,0};
|
||||
unsigned int tx_lev = 0, tx_lev_dB = 0, trials, errs[6] = {0}, round_trials[4] = {0};
|
||||
FILE *bler_fd=NULL;
|
||||
char bler_fname[512];
|
||||
FILE *time_meas_fd=NULL;
|
||||
@@ -387,7 +387,6 @@ int main(int argc, char **argv) {
|
||||
double cpu_freq_GHz;
|
||||
int iter_trials;
|
||||
uint32_t UL_alloc_pdu;
|
||||
int s,Kr,Kr_bytes;
|
||||
int dump_perf=0;
|
||||
static int dump_table =0;
|
||||
double effective_rate=0.0;
|
||||
@@ -1233,20 +1232,21 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (n_frames==1) {
|
||||
printf("ULSCH errors found o_ACK[0]= %d\n",eNB->ulsch[0]->harq_processes[harq_pid]->o_ACK[0]);
|
||||
|
||||
#ifdef DUMP_EACH_VALUE
|
||||
int Kr_bytes;
|
||||
for (s=0; s<eNB->ulsch[0]->harq_processes[harq_pid]->C; s++) {
|
||||
if (s<eNB->ulsch[0]->harq_processes[harq_pid]->Cminus)
|
||||
Kr = eNB->ulsch[0]->harq_processes[harq_pid]->Kminus;
|
||||
Kr_bytes = eNB->ulsch[0]->harq_processes[harq_pid]->Kminus;
|
||||
else
|
||||
Kr = eNB->ulsch[0]->harq_processes[harq_pid]->Kplus;
|
||||
|
||||
Kr_bytes = Kr>>3;
|
||||
Kr_bytes = eNB->ulsch[0]->harq_processes[harq_pid]->Kplus;
|
||||
Kr_bytes = Kr_bytes >> 3;
|
||||
printf("Decoded_output (Segment %d):\n",s);
|
||||
|
||||
for (i=0; i<Kr_bytes; i++)
|
||||
printf("%d : %x (%x)\n",i,eNB->ulsch[0]->harq_processes[harq_pid]->c[s][i],
|
||||
eNB->ulsch[0]->harq_processes[harq_pid]->c[s][i]^UE->ulsch[0]->harq_processes[harq_pid]->c[s][i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
dump_ulsch(eNB,eNB->proc.frame_rx,subframe,0,round);
|
||||
round=5;
|
||||
|
||||
@@ -1142,7 +1142,7 @@ int main(int argc, char **argv)
|
||||
Sched_INFO.frame = frame;
|
||||
Sched_INFO.slot = slot;
|
||||
Sched_INFO.DL_req = &gNB_mac->DL_req[0];
|
||||
Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[slot];
|
||||
Sched_INFO.UL_tti_req = gNB_mac->UL_tti_req_ahead[0];
|
||||
Sched_INFO.UL_dci_req = NULL;
|
||||
Sched_INFO.TX_req = &gNB_mac->TX_req[0];
|
||||
pushNotifiedFIFO(gNB->L1_tx_free,msgL1Tx);
|
||||
|
||||
Reference in New Issue
Block a user