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
alex037yang
OpenXG-RAN
Commits
df8b32b8
Commit
df8b32b8
authored
Oct 28, 2018
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fast polar encoder functional only for 32-64 bit input (B, payload+crc)
parent
123f8745
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
256 additions
and
65 deletions
+256
-65
openair1/PHY/CODING/TESTBENCH/polartest.c
openair1/PHY/CODING/TESTBENCH/polartest.c
+20
-11
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
+49
-23
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
+8
-4
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
+165
-26
openair1/PHY/CODING/nr_polar_init.c
openair1/PHY/CODING/nr_polar_init.c
+14
-1
No files found.
openair1/PHY/CODING/TESTBENCH/polartest.c
View file @
df8b32b8
...
...
@@ -92,12 +92,12 @@ int main(int argc, char *argv[]) {
}
if
(
polarMessageType
==
0
)
{
//PBCH
testLength
=
NR_POLAR_PBCH_PAYLOAD_BITS
;
testLength
=
64
;
//
NR_POLAR_PBCH_PAYLOAD_BITS;
coderLength
=
NR_POLAR_PBCH_E
;
aggregation_level
=
NR_POLAR_PBCH_AGGREGATION_LEVEL
;
}
else
if
(
polarMessageType
==
1
)
{
//DCI
//testLength = nr_get_dci_size(params_rel15->dci_format, params_rel15->rnti_type, &fp->initial_bwp_dl, cfg);
testLength
=
20
;
testLength
=
64
;
//
20;
coderLength
=
108
;
//to be changed by aggregate level function.
}
else
if
(
polarMessageType
==
-
1
)
{
//UCI
//testLength = ;
...
...
@@ -318,10 +318,16 @@ int main(int argc, char *argv[]) {
for (int i=0; i<32; i++)
printf("%d\n",(testInput[0]>>i)&1);*/
start_meas
(
&
timeEncoder
);
polar_encoder
(
testInput
,
encoderOutput
,
currentPtr
);
if
(
decoder_int16
==
0
)
polar_encoder
(
testInput
,
encoderOutput
,
currentPtr
);
else
polar_encoder_fast
((
uint64_t
*
)
testInput
,
(
uint64_t
*
)
encoderOutput
,
0
,
currentPtr
);
stop_meas
(
&
timeEncoder
);
/*printf("encoderOutput: [0]->0x%08x\n", encoderOutput[0]);
printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/
...
...
@@ -377,13 +383,16 @@ int main(int argc, char *argv[]) {
blockErrorState
=-
1
;
nBitError
=-
1
;
}
else
{
for
(
int
i
=
0
;
i
<
testArrayLength
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
sizeof
(
testInput
[
0
])
*
8
);
j
++
)
{
if
(((
estimatedOutput
[
i
]
>>
j
)
&
1
)
!=
((
testInput
[
i
]
>>
j
)
&
1
))
nBitError
++
;
}
}
if
(
nBitError
>
0
)
blockErrorState
=
1
;
for
(
int
j
=
0
;
j
<
currentPtr
->
payloadBits
;
j
++
)
{
if
(((
estimatedOutput
[
0
]
>>
j
)
&
1
)
!=
((
testInput
[
0
]
>>
j
)
&
1
))
nBitError
++
;
}
if
(
nBitError
>
0
)
{
blockErrorState
=
1
;
printf
(
"Error: Input %x, Output %x
\n
"
,
testInput
[
0
],
estimatedOutput
[
0
]);
}
}
//Iteration times are in microseconds.
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
View file @
df8b32b8
...
...
@@ -37,7 +37,7 @@
*/
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "assertions.h"
int8_t
polar_decoder
(
double
*
input
,
...
...
@@ -1037,6 +1037,31 @@ int8_t polar_decoder_dci(double *input,
return
(
0
);
}
void
init_polar_deinterleaver_table
(
t_nrPolar_params
*
polarParams
)
{
AssertFatal
(
polarParams
->
K
>
32
,
"K = %d < 33, is not supported yet
\n
"
,
polarParams
->
K
);
AssertFatal
(
polarParams
->
K
<
65
,
"K = %d > 64, is not supported yet
\n
"
,
polarParams
->
K
);
int
bit_i
,
ip
;
int
numbytes
=
polarParams
->
K
>>
3
;
int
residue
=
polarParams
->
K
&
7
;
int
numbits
;
if
(
residue
>
0
)
numbytes
++
;
for
(
int
byte
=
0
;
byte
<
numbytes
;
byte
++
)
{
if
(
byte
<
(
polarParams
->
K
>>
3
))
numbits
=
8
;
else
numbits
=
residue
;
for
(
int
i
=
0
;
i
<
numbits
;
i
++
)
{
ip
=
polarParams
->
interleaving_pattern
[(
8
*
byte
)
+
i
];
AssertFatal
(
ip
<
64
,
"ip = %d
\n
"
,
ip
);
for
(
int
val
=
0
;
val
<
256
;
val
++
)
{
bit_i
=
(
val
>>
i
)
&
1
;
polarParams
->
B_tab
[
byte
][
val
]
|=
(((
uint64_t
)
bit_i
)
<<
ip
);
}
}
}
}
int8_t
polar_decoder_int16
(
int16_t
*
input
,
uint8_t
*
out
,
...
...
@@ -1053,33 +1078,34 @@ int8_t polar_decoder_int16(int16_t *input,
}
memcpy
((
void
*
)
&
polarParams
->
tree
.
root
->
alpha
[
0
],(
void
*
)
&
d_tilde
[
0
],
sizeof
(
int16_t
)
*
polarParams
->
N
);
/*
* SCL polar decoder.
*/
generic_polar_decoder
(
polarParams
,
polarParams
->
tree
.
root
);
//Extract the information bits (û to ĉ)
nr_polar_info_bit_extraction
(
polarParams
->
nr_polar_U
,
polarParams
->
nr_polar_CPrime
,
polarParams
->
information_bit_pattern
,
polarParams
->
N
);
uint64_t
Cprime
=
0
;
uint64_t
B
;
for
(
int
i
=
0
;
i
<
polarParams
->
K
;
i
++
)
Cprime
=
Cprime
|
((
uint64_t
)
polarParams
->
nr_polar_U
[
polarParams
->
Q_I_N
[
i
]])
<<
i
;
//Deinterleaving (ĉ to b)
nr_polar_deinterleaver
(
polarParams
->
nr_polar_CPrime
,
polarParams
->
nr_polar_B
,
polarParams
->
interleaving_pattern
,
polarParams
->
K
);
//Remove the CRC (â)
//for (int j = 0; j < polarParams->payloadBits; j++) polarParams->nr_polar_A[j]=polarParams->nr_polar_B[j];
// Check the CRC
for
(
int
j
=
0
;
j
<
polarParams
->
crcParityBits
;
j
++
)
{
int
crcbit
=
0
;
for
(
int
i
=
0
;
i
<
polarParams
->
payloadBits
;
i
++
)
crcbit
=
crcbit
^
(
polarParams
->
crc_generator_matrix
[
i
][
j
]
&
polarParams
->
nr_polar_B
[
i
]);
if
(
crcbit
!=
polarParams
->
nr_polar_B
[
polarParams
->
payloadBits
+
j
])
return
(
-
1
);
uint8_t
*
Cprimebyte
=
(
uint8_t
*
)
&
Cprime
;
B
=
polarParams
->
B_tab
[
0
][
Cprimebyte
[
0
]]
|
polarParams
->
B_tab
[
1
][
Cprimebyte
[
1
]]
|
polarParams
->
B_tab
[
2
][
Cprimebyte
[
2
]]
|
polarParams
->
B_tab
[
3
][
Cprimebyte
[
3
]]
|
polarParams
->
B_tab
[
4
][
Cprimebyte
[
4
]]
|
polarParams
->
B_tab
[
5
][
Cprimebyte
[
5
]]
|
polarParams
->
B_tab
[
6
][
Cprimebyte
[
6
]]
|
polarParams
->
B_tab
[
7
][
Cprimebyte
[
7
]];
#if 0
printf("Decoded B %llx (crc %x,B>>payloadBits %x)\n",B,crc24c((uint8_t*)&B,polarParams->payloadBits)>>8,
(uint32_t)(B>>polarParams->payloadBits));
#endif
if
((
uint64_t
)(
crc24c
((
uint8_t
*
)
&
B
,
polarParams
->
payloadBits
)
>>
8
)
==
(
B
>>
polarParams
->
payloadBits
))
{
*
((
uint64_t
*
)
out
)
=
B
&
(((
uint64_t
)
1
<<
polarParams
->
payloadBits
)
-
1
);
return
(
0
);
}
// pack into ceil(payloadBits/32) 32 bit words, lowest index in MSB
// nr_byte2bit_uint8_32_t(polarParams->nr_polar_A, polarParams->payloadBits, out);
nr_byte2bit_uint8_32_t
(
polarParams
->
nr_polar_B
,
polarParams
->
payloadBits
,
out
);
return
(
0
);
else
return
(
-
1
);
}
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
View file @
df8b32b8
...
...
@@ -98,6 +98,7 @@ struct nrPolar_params {
uint32_t
crcBit
;
uint16_t
*
interleaving_pattern
;
uint16_t
*
deinterleaving_pattern
;
uint16_t
*
rate_matching_pattern
;
const
uint16_t
*
Q_0_Nminus1
;
int16_t
*
Q_I_N
;
...
...
@@ -110,7 +111,10 @@ struct nrPolar_params {
uint8_t
**
crc_generator_matrix
;
//G_P
uint8_t
**
G_N
;
uint64_t
**
G_N_tab
;
int
groupsize
;
int
*
rm_tab
;
uint64_t
cprime_tab
[
8
][
256
];
uint64_t
B_tab
[
8
][
256
];
uint32_t
*
crc256Table
;
uint8_t
**
extended_crc_generator_matrix
;
//lowercase: bits, Uppercase: Bits stored in bytes
...
...
@@ -355,11 +359,11 @@ uint8_t **crc6_generator_matrix(uint16_t payloadSizeBits);
//Also nr_polar_rate_matcher
static
inline
void
nr_polar_interleaver
(
uint8_t
*
input
,
uint8_t
*
output
,
uint16_t
*
pattern
,
uint16_t
size
)
uint8_t
*
output
,
uint16_t
*
pattern
,
uint16_t
size
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++
)
output
[
i
]
=
input
[
pattern
[
i
]];
for
(
int
i
=
0
;
i
<
size
;
i
++
)
output
[
i
]
=
input
[
pattern
[
i
]];
}
static
inline
void
nr_polar_deinterleaver
(
uint8_t
*
input
,
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
View file @
df8b32b8
This diff is collapsed.
Click to expand it.
openair1/PHY/CODING/nr_polar_init.c
View file @
df8b32b8
...
...
@@ -36,6 +36,11 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_pbch_defs.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
static
int
intcmp
(
const
void
*
p1
,
const
void
*
p2
)
{
return
(
*
(
int16_t
*
)
p1
>
*
(
int16_t
*
)
p2
);
}
void
nr_polar_init
(
t_nrPolar_paramsPtr
*
polarParams
,
int8_t
messageType
,
uint16_t
messageLength
,
...
...
@@ -115,6 +120,10 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode
->
i_il
,
newPolarInitNode
->
interleaving_pattern
);
newPolarInitNode
->
deinterleaving_pattern
=
malloc
(
sizeof
(
uint16_t
)
*
newPolarInitNode
->
K
);
for
(
int
i
=
0
;
i
<
newPolarInitNode
->
K
;
i
++
)
newPolarInitNode
->
deinterleaving_pattern
[
newPolarInitNode
->
interleaving_pattern
[
i
]]
=
i
;
newPolarInitNode
->
rate_matching_pattern
=
malloc
(
sizeof
(
uint16_t
)
*
newPolarInitNode
->
encoderLength
);
uint16_t
*
J
=
malloc
(
sizeof
(
uint16_t
)
*
newPolarInitNode
->
N
);
nr_polar_rate_matching_pattern
(
newPolarInitNode
->
rate_matching_pattern
,
...
...
@@ -139,7 +148,9 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
newPolarInitNode
->
N
,
newPolarInitNode
->
encoderLength
,
newPolarInitNode
->
n_pc
);
// sort the Q_I_N array in ascending order (first K positions)
qsort
((
void
*
)
newPolarInitNode
->
Q_I_N
,
newPolarInitNode
->
K
,
sizeof
(
int16_t
),
intcmp
);
newPolarInitNode
->
channel_interleaver_pattern
=
malloc
(
sizeof
(
uint16_t
)
*
newPolarInitNode
->
encoderLength
);
nr_polar_channel_interleaver_pattern
(
newPolarInitNode
->
channel_interleaver_pattern
,
newPolarInitNode
->
i_bil
,
...
...
@@ -149,6 +160,8 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
build_decoder_tree
(
newPolarInitNode
);
build_polar_tables
(
newPolarInitNode
);
init_polar_deinterleaver_table
(
newPolarInitNode
);
printf
(
"decoder tree nodes %d
\n
"
,
newPolarInitNode
->
tree
.
num_nodes
);
}
else
{
...
...
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