Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZhouShuya
OpenXG-RAN
Commits
d5e94b2c
Commit
d5e94b2c
authored
Sep 11, 2018
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder_list_t structure for in-place computations
parent
d4d2f866
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
274 additions
and
259 deletions
+274
-259
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
+128
-113
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
+83
-86
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
+32
-18
openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c
...air1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c
+31
-42
No files found.
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
View file @
d5e94b2c
...
...
@@ -29,6 +29,8 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
#include "PHY/TOOLS/time_meas.h"
int8_t
polar_decoder
(
double
*
input
,
uint8_t
*
output
,
...
...
@@ -48,23 +50,24 @@ int8_t polar_decoder(
start_meas
(
init
);
uint8_t
***
bit
=
nr_alloc_uint8_t_3D_array
(
2
*
listSize
,
(
polarParams
->
n
+
1
),
polarParams
->
N
);
uint8_t
**
bitUpdated
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
));
//0=False, 1=True
uint8_t
**
llrUpdated
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
));
//0=False, 1=True
double
***
llr
=
nr_alloc_double_3D_array
(
2
*
listSize
,(
polarParams
->
n
+
1
),
polarParams
->
N
);
uint8_t
**
crcChecksum
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
crcParityBits
,
2
*
listSize
);
double
*
pathMetric
=
malloc
(
sizeof
(
double
)
*
(
2
*
listSize
));
uint8_t
*
crcState
=
malloc
(
sizeof
(
uint8_t
)
*
(
2
*
listSize
));
//0=False, 1=True
for
(
int
i
=
0
;
i
<
(
2
*
listSize
);
i
++
)
{
pathMetric
[
i
]
=
0
;
crcState
[
i
]
=
1
;
decoder_list_t
dlist
[
2
*
listSize
];
for
(
int
i
=
0
;
i
<
2
*
listSize
;
i
++
)
{
dlist
[
i
].
bit
=
nr_alloc_uint8_t_2D_array
((
polarParams
->
n
+
1
),
polarParams
->
N
);
dlist
[
i
].
llr
=
nr_alloc_double_2D_array
((
polarParams
->
n
+
1
),
polarParams
->
N
);
dlist
[
i
].
crcChecksum
=
malloc
(
sizeof
(
uint8_t
)
*
polarParams
->
crcParityBits
);
for
(
int
j
=
0
;
j
<
polarParams
->
n
+
1
;
j
++
)
{
memset
((
void
*
)
&
bit
[
i
]
[
j
][
0
],
0
,
sizeof
(
uint8_t
)
*
polarParams
->
N
);
memset
((
void
*
)
&
llr
[
i
]
[
j
][
0
],
0
,
sizeof
(
double
)
*
polarParams
->
N
);
memset
((
void
*
)
&
dlist
[
i
].
bit
[
j
][
0
],
0
,
sizeof
(
uint8_t
)
*
polarParams
->
N
);
memset
((
void
*
)
&
dlist
[
i
].
llr
[
j
][
0
],
0
,
sizeof
(
double
)
*
polarParams
->
N
);
}
for
(
int
j
=
0
;
j
<
polarParams
->
crcParityBits
;
j
++
)
crcChecksum
[
j
][
i
]
=
0
;
for
(
int
j
=
0
;
j
<
polarParams
->
crcParityBits
;
j
++
)
dlist
[
i
].
crcChecksum
[
j
]
=
0
;
dlist
[
i
].
crcState
=
1
;
dlist
[
i
].
pathMetric
=
0
;
}
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
memset
((
void
*
)
&
llrUpdated
[
i
][
0
],
0
,
sizeof
(
uint8_t
)
*
polarParams
->
n
);
memset
((
void
*
)
&
bitUpdated
[
i
][
0
],
0
,
sizeof
(
uint8_t
)
*
polarParams
->
n
);
...
...
@@ -114,7 +117,7 @@ int8_t polar_decoder(
double
*
d_tilde
=
malloc
(
sizeof
(
double
)
*
polarParams
->
N
);
nr_polar_rate_matching
(
input
,
d_tilde
,
polarParams
->
rate_matching_pattern
,
polarParams
->
K
,
polarParams
->
N
,
polarParams
->
encoderLength
);
memcpy
((
void
*
)
&
llr
[
0
]
[
polarParams
->
n
][
0
],(
void
*
)
&
d_tilde
[
0
],
sizeof
(
double
)
*
polarParams
->
N
);
memcpy
((
void
*
)
&
dlist
[
0
].
llr
[
polarParams
->
n
][
0
],(
void
*
)
&
d_tilde
[
0
],
sizeof
(
double
)
*
polarParams
->
N
);
stop_meas
(
polar_rate_matching
);
/*
...
...
@@ -125,17 +128,23 @@ int8_t polar_decoder(
uint8_t
currentListSize
=
1
;
uint8_t
decoderIterationCheck
=
0
;
int16_t
checkCrcBits
=-
1
;
uint8_t
listIndex
[
2
*
listSize
],
copyIndex
=
0
;
uint8_t
copyIndex
=
0
;
decoder_list_t
*
sorted_dlist
[
2
*
listSize
];
int
listIndex
[
2
*
listSize
];
double
pathMetric
[
2
*
listSize
];
for
(
uint8_t
i
=
0
;
i
<
2
*
listSize
;
i
++
)
sorted_dlist
[
i
]
=
&
dlist
[
i
];
// for (uint8_t i = 0; i < 2*listSize; i++) listIndex[i]=i;
for
(
uint16_t
currentBit
=
0
;
currentBit
<
polarParams
->
N
;
currentBit
++
){
// printf("***************** BIT %d\n",currentBit);
start_meas
(
update_LLR
);
updateLLR
(
llr
,
llrUpdated
,
bit
,
bitUpdated
,
currentListSize
,
currentBit
,
0
,
polarParams
->
N
,
(
polarParams
->
n
+
1
),
pathMetricAppr
);
updateLLR
(
sorted_dlist
,
llrUpdated
,
bitUpdated
,
currentListSize
,
currentBit
,
0
,
polarParams
->
N
,
(
polarParams
->
n
+
1
),
pathMetricAppr
);
stop_meas
(
update_LLR
);
if
(
polarParams
->
information_bit_pattern
[
currentBit
]
==
0
)
{
//Frozen bit.
updatePathMetric
(
pathMetric
,
llr
,
currentListSize
,
0
,
currentBit
,
pathMetricAppr
);
//approximation=0 --> 11b, approximation=1 --> 12
updatePathMetric
(
sorted_dlist
,
currentListSize
,
0
,
currentBit
,
pathMetricAppr
);
//approximation=0 --> 11b, approximation=1 --> 12
}
else
{
//Information or CRC bit.
if
(
(
polarParams
->
interleaving_pattern
[
nonFrozenBit
]
<
polarParams
->
payloadBits
)
&&
(
aPrioriPayload
[
polarParams
->
interleaving_pattern
[
nonFrozenBit
]]
==
0
)
)
{
printf
(
"app[%d] %f, payloadBits %d
\n
"
,
polarParams
->
interleaving_pattern
[
nonFrozenBit
],
...
...
@@ -143,17 +152,17 @@ int8_t polar_decoder(
aPrioriPayload
[
polarParams
->
interleaving_pattern
[
nonFrozenBit
]]);
//Information bit with known value of "0".
updatePathMetric
(
pathMetric
,
llr
,
currentListSize
,
0
,
currentBit
,
pathMetricAppr
);
updatePathMetric
(
sorted_dlist
,
currentListSize
,
0
,
currentBit
,
pathMetricAppr
);
bitUpdated
[
currentBit
][
0
]
=
1
;
//0=False, 1=True
}
else
if
(
(
polarParams
->
interleaving_pattern
[
nonFrozenBit
]
<
polarParams
->
payloadBits
)
&&
(
aPrioriPayload
[
polarParams
->
interleaving_pattern
[
nonFrozenBit
]]
==
1
)
)
{
//Information bit with known value of "1".
updatePathMetric
(
pathMetric
,
llr
,
currentListSize
,
1
,
currentBit
,
pathMetricAppr
);
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
bit
[
i
]
[
0
][
currentBit
]
=
1
;
updatePathMetric
(
sorted_dlist
,
currentListSize
,
1
,
currentBit
,
pathMetricAppr
);
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
sorted_dlist
[
i
]
->
bit
[
0
][
currentBit
]
=
1
;
bitUpdated
[
currentBit
][
0
]
=
1
;
updateCrcChecksum
(
crcChecksum
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
updateCrcChecksum
(
sorted_dlist
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
}
else
{
start_meas
(
path_metric
);
updatePathMetric2
(
pathMetric
,
llr
,
currentListSize
,
currentBit
,
pathMetricAppr
);
updatePathMetric2
(
sorted_dlist
,
currentListSize
,
currentBit
,
pathMetricAppr
);
stop_meas
(
path_metric
);
start_meas
(
sorting
);
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
...
...
@@ -163,25 +172,31 @@ int8_t polar_decoder(
bit[i+currentListSize][k][j]=bit[i][k][j];
llr[i+currentListSize][k][j]=llr[i][k][j];
}*/
memcpy
((
void
*
)
&
bit
[
i
+
currentListSize
][
k
][
0
],(
void
*
)
&
bit
[
i
]
[
k
][
0
],
sizeof
(
uint8_t
)
*
polarParams
->
N
);
memcpy
((
void
*
)
&
llr
[
i
+
currentListSize
][
k
][
0
],(
void
*
)
&
llr
[
i
]
[
k
][
0
],
sizeof
(
double
)
*
polarParams
->
N
);
memcpy
((
void
*
)
&
sorted_dlist
[
i
+
currentListSize
]
->
bit
[
k
][
0
],(
void
*
)
&
sorted_dlist
[
i
]
->
bit
[
k
][
0
],
sizeof
(
uint8_t
)
*
polarParams
->
N
);
memcpy
((
void
*
)
&
sorted_dlist
[
i
+
currentListSize
]
->
llr
[
k
][
0
],(
void
*
)
&
sorted_dlist
[
i
]
->
llr
[
k
][
0
],
sizeof
(
double
)
*
polarParams
->
N
);
}
}
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
bit
[
i
]
[
0
][
currentBit
]
=
0
;
crcState
[
i
+
currentListSize
]
=
crcState
[
i
]
;
sorted_dlist
[
i
]
->
bit
[
0
][
currentBit
]
=
0
;
sorted_dlist
[
i
+
currentListSize
]
->
crcState
=
sorted_dlist
[
i
]
->
crcState
;
}
for
(
int
i
=
currentListSize
;
i
<
2
*
currentListSize
;
i
++
)
bit
[
i
][
0
]
[
currentBit
]
=
1
;
for
(
int
i
=
currentListSize
;
i
<
2
*
currentListSize
;
i
++
)
sorted_dlist
[
i
]
->
bit
[
currentBit
]
=
1
;
bitUpdated
[
currentBit
][
0
]
=
1
;
updateCrcChecksum2
(
crcChecksum
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
updateCrcChecksum2
(
sorted_dlist
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
currentListSize
*=
2
;
//Keep only the best "listSize" number of entries.
if
(
currentListSize
>
listSize
)
{
for
(
uint8_t
i
=
0
;
i
<
2
*
listSize
;
i
++
)
listIndex
[
i
]
=
i
;
nr_sort_asc_double_1D_array_ind
(
pathMetric
,
listIndex
,
currentListSize
);
for
(
int
i
=
0
;
i
<
2
*
listSize
;
i
++
)
{
listIndex
[
i
]
=
i
;
pathMetric
[
i
]
=
dlist
[
i
].
pathMetric
;
}
nr_sort_asc_double_1D_array_ind
(
pathMetric
,
listIndex
,
currentListSize
);
for
(
int
i
=
0
;
i
<
2
*
listSize
;
i
++
)
sorted_dlist
[
i
]
=&
dlist
[
listIndex
[
i
]];
}
/*
//sort listIndex[listSize, ..., 2*listSize-1] in descending order.
uint8_t swaps, tempInd;
for (uint8_t i = 0; i < listSize; i++) {
...
...
@@ -201,11 +216,11 @@ int8_t polar_decoder(
//First, backup the best "listSize" number of entries.
for (int k=(listSize-1); k>0; k--) {
for (int j=0; j<(polarParams->n+1); j++) {
/*
for (int i=0; i<polarParams->N; i++) {
bit[listIndex[(2*listSize-1)-k]][j][i]=bit[listIndex[k]][j][i];
llr[listIndex[(2*listSize-1)-k]][j][i]=llr[listIndex[k]][j][i];
}*/
//
for (int i=0; i<polarParams->N; i++) {
//
bit[listIndex[(2*listSize-1)-k]][j][i]=bit[listIndex[k]][j][i];
//
llr[listIndex[(2*listSize-1)-k]][j][i]=llr[listIndex[k]][j][i];
// }
memcpy((void*)&bit[listIndex[(2*listSize-1)-k]][j][0],
(void*)&bit[listIndex[k]][j][0],
sizeof(uint8_t)*polarParams->N);
...
...
@@ -231,10 +246,10 @@ int8_t polar_decoder(
if (copyIndex!=k) {
for (int j = 0; j < (polarParams->n + 1); j++) {
/
*
for (int i = 0; i < polarParams->N; i++) {
bit[k][j][i] = bit[copyIndex][j][i];
llr[k][j][i] = llr[copyIndex][j][i];
}*/
/
/
for (int i = 0; i < polarParams->N; i++) {
//
bit[k][j][i] = bit[copyIndex][j][i];
//
llr[k][j][i] = llr[copyIndex][j][i];
// }
memcpy((void*)&bit[k][j][0],(void*)&bit[copyIndex][j][0],sizeof(uint8_t)*polarParams->N);
memcpy((void*)&llr[k][j][0],(void*)&llr[copyIndex][j][0],sizeof(double)*polarParams->N);
}
...
...
@@ -259,7 +274,7 @@ int8_t polar_decoder(
crcState[k]=crcState[copyIndex];
}
currentListSize = listSize;
}
}*/
stop_meas
(
sorting
);
}
...
...
@@ -272,21 +287,21 @@ int8_t polar_decoder(
if
(
checkCrcBits
>
(
-
1
)
)
{
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
{
if
(
crcChecksum
[
checkCrcBits
][
i
]
==
1
)
{
crcState
[
i
]
=
0
;
//0=False, 1=True
if
(
dlist
[
i
].
crcChecksum
[
checkCrcBits
]
==
1
)
{
dlist
[
i
].
crcState
=
0
;
//0=False, 1=True
}
}
}
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
decoderIterationCheck
+=
crcState
[
i
]
;
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
decoderIterationCheck
+=
sorted_dlist
[
i
]
->
crcState
;
if
(
decoderIterationCheck
==
0
)
{
//perror("[SCL polar decoder] All list entries have failed the CRC checks.");
free
(
d_tilde
);
f
ree
(
pathMetric
);
free
(
crcState
);
nr_free_uint8_t_3D_array
(
bit
,
2
*
listSize
,
(
polarParams
->
n
+
1
));
nr_free_double_3D_array
(
llr
,
2
*
listSize
,
(
polarParams
->
n
+
1
)
);
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
f
or
(
int
i
=
0
;
i
<
2
*
listSize
;
i
++
)
{
nr_free_uint8_t_2D_array
(
dlist
[
i
].
bit
,
(
polarParams
->
n
+
1
)
);
nr_free_double_2D_array
(
dlist
[
i
].
llr
,
(
polarParams
->
n
+
1
));
free
(
dlist
[
i
].
crcChecksum
);
}
stop_meas
(
decoding
);
return
(
-
1
);
}
...
...
@@ -301,8 +316,8 @@ int8_t polar_decoder(
nr_sort_asc_double_1D_array_ind
(
pathMetric
,
listIndex
,
currentListSize
);
for
(
uint8_t
i
=
0
;
i
<
fmin
(
listSize
,
(
pow
(
2
,
polarParams
->
crcCorrectionBits
))
);
i
++
)
{
if
(
crcState
[
listIndex
[
i
]]
==
1
)
{
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
polarParams
->
nr_polar_u
[
j
]
=
bit
[
listIndex
[
i
]]
[
0
][
j
];
if
(
dlist
[
i
].
crcState
==
1
)
{
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
polarParams
->
nr_polar_u
[
j
]
=
dlist
[
listIndex
[
i
]].
bit
[
0
][
j
];
start_meas
(
bit_extraction
);
//Extract the information bits (û to ĉ)
...
...
@@ -320,11 +335,11 @@ int8_t polar_decoder(
}
free
(
d_tilde
);
f
ree
(
pathMetric
);
free
(
crcState
);
nr_free_uint8_t_3D_array
(
bit
,
2
*
listSize
,
(
polarParams
->
n
+
1
));
nr_free_double_3D_array
(
llr
,
2
*
listSize
,
(
polarParams
->
n
+
1
)
);
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
f
or
(
int
i
=
0
;
i
<
2
*
listSize
;
i
++
)
{
nr_free_uint8_t_2D_array
(
dlist
[
i
].
bit
,
(
polarParams
->
n
+
1
)
);
nr_free_double_2D_array
(
dlist
[
i
].
llr
,
(
polarParams
->
n
+
1
));
free
(
dlist
[
i
].
crcChecksum
);
}
nr_free_uint8_t_2D_array
(
extended_crc_generator_matrix
,
polarParams
->
K
);
nr_free_uint8_t_2D_array
(
tempECGM
,
polarParams
->
K
);
stop_meas
(
decoding
);
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
View file @
d5e94b2c
...
...
@@ -22,13 +22,39 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
//#define SHOWCOMP 1
void
updateLLR
(
double
***
llr
,
uint8_t
**
llrU
,
uint8_t
***
bit
,
uint8_t
**
bitU
,
inline
void
computeLLR
(
double
**
llr
,
uint16_t
row
,
uint16_t
col
,
uint16_t
offset
,
uint8_t
approximation
)
__attribute__
((
always_inline
));
inline
void
computeLLR
(
double
**
llr
,
uint16_t
row
,
uint16_t
col
,
uint16_t
offset
,
uint8_t
approximation
)
{
double
a
;
double
b
;
double
absA
,
absB
;
#ifdef SHOWCOMP
printf
(
"computeLLR (%d,%d,%d,%d)
\n
"
,
row
,
col
,
offset
,
i
);
#endif
a
=
llr
[
col
+
1
][
row
];
b
=
llr
[
col
+
1
][
row
+
offset
];
if
(
approximation
)
{
//eq. (9)
absA
=
fabs
(
a
);
absB
=
fabs
(
b
);
llr
[
col
][
row
]
=
copysign
(
1
.
0
,
a
)
*
copysign
(
1
.
0
,
b
)
*
fmin
(
absA
,
absB
);
}
else
{
//eq. (8a)
llr
[
col
][
row
]
=
log
((
exp
(
a
+
b
)
+
1
)
/
(
exp
(
a
)
+
exp
(
b
)));
}
}
void
updateLLR
(
decoder_list_t
**
dlist
,
uint8_t
**
llrU
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
uint16_t
col
,
uint16_t
xlen
,
uint8_t
ylen
,
uint8_t
approximation
)
{
uint16_t
offset
=
(
xlen
/
(
1
<<
(
ylen
-
col
-
1
)));
if
((
(
row
)
%
(
2
*
offset
)
)
>=
offset
)
{
if
(
bitU
[
row
-
offset
][
col
]
==
0
)
updateBit
(
bi
t
,
bitU
,
listSize
,
(
row
-
offset
),
col
,
xlen
,
ylen
);
if
(
llrU
[
row
-
offset
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
(
row
-
offset
),
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
bitU
[
row
-
offset
][
col
]
==
0
)
updateBit
(
dlis
t
,
bitU
,
listSize
,
(
row
-
offset
),
col
,
xlen
,
ylen
);
if
(
llrU
[
row
-
offset
][
col
+
1
]
==
0
)
updateLLR
(
dlist
,
llrU
,
bitU
,
listSize
,
(
row
-
offset
),
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
dlist
,
llrU
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
...
...
@@ -36,34 +62,34 @@ void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU,
printf
(
"updating LLR (%d,%d,%d) (bit %d,%d,%d, llr0 %d,%d,%d, llr1 %d,%d,%d
\n
"
,
row
,
col
,
i
,
row
-
offset
,
col
,
i
,
row
-
offset
,
col
+
1
,
i
,
row
,
col
+
1
,
i
);
#endif
llr
[
i
][
col
][
row
]
=
(
pow
((
-
1
),
bit
[
i
][
col
][
row
-
offset
])
*
llr
[
i
][
col
+
1
][
row
-
offset
])
+
llr
[
i
]
[
col
+
1
][
row
];
dlist
[
i
]
->
llr
[
col
][
row
]
=
(
pow
((
-
1
),
dlist
[
i
]
->
bit
[
col
][
row
-
offset
])
*
dlist
[
i
]
->
llr
[
col
+
1
][
row
-
offset
])
+
dlist
[
i
]
->
llr
[
col
+
1
][
row
];
}
}
else
{
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
llrU
[
row
+
offset
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
(
row
+
offset
),
(
col
+
1
),
xlen
,
ylen
,
approximation
);
computeLLR
(
llr
,
row
,
col
,
listSize
,
offset
,
approximation
);
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
dlist
,
llrU
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
llrU
[
row
+
offset
][
col
+
1
]
==
0
)
updateLLR
(
dlist
,
llrU
,
bitU
,
listSize
,
(
row
+
offset
),
(
col
+
1
),
xlen
,
ylen
,
approximation
);
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
computeLLR
(
dlist
[
i
]
->
llr
,
row
,
col
,
offset
,
approximation
);
}
llrU
[
row
][
col
]
=
1
;
}
void
updateBit
(
uint8_t
***
bi
t
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
void
updateBit
(
decoder_list_t
**
dlis
t
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
uint16_t
col
,
uint16_t
xlen
,
uint8_t
ylen
)
{
uint16_t
offset
=
(
xlen
/
(
pow
(
2
,(
ylen
-
col
)))
);
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
if
((
(
row
)
%
(
2
*
offset
)
)
>=
offset
)
{
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
bi
t
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
bit
[
i
][
col
][
row
]
=
bit
[
i
]
[
col
-
1
][
row
];
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
dlis
t
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
dlist
[
i
]
->
bit
[
col
][
row
]
=
dlist
[
i
]
->
bit
[
col
-
1
][
row
];
#ifdef SHOWCOMP
printf
(
"updating bit (%d,%d,%d) from (%d,%d,%d)
\n
"
,
row
,
col
,
i
,
row
,
col
-
1
,
i
);
#endif
}
else
{
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
bi
t
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
if
(
bitU
[
row
+
offset
][
col
-
1
]
==
0
)
updateBit
(
bi
t
,
bitU
,
listSize
,
(
row
+
offset
),
(
col
-
1
),
xlen
,
ylen
);
bit
[
i
][
col
][
row
]
=
(
(
bit
[
i
][
col
-
1
][
row
]
+
bit
[
i
]
[
col
-
1
][
row
+
offset
])
%
2
);
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
dlis
t
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
if
(
bitU
[
row
+
offset
][
col
-
1
]
==
0
)
updateBit
(
dlis
t
,
bitU
,
listSize
,
(
row
+
offset
),
(
col
-
1
),
xlen
,
ylen
);
dlist
[
i
]
->
bit
[
col
][
row
]
=
(
(
dlist
[
i
]
->
bit
[
col
-
1
][
row
]
+
dlist
[
i
]
->
bit
[
col
-
1
][
row
+
offset
])
%
2
);
#ifdef SHOWCOMP
printf
(
"updating bit (%d,%d,%d) from (%d,%d,%d)+(%d,%d,%d)
\n
"
,
row
,
col
,
i
,
row
,
col
-
1
,
i
,
row
+
offset
,
col
-
1
,
i
);
...
...
@@ -74,7 +100,7 @@ void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row,
bitU
[
row
][
col
]
=
1
;
}
void
updatePathMetric
(
d
ouble
*
pathMetric
,
double
***
llr
,
uint8_t
listSize
,
uint8_t
bitValue
,
void
updatePathMetric
(
d
ecoder_list_t
**
dlist
,
uint8_t
listSize
,
uint8_t
bitValue
,
uint16_t
row
,
uint8_t
approximation
)
{
#ifdef SHOWCOMP
...
...
@@ -84,11 +110,11 @@ void updatePathMetric(double *pathMetric, double ***llr, uint8_t listSize, uint8
if
(
approximation
)
{
//eq. (12)
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
if
((
2
*
bitValue
)
!=
(
1
-
copysign
(
1
.
0
,
llr
[
i
][
0
][
row
])
))
pathMetric
[
i
]
+=
fabs
(
llr
[
i
]
[
0
][
row
]);
if
((
2
*
bitValue
)
!=
(
1
-
copysign
(
1
.
0
,
dlist
[
i
]
->
llr
[
0
][
row
])
))
dlist
[
i
]
->
pathMetric
+=
fabs
(
dlist
[
i
]
->
llr
[
0
][
row
]);
}
}
else
{
//eq. (11b)
int8_t
multiplier
=
(
2
*
bitValue
)
-
1
;
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
pathMetric
[
i
]
+=
log
(
1
+
exp
(
multiplier
*
llr
[
i
]
[
0
][
row
])
)
;
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
dlist
[
i
]
->
pathMetric
+=
log
(
1
+
exp
(
multiplier
*
dlist
[
i
]
->
llr
[
0
][
row
])
)
;
}
}
...
...
@@ -124,13 +150,13 @@ void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, uint
}
*/
void
updatePathMetric2
(
double
*
pathMetric
,
double
***
llr
,
uint8_t
listSize
,
uint16_t
row
,
uint8_t
appr
)
{
double
*
pm2
=&
pathMetric
[
listSize
];
memcpy
((
void
*
)
pm2
,(
void
*
)
pathMetric
,
listSize
*
sizeof
(
double
*
));
void
updatePathMetric2
(
decoder_list_t
**
dlist
,
uint8_t
listSize
,
uint16_t
row
,
uint8_t
appr
)
{
int
i
;
for
(
i
=
0
;
i
<
listSize
;
i
++
)
dlist
[
i
+
listSize
]
->
pathMetric
=
dlist
[
i
]
->
pathMetric
;
decoder_list_t
**
dlist2
=
&
dlist
[
listSize
];
#ifdef SHOWCOMP
printf
(
"updating path_metric from information bit (%d,%d)
\n
"
,
row
,
0
);
...
...
@@ -138,65 +164,36 @@ void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, uint
if
(
appr
)
{
//eq. (12)
for
(
i
=
0
;
i
<
listSize
;
i
++
)
{
// bitValue=0
if
(
llr
[
i
][
0
][
row
]
<
0
)
pathMetric
[
i
]
-=
llr
[
i
]
[
0
][
row
];
if
(
dlist
[
i
]
->
llr
[
0
][
row
]
<
0
)
dlist
[
i
]
->
pathMetric
-=
dlist
[
i
]
->
llr
[
0
][
row
];
// bitValue=1
else
pm2
[
i
]
+=
llr
[
i
]
[
0
][
row
];
else
dlist2
[
i
]
->
pathMetric
+=
dlist
[
i
]
->
llr
[
0
][
row
];
}
}
else
{
//eq. (11b)
for
(
i
=
0
;
i
<
listSize
;
i
++
)
{
// bitValue=0
pathMetric
[
i
]
+=
log
(
1
+
exp
(
-
llr
[
i
]
[
0
][
row
]));
dlist
[
i
]
->
pathMetric
+=
log
(
1
+
exp
(
-
dlist
[
i
]
->
llr
[
0
][
row
]));
// bitValue=1
pm2
[
i
]
+=
log
(
1
+
exp
(
llr
[
i
]
[
0
][
row
]));
dlist2
[
i
]
->
pathMetric
+=
log
(
1
+
exp
(
dlist
[
i
]
->
llr
[
0
][
row
]));
}
}
}
inline
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
col
,
uint8_t
listSize
,
uint16_t
offset
,
uint8_t
approximation
)
__attribute__
((
always_inline
));
inline
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
col
,
uint8_t
listSize
,
uint16_t
offset
,
uint8_t
approximation
)
{
double
a
;
double
b
;
double
absA
,
absB
;
#ifdef SHOWCOMP
printf
(
"computeLLR (%d,%d,%d,%d)
\n
"
,
row
,
col
,
offset
,
i
);
#endif
if
(
approximation
)
{
//eq. (9)
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
{
a
=
llr
[
i
][
col
+
1
][
row
];
b
=
llr
[
i
][
col
+
1
][
row
+
offset
];
absA
=
fabs
(
a
);
absB
=
fabs
(
b
);
llr
[
i
][
col
][
row
]
=
copysign
(
1
.
0
,
a
)
*
copysign
(
1
.
0
,
b
)
*
fmin
(
absA
,
absB
);
}
}
else
{
//eq. (8a)
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
{
a
=
llr
[
i
][
col
+
1
][
row
];
b
=
llr
[
i
][
col
+
1
][
row
+
offset
];
llr
[
i
][
col
][
row
]
=
log
((
exp
(
a
+
b
)
+
1
)
/
(
exp
(
a
)
+
exp
(
b
)));
}
}
}
void
updateCrcChecksum
(
uint8_t
**
crcChecksum
,
uint8_t
**
crcGen
,
void
updateCrcChecksum
(
decoder_list_t
**
dlist
,
uint8_t
**
crcGen
,
uint8_t
listSize
,
uint32_t
i2
,
uint8_t
len
)
{
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
uint8_t
j
=
0
;
j
<
len
;
j
++
)
{
crcChecksum
[
j
][
i
]
=
(
(
crcChecksum
[
j
][
i
]
+
crcGen
[
i2
][
j
])
%
2
);
dlist
[
i
]
->
crcChecksum
[
j
]
=
(
(
dlist
[
i
]
->
crcChecksum
[
j
]
+
crcGen
[
i2
][
j
])
%
2
);
}
}
}
void
updateCrcChecksum2
(
uint8_t
**
crcChecksum
,
uint8_t
**
crcGen
,
void
updateCrcChecksum2
(
decoder_list_t
**
dlist
,
uint8_t
**
crcGen
,
uint8_t
listSize
,
uint32_t
i2
,
uint8_t
len
)
{
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
uint8_t
j
=
0
;
j
<
len
;
j
++
)
{
crcChecksum
[
j
][
i
+
listSize
]
=
(
(
crcChecksum
[
j
][
i
]
+
crcGen
[
i2
][
j
])
%
2
);
dlist
[
i
+
listSize
]
->
crcChecksum
[
j
]
=
(
(
dlist
[
i
]
->
crcChecksum
[
j
]
+
crcGen
[
i2
][
j
])
%
2
);
}
}
}
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
View file @
d5e94b2c
...
...
@@ -124,27 +124,41 @@ void nr_matrix_multiplication_uint8_t_1D_uint8_t_2D(uint8_t *matrix1, uint8_t **
uint8_t
***
nr_alloc_uint8_t_3D_array
(
uint16_t
xlen
,
uint16_t
ylen
,
uint16_t
zlen
);
uint8_t
**
nr_alloc_uint8_t_2D_array
(
uint16_t
xlen
,
uint16_t
ylen
);
double
**
*
nr_alloc_double_3D_array
(
uint16_t
xlen
,
uint16_t
ylen
,
uint16_t
z
len
);
double
**
nr_alloc_double_2D_array
(
uint16_t
xlen
,
uint16_t
y
len
);
void
nr_free_uint8_t_3D_array
(
uint8_t
***
input
,
uint16_t
xlen
,
uint16_t
ylen
);
void
nr_free_uint8_t_2D_array
(
uint8_t
**
input
,
uint16_t
xlen
);
void
nr_free_double_
3D_array
(
double
***
input
,
uint16_t
xlen
,
uint16_t
y
len
);
void
nr_free_double_
2D_array
(
double
**
input
,
uint16_t
x
len
);
void
updateLLR
(
double
***
llr
,
uint8_t
**
llrU
,
uint8_t
***
bit
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
uint16_t
col
,
uint16_t
xlen
,
uint8_t
ylen
,
uint8_t
approximation
);
void
updateBit
(
uint8_t
***
bit
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
typedef
struct
decoder_list_s
{
uint8_t
**
bit
;
double
**
llr
;
uint8_t
*
crcChecksum
;
uint8_t
crcState
;
double
pathMetric
;
}
decoder_list_t
;
void
updateLLR
(
decoder_list_t
**
dlist
,
uint8_t
**
llrU
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
uint16_t
col
,
uint16_t
xlen
,
uint8_t
ylen
,
uint8_t
approximation
);
void
updateBit
(
decoder_list_t
**
dlist
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint16_t
row
,
uint16_t
col
,
uint16_t
xlen
,
uint8_t
ylen
);
void
updatePathMetric
(
double
*
pathMetric
,
double
***
llr
,
uint8_t
listSize
,
uint8_t
bitValue
,
uint16_t
row
,
uint8_t
approximation
);
void
updatePathMetric2
(
double
*
pathMetric
,
double
***
llr
,
uint8_t
listSize
,
void
updatePathMetric
(
decoder_list_t
**
dlist
,
uint8_t
listSize
,
uint8_t
bitValue
,
uint16_t
row
,
uint8_t
approximation
);
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
col
,
uint8_t
i
,
uint16_t
offset
,
uint8_t
approximation
);
void
updateCrcChecksum
(
uint8_t
**
crcChecksum
,
uint8_t
**
crcGen
,
void
updatePathMetric2
(
decoder_list_t
**
dlist
,
uint8_t
listSize
,
uint16_t
row
,
uint8_t
appr
);
void
updateCrcChecksum
(
decoder_list_t
**
dlist
,
uint8_t
**
crcGen
,
uint8_t
listSize
,
uint32_t
i2
,
uint8_t
len
);
void
updateCrcChecksum2
(
uint8_t
**
crcChecksum
,
uint8_t
**
crcGen
,
void
updateCrcChecksum2
(
decoder_list_t
**
dlist
,
uint8_t
**
crcGen
,
uint8_t
listSize
,
uint32_t
i2
,
uint8_t
len
);
void
nr_sort_asc_double_1D_array_ind
(
double
*
matrix
,
uint8_t
*
ind
,
uint8_t
len
);
uint8_t
**
crc24c_generator_matrix
(
uint16_t
payloadSizeBits
);
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_matrix_and_array.c
View file @
d5e94b2c
...
...
@@ -66,8 +66,8 @@ uint8_t ***nr_alloc_uint8_t_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen
return
output
;
}
double
**
*
nr_alloc_double_3D_array
(
uint16_t
xlen
,
uint16_t
ylen
,
uint16_t
z
len
)
{
double
*
**
output
;
double
**
nr_alloc_double_2D_array
(
uint16_t
xlen
,
uint16_t
y
len
)
{
double
**
output
;
int
i
,
j
;
if
((
output
=
malloc
(
xlen
*
sizeof
(
*
output
)))
==
NULL
)
{
...
...
@@ -80,22 +80,14 @@ double ***nr_alloc_double_3D_array(uint16_t xlen, uint16_t ylen, uint16_t zlen)
for
(
i
=
0
;
i
<
xlen
;
i
++
)
if
((
output
[
i
]
=
malloc
(
ylen
*
sizeof
*
output
[
i
]))
==
NULL
)
{
perror
(
"[nr_alloc_double_3
D_array] Problem at 2D allocation"
);
nr_free_double_3D_array
(
output
,
xlen
,
y
len
);
perror
(
"[nr_alloc_double_2
D_array] Problem at 2D allocation"
);
nr_free_double_2D_array
(
output
,
x
len
);
return
NULL
;
}
for
(
i
=
0
;
i
<
xlen
;
i
++
)
for
(
j
=
0
;
j
<
ylen
;
j
++
)
output
[
i
][
j
]
=
NULL
;
output
[
i
][
j
]
=
0
;
for
(
i
=
0
;
i
<
xlen
;
i
++
)
for
(
j
=
0
;
j
<
ylen
;
j
++
)
if
((
output
[
i
][
j
]
=
malloc
(
zlen
*
sizeof
*
output
[
i
][
j
]))
==
NULL
)
{
perror
(
"[nr_alloc_double_3D_array] Problem at 3D allocation"
);
nr_free_double_3D_array
(
output
,
xlen
,
ylen
);
return
NULL
;
}
return
output
;
}
...
...
@@ -142,13 +134,10 @@ void nr_free_uint8_t_2D_array(uint8_t **input, uint16_t xlen) {
free
(
input
);
}
void
nr_free_double_
3D_array
(
double
***
input
,
uint16_t
xlen
,
uint16_t
y
len
)
{
int
i
,
j
;
void
nr_free_double_
2D_array
(
double
**
input
,
uint16_t
x
len
)
{
int
i
;
for
(
i
=
0
;
i
<
xlen
;
i
++
)
{
for
(
j
=
0
;
j
<
ylen
;
j
++
)
{
free
(
input
[
i
][
j
]);
}
free
(
input
[
i
]);
}
free
(
input
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment