Commit 96ff859c authored by francescomani's avatar francescomani

shiftTooManyBitsSigned

parent 9cc53a43
...@@ -169,12 +169,18 @@ uint32_t nr_timer_elapsed_time(NR_timer_t timer); ...@@ -169,12 +169,18 @@ uint32_t nr_timer_elapsed_time(NR_timer_t timer);
extern const nr_bandentry_t nr_bandtable[]; extern const nr_bandentry_t nr_bandtable[];
static inline int get_num_dmrs(uint16_t dmrs_mask ) { static inline int get_num_dmrs(uint16_t dmrs_mask )
{
int num_dmrs=0; int num_dmrs=0;
for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1); for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1);
return(num_dmrs); return(num_dmrs);
} }
static __attribute__((always_inline)) inline int count_bits_set(uint64_t v)
{
return __builtin_popcountll(v);
}
uint64_t reverse_bits(uint64_t in, int n_bits); uint64_t reverse_bits(uint64_t in, int n_bits);
void reverse_bits_u8(uint8_t const* in, size_t sz, uint8_t* out); void reverse_bits_u8(uint8_t const* in, size_t sz, uint8_t* out);
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "common/utils/nr/nr_common.h" #include "common/utils/nr/nr_common.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h" #include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
......
...@@ -265,10 +265,10 @@ int nr_generate_pbch(nfapi_nr_dl_tti_ssb_pdu *ssb_pdu, ...@@ -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 pbch->pbch_a |= n_hf<<28; // half frame index bit
if (Lmax == 64) if (Lmax == 64)
for (int i=0; i<3; i++) 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 pbch->pbch_a |= (uint32_t)((ssb_index >> (5 - i)) & 1) << (29 + i); // resp. 6th, 5th and 4th bits of ssb_index
else 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); LOG_D(PHY,"After extra byte: pbch_a = 0x%08x\n",pbch->pbch_a);
......
...@@ -813,11 +813,6 @@ double interp(double x, double *xs, double *ys, int count); ...@@ -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_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); 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 #ifdef __cplusplus
} }
#endif #endif
......
...@@ -544,13 +544,14 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { ...@@ -544,13 +544,14 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
int rb2 = 0; int rb2 = 0;
int prbpos = 0; int prbpos = 0;
for (int symbol=0;symbol<14;symbol++) { for (int symbol = 0; symbol < 14; symbol++) {
for (int m=0;m<9;m++) { for (int m = 0; m < 9; m++) {
gNB->rb_mask_ul[symbol][m] = 0; gNB->rb_mask_ul[symbol][m] = 0;
for (int i=0;i<32;i++) { for (int i = 0; i < 32; i++) {
prbpos = (m*32)+i; prbpos = (m * 32) + i;
if (prbpos>gNB->frame_parms.N_RB_UL) break; if (prbpos>gNB->frame_parms.N_RB_UL)
gNB->rb_mask_ul[symbol][m] |= (gNB->ulprbbl[prbpos]>0 ? 1 : 0)<<i; break;
gNB->rb_mask_ul[symbol][m] |= (gNB->ulprbbl[prbpos] > 0 ? 1U : 0) << i;
} }
} }
} }
......
...@@ -25,28 +25,24 @@ ...@@ -25,28 +25,24 @@
#include "defs.h" #include "defs.h"
unsigned int *generate_gauss_LUT(unsigned char Nbits, unsigned int *generate_gauss_LUT(unsigned char Nbits, unsigned char L)
unsigned char L {
) { unsigned int *LUT_ptr = calloc((1U << (Nbits - 1)), sizeof(int));
unsigned int *LUT_ptr,i;
LUT_ptr = (unsigned int *)malloc((1<<(Nbits-1))*sizeof(int));
assert(LUT_ptr); assert(LUT_ptr);
for (i=0; i<(1<<(Nbits-1)); i++) { for (int i = 0; i < (1 << (Nbits - 1)); i++) {
LUT_ptr[i] = (unsigned int)((double)((unsigned int)(1<<31))*erf(i*L/(double)(1<<(Nbits-1)))); LUT_ptr[i] = (unsigned int)((double)((unsigned int)(1U << 31)) * erf(i * L / (double)(1 << (Nbits - 1))));
#ifdef LUTDEBUG #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 #endif //LUTDEBUG
} }
return(LUT_ptr); return(LUT_ptr);
} }
int gauss(unsigned int *gauss_LUT, int gauss(unsigned int *gauss_LUT, unsigned char Nbits)
unsigned char Nbits {
) {
unsigned int search_pos,step_size,u,tmp,tmpm1,tmpp1,s; unsigned int search_pos,step_size,u,tmp,tmpm1,tmpp1,s;
// Get a 32-bit uniform random-variable // Get a 32-bit uniform random-variable
u = taus(); u = taus();
...@@ -127,8 +123,10 @@ void main(int argc,char **argv) { ...@@ -127,8 +123,10 @@ void main(int argc,char **argv) {
// printf("%d\n",gauss(gauss_LUT_ptr,Nbits)); // 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("Tail probability = %e(%x)\n",
printf("max %d, min %d, mean %f, stddev %f, Pr(maxnum)=%e(%d)\n",maxg,ming,meang,sqrt(varg),(double)maxnum/Ntrials,maxnum); 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++) // for (i=0;i<(1<<Nhistbits);i++)
// printf("%d : %u\n",i,hist[i]); // printf("%d : %u\n",i,hist[i]);
free(gauss_LUT_ptr); free(gauss_LUT_ptr);
......
...@@ -1686,19 +1686,15 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, ...@@ -1686,19 +1686,15 @@ int get_nr_prach_occasion_info_from_index(uint8_t index,
uint8_t *N_dur, uint8_t *N_dur,
uint8_t *N_RA_slot, uint8_t *N_RA_slot,
uint16_t *N_RA_sfn, uint16_t *N_RA_sfn,
uint8_t *max_association_period) { uint8_t *max_association_period)
{
int x; int x;
int64_t s_map; uint64_t s_map;
uint8_t format2 = 0xff; uint8_t format2 = 0xff;
if (pointa > 2016666) { //FR2 if (pointa > 2016666) { //FR2
x = table_6_3_3_2_4_prachConfig_Index[index][2]; x = table_6_3_3_2_4_prachConfig_Index[index][2];
s_map = table_6_3_3_2_4_prachConfig_Index[index][5]; s_map = table_6_3_3_2_4_prachConfig_Index[index][5];
for(int i = 0; i < 64 ;i++) { *N_RA_sfn += count_bits_set(s_map);
if ( (s_map >> i) & 0x01) {
(*N_RA_sfn)++;
}
}
*N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; // Number of RACH slots within a subframe *N_RA_slot = table_6_3_3_2_4_prachConfig_Index[index][7]; // Number of RACH slots within a subframe
*max_association_period = 160/(x * 10); *max_association_period = 160/(x * 10);
if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
...@@ -1722,15 +1718,10 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, ...@@ -1722,15 +1718,10 @@ int get_nr_prach_occasion_info_from_index(uint8_t index,
return 1; return 1;
} }
else { else {
if (unpaired) { if (unpaired) {
x = table_6_3_3_2_3_prachConfig_Index[index][2]; x = table_6_3_3_2_3_prachConfig_Index[index][2];
s_map = table_6_3_3_2_3_prachConfig_Index[index][4]; s_map = table_6_3_3_2_3_prachConfig_Index[index][4];
for(int i = 0; i < 64 ;i++) { *N_RA_sfn += count_bits_set(s_map);
if ( (s_map >> i) & 0x01) {
(*N_RA_sfn)++;
}
}
*N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe *N_RA_slot = table_6_3_3_2_3_prachConfig_Index[index][6]; // Number of RACH slots within a subframe
*max_association_period = 160/(x * 10); *max_association_period = 160/(x * 10);
if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
...@@ -1755,11 +1746,7 @@ int get_nr_prach_occasion_info_from_index(uint8_t index, ...@@ -1755,11 +1746,7 @@ int get_nr_prach_occasion_info_from_index(uint8_t index,
else { // FDD else { // FDD
x = table_6_3_3_2_2_prachConfig_Index[index][2]; x = table_6_3_3_2_2_prachConfig_Index[index][2];
s_map = table_6_3_3_2_2_prachConfig_Index[index][4]; s_map = table_6_3_3_2_2_prachConfig_Index[index][4];
for(int i = 0; i < 64 ; i++) { *N_RA_sfn += count_bits_set(s_map);
if ( (s_map >> i) & 0x01) {
(*N_RA_sfn)++;
}
}
*N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6]; *N_RA_slot = table_6_3_3_2_2_prachConfig_Index[index][6];
if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){ if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
*start_symbol = table_6_3_3_2_2_prachConfig_Index[index][5]; *start_symbol = table_6_3_3_2_2_prachConfig_Index[index][5];
......
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