Commit d3c11bd5 authored by Guy De Souza's avatar Guy De Souza

Merge branch 'nr_pdcch' of https://gitlab.eurecom.fr/oai/openairinterface5g into nr_pdcch

parents fa1fb8e5 3c4d3ef9
......@@ -7,7 +7,7 @@
#include <time.h>
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
#include "PHY/defs_gNB.h"
#include "SIMULATION/TOOLS/sim.h"
......@@ -20,6 +20,16 @@ int main(int argc, char *argv[]) {
reset_meas(&timeEncoder);
reset_meas(&timeDecoder);
//gNB scheduler
/*PHY_VARS_gNB *gNB = RC.gNB[0][0];
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
nfapi_nr_config_request_t *cfg = &gNB->gNB_config;
nfapi_nr_dl_config_request_pdu_t *pdu;
nfapi_nr_dl_config_pdcch_parameters_rel15_t *params_rel15 = &pdu->dci_dl_pdu.pdcch_params_rel15;
params_rel15->rnti_type = NFAPI_NR_RNTI_RA;
params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;*/
randominit(0);
//Default simulation values (Aim for iterations = 1000000.)
int itr, iterations = 1000, arguments, polarMessageType = 0; //0=PBCH, 1=DCI, -1=UCI
......@@ -31,7 +41,7 @@ int main(int argc, char *argv[]) {
uint16_t testLength, coderLength, blockErrorCumulative=0, bitErrorCumulative=0;
double timeEncoderCumulative = 0, timeDecoderCumulative = 0;
uint8_t decoderListSize = 8, pathMetricAppr = 0; //0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12)
uint8_t aggregation_level, decoderListSize = 8, pathMetricAppr = 0; //0 --> eq. (8a) and (11b), 1 --> eq. (9) and (12)
while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:")) != -1)
switch (arguments)
......@@ -73,9 +83,11 @@ int main(int argc, char *argv[]) {
if (polarMessageType == 0) { //PBCH
testLength = NR_POLAR_PBCH_PAYLOAD_BITS;
coderLength = NR_POLAR_PBCH_E;
aggregation_level = NR_POLAR_PBCH_AGGREGATION_LEVEL;
} else if (polarMessageType == 1) { //DCI
//testLength = nr_get_dci_size(rel15->dci_format, rel15->rnti_type, &fp->initial_bwp_params_ul ,cfg);
//coderLength = ;
//testLength = nr_get_dci_size(params_rel15->dci_format, params_rel15->rnti_type, &fp->initial_bwp_dl, cfg);
testLength = 20;
coderLength = 108; //to be changed by aggregate level function.
} else if (polarMessageType == -1) { //UCI
//testLength = ;
//coderLength = ;
......@@ -112,16 +124,8 @@ int main(int argc, char *argv[]) {
uint8_t *estimatedOutput = malloc(sizeof(uint8_t) * testLength); //decoder output
t_nrPolar_paramsPtr nrPolar_params = NULL;
nr_polar_init(&nrPolar_params, polarMessageType, testLength);
t_nrPolar_paramsPtr currentPtr = nrPolar_params;
while (currentPtr != NULL) {
if (currentPtr->idx == (polarMessageType * testLength)) {
break;
} else {
currentPtr = currentPtr->nextPtr;
}
}
nr_polar_init(&nrPolar_params, polarMessageType, testLength, aggregation_level);
t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params, polarMessageType, testLength);
// We assume no a priori knowledge available about the payload.
double aPrioriArray[currentPtr->payloadBits];
......
......@@ -21,17 +21,29 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray){//First 2 parameters are in bytes.
void nr_byte2bit_uint8(uint8_t *array, uint8_t arraySize, uint8_t *bitArray) {
//First 2 parameters are in bytes.
for (int i=0; i<arraySize; i++){
bitArray[(7+(i*8))] = ( array[i]>>0 & 0x01);
bitArray[(6+(i*8))] = ( array[i]>>1 & 0x01);
bitArray[(5+(i*8))] = ( array[i]>>2 & 0x01);
bitArray[(4+(i*8))] = ( array[i]>>3 & 0x01);
bitArray[(3+(i*8))] = ( array[i]>>4 & 0x01);
bitArray[(2+(i*8))] = ( array[i]>>5 & 0x01);
bitArray[(1+(i*8))] = ( array[i]>>6 & 0x01);
bitArray[ (i*8) ] = ( array[i]>>7 & 0x01);
for (int i = 0; i < arraySize; i++) {
bitArray[(7 + (i * 8))] = (array[i] >> 0 & 0x01);
bitArray[(6 + (i * 8))] = (array[i] >> 1 & 0x01);
bitArray[(5 + (i * 8))] = (array[i] >> 2 & 0x01);
bitArray[(4 + (i * 8))] = (array[i] >> 3 & 0x01);
bitArray[(3 + (i * 8))] = (array[i] >> 4 & 0x01);
bitArray[(2 + (i * 8))] = (array[i] >> 5 & 0x01);
bitArray[(1 + (i * 8))] = (array[i] >> 6 & 0x01);
bitArray[(i * 8)] = (array[i] >> 7 & 0x01);
}
}
void nr_bit2byte(uint32_t *in, uint16_t arraySize, uint8_t *out) {
for (int i = 0; i < arraySize; i++) {
out[i] = ((*in) >> i) & 1;
}
}
void nr_byte2bit(uint8_t *in, uint16_t arraySize, uint32_t *out) {
for (int i = 0; i < arraySize; i++) {
*out = (*out) << i | in[i];
}
}
......@@ -33,10 +33,14 @@
#ifndef __NR_POLAR_DCI_DEFS__H__
#define __NR_POLAR_DCI_DEFS__H__
#define NR_POLAR_DCI_MESSAGE_TYPE 1 //int8_t
#define NR_POLAR_DCI_CRC_PARITY_BITS 24
#define NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS 3
//Sec. 7.3.3: Channel Coding
#define NR_POLAR_DCI_N_MAX 9 //uint8_t
#define NR_POLAR_DCI_I_IL 1 //uint8_t
//#define NR_POLAR_DCI_I_SEG 0 //uint8_t
#define NR_POLAR_DCI_I_SEG 0 //uint8_t
#define NR_POLAR_DCI_N_PC 0 //uint8_t
#define NR_POLAR_DCI_N_PC_WM 0 //uint8_t
......
......@@ -28,6 +28,10 @@
#include <stdlib.h>
#include <string.h>
#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
static const uint8_t nr_polar_subblock_interleaver_pattern[32] = { 0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, 29, 30, 31 };
struct nrPolar_params {
......@@ -76,7 +80,14 @@ void polar_encoder(uint8_t *input, uint8_t *output, t_nrPolar_paramsPtr polarPar
int8_t polar_decoder(double *input, uint8_t *output, t_nrPolar_paramsPtr polarParams,
uint8_t listSize, double *aPrioriPayload, uint8_t pathMetricAppr);
void nr_polar_init(t_nrPolar_paramsPtr *polarParams, int8_t messageType, uint16_t messageLength);
void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
int8_t messageType,
uint16_t messageLength,
uint8_t aggregation_level);
void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams);
t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams,
int8_t messageType,
uint16_t messageLength);
uint8_t** nr_polar_kronecker_power_matrices(uint8_t n);
......@@ -102,7 +113,9 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, int16_t *Q_I_N, int16_t *Q_F_N,
void nr_polar_info_bit_extraction(uint8_t *input, uint8_t *output,
uint8_t *pattern, uint16_t size);
void nr_byte2bit(uint8_t *array, uint8_t arraySize, uint8_t *bitArray);
void nr_byte2bit(uint8_t *in, uint16_t arraySize, uint32_t *out);
void nr_byte2bit_uint8(uint8_t *array, uint8_t arraySize, uint8_t *bitArray);
void nr_bit2byte(uint32_t *in, uint16_t arraySize, uint8_t *out);
void nr_polar_bit_insertion(uint8_t *input, uint8_t *output, uint16_t N,
uint16_t K, int16_t *Q_I_N, int16_t *Q_PC_N, uint8_t n_PC);
......
......@@ -20,7 +20,6 @@
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
void polar_encoder(
uint8_t *input,
......
......@@ -33,6 +33,8 @@
#ifndef __NR_POLAR_PBCH_DEFS__H__
#define __NR_POLAR_PBCH_DEFS__H__
#define NR_POLAR_PBCH_AGGREGATION_LEVEL 0 //uint8_t
#define NR_POLAR_PBCH_MESSAGE_TYPE 0 //int8_t
#define NR_POLAR_PBCH_PAYLOAD_BITS 32 //uint16_t
#define NR_POLAR_PBCH_CRC_PARITY_BITS 24
#define NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS 3
......
......@@ -33,4 +33,7 @@
#ifndef __NR_POLAR_UCI_DEFS__H__
#define __NR_POLAR_UCI_DEFS__H__
#define NR_POLAR_UCI_MESSAGE_TYPE -1 //int8_t
#define NR_POLAR_UCI_CRC_ERROR_CORRECTION_BITS 3
#endif
......@@ -20,13 +20,16 @@
*/
#include "nrPolar_tools/nr_polar_defs.h"
#include "nrPolar_tools/nr_polar_pbch_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
int8_t messageType,
uint16_t messageLength) {
uint16_t messageLength,
uint8_t aggregation_level)
{
t_nrPolar_paramsPtr currentPtr = *polarParams;
t_nrPolar_paramsPtr previousPtr = NULL;
......@@ -55,10 +58,26 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode->n_pc = NR_POLAR_PBCH_N_PC;
newPolarInitNode->n_pc_wm = NR_POLAR_PBCH_N_PC_WM;
newPolarInitNode->i_bil = NR_POLAR_PBCH_I_BIL;
newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS;
newPolarInitNode->payloadBits = NR_POLAR_PBCH_PAYLOAD_BITS;
newPolarInitNode->encoderLength = NR_POLAR_PBCH_E;
newPolarInitNode->crcParityBits = NR_POLAR_PBCH_CRC_PARITY_BITS;
newPolarInitNode->crcCorrectionBits = NR_POLAR_PBCH_CRC_ERROR_CORRECTION_BITS;
} else if (messageType == 1) { //DCI
newPolarInitNode->n_max = NR_POLAR_DCI_N_MAX;
newPolarInitNode->i_il = NR_POLAR_DCI_I_IL;
newPolarInitNode->i_seg = NR_POLAR_DCI_I_SEG;
newPolarInitNode->n_pc = NR_POLAR_DCI_N_PC;
newPolarInitNode->n_pc_wm = NR_POLAR_DCI_N_PC_WM;
newPolarInitNode->i_bil = NR_POLAR_DCI_I_BIL;
newPolarInitNode->crcParityBits = NR_POLAR_DCI_CRC_PARITY_BITS;
newPolarInitNode->payloadBits = messageLength;
newPolarInitNode->encoderLength = aggregation_level*108;
newPolarInitNode->crcCorrectionBits = NR_POLAR_DCI_CRC_ERROR_CORRECTION_BITS;
} else if (messageType == -1) { //UCI
} else {
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
}
newPolarInitNode->K = newPolarInitNode->payloadBits + newPolarInitNode->crcParityBits; // Number of bits to encode.
newPolarInitNode->N = nr_polar_output_length(newPolarInitNode->K, newPolarInitNode->encoderLength, newPolarInitNode->n_max);
......@@ -76,13 +95,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode->nr_polar_u = malloc(sizeof(uint8_t) * newPolarInitNode->N); //Decoder: nr_polar_uHat
newPolarInitNode->nr_polar_cPrime = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_cHat
newPolarInitNode->nr_polar_b = malloc(sizeof(uint8_t) * newPolarInitNode->K); //Decoder: nr_polar_bHat
} else if (messageType == 1) { //DCI
} else if (messageType == -1) { //UCI
} else {
AssertFatal(1 == 0, "[nr_polar_init] Incorrect Message Type(%d)", messageType);
}
newPolarInitNode->Q_0_Nminus1 = nr_polar_sequence_pattern(newPolarInitNode->n);
......@@ -141,3 +154,35 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
currentPtr->nextPtr= newPolarInitNode;
return;
}
void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams)
{
uint8_t i = 0;
if (polarParams == NULL) {
printf("polarParams is empty.\n");
} else {
while (polarParams != NULL){
printf("polarParams[%d] = %d\n", i, polarParams->idx);
polarParams = polarParams->nextPtr;
i++;
}
}
return;
}
t_nrPolar_paramsPtr nr_polar_params (t_nrPolar_paramsPtr polarParams,
int8_t messageType,
uint16_t messageLength)
{
t_nrPolar_paramsPtr currentPtr;
while (polarParams != NULL) {
if (polarParams->idx == (messageType * messageLength)) {
currentPtr = polarParams;
break;
} else {
polarParams = polarParams->nextPtr;
}
}
return currentPtr;
}
......@@ -119,7 +119,11 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB,
// PBCH DMRS gold sequences generation
nr_init_pbch_dmrs(gNB);
// Polar encoder init for PBCH
nr_polar_init(&fp->pbch_polar_params, 1, NR_POLAR_PBCH_PAYLOAD_BITS);
nr_polar_init(&fp->pbch_polar_params,
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS,
NR_POLAR_PBCH_AGGREGATION_LEVEL);
//PDCCH DMRS init
gNB->nr_gold_pdcch_dmrs = (uint32_t ***)malloc16(fp->slots_per_frame*sizeof(uint32_t**));
uint32_t ***pdcch_dmrs = gNB->nr_gold_pdcch_dmrs;
......
......@@ -153,6 +153,7 @@ void nr_pdcch_scrambling(uint32_t *in,
}
uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
t_nrPolar_paramsPtr *nrPolar_params,
uint32_t *gold_pdcch_dmrs,
int32_t** txdataF,
int16_t amp,
......@@ -188,12 +189,24 @@ uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
/// DCI payload processing
//channel coding
uint8_t *encoderInput = malloc(sizeof(uint8_t) * dci_alloc.size);
nr_bit2byte(dci_alloc.dci_pdu, dci_alloc.size, encoderInput);
nr_polar_init(&nrPolar_params, NR_POLAR_DCI_MESSAGE_TYPE, dci_alloc.size, pdcch_params.aggregation_level);
t_nrPolar_paramsPtr currentPtr = nr_polar_params(nrPolar_params,
NR_POLAR_DCI_MESSAGE_TYPE,
dci_alloc.size);
uint8_t *encoderOutput = malloc(sizeof(uint8_t) * currentPtr->encoderLength);
polar_encoder(encoderInput, encoderOutput, currentPtr);
uint32_t encoded_payload[4];
nr_byte2bit(encoderOutput,currentPtr->encoderLength,encoded_payload);
// scrambling
uint32_t scrambled_payload[4];
uint32_t Nid = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.scrambling_id : config.sch_config.physical_cell_id.value;
uint32_t n_RNTI = (pdcch_params.search_space_type == NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC)? pdcch_params.rnti : 0;
nr_pdcch_scrambling(dci_alloc.dci_pdu, dci_alloc.size, Nid, n_RNTI, scrambled_payload);
nr_pdcch_scrambling(encoded_payload, dci_alloc.size, Nid, n_RNTI, scrambled_payload);
// QPSK modulation
uint32_t mod_dci[NR_MAX_DCI_SIZE>>1];
......
......@@ -33,6 +33,7 @@ uint16_t nr_get_dci_size(nfapi_nr_dci_format_e format,
nfapi_nr_config_request_t* config);
uint8_t nr_generate_dci_top(NR_gNB_PDCCH pdcch_vars,
t_nrPolar_paramsPtr *nrPolar_params,
uint32_t *gold_pdcch_dmrs,
int32_t** txdataF,
int16_t amp,
......
......@@ -142,3 +142,4 @@ void nr_fill_dci_and_dlsch(PHY_VARS_gNB *gNB,
return;
}
......@@ -48,7 +48,7 @@ typedef struct {
typedef struct {
/// Length of DCI payload in bits
uint8_t size;
uint16_t size;
/// Aggregation level
uint8_t L;
/// PDCCH parameters
......@@ -462,6 +462,8 @@ typedef struct PHY_VARS_gNB_s {
int32_t pusch_stats_mcs[NUMBER_OF_UE_MAX][10240];
int32_t pusch_stats_bsr[NUMBER_OF_UE_MAX][10240];
int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240];
t_nrPolar_paramsPtr nrPolar_params;
} PHY_VARS_gNB;
#endif
......@@ -188,6 +188,7 @@ void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB,
if (nfapi_mode == 0 || nfapi_mode == 1)
nr_generate_dci_top(gNB->pdcch_vars,
&gNB->nrPolar_params,
gNB->nr_gold_pdcch_dmrs[0][0],
gNB->common_vars.txdataF,
AMP, *fp, *cfg);
......
......@@ -83,6 +83,7 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP,
params_rel15->rnti = 0x03;
params_rel15->rnti_type = NFAPI_NR_RNTI_RA;
params_rel15->dci_format = NFAPI_NR_DL_DCI_FORMAT_1_0;
params_rel15->aggregation_level = 1;
LOG_I(MAC, "DCI type 1 params: rmsi_pdcch_config %d, rnti %d, rnti_type %d, dci_format %d\n \
coreset params: mux_pattern %d, n_rb %d, n_symb %d, rb_offset %d \n \
ss params : nb_ss_sets_per_slot %d, first symb %d, nb_slots %d, sfn_mod2 %d, first slot %d\n",
......
......@@ -916,7 +916,10 @@ void init_gNB(int single_thread_flag,int wait_for_sync) {
gNB = RC.gNB[inst][CC_id];
gNB->abstraction_flag = 0;
gNB->single_thread_flag = single_thread_flag;
nr_polar_init(&gNB->nrPolar_params,
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS,
NR_POLAR_PBCH_AGGREGATION_LEVEL);
LOG_I(PHY,"Initializing gNB %d CC_id %d single_thread_flag:%d\n",inst,CC_id,single_thread_flag);
#ifndef OCP_FRAMEWORK
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment