Merge branch 'bler_txoptim' into F1C_extensions_develop
Conflicts: cmake_targets/CMakeLists.txt common/utils/nr/nr_common.c openair1/PHY/INIT/nr_parms.c openair1/PHY/NR_TRANSPORT/pucch_rx.c openair1/PHY/NR_UE_TRANSPORT/dci_nr.c openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c openair1/SCHED_NR/fapi_nr_l1.c openair1/SCHED_NR/phy_procedures_nr_gNB.c openair1/SCHED_NR_UE/phy_procedures_nr_ue.c openair1/SIMULATION/NR_PHY/dlschsim.c openair1/SIMULATION/NR_PHY/dlsim.c openair2/GNB_APP/gnb_config.c openair2/LAYER2/NR_MAC_UE/config_ue.c openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c openair2/LAYER2/NR_MAC_gNB/main.c openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c openair2/RRC/NR/L2_nr_interface.c openair2/RRC/NR/MESSAGES/asn1_msg.c openair2/RRC/NR/MESSAGES/asn1_msg.h openair2/RRC/NR/rrc_gNB_NGAP.c openair3/NAS/NR_UE/nr_nas_msg_sim.c openair3/NAS/NR_UE/nr_nas_msg_sim.h openair3/ocp-gtpu/gtp_itf.cpp targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf
This commit is contained in:
@@ -0,0 +1,541 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2009-2018, Intel Corporation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* Header file for module with CRC computation methods
|
||||
*
|
||||
* PCLMULQDQ implementation is based on work by:
|
||||
* Erdinc Ozturk
|
||||
* Vinodh Gopal
|
||||
* James Guilford
|
||||
*
|
||||
* "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
|
||||
* URL: http://download.intel.com/design/intarch/papers/323102.pdf
|
||||
*/
|
||||
|
||||
#ifndef __CRC_H__
|
||||
#define __CRC_H__
|
||||
|
||||
#include <x86intrin.h>
|
||||
|
||||
#include "crcext.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* PCLMULQDQ CRC computation context structure
|
||||
*/
|
||||
struct crc_pclmulqdq_ctx {
|
||||
/**
|
||||
* K1 = reminder X^128 / P(X) : 0-63
|
||||
* K2 = reminder X^192 / P(X) : 64-127
|
||||
*/
|
||||
uint64_t k1;
|
||||
uint64_t k2;
|
||||
|
||||
/**
|
||||
* K3 = reminder X^64 / P(X) : 0-63
|
||||
* q = quotient X^64 / P(X) : 64-127
|
||||
*/
|
||||
uint64_t k3;
|
||||
uint64_t q;
|
||||
|
||||
/**
|
||||
* p = polynomial / P(X) : 0-63
|
||||
* res = reserved : 64-127
|
||||
*/
|
||||
uint64_t p;
|
||||
uint64_t res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions and prototypes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes look-up-table (LUT) for given 8 bit polynomial
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param lut pointer to look-up-table to be initialized
|
||||
*/
|
||||
void crc8_init_lut(const uint8_t poly, uint8_t *lut);
|
||||
|
||||
/**
|
||||
* @brief Calculates 8 bit CRC using LUT method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param lut 256x8bits look-up-table pointer
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint8_t crc8_calc_lut(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint8_t crc,
|
||||
const uint8_t *lut)
|
||||
{
|
||||
if (unlikely(data == NULL || lut == NULL))
|
||||
return crc;
|
||||
|
||||
while (data_len--)
|
||||
crc = lut[*data++ ^ crc];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look-up-table (LUT) for given 16 bit polynomial
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param lut pointer to 256x16bits look-up-table to be initialized
|
||||
*/
|
||||
void crc16_init_lut(const uint16_t poly, uint16_t *lut);
|
||||
|
||||
/**
|
||||
* @brief Calculates 16 bit CRC using LUT method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param lut 256x16bits look-up-table pointer
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint16_t crc16_calc_lut(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint16_t crc,
|
||||
const uint16_t *lut)
|
||||
{
|
||||
if (unlikely(data == NULL || lut == NULL))
|
||||
return crc;
|
||||
|
||||
while (data_len--)
|
||||
crc = lut[(crc >> 8) ^ *data++] ^ (crc << 8);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look-up-table (LUT) for given 32 bit polynomial
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param lut pointer to 256x32bits look-up-table to be initialized
|
||||
*/
|
||||
void crc32_init_lut(const uint32_t poly, uint32_t *lut);
|
||||
|
||||
/**
|
||||
* @brief Calculates 32 bit CRC using LUT method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param lut 256x32bits look-up-table pointer
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t crc32_calc_lut(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint32_t crc,
|
||||
const uint32_t *lut)
|
||||
{
|
||||
if (unlikely(data == NULL || lut == NULL))
|
||||
return crc;
|
||||
|
||||
while (data_len--)
|
||||
crc = lut[(crc >> 24) ^ *data++] ^ (crc << 8);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look up tables for slice-By-2 method.
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param slice1 slice-by-2 look-up-table 1
|
||||
* @param slice2 slice-by-2 look-up-table 2
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
void crc16_init_slice2(const uint16_t poly,
|
||||
uint16_t *slice1,
|
||||
uint16_t *slice2);
|
||||
|
||||
/**
|
||||
* @brief Calculates 16 bit CRC using Slice-By-2 method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param slice1 256x16bits slice look-up-table 1
|
||||
* @param slice2 256x16bits slice look-up-table 2
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint16_t crc16_calc_slice2(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint16_t crc,
|
||||
const uint16_t *slice1,
|
||||
const uint16_t *slice2)
|
||||
{
|
||||
uint_fast32_t i;
|
||||
|
||||
if (unlikely(data == NULL))
|
||||
return crc;
|
||||
|
||||
if (unlikely(slice1 == NULL || slice2 == NULL))
|
||||
return crc;
|
||||
|
||||
crc = bswap2(crc);
|
||||
for (i = (data_len & (~1)), data += (data_len & (~1)); i != 0;
|
||||
i -= sizeof(uint16_t)) {
|
||||
crc ^= (*((const uint16_t *)(data - i)));
|
||||
crc = slice2[(uint8_t)crc] ^ slice1[(uint8_t)(crc >> 8)];
|
||||
}
|
||||
crc = bswap2(crc);
|
||||
if (data_len & 1)
|
||||
crc = (crc << 8) ^ bswap2(slice1[(crc >> 8) ^ *data]);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look up tables for slice-By-4 method.
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param slice1 256x32bits slice look-up-table 1
|
||||
* @param slice2 256x32bits slice look-up-table 2
|
||||
* @param slice3 256x32bits slice look-up-table 3
|
||||
* @param slice4 256x32bits slice look-up-table 4
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
void crc32_init_slice4(const uint32_t poly,
|
||||
uint32_t *slice1, uint32_t *slice2,
|
||||
uint32_t *slice3, uint32_t *slice4);
|
||||
|
||||
/**
|
||||
* @brief Calculates 32 bit CRC using Slice-By-4 method.
|
||||
*
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param crc CRC initial value
|
||||
* @param slice1 256x32bits slice look-up-table 1
|
||||
* @param slice2 256x32bits slice look-up-table 2
|
||||
* @param slice3 256x32bits slice look-up-table 3
|
||||
* @param slice4 256x32bits slice look-up-table 4
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t crc32_calc_slice4(const uint8_t *data,
|
||||
uint32_t data_len, uint32_t crc,
|
||||
const uint32_t *slice1, const uint32_t *slice2,
|
||||
const uint32_t *slice3, const uint32_t *slice4)
|
||||
{
|
||||
uint_fast32_t i;
|
||||
|
||||
if (unlikely(data == NULL))
|
||||
return crc;
|
||||
|
||||
if (unlikely(slice1 == NULL || slice2 == NULL ||
|
||||
slice3 == NULL || slice4 == NULL))
|
||||
return crc;
|
||||
|
||||
crc = bswap4(crc);
|
||||
for (i = data_len & (~3), data += (data_len & (~3)); i != 0;
|
||||
i -= sizeof(uint32_t)) {
|
||||
crc ^= (*((const uint32_t *)(data - i)));
|
||||
crc = slice4[(uint8_t)(crc)] ^
|
||||
slice3[(uint8_t)(crc >> 8)] ^
|
||||
slice2[(uint8_t)(crc >> 16)] ^
|
||||
slice1[(uint8_t)(crc >> 24)];
|
||||
}
|
||||
crc = bswap4(crc);
|
||||
for (i = data_len & 3, data += (data_len & 3); i != 0; i--)
|
||||
crc = (crc << 8) ^
|
||||
bswap4(slice1[(crc >> 24) ^ *(data - i)]);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs one folding round
|
||||
*
|
||||
* Logically function operates as follows:
|
||||
* DATA = READ_NEXT_16BYTES();
|
||||
* F1 = LSB8(FOLD)
|
||||
* F2 = MSB8(FOLD)
|
||||
* T1 = CLMUL( F1, K1 )
|
||||
* T2 = CLMUL( F2, K2 )
|
||||
* FOLD = XOR( T1, T2, DATA )
|
||||
*
|
||||
* @param data_block 16 byte data block
|
||||
* @param k1_k2 k1 and k2 constanst enclosed in XMM register
|
||||
* @param fold running 16 byte folded data
|
||||
*
|
||||
* @return New 16 byte folded data
|
||||
*/
|
||||
__forceinline
|
||||
__m128i crc32_folding_round(const __m128i data_block,
|
||||
const __m128i k1_k2,
|
||||
const __m128i fold)
|
||||
{
|
||||
__m128i tmp = _mm_clmulepi64_si128(fold, k1_k2, 0x11);
|
||||
|
||||
return _mm_xor_si128(_mm_clmulepi64_si128(fold, k1_k2, 0x00),
|
||||
_mm_xor_si128(data_block, tmp));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs Barret's reduction from 128 bits to 64 bits
|
||||
*
|
||||
* @param data128 128 bits data to be reduced
|
||||
* @param k3_q k3 and Q constants enclosed in XMM register
|
||||
*
|
||||
* @return data reduced to 64 bits
|
||||
*/
|
||||
__forceinline
|
||||
__m128i crc32_reduce_128_to_64(__m128i data128, const __m128i k3_q)
|
||||
{
|
||||
__m128i tmp;
|
||||
|
||||
tmp = _mm_xor_si128(_mm_clmulepi64_si128(data128, k3_q, 0x01 /* k3 */),
|
||||
data128);
|
||||
|
||||
data128 = _mm_xor_si128(_mm_clmulepi64_si128(tmp, k3_q, 0x01 /* k3 */),
|
||||
data128);
|
||||
|
||||
return _mm_srli_si128(_mm_slli_si128(data128, 8), 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs Barret's reduction from 64 bits to 32 bits
|
||||
*
|
||||
* @param data64 64 bits data to be reduced
|
||||
* @param k3_q k3 and Q constants enclosed in XMM register
|
||||
* @param p_res P constant enclosed in XMM register
|
||||
*
|
||||
* @return data reduced to 32 bits
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t
|
||||
crc32_reduce_64_to_32(__m128i fold, const __m128i k3_q, const __m128i p_res)
|
||||
{
|
||||
__m128i temp;
|
||||
|
||||
temp = _mm_clmulepi64_si128(_mm_srli_si128(fold, 4),
|
||||
k3_q, 0x10 /* Q */);
|
||||
temp = _mm_srli_si128(_mm_xor_si128(temp, fold), 4);
|
||||
temp = _mm_clmulepi64_si128(temp, p_res, 0 /* P */);
|
||||
return _mm_extract_epi32(_mm_xor_si128(temp, fold), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates 32 bit CRC for given \a data block by applying folding and
|
||||
* reduction methods.
|
||||
*
|
||||
* Algorithm operates on 32 bit CRCs so polynomials and initial values may
|
||||
* need to be promoted to 32 bits where required.
|
||||
*
|
||||
* @param crc initial CRC value (32 bit value)
|
||||
* @param data pointer to data block
|
||||
* @param data_len length of \a data block in bytes
|
||||
* @param params pointer to PCLMULQDQ CRC calculation context
|
||||
*
|
||||
* @return CRC for given \a data block (32 bits wide).
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t
|
||||
crc32_calc_pclmulqdq(const uint8_t *data,
|
||||
uint32_t data_len, uint32_t crc,
|
||||
const struct crc_pclmulqdq_ctx *params)
|
||||
{
|
||||
__m128i temp, fold, k, swap;
|
||||
uint32_t n;
|
||||
|
||||
if (unlikely(data == NULL || data_len == 0 || params == NULL))
|
||||
return crc;
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/**
|
||||
* Preserve FPU context
|
||||
*/
|
||||
kernel_fpu_begin();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add 4 bytes to data block size
|
||||
* This is to secure the following:
|
||||
* CRC32 = M(X)^32 mod P(X)
|
||||
* M(X) - message to compute CRC on
|
||||
* P(X) - CRC polynomial
|
||||
*/
|
||||
data_len += 4;
|
||||
|
||||
/**
|
||||
* Load first 16 data bytes in \a fold and
|
||||
* set \a swap BE<->LE 16 byte conversion variable
|
||||
*/
|
||||
fold = _mm_loadu_si128((__m128i *)data);
|
||||
swap = crc_xmm_be_le_swap128;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------
|
||||
* Folding all data into single 16 byte data block
|
||||
* Assumes: \a fold holds first 16 bytes of data
|
||||
*/
|
||||
|
||||
if (unlikely(data_len <= 16)) {
|
||||
/**
|
||||
* Data block fits into 16 byte block
|
||||
* - adjust data block
|
||||
* - 4 least significant bytes need to be zero
|
||||
*/
|
||||
fold = _mm_shuffle_epi8(fold, swap);
|
||||
fold = _mm_slli_si128(xmm_shift_right(fold, 20 - data_len), 4);
|
||||
|
||||
/**
|
||||
* Apply CRC init value
|
||||
*/
|
||||
temp = _mm_insert_epi32(_mm_setzero_si128(), bswap4(crc), 0);
|
||||
temp = xmm_shift_left(temp, data_len - 4);
|
||||
fold = _mm_xor_si128(fold, temp);
|
||||
} else {
|
||||
/**
|
||||
* There are 2x16 data blocks or more
|
||||
*/
|
||||
__m128i next_data;
|
||||
|
||||
/**
|
||||
* n = number of bytes required to align \a data_len
|
||||
* to multiple of 16
|
||||
*/
|
||||
n = ((~data_len) + 1) & 15;
|
||||
|
||||
/**
|
||||
* Apply CRC initial value and
|
||||
* get \a fold to BE format
|
||||
*/
|
||||
fold = _mm_xor_si128(fold,
|
||||
_mm_insert_epi32(_mm_setzero_si128(),
|
||||
crc, 0));
|
||||
fold = _mm_shuffle_epi8(fold, swap);
|
||||
|
||||
/**
|
||||
* Load next 16 bytes of data and
|
||||
* adjust \a fold & \a next_data as follows:
|
||||
*
|
||||
* CONCAT(fold,next_data) >> (n*8)
|
||||
*/
|
||||
next_data = _mm_loadu_si128((__m128i *)&data[16]);
|
||||
next_data = _mm_shuffle_epi8(next_data, swap);
|
||||
next_data = _mm_or_si128(xmm_shift_right(next_data, n),
|
||||
xmm_shift_left(fold, 16 - n));
|
||||
fold = xmm_shift_right(fold, n);
|
||||
|
||||
if (unlikely(data_len <= 32))
|
||||
/**
|
||||
* In such unlikely case clear 4 least significant bytes
|
||||
*/
|
||||
next_data =
|
||||
_mm_slli_si128(_mm_srli_si128(next_data, 4), 4);
|
||||
|
||||
/**
|
||||
* Do the initial folding round on 2 first 16 byte chunks
|
||||
*/
|
||||
k = _mm_load_si128((__m128i *)(¶ms->k1));
|
||||
fold = crc32_folding_round(next_data, k, fold);
|
||||
|
||||
if (likely(data_len > 32)) {
|
||||
/**
|
||||
* \a data_block needs to be at least 48 bytes long
|
||||
* in order to get here
|
||||
*/
|
||||
__m128i new_data;
|
||||
|
||||
/**
|
||||
* Main folding loop
|
||||
* - n is adjusted to point to next 16 data block
|
||||
* to read
|
||||
* (16+16) = 2x16; represents 2 first data blocks
|
||||
* processed above
|
||||
* (- n) is the number of zero bytes padded to
|
||||
* the message in order to align it to 16 bytes
|
||||
* - the last 16 bytes is processed separately
|
||||
*/
|
||||
for (n = 16 + 16 - n; n < (data_len - 16); n += 16) {
|
||||
new_data = _mm_loadu_si128((__m128i *)&data[n]);
|
||||
new_data = _mm_shuffle_epi8(new_data, swap);
|
||||
fold = crc32_folding_round(new_data, k, fold);
|
||||
}
|
||||
|
||||
/**
|
||||
* The last folding round works always on 12 bytes
|
||||
* (12 bytes of data and 4 zero bytes)
|
||||
* Read from offset -4 is to avoid one
|
||||
* shift right operation.
|
||||
*/
|
||||
new_data = _mm_loadu_si128((__m128i *)&data[n - 4]);
|
||||
new_data = _mm_shuffle_epi8(new_data, swap);
|
||||
new_data = _mm_slli_si128(new_data, 4);
|
||||
fold = crc32_folding_round(new_data, k, fold);
|
||||
} /* if (data_len > 32) */
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------
|
||||
* Reduction 128 -> 32
|
||||
* Assumes: \a fold holds 128bit folded data
|
||||
*/
|
||||
|
||||
/**
|
||||
* REDUCTION 128 -> 64
|
||||
*/
|
||||
k = _mm_load_si128((__m128i *)(¶ms->k3));
|
||||
fold = crc32_reduce_128_to_64(fold, k);
|
||||
|
||||
/**
|
||||
* REDUCTION 64 -> 32
|
||||
*/
|
||||
n = crc32_reduce_64_to_32(fold, k,
|
||||
_mm_load_si128((__m128i *)(¶ms->p)));
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/**
|
||||
* - restore FPU context
|
||||
*/
|
||||
kernel_fpu_end();
|
||||
#endif
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif /* __CRC_H__ */
|
||||
@@ -30,10 +30,14 @@
|
||||
Modified in June, 2001, to include the length non multiple of 8
|
||||
*/
|
||||
|
||||
#define USE_INTEL_CRC 1
|
||||
|
||||
#include "coding_defs.h"
|
||||
#include "assertions.h"
|
||||
|
||||
#ifdef USE_INTEL_CRC
|
||||
#include "crc_intel.h"
|
||||
#include "crc.h"
|
||||
#endif
|
||||
/*ref 36-212 v8.6.0 , pp 8-9 */
|
||||
/* the highest degree is set by default */
|
||||
|
||||
@@ -94,6 +98,28 @@ static unsigned short crc11Table[256];
|
||||
static unsigned char crc8Table[256];
|
||||
static unsigned char crc6Table[256];
|
||||
|
||||
#ifdef USE_INTEL_CRC
|
||||
static DECLARE_ALIGNED(struct crc_pclmulqdq_ctx lte_crc24a_pclmulqdq, 16) = {
|
||||
0x64e4d700, /**< k1 */
|
||||
0x2c8c9d00, /**< k2 */
|
||||
0xd9fe8c00, /**< k3 */
|
||||
0xf845fe24, /**< q */
|
||||
0x864cfb00, /**< p */
|
||||
0ULL /**< res */
|
||||
};
|
||||
__m128i crc_xmm_be_le_swap128;
|
||||
|
||||
DECLARE_ALIGNED(const uint8_t crc_xmm_shift_tab[48], 16) = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void crcTableInit (void)
|
||||
{
|
||||
unsigned char c = 0;
|
||||
@@ -108,14 +134,20 @@ void crcTableInit (void)
|
||||
crc8Table[c] = (unsigned char) (crcbit (&c, 1, poly8) >> 24);
|
||||
crc6Table[c] = (unsigned char) (crcbit (&c, 1, poly6) >> 24);
|
||||
} while (++c);
|
||||
#ifdef USE_INTEL_CRC
|
||||
crc_xmm_be_le_swap128 = _mm_setr_epi32(0x0c0d0e0f, 0x08090a0b,
|
||||
0x04050607, 0x00010203);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
|
||||
Byte by byte implementations,
|
||||
Byte by byte LUT implementations,
|
||||
assuming initial byte is 0 padded (in MSB) if necessary
|
||||
|
||||
can use SIMD optimized Intel CRC for LTE/NR 24a/24b variants
|
||||
*********************************************************/
|
||||
|
||||
unsigned int crc24a (unsigned char * inptr,
|
||||
int bitlen)
|
||||
{
|
||||
@@ -124,7 +156,7 @@ unsigned int crc24a (unsigned char * inptr,
|
||||
unsigned int crc = 0;
|
||||
octetlen = bitlen / 8; /* Change in octets */
|
||||
resbit = (bitlen % 8);
|
||||
|
||||
#ifndef USE_INTEL_CRC
|
||||
while (octetlen-- > 0) {
|
||||
// printf("crc24a: in %x => crc %x\n",crc,*inptr);
|
||||
crc = (crc << 8) ^ crc24aTable[(*inptr++) ^ (crc >> 24)];
|
||||
@@ -132,18 +164,32 @@ unsigned int crc24a (unsigned char * inptr,
|
||||
|
||||
if (resbit > 0)
|
||||
crc = (crc << resbit) ^ crc24aTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
|
||||
|
||||
return crc;
|
||||
#else
|
||||
return crc32_calc_pclmulqdq(inptr, octetlen, 0,
|
||||
<e_crc24a_pclmulqdq);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef USE_INTEL_CRC
|
||||
static DECLARE_ALIGNED(struct crc_pclmulqdq_ctx lte_crc24b_pclmulqdq, 16) = {
|
||||
0x80140500, /**< k1 */
|
||||
0x42000100, /**< k2 */
|
||||
0x90042100, /**< k3 */
|
||||
0xffff83ff, /**< q */
|
||||
0x80006300, /**< p */
|
||||
0ULL /**< res */
|
||||
};
|
||||
#endif
|
||||
unsigned int crc24b (unsigned char * inptr,
|
||||
int bitlen)
|
||||
int bitlen)
|
||||
{
|
||||
int octetlen, resbit;
|
||||
unsigned int crc = 0;
|
||||
octetlen = bitlen / 8; /* Change in octets */
|
||||
resbit = (bitlen % 8);
|
||||
|
||||
#ifndef USE_INTEL_CRC
|
||||
while (octetlen-- > 0) {
|
||||
// printf("crc24b: in %x => crc %x (%x)\n",crc,*inptr,crc24bTable[(*inptr) ^ (crc >> 24)]);
|
||||
crc = (crc << 8) ^ crc24bTable[(*inptr++) ^ (crc >> 24)];
|
||||
@@ -153,6 +199,10 @@ unsigned int crc24b (unsigned char * inptr,
|
||||
crc = (crc << resbit) ^ crc24bTable[((*inptr) >> (8 - resbit)) ^ (crc >> (32 - resbit))];
|
||||
|
||||
return crc;
|
||||
#else
|
||||
return crc32_calc_pclmulqdq(inptr, octetlen, 0,
|
||||
<e_crc24b_pclmulqdq);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int crc24c (unsigned char * inptr,
|
||||
|
||||
@@ -0,0 +1,541 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2009-2018, Intel Corporation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* Header file for module with CRC computation methods
|
||||
*
|
||||
* PCLMULQDQ implementation is based on work by:
|
||||
* Erdinc Ozturk
|
||||
* Vinodh Gopal
|
||||
* James Guilford
|
||||
*
|
||||
* "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
|
||||
* URL: http://download.intel.com/design/intarch/papers/323102.pdf
|
||||
*/
|
||||
|
||||
#ifndef __CRC_H__
|
||||
#define __CRC_H__
|
||||
|
||||
#include <x86intrin.h>
|
||||
|
||||
#include "crcext.h"
|
||||
#include "types.h"
|
||||
|
||||
/**
|
||||
* PCLMULQDQ CRC computation context structure
|
||||
*/
|
||||
struct crc_pclmulqdq_ctx {
|
||||
/**
|
||||
* K1 = reminder X^128 / P(X) : 0-63
|
||||
* K2 = reminder X^192 / P(X) : 64-127
|
||||
*/
|
||||
uint64_t k1;
|
||||
uint64_t k2;
|
||||
|
||||
/**
|
||||
* K3 = reminder X^64 / P(X) : 0-63
|
||||
* q = quotient X^64 / P(X) : 64-127
|
||||
*/
|
||||
uint64_t k3;
|
||||
uint64_t q;
|
||||
|
||||
/**
|
||||
* p = polynomial / P(X) : 0-63
|
||||
* res = reserved : 64-127
|
||||
*/
|
||||
uint64_t p;
|
||||
uint64_t res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions and prototypes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes look-up-table (LUT) for given 8 bit polynomial
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param lut pointer to look-up-table to be initialized
|
||||
*/
|
||||
void crc8_init_lut(const uint8_t poly, uint8_t *lut);
|
||||
|
||||
/**
|
||||
* @brief Calculates 8 bit CRC using LUT method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param lut 256x8bits look-up-table pointer
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint8_t crc8_calc_lut(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint8_t crc,
|
||||
const uint8_t *lut)
|
||||
{
|
||||
if (unlikely(data == NULL || lut == NULL))
|
||||
return crc;
|
||||
|
||||
while (data_len--)
|
||||
crc = lut[*data++ ^ crc];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look-up-table (LUT) for given 16 bit polynomial
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param lut pointer to 256x16bits look-up-table to be initialized
|
||||
*/
|
||||
void crc16_init_lut(const uint16_t poly, uint16_t *lut);
|
||||
|
||||
/**
|
||||
* @brief Calculates 16 bit CRC using LUT method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param lut 256x16bits look-up-table pointer
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint16_t crc16_calc_lut(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint16_t crc,
|
||||
const uint16_t *lut)
|
||||
{
|
||||
if (unlikely(data == NULL || lut == NULL))
|
||||
return crc;
|
||||
|
||||
while (data_len--)
|
||||
crc = lut[(crc >> 8) ^ *data++] ^ (crc << 8);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look-up-table (LUT) for given 32 bit polynomial
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param lut pointer to 256x32bits look-up-table to be initialized
|
||||
*/
|
||||
void crc32_init_lut(const uint32_t poly, uint32_t *lut);
|
||||
|
||||
/**
|
||||
* @brief Calculates 32 bit CRC using LUT method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param lut 256x32bits look-up-table pointer
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t crc32_calc_lut(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint32_t crc,
|
||||
const uint32_t *lut)
|
||||
{
|
||||
if (unlikely(data == NULL || lut == NULL))
|
||||
return crc;
|
||||
|
||||
while (data_len--)
|
||||
crc = lut[(crc >> 24) ^ *data++] ^ (crc << 8);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look up tables for slice-By-2 method.
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param slice1 slice-by-2 look-up-table 1
|
||||
* @param slice2 slice-by-2 look-up-table 2
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
void crc16_init_slice2(const uint16_t poly,
|
||||
uint16_t *slice1,
|
||||
uint16_t *slice2);
|
||||
|
||||
/**
|
||||
* @brief Calculates 16 bit CRC using Slice-By-2 method.
|
||||
*
|
||||
* @param crc CRC initial value
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param slice1 256x16bits slice look-up-table 1
|
||||
* @param slice2 256x16bits slice look-up-table 2
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint16_t crc16_calc_slice2(const uint8_t *data,
|
||||
uint32_t data_len,
|
||||
uint16_t crc,
|
||||
const uint16_t *slice1,
|
||||
const uint16_t *slice2)
|
||||
{
|
||||
uint_fast32_t i;
|
||||
|
||||
if (unlikely(data == NULL))
|
||||
return crc;
|
||||
|
||||
if (unlikely(slice1 == NULL || slice2 == NULL))
|
||||
return crc;
|
||||
|
||||
crc = bswap2(crc);
|
||||
for (i = (data_len & (~1)), data += (data_len & (~1)); i != 0;
|
||||
i -= sizeof(uint16_t)) {
|
||||
crc ^= (*((const uint16_t *)(data - i)));
|
||||
crc = slice2[(uint8_t)crc] ^ slice1[(uint8_t)(crc >> 8)];
|
||||
}
|
||||
crc = bswap2(crc);
|
||||
if (data_len & 1)
|
||||
crc = (crc << 8) ^ bswap2(slice1[(crc >> 8) ^ *data]);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes look up tables for slice-By-4 method.
|
||||
*
|
||||
* @param poly CRC polynomial
|
||||
* @param slice1 256x32bits slice look-up-table 1
|
||||
* @param slice2 256x32bits slice look-up-table 2
|
||||
* @param slice3 256x32bits slice look-up-table 3
|
||||
* @param slice4 256x32bits slice look-up-table 4
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
void crc32_init_slice4(const uint32_t poly,
|
||||
uint32_t *slice1, uint32_t *slice2,
|
||||
uint32_t *slice3, uint32_t *slice4);
|
||||
|
||||
/**
|
||||
* @brief Calculates 32 bit CRC using Slice-By-4 method.
|
||||
*
|
||||
* @param data pointer to data block to calculate CRC for
|
||||
* @param data_len size of data block
|
||||
* @param crc CRC initial value
|
||||
* @param slice1 256x32bits slice look-up-table 1
|
||||
* @param slice2 256x32bits slice look-up-table 2
|
||||
* @param slice3 256x32bits slice look-up-table 3
|
||||
* @param slice4 256x32bits slice look-up-table 4
|
||||
*
|
||||
* @return New CRC value
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t crc32_calc_slice4(const uint8_t *data,
|
||||
uint32_t data_len, uint32_t crc,
|
||||
const uint32_t *slice1, const uint32_t *slice2,
|
||||
const uint32_t *slice3, const uint32_t *slice4)
|
||||
{
|
||||
uint_fast32_t i;
|
||||
|
||||
if (unlikely(data == NULL))
|
||||
return crc;
|
||||
|
||||
if (unlikely(slice1 == NULL || slice2 == NULL ||
|
||||
slice3 == NULL || slice4 == NULL))
|
||||
return crc;
|
||||
|
||||
crc = bswap4(crc);
|
||||
for (i = data_len & (~3), data += (data_len & (~3)); i != 0;
|
||||
i -= sizeof(uint32_t)) {
|
||||
crc ^= (*((const uint32_t *)(data - i)));
|
||||
crc = slice4[(uint8_t)(crc)] ^
|
||||
slice3[(uint8_t)(crc >> 8)] ^
|
||||
slice2[(uint8_t)(crc >> 16)] ^
|
||||
slice1[(uint8_t)(crc >> 24)];
|
||||
}
|
||||
crc = bswap4(crc);
|
||||
for (i = data_len & 3, data += (data_len & 3); i != 0; i--)
|
||||
crc = (crc << 8) ^
|
||||
bswap4(slice1[(crc >> 24) ^ *(data - i)]);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs one folding round
|
||||
*
|
||||
* Logically function operates as follows:
|
||||
* DATA = READ_NEXT_16BYTES();
|
||||
* F1 = LSB8(FOLD)
|
||||
* F2 = MSB8(FOLD)
|
||||
* T1 = CLMUL( F1, K1 )
|
||||
* T2 = CLMUL( F2, K2 )
|
||||
* FOLD = XOR( T1, T2, DATA )
|
||||
*
|
||||
* @param data_block 16 byte data block
|
||||
* @param k1_k2 k1 and k2 constanst enclosed in XMM register
|
||||
* @param fold running 16 byte folded data
|
||||
*
|
||||
* @return New 16 byte folded data
|
||||
*/
|
||||
__forceinline
|
||||
__m128i crc32_folding_round(const __m128i data_block,
|
||||
const __m128i k1_k2,
|
||||
const __m128i fold)
|
||||
{
|
||||
__m128i tmp = _mm_clmulepi64_si128(fold, k1_k2, 0x11);
|
||||
|
||||
return _mm_xor_si128(_mm_clmulepi64_si128(fold, k1_k2, 0x00),
|
||||
_mm_xor_si128(data_block, tmp));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs Barret's reduction from 128 bits to 64 bits
|
||||
*
|
||||
* @param data128 128 bits data to be reduced
|
||||
* @param k3_q k3 and Q constants enclosed in XMM register
|
||||
*
|
||||
* @return data reduced to 64 bits
|
||||
*/
|
||||
__forceinline
|
||||
__m128i crc32_reduce_128_to_64(__m128i data128, const __m128i k3_q)
|
||||
{
|
||||
__m128i tmp;
|
||||
|
||||
tmp = _mm_xor_si128(_mm_clmulepi64_si128(data128, k3_q, 0x01 /* k3 */),
|
||||
data128);
|
||||
|
||||
data128 = _mm_xor_si128(_mm_clmulepi64_si128(tmp, k3_q, 0x01 /* k3 */),
|
||||
data128);
|
||||
|
||||
return _mm_srli_si128(_mm_slli_si128(data128, 8), 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs Barret's reduction from 64 bits to 32 bits
|
||||
*
|
||||
* @param data64 64 bits data to be reduced
|
||||
* @param k3_q k3 and Q constants enclosed in XMM register
|
||||
* @param p_res P constant enclosed in XMM register
|
||||
*
|
||||
* @return data reduced to 32 bits
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t
|
||||
crc32_reduce_64_to_32(__m128i fold, const __m128i k3_q, const __m128i p_res)
|
||||
{
|
||||
__m128i temp;
|
||||
|
||||
temp = _mm_clmulepi64_si128(_mm_srli_si128(fold, 4),
|
||||
k3_q, 0x10 /* Q */);
|
||||
temp = _mm_srli_si128(_mm_xor_si128(temp, fold), 4);
|
||||
temp = _mm_clmulepi64_si128(temp, p_res, 0 /* P */);
|
||||
return _mm_extract_epi32(_mm_xor_si128(temp, fold), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates 32 bit CRC for given \a data block by applying folding and
|
||||
* reduction methods.
|
||||
*
|
||||
* Algorithm operates on 32 bit CRCs so polynomials and initial values may
|
||||
* need to be promoted to 32 bits where required.
|
||||
*
|
||||
* @param crc initial CRC value (32 bit value)
|
||||
* @param data pointer to data block
|
||||
* @param data_len length of \a data block in bytes
|
||||
* @param params pointer to PCLMULQDQ CRC calculation context
|
||||
*
|
||||
* @return CRC for given \a data block (32 bits wide).
|
||||
*/
|
||||
__forceinline
|
||||
uint32_t
|
||||
crc32_calc_pclmulqdq(const uint8_t *data,
|
||||
uint32_t data_len, uint32_t crc,
|
||||
const struct crc_pclmulqdq_ctx *params)
|
||||
{
|
||||
__m128i temp, fold, k, swap;
|
||||
uint32_t n;
|
||||
|
||||
if (unlikely(data == NULL || data_len == 0 || params == NULL))
|
||||
return crc;
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/**
|
||||
* Preserve FPU context
|
||||
*/
|
||||
kernel_fpu_begin();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add 4 bytes to data block size
|
||||
* This is to secure the following:
|
||||
* CRC32 = M(X)^32 mod P(X)
|
||||
* M(X) - message to compute CRC on
|
||||
* P(X) - CRC polynomial
|
||||
*/
|
||||
data_len += 4;
|
||||
|
||||
/**
|
||||
* Load first 16 data bytes in \a fold and
|
||||
* set \a swap BE<->LE 16 byte conversion variable
|
||||
*/
|
||||
fold = _mm_loadu_si128((__m128i *)data);
|
||||
swap = crc_xmm_be_le_swap128;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------
|
||||
* Folding all data into single 16 byte data block
|
||||
* Assumes: \a fold holds first 16 bytes of data
|
||||
*/
|
||||
|
||||
if (unlikely(data_len <= 16)) {
|
||||
/**
|
||||
* Data block fits into 16 byte block
|
||||
* - adjust data block
|
||||
* - 4 least significant bytes need to be zero
|
||||
*/
|
||||
fold = _mm_shuffle_epi8(fold, swap);
|
||||
fold = _mm_slli_si128(xmm_shift_right(fold, 20 - data_len), 4);
|
||||
|
||||
/**
|
||||
* Apply CRC init value
|
||||
*/
|
||||
temp = _mm_insert_epi32(_mm_setzero_si128(), bswap4(crc), 0);
|
||||
temp = xmm_shift_left(temp, data_len - 4);
|
||||
fold = _mm_xor_si128(fold, temp);
|
||||
} else {
|
||||
/**
|
||||
* There are 2x16 data blocks or more
|
||||
*/
|
||||
__m128i next_data;
|
||||
|
||||
/**
|
||||
* n = number of bytes required to align \a data_len
|
||||
* to multiple of 16
|
||||
*/
|
||||
n = ((~data_len) + 1) & 15;
|
||||
|
||||
/**
|
||||
* Apply CRC initial value and
|
||||
* get \a fold to BE format
|
||||
*/
|
||||
fold = _mm_xor_si128(fold,
|
||||
_mm_insert_epi32(_mm_setzero_si128(),
|
||||
crc, 0));
|
||||
fold = _mm_shuffle_epi8(fold, swap);
|
||||
|
||||
/**
|
||||
* Load next 16 bytes of data and
|
||||
* adjust \a fold & \a next_data as follows:
|
||||
*
|
||||
* CONCAT(fold,next_data) >> (n*8)
|
||||
*/
|
||||
next_data = _mm_loadu_si128((__m128i *)&data[16]);
|
||||
next_data = _mm_shuffle_epi8(next_data, swap);
|
||||
next_data = _mm_or_si128(xmm_shift_right(next_data, n),
|
||||
xmm_shift_left(fold, 16 - n));
|
||||
fold = xmm_shift_right(fold, n);
|
||||
|
||||
if (unlikely(data_len <= 32))
|
||||
/**
|
||||
* In such unlikely case clear 4 least significant bytes
|
||||
*/
|
||||
next_data =
|
||||
_mm_slli_si128(_mm_srli_si128(next_data, 4), 4);
|
||||
|
||||
/**
|
||||
* Do the initial folding round on 2 first 16 byte chunks
|
||||
*/
|
||||
k = _mm_load_si128((__m128i *)(¶ms->k1));
|
||||
fold = crc32_folding_round(next_data, k, fold);
|
||||
|
||||
if (likely(data_len > 32)) {
|
||||
/**
|
||||
* \a data_block needs to be at least 48 bytes long
|
||||
* in order to get here
|
||||
*/
|
||||
__m128i new_data;
|
||||
|
||||
/**
|
||||
* Main folding loop
|
||||
* - n is adjusted to point to next 16 data block
|
||||
* to read
|
||||
* (16+16) = 2x16; represents 2 first data blocks
|
||||
* processed above
|
||||
* (- n) is the number of zero bytes padded to
|
||||
* the message in order to align it to 16 bytes
|
||||
* - the last 16 bytes is processed separately
|
||||
*/
|
||||
for (n = 16 + 16 - n; n < (data_len - 16); n += 16) {
|
||||
new_data = _mm_loadu_si128((__m128i *)&data[n]);
|
||||
new_data = _mm_shuffle_epi8(new_data, swap);
|
||||
fold = crc32_folding_round(new_data, k, fold);
|
||||
}
|
||||
|
||||
/**
|
||||
* The last folding round works always on 12 bytes
|
||||
* (12 bytes of data and 4 zero bytes)
|
||||
* Read from offset -4 is to avoid one
|
||||
* shift right operation.
|
||||
*/
|
||||
new_data = _mm_loadu_si128((__m128i *)&data[n - 4]);
|
||||
new_data = _mm_shuffle_epi8(new_data, swap);
|
||||
new_data = _mm_slli_si128(new_data, 4);
|
||||
fold = crc32_folding_round(new_data, k, fold);
|
||||
} /* if (data_len > 32) */
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------
|
||||
* Reduction 128 -> 32
|
||||
* Assumes: \a fold holds 128bit folded data
|
||||
*/
|
||||
|
||||
/**
|
||||
* REDUCTION 128 -> 64
|
||||
*/
|
||||
k = _mm_load_si128((__m128i *)(¶ms->k3));
|
||||
fold = crc32_reduce_128_to_64(fold, k);
|
||||
|
||||
/**
|
||||
* REDUCTION 64 -> 32
|
||||
*/
|
||||
n = crc32_reduce_64_to_32(fold, k,
|
||||
_mm_load_si128((__m128i *)(¶ms->p)));
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/**
|
||||
* - restore FPU context
|
||||
*/
|
||||
kernel_fpu_end();
|
||||
#endif
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif /* __CRC_H__ */
|
||||
@@ -0,0 +1,89 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2009-2018, Intel Corporation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* Header file with CRC external definitions
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CRCEXT_H__
|
||||
#define __CRCEXT_H__
|
||||
|
||||
#include <x86intrin.h>
|
||||
#include "types.h"
|
||||
/**
|
||||
* Flag indicating availability of PCLMULQDQ instruction
|
||||
* Only valid after running CRCInit() function.
|
||||
*/
|
||||
extern int pclmulqdq_available;
|
||||
|
||||
/**
|
||||
* Flag indicating availability of PCLMULQDQ instruction
|
||||
* Only valid after running CRCInit() function.
|
||||
*/
|
||||
extern __m128i crc_xmm_be_le_swap128;
|
||||
extern const uint8_t crc_xmm_shift_tab[48];
|
||||
|
||||
/**
|
||||
* @brief Shifts right 128 bit register by specified number of bytes
|
||||
*
|
||||
* @param reg 128 bit value
|
||||
* @param num number of bytes to shift right \a reg by (0-16)
|
||||
*
|
||||
* @return \a reg >> (\a num * 8)
|
||||
*/
|
||||
__forceinline
|
||||
__m128i xmm_shift_right(__m128i reg, const unsigned int num)
|
||||
{
|
||||
const __m128i *p = (const __m128i *)(crc_xmm_shift_tab + 16 + num);
|
||||
|
||||
return _mm_shuffle_epi8(reg, _mm_loadu_si128(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Shifts left 128 bit register by specified number of bytes
|
||||
*
|
||||
* @param reg 128 bit value
|
||||
* @param num number of bytes to shift left \a reg by (0-16)
|
||||
*
|
||||
* @return \a reg << (\a num * 8)
|
||||
*/
|
||||
__forceinline
|
||||
__m128i xmm_shift_left(__m128i reg, const unsigned int num)
|
||||
{
|
||||
const __m128i *p = (const __m128i *)(crc_xmm_shift_tab + 16 - num);
|
||||
|
||||
return _mm_shuffle_epi8(reg, _mm_loadu_si128(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes CRC module.
|
||||
* @note It is mandatory to run it before using any of CRC API's.
|
||||
*/
|
||||
extern void CRCInit(void);
|
||||
|
||||
#endif /* __CRCEXT_H__ */
|
||||
@@ -30,14 +30,6 @@
|
||||
|
||||
#include <stdint.h> // for uint8/16/32_t
|
||||
|
||||
/* check if this ifndef is required for NB-IoT ?!
|
||||
//#ifndef NO_OPENAIR1
|
||||
//#include "PHY/defs_NB_IoT.h"
|
||||
//#else
|
||||
//#include "PHY/TOOLS/time_meas.h"
|
||||
//#endif
|
||||
*/
|
||||
|
||||
#define CRC24_A_NB_IoT 0
|
||||
#define CRC24_B_NB_IoT 1
|
||||
#define CRC16_NB_IoT 2
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "nrLDPC_types.h"
|
||||
|
||||
#ifndef malloc32_clear
|
||||
/**
|
||||
\brief Allocates 32 byte aligned memory and initializes to zero
|
||||
\param size Input size in bytes
|
||||
@@ -46,7 +45,6 @@ static inline void* malloc32_clear(size_t size)
|
||||
memset(ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Allocates and initializes the internal decoder processing buffers
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
// encoder interface
|
||||
#ifndef __NRLDPC_DEFS__H__
|
||||
#define __NRLDPC_DEFS__H__
|
||||
#include <openair1/PHY/defs_nr_common.h>
|
||||
#include "openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_types.h"
|
||||
/**
|
||||
\brief LDPC encoder
|
||||
@@ -36,13 +37,27 @@
|
||||
\param 9-12 time_stats_t *tinput,*tprep, *tparity,*toutput
|
||||
*/
|
||||
typedef struct {
|
||||
int n_segments; // optim8seg
|
||||
unsigned int n_segments; // optim8seg
|
||||
unsigned int macro_num; // optim8segmulti
|
||||
unsigned char gen_code; //orig
|
||||
time_stats_t *tinput;
|
||||
time_stats_t *tprep;
|
||||
time_stats_t *tparity;
|
||||
time_stats_t *toutput;
|
||||
int Kr;
|
||||
uint32_t Kb;
|
||||
uint32_t *Zc;
|
||||
void *harq;
|
||||
/// Encoder BG
|
||||
uint8_t BG;
|
||||
/// Interleaver outputs
|
||||
unsigned char *output;
|
||||
/// Number of bits in "small" code segments
|
||||
uint32_t K;
|
||||
/// Number of "Filler" bits
|
||||
uint32_t F;
|
||||
/// LDPC-code outputs
|
||||
uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
|
||||
}encoder_implemparams_t;
|
||||
#define INIT0_LDPCIMPLEMPARAMS {0,0,0,NULL,NULL,NULL,NULL}
|
||||
typedef void(*nrLDPC_initcallfunc_t)(t_nrLDPC_dec_params* p_decParams, int8_t* p_llr, int8_t* p_out);
|
||||
|
||||
@@ -73,9 +73,18 @@
|
||||
|
||||
|
||||
|
||||
static inline void encode_parity_check_part_optim(uint8_t *c,uint8_t *d, short BG,short Zc,short Kb)
|
||||
static void encode_parity_check_part_optim(uint8_t *cc,uint8_t *d, short BG,short Zc,short Kb, int simd_size, int ncols)
|
||||
{
|
||||
|
||||
unsigned char c[2*22*Zc*simd_size] __attribute__((aligned(32))); //double size matrix of c
|
||||
|
||||
for (int i1=0; i1 < ncols; i1++) {
|
||||
memcpy(&c[2*i1*Zc], &cc[i1*Zc], Zc*sizeof(unsigned char));
|
||||
memcpy(&c[(2*i1+1)*Zc], &cc[i1*Zc], Zc*sizeof(unsigned char));
|
||||
}
|
||||
for (int i1=1;i1<simd_size;i1++) {
|
||||
memcpy(&c[(2*ncols*Zc*i1)], &c[i1], (2*ncols*Zc*sizeof(unsigned char))-i1);
|
||||
}
|
||||
|
||||
if (BG==1)
|
||||
{
|
||||
switch (Zc)
|
||||
|
||||
@@ -86,8 +86,6 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
unsigned char c[22*Zc] __attribute__((aligned(32))); //padded input, unpacked, max size
|
||||
unsigned char d[46*Zc] __attribute__((aligned(32))); //coded parity part output, unpacked, max size
|
||||
|
||||
unsigned char c_extension[2*22*Zc*simd_size] __attribute__((aligned(32))); //double size matrix of c
|
||||
|
||||
// calculate number of punctured bits
|
||||
no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*rate)/Zc;
|
||||
removed_bit=(nrows-no_punctured_columns-2) * Zc+block_length-(int)(block_length*rate);
|
||||
@@ -108,24 +106,10 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
if ((BG==1 && Zc>176) || (BG==2 && Zc>64)) {
|
||||
// extend matrix
|
||||
if(impp->tprep != NULL) start_meas(impp->tprep);
|
||||
for (i1=0; i1 < ncols; i1++)
|
||||
{
|
||||
memcpy(&c_extension[2*i1*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
|
||||
memcpy(&c_extension[(2*i1+1)*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
|
||||
}
|
||||
for (i1=1;i1<simd_size;i1++) {
|
||||
memcpy(&c_extension[(2*ncols*Zc*i1)], &c_extension[i1], (2*ncols*Zc*sizeof(unsigned char))-i1);
|
||||
// memset(&c_extension[(2*ncols*Zc*i1)],0,i1);
|
||||
/*
|
||||
printf("shift %d: ",i1);
|
||||
for (int j=0;j<64;j++) printf("%d ",c_extension[(2*ncols*Zc*i1)+j]);
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
if(impp->tprep != NULL) stop_meas(impp->tprep);
|
||||
//parity check part
|
||||
if(impp->tparity != NULL) start_meas(impp->tparity);
|
||||
encode_parity_check_part_optim(c_extension, d, BG, Zc, Kb);
|
||||
encode_parity_check_part_optim(c, d, BG, Zc, Kb,simd_size, ncols);
|
||||
if(impp->tparity != NULL) stop_meas(impp->tparity);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -102,7 +102,6 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
unsigned char c[22*Zc] __attribute__((aligned(32))); //padded input, unpacked, max size
|
||||
unsigned char d[46*Zc] __attribute__((aligned(32))); //coded parity part output, unpacked, max size
|
||||
|
||||
unsigned char c_extension[2*22*Zc*simd_size] __attribute__((aligned(32))); //double size matrix of c
|
||||
|
||||
// calculate number of punctured bits
|
||||
no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*rate)/Zc;
|
||||
@@ -151,24 +150,10 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
if ((BG==1 && Zc>176) || (BG==2 && Zc>64)) {
|
||||
// extend matrix
|
||||
if(impp->tprep != NULL) start_meas(impp->tprep);
|
||||
for (i1=0; i1 < ncols; i1++)
|
||||
{
|
||||
memcpy(&c_extension[2*i1*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
|
||||
memcpy(&c_extension[(2*i1+1)*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
|
||||
}
|
||||
for (i1=1;i1<simd_size;i1++) {
|
||||
memcpy(&c_extension[(2*ncols*Zc*i1)], &c_extension[i1], (2*ncols*Zc*sizeof(unsigned char))-i1);
|
||||
// memset(&c_extension[(2*ncols*Zc*i1)],0,i1);
|
||||
/*
|
||||
printf("shift %d: ",i1);
|
||||
for (int j=0;j<64;j++) printf("%d ",c_extension[(2*ncols*Zc*i1)+j]);
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
if(impp->tprep != NULL) stop_meas(impp->tprep);
|
||||
//parity check part
|
||||
if(impp->tparity != NULL) start_meas(impp->tparity);
|
||||
encode_parity_check_part_optim(c_extension, d, BG, Zc, Kb);
|
||||
encode_parity_check_part_optim(c, d, BG, Zc, Kb, simd_size, ncols);
|
||||
if(impp->tparity != NULL) stop_meas(impp->tparity);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -38,18 +38,19 @@
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "PHY/TOOLS/time_meas.h"
|
||||
#include "openair1/PHY/CODING/nrLDPC_defs.h"
|
||||
|
||||
//#define DEBUG_LDPC
|
||||
|
||||
#include "ldpc_encode_parity_check.c"
|
||||
#include "ldpc_generate_coefficient.c"
|
||||
|
||||
|
||||
int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc,int Kb,short block_length, short BG, encoder_implemparams_t *impp)
|
||||
int nrLDPC_encod(unsigned char **input,unsigned char **output,int Zc,int Kb,short block_length, short BG, encoder_implemparams_t *impp)
|
||||
{
|
||||
//set_log(PHY, 4);
|
||||
|
||||
|
||||
short nrows=0,ncols=0;
|
||||
int i,i1,j,rate=3;
|
||||
int nrows=0,ncols=0;
|
||||
int rate=3;
|
||||
int no_punctured_columns,removed_bit;
|
||||
//Table of possible lifting sizes
|
||||
char temp;
|
||||
@@ -95,8 +96,8 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LDPC
|
||||
LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d, segments %d\n",BG,Zc,Kb,block_length,n_segments);
|
||||
LOG_D(PHY,"ldpc_encoder_optim_8seg: PDU (seg 0) %x %x %x %x\n",test_input[0][0],test_input[0][1],test_input[0][2],test_input[0][3]);
|
||||
LOG_D(PHY,"ldpc_encoder_optim_8seg: BG %d, Zc %d, Kb %d, block_length %d, segments %d\n",BG,Zc,Kb,block_length,impp->n_segments);
|
||||
LOG_D(PHY,"ldpc_encoder_optim_8seg: PDU (seg 0) %x %x %x %x\n",input[0][0],input[0][1],input[0][2],input[0][3]);
|
||||
#endif
|
||||
|
||||
AssertFatal(Zc>0,"no valid Zc found for block length %d\n",block_length);
|
||||
@@ -104,10 +105,8 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
if ((Zc&31) > 0) simd_size = 16;
|
||||
else simd_size = 32;
|
||||
|
||||
unsigned char c[22*Zc] __attribute__((aligned(32))); //padded input, unpacked, max size
|
||||
unsigned char d[46*Zc] __attribute__((aligned(32))); //coded parity part output, unpacked, max size
|
||||
|
||||
unsigned char c_extension[2*22*Zc*simd_size] __attribute__((aligned(32))); //double size matrix of c
|
||||
unsigned char cc[22*Zc] __attribute__((aligned(32))); //padded input, unpacked, max size
|
||||
unsigned char dd[46*Zc] __attribute__((aligned(32))); //coded parity part output, unpacked, max size
|
||||
|
||||
// calculate number of punctured bits
|
||||
no_punctured_columns=(int)((nrows-2)*Zc+block_length-block_length*rate)/Zc;
|
||||
@@ -115,8 +114,8 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
//printf("%d\n",no_punctured_columns);
|
||||
//printf("%d\n",removed_bit);
|
||||
// unpack input
|
||||
memset(c,0,sizeof(unsigned char) * ncols * Zc);
|
||||
memset(d,0,sizeof(unsigned char) * nrows * Zc);
|
||||
memset(cc,0,sizeof(unsigned char) * ncols * Zc);
|
||||
memset(dd,0,sizeof(unsigned char) * nrows * Zc);
|
||||
|
||||
if(impp->tinput != NULL) start_meas(impp->tinput);
|
||||
#if 0
|
||||
@@ -124,29 +123,29 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
//for (j=0; j<n_segments; j++) {
|
||||
for (j=macro_segment; j < macro_segment_end; j++) {
|
||||
|
||||
temp = (test_input[j][i/8]&(1<<(i&7)))>>(i&7);
|
||||
temp = (input[j][i/8]&(1<<(i&7)))>>(i&7);
|
||||
//printf("c(%d,%d)=%d\n",j,i,temp);
|
||||
c[i] |= (temp << (j-macro_segment));
|
||||
}
|
||||
}
|
||||
#else
|
||||
#ifdef __AVX2__
|
||||
for (i=0; i<block_length>>5; i++) {
|
||||
c256 = _mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)test_input[macro_segment])[i]), shufmask),andmask),zero256),masks[0]);
|
||||
for (int i=0; i<block_length>>5; i++) {
|
||||
c256 = _mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)input[macro_segment])[i]), shufmask),andmask),zero256),masks[0]);
|
||||
//for (j=1; j<n_segments; j++) {
|
||||
for (j=macro_segment+1; j < macro_segment_end; j++) {
|
||||
c256 = _mm256_or_si256(_mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)test_input[j])[i]), shufmask),andmask),zero256),masks[j-macro_segment]),c256);
|
||||
for (int j=macro_segment+1; j < macro_segment_end; j++) {
|
||||
c256 = _mm256_or_si256(_mm256_and_si256(_mm256_cmpeq_epi8(_mm256_andnot_si256(_mm256_shuffle_epi8(_mm256_set1_epi32(((uint32_t*)input[j])[i]), shufmask),andmask),zero256),masks[j-macro_segment]),c256);
|
||||
}
|
||||
((__m256i *)c)[i] = c256;
|
||||
((__m256i *)cc)[i] = c256;
|
||||
}
|
||||
|
||||
for (i=(block_length>>5)<<5;i<block_length;i++) {
|
||||
for (int i=(block_length>>5)<<5;i<block_length;i++) {
|
||||
//for (j=0; j<n_segments; j++) {
|
||||
for (j=macro_segment; j < macro_segment_end; j++) {
|
||||
for (int j=macro_segment; j < macro_segment_end; j++) {
|
||||
|
||||
temp = (test_input[j][i/8]&(128>>(i&7)))>>(7-(i&7));
|
||||
temp = (input[j][i/8]&(128>>(i&7)))>>(7-(i&7));
|
||||
//printf("c(%d,%d)=%d\n",j,i,temp);
|
||||
c[i] |= (temp << (j-macro_segment));
|
||||
cc[i] |= (temp << (j-macro_segment));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -159,28 +158,14 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
if ((BG==1 && Zc>176) || (BG==2 && Zc>64)) {
|
||||
// extend matrix
|
||||
if(impp->tprep != NULL) start_meas(impp->tprep);
|
||||
for (i1=0; i1 < ncols; i1++)
|
||||
{
|
||||
memcpy(&c_extension[2*i1*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
|
||||
memcpy(&c_extension[(2*i1+1)*Zc], &c[i1*Zc], Zc*sizeof(unsigned char));
|
||||
}
|
||||
for (i1=1;i1<simd_size;i1++) {
|
||||
memcpy(&c_extension[(2*ncols*Zc*i1)], &c_extension[i1], (2*ncols*Zc*sizeof(unsigned char))-i1);
|
||||
// memset(&c_extension[(2*ncols*Zc*i1)],0,i1);
|
||||
/*
|
||||
printf("shift %d: ",i1);
|
||||
for (int j=0;j<64;j++) printf("%d ",c_extension[(2*ncols*Zc*i1)+j]);
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
if(impp->tprep != NULL) stop_meas(impp->tprep);
|
||||
//parity check part
|
||||
if(impp->tparity != NULL) start_meas(impp->tparity);
|
||||
encode_parity_check_part_optim(c_extension, d, BG, Zc, Kb);
|
||||
encode_parity_check_part_optim(cc, dd, BG, Zc, Kb, simd_size, ncols);
|
||||
if(impp->tparity != NULL) stop_meas(impp->tparity);
|
||||
}
|
||||
else {
|
||||
if (encode_parity_check_part_orig(c, d, BG, Zc, Kb, block_length)!=0) {
|
||||
if (encode_parity_check_part_orig(cc, dd, BG, Zc, Kb, block_length)!=0) {
|
||||
printf("Problem with encoder\n");
|
||||
return(-1);
|
||||
}
|
||||
@@ -188,8 +173,8 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
if(impp->toutput != NULL) start_meas(impp->toutput);
|
||||
// information part and puncture columns
|
||||
/*
|
||||
memcpy(&channel_input[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char));
|
||||
memcpy(&channel_input[block_length-2*Zc], &d[0], ((nrows-no_punctured_columns) * Zc-removed_bit)*sizeof(unsigned char));
|
||||
memcpy(&output[0], &c[2*Zc], (block_length-2*Zc)*sizeof(unsigned char));
|
||||
memcpy(&output[block_length-2*Zc], &d[0], ((nrows-no_punctured_columns) * Zc-removed_bit)*sizeof(unsigned char));
|
||||
*/
|
||||
#ifdef __AVX2__
|
||||
if ((((2*Zc)&31) == 0) && (((block_length-(2*Zc))&31) == 0)) {
|
||||
@@ -197,34 +182,34 @@ int nrLDPC_encod(unsigned char **test_input,unsigned char **channel_input,int Zc
|
||||
//AssertFatal(((block_length-(2*Zc))&31) == 0,"block_length-(2*Zc) needs to be a multiple of 32 for now\n");
|
||||
uint32_t l1 = (block_length-(2*Zc))>>5;
|
||||
uint32_t l2 = ((nrows-no_punctured_columns) * Zc-removed_bit)>>5;
|
||||
__m256i *c256p = (__m256i *)&c[2*Zc];
|
||||
__m256i *d256p = (__m256i *)&d[0];
|
||||
__m256i *c256p = (__m256i *)&cc[2*Zc];
|
||||
__m256i *d256p = (__m256i *)&dd[0];
|
||||
// if (((block_length-(2*Zc))&31)>0) l1++;
|
||||
|
||||
for (i=0;i<l1;i++)
|
||||
//for (j=0;j<n_segments;j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(c256p[i],j),masks[0]);
|
||||
for (j=macro_segment; j < macro_segment_end; j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(c256p[i],j-macro_segment),masks[0]);
|
||||
for (int i=0;i<l1;i++)
|
||||
//for (j=0;j<n_segments;j++) ((__m256i *)output[j])[i] = _mm256_and_si256(_mm256_srai_epi16(c256p[i],j),masks[0]);
|
||||
for (int j=macro_segment; j < macro_segment_end; j++) ((__m256i *)output[j])[i] = _mm256_and_si256(_mm256_srai_epi16(c256p[i],j-macro_segment),masks[0]);
|
||||
|
||||
|
||||
// if ((((nrows-no_punctured_columns) * Zc-removed_bit)&31)>0) l2++;
|
||||
|
||||
for (i1=0;i1<l2;i1++,i++)
|
||||
//for (j=0;j<n_segments;j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(d256p[i1],j),masks[0]);
|
||||
for (j=macro_segment; j < macro_segment_end; j++) ((__m256i *)channel_input[j])[i] = _mm256_and_si256(_mm256_srai_epi16(d256p[i1],j-macro_segment),masks[0]);
|
||||
for (int i1=0, i=l1;i1<l2;i1++,i++)
|
||||
//for (j=0;j<n_segments;j++) ((__m256i *)output[j])[i] = _mm256_and_si256(_mm256_srai_epi16(d256p[i1],j),masks[0]);
|
||||
for (int j=macro_segment; j < macro_segment_end; j++) ((__m256i *)output[j])[i] = _mm256_and_si256(_mm256_srai_epi16(d256p[i1],j-macro_segment),masks[0]);
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG_LDPC
|
||||
LOG_W(PHY,"using non-optimized version\n");
|
||||
#endif
|
||||
// do non-SIMD version
|
||||
for (i=0;i<(block_length-2*Zc);i++)
|
||||
for (int i=0;i<(block_length-2*Zc);i++)
|
||||
//for (j=0; j<n_segments; j++)
|
||||
for (j=macro_segment; j < macro_segment_end; j++)
|
||||
channel_input[j][i] = (c[2*Zc+i]>>(j-macro_segment))&1;
|
||||
for (i=0;i<((nrows-no_punctured_columns) * Zc-removed_bit);i++)
|
||||
for (int j=macro_segment; j < macro_segment_end; j++)
|
||||
output[j][i] = (cc[2*Zc+i]>>(j-macro_segment))&1;
|
||||
for (int i=0;i<((nrows-no_punctured_columns) * Zc-removed_bit);i++)
|
||||
//for (j=0; j<n_segments; j++)
|
||||
for (j=macro_segment; j < macro_segment_end; j++)
|
||||
channel_input[j][block_length-2*Zc+i] = (d[i]>>(j-macro_segment))&1;
|
||||
for (int j=macro_segment; j < macro_segment_end; j++)
|
||||
output[j][block_length-2*Zc+i] = (dd[i]>>(j-macro_segment))&1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2009-2018, Intel Corporation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Common data types, macros and functions used across the CRC library */
|
||||
|
||||
#ifndef CRC_TYPES_H_
|
||||
#define CRC_TYPES_H_
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <asm/i387.h>
|
||||
#include <linux/types.h>
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* Declare variable at address aligned to a boundary */
|
||||
#define DECLARE_ALIGNED(_declaration, _boundary) \
|
||||
_declaration __attribute__((aligned(_boundary)))
|
||||
|
||||
/* Macro to make function to be always inlined */
|
||||
#ifndef DEBUG
|
||||
#define __forceinline \
|
||||
static inline __attribute__((always_inline))
|
||||
#else
|
||||
#define __forceinline \
|
||||
static
|
||||
#endif
|
||||
|
||||
/* Likely & unliekly hints for the compiler */
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
/* Macro to get dimension of an array */
|
||||
#ifndef DIM
|
||||
#define DIM(x) (sizeof(x)/sizeof(x[0]))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Common functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Swaps bytes in 16 bit word
|
||||
*
|
||||
* @param val 16 bit data value
|
||||
*
|
||||
* @return byte swapped value
|
||||
*/
|
||||
__forceinline uint16_t bswap2(const uint16_t val)
|
||||
{
|
||||
return (uint16_t) ((val >> 8) | (val << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swaps bytes in 32 bit word
|
||||
* ABCD -> DCBA
|
||||
*
|
||||
* @param val 32 bit data value
|
||||
*
|
||||
* @return byte swapped value
|
||||
*/
|
||||
__forceinline uint32_t bswap4(const uint32_t val)
|
||||
{
|
||||
return ((val >> 24) | /**< A*/
|
||||
((val & 0xff0000) >> 8) | /**< B*/
|
||||
((val & 0xff00) << 8) | /**< C*/
|
||||
(val << 24)); /**< D*/
|
||||
}
|
||||
|
||||
#endif /* CRC_TYPES_H_ */
|
||||
@@ -27,6 +27,58 @@
|
||||
uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, 120e3, 240e3};
|
||||
uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 8, 16};
|
||||
|
||||
// Table 5.4.3.3-1 38-101
|
||||
int nr_ssb_table[48][3] = {
|
||||
{1, 15, nr_ssb_type_A},
|
||||
{2, 15, nr_ssb_type_A},
|
||||
{3, 15, nr_ssb_type_A},
|
||||
{5, 15, nr_ssb_type_A},
|
||||
{5, 30, nr_ssb_type_B},
|
||||
{7, 15, nr_ssb_type_A},
|
||||
{8, 15, nr_ssb_type_A},
|
||||
{12, 15, nr_ssb_type_A},
|
||||
{14, 15, nr_ssb_type_A},
|
||||
{18, 15, nr_ssb_type_A},
|
||||
{20, 15, nr_ssb_type_A},
|
||||
{25, 15, nr_ssb_type_A},
|
||||
{26, 15, nr_ssb_type_A},
|
||||
{28, 15, nr_ssb_type_A},
|
||||
{29, 15, nr_ssb_type_A},
|
||||
{30, 15, nr_ssb_type_A},
|
||||
{34, 15, nr_ssb_type_A},
|
||||
{34, 30, nr_ssb_type_C},
|
||||
{38, 15, nr_ssb_type_A},
|
||||
{38, 30, nr_ssb_type_C},
|
||||
{39, 15, nr_ssb_type_A},
|
||||
{39, 30, nr_ssb_type_C},
|
||||
{40, 30, nr_ssb_type_C},
|
||||
{41, 15, nr_ssb_type_A},
|
||||
{41, 30, nr_ssb_type_C},
|
||||
{46, 30, nr_ssb_type_C},
|
||||
{48, 30, nr_ssb_type_C},
|
||||
{50, 30, nr_ssb_type_C},
|
||||
{51, 15, nr_ssb_type_A},
|
||||
{53, 15, nr_ssb_type_A},
|
||||
{65, 15, nr_ssb_type_A},
|
||||
{66, 15, nr_ssb_type_A},
|
||||
{66, 30, nr_ssb_type_B},
|
||||
{70, 15, nr_ssb_type_A},
|
||||
{71, 15, nr_ssb_type_A},
|
||||
{74, 15, nr_ssb_type_A},
|
||||
{75, 15, nr_ssb_type_A},
|
||||
{76, 15, nr_ssb_type_A},
|
||||
{77, 30, nr_ssb_type_C},
|
||||
{78, 30, nr_ssb_type_C},
|
||||
{79, 30, nr_ssb_type_C},
|
||||
{90, 15, nr_ssb_type_A},
|
||||
{90, 30, nr_ssb_type_C},
|
||||
{91, 15, nr_ssb_type_A},
|
||||
{92, 15, nr_ssb_type_A},
|
||||
{93, 15, nr_ssb_type_A},
|
||||
{94, 15, nr_ssb_type_A},
|
||||
{96, 30, nr_ssb_type_C}
|
||||
};
|
||||
|
||||
|
||||
void set_Lmax(NR_DL_FRAME_PARMS *fp) {
|
||||
// definition of Lmax according to ts 38.213 section 4.1
|
||||
@@ -85,27 +137,28 @@ int nr_get_ssb_start_symbol(NR_DL_FRAME_PARMS *fp,uint8_t i_ssb) {
|
||||
|
||||
void set_scs_parameters (NR_DL_FRAME_PARMS *fp, int mu, int N_RB_DL)
|
||||
{
|
||||
int idx = 0;
|
||||
switch(mu) {
|
||||
|
||||
case NR_MU_0: //15kHz scs
|
||||
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_0];
|
||||
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_0];
|
||||
fp->ssb_type = nr_ssb_type_A;
|
||||
while(nr_ssb_table[idx][0]!=fp->nr_band)
|
||||
idx++;
|
||||
AssertFatal(nr_ssb_table[idx][1]==15,"SCS %d not applicable to band %d\n",
|
||||
fp->subcarrier_spacing,fp->nr_band);
|
||||
break;
|
||||
|
||||
case NR_MU_1: //30kHz scs
|
||||
fp->subcarrier_spacing = nr_subcarrier_spacing[NR_MU_1];
|
||||
fp->slots_per_subframe = nr_slots_per_subframe[NR_MU_1];
|
||||
|
||||
// selection of SS block pattern according to TS 38101-1 Table 5.4.3.3-1 for SCS 30kHz
|
||||
if (fp->nr_band == 5 || fp->nr_band == 66)
|
||||
fp->ssb_type = nr_ssb_type_B;
|
||||
else{
|
||||
if (fp->nr_band == 41 || fp->nr_band == 38 || ( fp->nr_band > 76 && fp->nr_band < 80) )
|
||||
fp->ssb_type = nr_ssb_type_C;
|
||||
else
|
||||
AssertFatal(1==0,"NR Operating Band n%d not available for SS block SCS with mu=%d\n", fp->nr_band, mu);
|
||||
while(nr_ssb_table[idx][0]!=fp->nr_band ||
|
||||
nr_ssb_table[idx][1]!=30) {
|
||||
AssertFatal(nr_ssb_table[idx][0]<=fp->nr_band,"SCS %d not applicable to band %d\n",
|
||||
fp->subcarrier_spacing,fp->nr_band);
|
||||
idx++;
|
||||
}
|
||||
fp->ssb_type = nr_ssb_table[idx][2];
|
||||
break;
|
||||
|
||||
case NR_MU_2: //60kHz scs
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
//#define DEBUG_DCI_DECODING 1
|
||||
//#define DEBUG_PHY
|
||||
|
||||
//#undef ALL_AGGREGATION
|
||||
|
||||
//extern uint16_t phich_reg[MAX_NUM_PHICH_GROUPS][3];
|
||||
//extern uint16_t pcfich_reg[4];
|
||||
|
||||
|
||||
@@ -32,11 +32,8 @@
|
||||
#ifndef __DCI_NB_IOT_H__
|
||||
#define __DCI_NB_IOT_H__
|
||||
|
||||
//#ifndef USER_MODE
|
||||
//#include "PHY/types.h"
|
||||
//#else
|
||||
#include <stdint.h>
|
||||
//#endif
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -36,10 +36,8 @@
|
||||
#include "PHY/extern.h"
|
||||
#include "SCHED/extern.h"
|
||||
|
||||
#ifdef OPENAIR2
|
||||
#include "openair2/LAYER2/MAC/proto.h"
|
||||
#include "openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
|
||||
#endif
|
||||
|
||||
extern int mac_get_rrc_status(uint8_t Mod_id,uint8_t eNB_flag,uint8_t index);
|
||||
|
||||
@@ -434,10 +432,8 @@ int dump_ue_stats(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,char *buffer, int length
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef OPENAIR2
|
||||
RRC_status = mac_UE_get_rrc_status(ue->Mod_id, 0);
|
||||
len += sprintf(&buffer[len],"[UE PROC] RRC status = %d\n",RRC_status);
|
||||
#endif
|
||||
len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d \n",ue->transmission_mode[eNB]);
|
||||
len += sprintf(&buffer[len], "[UE PROC] PBCH err conseq %d, PBCH error total %d, PBCH FER %d\n",
|
||||
ue->pbch_vars[eNB]->pdu_errors_conseq,
|
||||
|
||||
@@ -321,4 +321,4 @@ HLC_subband_cqi_mcs_CBA_20MHz_NB_IoT;
|
||||
#define MAX_ACK_PAYLOAD_NB_IoT 18
|
||||
#define MAX_RI_PAYLOAD_NB_IoT 6
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,6 @@
|
||||
//#define DEBUG_DCI_DECODING 1
|
||||
//#define DEBUG_PHY
|
||||
|
||||
//#undef ALL_AGGREGATION
|
||||
|
||||
|
||||
uint16_t extract_crc(uint8_t *dci,uint8_t dci_len)
|
||||
{
|
||||
|
||||
@@ -2802,7 +2799,6 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue,
|
||||
if (dci_cnt>old_dci_cnt)
|
||||
return(dci_cnt);
|
||||
|
||||
//#ifdef ALL_AGGREGATION
|
||||
// Now check UE_SPEC format 1 search spaces at aggregation 8
|
||||
old_dci_cnt=dci_cnt;
|
||||
dci_decoding_procedure0(pdcch_vars,0,mode,subframe,
|
||||
@@ -2836,7 +2832,6 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue,
|
||||
if (dci_cnt>old_dci_cnt)
|
||||
return(dci_cnt);
|
||||
|
||||
//#endif //ALL_AGGREGATION
|
||||
} else if (tmode == 3) {
|
||||
|
||||
|
||||
@@ -2946,7 +2941,6 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue,
|
||||
if (dci_cnt>old_dci_cnt)
|
||||
return(dci_cnt);
|
||||
|
||||
//#ifdef ALL_AGGREGATION
|
||||
// Now check UE_SPEC format 2_2A search spaces at aggregation 8
|
||||
LOG_D(PHY," Now check UE_SPEC format 2_2A search spaces at aggregation 8 dci length: %d[bits] %d[bytes]\n",format2A_size_bits,format2A_size_bytes);
|
||||
old_dci_cnt=dci_cnt;
|
||||
@@ -3082,7 +3076,6 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue,
|
||||
if (dci_cnt>old_dci_cnt)
|
||||
return(dci_cnt);
|
||||
|
||||
//#ifdef ALL_AGGREGATION
|
||||
// Now check UE_SPEC format 2_2A search spaces at aggregation 8
|
||||
old_dci_cnt=dci_cnt;
|
||||
dci_decoding_procedure0(pdcch_vars,0,mode,
|
||||
@@ -3214,7 +3207,6 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue,
|
||||
if (dci_cnt>old_dci_cnt)
|
||||
return(dci_cnt);
|
||||
|
||||
//#ifdef ALL_AGGREGATION
|
||||
|
||||
// Now check UE_SPEC format 1E_2A_M10PRB search spaces at aggregation 8
|
||||
old_dci_cnt=dci_cnt;
|
||||
@@ -3249,7 +3241,6 @@ uint16_t dci_decoding_procedure(PHY_VARS_UE *ue,
|
||||
if (dci_cnt>old_dci_cnt)
|
||||
return(dci_cnt);
|
||||
|
||||
//#endif //ALL_AGGREGATION
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include <cblas.h>
|
||||
#include "linear_preprocessing_rec.h"
|
||||
|
||||
#define NOCYGWIN_STATIC
|
||||
//#define DEBUG_MMSE
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
//#define DEBUG_ULSCH_MODULATION
|
||||
|
||||
#ifndef OFDMA_ULSCH
|
||||
void dft_lte(int32_t *z,int32_t *d, int32_t Msc_PUSCH, uint8_t Nsymb)
|
||||
{
|
||||
|
||||
@@ -371,7 +370,6 @@ void dft_lte(int32_t *z,int32_t *d, int32_t Msc_PUSCH, uint8_t Nsymb)
|
||||
// printf("\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
void ulsch_modulation(int32_t **txdataF,
|
||||
short amp,
|
||||
uint32_t frame,
|
||||
@@ -690,57 +688,10 @@ void ulsch_modulation(int32_t **txdataF,
|
||||
|
||||
// Transform Precoding
|
||||
|
||||
#ifdef OFDMA_ULSCH
|
||||
|
||||
for (i=0; i<ulsch_Msymb; i++) {
|
||||
ulsch->z[i] = ulsch->d[i];
|
||||
}
|
||||
|
||||
#else
|
||||
dft_lte(ulsch->z,ulsch->d,Msc_PUSCH,ulsch->Nsymb_pusch);
|
||||
#endif
|
||||
|
||||
DevAssert(txdataF);
|
||||
|
||||
#ifdef OFDMA_ULSCH
|
||||
re_offset0 = frame_parms->first_carrier_offset + (ulsch->harq_processes[harq_pid]->first_rb*12);
|
||||
|
||||
if (re_offset0>frame_parms->ofdm_symbol_size) {
|
||||
re_offset0 -= frame_parms->ofdm_symbol_size;
|
||||
// re_offset0++;
|
||||
}
|
||||
|
||||
// printf("re_offset0 %d\n",re_offset0);
|
||||
|
||||
|
||||
for (j=0,l=0; l<(nsymb-ulsch->srs_active); l++) {
|
||||
re_offset = re_offset0;
|
||||
symbol_offset = (int)frame_parms->ofdm_symbol_size*(l+(subframe*nsymb));
|
||||
#ifdef DEBUG_ULSCH_MODULATION
|
||||
printf("symbol %d (subframe %d): symbol_offset %d\n",l,subframe,symbol_offset);
|
||||
#endif
|
||||
txptr = &txdataF[0][symbol_offset];
|
||||
|
||||
if (((frame_parms->Ncp == 0) && ((l==3) || (l==10)))||
|
||||
((frame_parms->Ncp == 1) && ((l==2) || (l==8)))) {
|
||||
}
|
||||
// Skip reference symbols
|
||||
else {
|
||||
|
||||
// printf("copying %d REs\n",Msc_PUSCH);
|
||||
for (i=0; i<Msc_PUSCH; i++,j++) {
|
||||
#ifdef DEBUG_ULSCH_MODULATION
|
||||
printf("re_offset %d (%p): %d,%d\n", re_offset,&ulsch->z[j],((int16_t*)&ulsch->z[j])[0],((int16_t*)&ulsch->z[j])[1]);
|
||||
#endif
|
||||
txptr[re_offset++] = ulsch->z[j];
|
||||
|
||||
if (re_offset==frame_parms->ofdm_symbol_size)
|
||||
re_offset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# else // OFDMA_ULSCH = 0
|
||||
re_offset0 = frame_parms->first_carrier_offset + (ulsch->harq_processes[harq_pid]->first_rb*12);
|
||||
|
||||
if (re_offset0>frame_parms->ofdm_symbol_size) {
|
||||
@@ -777,8 +728,5 @@ void ulsch_modulation(int32_t **txdataF,
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_ULSCH_MODULATION, VCD_FUNCTION_OUT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -180,9 +180,12 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
|
||||
/// CRC, coding, interleaving and rate matching
|
||||
AssertFatal(harq->pdu!=NULL,"harq->pdu is null\n");
|
||||
unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32)));
|
||||
bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
|
||||
start_meas(dlsch_encoding_stats);
|
||||
nr_dlsch_encoding(gNB,
|
||||
harq->pdu, frame, slot, dlsch, frame_parms,tinput,tprep,tparity,toutput,
|
||||
harq->pdu, frame, slot, dlsch, frame_parms, output,
|
||||
tinput,tprep,tparity,toutput,
|
||||
dlsch_rate_matching_stats,
|
||||
dlsch_interleaving_stats,
|
||||
dlsch_segmentation_stats);
|
||||
@@ -197,7 +200,7 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
printf("\nEncoded payload:\n");
|
||||
for (int i=0; i<encoded_length>>3; i++) {
|
||||
for (int j=0; j<8; j++)
|
||||
printf("%d", harq->f[(i<<3)+j]);
|
||||
printf("%d", output[(i<<3)+j]);
|
||||
printf("\t");
|
||||
}
|
||||
printf("\n");
|
||||
@@ -210,7 +213,7 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
for (int q=0; q<rel15->NrOfCodewords; q++)
|
||||
memset((void*)scrambled_output[q], 0, (encoded_length>>5)*sizeof(uint32_t));
|
||||
for (int q=0; q<rel15->NrOfCodewords; q++)
|
||||
nr_pdsch_codeword_scrambling_optim(harq->f,
|
||||
nr_pdsch_codeword_scrambling_optim(output,
|
||||
encoded_length,
|
||||
q,
|
||||
rel15->dataScramblingId,
|
||||
@@ -247,7 +250,7 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
start_meas(&gNB->dlsch_layer_mapping_stats);
|
||||
/// Layer mapping
|
||||
nr_layer_mapping(mod_symbs,
|
||||
rel15->nrOfLayers,
|
||||
@@ -265,6 +268,7 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
}
|
||||
#endif
|
||||
|
||||
stop_meas(&gNB->dlsch_layer_mapping_stats);
|
||||
/// Resource mapping
|
||||
|
||||
// Non interleaved VRB to PRB mapping
|
||||
@@ -278,7 +282,7 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
printf("PDSCH resource mapping started (start SC %d\tstart symbol %d\tN_PRB %d\tnb_re %d,nb_layers %d)\n",
|
||||
start_sc, rel15->StartSymbolIndex, rel15->rbSize, nb_re,rel15->nrOfLayers);
|
||||
#endif
|
||||
|
||||
start_meas(&gNB->dlsch_resource_mapping_stats);
|
||||
for (int ap=0; ap<rel15->nrOfLayers; ap++) {
|
||||
|
||||
// DMRS params for this ap
|
||||
@@ -320,20 +324,13 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
dmrs_idx = (rel15->rbStart+rel15->BWPStart)*4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update l_prime in the case of double DMRS config
|
||||
if ((dmrs_symbol_map & (1 << l))){ //DMRS time occasion
|
||||
if (l==(l_overline+1)) //take into account the double DMRS symbols
|
||||
l_prime = 1;
|
||||
else if (l>(l_overline+1)) {//new DMRS pair
|
||||
l_overline = l;
|
||||
l_prime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// DMRS QPSK modulation
|
||||
if (rel15->dlDmrsSymbPos & (1 << l)) {
|
||||
/// DMRS QPSK modulation
|
||||
nr_modulation(pdsch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated
|
||||
|
||||
#ifdef DEBUG_DLSCH
|
||||
@@ -358,69 +355,137 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
}
|
||||
}
|
||||
uint16_t k = start_sc;
|
||||
// Loop Over SCs:
|
||||
for (int i=0; i<rel15->rbSize*NR_NB_SC_PER_RB; i++) {
|
||||
/* check if cuurent RE is PTRS RE*/
|
||||
is_ptrs_re=0;
|
||||
/* check for PTRS symbol and set flag for PTRS RE */
|
||||
if(ptrs_symbol){
|
||||
is_ptrs_re = is_ptrs_subcarrier(k,
|
||||
rel15->rnti,
|
||||
ap,
|
||||
rel15->dmrsConfigType,
|
||||
rel15->PTRSFreqDensity,
|
||||
rel15->rbSize,
|
||||
rel15->PTRSReOffset,
|
||||
start_sc,
|
||||
frame_parms->ofdm_symbol_size);
|
||||
}
|
||||
if (ptrs_symbol || dmrs_symbol_map & (1 << l)) {
|
||||
|
||||
/* Map DMRS Symbol */
|
||||
if ( ( dmrs_symbol_map & (1 << l) ) && (k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_Type))%(frame_parms->ofdm_symbol_size)))) {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[dmrs_idx<<1]) >> 15;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
|
||||
// Loop Over SCs:
|
||||
for (int i=0; i<rel15->rbSize*NR_NB_SC_PER_RB; i++) {
|
||||
/* check if cuurent RE is PTRS RE*/
|
||||
is_ptrs_re = 0;
|
||||
if (ptrs_symbol)
|
||||
is_ptrs_re = is_ptrs_subcarrier(k,
|
||||
rel15->rnti,
|
||||
ap,
|
||||
rel15->dmrsConfigType,
|
||||
rel15->PTRSFreqDensity,
|
||||
rel15->rbSize,
|
||||
rel15->PTRSReOffset,
|
||||
start_sc,
|
||||
frame_parms->ofdm_symbol_size);
|
||||
/* Map DMRS Symbol */
|
||||
if ( (dmrs_symbol_map & (1 << l)) &&
|
||||
(k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_Type))%(frame_parms->ofdm_symbol_size)))) {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[dmrs_idx<<1]) >> 15;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15;
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n",
|
||||
dmrs_idx, l, k, k_prime, n, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
|
||||
printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n",
|
||||
dmrs_idx, l, k, k_prime, n, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
|
||||
#endif
|
||||
dmrs_idx++;
|
||||
k_prime++;
|
||||
k_prime&=1;
|
||||
n+=(k_prime)?0:1;
|
||||
}
|
||||
/* Map PTRS Symbol */
|
||||
else if(is_ptrs_re){
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (beta_ptrs*amp*mod_ptrs[ptrs_idx<<1]) >> 15;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (beta_ptrs*amp*mod_ptrs[(ptrs_idx<<1) + 1])>> 15;
|
||||
dmrs_idx++;
|
||||
k_prime++;
|
||||
k_prime&=1;
|
||||
n+=(k_prime)?0:1;
|
||||
}
|
||||
else if(is_ptrs_re){
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (beta_ptrs*amp*mod_ptrs[ptrs_idx<<1]) >> 15;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (beta_ptrs*amp*mod_ptrs[(ptrs_idx<<1) + 1])>> 15;
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
printf("ptrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n",
|
||||
ptrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
|
||||
((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
|
||||
printf("ptrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n",
|
||||
ptrs_idx, l, k, k_prime, n, ((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
|
||||
((int16_t*)txdataF[ap])[((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
|
||||
#endif
|
||||
ptrs_idx++;
|
||||
}
|
||||
ptrs_idx++;
|
||||
}
|
||||
/* Map DATA Symbol */
|
||||
else if( (!(dmrs_symbol_map & (1 << l))) || allowed_xlsch_re_in_dmrs_symbol(k,start_sc,frame_parms->ofdm_symbol_size,rel15->numDmrsCdmGrpsNoData,dmrs_Type)) {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (amp * tx_layers[ap][m<<1]) >> 15;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (amp * tx_layers[ap][(m<<1) + 1]) >> 15;
|
||||
else if( allowed_xlsch_re_in_dmrs_symbol(k,start_sc,frame_parms->ofdm_symbol_size,rel15->numDmrsCdmGrpsNoData,dmrs_Type)) {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (amp * tx_layers[ap][m<<1]) >> 15;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (amp * tx_layers[ap][(m<<1) + 1]) >> 15;
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
|
||||
m, l, k, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
|
||||
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
|
||||
m, l, k, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)],
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)]);
|
||||
#endif
|
||||
m++;
|
||||
m++;
|
||||
}
|
||||
/* mute RE */
|
||||
else {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0;
|
||||
}
|
||||
if (++k >= frame_parms->ofdm_symbol_size)
|
||||
k -= frame_parms->ofdm_symbol_size;
|
||||
} //RE loop
|
||||
}
|
||||
else { // no PTRS or DMRS in this symbol
|
||||
// Loop Over SCs:
|
||||
int upper_limit=rel15->rbSize*NR_NB_SC_PER_RB;
|
||||
int remaining_re = 0;
|
||||
if (start_sc + upper_limit > frame_parms->ofdm_symbol_size) {
|
||||
remaining_re = upper_limit + start_sc - frame_parms->ofdm_symbol_size;
|
||||
upper_limit = frame_parms->ofdm_symbol_size - start_sc;
|
||||
}
|
||||
if (0/*(frame_parms->N_RB_DL&1)==0*/) {
|
||||
__m128i *txF=(__m128i*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+start_sc+txdataF_offset)<<1)];
|
||||
|
||||
__m128i *txl = (__m128i*)&tx_layers[ap][m<<1];
|
||||
__m128i amp128=_mm_set1_epi16(amp);
|
||||
for (int i=0; i<(upper_limit>>2); i++) {
|
||||
txF[i] = _mm_mulhrs_epi16(amp128,txl[i]);
|
||||
} //RE loop, first part
|
||||
m+=upper_limit;
|
||||
if (remaining_re > 0) {
|
||||
txF = (__m128i*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+txdataF_offset)<<1)];
|
||||
txl = (__m128i*)&tx_layers[ap][m<<1];
|
||||
for (int i=0; i<(remaining_re>>2); i++) {
|
||||
txF[i] = _mm_mulhrs_epi16(amp128,txl[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* mute RE */
|
||||
else {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0;
|
||||
}
|
||||
if (++k >= frame_parms->ofdm_symbol_size)
|
||||
k -= frame_parms->ofdm_symbol_size;
|
||||
} //RE loop
|
||||
__m64 *txF=(__m64*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+start_sc+txdataF_offset)<<1)];
|
||||
|
||||
__m64 *txl = (__m64*)&tx_layers[ap][m<<1];
|
||||
__m64 amp64=_mm_set1_pi16(amp);
|
||||
for (int i=0; i<(upper_limit>>1); i++) {
|
||||
|
||||
txF[i] = _mm_mulhrs_pi16(amp64,txl[i]);
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
if ((i&1) > 0)
|
||||
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
|
||||
m, l, start_sc+(i>>1), txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + start_sc+(i>>1))<<1) + (2*txdataF_offset)],
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + start_sc+(i>>1))<<1) + 1 + (2*txdataF_offset)]);
|
||||
#endif
|
||||
/* handle this, mute RE */
|
||||
/*else {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0;
|
||||
}*/
|
||||
} //RE loop, first part
|
||||
m+=upper_limit;
|
||||
if (remaining_re > 0) {
|
||||
txF = (__m64*)&txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size+txdataF_offset)<<1)];
|
||||
txl = (__m64*)&tx_layers[ap][m<<1];
|
||||
for (int i=0; i<(remaining_re>>1); i++) {
|
||||
txF[i] = _mm_mulhrs_pi16(amp64,txl[i]);
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
if ((i&1) > 0)
|
||||
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
|
||||
m, l, i>>1, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + (i>>1))<<1) + (2*txdataF_offset)],
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + (i>>1))<<1) + 1 + (2*txdataF_offset)]);
|
||||
#endif
|
||||
/* handle this, mute RE */
|
||||
/*else {
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = 0;
|
||||
txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = 0;
|
||||
}*/
|
||||
} //RE loop, second part
|
||||
} //
|
||||
m+=remaining_re;
|
||||
} // N_RB_DL even
|
||||
} // no DMRS/PTRS in symbol
|
||||
} // symbol loop
|
||||
}// layer loop
|
||||
stop_meas(&gNB->dlsch_resource_mapping_stats);
|
||||
|
||||
///Layer Precoding and Antenna port mapping
|
||||
// tx_layers 1-8 are mapped on antenna ports 1000-1007
|
||||
@@ -429,7 +494,9 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
// pmi = prgs_list[rbidx/prg_size].pm_idx, rbidx =0,...,rbSize-1
|
||||
// The Precoding matrix:
|
||||
// The Codebook Type I and Type II are not supported yet.
|
||||
// We adopt the precoding matrices of PUSCH for 4 layers.
|
||||
// We`adopt the precoding matrices of PUSCH for 4 layers.
|
||||
start_meas(&gNB->dlsch_precoding_stats);
|
||||
|
||||
for (int ap=0; ap<frame_parms->nb_antennas_tx; ap++) {
|
||||
|
||||
for (int l=rel15->StartSymbolIndex; l<rel15->StartSymbolIndex+rel15->NrOfSymbols; l++) {
|
||||
@@ -504,6 +571,7 @@ uint8_t nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
} // symbol loop
|
||||
}// port loop
|
||||
|
||||
stop_meas(&gNB->dlsch_precoding_stats);
|
||||
dlsch->slot_tx[slot]=0;
|
||||
|
||||
// TODO: handle precoding
|
||||
|
||||
@@ -85,6 +85,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
|
||||
uint8_t slot,
|
||||
NR_gNB_DLSCH_t *dlsch,
|
||||
NR_DL_FRAME_PARMS* frame_parms,
|
||||
unsigned char * output,
|
||||
time_stats_t *tinput,
|
||||
time_stats_t *tprep,
|
||||
time_stats_t *tparity,
|
||||
|
||||
@@ -50,70 +50,47 @@
|
||||
//#define DEBUG_DLSCH_FREE 1
|
||||
|
||||
|
||||
void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB)
|
||||
{
|
||||
void free_gNB_dlsch(NR_gNB_DLSCH_t **dlschptr, uint16_t N_RB) {
|
||||
int r;
|
||||
|
||||
NR_gNB_DLSCH_t *dlsch = *dlschptr;
|
||||
|
||||
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
|
||||
if (dlsch) {
|
||||
|
||||
if (dlsch) {
|
||||
if (N_RB != 273) {
|
||||
a_segments = a_segments*N_RB;
|
||||
a_segments = a_segments/273 +1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY,"Freeing dlsch %p\n",dlsch);
|
||||
#endif
|
||||
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
|
||||
|
||||
if (harq->b) {
|
||||
free16(harq->b, a_segments * 1056);
|
||||
harq->b = NULL;
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY, "Freeing harq->b (%p)\n", harq->b);
|
||||
#endif
|
||||
|
||||
if (harq->e) {
|
||||
free16(harq->e, 14 * N_RB * 12 * 8);
|
||||
harq->e = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
printf("Freeing dlsch process %d e (%p)\n", i, harq->e);
|
||||
LOG_D(PHY, "Freeing dlsch process %d c (%p)\n", i, harq->c);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (harq->f) {
|
||||
free16(harq->f, 14 * N_RB * 12 * 8);
|
||||
harq->f = NULL;
|
||||
|
||||
for (r = 0; r < a_segments; r++) {
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
printf("Freeing dlsch process %d f (%p)\n", i, harq->f);
|
||||
LOG_D(PHY, "Freeing dlsch process %d c[%d] (%p)\n", i, r, harq->c[r]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY, "Freeing dlsch process %d c (%p)\n", i, harq->c);
|
||||
#endif
|
||||
|
||||
for (r = 0; r < a_segments; r++) {
|
||||
#ifdef DEBUG_DLSCH_FREE
|
||||
LOG_D(PHY, "Freeing dlsch process %d c[%d] (%p)\n", i, r, harq->c[r]);
|
||||
#endif
|
||||
|
||||
if (harq->c[r]) {
|
||||
free16(harq->c[r], 1056);
|
||||
harq->c[r] = NULL;
|
||||
}
|
||||
if (harq->d[r]) {
|
||||
free16(harq->d[r], 3 * 8448);
|
||||
harq->d[r] = NULL;
|
||||
}
|
||||
|
||||
if (harq->c[r]) {
|
||||
free16(harq->c[r], 1056);
|
||||
harq->c[r] = NULL;
|
||||
}
|
||||
}
|
||||
free16(dlsch, sizeof(NR_gNB_DLSCH_t));
|
||||
*dlschptr = NULL;
|
||||
}
|
||||
|
||||
free16(dlsch, sizeof(NR_gNB_DLSCH_t));
|
||||
*dlschptr = NULL;
|
||||
}
|
||||
|
||||
NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
@@ -121,8 +98,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
unsigned char Mdlharq,
|
||||
uint32_t Nsoft,
|
||||
uint8_t abstraction_flag,
|
||||
uint16_t N_RB)
|
||||
{
|
||||
uint16_t N_RB) {
|
||||
unsigned char i,r,aa,layer;
|
||||
int re;
|
||||
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
|
||||
@@ -133,10 +109,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
}
|
||||
|
||||
uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
|
||||
|
||||
NR_gNB_DLSCH_t *dlsch = malloc16(sizeof(NR_gNB_DLSCH_t));
|
||||
AssertFatal(dlsch, "cannot allocate dlsch\n");
|
||||
|
||||
bzero(dlsch,sizeof(NR_gNB_DLSCH_t));
|
||||
dlsch->Kmimo = Kmimo;
|
||||
dlsch->Mdlharq = Mdlharq;
|
||||
@@ -144,11 +118,12 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
dlsch->Nsoft = Nsoft;
|
||||
|
||||
for (layer=0; layer<NR_MAX_NB_LAYERS; layer++) {
|
||||
dlsch->ue_spec_bf_weights[layer] = (int32_t**)malloc16(64*sizeof(int32_t*));
|
||||
dlsch->ue_spec_bf_weights[layer] = (int32_t **)malloc16(64*sizeof(int32_t *));
|
||||
|
||||
for (aa=0; aa<64; aa++) {
|
||||
dlsch->ue_spec_bf_weights[layer][aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
|
||||
for (re=0;re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) {
|
||||
|
||||
for (re=0; re<OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES; re++) {
|
||||
dlsch->ue_spec_bf_weights[layer][aa][re] = 0x00007fff;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +135,8 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
for (int q=0; q<NR_MAX_NB_CODEWORDS; q++)
|
||||
dlsch->mod_symbs[q] = (int32_t *)malloc16(NR_MAX_PDSCH_ENCODED_LENGTH*sizeof(int32_t));
|
||||
|
||||
dlsch->calib_dl_ch_estimates = (int32_t**)malloc16(64*sizeof(int32_t*));
|
||||
dlsch->calib_dl_ch_estimates = (int32_t **)malloc16(64*sizeof(int32_t *));
|
||||
|
||||
for (aa=0; aa<64; aa++) {
|
||||
dlsch->calib_dl_ch_estimates[aa] = (int32_t *)malloc16(OFDM_SYMBOL_SIZE_COMPLEX_SAMPLES*sizeof(int32_t));
|
||||
}
|
||||
@@ -172,7 +148,6 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
|
||||
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
|
||||
bzero(harq, sizeof(NR_DL_gNB_HARQ_t));
|
||||
|
||||
harq->b = malloc16(dlsch_bytes);
|
||||
AssertFatal(harq->b, "cannot allocate memory for harq->b\n");
|
||||
harq->pdu = malloc16(dlsch_bytes);
|
||||
@@ -188,71 +163,33 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms,
|
||||
// In section 5.3.2 in 38.212, the for loop is up to N + 2*Zc (maximum size of N is 66*Zc, therefore 68*Zc)
|
||||
harq->c[r] = malloc16(8448);
|
||||
AssertFatal(harq->c[r], "cannot allocate harq->c[%d]\n", r);
|
||||
harq->d[r] = malloc16(68 * 384);
|
||||
AssertFatal(harq->d[r], "cannot allocate harq->d[%d]\n", r); // max size for coded output
|
||||
bzero(harq->c[r], 8448);
|
||||
bzero(harq->d[r], (3 * 8448));
|
||||
}
|
||||
|
||||
harq->e = malloc16(N_RB * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
|
||||
AssertFatal(harq->e, "cannot allocate harq->e\n");
|
||||
bzero(harq->e, N_RB * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
|
||||
harq->f = malloc16(N_RB * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
|
||||
AssertFatal(harq->f, "cannot allocate harq->f\n");
|
||||
bzero(harq->f, N_RB * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
|
||||
|
||||
return(dlsch);
|
||||
}
|
||||
|
||||
void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
|
||||
{
|
||||
|
||||
unsigned char Mdlharq;
|
||||
unsigned char i,j,r;
|
||||
|
||||
void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) {
|
||||
AssertFatal(dlsch!=NULL,"dlsch is null\n");
|
||||
Mdlharq = dlsch->Mdlharq;
|
||||
unsigned char Mdlharq = dlsch->Mdlharq;
|
||||
dlsch->rnti = 0;
|
||||
dlsch->active = 0;
|
||||
NR_DL_gNB_HARQ_t *harq=&dlsch->harq_process;
|
||||
|
||||
for (i=0; i<10; i++) {
|
||||
for (int i=0; i<10; i++) {
|
||||
dlsch->harq_ids[0][i] = Mdlharq;
|
||||
dlsch->harq_ids[1][i] = Mdlharq;
|
||||
}
|
||||
for (i=0; i<Mdlharq; i++) {
|
||||
for (j=0; j<96; j++)
|
||||
for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS; r++)
|
||||
if (harq->d[r])
|
||||
harq->d[r][j] = NR_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
|
||||
unsigned char *a,
|
||||
int frame,
|
||||
uint8_t slot,
|
||||
NR_gNB_DLSCH_t *dlsch,
|
||||
NR_DL_FRAME_PARMS* frame_parms,
|
||||
time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput,
|
||||
time_stats_t *dlsch_rate_matching_stats,time_stats_t *dlsch_interleaving_stats,
|
||||
time_stats_t *dlsch_segmentation_stats)
|
||||
{
|
||||
|
||||
unsigned int G;
|
||||
unsigned int crc=1;
|
||||
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
|
||||
void ldpc8blocks( void *p) {
|
||||
encoder_implemparams_t *impp=(encoder_implemparams_t *) p;
|
||||
NR_DL_gNB_HARQ_t *harq = (NR_DL_gNB_HARQ_t *)impp->harq;
|
||||
uint16_t Kr= impp->K;
|
||||
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15;
|
||||
uint8_t mod_order = rel15->qamModOrder[0];
|
||||
uint16_t nb_rb = rel15->rbSize;
|
||||
uint8_t nb_symb_sch = rel15->NrOfSymbols;
|
||||
uint32_t A, Kb, F=0;
|
||||
uint32_t *Zc = &dlsch->harq_process.Z;
|
||||
uint8_t mod_order = rel15->qamModOrder[0];
|
||||
uint16_t Kr=0,r;
|
||||
uint32_t r_offset=0;
|
||||
uint32_t E;
|
||||
uint8_t Ilbrm = 1;
|
||||
uint32_t Tbslbrm = 950984; //max tbs
|
||||
uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos);
|
||||
uint32_t A = rel15->TBSize[0]<<3;
|
||||
uint8_t nb_re_dmrs;
|
||||
|
||||
if (rel15->dmrsConfigType==NFAPI_NR_DMRS_TYPE1)
|
||||
@@ -260,24 +197,113 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
|
||||
else
|
||||
nb_re_dmrs = 4*rel15->numDmrsCdmGrpsNoData;
|
||||
|
||||
uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos);
|
||||
uint16_t R=rel15->targetCodeRate[0];
|
||||
unsigned int G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15->nrOfLayers);
|
||||
LOG_D(PHY,"dlsch coding A %d Kr %d G %d (nb_rb %d, nb_symb_sch %d, nb_re_dmrs %d, length_dmrs %d, mod_order %d)\n",
|
||||
A,impp->K,G, nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs,(int)mod_order);
|
||||
// nrLDPC_encoder output is in "d"
|
||||
// let's make this interface happy!
|
||||
uint8_t tmp[8][68 * 384]__attribute__((aligned(32)));
|
||||
for (int rr=impp->macro_num*8, i=0; rr < impp->n_segments && rr < (impp->macro_num+1)*8; rr++,i++ )
|
||||
impp->d[rr]=tmp[i];
|
||||
nrLDPC_encoder(harq->c,impp->d,*impp->Zc, impp->Kb,Kr,impp->BG,impp);
|
||||
// Compute where to place in output buffer that is concatenation of all segments
|
||||
uint32_t r_offset=0;
|
||||
for (int i=0; i < impp->macro_num*8; i++ )
|
||||
r_offset+=nr_get_E(G, impp->n_segments, mod_order, rel15->nrOfLayers, i);
|
||||
for (int rr=impp->macro_num*8; rr < impp->n_segments && rr < (impp->macro_num+1)*8; rr++ ) {
|
||||
if (impp->F>0) {
|
||||
// writing into positions d[r][k-2Zc] as in clause 5.3.2 step 2) in 38.212
|
||||
memset(&impp->d[rr][Kr-impp->F-2*(*impp->Zc)], impp->F, NR_NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
LOG_D(PHY,"rvidx in encoding = %d\n", rel15->rvIndex[0]);
|
||||
#endif
|
||||
uint32_t E = nr_get_E(G, impp->n_segments, mod_order, rel15->nrOfLayers, rr);
|
||||
//#ifdef DEBUG_DLSCH_CODING
|
||||
LOG_D(NR_PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n",
|
||||
rr,
|
||||
impp->n_segments,
|
||||
G,
|
||||
E,
|
||||
impp->F,
|
||||
Kr-impp->F-2*(*impp->Zc),
|
||||
mod_order,nb_rb);
|
||||
// for tbslbrm calculation according to 5.4.2.1 of 38.212
|
||||
uint8_t Nl = 4;
|
||||
|
||||
if (rel15->nrOfLayers < Nl)
|
||||
Nl = rel15->nrOfLayers;
|
||||
|
||||
uint32_t Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl);
|
||||
uint8_t Ilbrm = 1;
|
||||
|
||||
uint8_t e[E];
|
||||
bzero (e, E);
|
||||
nr_rate_matching_ldpc(Ilbrm,
|
||||
Tbslbrm,
|
||||
impp->BG,
|
||||
*impp->Zc,
|
||||
impp->d[rr],
|
||||
e,
|
||||
impp->n_segments,
|
||||
impp->F,
|
||||
Kr-impp->F-2*(*impp->Zc),
|
||||
rel15->rvIndex[0],
|
||||
E);
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
|
||||
for (int i =0; i<16; i++)
|
||||
printf("output ratematching e[%d]= %d r_offset %u\n", i,e[i], r_offset);
|
||||
|
||||
#endif
|
||||
nr_interleaving_ldpc(E,
|
||||
mod_order,
|
||||
e,
|
||||
impp->output+r_offset);
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
|
||||
for (int i =0; i<16; i++)
|
||||
printf("output interleaving f[%d]= %d r_offset %u\n", i,impp->output[i+r_offset], r_offset);
|
||||
|
||||
|
||||
#endif
|
||||
r_offset += E;
|
||||
}
|
||||
}
|
||||
|
||||
int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
|
||||
unsigned char *a,
|
||||
int frame,
|
||||
uint8_t slot,
|
||||
NR_gNB_DLSCH_t *dlsch,
|
||||
NR_DL_FRAME_PARMS *frame_parms,
|
||||
unsigned char * output,
|
||||
time_stats_t *tinput,time_stats_t *tprep,time_stats_t *tparity,time_stats_t *toutput,
|
||||
time_stats_t *dlsch_rate_matching_stats,time_stats_t *dlsch_interleaving_stats,
|
||||
time_stats_t *dlsch_segmentation_stats) {
|
||||
encoder_implemparams_t impp;
|
||||
impp.output=output;
|
||||
unsigned int crc=1;
|
||||
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
|
||||
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15;
|
||||
impp.Zc = &dlsch->harq_process.Z;
|
||||
float Coderate = 0.0;
|
||||
uint8_t Nl = 4;
|
||||
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN);
|
||||
uint32_t A = rel15->TBSize[0]<<3;
|
||||
|
||||
A = rel15->TBSize[0]<<3;
|
||||
if ( dlsch->rnti != SI_RNTI )
|
||||
trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, dlsch->rnti, frame, slot,0, 0);
|
||||
trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, dlsch->rnti, frame, slot,0, 0);
|
||||
|
||||
NR_gNB_SCH_STATS_t *stats=NULL;
|
||||
int first_free=-1;
|
||||
for (int i=0;i<NUMBER_OF_NR_SCH_STATS_MAX;i++) {
|
||||
|
||||
for (int i=0; i<NUMBER_OF_NR_SCH_STATS_MAX; i++) {
|
||||
if (gNB->dlsch_stats[i].rnti == 0 && first_free == -1) {
|
||||
first_free = i;
|
||||
stats=&gNB->dlsch_stats[i];
|
||||
}
|
||||
|
||||
if (gNB->dlsch_stats[i].rnti == dlsch->rnti) {
|
||||
stats=&gNB->dlsch_stats[i];
|
||||
break;
|
||||
@@ -290,179 +316,94 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
|
||||
stats->current_RI = rel15->nrOfLayers;
|
||||
stats->current_Qm = rel15->qamModOrder[0];
|
||||
}
|
||||
G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,rel15->nrOfLayers);
|
||||
|
||||
LOG_D(PHY,"dlsch coding A %d G %d (nb_rb %d, nb_symb_sch %d, nb_re_dmrs %d, length_dmrs %d, mod_order %d)\n",
|
||||
A,G, nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs,(int)mod_order);
|
||||
|
||||
if (A > 3824) {
|
||||
// Add 24-bit crc (polynomial A) to payload
|
||||
crc = crc24a(a,A)>>8;
|
||||
a[A>>3] = ((uint8_t*)&crc)[2];
|
||||
a[1+(A>>3)] = ((uint8_t*)&crc)[1];
|
||||
a[2+(A>>3)] = ((uint8_t*)&crc)[0];
|
||||
a[A>>3] = ((uint8_t *)&crc)[2];
|
||||
a[1+(A>>3)] = ((uint8_t *)&crc)[1];
|
||||
a[2+(A>>3)] = ((uint8_t *)&crc)[0];
|
||||
//printf("CRC %x (A %d)\n",crc,A);
|
||||
//printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]);
|
||||
|
||||
harq->B = A+24;
|
||||
// harq->b = a;
|
||||
|
||||
AssertFatal((A / 8) + 4 <= MAX_NR_DLSCH_PAYLOAD_BYTES,
|
||||
"A %d is too big (A/8+4 = %d > %d)\n",
|
||||
A,
|
||||
(A / 8) + 4,
|
||||
MAX_NR_DLSCH_PAYLOAD_BYTES);
|
||||
|
||||
memcpy(harq->b, a, (A / 8) + 4); // why is this +4 if the CRC is only 3 bytes?
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Add 16-bit crc (polynomial A) to payload
|
||||
crc = crc16(a,A)>>16;
|
||||
a[A>>3] = ((uint8_t*)&crc)[1];
|
||||
a[1+(A>>3)] = ((uint8_t*)&crc)[0];
|
||||
a[A>>3] = ((uint8_t *)&crc)[1];
|
||||
a[1+(A>>3)] = ((uint8_t *)&crc)[0];
|
||||
//printf("CRC %x (A %d)\n",crc,A);
|
||||
//printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]);
|
||||
|
||||
harq->B = A+16;
|
||||
// harq->b = a;
|
||||
|
||||
AssertFatal((A / 8) + 3 <= MAX_NR_DLSCH_PAYLOAD_BYTES,
|
||||
"A %d is too big (A/8+3 = %d > %d)\n",
|
||||
A,
|
||||
(A / 8) + 3,
|
||||
MAX_NR_DLSCH_PAYLOAD_BYTES);
|
||||
|
||||
memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc
|
||||
}
|
||||
if (R<1000)
|
||||
Coderate = (float) R /(float) 1024;
|
||||
|
||||
if (rel15->targetCodeRate[0]<1000)
|
||||
Coderate = (float)rel15->targetCodeRate[0] /(float) 1024;
|
||||
else // to scale for mcs 20 and 26 in table 5.1.3.1-2 which are decimal and input 2* in nr_tbs_tools
|
||||
Coderate = (float) R /(float) 2048;
|
||||
Coderate = (float)rel15->targetCodeRate[0] /(float) 2048;
|
||||
|
||||
if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25)
|
||||
harq->BG = 2;
|
||||
impp.BG = 2;
|
||||
else
|
||||
harq->BG = 1;
|
||||
impp.BG = 1;
|
||||
|
||||
start_meas(dlsch_segmentation_stats);
|
||||
Kb = nr_segmentation(harq->b, harq->c, harq->B, &harq->C, &harq->K, Zc, &harq->F, harq->BG);
|
||||
impp.Kb = nr_segmentation(harq->b, harq->c, harq->B, &impp.n_segments, &impp.K, impp.Zc, &impp.F, impp.BG);
|
||||
stop_meas(dlsch_segmentation_stats);
|
||||
F = harq->F;
|
||||
|
||||
Kr = harq->K;
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
uint16_t Kr_bytes;
|
||||
Kr_bytes = Kr>>3;
|
||||
#endif
|
||||
|
||||
//printf("segment Z %d k %d Kr %d BG %d C %d\n", *Zc,harq->K,Kr,BG,harq->C);
|
||||
|
||||
for (r=0; r<harq->C; r++) {
|
||||
for (int r=0; r<impp.n_segments; r++) {
|
||||
//d_tmp[r] = &harq->d[r][0];
|
||||
//channel_input[r] = &harq->d[r][0];
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
LOG_D(PHY,"Encoder: B %d F %d \n",harq->B, harq->F);
|
||||
LOG_D(PHY,"start ldpc encoder segment %d/%d\n",r,harq->C);
|
||||
LOG_D(PHY,"Encoder: B %d F %d \n",harq->B, impp.F);
|
||||
LOG_D(PHY,"start ldpc encoder segment %d/%d\n",r,impp.n_segments);
|
||||
LOG_D(PHY,"input %d %d %d %d %d \n", harq->c[r][0], harq->c[r][1], harq->c[r][2],harq->c[r][3], harq->c[r][4]);
|
||||
for (int cnt =0 ; cnt < 22*(*Zc)/8; cnt ++){
|
||||
|
||||
for (int cnt =0 ; cnt < 22*(*impp.Zc)/8; cnt ++) {
|
||||
LOG_D(PHY,"%d ", harq->c[r][cnt]);
|
||||
}
|
||||
LOG_D(PHY,"\n");
|
||||
|
||||
LOG_D(PHY,"\n");
|
||||
#endif
|
||||
//ldpc_encoder_orig((unsigned char*)harq->c[r],harq->d[r],*Zc,Kb,Kr,BG,0);
|
||||
//ldpc_encoder_optim((unsigned char*)harq->c[r],(unsigned char*)&harq->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL);
|
||||
}
|
||||
encoder_implemparams_t impp;
|
||||
impp.n_segments=harq->C;
|
||||
|
||||
impp.tprep = tprep;
|
||||
impp.tinput = tinput;
|
||||
impp.tparity = tparity;
|
||||
impp.toutput = toutput;
|
||||
|
||||
for(int j=0;j<(harq->C/8+1);j++) {
|
||||
impp.macro_num=j;
|
||||
nrLDPC_encoder(harq->c,harq->d,*Zc,Kb,Kr,harq->BG,&impp);
|
||||
impp.harq=harq;
|
||||
notifiedFIFO_t nf;
|
||||
initNotifiedFIFO(&nf);
|
||||
int nbJobs=0;
|
||||
for(int j=0; j<(impp.n_segments/8+((impp.n_segments&7)==0 ? 0 : 1)); j++) {
|
||||
notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(impp), j, &nf, ldpc8blocks);
|
||||
encoder_implemparams_t* perJobImpp=(encoder_implemparams_t*)NotifiedFifoData(req);
|
||||
*perJobImpp=impp;
|
||||
perJobImpp->macro_num=j;
|
||||
pushTpool(gNB->threadPool,req);
|
||||
nbJobs++;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
write_output("enc_input0.m","enc_in0",&harq->c[0][0],Kr_bytes,1,4);
|
||||
write_output("enc_output0.m","enc0",&harq->d[0][0],(3*8*Kr_bytes)+12,1,4);
|
||||
#endif
|
||||
|
||||
F = harq->F;
|
||||
|
||||
Kr = harq->K;
|
||||
for (r=0; r<harq->C; r++) {
|
||||
|
||||
if (F>0) {
|
||||
for (int k=(Kr-F-2*(*Zc)); k<Kr-2*(*Zc); k++) {
|
||||
// writing into positions d[r][k-2Zc] as in clause 5.3.2 step 2) in 38.212
|
||||
harq->d[r][k] = NR_NULL;
|
||||
//if (k<(Kr-F+8))
|
||||
//printf("r %d filler bits [%d] = %d \n", r,k, harq->d[r][k]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
LOG_D(PHY,"rvidx in encoding = %d\n", rel15->rvIndex[0]);
|
||||
#endif
|
||||
|
||||
E = nr_get_E(G, harq->C, mod_order, rel15->nrOfLayers, r);
|
||||
|
||||
//#ifdef DEBUG_DLSCH_CODING
|
||||
LOG_D(NR_PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n",
|
||||
r,
|
||||
harq->C,
|
||||
G,
|
||||
E,
|
||||
F,
|
||||
Kr-F-2*(*Zc),
|
||||
mod_order,nb_rb);
|
||||
|
||||
// for tbslbrm calculation according to 5.4.2.1 of 38.212
|
||||
if (rel15->nrOfLayers < Nl)
|
||||
Nl = rel15->nrOfLayers;
|
||||
|
||||
Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl);
|
||||
|
||||
start_meas(dlsch_rate_matching_stats);
|
||||
nr_rate_matching_ldpc(Ilbrm,
|
||||
Tbslbrm,
|
||||
harq->BG,
|
||||
*Zc,
|
||||
harq->d[r],
|
||||
harq->e+r_offset,
|
||||
harq->C,
|
||||
F,
|
||||
Kr-F-2*(*Zc),
|
||||
rel15->rvIndex[0],
|
||||
E);
|
||||
stop_meas(dlsch_rate_matching_stats);
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
for (int i =0; i<16; i++)
|
||||
printf("output ratematching e[%d]= %d r_offset %u\n", i,harq->e[i+r_offset], r_offset);
|
||||
#endif
|
||||
|
||||
start_meas(dlsch_interleaving_stats);
|
||||
nr_interleaving_ldpc(E,
|
||||
mod_order,
|
||||
harq->e+r_offset,
|
||||
harq->f+r_offset);
|
||||
stop_meas(dlsch_interleaving_stats);
|
||||
|
||||
#ifdef DEBUG_DLSCH_CODING
|
||||
for (int i =0; i<16; i++)
|
||||
printf("output interleaving f[%d]= %d r_offset %u\n", i,harq->f[i+r_offset], r_offset);
|
||||
|
||||
if (r==harq->C-1)
|
||||
write_output("enc_output.m","enc",harq->f,G,1,4);
|
||||
#endif
|
||||
|
||||
r_offset += E;
|
||||
while(nbJobs) {
|
||||
notifiedFIFO_elt_t *req=pullTpool(&nf, gNB->threadPool);
|
||||
delNotifiedFIFO_elt(req);
|
||||
nbJobs--;
|
||||
}
|
||||
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
|
||||
nr_sequences=8>>(1-pucch_pdu->sr_flag);
|
||||
}
|
||||
|
||||
LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, O_ACK %d, O_SR %d, mcs %d initial_cyclic_shift %d\n",pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,mcs[0],pucch_pdu->initial_cyclic_shift);
|
||||
LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, O_ACK %d, O_SR %d, mcs %d initial_cyclic_shift %d\n",
|
||||
pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->bit_len_harq,
|
||||
pucch_pdu->sr_flag,mcs[0],pucch_pdu->initial_cyclic_shift);
|
||||
|
||||
int cs_ind = get_pucch0_cs_lut_index(gNB,pucch_pdu);
|
||||
/*
|
||||
@@ -324,7 +326,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
|
||||
LOG_D(PHY,"PUCCH IDFT[%d/%d] = (%d,%d)=>%f\n",
|
||||
mcs[i],seq_index,corr_re[0][0],corr_im[0][0],
|
||||
10*log10((double)corr_re[0][0]*corr_re[0][0] + (double)corr_im[0][0]*corr_im[0][0]));
|
||||
if (pucch_pdu->nr_of_symbols==2)
|
||||
if (pucch_pdu->nr_of_symbols==2)
|
||||
LOG_D(PHY,"PUCCH 2nd symbol IDFT[%d/%d] = (%d,%d)=>%f\n",
|
||||
mcs[i],seq_index,corr_re[0][1],corr_im[0][1],
|
||||
10*log10((double)corr_re[0][1]*corr_re[0][1] + (double)corr_im[0][1]*corr_im[0][1]));
|
||||
@@ -428,8 +430,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
|
||||
uci_pdu->harq->harq_confidence_level = no_conf ? 1 : 0;
|
||||
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(1);
|
||||
uci_pdu->harq->harq_list[0].harq_value = index&0x01;
|
||||
LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n",
|
||||
frame,slot,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos);
|
||||
LOG_D(NR_PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ value %d SR_flag %d with confidence level (0 is good, 1 is bad) %d xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d, energy %f, sync_pos %d\n",
|
||||
frame,slot,uci_pdu->harq->harq_list[0].harq_value,pucch_pdu->sr_flag,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,10*log10((double)sigenergy),gNB->ulsch_stats[0].sync_pos);
|
||||
if (pucch_pdu->sr_flag == 1) {
|
||||
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
|
||||
uci_pdu->sr->sr_indication = (index>1) ? 1 : 0;
|
||||
@@ -445,8 +447,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
|
||||
uci_pdu->harq->harq_list = (nfapi_nr_harq_t*)malloc(2);
|
||||
uci_pdu->harq->harq_list[1].harq_value = index&0x01;
|
||||
uci_pdu->harq->harq_list[0].harq_value = (index>>1)&0x01;
|
||||
LOG_D(PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d and %d with confidence level (0 is good, 1 is bad) %d, xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n",
|
||||
frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,gNB->ulsch_stats[0].sync_pos);
|
||||
LOG_D(NR_PHY, "[DLSCH/PDSCH/PUCCH] %d.%d HARQ values %d and %d SR_flag %d with confidence level (0 is good, 1 is bad) %d, xrt_mag %d xrt_mag_next %d n0 %d (%d,%d) pucch0_thres %d, cqi %d, SNRtimes10 %d,sync_pos %d\n",
|
||||
frame,slot,uci_pdu->harq->harq_list[1].harq_value,uci_pdu->harq->harq_list[0].harq_value,pucch_pdu->sr_flag,uci_pdu->harq->harq_confidence_level,xrtmag_dBtimes10,xrtmag_next_dBtimes10,max_n0,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,cqi,SNRtimes10,gNB->ulsch_stats[0].sync_pos);
|
||||
if (pucch_pdu->sr_flag == 1) {
|
||||
uci_pdu->sr = calloc(1,sizeof(*uci_pdu->sr));
|
||||
uci_pdu->sr->sr_indication = (index>3) ? 1 : 0;
|
||||
|
||||
@@ -42,7 +42,6 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
|
||||
short coef)
|
||||
{
|
||||
|
||||
static int max_pos_fil = 0;
|
||||
static int count_max_pos_ok = 0;
|
||||
static int first_time = 1;
|
||||
int max_val = 0, max_pos = 0;
|
||||
@@ -55,13 +54,14 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
|
||||
|
||||
LOG_D(PHY,"AbsSubframe %d: rx_offset (before) = %d\n",subframe,ue->rx_offset);
|
||||
|
||||
// we only use channel estimates from tx antenna 0 here
|
||||
for (int i = 0; i < frame_parms->nb_prefix_samples; i++) {
|
||||
// search for maximum position within the cyclic prefix
|
||||
for (int i = -frame_parms->nb_prefix_samples/2; i < frame_parms->nb_prefix_samples/2; i++) {
|
||||
int temp = 0;
|
||||
|
||||
int j = (i < 0) ? (i + frame_parms->ofdm_symbol_size) : i;
|
||||
for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) {
|
||||
int Re = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[(i<<1)];
|
||||
int Im = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[1+(i<<1)];
|
||||
int Re = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[(j<<1)];
|
||||
int Im = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[1+(j<<1)];
|
||||
temp += (Re*Re/2) + (Im*Im/2);
|
||||
}
|
||||
|
||||
@@ -71,19 +71,16 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
|
||||
}
|
||||
}
|
||||
|
||||
if (max_pos > frame_parms->ofdm_symbol_size/2)
|
||||
max_pos = max_pos - frame_parms->ofdm_symbol_size;
|
||||
|
||||
// filter position to reduce jitter
|
||||
if (clear == 1)
|
||||
max_pos_fil = max_pos;
|
||||
ue->max_pos_fil = max_pos;
|
||||
else
|
||||
max_pos_fil = ((max_pos_fil * coef) + (max_pos * ncoef)) >> 15;
|
||||
ue->max_pos_fil = ((ue->max_pos_fil * coef) + (max_pos * ncoef)) >> 15;
|
||||
|
||||
// do not filter to have proactive timing adjustment
|
||||
//max_pos_fil = max_pos;
|
||||
//ue->max_pos_fil = max_pos;
|
||||
|
||||
int diff = max_pos_fil - sync_pos;
|
||||
int diff = ue->max_pos_fil - sync_pos;
|
||||
|
||||
if (frame_parms->freq_range==nr_FR2)
|
||||
sync_offset = 2;
|
||||
@@ -131,7 +128,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
|
||||
ue->rx_offset,
|
||||
clear,
|
||||
max_pos,
|
||||
max_pos_fil,
|
||||
ue->max_pos_fil,
|
||||
max_val,
|
||||
sync_pos);
|
||||
#endif //DEBUG_PHY
|
||||
|
||||
@@ -485,8 +485,8 @@ int nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
|
||||
|
||||
|
||||
#ifdef DEBUG_PDCCH
|
||||
printf("PDCCH Channel Estimation : ThreadId %d, gNB_id %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, k=%d symbol %d\n",proc->thread_id, gNB_id,ch_offset,ue->frame_parms.ofdm_symbol_size,
|
||||
ue->frame_parms.Ncp,Ns,k, symbol);
|
||||
printf("PDCCH Channel Estimation : ThreadId %d, gNB_id %d ch_offset %d, OFDM size %d, Ncp=%d, Ns=%d, symbol %d\n",
|
||||
proc->thread_id, gNB_id,ch_offset,ue->frame_parms.ofdm_symbol_size,ue->frame_parms.Ncp,Ns,symbol);
|
||||
#endif
|
||||
|
||||
fl = filt16a_l1;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,13 +33,7 @@
|
||||
#ifndef __PHY_NR_UE_TRANSPORT_DCI_NR__H__
|
||||
#define __PHY_NR_UE_TRANSPORT_DCI_NR__H__
|
||||
|
||||
#ifndef USER_MODE
|
||||
#include "PHY/types.h"
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define MAX_DCI_SIZE_BITS 45
|
||||
|
||||
|
||||
@@ -43,12 +43,6 @@
|
||||
#include "PHY/NR_REFSIG/dmrs_nr.h"
|
||||
#include "common/utils/nr/nr_common.h"
|
||||
|
||||
#ifndef USER_MODE
|
||||
#define NOCYGWIN_STATIC static
|
||||
#else
|
||||
#define NOCYGWIN_STATIC
|
||||
#endif
|
||||
|
||||
/* dynamic shift for LLR computation for TM3/4
|
||||
* set as command line argument, see lte-softmodem.c
|
||||
* default value: 0
|
||||
@@ -389,7 +383,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
|
||||
printf("[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n",
|
||||
frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n",
|
||||
LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n",
|
||||
frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
@@ -411,7 +405,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
|
||||
#if DISABLE_LOG_X
|
||||
printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
|
||||
if (first_symbol_flag==1) {
|
||||
@@ -472,7 +466,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
|
||||
#if DISABLE_LOG_X
|
||||
printf("[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
|
||||
@@ -524,7 +518,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
|
||||
#if DISABLE_LOG_X
|
||||
printf("[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
|
||||
|
||||
@@ -583,7 +577,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
|
||||
#if DISABLE_LOG_X
|
||||
printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
|
||||
/* Store the valid DL RE's */
|
||||
@@ -666,7 +660,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
|
||||
#if DISABLE_LOG_X
|
||||
printf("[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
LOG_D(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
// Please keep it: useful for debugging
|
||||
|
||||
@@ -485,9 +485,9 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
||||
|
||||
for(int n_ss = 0; n_ss<pdcch_vars->nb_search_space; n_ss++) {
|
||||
uint8_t nb_symb_pdcch = pdcch_vars->pdcch_config[n_ss].coreset.duration;
|
||||
int start_symb = pdcch_vars->pdcch_config[n_ss].coreset.StartSymbolIndex;
|
||||
get_coreset_rballoc(pdcch_vars->pdcch_config[n_ss].coreset.frequency_domain_resource,&coreset_nb_rb,&coreset_start_rb);
|
||||
|
||||
for (uint16_t l=0; l<nb_symb_pdcch; l++) {
|
||||
for (uint16_t l=start_symb; l<start_symb+nb_symb_pdcch; l++) {
|
||||
nr_slot_fep_init_sync(ue,
|
||||
proc,
|
||||
l, // the UE PHY has no notion of the symbols to be monitored in the search space
|
||||
|
||||
@@ -40,9 +40,7 @@
|
||||
//#define DEBUG_PBCH
|
||||
//#define DEBUG_PBCH_ENCODING
|
||||
|
||||
#ifdef OPENAIR2
|
||||
//#include "PHY_INTERFACE/defs.h"
|
||||
#endif
|
||||
|
||||
#define PBCH_A 24
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue,
|
||||
// the value of u,v (delta always 0 for PUCCH) has to be calculated according to TS 38.211 Subclause 6.3.2.2.1
|
||||
uint8_t u[2]={0,0},v[2]={0,0};
|
||||
|
||||
LOG_D(PHY,"pucch0: slot %d nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, mcs %d\n",nr_slot_tx,pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->mcs);
|
||||
|
||||
LOG_D(PHY,"pucch0: slot %d nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, mcs %d\n",
|
||||
nr_slot_tx,pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->mcs);
|
||||
|
||||
#ifdef DEBUG_NR_PUCCH_TX
|
||||
printf("\t [nr_generate_pucch0] sequence generation: variable initialization for test\n");
|
||||
|
||||
@@ -69,18 +69,12 @@ void reset_stats(FL_OBJECT *button, long arg) {
|
||||
|
||||
|
||||
static void *scope_thread_eNB(void *arg) {
|
||||
# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
FILE *eNB_stats;
|
||||
# endif
|
||||
struct sched_param sched_param;
|
||||
int UE_id, CC_id;
|
||||
int ue_cnt=0;
|
||||
sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1;
|
||||
sched_setscheduler(0, SCHED_FIFO,&sched_param);
|
||||
printf("Scope thread has priority %d\n",sched_param.sched_priority);
|
||||
# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
eNB_stats = fopen("eNB_stats.txt", "w");
|
||||
#endif
|
||||
|
||||
while (!oai_exit) {
|
||||
ue_cnt=0;
|
||||
@@ -99,16 +93,6 @@ static void *scope_thread_eNB(void *arg) {
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
// printf("%s",stats_buffer);
|
||||
# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
|
||||
if (eNB_stats) {
|
||||
rewind (eNB_stats);
|
||||
fwrite (stats_buffer, 1, len, eNB_stats);
|
||||
fclose (eNB_stats);
|
||||
}
|
||||
|
||||
# endif
|
||||
pthread_exit((void *)arg);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,16 +72,10 @@ void reset_stats(FL_OBJECT *button, long arg) {
|
||||
|
||||
static void *scope_thread_UE(void *arg) {
|
||||
char stats_buffer[16384];
|
||||
# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
FILE *UE_stats, *eNB_stats;
|
||||
# endif
|
||||
struct sched_param sched_param;
|
||||
sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1;
|
||||
sched_setscheduler(0, SCHED_FIFO,&sched_param);
|
||||
printf("Scope thread has priority %d\n",sched_param.sched_priority);
|
||||
# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
UE_stats = fopen("UE_stats.txt", "w");
|
||||
#endif
|
||||
|
||||
while (!oai_exit) {
|
||||
// dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm);
|
||||
@@ -94,16 +88,6 @@ static void *scope_thread_UE(void *arg) {
|
||||
0,7);
|
||||
// printf("%s",stats_buffer);
|
||||
}
|
||||
|
||||
# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
|
||||
if (UE_stats) {
|
||||
rewind (UE_stats);
|
||||
fwrite (stats_buffer, 1, len, UE_stats);
|
||||
fclose (UE_stats);
|
||||
}
|
||||
|
||||
# endif
|
||||
pthread_exit((void *)arg);
|
||||
}
|
||||
|
||||
|
||||
@@ -517,9 +517,6 @@ void phy_scope_gNB(OAI_phy_scope_t *form,
|
||||
}
|
||||
static void *scope_thread_gNB(void *arg) {
|
||||
scopeData_t *p=(scopeData_t *) arg;
|
||||
//# ifdef ENABLE_XFORMS_WRITE_STATS
|
||||
// FILE *gNB_stats = fopen("gNB_stats.txt", "w");
|
||||
//#endif
|
||||
size_t stksize=0;
|
||||
pthread_attr_t atr;
|
||||
pthread_attr_init(&atr);
|
||||
|
||||
@@ -128,6 +128,7 @@ static inline void start_meas(time_stats_t *ts) {
|
||||
} else {
|
||||
ts->in = rdtsc_oai();
|
||||
}
|
||||
if ((ts->trials&16383)<10) ts->max=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#ifdef MEX
|
||||
#define msg mexPrintf
|
||||
#else
|
||||
#ifdef OPENAIR2
|
||||
#if ENABLE_RAL
|
||||
#include "collection/hashtable/hashtable.h"
|
||||
#include "COMMON/ral_messages_types.h"
|
||||
@@ -56,9 +55,6 @@
|
||||
#endif
|
||||
#include "common/utils/LOG/log.h"
|
||||
#define msg(aRGS...) LOG_D(PHY, ##aRGS)
|
||||
#else
|
||||
#define msg printf
|
||||
#endif
|
||||
#endif
|
||||
//use msg in the real-time thread context
|
||||
#define msg_nrt printf
|
||||
@@ -196,19 +192,6 @@ typedef struct {
|
||||
NB_IoT_UE_DLSCH_t *dlsch_rn_MCH[10];
|
||||
|
||||
} PHY_VARS_RN_NB_IoT;
|
||||
/*
|
||||
#ifdef OCP_FRAMEWORK
|
||||
#include <enums.h>
|
||||
#else
|
||||
//typedef enum {normal_txrx=0,rx_calib_ue=1,rx_calib_ue_med=2,rx_calib_ue_byp=3,debug_prach=4,no_L2_connect=5,calib_prach_tx=6,rx_dump_frame=7,loop_through_memory=8} runmode_t;
|
||||
*/
|
||||
// enum transmission_access_mode {
|
||||
// NO_ACCESS=0,
|
||||
// POSTPONED_ACCESS,
|
||||
// CANCELED_ACCESS,
|
||||
// UNKNOWN_ACCESS,
|
||||
// SCHEDULED_ACCESS,
|
||||
// CBA_ACCESS};
|
||||
|
||||
typedef enum {
|
||||
eNodeB_3GPP_NB_IoT=0, // classical eNodeB function
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
#define LOG_W(x, ...) mexPrintf(__VA_ARGS__)
|
||||
#define LOG_M(x, ...) mexPrintf(__VA_ARGS__)
|
||||
#else
|
||||
#ifdef OPENAIR2
|
||||
#if ENABLE_RAL
|
||||
#include "collection/hashtable/hashtable.h"
|
||||
#include "COMMON/ral_messages_types.h"
|
||||
@@ -95,9 +94,6 @@
|
||||
#endif
|
||||
#include "common/utils/LOG/log.h"
|
||||
#define msg(aRGS...) LOG_D(PHY, ##aRGS)
|
||||
#else
|
||||
#define msg printf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
+4
-14
@@ -96,20 +96,6 @@ typedef struct {
|
||||
uint32_t subframe;
|
||||
/// MIMO mode for this DLSCH
|
||||
MIMO_mode_t mimo_mode;
|
||||
/// Concatenated sequences
|
||||
uint8_t *e;
|
||||
/// LDPC-code outputs
|
||||
uint8_t *d[MAX_NUM_NR_DLSCH_SEGMENTS];
|
||||
/// Interleaver outputs
|
||||
uint8_t *f;
|
||||
/// Number of code segments
|
||||
uint32_t C;
|
||||
/// Number of bits in "small" code segments
|
||||
uint32_t K;
|
||||
/// Number of "Filler" bits
|
||||
uint32_t F;
|
||||
/// Encoder BG
|
||||
uint8_t BG;
|
||||
/// LDPC lifting size
|
||||
uint32_t Z;
|
||||
} NR_DL_gNB_HARQ_t;
|
||||
@@ -868,6 +854,9 @@ typedef struct PHY_VARS_gNB_s {
|
||||
time_stats_t dlsch_encoding_stats;
|
||||
time_stats_t dlsch_modulation_stats;
|
||||
time_stats_t dlsch_scrambling_stats;
|
||||
time_stats_t dlsch_resource_mapping_stats;
|
||||
time_stats_t dlsch_layer_mapping_stats;
|
||||
time_stats_t dlsch_precoding_stats;
|
||||
time_stats_t tinput;
|
||||
time_stats_t tprep;
|
||||
time_stats_t tparity;
|
||||
@@ -879,6 +868,7 @@ typedef struct PHY_VARS_gNB_s {
|
||||
|
||||
time_stats_t rx_pusch_stats;
|
||||
time_stats_t ul_indication_stats;
|
||||
time_stats_t schedule_response_stats;
|
||||
time_stats_t ulsch_decoding_stats;
|
||||
time_stats_t ulsch_rate_unmatching_stats;
|
||||
time_stats_t ulsch_ldpc_decoding_stats;
|
||||
|
||||
@@ -51,16 +51,12 @@
|
||||
#ifdef MEX
|
||||
#define msg mexPrintf
|
||||
#else
|
||||
#ifdef OPENAIR2
|
||||
#if ENABLE_RAL
|
||||
#include "common/utils/hashtable/hashtable.h"
|
||||
#include "COMMON/ral_messages_types.h"
|
||||
#include "UTIL/queue.h"
|
||||
#endif
|
||||
#define msg(aRGS...) LOG_D(PHY, ##aRGS)
|
||||
#else
|
||||
#define msg printf
|
||||
#endif
|
||||
#endif
|
||||
//use msg in the real-time thread context
|
||||
#define msg_nrt printf
|
||||
@@ -638,7 +634,7 @@ typedef struct {
|
||||
uint8_t dciFormat;
|
||||
uint8_t agregationLevel;
|
||||
int nb_search_space;
|
||||
fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS_PER_CORESET];
|
||||
fapi_nr_dl_config_dci_dl_pdu_rel15_t pdcch_config[FAPI_NR_MAX_SS];
|
||||
// frame and slot for sib1 in initial sync
|
||||
uint16_t sfn;
|
||||
uint16_t slot;
|
||||
@@ -921,9 +917,10 @@ typedef struct {
|
||||
uint8_t init_sync_frame;
|
||||
/// temporary offset during cell search prior to MIB decoding
|
||||
int ssb_offset;
|
||||
uint16_t symbol_offset; // offset in terms of symbols for detected ssb in sync
|
||||
int rx_offset; /// Timing offset
|
||||
uint16_t symbol_offset; /// offset in terms of symbols for detected ssb in sync
|
||||
int rx_offset; /// Timing offset
|
||||
int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP
|
||||
int max_pos_fil; /// Timing offset IIR filter
|
||||
int time_sync_cell;
|
||||
|
||||
/// Timing Advance updates variables
|
||||
|
||||
@@ -55,12 +55,6 @@ extern char mode_string[4][20];
|
||||
extern unsigned char NB_RU;
|
||||
|
||||
|
||||
#ifndef OPENAIR2
|
||||
extern unsigned char NB_eNB_INST;
|
||||
extern uint16_t NB_UE_INST;
|
||||
extern unsigned char NB_RN_INST;
|
||||
#endif
|
||||
|
||||
extern int flag_LA;
|
||||
extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
|
||||
extern double sinr_bler_map_up[MCS_COUNT][2][16];
|
||||
|
||||
@@ -63,12 +63,6 @@ extern char mode_string[4][20];
|
||||
|
||||
extern unsigned char NB_RU;
|
||||
|
||||
#ifndef OPENAIR2
|
||||
extern unsigned char NB_eNB_INST;
|
||||
extern uint16_t NB_UE_INST;
|
||||
extern unsigned char NB_RN_INST;
|
||||
#endif
|
||||
|
||||
extern int flag_LA;
|
||||
extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
|
||||
extern double sinr_bler_map_up[MCS_COUNT][2][16];
|
||||
|
||||
@@ -53,12 +53,6 @@ extern int flagMag;
|
||||
extern char mode_string[4][20];
|
||||
|
||||
|
||||
#ifndef OPENAIR2
|
||||
extern unsigned char NB_eNB_INST;
|
||||
extern uint16_t NB_UE_INST;
|
||||
extern unsigned char NB_RN_INST;
|
||||
#endif
|
||||
|
||||
extern int flag_LA;
|
||||
extern double sinr_bler_map[MCS_COUNT][2][MCS_TABLE_LENGTH_MAX];
|
||||
extern double sinr_bler_map_up[MCS_COUNT][2][16];
|
||||
|
||||
@@ -55,13 +55,6 @@ const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1};
|
||||
|
||||
unsigned char NB_RU=0;
|
||||
|
||||
#ifndef OPENAIR2
|
||||
//unsigned char NB_eNB_INST=0;
|
||||
//uint16_t NB_UE_INST=0;
|
||||
//unsigned char NB_RN_INST=0;
|
||||
//unsigned char NB_INST=0;
|
||||
#endif
|
||||
|
||||
int number_of_cards;
|
||||
|
||||
|
||||
|
||||
@@ -57,13 +57,6 @@ const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1};
|
||||
|
||||
unsigned char NB_RU=0;
|
||||
|
||||
#ifndef OPENAIR2
|
||||
unsigned char NB_eNB_INST=0;
|
||||
uint16_t NB_UE_INST=0;
|
||||
unsigned char NB_RN_INST=0;
|
||||
unsigned char NB_INST=0;
|
||||
#endif
|
||||
|
||||
|
||||
int number_of_cards;
|
||||
|
||||
|
||||
@@ -47,14 +47,6 @@ const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1};
|
||||
#include "SIMULATION/ETH_TRANSPORT/vars.h"
|
||||
|
||||
|
||||
#ifndef OPENAIR2
|
||||
unsigned char NB_eNB_INST=0;
|
||||
uint16_t NB_UE_INST=0;
|
||||
unsigned char NB_RN_INST=0;
|
||||
unsigned char NB_INST=0;
|
||||
#endif
|
||||
|
||||
|
||||
int number_of_cards;
|
||||
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
#ifndef __openair_TYPES_NB_IOT_H__
|
||||
#define __openair_TYPES_NB_IOT_H__
|
||||
|
||||
#ifdef USER_MODE
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <linux/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*__openair_TYPES_NB_IOT_H__ */
|
||||
|
||||
@@ -148,7 +148,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){
|
||||
AssertFatal(RC.gNB[Mod_id]!=NULL,"RC.gNB[%d] is null\n",Mod_id);
|
||||
|
||||
gNB = RC.gNB[Mod_id];
|
||||
|
||||
start_meas(&gNB->schedule_response_stats);
|
||||
notifiedFIFO_elt_t *res;
|
||||
res = pullTpool(gNB->resp_L1_tx, gNB->threadPool);
|
||||
processingData_L1tx_t *msgTx = (processingData_L1tx_t *)NotifiedFifoData(res);
|
||||
@@ -248,5 +248,5 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){
|
||||
oai_nfapi_tx_data_req(TX_req);
|
||||
|
||||
}
|
||||
|
||||
stop_meas(&gNB->schedule_response_stats);
|
||||
}
|
||||
|
||||
@@ -401,10 +401,8 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH
|
||||
|
||||
void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id, uint8_t harq_pid, uint8_t crc_flag, int dtx_flag) {
|
||||
|
||||
pthread_mutex_lock(&gNB->UL_INFO_mutex);
|
||||
//pthread_mutex_lock(&gNB->UL_INFO_mutex);
|
||||
|
||||
int timing_advance_update, cqi;
|
||||
int sync_pos;
|
||||
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0];
|
||||
NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid];
|
||||
NR_gNB_SCH_STATS_t *stats=get_ulsch_stats(gNB,ulsch);
|
||||
@@ -412,19 +410,20 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,
|
||||
nfapi_nr_pusch_pdu_t *pusch_pdu = &harq_process->ulsch_pdu;
|
||||
|
||||
// pdu->data = gNB->ulsch[ULSCH_id+1][0]->harq_processes[harq_pid]->b;
|
||||
sync_pos = nr_est_timing_advance_pusch(gNB, ULSCH_id); // estimate timing advance for MAC
|
||||
int sync_pos = nr_est_timing_advance_pusch(gNB, ULSCH_id); // estimate timing advance for MAC
|
||||
|
||||
// scale the 16 factor in N_TA calculation in 38.213 section 4.2 according to the used FFT size
|
||||
uint16_t bw_scaling = 16 * gNB->frame_parms.ofdm_symbol_size / 2048;
|
||||
int sync_pos_rounded;
|
||||
|
||||
// do some integer rounding to improve TA accuracy
|
||||
int sync_pos_rounded;
|
||||
if (sync_pos > 0)
|
||||
sync_pos_rounded = sync_pos + (bw_scaling / 2) - 1;
|
||||
else
|
||||
sync_pos_rounded = sync_pos - (bw_scaling / 2) - 1;
|
||||
sync_pos_rounded = sync_pos - (bw_scaling / 2) + 1;
|
||||
if (stats) stats->sync_pos = sync_pos;
|
||||
|
||||
timing_advance_update = sync_pos_rounded / bw_scaling;
|
||||
int timing_advance_update = sync_pos_rounded / bw_scaling;
|
||||
|
||||
// put timing advance command in 0..63 range
|
||||
timing_advance_update += 31;
|
||||
@@ -449,6 +448,7 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,
|
||||
|
||||
LOG_D(PHY, "Estimated SNR for PUSCH is = %f dB (ulsch_power %f, noise %f)\n", SNRtimes10/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot)/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot)/10.0);
|
||||
|
||||
int cqi;
|
||||
if (SNRtimes10 < -640) cqi=0;
|
||||
else if (SNRtimes10 > 635) cqi=255;
|
||||
else cqi=(640+SNRtimes10)/5;
|
||||
@@ -526,7 +526,7 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,
|
||||
|
||||
gNB->UL_INFO.rx_ind.number_of_pdus++;
|
||||
|
||||
pthread_mutex_unlock(&gNB->UL_INFO_mutex);
|
||||
// pthread_mutex_unlock(&gNB->UL_INFO_mutex);
|
||||
}
|
||||
|
||||
// Function to fill UL RB mask to be used for N0 measurements
|
||||
|
||||
@@ -44,4 +44,4 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response);
|
||||
int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -779,7 +779,8 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_
|
||||
uint16_t s1 = dlsch0_harq->nb_symbols;
|
||||
bool is_SI = dlsch0->rnti_type == _SI_RNTI_;
|
||||
|
||||
LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_slot_rx %d, harq_pid %d (%d), rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x\n",ue->Mod_id,pdsch,nr_slot_rx,harq_pid,dlsch0_harq->status,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0_harq->dlDmrsSymbPos);
|
||||
LOG_D(PHY,"[UE %d] PDSCH type %d active in nr_slot_rx %d, harq_pid %d (%d), rb_start %d, nb_rb %d, symbol_start %d, nb_symbols %d, DMRS mask %x\n",
|
||||
ue->Mod_id,pdsch,nr_slot_rx,harq_pid,dlsch0_harq->status,pdsch_start_rb,pdsch_nb_rb,s0,s1,dlsch0_harq->dlDmrsSymbPos);
|
||||
|
||||
for (m = s0; m < (s0 +s1); m++) {
|
||||
if (dlsch0_harq->dlDmrsSymbPos & (1 << m)) {
|
||||
@@ -854,11 +855,7 @@ int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, int gNB_
|
||||
} else AssertFatal(1==0,"Not RA_PDSCH, SI_PDSCH or PDSCH\n");
|
||||
|
||||
stop_meas(&ue->dlsch_llr_stats_parallelization[proc->thread_id][slot]);
|
||||
#if PHYSIM
|
||||
printf("[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_D(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",frame_rx,nr_slot_rx,m,ue->dlsch_llr_stats_parallelization[proc->thread_id][slot].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
if(first_symbol_flag) {
|
||||
proc->first_symbol_available = 1;
|
||||
@@ -1052,17 +1049,10 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
|
||||
|
||||
|
||||
stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]);
|
||||
#if PHYSIM
|
||||
printf(" --> Unscrambling for CW0 %5.3f\n",
|
||||
(ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
|
||||
printf("AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n",
|
||||
frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_I(PHY, " --> Unscrambling for CW0 %5.3f\n",
|
||||
LOG_D(PHY, " --> Unscrambling for CW0 %5.3f\n",
|
||||
(ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
|
||||
LOG_I(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n",
|
||||
LOG_D(PHY, "AbsSubframe %d.%d --> LDPC Decoding for CW0 %5.3f\n",
|
||||
frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
if(is_cw1_active) {
|
||||
// start ldpc decode for CW 1
|
||||
@@ -1128,17 +1118,10 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
|
||||
|
||||
|
||||
stop_meas(&ue->dlsch_decoding_stats[proc->thread_id]);
|
||||
#if PHYSIM
|
||||
printf(" --> Unscrambling for CW1 %5.3f\n",
|
||||
(ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
|
||||
printf("AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n",
|
||||
frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_D(PHY, " --> Unscrambling for CW1 %5.3f\n",
|
||||
(ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0));
|
||||
LOG_D(PHY, "AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n",
|
||||
frame_rx%1024, nr_slot_rx,(ue->dlsch_decoding_stats[proc->thread_id].p_time)/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
|
||||
LOG_D(PHY,"AbsSubframe %d.%d --> ldpc Decoding for CW1 %5.3f\n",
|
||||
@@ -1449,11 +1432,7 @@ void *UE_thread_slot1_dl_processing(void *arg) {
|
||||
|
||||
|
||||
stop_meas(&ue->ue_front_end_per_slot_stat[proc->thread_id][1]);
|
||||
#if PHYSIM
|
||||
printf("[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_D(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,nr_slot_rx,ue->ue_front_end_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
|
||||
//wait until pdcch is decoded
|
||||
@@ -1543,11 +1522,7 @@ void *UE_thread_slot1_dl_processing(void *arg) {
|
||||
//printf("Set available LLR slot1 to 1 AbsSubframe %d.%d \n",frame_rx,nr_slot_rx);
|
||||
|
||||
stop_meas(&ue->pdsch_procedures_per_slot_stat[proc->thread_id][1]);
|
||||
#if PHYSIM
|
||||
printf("[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_D(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,nr_slot_rx,ue->pdsch_procedures_per_slot_stat[proc->thread_id][1].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) {
|
||||
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" );
|
||||
@@ -1744,8 +1719,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
|
||||
for (uint16_t l=0; l<nb_symb_pdcch; l++) {
|
||||
|
||||
// note: this only works if RBs for PDCCH are contigous!
|
||||
LOG_D(PHY, "pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d\n",
|
||||
fp->first_carrier_offset, pdcch_vars->pdcch_config[n_ss].BWPStart, coreset_start_rb);
|
||||
LOG_D(PHY, "pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d, coreset_nb_rb %d\n",
|
||||
fp->first_carrier_offset, pdcch_vars->pdcch_config[n_ss].BWPStart, coreset_start_rb, coreset_nb_rb);
|
||||
|
||||
if (coreset_nb_rb > 0)
|
||||
nr_pdcch_channel_estimation(ue,
|
||||
@@ -1917,13 +1892,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
|
||||
dlsch_parallel);
|
||||
|
||||
stop_meas(&ue->dlsch_procedures_stat[proc->thread_id]);
|
||||
#if PHYSIM
|
||||
printf("[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
|
||||
printf("[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_D(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",nr_slot_rx,ue->pdsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
|
||||
LOG_D(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",nr_slot_rx,ue->dlsch_procedures_stat[proc->thread_id].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -2000,9 +1970,6 @@ if (nr_slot_rx==9) {
|
||||
}
|
||||
|
||||
stop_meas(&ue->generic_stat);
|
||||
#if PHYSIM
|
||||
printf("after tubo until end of Rx %5.2f \n",ue->generic_stat.p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
#ifdef EMOS
|
||||
phy_procedures_emos_UE_RX(ue,slot,gNB_id);
|
||||
@@ -2012,11 +1979,7 @@ phy_procedures_emos_UE_RX(ue,slot,gNB_id);
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT);
|
||||
|
||||
stop_meas(&ue->phy_proc_rx[proc->thread_id]);
|
||||
#if PHYSIM
|
||||
printf("------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0));
|
||||
#else
|
||||
LOG_D(PHY, "------FULL RX PROC [SFN %d]: %5.2f ------\n",nr_slot_rx,ue->phy_proc_rx[proc->thread_id].p_time/(cpuf*1000.0));
|
||||
#endif
|
||||
|
||||
//#endif //pdsch
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<gpib/ib.h>
|
||||
#include"gpib_send.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <gpib/ib.h>
|
||||
#include "gpib_send.h"
|
||||
void gpib_send(unsigned int gpib_board, unsigned int gpib_device, char *command_string )
|
||||
{
|
||||
unsigned short addlist[2] = {gpib_device, NOADDR};
|
||||
|
||||
@@ -68,6 +68,7 @@ uint16_t n_rnti = 0x1234;
|
||||
openair0_config_t openair0_cfg[MAX_CARDS];
|
||||
|
||||
void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {}
|
||||
void processSlotTX(void *arg) {}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -116,8 +117,10 @@ int main(int argc, char **argv)
|
||||
uint8_t Imcs = 9;
|
||||
uint8_t mcs_table = 0;
|
||||
double DS_TDL = .03;
|
||||
cpuf = get_cpu_freq_GHz();
|
||||
cpuf = get_cpu_freq_GHz();
|
||||
char gNBthreads[128]="n";
|
||||
|
||||
|
||||
if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) {
|
||||
exit_fun("[NR_DLSCHSIM] Error, configuration module init failed\n");
|
||||
}
|
||||
@@ -426,9 +429,22 @@ int main(int argc, char **argv)
|
||||
UE->dlsch_SI[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
|
||||
UE->dlsch_ra[0] = new_nr_ue_dlsch(1, 1, Nsoft, 5, N_RB_DL, 0);
|
||||
unsigned char harq_pid = 0; //dlsch->harq_ids[subframe];
|
||||
processingData_L1tx_t msgDataTx;
|
||||
init_DLSCH_struct(gNB, &msgDataTx);
|
||||
NR_gNB_DLSCH_t *dlsch = msgDataTx.dlsch[0][0];
|
||||
|
||||
gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
|
||||
initTpool(gNBthreads, gNB->threadPool, true);
|
||||
gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
|
||||
initNotifiedFIFO(gNB->resp_L1_tx);
|
||||
// we create 2 threads for L1 tx processing
|
||||
notifiedFIFO_elt_t *msgL1Tx = newNotifiedFIFO_elt(sizeof(processingData_L1tx_t),0,gNB->resp_L1_tx,processSlotTX);
|
||||
processingData_L1tx_t *msgDataTx = (processingData_L1tx_t *)NotifiedFifoData(msgL1Tx);
|
||||
init_DLSCH_struct(gNB, msgDataTx);
|
||||
msgDataTx->slot = slot;
|
||||
msgDataTx->frame = frame;
|
||||
memset(msgDataTx->ssb, 0, 64*sizeof(NR_gNB_SSB_t));
|
||||
reset_meas(&msgDataTx->phy_proc_tx);
|
||||
gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx;
|
||||
pushTpool(gNB->threadPool,msgL1Tx);
|
||||
NR_gNB_DLSCH_t *dlsch = msgDataTx->dlsch[0][0];
|
||||
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->harq_process.pdsch_pdu.pdsch_pdu_rel15;
|
||||
//time_stats_t *rm_stats, *te_stats, *i_stats;
|
||||
uint8_t is_crnti = 0, llr8_flag = 0;
|
||||
@@ -501,10 +517,13 @@ int main(int argc, char **argv)
|
||||
/*for (int i=0; i<TBS/8; i++)
|
||||
printf("test input[%d]=%d \n",i,test_input[i]);*/
|
||||
|
||||
|
||||
//printf("crc32: [0]->0x%08x\n",crc24c(test_input, 32));
|
||||
// generate signal
|
||||
unsigned char output[rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS] __attribute__((aligned(32)));
|
||||
bzero(output,rel15->rbSize * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
|
||||
if (input_fd == NULL) {
|
||||
nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
|
||||
nr_dlsch_encoding(gNB, test_input, frame, slot, dlsch, frame_parms,output,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
|
||||
}
|
||||
|
||||
for (SNR = snr0; SNR < snr1; SNR += snr_step) {
|
||||
@@ -521,11 +540,12 @@ int main(int argc, char **argv)
|
||||
|
||||
//if (i<16)
|
||||
// printf("encoder output f[%d] = %d\n",i,dlsch->harq_processes[0]->f[i]);
|
||||
/*
|
||||
if (dlsch->harq_process.f[i] == 0)
|
||||
modulated_input[i] = 1.0; ///sqrt(2); //QPSK
|
||||
else
|
||||
modulated_input[i] = -1.0; ///sqrt(2);
|
||||
|
||||
*/
|
||||
//if (i<16) printf("modulated_input[%d] = %d\n",i,modulated_input[i]);
|
||||
//SNR =10;
|
||||
SNR_lin = pow(10, SNR / 10.0);
|
||||
@@ -548,9 +568,10 @@ int main(int argc, char **argv)
|
||||
channel_output_uncoded[i] = 1; //QPSK demod
|
||||
else
|
||||
channel_output_uncoded[i] = 0;
|
||||
|
||||
/*
|
||||
if (channel_output_uncoded[i] != dlsch->harq_process.f[i])
|
||||
errors_bit_uncoded = errors_bit_uncoded + 1;
|
||||
*/
|
||||
}
|
||||
|
||||
//if (errors_bit_uncoded>10)
|
||||
@@ -636,7 +657,7 @@ int main(int argc, char **argv)
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
printf("gNB %d\n", i);
|
||||
free_gNB_dlsch(&(msgDataTx.dlsch[0][i]),N_RB_DL);
|
||||
free_gNB_dlsch(&(msgDataTx->dlsch[0][i]),N_RB_DL);
|
||||
printf("UE %d\n", i);
|
||||
free_nr_ue_dlsch(&(UE->dlsch[0][0][i]),N_RB_DL);
|
||||
}
|
||||
|
||||
@@ -371,6 +371,7 @@ int main(int argc, char **argv)
|
||||
uint8_t n_tx=1,n_rx=1;
|
||||
uint8_t round;
|
||||
uint8_t num_rounds = 4;
|
||||
char gNBthreads[128]="n";
|
||||
|
||||
channel_desc_t *gNB2UE;
|
||||
//uint32_t nsymb,tx_lev,tx_lev1 = 0,tx_lev2 = 0;
|
||||
@@ -432,9 +433,7 @@ int main(int argc, char **argv)
|
||||
|
||||
FILE *scg_fd=NULL;
|
||||
|
||||
|
||||
while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:D:e:m:w:T:U:q")) != -1) {
|
||||
|
||||
while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:d:e:m:w:T:U:qX:")) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
scg_fd = fopen(optarg,"r");
|
||||
@@ -637,7 +636,12 @@ int main(int argc, char **argv)
|
||||
dmrs_arg[i] = atoi(argv[optind++]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'X':
|
||||
strncpy(gNBthreads, optarg, sizeof(gNBthreads));
|
||||
gNBthreads[sizeof(gNBthreads)-1]=0;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'h':
|
||||
printf("%s -h(elp) -p(extended_prefix) -N cell_id -f output_filename -F input_filename -g channel_model -n n_frames -t Delayspread -s snr0 -S snr1 -x transmission_mode -y TXant -z RXant -i Intefrence0 -j Interference1 -A interpolation_file -C(alibration offset dB) -N CellId\n",
|
||||
@@ -673,7 +677,8 @@ int main(int argc, char **argv)
|
||||
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n");
|
||||
printf("-P Print DLSCH performances\n");
|
||||
printf("-w Write txdata to binary file (one frame)\n");
|
||||
printf("-D number of dlsch threads, 0: no dlsch parallelization\n");
|
||||
printf("-d number of dlsch threads, 0: no dlsch parallelization\n");
|
||||
printf("-X gNB thread pool configuration, n => no threads");
|
||||
exit (-1);
|
||||
break;
|
||||
}
|
||||
@@ -829,6 +834,14 @@ int main(int argc, char **argv)
|
||||
fs = 61.44e6;
|
||||
bw = 40e6;
|
||||
}
|
||||
else if (mu == 1 && N_RB_DL == 133) {
|
||||
fs = 61.44e6;
|
||||
bw = 50e6;
|
||||
}
|
||||
else if (mu == 1 && N_RB_DL == 162) {
|
||||
fs = 61.44e6;
|
||||
bw = 60e6;
|
||||
}
|
||||
else if (mu == 3 && N_RB_DL == 66) {
|
||||
fs = 122.88e6;
|
||||
bw = 100e6;
|
||||
@@ -968,8 +981,7 @@ int main(int argc, char **argv)
|
||||
snrRun = 0;
|
||||
|
||||
gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
|
||||
char tp_param[] = "n";
|
||||
initTpool(tp_param, gNB->threadPool, true);
|
||||
initTpool(gNBthreads, gNB->threadPool, true);
|
||||
gNB->resp_L1_tx = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
|
||||
initNotifiedFIFO(gNB->resp_L1_tx);
|
||||
// we create 2 threads for L1 tx processing
|
||||
@@ -1223,8 +1235,8 @@ int main(int argc, char **argv)
|
||||
UE->dlsch[UE_proc.thread_id][0][0]->max_ldpc_iterations+1)
|
||||
n_errors++;
|
||||
|
||||
NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars[UE_proc.thread_id];
|
||||
int16_t *UE_llr = pdsch_vars[0]->llr[0];
|
||||
//NR_UE_PDSCH **pdsch_vars = UE->pdsch_vars[UE_proc.thread_id];
|
||||
//int16_t *UE_llr = pdsch_vars[0]->llr[0];
|
||||
|
||||
TBS = UE_harq_process->TBS;//rel15->TBSize[0];
|
||||
uint16_t length_dmrs = get_num_dmrs(rel15->dlDmrsSymbPos);
|
||||
@@ -1239,6 +1251,7 @@ int main(int argc, char **argv)
|
||||
printf("[DLSIM][PTRS] Available bits are: %5u, removed PTRS bits are: %5u \n",available_bits, (ptrsSymbPerSlot * ptrsRePerSymb *rel15->nrOfLayers* 2) );
|
||||
}
|
||||
|
||||
/*
|
||||
for (i = 0; i < available_bits; i++) {
|
||||
|
||||
if(((gNB_dlsch->harq_process.f[i] == 0) && (UE_llr[i] <= 0)) ||
|
||||
@@ -1252,6 +1265,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
for (i = 0; i < TBS; i++) {
|
||||
|
||||
estimated_output_bit[i] = (UE_harq_process->b[i/8] & (1 << (i & 7))) >> (i & 7);
|
||||
@@ -1295,11 +1309,9 @@ int main(int argc, char **argv)
|
||||
printf("\n");
|
||||
|
||||
if (print_perf==1) {
|
||||
printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d, Kr %d (Zc %d))\n",
|
||||
printf("\ngNB TX function statistics (per %d us slot, NPRB %d, mcs %d, TBS %d)\n",
|
||||
1000>>*scc->ssbSubcarrierSpacing, g_rbSize, g_mcsIndex,
|
||||
msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3,
|
||||
msgDataTx->dlsch[0][0]->harq_process.K,
|
||||
msgDataTx->dlsch[0][0]->harq_process.K/((msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3)>3824?22:10));
|
||||
msgDataTx->dlsch[0][0]->harq_process.pdsch_pdu.pdsch_pdu_rel15.TBSize[0]<<3);
|
||||
printDistribution(gNB->phy_proc_tx_0,table_tx,"PHY proc tx");
|
||||
printStatIndent2(&gNB->dlsch_encoding_stats,"DLSCH encoding time");
|
||||
printStatIndent3(&gNB->dlsch_segmentation_stats,"DLSCH segmentation time");
|
||||
@@ -1311,6 +1323,9 @@ int main(int argc, char **argv)
|
||||
printStatIndent3(&gNB->dlsch_interleaving_stats, "DLSCH Interleaving time");
|
||||
printStatIndent2(&gNB->dlsch_modulation_stats,"DLSCH modulation time");
|
||||
printStatIndent2(&gNB->dlsch_scrambling_stats, "DLSCH scrambling time");
|
||||
printStatIndent2(&gNB->dlsch_layer_mapping_stats, "DLSCH Layer Mapping time");
|
||||
printStatIndent2(&gNB->dlsch_resource_mapping_stats, "DLSCH Resource Mapping time");
|
||||
printStatIndent2(&gNB->dlsch_precoding_stats,"DLSCH Layer Precoding time");
|
||||
|
||||
|
||||
printf("\nUE RX function statistics (per %d us slot)\n",1000>>*scc->ssbSubcarrierSpacing);
|
||||
|
||||
Reference in New Issue
Block a user