Commit 3ec56603 authored by Sakthivel Velumani's avatar Sakthivel Velumani

first commit - dlsim compiled

parent 892dffec
...@@ -531,6 +531,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { ...@@ -531,6 +531,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB) {
for (j=0; j<2; j++) { for (j=0; j<2; j++) {
gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size); gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size);
gNB->dlsch[i][j]->threadPool = gNB->threadPool;
AssertFatal(gNB->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i); AssertFatal(gNB->dlsch[i][j]!=NULL,"Can't initialize dlsch %d \n", i);
} }
} }
......
...@@ -160,6 +160,11 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch, ...@@ -160,6 +160,11 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
dlsch_interleaving_stats, dlsch_interleaving_stats,
dlsch_segmentation_stats); dlsch_segmentation_stats);
stop_meas(dlsch_encoding_stats); stop_meas(dlsch_encoding_stats);
while (dlsch->nbEncode > 0) {
notifiedFIFO_elt_t *req=pullTpool(&dlsch->respEncode, dlsch->threadPool);
dlsch->nbEncode--;
delNotifiedFIFO_elt(req);
}
#ifdef DEBUG_DLSCH #ifdef DEBUG_DLSCH
printf("PDSCH encoding:\nPayload:\n"); printf("PDSCH encoding:\nPayload:\n");
for (int i=0; i<harq->B>>7; i++) { for (int i=0; i<harq->B>>7; i++) {
......
...@@ -309,6 +309,97 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) ...@@ -309,6 +309,97 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
} }
} }
int nr_processDLSegment(void* args) {
ldpcEncode_t *rdata = (ldpcEncode_t*) args;
NR_DL_gNB_HARQ_t *dlsch_harq = rdata->dlsch_harq;
encoder_implemparams_t impp = rdata->impp;
int F = dlsch_harq->F;
int Kr = dlsch_harq->K;
int Z = rdata->Z;
int rvIndex = rdata->rvIndex;
int G = rdata->G;
int r_offset = rdata->r_offset;
int BG = rdata->BG;
int Kb = rdata->Kb;
int nrOfLayers = rdata->nrOfLayers;
int Ilbrm = rdata->Ilbrm;
int Tbslbrm = rdata->Tbslbrm;
int mod_order = rdata->mod_order;
int j = impp.macro_num;
int E;
int r;
int Nl = 4;
nrLDPC_encoder(dlsch_harq->c,dlsch_harq->d,Z,Kb,Kr,BG,&impp);
int maxSeg = ((j+1)*8 > dlsch_harq->C) ? dlsch_harq->C : (j+1)*8;
for (r=j*8; r<maxSeg; r++) {
if (F>0) {
for (int k=(Kr-F-2*(Z)); k<Kr-2*(Z); k++) {
// writing into positions d[r][k-2Zc] as in clause 5.3.2 step 2) in 38.212
dlsch_harq->d[r][k] = NR_NULL;
}
}
#ifdef DEBUG_DLSCH_CODING
LOG_D(PHY,"rvidx in encoding = %d\n", rvIndex);
#endif
E = nr_get_E(G, dlsch_harq->C, mod_order, nrOfLayers, r);
//#ifdef DEBUG_DLSCH_CODING
LOG_D(PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d)...\n",
r,
dlsch_harq->C,
G,
E,
F,
Kr-F-2*(Z),
mod_order);
// for tbslbrm calculation according to 5.4.2.1 of 38.212
if (nrOfLayers < Nl)
Nl = nrOfLayers;
nr_rate_matching_ldpc(Ilbrm,
Tbslbrm,
BG,
Z,
dlsch_harq->d[r],
dlsch_harq->e+r_offset,
dlsch_harq->C,
F,
Kr-F-2*(Z),
rvIndex,
E);
#ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++)
printf("output ratematching e[%d]= %d r_offset %u\n", i,dlsch_harq->e[i+r_offset], r_offset);
#endif
nr_interleaving_ldpc(E,
mod_order,
dlsch_harq->e+r_offset,
dlsch_harq->f+r_offset);
#ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++)
printf("output interleaving f[%d]= %d r_offset %u\n", i,dlsch_harq->f[i+r_offset], r_offset);
if (r==dlsch_harq->C-1)
write_output("enc_output.m","enc",dlsch_harq->f,G,1,4);
#endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
r_offset += E;
}
}
int nr_dlsch_encoding(unsigned char *a, int nr_dlsch_encoding(unsigned char *a,
int frame, int frame,
uint8_t slot, uint8_t slot,
...@@ -429,45 +520,42 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -429,45 +520,42 @@ int nr_dlsch_encoding(unsigned char *a,
uint16_t Kr_bytes; uint16_t Kr_bytes;
Kr_bytes = Kr>>3; Kr_bytes = Kr>>3;
#endif #endif
dlsch->nbEncode = 0;
//printf("segment Z %d k %d Kr %d BG %d C %d\n", *Zc,dlsch->harq_processes[harq_pid]->K,Kr,BG,dlsch->harq_processes[harq_pid]->C); //printf("segment Z %d k %d Kr %d BG %d C %d\n", *Zc,dlsch->harq_processes[harq_pid]->K,Kr,BG,dlsch->harq_processes[harq_pid]->C);
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
//d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
//channel_input[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
#ifdef DEBUG_DLSCH_CODING
LOG_D(PHY,"Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
LOG_D(PHY,"start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C);
LOG_D(PHY,"input %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->c[r][0], dlsch->harq_processes[harq_pid]->c[r][1], dlsch->harq_processes[harq_pid]->c[r][2],dlsch->harq_processes[harq_pid]->c[r][3], dlsch->harq_processes[harq_pid]->c[r][4]);
for (int cnt =0 ; cnt < 22*(*Zc)/8; cnt ++){
LOG_D(PHY,"%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]);
}
LOG_D(PHY,"\n");
#endif
//ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],*Zc,Kb,Kr,BG,0);
//ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL);
}
encoder_implemparams_t impp;
impp.n_segments=dlsch->harq_processes[harq_pid]->C;
impp.tprep = tprep;
impp.tinput = tinput;
impp.tparity = tparity;
impp.toutput = toutput;
for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) { for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) {
impp.macro_num=j; notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), 0, &dlsch->respEncode, nr_processDLSegment);
nrLDPC_encoder(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,&impp); ldpcEncode_t *rdata = (ldpcEncode_t *) NotifiedFifoData(req);
}
rdata->impp.n_segments=dlsch->harq_processes[harq_pid]->C;
rdata->impp.tprep = NULL;
#ifdef DEBUG_DLSCH_CODING rdata->impp.tinput = NULL;
write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); rdata->impp.tparity = NULL;
write_output("enc_output0.m","enc0",&dlsch->harq_processes[harq_pid]->d[0][0],(3*8*Kr_bytes)+12,1,4); rdata->impp.toutput = NULL;
#endif rdata->impp.macro_num=j;
rdata->Z = Z;
} rdata->rvIndex = rel15->rvIndex[0];
rdata->dlsch_harq = dlsch->harq_processes[harq_pid];
rdata->harq_pid = harq_pid;
rdata->Ilbrm = Ilbrm;
rdata->Tbslbrm = Tbslbrm;
rdata->BG = BG;
rdata->F = F;
rdata->mod_order = mod_order;
rdata->nrOfLayers = rel15->nrOfLayers;
rdata->Kb = Kb;
for (int cj=0; cj<j*8; cj++) {
r_offset += nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15->nrOfLayers, r);
}
rdata->r_offset = r_offset;
pushTpool(dlsch->threadPool,req);
dlsch->nbEncode++;
LOG_D(PHY,"Added a block to encode, in pipe: %d\n",dlsch->nbEncode);
}
return;
} else {
F = dlsch->harq_processes[harq_pid]->F; F = dlsch->harq_processes[harq_pid]->F;
Kr = dlsch->harq_processes[harq_pid]->K; Kr = dlsch->harq_processes[harq_pid]->K;
...@@ -506,7 +594,6 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -506,7 +594,6 @@ int nr_dlsch_encoding(unsigned char *a,
Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl,dlsch->harq_processes[harq_pid]->C); Tbslbrm = nr_compute_tbslbrm(rel15->mcsTable[0],nb_rb,Nl,dlsch->harq_processes[harq_pid]->C);
start_meas(dlsch_rate_matching_stats);
nr_rate_matching_ldpc(Ilbrm, nr_rate_matching_ldpc(Ilbrm,
Tbslbrm, Tbslbrm,
BG, BG,
...@@ -518,18 +605,15 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -518,18 +605,15 @@ int nr_dlsch_encoding(unsigned char *a,
Kr-F-2*(*Zc), Kr-F-2*(*Zc),
rel15->rvIndex[0], rel15->rvIndex[0],
E); E);
stop_meas(dlsch_rate_matching_stats);
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++) for (int i =0; i<16; i++)
printf("output ratematching e[%d]= %d r_offset %u\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset); printf("output ratematching e[%d]= %d r_offset %u\n", i,dlsch->harq_processes[harq_pid]->e[i+r_offset], r_offset);
#endif #endif
start_meas(dlsch_interleaving_stats);
nr_interleaving_ldpc(E, nr_interleaving_ldpc(E,
mod_order, mod_order,
dlsch->harq_processes[harq_pid]->e+r_offset, dlsch->harq_processes[harq_pid]->e+r_offset,
dlsch->harq_processes[harq_pid]->f+r_offset); dlsch->harq_processes[harq_pid]->f+r_offset);
stop_meas(dlsch_interleaving_stats);
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++) for (int i =0; i<16; i++)
...@@ -541,8 +625,7 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -541,8 +625,7 @@ int nr_dlsch_encoding(unsigned char *a,
r_offset += E; r_offset += E;
} }
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
return 0; return 0;
} }
...@@ -612,7 +612,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -612,7 +612,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
E = nr_get_E(G, harq_process->C, Qm, n_layers, r); E = nr_get_E(G, harq_process->C, Qm, n_layers, r);
union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}}; union ldpcReqUnion id = {.s={ulsch->rnti,frame,nr_tti_rx,0,0}};
notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), id.p, phy_vars_gNB->respDecode, nr_processULSegment); notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(ldpcDecode_t), 0, phy_vars_gNB->respDecode, nr_processULSegment);
ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req); ldpcDecode_t * rdata=(ldpcDecode_t *) NotifiedFifoData(req);
rdata->gNB = phy_vars_gNB; rdata->gNB = phy_vars_gNB;
......
...@@ -167,6 +167,12 @@ typedef struct { ...@@ -167,6 +167,12 @@ typedef struct {
int16_t sqrt_rho_a; int16_t sqrt_rho_a;
/// amplitude of PDSCH (compared to RS) in symbols containing pilots /// amplitude of PDSCH (compared to RS) in symbols containing pilots
int16_t sqrt_rho_b; int16_t sqrt_rho_b;
/// for maintaining multi threads for encoding
tpool_t *threadPool;
/// number of encoding threads
int nbEncode;
/// fifo to store the thread result
notifiedFIFO_t respEncode;
} NR_gNB_DLSCH_t; } NR_gNB_DLSCH_t;
typedef struct { typedef struct {
...@@ -831,6 +837,26 @@ typedef struct LDPCDecode_s { ...@@ -831,6 +837,26 @@ typedef struct LDPCDecode_s {
int decodeIterations; int decodeIterations;
} ldpcDecode_t; } ldpcDecode_t;
typedef struct LDPCEncode_s {
PHY_VARS_gNB *gNB;
NR_DL_gNB_HARQ_t *dlsch_harq;
encoder_implemparams_t impp;
NR_gNB_DLSCH_t *dlsch;
int dlsch_id;
int harq_pid;
int Z;
int rvIndex;
int F;
int Ilbrm;
int Tbslbrm;
int mod_order;
int r_offset;
int nrOfLayers;
int G;
int BG;
int Kb;
} ldpcEncode_t;
struct ldpcReqId { struct ldpcReqId {
uint16_t rnti; uint16_t rnti;
uint16_t frame; uint16_t frame;
......
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