Commit 1197c561 authored by Guy De Souza's avatar Guy De Souza

Payload emulation/scrambling update

parent 93641258
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "nr_dci.h" #include "nr_dci.h"
#include "nr_sch_dmrs.h" #include "nr_sch_dmrs.h"
//#define DEBUG_DLSCH #define DEBUG_DLSCH
//#define DEBUG_DLSCH_MAPPING //#define DEBUG_DLSCH_MAPPING
uint8_t mod_order[5] = {1, 2, 4, 6, 8}; uint8_t mod_order[5] = {1, 2, 4, 6, 8};
...@@ -47,18 +47,21 @@ void nr_pdsch_codeword_scrambling(uint8_t *in, ...@@ -47,18 +47,21 @@ void nr_pdsch_codeword_scrambling(uint8_t *in,
uint32_t n_RNTI, uint32_t n_RNTI,
uint32_t* out) { uint32_t* out) {
uint8_t reset; uint8_t reset, b_idx;
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
reset = 1; reset = 1;
x2 = (n_RNTI<<15) + (q<<14) + Nid; x2 = (n_RNTI<<15) + (q<<14) + Nid;
for (int i=0; i<size; i++) { for (int i=0; i<size; i++) {
if ((i&0x1f)==0) { b_idx = i&0x1f;
if (b_idx==0) {
s = lte_gold_generic(&x1, &x2, reset); s = lte_gold_generic(&x1, &x2, reset);
reset = 0; reset = 0;
if (i)
out++;
} }
*out ^= ((in[i])&1) ^ ((s>>i)&1); *out ^= (((in[i])&1) ^ ((s>>b_idx)&1))<<b_idx;
} }
} }
...@@ -209,17 +212,16 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t dlsch, ...@@ -209,17 +212,16 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t dlsch,
uint16_t encoded_length = nb_symbols*Qm; uint16_t encoded_length = nb_symbols*Qm;
/// CRC, coding, interleaving and rate matching /// CRC, coding, interleaving and rate matching
memset((void*)harq->pdu, 1, (TBS>>3)*sizeof(uint8_t));
nr_dlsch_encoding(harq->pdu, subframe, &dlsch, &frame_parms); nr_dlsch_encoding(harq->pdu, subframe, &dlsch, &frame_parms);
#ifdef DEBUG_DLSCH #ifdef DEBUG_DLSCH
printf("PDSCH encoding:\nPayload:\n"); printf("PDSCH encoding:\nPayload:\n");
for (int i=0; i<MAX_NR_DLSCH_PAYLOAD_BYTES>>4; i++) { for (int i=0; i<TBS>>7; i++) {
for (int j=0; j<16; j++) for (int j=0; j<16; j++)
printf("0x%02x\t", harq->pdu[(i<<4)+j]); printf("0x%02x\t", harq->pdu[(i<<4)+j]);
printf("\n"); printf("\n");
} }
printf("\nEncoded payload:\n"); printf("\nEncoded payload:\n");
for (int i=0; i<encoded_length>>4; i++) { for (int i=0; i<encoded_length>>7; i++) {
for (int j=0; j<16; j++) for (int j=0; j<16; j++)
printf("0x%02x\t", harq->f[(i<<4)+j]); printf("0x%02x\t", harq->f[(i<<4)+j]);
printf("\n"); printf("\n");
...@@ -290,8 +292,8 @@ for (int l=0; l<rel15->nb_layers; l++) ...@@ -290,8 +292,8 @@ for (int l=0; l<rel15->nb_layers; l++)
l0 = get_l0(dmrs_type, 2);//config.pdsch_config.dmrs_typeA_position.value); l0 = get_l0(dmrs_type, 2);//config.pdsch_config.dmrs_typeA_position.value);
nr_modulation(pdsch_dmrs[l0][0], n_dmrs, MOD_QPSK, mod_dmrs); // currently only codeword 0 is modulated nr_modulation(pdsch_dmrs[l0][0], n_dmrs, MOD_QPSK, mod_dmrs); // currently only codeword 0 is modulated
#ifdef DEBUG_DLSCH #ifdef DEBUG_DLSCH
printf("DMRS modulation (single symbol %d, %d symbols, type %d):\n", l0, n_dmrs, dmrs_type); printf("DMRS modulation (single symbol %d, %d symbols, type %d):\n", l0, n_dmrs>>1, dmrs_type);
for (int i=0; i<n_dmrs>>3; i++) { for (int i=0; i<n_dmrs>>4; i++) {
for (int j=0; j<8; j++) { for (int j=0; j<8; j++) {
printf("%d %d\t", mod_dmrs[((i<<3)+j)<<1], mod_dmrs[(((i<<3)+j)<<1)+1]); printf("%d %d\t", mod_dmrs[((i<<3)+j)<<1], mod_dmrs[(((i<<3)+j)<<1)+1]);
} }
...@@ -366,6 +368,5 @@ m, l, k, ((int16_t*)txdataF[ap])[(l*frame_parms.ofdm_symbol_size + k)<<1], ...@@ -366,6 +368,5 @@ m, l, k, ((int16_t*)txdataF[ap])[(l*frame_parms.ofdm_symbol_size + k)<<1],
} }
} }
} }
return 0; return 0;
} }
...@@ -95,3 +95,5 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -95,3 +95,5 @@ int nr_dlsch_encoding(unsigned char *a,
NR_gNB_DLSCH_t *dlsch, NR_gNB_DLSCH_t *dlsch,
NR_DL_FRAME_PARMS* frame_parms); NR_DL_FRAME_PARMS* frame_parms);
void nr_emulate_dlsch_payload(uint8_t* payload, uint16_t size);
...@@ -178,6 +178,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -178,6 +178,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
if (dlsch->harq_processes[i]->pdu) { if (dlsch->harq_processes[i]->pdu) {
bzero(dlsch->harq_processes[i]->pdu,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); bzero(dlsch->harq_processes[i]->pdu,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling)>>3);
} else { } else {
printf("Can't allocate PDU\n"); printf("Can't allocate PDU\n");
exit_flag=1; exit_flag=1;
......
...@@ -237,3 +237,10 @@ void nr_get_PRG_parms(NR_BWP_PARMS* bwp, NR_gNB_DCI_ALLOC_t dci_alloc, uint8_t p ...@@ -237,3 +237,10 @@ void nr_get_PRG_parms(NR_BWP_PARMS* bwp, NR_gNB_DCI_ALLOC_t dci_alloc, uint8_t p
LOG_I(PHY, "PRG parameters for BWP %d location %d N_RB %d:\n", bwp->bwp_id, bwp->location, bwp->N_RB); LOG_I(PHY, "PRG parameters for BWP %d location %d N_RB %d:\n", bwp->bwp_id, bwp->location, bwp->N_RB);
LOG_I(PHY, "P_prime %d\t start size %d\t endsize %d\t N_PRG %d\n", prg_parms->P_prime, prg_parms->start_size, prg_parms->end_size, prg_parms->N_PRG); LOG_I(PHY, "P_prime %d\t start size %d\t endsize %d\t N_PRG %d\n", prg_parms->P_prime, prg_parms->start_size, prg_parms->end_size, prg_parms->N_PRG);
} }
/// Payload emulation
void nr_emulate_dlsch_payload(uint8_t* pdu, uint16_t size) {
set_taus_seed(0);
for (int i=0; i<size; i++)
*(pdu+i) = (uint8_t)rand();
}
...@@ -160,8 +160,6 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, ...@@ -160,8 +160,6 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
TBS = (CEILIDIV((Ninfo_prime+24),8) - 24)<<3; TBS = (CEILIDIV((Ninfo_prime+24),8) - 24)<<3;
} }
} }
LOG_I(MAC, "TBS %d : N_RE %d N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d Ninfo %d Ninfo_prime %d R %d Qm %d table %d scale %d\n",
TBS, N_RE, N_PRB_DMRS, N_sh_symb, N_PRB_oh, Ninfo, Ninfo_prime, R, Qm, table_idx, scale);
dlsch_rel15->coding_rate = R; dlsch_rel15->coding_rate = R;
dlsch_rel15->modulation_order = Qm; dlsch_rel15->modulation_order = Qm;
...@@ -169,6 +167,8 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu, ...@@ -169,6 +167,8 @@ void nr_get_tbs(nfapi_nr_dl_config_dlsch_pdu *dlsch_pdu,
dlsch_rel15->nb_re_dmrs = N_PRB_DMRS; dlsch_rel15->nb_re_dmrs = N_PRB_DMRS;
dlsch_rel15->nb_mod_symbols = N_RE_prime*dlsch_rel15->n_prb*dlsch_rel15->nb_codewords; dlsch_rel15->nb_mod_symbols = N_RE_prime*dlsch_rel15->n_prb*dlsch_rel15->nb_codewords;
LOG_I(MAC, "TBS %d : N_RE %d N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d Ninfo %d Ninfo_prime %d R %d Qm %d table %d scale %d nb_symbols %d\n",
TBS, N_RE, N_PRB_DMRS, N_sh_symb, N_PRB_oh, Ninfo, Ninfo_prime, R, Qm, table_idx, scale, dlsch_rel15->nb_mod_symbols);
} }
uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) { uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) {
......
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
#define NR_MAX_NB_CODEWORDS 2 #define NR_MAX_NB_CODEWORDS 2
#define NR_MAX_NB_HARQ_PROCESSES 16 #define NR_MAX_NB_HARQ_PROCESSES 16
#define NR_MAX_PDSCH_ENCODED_LENGTH 950984 #define NR_MAX_PDSCH_ENCODED_LENGTH 950984
#define NR_MAX_PDSCH_TBS 3824
typedef enum { typedef enum {
NR_MU_0=0, NR_MU_0=0,
......
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