shiftTooManyBitsSigned

This commit is contained in:
francescomani
2024-04-09 16:53:12 +02:00
parent 9cc53a43b1
commit 96ff859cb7
7 changed files with 47 additions and 61 deletions
@@ -32,7 +32,6 @@
#include "common/utils/nr/nr_common.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
+3 -3
View File
@@ -265,10 +265,10 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu,
pbch->pbch_a |= n_hf<<28; // half frame index bit
if (Lmax == 64)
for (int i=0; i<3; i++)
pbch->pbch_a |= ((ssb_index>>(5-i))&1)<<(29+i); // resp. 6th, 5th and 4th bits of ssb_index
for (int i = 0; i < 3; i++)
pbch->pbch_a |= (uint32_t)((ssb_index >> (5 - i)) & 1) << (29 + i); // resp. 6th, 5th and 4th bits of ssb_index
else
pbch->pbch_a |= ((ssb_sc_offset>>4)&1)<<29; //MSB of k_SSB (bit index 4)
pbch->pbch_a |= ((ssb_sc_offset >> 4) & 1) << 29; //MSB of k_SSB (bit index 4)
LOG_D(PHY,"After extra byte: pbch_a = 0x%08x\n",pbch->pbch_a);
-5
View File
@@ -813,11 +813,6 @@ double interp(double x, double *xs, double *ys, int count);
void simde_mm128_separate_real_imag_parts(simde__m128i *out_re, simde__m128i *out_im, simde__m128i in0, simde__m128i in1);
void simde_mm256_separate_real_imag_parts(simde__m256i *out_re, simde__m256i *out_im, simde__m256i in0, simde__m256i in1);
static __attribute__((always_inline)) inline int count_bits_set(uint64_t v)
{
return __builtin_popcountll(v);
}
#ifdef __cplusplus
}
#endif
+7 -6
View File
@@ -544,13 +544,14 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
int rb2 = 0;
int prbpos = 0;
for (int symbol=0;symbol<14;symbol++) {
for (int m=0;m<9;m++) {
for (int symbol = 0; symbol < 14; symbol++) {
for (int m = 0; m < 9; m++) {
gNB->rb_mask_ul[symbol][m] = 0;
for (int i=0;i<32;i++) {
prbpos = (m*32)+i;
if (prbpos>gNB->frame_parms.N_RB_UL) break;
gNB->rb_mask_ul[symbol][m] |= (gNB->ulprbbl[prbpos]>0 ? 1 : 0)<<i;
for (int i = 0; i < 32; i++) {
prbpos = (m * 32) + i;
if (prbpos>gNB->frame_parms.N_RB_UL)
break;
gNB->rb_mask_ul[symbol][m] |= (gNB->ulprbbl[prbpos] > 0 ? 1U : 0) << i;
}
}
}
+12 -14
View File
@@ -25,28 +25,24 @@
#include "defs.h"
unsigned int *generate_gauss_LUT(unsigned char Nbits,
unsigned char L
) {
unsigned int *LUT_ptr,i;
LUT_ptr = (unsigned int *)malloc((1<<(Nbits-1))*sizeof(int));
unsigned int *generate_gauss_LUT(unsigned char Nbits, unsigned char L)
{
unsigned int *LUT_ptr = calloc((1U << (Nbits - 1)), sizeof(int));
assert(LUT_ptr);
for (i=0; i<(1<<(Nbits-1)); i++) {
LUT_ptr[i] = (unsigned int)((double)((unsigned int)(1<<31))*erf(i*L/(double)(1<<(Nbits-1))));
for (int i = 0; i < (1 << (Nbits - 1)); i++) {
LUT_ptr[i] = (unsigned int)((double)((unsigned int)(1U << 31)) * erf(i * L / (double)(1 << (Nbits - 1))));
#ifdef LUTDEBUG
printf("pos %u : LUT_ptr[%u]=%x (%f)\n",i,i,LUT_ptr[i],(double)(erf(i*L/(double)(1<<(Nbits-1)))));
printf("pos %d : LUT_ptr[%d]=%x (%f)\n", i, i, LUT_ptr[i], (double)(erf(i * L / (double)(1 << (Nbits -1 )))));
#endif //LUTDEBUG
}
return(LUT_ptr);
}
int gauss(unsigned int *gauss_LUT,
unsigned char Nbits
) {
int gauss(unsigned int *gauss_LUT, unsigned char Nbits)
{
unsigned int search_pos,step_size,u,tmp,tmpm1,tmpp1,s;
// Get a 32-bit uniform random-variable
u = taus();
@@ -127,8 +123,10 @@ void main(int argc,char **argv) {
// printf("%d\n",gauss(gauss_LUT_ptr,Nbits));
}
printf("Tail probability = %e(%x)\n",2*erfc((double)L*gauss_LUT_ptr[(1<<(Nbits-1))-1]/(unsigned int)(1<<31)),gauss_LUT_ptr[(1<<(Nbits-1))-1]);
printf("max %d, min %d, mean %f, stddev %f, Pr(maxnum)=%e(%d)\n",maxg,ming,meang,sqrt(varg),(double)maxnum/Ntrials,maxnum);
printf("Tail probability = %e(%x)\n",
2 * erfc((double)L * gauss_LUT_ptr[(1U << (Nbits - 1)) - 1] / (unsigned int)(1U << 31)),
gauss_LUT_ptr[(1U << (Nbits - 1)) - 1]);
printf("max %d, min %d, mean %f, stddev %f, Pr(maxnum)=%e(%d)\n", maxg, ming, meang, sqrt(varg), (double)maxnum / Ntrials, maxnum);
// for (i=0;i<(1<<Nhistbits);i++)
// printf("%d : %u\n",i,hist[i]);
free(gauss_LUT_ptr);