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
6d38327d
Commit
6d38327d
authored
Sep 10, 2018
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
memcpy instead of loop-based copy
parent
52669a08
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
25 deletions
+43
-25
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
+40
-22
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
+3
-3
No files found.
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
View file @
6d38327d
...
@@ -37,7 +37,7 @@ int8_t polar_decoder(
...
@@ -37,7 +37,7 @@ int8_t polar_decoder(
uint8_t
pathMetricAppr
)
uint8_t
pathMetricAppr
)
{
{
uint8_t
***
bit
=
nr_alloc_uint8_t_3D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
),
2
*
listSize
);
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
**
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
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
);
double
***
llr
=
nr_alloc_double_3D_array
(
2
*
listSize
,(
polarParams
->
n
+
1
),
polarParams
->
N
);
...
@@ -48,12 +48,14 @@ int8_t polar_decoder(
...
@@ -48,12 +48,14 @@ int8_t polar_decoder(
for
(
int
i
=
0
;
i
<
(
2
*
listSize
);
i
++
)
{
for
(
int
i
=
0
;
i
<
(
2
*
listSize
);
i
++
)
{
pathMetric
[
i
]
=
0
;
pathMetric
[
i
]
=
0
;
crcState
[
i
]
=
1
;
crcState
[
i
]
=
1
;
for
(
int
j
=
0
;
j
<
polarParams
->
n
+
1
;
j
++
)
memset
((
void
*
)
&
bit
[
i
][
j
][
0
],
0
,
sizeof
(
uint8_t
)
*
polarParams
->
N
);
}
}
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
llrUpdated
[
i
][
polarParams
->
n
]
=
1
;
llrUpdated
[
i
][
polarParams
->
n
]
=
1
;
bitUpdated
[
i
][
0
]
=
((
polarParams
->
information_bit_pattern
[
i
]
+
1
)
%
2
);
bitUpdated
[
i
][
0
]
=
((
polarParams
->
information_bit_pattern
[
i
]
+
1
)
%
2
);
}
}
uint8_t
**
extended_crc_generator_matrix
=
malloc
(
polarParams
->
K
*
sizeof
(
uint8_t
*
));
//G_P3
uint8_t
**
extended_crc_generator_matrix
=
malloc
(
polarParams
->
K
*
sizeof
(
uint8_t
*
));
//G_P3
uint8_t
**
tempECGM
=
malloc
(
polarParams
->
K
*
sizeof
(
uint8_t
*
));
//G_P2
uint8_t
**
tempECGM
=
malloc
(
polarParams
->
K
*
sizeof
(
uint8_t
*
));
//G_P2
for
(
int
i
=
0
;
i
<
polarParams
->
K
;
i
++
){
for
(
int
i
=
0
;
i
<
polarParams
->
K
;
i
++
){
...
@@ -120,23 +122,29 @@ int8_t polar_decoder(
...
@@ -120,23 +122,29 @@ int8_t polar_decoder(
}
else
if
(
(
polarParams
->
interleaving_pattern
[
nonFrozenBit
]
<=
polarParams
->
payloadBits
)
&&
(
aPrioriPayload
[
polarParams
->
interleaving_pattern
[
nonFrozenBit
]]
==
1
)
)
{
}
else
if
(
(
polarParams
->
interleaving_pattern
[
nonFrozenBit
]
<=
polarParams
->
payloadBits
)
&&
(
aPrioriPayload
[
polarParams
->
interleaving_pattern
[
nonFrozenBit
]]
==
1
)
)
{
//Information bit with known value of "1".
//Information bit with known value of "1".
updatePathMetric
(
pathMetric
,
llr
,
currentListSize
,
1
,
currentBit
,
pathMetricAppr
);
updatePathMetric
(
pathMetric
,
llr
,
currentListSize
,
1
,
currentBit
,
pathMetricAppr
);
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
bit
[
currentBit
][
0
][
i
]
=
1
;
for
(
uint8_t
i
=
0
;
i
<
currentListSize
;
i
++
)
bit
[
i
][
0
][
currentBit
]
=
1
;
bitUpdated
[
currentBit
][
0
]
=
1
;
bitUpdated
[
currentBit
][
0
]
=
1
;
updateCrcChecksum
(
crcChecksum
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
updateCrcChecksum
(
crcChecksum
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
}
else
{
}
else
{
updatePathMetric2
(
pathMetric
,
llr
,
currentListSize
,
currentBit
,
pathMetricAppr
);
updatePathMetric2
(
pathMetric
,
llr
,
currentListSize
,
currentBit
,
pathMetricAppr
);
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
{
for
(
int
k
=
0
;
k
<
(
polarParams
->
n
+
1
);
k
++
)
{
for
(
int
k
=
0
;
k
<
(
polarParams
->
n
+
1
);
k
++
)
{
bit
[
j
][
k
][
i
+
currentListSize
]
=
bit
[
j
][
k
][
i
];
/*
llr
[
i
+
currentListSize
][
k
][
j
]
=
llr
[
i
][
k
][
j
];}}}
for (int j = 0; j < polarParams->N; j++) {
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
);
}
}
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
bit
[
currentBit
][
0
][
i
]
=
0
;
bit
[
i
][
0
][
currentBit
]
=
0
;
crcState
[
i
+
currentListSize
]
=
crcState
[
i
];
crcState
[
i
+
currentListSize
]
=
crcState
[
i
];
}
}
for
(
int
i
=
currentListSize
;
i
<
2
*
currentListSize
;
i
++
)
bit
[
currentBit
][
0
][
i
]
=
1
;
for
(
int
i
=
currentListSize
;
i
<
2
*
currentListSize
;
i
++
)
bit
[
i
][
0
][
currentBit
]
=
1
;
bitUpdated
[
currentBit
][
0
]
=
1
;
bitUpdated
[
currentBit
][
0
]
=
1
;
updateCrcChecksum2
(
crcChecksum
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
updateCrcChecksum2
(
crcChecksum
,
extended_crc_generator_matrix
,
currentListSize
,
nonFrozenBit
,
polarParams
->
crcParityBits
);
currentListSize
*=
2
;
currentListSize
*=
2
;
...
@@ -164,11 +172,18 @@ int8_t polar_decoder(
...
@@ -164,11 +172,18 @@ int8_t polar_decoder(
//First, backup the best "listSize" number of entries.
//First, backup the best "listSize" number of entries.
for
(
int
k
=
(
listSize
-
1
);
k
>
0
;
k
--
)
{
for
(
int
k
=
(
listSize
-
1
);
k
>
0
;
k
--
)
{
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
bit
[
i
][
j
][
listIndex
[(
2
*
listSize
-
1
)
-
k
]]
=
bit
[
i
][
j
][
listIndex
[
k
]];
/*
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];
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
);
memcpy
((
void
*
)
&
llr
[
listIndex
[(
2
*
listSize
-
1
)
-
k
]][
j
][
0
],
(
void
*
)
&
llr
[
listIndex
[
k
]][
j
][
0
],
sizeof
(
double
)
*
polarParams
->
N
);
}
}
}
}
for
(
int
k
=
(
listSize
-
1
);
k
>
0
;
k
--
)
{
for
(
int
k
=
(
listSize
-
1
);
k
>
0
;
k
--
)
{
...
@@ -185,11 +200,14 @@ int8_t polar_decoder(
...
@@ -185,11 +200,14 @@ int8_t polar_decoder(
}
else
{
//Use the backup.
}
else
{
//Use the backup.
copyIndex
=
listIndex
[
k
];
copyIndex
=
listIndex
[
k
];
}
}
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
bit
[
i
][
j
][
k
]
=
bit
[
i
][
j
][
copyIndex
];
/* for (int i = 0; i < polarParams->N; i++) {
bit[k][j][i] = bit[copyIndex][j][i];
llr[k][j][i] = llr[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
);
}
}
}
}
for
(
int
k
=
0
;
k
<
listSize
;
k
++
)
{
for
(
int
k
=
0
;
k
<
listSize
;
k
++
)
{
...
@@ -235,7 +253,7 @@ int8_t polar_decoder(
...
@@ -235,7 +253,7 @@ int8_t polar_decoder(
free
(
d_tilde
);
free
(
d_tilde
);
free
(
pathMetric
);
free
(
pathMetric
);
free
(
crcState
);
free
(
crcState
);
nr_free_uint8_t_3D_array
(
bit
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
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_double_3D_array
(
llr
,
2
*
listSize
,
(
polarParams
->
n
+
1
));
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
return
(
-
1
);
return
(
-
1
);
...
@@ -252,7 +270,7 @@ int8_t polar_decoder(
...
@@ -252,7 +270,7 @@ int8_t polar_decoder(
for
(
uint8_t
i
=
0
;
i
<
fmin
(
listSize
,
(
pow
(
2
,
polarParams
->
crcCorrectionBits
))
);
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
fmin
(
listSize
,
(
pow
(
2
,
polarParams
->
crcCorrectionBits
))
);
i
++
)
{
if
(
crcState
[
listIndex
[
i
]]
==
1
)
{
if
(
crcState
[
listIndex
[
i
]]
==
1
)
{
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
polarParams
->
nr_polar_u
[
j
]
=
bit
[
j
][
0
][
listIndex
[
i
]
];
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
polarParams
->
nr_polar_u
[
j
]
=
bit
[
listIndex
[
i
]][
0
][
j
];
//Extract the information bits (û to ĉ)
//Extract the information bits (û to ĉ)
nr_polar_info_bit_extraction
(
polarParams
->
nr_polar_u
,
polarParams
->
nr_polar_cPrime
,
polarParams
->
information_bit_pattern
,
polarParams
->
N
);
nr_polar_info_bit_extraction
(
polarParams
->
nr_polar_u
,
polarParams
->
nr_polar_cPrime
,
polarParams
->
information_bit_pattern
,
polarParams
->
N
);
...
@@ -270,7 +288,7 @@ int8_t polar_decoder(
...
@@ -270,7 +288,7 @@ int8_t polar_decoder(
free
(
d_tilde
);
free
(
d_tilde
);
free
(
pathMetric
);
free
(
pathMetric
);
free
(
crcState
);
free
(
crcState
);
nr_free_uint8_t_3D_array
(
bit
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
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_double_3D_array
(
llr
,
2
*
listSize
,
(
polarParams
->
n
+
1
));
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
nr_free_uint8_t_2D_array
(
extended_crc_generator_matrix
,
polarParams
->
K
);
nr_free_uint8_t_2D_array
(
extended_crc_generator_matrix
,
polarParams
->
K
);
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
View file @
6d38327d
...
@@ -36,7 +36,7 @@ void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU,
...
@@ -36,7 +36,7 @@ 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
,
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
);
row
-
offset
,
col
,
i
,
row
-
offset
,
col
+
1
,
i
,
row
,
col
+
1
,
i
);
#endif
#endif
llr
[
i
][
col
][
row
]
=
(
pow
((
-
1
),
bit
[
row
-
offset
][
col
][
i
])
*
llr
[
i
][
col
+
1
][
row
-
offset
])
+
llr
[
i
][
col
+
1
][
row
];
llr
[
i
][
col
][
row
]
=
(
pow
((
-
1
),
bit
[
i
][
col
][
row
-
offset
])
*
llr
[
i
][
col
+
1
][
row
-
offset
])
+
llr
[
i
][
col
+
1
][
row
];
}
}
}
else
{
}
else
{
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
...
@@ -55,7 +55,7 @@ void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row,
...
@@ -55,7 +55,7 @@ void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row,
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
if
((
(
row
)
%
(
2
*
offset
)
)
>=
offset
)
{
if
((
(
row
)
%
(
2
*
offset
)
)
>=
offset
)
{
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
bit
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
bit
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
bit
[
row
][
col
][
i
]
=
bit
[
row
][
col
-
1
][
i
];
bit
[
i
][
col
][
row
]
=
bit
[
i
][
col
-
1
][
row
];
#ifdef SHOWCOMP
#ifdef SHOWCOMP
printf
(
"updating bit (%d,%d,%d) from (%d,%d,%d)
\n
"
,
printf
(
"updating bit (%d,%d,%d) from (%d,%d,%d)
\n
"
,
row
,
col
,
i
,
row
,
col
-
1
,
i
);
row
,
col
,
i
,
row
,
col
-
1
,
i
);
...
@@ -63,7 +63,7 @@ void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row,
...
@@ -63,7 +63,7 @@ void updateBit(uint8_t ***bit, uint8_t **bitU, uint8_t listSize, uint16_t row,
}
else
{
}
else
{
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
bit
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
if
(
bitU
[
row
][
col
-
1
]
==
0
)
updateBit
(
bit
,
bitU
,
listSize
,
row
,
(
col
-
1
),
xlen
,
ylen
);
if
(
bitU
[
row
+
offset
][
col
-
1
]
==
0
)
updateBit
(
bit
,
bitU
,
listSize
,
(
row
+
offset
),
(
col
-
1
),
xlen
,
ylen
);
if
(
bitU
[
row
+
offset
][
col
-
1
]
==
0
)
updateBit
(
bit
,
bitU
,
listSize
,
(
row
+
offset
),
(
col
-
1
),
xlen
,
ylen
);
bit
[
row
][
col
][
i
]
=
(
(
bit
[
row
][
col
-
1
][
i
]
+
bit
[
row
+
offset
][
col
-
1
][
i
])
%
2
);
bit
[
i
][
col
][
row
]
=
(
(
bit
[
i
][
col
-
1
][
row
]
+
bit
[
i
][
col
-
1
][
row
+
offset
])
%
2
);
#ifdef SHOWCOMP
#ifdef SHOWCOMP
printf
(
"updating bit (%d,%d,%d) from (%d,%d,%d)+(%d,%d,%d)
\n
"
,
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
);
row
,
col
,
i
,
row
,
col
-
1
,
i
,
row
+
offset
,
col
-
1
,
i
);
...
...
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