Skip to content

Instantly share code, notes, and snippets.

@ramblex
Created December 13, 2010 11:13
Show Gist options
  • Save ramblex/738905 to your computer and use it in GitHub Desktop.
Save ramblex/738905 to your computer and use it in GitHub Desktop.
/**************************************************************************
*
* checkKi()
*
* Purpose: Calculates the value of Ki, with MCS table entry and Kt.
*
* (ki = kt - k0,i) and k0,i. is found in the MCS table.
*
* Args: UeConfig_t* - pointer to UE configuration structure
* HarqData_t* - pointer to HARQ data structure
* bool - whether the UE supports 16QAM.
* uint16_t - MCS combination, 0..29.
* uint16_t - Number of HS-PDSCH code.for this combination.
* uint16_t - Kt
*
* Returns: bool - whether a Ki was successfully derived.
*
***************************************************************************/
static bool checkKi(
const UeConfig_t *thisUe, HarqData_t *thisHarq, const McsTable_t *mcsTable,
uint16_t kt, int supportsQam)
{
int tempKi = 0;
uint8_t idx = 0;
uint8_t numCodes = MIN(thisHarq->nCodes, MCS_TABLE_SZ);
if (numCodes == 0)
{
return false;
}
for ( ; numCodes; numCodes = idx)
{
// ki = 0..63
// kt = 1..254 (137..27952 bits)
// Koi = 153..1 (QPSK combinations)
// Koi = 192..40 (16QAM combinations)
idx = numCodes - 1;
tempKi = kt - mcsTable->a[idx];
// Reject this combo if Ki is out of range.
// If too big, then quit now because it gets bigger each iteration.
if (tempKi > MAX_KI)
{
return false;
}
if (tempKi < 0)
{
continue;
}
// Check whether we're checking for QPSK combinations or 16QAM.
// 4800 <= (codingBlockSize) <= 28800
// Coding block size = (480 symbols per TTI)*(numCodes)*(M symbols per bit)
const uint32_t codingBlkSize = (uint32_t)SYMBOLS_PER_TTI * numCodes * mcsTable->bitsPerModSym;
// Reject this combo if it requires too much buffering.
// (bufferSize) = {4800..28800}
if (codingBlkSize > ueCategory[thisUe->ueCategory].nIr)
{
continue;
}
// Check code rate is out of range for 16QAM capable users checking
// QPSK combinations.
if (supportsQam && mcsTable->mod == MOD_QPSK)
{
/* TBS 1..27952, i.e. needs 16 bits */
/* Coding rate <= 0.75 */
/* (TBS + Coder CRC + Tail Bits)/ Coding Block Size <= 0.75 */
uint32_t codeRateValue =
(thisHarq->machsFrameSz + CODER_CRC_SZ + NUM_TURBO_TAIL_BITS)
* (uint32_t)MAX_QPSK_CODING_RATE_DENOMINATOR; //lint !e776
uint32_t codeRate = MAX_QPSK_CODING_RATE_NUMERATOR * codingBlkSize;
/* Reject this combo if the coding rate is too high. */
if (codeRateValue > codeRate)
{
continue;
}
}
break;
}
thisHarq->ki = tempKi;
thisHarq->nCodes = numCodes;
thisHarq->mod = mcsTable->mod;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment