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);
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;
for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1);
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);
void reverse_bits_u8(uint8_t const* in, size_t sz, uint8_t* out);
......
......@@ -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>
......
......@@ -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);
......
......@@ -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
......
......@@ -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;
}
}
}
......
......@@ -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);
......
......@@ -1677,28 +1677,24 @@ void set_monitoring_periodicity_offset(NR_SearchSpace_t *ss,
int get_nr_prach_occasion_info_from_index(uint8_t index,
uint32_t pointa,
uint8_t mu,
uint8_t unpaired,
uint16_t *format,
uint8_t *start_symbol,
uint8_t *N_t_slot,
uint8_t *N_dur,
uint8_t *N_RA_slot,
uint16_t *N_RA_sfn,
uint8_t *max_association_period) {
uint32_t pointa,
uint8_t mu,
uint8_t unpaired,
uint16_t *format,
uint8_t *start_symbol,
uint8_t *N_t_slot,
uint8_t *N_dur,
uint8_t *N_RA_slot,
uint16_t *N_RA_sfn,
uint8_t *max_association_period)
{
int x;
int64_t s_map;
uint64_t s_map;
uint8_t format2 = 0xff;
if (pointa > 2016666) { //FR2
x = table_6_3_3_2_4_prachConfig_Index[index][2];
s_map = table_6_3_3_2_4_prachConfig_Index[index][5];
for(int i = 0; i < 64 ;i++) {
if ( (s_map >> i) & 0x01) {
(*N_RA_sfn)++;
}
}
*N_RA_sfn += count_bits_set(s_map);
*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);
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,
return 1;
}
else {
if (unpaired) {
x = table_6_3_3_2_3_prachConfig_Index[index][2];
s_map = table_6_3_3_2_3_prachConfig_Index[index][4];
for(int i = 0; i < 64 ;i++) {
if ( (s_map >> i) & 0x01) {
(*N_RA_sfn)++;
}
}
*N_RA_sfn += count_bits_set(s_map);
*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);
if (start_symbol != NULL && N_t_slot != NULL && N_dur != NULL && format != NULL){
......@@ -1748,18 +1739,14 @@ int get_nr_prach_occasion_info_from_index(uint8_t index,
*start_symbol,
*N_t_slot,
*N_dur,
*N_RA_sfn);
*N_RA_sfn);
}
return 1;
}
return 1;
}
else { // FDD
x = table_6_3_3_2_2_prachConfig_Index[index][2];
s_map = table_6_3_3_2_2_prachConfig_Index[index][4];
for(int i = 0; i < 64 ; i++) {
if ( (s_map >> i) & 0x01) {
(*N_RA_sfn)++;
}
}
*N_RA_sfn += count_bits_set(s_map);
*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){
*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