Commit 4c3d8e75 authored by Laurent THOMAS's avatar Laurent THOMAS

fix-mem-overflow_64qam

fix the 64QAM modulator case, that process 192 bits per iteration, then 24 bits per iteration of the tail bits, then added the last two symboles processing (no odd number of symbols case)
parent 464a62dd
...@@ -121,10 +121,7 @@ void nr_modulation(uint32_t *in, ...@@ -121,10 +121,7 @@ void nr_modulation(uint32_t *in,
uint8_t* in_bytes = (uint8_t*) in; uint8_t* in_bytes = (uint8_t*) in;
uint64_t* in64 = (uint64_t*) in; uint64_t* in64 = (uint64_t*) in;
int64_t* out64 = (int64_t*) out; int64_t* out64 = (int64_t*) out;
uint8_t idx; uint32_t i;
uint32_t i,j;
uint32_t bit_cnt;
uint64_t x,x1,x2;
#if defined(__SSE2__) #if defined(__SSE2__)
__m128i *nr_mod_table128; __m128i *nr_mod_table128;
...@@ -145,7 +142,7 @@ void nr_modulation(uint32_t *in, ...@@ -145,7 +142,7 @@ void nr_modulation(uint32_t *in,
i = i*8/2; i = i*8/2;
nr_mod_table32 = (int32_t*) nr_qpsk_mod_table; nr_mod_table32 = (int32_t*) nr_qpsk_mod_table;
while (i<length/2) { while (i<length/2) {
idx = ((in_bytes[(i*2)/8]>>((i*2)&0x7)) & mask); const int idx = ((in_bytes[(i * 2) / 8] >> ((i * 2) & 0x7)) & mask);
out32[i] = nr_mod_table32[idx]; out32[i] = nr_mod_table32[idx];
i++; i++;
} }
...@@ -154,7 +151,7 @@ void nr_modulation(uint32_t *in, ...@@ -154,7 +151,7 @@ void nr_modulation(uint32_t *in,
case 2: case 2:
nr_mod_table32 = (int32_t*) nr_qpsk_mod_table; nr_mod_table32 = (int32_t*) nr_qpsk_mod_table;
for (i=0; i<length/mod_order; i++) { for (i=0; i<length/mod_order; i++) {
idx = ((in[i*2/32]>>((i*2)&0x1f)) & mask); const int idx = ((in[i * 2 / 32] >> ((i * 2) & 0x1f)) & mask);
out32[i] = nr_mod_table32[idx]; out32[i] = nr_mod_table32[idx];
} }
return; return;
...@@ -167,66 +164,68 @@ void nr_modulation(uint32_t *in, ...@@ -167,66 +164,68 @@ void nr_modulation(uint32_t *in,
// the bits that are left out // the bits that are left out
i = i*8/4; i = i*8/4;
while (i<length/4) { while (i<length/4) {
idx = ((in_bytes[(i*4)/8]>>((i*4)&0x7)) & mask); const int idx = ((in_bytes[(i * 4) / 8] >> ((i * 4) & 0x7)) & mask);
out32[i] = nr_16qam_mod_table[idx]; out32[i] = nr_16qam_mod_table[idx];
i++; i++;
} }
return; return;
case 6: case 6:
j = 0; for (i = 0; i < length - 3 * 64; i += 3 * 64) {
for (i=0; i<length/192; i++) { uint64_t x = *in64++;
x = in64[i*3]; uint64_t x1 = x & 0xfff;
x1 = x&4095; *out64++ = nr_64qam_mod_table[x1];
out64[j++] = nr_64qam_mod_table[x1]; x1 = (x >> 12) & 0xfff;
x1 = (x>>12)&4095; *out64++ = nr_64qam_mod_table[x1];
out64[j++] = nr_64qam_mod_table[x1]; x1 = (x >> 24) & 0xfff;
x1 = (x>>24)&4095; *out64++ = nr_64qam_mod_table[x1];
out64[j++] = nr_64qam_mod_table[x1]; x1 = (x >> 36) & 0xfff;
x1 = (x>>36)&4095; *out64++ = nr_64qam_mod_table[x1];
out64[j++] = nr_64qam_mod_table[x1]; x1 = (x >> 48) & 0xfff;
x1 = (x>>48)&4095; *out64++ = nr_64qam_mod_table[x1];
out64[j++] = nr_64qam_mod_table[x1]; uint64_t x2 = (x >> 60);
x2 = (x>>60); x = *in64++;
x = in64[i*3+1];
x2 |= x<<4; x2 |= x<<4;
x1 = x2&4095; x1 = x2 & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>12)&4095; x1 = (x2 >> 12) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>24)&4095; x1 = (x2 >> 24) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>36)&4095; x1 = (x2 >> 36) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>48)&4095; x1 = (x2 >> 48) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x2 = ((x>>56)&0xf0) | (x2>>60); x2 = ((x>>56)&0xf0) | (x2>>60);
x = in64[i*3+2]; x = *in64++;
x2 |= x<<8; x2 |= x<<8;
x1 = x2&4095; x1 = x2 & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>12)&4095; x1 = (x2 >> 12) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>24)&4095; x1 = (x2 >> 24) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>36)&4095; x1 = (x2 >> 36) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (x2>>48)&4095; x1 = (x2 >> 48) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x2 = ((x>>52)&0xff0) | (x2>>60); x2 = ((x>>52)&0xff0) | (x2>>60);
out64[j++] = nr_64qam_mod_table[x2]; *out64++ = nr_64qam_mod_table[x2];
} }
i *= 24; while (i + 24 <= length) {
bit_cnt = i * 8; uint32_t xx = 0;
while (bit_cnt < length) { memcpy(&xx, in_bytes + i / 8, 3);
uint32_t xx; uint64_t x1 = xx & 0xfff;
memcpy(&xx, in_bytes+i, sizeof(xx)); *out64++ = nr_64qam_mod_table[x1];
x1 = xx & 4095; x1 = (xx >> 12) & 0xfff;
out64[j++] = nr_64qam_mod_table[x1]; *out64++ = nr_64qam_mod_table[x1];
x1 = (xx >> 12) & 4095; i += 24;
out64[j++] = nr_64qam_mod_table[x1]; }
i += 3; if (i != length) {
bit_cnt += 24; uint32_t xx = 0;
memcpy(&xx, in_bytes + i / 8, 2);
uint64_t x1 = xx & 0xfff;
*out64++ = nr_64qam_mod_table[x1];
} }
return; return;
......
...@@ -184,8 +184,9 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -184,8 +184,9 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////// ///////////
uint32_t available_bits = G; uint32_t available_bits = G;
uint32_t scrambled_output[(available_bits>>5)+1]; // +1 because size can be not modulo 4
memset(scrambled_output, 0, ((available_bits>>5)+1)*sizeof(uint32_t)); uint32_t scrambled_output[available_bits / (8 * sizeof(uint32_t)) + 1];
memset(scrambled_output, 0, sizeof(scrambled_output));
nr_pusch_codeword_scrambling(harq_process_ul_ue->f, nr_pusch_codeword_scrambling(harq_process_ul_ue->f,
available_bits, available_bits,
......
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