Commit f9ca54e9 authored by Francesco Mani's avatar Francesco Mani

crc and tbs fixes in ulsch

parent 631d345d
...@@ -361,7 +361,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -361,7 +361,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
// harq_process->trials[nfapi_ulsch_pdu_rel15->round]++; // harq_process->trials[nfapi_ulsch_pdu_rel15->round]++;
harq_process->TBS = pusch_pdu->pusch_data.tb_size; harq_process->TBS = pusch_pdu->pusch_data.tb_size;
A = harq_process->TBS; A = (harq_process->TBS)<<3;
ret = ulsch->max_ldpc_iterations + 1; ret = ulsch->max_ldpc_iterations + 1;
LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers); LOG_D(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, n_layers %d\n",harq_pid,A,G, mcs, n_layers, nb_rb, Qm, n_layers);
...@@ -548,7 +548,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -548,7 +548,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
// printf("done\n"); // printf("done\n");
if (harq_process->C == 1) { if (harq_process->C == 1) {
if (A > 3824)
crc_type = CRC24_A; crc_type = CRC24_A;
else
crc_type = CRC16;
length_dec = harq_process->B; length_dec = harq_process->B;
} }
else { else {
......
...@@ -292,6 +292,8 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ...@@ -292,6 +292,8 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
printf("%02x.",a[i]); printf("%02x.",a[i]);
printf("\n"); printf("\n");
*/ */
if (A > 3824) {
// Add 24-bit crc (polynomial A) to payload // Add 24-bit crc (polynomial A) to payload
crc = crc24a(harq_process->a,A)>>8; crc = crc24a(harq_process->a,A)>>8;
harq_process->a[A>>3] = ((uint8_t*)&crc)[2]; harq_process->a[A>>3] = ((uint8_t*)&crc)[2];
...@@ -302,8 +304,24 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, ...@@ -302,8 +304,24 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch,
harq_process->B = A+24; harq_process->B = A+24;
AssertFatal((A/8)+4 <= MAX_NR_ULSCH_PAYLOAD_BYTES,"A %d is too big (A/8+4 = %d > %d)\n",A,(A/8)+4,MAX_NR_ULSCH_PAYLOAD_BYTES);
memcpy(harq_process->b,harq_process->a,(A/8)+4); memcpy(harq_process->b,harq_process->a,(A/8)+4);
}
else {
// Add 16-bit crc (polynomial A) to payload
crc = crc16(harq_process->a,A)>>16;
harq_process->a[A>>3] = ((uint8_t*)&crc)[1];
harq_process->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_process->B = A+16;
AssertFatal((A/8)+3 <= MAX_NR_ULSCH_PAYLOAD_BYTES,"A %d is too big (A/8+3 = %d > %d)\n",A,(A/8)+3,MAX_NR_ULSCH_PAYLOAD_BYTES);
memcpy(harq_process->b,harq_process->a,(A/8)+3); // using 3 bytes to mimic the case of 24 bit crc
}
/////////// ///////////
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
......
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