From 55295b31a7e2765d934d238e9530342a7ffec602 Mon Sep 17 00:00:00 2001 From: Balaji Shankaran Date: Mon, 13 Jul 2020 12:21:53 +0530 Subject: [PATCH] To Calculate Set Bits from Msb for FreqDomain Allocation JIRA ID: ODUHIGH-192 Change-Id: If9c238bbd728e5cc812893302607e690b92d1554 Signed-off-by: Balaji Shankaran --- src/5gnrsch/sch_utils.c | 8 ++++---- src/5gnrsch/sch_utils.h | 13 ++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/5gnrsch/sch_utils.c b/src/5gnrsch/sch_utils.c index 1397c65d8..1f0035a25 100644 --- a/src/5gnrsch/sch_utils.c +++ b/src/5gnrsch/sch_utils.c @@ -448,7 +448,7 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD { uint8_t remBits = prbSize; /* each bit represents 6 PRBs */ uint8_t firstByte = 1; - uint8_t numBits,startBit,byteCount = 0; + uint8_t numBits,startBit,byteCount = 5; while(remBits) { @@ -456,7 +456,7 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD if(startPrb/8) { startPrb -= 8; - byteCount++; + byteCount--; continue; } @@ -477,12 +477,12 @@ void schAllocFreqDomRscType0(uint16_t startPrb, uint16_t prbSize, uint8_t *freqD numBits = 8 - startBit; /* bit operation to set the bits */ - SET_BITS((startBit % 8),numBits,freqDomain[byteCount]) + SET_BITS_MSB((startBit % 8),numBits,freqDomain[byteCount]) firstByte = 0; /* the ramaining bits should be subtracted with the numBits set in this byte */ remBits -= numBits; - byteCount++; + byteCount--; } } diff --git a/src/5gnrsch/sch_utils.h b/src/5gnrsch/sch_utils.h index b4a3acb88..ec7d0e0d2 100644 --- a/src/5gnrsch/sch_utils.h +++ b/src/5gnrsch/sch_utils.h @@ -25,9 +25,16 @@ #define MAX_PRACH_CONFIG_IDX 256 #define MAX_MU_PUSCH 4 #define TOTAL_TBSIZE_VALUES 93 -#define SET_BITS(_startBit, _numBits, _byte) \ -{ \ - _byte = (((~((~0)<<_numBits))<<_startBit)); \ +#define SET_BITS_MSB(_startBit, _numBits, _byte) \ +{ \ + _byte = (~((0xFF) >> _numBits)); \ + _byte >>= _startBit; \ +} + +#define SET_BITS_LSB(_startBit, _numBits, _byte) \ +{ \ + _byte = (~((0xFF) << _numBits)); \ + _byte <<= _startBit; \ } /* functions declarations */ -- 2.16.6