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
canghaiwuhen
OpenXG-RAN
Commits
dd61e5a7
Commit
dd61e5a7
authored
Mar 08, 2019
by
yilmazt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working short block coding and various warning removals in --phy_simulators
parent
9cbfe2e3
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
762 additions
and
598 deletions
+762
-598
cmake_targets/CMakeLists.txt
cmake_targets/CMakeLists.txt
+11
-2
openair1/PHY/CODING/TESTBENCH/ldpctest.c
openair1/PHY/CODING/TESTBENCH/ldpctest.c
+4
-4
openair1/PHY/CODING/TESTBENCH/polartest.c
openair1/PHY/CODING/TESTBENCH/polartest.c
+39
-44
openair1/PHY/CODING/TESTBENCH/smallblocktest.c
openair1/PHY/CODING/TESTBENCH/smallblocktest.c
+169
-0
openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c
openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c
+3
-3
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
+19
-289
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
+57
-70
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
+122
-154
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
+7
-7
openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c
+27
-15
openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c
openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c
+117
-0
openair1/PHY/CODING/nrSmallBlock/encodeSmall.c
openair1/PHY/CODING/nrSmallBlock/encodeSmall.c
+0
-0
openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c
openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c
+44
-0
openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h
openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h
+134
-0
openair1/PHY/CODING/nr_polar_init.c
openair1/PHY/CODING/nr_polar_init.c
+9
-10
No files found.
cmake_targets/CMakeLists.txt
View file @
dd61e5a7
...
@@ -1143,15 +1143,19 @@ set(PHY_POLARSRC
...
@@ -1143,15 +1143,19 @@ set(PHY_POLARSRC
${
OPENAIR1_DIR
}
/PHY/CODING/nrPolar_tools/nr_polar_procedures.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrPolar_tools/nr_polar_procedures.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrPolar_tools/nr_polar_sequence_pattern.c
)
)
set
(
PHY_SMALLBLOCKSRC
${
OPENAIR1_DIR
}
/PHY/CODING/nrSmallBlock/encodeSmallBlock.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrSmallBlock/decodeSmallBlock.c
)
set
(
PHY_TURBOIF
set
(
PHY_TURBOIF
${
OPENAIR1_DIR
}
/PHY/CODING/coding_load.c
${
OPENAIR1_DIR
}
/PHY/CODING/coding_load.c
)
)
set
(
PHY_LDPCSRC
set
(
PHY_LDPCSRC
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_encoder/ldpc_encoder.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_encoder/ldpc_encoder2.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
${
OPENAIR1_DIR
}
/PHY/CODING/nrLDPC_encoder/ldpc_generate_coefficient.c
)
)
add_library
(
coding MODULE
${
PHY_TURBOSRC
}
)
add_library
(
coding MODULE
${
PHY_TURBOSRC
}
)
...
@@ -1326,6 +1330,7 @@ set(PHY_SRC_UE
...
@@ -1326,6 +1330,7 @@ set(PHY_SRC_UE
${
OPENAIR1_DIR
}
/PHY/TOOLS/time_meas.c
${
OPENAIR1_DIR
}
/PHY/TOOLS/time_meas.c
${
OPENAIR1_DIR
}
/PHY/TOOLS/lut.c
${
OPENAIR1_DIR
}
/PHY/TOOLS/lut.c
${
PHY_POLARSRC
}
${
PHY_POLARSRC
}
${
PHY_SMALLBLOCKSRC
}
${
PHY_LDPCSRC
}
${
PHY_LDPCSRC
}
)
)
...
@@ -1372,6 +1377,7 @@ set(PHY_SRC_UE
...
@@ -1372,6 +1377,7 @@ set(PHY_SRC_UE
${
OPENAIR1_DIR
}
/PHY/INIT/nr_init_ue.c
${
OPENAIR1_DIR
}
/PHY/INIT/nr_init_ue.c
# ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
# ${OPENAIR1_DIR}/SIMULATION/NR_UE_PHY/unit_tests/src/pucch_uci_test.c
${
PHY_POLARSRC
}
${
PHY_POLARSRC
}
${
PHY_SMALLBLOCKSRC
}
${
PHY_LDPCSRC
}
${
PHY_LDPCSRC
}
)
)
...
@@ -2558,6 +2564,9 @@ target_link_libraries (dlsim_tm4
...
@@ -2558,6 +2564,9 @@ target_link_libraries (dlsim_tm4
add_executable
(
polartest
${
OPENAIR1_DIR
}
/PHY/CODING/TESTBENCH/polartest.c
)
add_executable
(
polartest
${
OPENAIR1_DIR
}
/PHY/CODING/TESTBENCH/polartest.c
)
target_link_libraries
(
polartest SIMU PHY PHY_NR PHY_COMMON m
${
ATLAS_LIBRARIES
}
)
target_link_libraries
(
polartest SIMU PHY PHY_NR PHY_COMMON m
${
ATLAS_LIBRARIES
}
)
add_executable
(
smallblocktest
${
OPENAIR1_DIR
}
/PHY/CODING/TESTBENCH/smallblocktest.c
)
target_link_libraries
(
smallblocktest SIMU PHY PHY_NR PHY_COMMON m
${
ATLAS_LIBRARIES
}
)
add_executable
(
ldpctest
${
OPENAIR1_DIR
}
/PHY/CODING/TESTBENCH/ldpctest.c
)
add_executable
(
ldpctest
${
OPENAIR1_DIR
}
/PHY/CODING/TESTBENCH/ldpctest.c
)
target_link_libraries
(
ldpctest SIMU PHY PHY_NR m
${
ATLAS_LIBRARIES
}
)
target_link_libraries
(
ldpctest SIMU PHY PHY_NR m
${
ATLAS_LIBRARIES
}
)
...
...
openair1/PHY/CODING/TESTBENCH/ldpctest.c
View file @
dd61e5a7
...
@@ -382,12 +382,12 @@ int test_ldpc(short No_iteration,
...
@@ -382,12 +382,12 @@ int test_ldpc(short No_iteration,
//Uncoded BER
//Uncoded BER
if
(
channel_output_fixed
[
j
][
i
]
<
0
)
if
(
channel_output_fixed
[
j
][
i
]
<
0
)
channel_output_uncoded
[
j
][
i
]
=
1
;
//QPSK demod
channel_output_uncoded
[
j
][
i
]
=
1
;
//QPSK demod
else
else
channel_output_uncoded
[
j
][
i
]
=
0
;
channel_output_uncoded
[
j
][
i
]
=
0
;
if
(
channel_output_uncoded
[
j
][
i
]
!=
channel_input
[
j
][
i
-
2
*
Zc
])
if
(
channel_output_uncoded
[
j
][
i
]
!=
channel_input
[
j
][
i
-
2
*
Zc
])
*
errors_bit_uncoded
=
(
*
errors_bit_uncoded
)
+
1
;
*
errors_bit_uncoded
=
(
*
errors_bit_uncoded
)
+
1
;
}
}
}
// End segments
}
// End segments
...
...
openair1/PHY/CODING/TESTBENCH/polartest.c
View file @
dd61e5a7
...
@@ -62,7 +62,6 @@ int main(int argc, char *argv[]) {
...
@@ -62,7 +62,6 @@ int main(int argc, char *argv[]) {
int16_t
nBitError
=
0
;
// -1 = Decoding failed (All list entries have failed the CRC checks).
int16_t
nBitError
=
0
;
// -1 = Decoding failed (All list entries have failed the CRC checks).
uint32_t
decoderState
=
0
,
blockErrorState
=
0
;
//0 = Success, -1 = Decoding failed, 1 = Block Error.
uint32_t
decoderState
=
0
,
blockErrorState
=
0
;
//0 = Success, -1 = Decoding failed, 1 = Block Error.
uint16_t
testLength
=
0
,
coderLength
=
0
,
blockErrorCumulative
=
0
,
bitErrorCumulative
=
0
;
uint16_t
testLength
=
0
,
coderLength
=
0
,
blockErrorCumulative
=
0
,
bitErrorCumulative
=
0
;
double
timeEncoderCumulative
=
0
,
timeDecoderCumulative
=
0
;
uint8_t
aggregation_level
=
8
,
decoderListSize
=
8
,
pathMetricAppr
=
0
,
matlabDebug
=
0
;
uint8_t
aggregation_level
=
8
,
decoderListSize
=
8
,
pathMetricAppr
=
0
,
matlabDebug
=
0
;
while
((
arguments
=
getopt
(
argc
,
argv
,
"s:d:f:c:i:l:a:hqgm"
))
!=
-
1
)
while
((
arguments
=
getopt
(
argc
,
argv
,
"s:d:f:c:i:l:a:hqgm"
))
!=
-
1
)
...
@@ -217,7 +216,7 @@ int main(int argc, char *argv[]) {
...
@@ -217,7 +216,7 @@ int main(int argc, char *argv[]) {
memset
(
dci_estimation
,
0
,
sizeof
(
uint32_t
)
*
4
);
memset
(
dci_estimation
,
0
,
sizeof
(
uint32_t
)
*
4
);
printf
(
"dci_estimation: [0]->0x%08x
\t
[1]->0x%08x
\t
[2]->0x%08x
\t
[3]->0x%08x
\n
"
,
printf
(
"dci_estimation: [0]->0x%08x
\t
[1]->0x%08x
\t
[2]->0x%08x
\t
[3]->0x%08x
\n
"
,
dci_estimation
[
0
],
dci_estimation
[
1
],
dci_estimation
[
2
],
dci_estimation
[
3
]);
dci_estimation
[
0
],
dci_estimation
[
1
],
dci_estimation
[
2
],
dci_estimation
[
3
]);
nr_bit2byte_uint32_8
_t
(
encoder_output
,
currentPtrDCI
->
encoderLength
,
encoder_outputByte
);
nr_bit2byte_uint32_8
(
encoder_output
,
currentPtrDCI
->
encoderLength
,
encoder_outputByte
);
printf
(
"[polartest] encoder_outputByte: "
);
printf
(
"[polartest] encoder_outputByte: "
);
for
(
int
i
=
0
;
i
<
currentPtrDCI
->
encoderLength
;
i
++
)
printf
(
"%d-"
,
encoder_outputByte
[
i
]);
for
(
int
i
=
0
;
i
<
currentPtrDCI
->
encoderLength
;
i
++
)
printf
(
"%d-"
,
encoder_outputByte
[
i
]);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
@@ -257,7 +256,7 @@ int main(int argc, char *argv[]) {
...
@@ -257,7 +256,7 @@ int main(int argc, char *argv[]) {
uint32_t
testInputcrc2
=
0x00291880
;
uint32_t
testInputcrc2
=
0x00291880
;
uint8_t
testInputCRC2
[
8
];
uint8_t
testInputCRC2
[
8
];
nr_crc_bit2bit_uint32_8
_t
(
testInputCRC
,
32
,
testInputCRC2
);
nr_crc_bit2bit_uint32_8
(
testInputCRC
,
32
,
testInputCRC2
);
printf
(
"testInputCRC2: [0]->%x
\t
[1]->%x
\t
[2]->%x
\t
[3]->%x
\n
"
printf
(
"testInputCRC2: [0]->%x
\t
[1]->%x
\t
[2]->%x
\t
[3]->%x
\n
"
" [4]->%x
\t
[5]->%x
\t
[6]->%x
\t
[7]->%x
\n
"
,
" [4]->%x
\t
[5]->%x
\t
[6]->%x
\t
[7]->%x
\n
"
,
testInputCRC2
[
0
],
testInputCRC2
[
1
],
testInputCRC2
[
2
],
testInputCRC2
[
3
],
testInputCRC2
[
0
],
testInputCRC2
[
1
],
testInputCRC2
[
2
],
testInputCRC2
[
3
],
...
@@ -339,7 +338,7 @@ int main(int argc, char *argv[]) {
...
@@ -339,7 +338,7 @@ int main(int argc, char *argv[]) {
for
(
int
i
=
0
;
i
<
currentPtr
->
payloadBits
;
i
++
)
aPrioriArray
[
i
]
=
NAN
;
for
(
int
i
=
0
;
i
<
currentPtr
->
payloadBits
;
i
++
)
aPrioriArray
[
i
]
=
NAN
;
for
(
SNR
=
SNRstart
;
SNR
<=
SNRstop
;
SNR
+=
SNRinc
)
{
for
(
SNR
=
SNRstart
;
SNR
<=
SNRstop
;
SNR
+=
SNRinc
)
{
printf
(
"SNR %f
\n
"
,
SNR
);
printf
(
"SNR %f
\n
"
,
SNR
);
SNR_lin
=
pow
(
10
,
SNR
/
10
);
SNR_lin
=
pow
(
10
,
SNR
/
10
);
for
(
itr
=
1
;
itr
<=
iterations
;
itr
++
)
{
for
(
itr
=
1
;
itr
<=
iterations
;
itr
++
)
{
...
@@ -420,11 +419,11 @@ int main(int argc, char *argv[]) {
...
@@ -420,11 +419,11 @@ int main(int argc, char *argv[]) {
uint8_t
nr_pbch_interleaver
[
NR_POLAR_PBCH_PAYLOAD_BITS
];
uint8_t
nr_pbch_interleaver
[
NR_POLAR_PBCH_PAYLOAD_BITS
];
memset
((
void
*
)
nr_pbch_interleaver
,
0
,
NR_POLAR_PBCH_PAYLOAD_BITS
);
memset
((
void
*
)
nr_pbch_interleaver
,
0
,
NR_POLAR_PBCH_PAYLOAD_BITS
);
nr_init_pbch_interleaver
(
nr_pbch_interleaver
);
nr_init_pbch_interleaver
(
nr_pbch_interleaver
);
for
(
int
i
=
0
;
i
<=
31
;
i
++
)
/*
for (int i=0; i<=31;i++)
printf("nr_pbch_interleaver[%d]=%d\n",i,nr_pbch_interleaver[i]);
printf("nr_pbch_interleaver[%d]=%d\n",i,nr_pbch_interleaver[i]);
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
printf
(
"nr_pbch_interleaver_operation[%d]=%d
\n
"
,
i
,(
*
(
nr_pbch_interleaver
+
i
)));
printf("nr_pbch_interleaver_operation[%d]=%d\n",i,(*(nr_pbch_interleaver+i)));
*/
start_meas
(
&
timeEncoder
);
start_meas
(
&
timeEncoder
);
...
@@ -438,25 +437,28 @@ int main(int argc, char *argv[]) {
...
@@ -438,25 +437,28 @@ int main(int argc, char *argv[]) {
printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/
printf("encoderOutput: [1]->0x%08x\n", encoderOutput[1]);*/
//Bit-to-byte:
//Bit-to-byte:
nr_bit2byte_uint32_8
_t
(
encoderOutput
,
coderLength
,
encoderOutputByte
);
nr_bit2byte_uint32_8
(
encoderOutput
,
coderLength
,
encoderOutputByte
);
//BPSK modulation
//BPSK modulation
for
(
int
i
=
0
;
i
<
coderLength
;
i
++
)
{
for
(
int
i
=
0
;
i
<
coderLength
;
i
++
)
{
if
(
encoderOutputByte
[
i
]
==
0
)
if
(
encoderOutputByte
[
i
]
==
0
)
modulatedInput
[
i
]
=
1
/
sqrt
(
2
);
modulatedInput
[
i
]
=
1
;
//modulatedInput[i]=1/sqrt(2);
else
else
modulatedInput
[
i
]
=
(
-
1
)
/
sqrt
(
2
);
modulatedInput
[
i
]
=
(
-
1
);
//modulatedInput[i]=((-1)/sqrt(2));
channelOutput
[
i
]
=
modulatedInput
[
i
]
+
(
gaussdouble
(
0
.
0
,
1
.
0
)
*
(
1
/
sqrt
(
2
*
SNR_lin
)));
channelOutput
[
i
]
=
modulatedInput
[
i
]
+
(
gaussdouble
(
0
.
0
,
1
.
0
)
*
(
1
/
sqrt
(
SNR_lin
)));
//channelOutput[i] = modulatedInput[i] + (gaussdouble(0.0,1.0) * (1/sqrt(2*SNR_lin)));
if
(
decoder_int16
==
1
)
{
if
(
decoder_int16
==
1
)
{
if
(
channelOutput
[
i
]
>
15
)
channelOutput_int16
[
i
]
=
127
;
if
(
channelOutput
[
i
]
>
15
)
else
if
(
channelOutput
[
i
]
<
-
16
)
channelOutput_int16
[
i
]
=
-
128
;
channelOutput_int16
[
i
]
=
127
;
else
channelOutput_int16
[
i
]
=
(
int16_t
)
(
8
*
channelOutput
[
i
]);
else
if
(
channelOutput
[
i
]
<
-
16
)
channelOutput_int16
[
i
]
=
-
128
;
else
channelOutput_int16
[
i
]
=
(
int16_t
)
(
8
*
channelOutput
[
i
]);
}
}
}
}
start_meas
(
&
timeDecoder
);
start_meas
(
&
timeDecoder
);
...
@@ -466,44 +468,38 @@ int main(int argc, char *argv[]) {
...
@@ -466,44 +468,38 @@ int main(int argc, char *argv[]) {
NR_POLAR_DECODER_LISTSIZE,
NR_POLAR_DECODER_LISTSIZE,
aPrioriArray,
aPrioriArray,
NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/
NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION);*/
if
(
decoder_int16
==
0
)
if
(
decoder_int16
==
1
)
decoderState
=
polar_decoder_aPriori
(
channelOutput
,
decoderState
=
polar_decoder_int16
(
channelOutput_int16
,
estimatedOutput
,
(
uint64_t
*
)
estimatedOutput
,
currentPtr
,
currentPtr
);
NR_POLAR_DECODER_LISTSIZE
,
else
NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION
,
decoderState
=
polar_decoder_aPriori
(
channelOutput
,
aPrioriArray
);
estimatedOutput
,
currentPtr
,
else
NR_POLAR_DECODER_LISTSIZE
,
decoderState
=
polar_decoder_int16
(
channelOutput_int16
,
NR_POLAR_DECODER_PATH_METRIC_APPROXIMATION
,
(
uint64_t
*
)
estimatedOutput
,
aPrioriArray
);
currentPtr
);
stop_meas
(
&
timeDecoder
);
stop_meas
(
&
timeDecoder
);
/*printf("testInput: [0]->0x%08x\n", testInput[0]);
/*printf("testInput: [0]->0x%08x\n", testInput[0]);
printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/
printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/
//calculate errors
//calculate errors
if
(
decoderState
!=
0
)
{
if
(
decoderState
!=
0
)
{
blockErrorState
=-
1
;
blockErrorState
=-
1
;
nBitError
=-
1
;
nBitError
=-
1
;
}
else
{
}
else
{
for
(
int
j
=
0
;
j
<
currentPtr
->
payloadBits
;
j
++
)
{
for
(
int
j
=
0
;
j
<
currentPtr
->
payloadBits
;
j
++
)
{
if
(((
estimatedOutput
[
0
]
>>
j
)
&
1
)
!=
((
testInput
[
0
]
>>
j
)
&
1
))
nBitError
++
;
if
(((
estimatedOutput
[
0
]
>>
j
)
&
1
)
!=
((
testInput
[
0
]
>>
j
)
&
1
))
nBitError
++
;
// printf("bit %d: %d => %d\n",j,(testInput[0]>>j)&1,(estimatedOutput[0]>>j)&1);
// printf("bit %d: %d => %d\n",j,(testInput[0]>>j)&1,(estimatedOutput[0]>>j)&1);
}
}
if
(
nBitError
>
0
)
{
blockErrorState
=
1
;
if
(
nBitError
>
0
)
{
//printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]);
blockErrorState
=
1
;
}
// printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]);
}
}
}
//Iteration times are in microseconds.
//Iteration times are in microseconds.
timeEncoderCumulative
+=
(
timeEncoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
));
timeDecoderCumulative
+=
(
timeDecoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
));
fprintf
(
logFile
,
",%f,%d,%d,%f,%f
\n
"
,
SNR
,
nBitError
,
blockErrorState
,
fprintf
(
logFile
,
",%f,%d,%d,%f,%f
\n
"
,
SNR
,
nBitError
,
blockErrorState
,
(
timeEncoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
)),
(
timeDecoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
)));
(
timeEncoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
)),
(
timeDecoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
)));
...
@@ -521,17 +517,16 @@ int main(int argc, char *argv[]) {
...
@@ -521,17 +517,16 @@ int main(int argc, char *argv[]) {
}
}
//Calculate error statistics for the SNR.
//Calculate error statistics for the SNR.
printf
(
"[ListSize=%d, Appr=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%
9.3fus, t_Decoder=%9.3
fus
\n
"
,
printf
(
"[ListSize=%d, Appr=%d] SNR=%+8.3f, BLER=%9.6f, BER=%12.9f, t_Encoder=%
12.6fus, t_Decoder=%12.6
fus
\n
"
,
decoderListSize
,
pathMetricAppr
,
SNR
,
((
double
)
blockErrorCumulative
/
iterations
),
decoderListSize
,
pathMetricAppr
,
SNR
,
((
double
)
blockErrorCumulative
/
iterations
),
((
double
)
bitErrorCumulative
/
(
iterations
*
testLength
)),
((
double
)
bitErrorCumulative
/
(
iterations
*
testLength
)),
(
double
)
timeEncoder
.
diff
/
timeEncoder
.
trials
/
(
cpu_freq_GHz
*
1000
.
0
),(
double
)
timeDecoder
.
diff
/
timeDecoder
.
trials
/
(
cpu_freq_GHz
*
1000
.
0
));
(
double
)
timeEncoder
.
diff
/
timeEncoder
.
trials
/
(
cpu_freq_GHz
*
1000
.
0
),
//(timeEncoderCumulative/iterations),timeDecoderCumulative/iterations
);
(
double
)
timeDecoder
.
diff
/
timeDecoder
.
trials
/
(
cpu_freq_GHz
*
1000
.
0
)
);
if
(
blockErrorCumulative
==
0
&&
bitErrorCumulative
==
0
)
if
(
blockErrorCumulative
==
0
&&
bitErrorCumulative
==
0
)
break
;
break
;
blockErrorCumulative
=
0
;
bitErrorCumulative
=
0
;
blockErrorCumulative
=
0
;
bitErrorCumulative
=
0
;
timeEncoderCumulative
=
0
;
timeDecoderCumulative
=
0
;
}
}
print_meas
(
&
timeEncoder
,
"polar_encoder"
,
NULL
,
NULL
);
print_meas
(
&
timeEncoder
,
"polar_encoder"
,
NULL
,
NULL
);
...
...
openair1/PHY/CODING/TESTBENCH/smallblocktest.c
0 → 100644
View file @
dd61e5a7
#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
#include "SIMULATION/TOOLS/sim.h"
#include <getopt.h>
//#define DEBUG_SMALLBLOCKTEST
signed
char
quantize
(
double
D
,
double
x
,
unsigned
char
B
)
{
double
qxd
;
short
maxlev
;
qxd
=
floor
(
x
/
D
);
maxlev
=
1
<<
(
B
-
1
);
//(char)(pow(2,B-1));
if
(
qxd
<=
-
maxlev
)
qxd
=
-
maxlev
;
else
if
(
qxd
>=
maxlev
)
qxd
=
maxlev
-
1
;
return
((
char
)
qxd
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
time_stats_t
timeEncoder
,
timeDecoder
;
opp_enabled
=
1
;
cpu_freq_GHz
=
get_cpu_freq_GHz
();
reset_meas
(
&
timeEncoder
);
reset_meas
(
&
timeDecoder
);
randominit
(
0
);
int
arguments
,
iterations
=
1000
,
matlabDebug
=
0
,
messageLength
=
11
;
uint32_t
testInput
,
encoderOutput
,
codingDifference
,
nBitError
=
0
,
blockErrorState
=
0
,
blockErrorCumulative
=
0
,
bitErrorCumulative
=
0
;
uint16_t
estimatedOutput
;
double
SNRstart
=
-
20
.
0
,
SNRstop
=
5
.
0
,
SNRinc
=
0
.
5
;
//dB
double
SNR
,
SNR_lin
,
sigma
;
double
modulatedInput
[
NR_SMALL_BLOCK_CODED_BITS
],
channelOutput
[
NR_SMALL_BLOCK_CODED_BITS
];
int16_t
channelOutput_int16
[
NR_SMALL_BLOCK_CODED_BITS
];
int8_t
channelOutput_int8
[
NR_SMALL_BLOCK_CODED_BITS
];
unsigned
char
qbits
=
8
;
while
((
arguments
=
getopt
(
argc
,
argv
,
"s:d:f:l:i:mhg"
))
!=
-
1
)
switch
(
arguments
)
{
case
's'
:
SNRstart
=
atof
(
optarg
);
break
;
case
'd'
:
SNRinc
=
atof
(
optarg
);
break
;
case
'f'
:
SNRstop
=
atof
(
optarg
);
break
;
case
'l'
:
messageLength
=
atoi
(
optarg
);
break
;
case
'i'
:
iterations
=
atoi
(
optarg
);
break
;
case
'm'
:
matlabDebug
=
1
;
//#define DEBUG_POLAR_MATLAB
break
;
case
'g'
:
iterations
=
1
;
SNRstart
=
-
6
.
0
;
SNRstop
=
-
6
.
0
;
messageLength
=
11
;
break
;
case
'h'
:
printf
(
"./smallblocktest -s SNRstart -d SNRinc -f SNRstop -l messageLength -i iterations -m Matlab Debug
\n
"
);
exit
(
-
1
);
default:
perror
(
"[smallblocktest.c] Problem at argument parsing with getopt"
);
exit
(
-
1
);
}
uint16_t
mask
=
0x07ff
>>
(
11
-
messageLength
);
for
(
SNR
=
SNRstart
;
SNR
<=
SNRstop
;
SNR
+=
SNRinc
)
{
printf
(
"SNR %f
\n
"
,
SNR
);
SNR_lin
=
pow
(
10
,
SNR
/
10
.
0
);
sigma
=
1
.
0
/
sqrt
(
SNR_lin
);
for
(
int
itr
=
1
;
itr
<=
iterations
;
itr
++
)
{
//Generate random test input of length "messageLength"
testInput
=
0
;
for
(
int
i
=
1
;
i
<
messageLength
;
i
++
)
{
testInput
|=
(
((
uint32_t
)
(
rand
()
%
2
))
&
1
);
testInput
<<=
1
;
}
testInput
|=
(
((
uint32_t
)
(
rand
()
%
2
))
&
1
);
//Encoding
start_meas
(
&
timeEncoder
);
encoderOutput
=
encodeSmallBlock
((
uint16_t
*
)
&
testInput
,
(
uint8_t
)
messageLength
);
stop_meas
(
&
timeEncoder
);
for
(
int
i
=
0
;
i
<
NR_SMALL_BLOCK_CODED_BITS
;
i
++
)
{
//BPSK modulation
if
((
encoderOutput
>>
i
)
&
1
)
{
modulatedInput
[
i
]
=-
1
;
}
else
{
modulatedInput
[
i
]
=
1
;
}
//AWGN
channelOutput
[
i
]
=
modulatedInput
[
i
]
+
(
gaussdouble
(
0
.
0
,
1
.
0
)
*
(
1
/
sqrt
(
SNR_lin
)
)
);
//Quantization
channelOutput_int8
[
i
]
=
quantize
(
sigma
/
16
.
0
,
channelOutput
[
i
],
qbits
);
}
//Decoding
start_meas
(
&
timeDecoder
);
estimatedOutput
=
decodeSmallBlock
(
channelOutput_int8
,
(
uint8_t
)
messageLength
);
stop_meas
(
&
timeDecoder
);
#ifdef DEBUG_SMALLBLOCKTEST
printf
(
"[smallblocktest] Input = 0x%x, Output = 0x%x, DecoderOutput = 0x%x
\n
"
,
testInput
,
encoderOutput
,
estimatedOutput
);
for
(
int
i
=
0
;
i
<
32
;
i
++
)
printf
(
"[smallblocktest] Input[%d] = %d, Output[%d] = %d, Mask[%d] = %d
\n
"
,
i
,
(
testInput
>>
i
)
&
1
,
i
,
(
estimatedOutput
>>
i
)
&
1
,
i
,
(
mask
>>
i
)
&
1
);
#endif
//Error Calculation
estimatedOutput
&=
mask
;
codingDifference
=
((
uint32_t
)
estimatedOutput
)
^
testInput
;
// Count the # of 1's in codingDifference by Brian Kernighan’s algorithm.
//for (int i=0;i<32;i++)
//printf("[smallblocktest] Input[%d] = %d, Output[%d] = %d, codingDifference[%d]=%d, Mask[%d] = %d, bitError = %d\n", i, (testInput>>i)&1, i, (estimatedOutput>>i)&1, i, (codingDifference>>i)&1, i, (mask>>i)&1, nBitError);
for
(
nBitError
=
0
;
codingDifference
;
nBitError
++
)
codingDifference
&=
codingDifference
-
1
;
blockErrorState
=
(
nBitError
>
0
)
?
1
:
0
;
blockErrorCumulative
+=
blockErrorState
;
bitErrorCumulative
+=
nBitError
;
nBitError
=
0
;
blockErrorState
=
0
;
}
//Error statistics for the SNR; iteration times are in nanoseconds and microseconds, respectively.
printf
(
"[smallblocktest] SNR=%+7.3f, BER=%9.6f, BLER=%9.6f, t_Encoder=%9.3fns, t_Decoder=%7.3fus
\n
"
,
SNR
,
((
double
)
bitErrorCumulative
/
(
iterations
*
messageLength
)),
((
double
)
blockErrorCumulative
/
iterations
),
((
double
)
timeEncoder
.
diff
/
timeEncoder
.
trials
)
/
(
cpu_freq_GHz
),
((
double
)
timeDecoder
.
diff
/
timeDecoder
.
trials
)
/
(
cpu_freq_GHz
*
1000
.
0
));
blockErrorCumulative
=
0
;
bitErrorCumulative
=
0
;
}
print_meas
(
&
timeEncoder
,
"smallblock_encoder"
,
NULL
,
NULL
);
print_meas
(
&
timeDecoder
,
"smallblock_decoder"
,
NULL
,
NULL
);
return
(
0
);
}
openair1/PHY/CODING/nrPolar_tools/nr_bitwise_operations.c
View file @
dd61e5a7
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void
nr_bit2byte_uint32_8
_t
(
uint32_t
*
in
,
uint16_t
arraySize
,
uint8_t
*
out
)
{
void
nr_bit2byte_uint32_8
(
uint32_t
*
in
,
uint16_t
arraySize
,
uint8_t
*
out
)
{
uint8_t
arrayInd
=
ceil
(
arraySize
/
32
.
0
);
uint8_t
arrayInd
=
ceil
(
arraySize
/
32
.
0
);
for
(
int
i
=
0
;
i
<
(
arrayInd
-
1
);
i
++
)
{
for
(
int
i
=
0
;
i
<
(
arrayInd
-
1
);
i
++
)
{
for
(
int
j
=
0
;
j
<
32
;
j
++
)
{
for
(
int
j
=
0
;
j
<
32
;
j
++
)
{
...
@@ -32,7 +32,7 @@ void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) {
...
@@ -32,7 +32,7 @@ void nr_bit2byte_uint32_8_t(uint32_t *in, uint16_t arraySize, uint8_t *out) {
for
(
int
j
=
0
;
j
<
arraySize
-
((
arrayInd
-
1
)
*
32
);
j
++
)
out
[
j
+
((
arrayInd
-
1
)
*
32
)]
=
(
in
[(
arrayInd
-
1
)]
>>
j
)
&
1
;
for
(
int
j
=
0
;
j
<
arraySize
-
((
arrayInd
-
1
)
*
32
);
j
++
)
out
[
j
+
((
arrayInd
-
1
)
*
32
)]
=
(
in
[(
arrayInd
-
1
)]
>>
j
)
&
1
;
}
}
void
nr_byte2bit_uint8_32
_t
(
uint8_t
*
in
,
uint16_t
arraySize
,
uint32_t
*
out
)
{
void
nr_byte2bit_uint8_32
(
uint8_t
*
in
,
uint16_t
arraySize
,
uint32_t
*
out
)
{
uint8_t
arrayInd
=
ceil
(
arraySize
/
32
.
0
);
uint8_t
arrayInd
=
ceil
(
arraySize
/
32
.
0
);
for
(
int
i
=
0
;
i
<
arrayInd
;
i
++
)
{
for
(
int
i
=
0
;
i
<
arrayInd
;
i
++
)
{
out
[
i
]
=
0
;
out
[
i
]
=
0
;
...
@@ -44,7 +44,7 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) {
...
@@ -44,7 +44,7 @@ void nr_byte2bit_uint8_32_t(uint8_t *in, uint16_t arraySize, uint32_t *out) {
}
}
}
}
void
nr_crc_bit2bit_uint32_8
_t
(
uint32_t
*
in
,
uint16_t
arraySize
,
uint8_t
*
out
)
{
void
nr_crc_bit2bit_uint32_8
(
uint32_t
*
in
,
uint16_t
arraySize
,
uint8_t
*
out
)
{
out
[
0
]
=
0xff
;
out
[
0
]
=
0xff
;
out
[
1
]
=
0xff
;
out
[
1
]
=
0xff
;
out
[
2
]
=
0xff
;
out
[
2
]
=
0xff
;
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
View file @
dd61e5a7
This diff is collapsed.
Click to expand it.
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
View file @
dd61e5a7
...
@@ -37,15 +37,15 @@
...
@@ -37,15 +37,15 @@
//#define DEBUG_NEW_IMPL 1
//#define DEBUG_NEW_IMPL 1
void
updateLLR
(
double
***
llr
,
void
updateLLR
(
double
***
llr
,
uint8_t
**
llrU
,
uint8_t
**
llrU
,
uint8_t
***
bit
,
uint8_t
***
bit
,
uint8_t
**
bitU
,
uint8_t
**
bitU
,
uint8_t
listSize
,
uint8_t
listSize
,
uint16_t
row
,
uint16_t
row
,
uint16_t
col
,
uint16_t
col
,
uint16_t
xlen
,
uint16_t
xlen
,
uint8_t
ylen
,
uint8_t
ylen
,
uint8_t
approximation
)
uint8_t
approximation
)
{
{
uint16_t
offset
=
(
xlen
/
(
pow
(
2
,(
ylen
-
col
-
1
))));
uint16_t
offset
=
(
xlen
/
(
pow
(
2
,(
ylen
-
col
-
1
))));
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
...
@@ -73,7 +73,6 @@ void updateBit(uint8_t ***bit,
...
@@ -73,7 +73,6 @@ void updateBit(uint8_t ***bit,
uint16_t
xlen
,
uint16_t
xlen
,
uint8_t
ylen
)
uint8_t
ylen
)
{
{
uint16_t
offset
=
(
xlen
/
(
pow
(
2
,(
ylen
-
col
)))
);
uint16_t
offset
=
(
xlen
/
(
pow
(
2
,(
ylen
-
col
)))
);
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
...
@@ -107,7 +106,6 @@ void updatePathMetric(double *pathMetric,
...
@@ -107,7 +106,6 @@ void updatePathMetric(double *pathMetric,
}
}
}
}
void
updatePathMetric2
(
double
*
pathMetric
,
void
updatePathMetric2
(
double
*
pathMetric
,
double
***
llr
,
double
***
llr
,
uint8_t
listSize
,
uint8_t
listSize
,
...
@@ -139,10 +137,7 @@ void updatePathMetric2(double *pathMetric,
...
@@ -139,10 +137,7 @@ void updatePathMetric2(double *pathMetric,
}
}
free
(
tempPM
);
free
(
tempPM
);
}
}
void
computeLLR
(
double
***
llr
,
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
row
,
...
@@ -161,8 +156,6 @@ void computeLLR(double ***llr,
...
@@ -161,8 +156,6 @@ void computeLLR(double ***llr,
}
else
{
//eq. (8a)
}
else
{
//eq. (8a)
llr
[
row
][
col
][
i
]
=
log
((
exp
(
a
+
b
)
+
1
)
/
(
exp
(
a
)
+
exp
(
b
)));
llr
[
row
][
col
][
i
]
=
log
((
exp
(
a
+
b
)
+
1
)
/
(
exp
(
a
)
+
exp
(
b
)));
}
}
}
}
void
updateCrcChecksum
(
uint8_t
**
crcChecksum
,
void
updateCrcChecksum
(
uint8_t
**
crcChecksum
,
...
@@ -191,9 +184,16 @@ void updateCrcChecksum2(uint8_t **crcChecksum,
...
@@ -191,9 +184,16 @@ void updateCrcChecksum2(uint8_t **crcChecksum,
}
}
}
}
void
build_decoder_tree
(
t_nrPolar_params
*
polarParams
)
{
polarParams
->
tree
.
num_nodes
=
0
;
polarParams
->
tree
.
root
=
add_nodes
(
polarParams
->
n
,
0
,
polarParams
);
#ifdef DEBUG_NEW_IMPL
printf
(
"root : left %p, right %p
\n
"
,
polarParams
->
tree
.
root
->
left
,
polarParams
->
tree
.
root
->
right
);
#endif
}
decoder_node_t
*
new_decoder_node
(
int
first_leaf_index
,
int
level
)
{
decoder_node_t
*
new_decoder_node
(
int
first_leaf_index
,
int
level
)
{
decoder_node_t
*
node
=
(
decoder_node_t
*
)
malloc
(
sizeof
(
decoder_node_t
));
decoder_node_t
*
node
=
(
decoder_node_t
*
)
malloc
(
sizeof
(
decoder_node_t
));
...
@@ -208,32 +208,34 @@ decoder_node_t *new_decoder_node(int first_leaf_index,int level) {
...
@@ -208,32 +208,34 @@ decoder_node_t *new_decoder_node(int first_leaf_index,int level) {
node
->
beta
=
(
int16_t
*
)
malloc16
(
node
->
Nv
*
sizeof
(
int16_t
));
node
->
beta
=
(
int16_t
*
)
malloc16
(
node
->
Nv
*
sizeof
(
int16_t
));
memset
((
void
*
)
node
->
beta
,
-
1
,
node
->
Nv
*
sizeof
(
int16_t
));
memset
((
void
*
)
node
->
beta
,
-
1
,
node
->
Nv
*
sizeof
(
int16_t
));
return
(
node
);
return
(
node
);
}
}
decoder_node_t
*
add_nodes
(
int
level
,
int
first_leaf_index
,
t_nrPolar_params
*
pp
)
{
decoder_node_t
*
add_nodes
(
int
level
,
int
first_leaf_index
,
t_nrPolar_params
*
polarParams
)
{
int
all_frozen_below
=
1
;
int
all_frozen_below
=
1
;
int
Nv
=
1
<<
level
;
int
Nv
=
1
<<
level
;
decoder_node_t
*
new_node
=
new_decoder_node
(
first_leaf_index
,
level
);
decoder_node_t
*
new_node
=
new_decoder_node
(
first_leaf_index
,
level
);
#ifdef DEBUG_NEW_IMPL
#ifdef DEBUG_NEW_IMPL
printf
(
"New node %d order %d, level %d
\n
"
,
p
p
->
tree
.
num_nodes
,
Nv
,
level
);
printf
(
"New node %d order %d, level %d
\n
"
,
p
olarParams
->
tree
.
num_nodes
,
Nv
,
level
);
#endif
#endif
p
p
->
tree
.
num_nodes
++
;
p
olarParams
->
tree
.
num_nodes
++
;
if
(
level
==
0
)
{
if
(
level
==
0
)
{
#ifdef DEBUG_NEW_IMPL
#ifdef DEBUG_NEW_IMPL
printf
(
"leaf %d (%s)
\n
"
,
first_leaf_index
,
pp
->
information_bit_pattern
[
first_leaf_index
]
==
1
?
"information or crc"
:
"frozen"
);
printf
(
"leaf %d (%s)
\n
"
,
first_leaf_index
,
polarParams
->
information_bit_pattern
[
first_leaf_index
]
==
1
?
"information or crc"
:
"frozen"
);
#endif
#endif
new_node
->
leaf
=
1
;
new_node
->
leaf
=
1
;
new_node
->
all_frozen
=
p
p
->
information_bit_pattern
[
first_leaf_index
]
==
0
?
1
:
0
;
new_node
->
all_frozen
=
p
olarParams
->
information_bit_pattern
[
first_leaf_index
]
==
0
?
1
:
0
;
return
new_node
;
// this is a leaf node
return
new_node
;
// this is a leaf node
}
}
for
(
int
i
=
0
;
i
<
Nv
;
i
++
)
{
for
(
int
i
=
0
;
i
<
Nv
;
i
++
)
{
if
(
pp
->
information_bit_pattern
[
i
+
first_leaf_index
]
>
0
)
all_frozen_below
=
0
;
if
(
polarParams
->
information_bit_pattern
[
i
+
first_leaf_index
]
>
0
)
all_frozen_below
=
0
;
}
}
if
(
all_frozen_below
==
0
)
new_node
->
left
=
add_nodes
(
level
-
1
,
first_leaf_index
,
pp
);
if
(
all_frozen_below
==
0
)
new_node
->
left
=
add_nodes
(
level
-
1
,
first_leaf_index
,
polarParams
);
else
{
else
{
#ifdef DEBUG_NEW_IMPL
#ifdef DEBUG_NEW_IMPL
printf
(
"aggregating frozen bits %d ... %d at level %d (%s)
\n
"
,
first_leaf_index
,
first_leaf_index
+
Nv
-
1
,
level
,((
first_leaf_index
/
Nv
)
&
1
)
==
0
?
"left"
:
"right"
);
printf
(
"aggregating frozen bits %d ... %d at level %d (%s)
\n
"
,
first_leaf_index
,
first_leaf_index
+
Nv
-
1
,
level
,((
first_leaf_index
/
Nv
)
&
1
)
==
0
?
"left"
:
"right"
);
...
@@ -241,22 +243,14 @@ decoder_node_t *add_nodes(int level,int first_leaf_index,t_nrPolar_params *pp) {
...
@@ -241,22 +243,14 @@ decoder_node_t *add_nodes(int level,int first_leaf_index,t_nrPolar_params *pp) {
new_node
->
leaf
=
1
;
new_node
->
leaf
=
1
;
new_node
->
all_frozen
=
1
;
new_node
->
all_frozen
=
1
;
}
}
if
(
all_frozen_below
==
0
)
new_node
->
right
=
add_nodes
(
level
-
1
,
first_leaf_index
+
(
Nv
/
2
),
pp
);
if
(
all_frozen_below
==
0
)
new_node
->
right
=
add_nodes
(
level
-
1
,
first_leaf_index
+
(
Nv
/
2
),
polarParams
);
#ifdef DEBUG_NEW_IMPL
#ifdef DEBUG_NEW_IMPL
printf
(
"new_node (%d): first_leaf_index %d, left %p, right %p
\n
"
,
Nv
,
first_leaf_index
,
new_node
->
left
,
new_node
->
right
);
printf
(
"new_node (%d): first_leaf_index %d, left %p, right %p
\n
"
,
Nv
,
first_leaf_index
,
new_node
->
left
,
new_node
->
right
);
#endif
return
(
new_node
);
}
void
build_decoder_tree
(
t_nrPolar_params
*
pp
)
{
pp
->
tree
.
num_nodes
=
0
;
pp
->
tree
.
root
=
add_nodes
(
pp
->
n
,
0
,
pp
);
#ifdef DEBUG_NEW_IMPL
printf
(
"root : left %p, right %p
\n
"
,
pp
->
tree
.
root
->
left
,
pp
->
tree
.
root
->
right
);
#endif
#endif
return
(
new_node
);
}
}
#if defined(__arm__) || defined(__aarch64__)
#if defined(__arm__) || defined(__aarch64__)
...
@@ -271,7 +265,7 @@ void build_decoder_tree(t_nrPolar_params *pp) {
...
@@ -271,7 +265,7 @@ void build_decoder_tree(t_nrPolar_params *pp) {
#define _mm_subs_pi16(a,b) vsub_s16(a,b)
#define _mm_subs_pi16(a,b) vsub_s16(a,b)
#endif
#endif
void
applyFtoleft
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
void
applyFtoleft
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
int16_t
*
alpha_v
=
node
->
alpha
;
int16_t
*
alpha_v
=
node
->
alpha
;
int16_t
*
alpha_l
=
node
->
left
->
alpha
;
int16_t
*
alpha_l
=
node
->
left
->
alpha
;
int16_t
*
betal
=
node
->
left
->
beta
;
int16_t
*
betal
=
node
->
left
->
beta
;
...
@@ -370,16 +364,16 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) {
...
@@ -370,16 +364,16 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) {
#endif
#endif
{
// equvalent scalar code to above, activated only on non x86/ARM architectures
{
// equvalent scalar code to above, activated only on non x86/ARM architectures
for
(
int
i
=
0
;
i
<
node
->
Nv
/
2
;
i
++
)
{
for
(
int
i
=
0
;
i
<
node
->
Nv
/
2
;
i
++
)
{
a
=
alpha_v
[
i
];
a
=
alpha_v
[
i
];
b
=
alpha_v
[
i
+
(
node
->
Nv
/
2
)];
b
=
alpha_v
[
i
+
(
node
->
Nv
/
2
)];
maska
=
a
>>
15
;
maska
=
a
>>
15
;
maskb
=
b
>>
15
;
maskb
=
b
>>
15
;
absa
=
(
a
+
maska
)
^
maska
;
absa
=
(
a
+
maska
)
^
maska
;
absb
=
(
b
+
maskb
)
^
maskb
;
absb
=
(
b
+
maskb
)
^
maskb
;
minabs
=
absa
<
absb
?
absa
:
absb
;
minabs
=
absa
<
absb
?
absa
:
absb
;
alpha_l
[
i
]
=
(
maska
^
maskb
)
==
0
?
minabs
:
-
minabs
;
alpha_l
[
i
]
=
(
maska
^
maskb
)
==
0
?
minabs
:
-
minabs
;
// printf("alphal[%d] %d (%d,%d)\n",i,alpha_l[i],a,b);
// printf("alphal[%d] %d (%d,%d)\n",i,alpha_l[i],a,b);
}
}
}
}
if
(
node
->
Nv
==
2
)
{
// apply hard decision on left node
if
(
node
->
Nv
==
2
)
{
// apply hard decision on left node
betal
[
0
]
=
(
alpha_l
[
0
]
>
0
)
?
-
1
:
1
;
betal
[
0
]
=
(
alpha_l
[
0
]
>
0
)
?
-
1
:
1
;
...
@@ -463,11 +457,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) {
...
@@ -463,11 +457,7 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) {
}
}
}
}
int16_t
all1
[
16
]
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
int16_t
all1
[
16
]
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
void
computeBeta
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
void
computeBeta
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
...
@@ -504,38 +494,35 @@ void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) {
...
@@ -504,38 +494,35 @@ void computeBeta(t_nrPolar_params *pp,decoder_node_t *node) {
int
ssr4len
=
node
->
Nv
/
2
/
8
;
int
ssr4len
=
node
->
Nv
/
2
/
8
;
register
__m128i
allones
=*
((
__m128i
*
)
all1
);
register
__m128i
allones
=*
((
__m128i
*
)
all1
);
for
(
int
i
=
0
;
i
<
sse4len
;
i
++
)
{
for
(
int
i
=
0
;
i
<
sse4len
;
i
++
)
{
((
__m256i
*
)
betav
)[
i
]
=
_mm_or_si128
(
_mm_cmpeq_epi16
(((
__m128i
*
)
betar
)[
i
],
((
__m256i
*
)
betav
)[
i
]
=
_mm_or_si128
(
_mm_cmpeq_epi16
(((
__m128i
*
)
betar
)[
i
],
((
__m128i
*
)
betal
)[
i
]),
allones
));
((
__m128i
*
)
betal
)[
i
]),
allones
));
}
}
}
}
else
if
(
sse4mod
==
4
)
{
else
if
(
sse4mod
==
4
)
{
((
__m64
*
)
betav
)[
0
]
=
_mm_or_si64
(
_mm_cmpeq_pi16
(((
__m64
*
)
betar
)[
0
],
((
__m64
*
)
betav
)[
0
]
=
_mm_or_si64
(
_mm_cmpeq_pi16
(((
__m64
*
)
betar
)[
0
],
((
__m64
*
)
betal
)[
0
]),
*
((
__m64
*
)
all1
));
((
__m64
*
)
betal
)[
0
]),
*
((
__m64
*
)
all1
));
}
}
else
else
#endif
#endif
{
{
for
(
int
i
=
0
;
i
<
node
->
Nv
/
2
;
i
++
)
{
for
(
int
i
=
0
;
i
<
node
->
Nv
/
2
;
i
++
)
{
betav
[
i
]
=
(
betal
[
i
]
!=
betar
[
i
])
?
1
:
-
1
;
betav
[
i
]
=
(
betal
[
i
]
!=
betar
[
i
])
?
1
:
-
1
;
}
}
}
}
}
}
else
memcpy
((
void
*
)
&
betav
[
0
],
betar
,(
node
->
Nv
/
2
)
*
sizeof
(
int16_t
));
else
memcpy
((
void
*
)
&
betav
[
0
],
betar
,(
node
->
Nv
/
2
)
*
sizeof
(
int16_t
));
memcpy
((
void
*
)
&
betav
[
node
->
Nv
/
2
],
betar
,(
node
->
Nv
/
2
)
*
sizeof
(
int16_t
));
memcpy
((
void
*
)
&
betav
[
node
->
Nv
/
2
],
betar
,(
node
->
Nv
/
2
)
*
sizeof
(
int16_t
));
}
}
void
generic_polar_decoder
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
void
generic_polar_decoder
(
t_nrPolar_params
*
polarParams
,
decoder_node_t
*
node
)
{
// Apply F to left
// Apply F to left
applyFtoleft
(
p
p
,
node
);
applyFtoleft
(
p
olarParams
,
node
);
// if left is not a leaf recurse down to the left
// if left is not a leaf recurse down to the left
if
(
node
->
left
->
leaf
==
0
)
generic_polar_decoder
(
pp
,
node
->
left
);
if
(
node
->
left
->
leaf
==
0
)
generic_polar_decoder
(
polarParams
,
node
->
left
);
applyGtoright
(
p
p
,
node
);
applyGtoright
(
p
olarParams
,
node
);
if
(
node
->
right
->
leaf
==
0
)
generic_polar_decoder
(
p
p
,
node
->
right
);
if
(
node
->
right
->
leaf
==
0
)
generic_polar_decoder
(
p
olarParams
,
node
->
right
);
computeBeta
(
p
p
,
node
);
computeBeta
(
p
olarParams
,
node
);
}
}
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
View file @
dd61e5a7
This diff is collapsed.
Click to expand it.
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
View file @
dd61e5a7
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
//#define DEBUG_POLAR_ENCODER
//#define DEBUG_POLAR_ENCODER
//#define DEBUG_POLAR_ENCODER_DCI
//#define DEBUG_POLAR_ENCODER_DCI
//#define DEBUG_POLAR_ENCODER_TIMING
//#define DEBUG_POLAR_ENCODER_TIMING
#define DEBUG_POLAR_MATLAB
//
#define DEBUG_POLAR_MATLAB
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "assertions.h"
#include "assertions.h"
...
@@ -51,9 +51,9 @@ void polar_encoder(uint32_t *in,
...
@@ -51,9 +51,9 @@ void polar_encoder(uint32_t *in,
#ifdef DEBUG_POLAR_ENCODER
#ifdef DEBUG_POLAR_ENCODER
printf("polar_B %llx (crc %x)\n",B,crc24c((uint8_t*)in,polarParams->payloadBits)>>8);
printf("polar_B %llx (crc %x)\n",B,crc24c((uint8_t*)in,polarParams->payloadBits)>>8);
#endif
#endif
nr_bit2byte_uint32_8
_t
((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/
nr_bit2byte_uint32_8((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*/
nr_bit2byte_uint32_8
_t
((
uint32_t
*
)
in
,
polarParams
->
payloadBits
,
polarParams
->
nr_polar_A
);
nr_bit2byte_uint32_8
((
uint32_t
*
)
in
,
polarParams
->
payloadBits
,
polarParams
->
nr_polar_A
);
/*
/*
* Bytewise operations
* Bytewise operations
*/
*/
...
@@ -147,7 +147,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*
...
@@ -147,7 +147,7 @@ nr_bit2byte_uint32_8_t((uint32_t*)&B, polarParams->K, polarParams->nr_polar_B);*
for
(
int
i
=
0
;
i
<
polarParams
->
encoderLength
;
i
++
)
printf
(
"f[%d]=%d
\n
"
,
i
,
polarParams
->
nr_polar_E
[
i
]);
for
(
int
i
=
0
;
i
<
polarParams
->
encoderLength
;
i
++
)
printf
(
"f[%d]=%d
\n
"
,
i
,
polarParams
->
nr_polar_E
[
i
]);
#endif
#endif
nr_byte2bit_uint8_32
_t
(
polarParams
->
nr_polar_E
,
polarParams
->
encoderLength
,
out
);
nr_byte2bit_uint8_32
(
polarParams
->
nr_polar_E
,
polarParams
->
encoderLength
,
out
);
}
}
void
polar_encoder_dci
(
uint32_t
*
in
,
void
polar_encoder_dci
(
uint32_t
*
in
,
...
@@ -163,7 +163,7 @@ void polar_encoder_dci(uint32_t *in,
...
@@ -163,7 +163,7 @@ void polar_encoder_dci(uint32_t *in,
* Bytewise operations
* Bytewise operations
*/
*/
//(a to a')
//(a to a')
nr_bit2byte_uint32_8
_t
(
in
,
polarParams
->
payloadBits
,
polarParams
->
nr_polar_A
);
nr_bit2byte_uint32_8
(
in
,
polarParams
->
payloadBits
,
polarParams
->
nr_polar_A
);
for
(
int
i
=
0
;
i
<
polarParams
->
crcParityBits
;
i
++
)
polarParams
->
nr_polar_APrime
[
i
]
=
1
;
for
(
int
i
=
0
;
i
<
polarParams
->
crcParityBits
;
i
++
)
polarParams
->
nr_polar_APrime
[
i
]
=
1
;
for
(
int
i
=
0
;
i
<
polarParams
->
payloadBits
;
i
++
)
polarParams
->
nr_polar_APrime
[
i
+
(
polarParams
->
crcParityBits
)]
=
polarParams
->
nr_polar_A
[
i
];
for
(
int
i
=
0
;
i
<
polarParams
->
payloadBits
;
i
++
)
polarParams
->
nr_polar_APrime
[
i
+
(
polarParams
->
crcParityBits
)]
=
polarParams
->
nr_polar_A
[
i
];
#ifdef DEBUG_POLAR_ENCODER_DCI
#ifdef DEBUG_POLAR_ENCODER_DCI
...
@@ -202,7 +202,7 @@ void polar_encoder_dci(uint32_t *in,
...
@@ -202,7 +202,7 @@ void polar_encoder_dci(uint32_t *in,
}
}
/* //(a to a')
/* //(a to a')
nr_crc_bit2bit_uint32_8
_t
(in, polarParams->payloadBits, polarParams->nr_polar_aPrime);
nr_crc_bit2bit_uint32_8(in, polarParams->payloadBits, polarParams->nr_polar_aPrime);
//Parity bits computation (p)
//Parity bits computation (p)
polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits));
polarParams->crcBit = crc24c(polarParams->nr_polar_aPrime, (polarParams->payloadBits+polarParams->crcParityBits));
#ifdef DEBUG_POLAR_ENCODER_DCI
#ifdef DEBUG_POLAR_ENCODER_DCI
...
@@ -273,7 +273,7 @@ void polar_encoder_dci(uint32_t *in,
...
@@ -273,7 +273,7 @@ void polar_encoder_dci(uint32_t *in,
/*
/*
* Return bits.
* Return bits.
*/
*/
nr_byte2bit_uint8_32
_t
(
polarParams
->
nr_polar_E
,
polarParams
->
encoderLength
,
out
);
nr_byte2bit_uint8_32
(
polarParams
->
nr_polar_E
,
polarParams
->
encoderLength
,
out
);
#ifdef DEBUG_POLAR_ENCODER_DCI
#ifdef DEBUG_POLAR_ENCODER_DCI
printf
(
"[polar_encoder_dci] E: "
);
printf
(
"[polar_encoder_dci] E: "
);
for
(
int
i
=
0
;
i
<
polarParams
->
encoderLength
;
i
++
)
printf
(
"%d-"
,
polarParams
->
nr_polar_E
[
i
]);
for
(
int
i
=
0
;
i
<
polarParams
->
encoderLength
;
i
++
)
printf
(
"%d-"
,
polarParams
->
nr_polar_E
[
i
]);
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c
View file @
dd61e5a7
...
@@ -33,12 +33,12 @@
...
@@ -33,12 +33,12 @@
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
void
nr_polar_bit_insertion
(
uint8_t
*
input
,
void
nr_polar_bit_insertion
(
uint8_t
*
input
,
uint8_t
*
output
,
uint8_t
*
output
,
uint16_t
N
,
uint16_t
N
,
uint16_t
K
,
uint16_t
K
,
int16_t
*
Q_I_N
,
int16_t
*
Q_I_N
,
int16_t
*
Q_PC_N
,
int16_t
*
Q_PC_N
,
uint8_t
n_PC
)
uint8_t
n_PC
)
{
{
uint16_t
k
=
0
;
uint16_t
k
=
0
;
uint8_t
flag
;
uint8_t
flag
;
...
@@ -256,8 +256,13 @@ void nr_polar_info_bit_extraction(uint8_t *input,
...
@@ -256,8 +256,13 @@ void nr_polar_info_bit_extraction(uint8_t *input,
}
}
void
nr_polar_rate_matching_pattern
(
uint16_t
*
rmp
,
uint16_t
*
J
,
const
uint8_t
*
P_i_
,
uint16_t
K
,
uint16_t
N
,
uint16_t
E
){
void
nr_polar_rate_matching_pattern
(
uint16_t
*
rmp
,
uint16_t
*
J
,
const
uint8_t
*
P_i_
,
uint16_t
K
,
uint16_t
N
,
uint16_t
E
)
{
uint8_t
i
;
uint8_t
i
;
uint16_t
*
d
,
*
y
,
ind
;
uint16_t
*
d
,
*
y
,
ind
;
d
=
(
uint16_t
*
)
malloc
(
sizeof
(
uint16_t
)
*
N
);
d
=
(
uint16_t
*
)
malloc
(
sizeof
(
uint16_t
)
*
N
);
...
@@ -293,8 +298,13 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P
...
@@ -293,8 +298,13 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t *J, const uint8_t *P
}
}
void
nr_polar_rate_matching
(
double
*
input
,
double
*
output
,
uint16_t
*
rmp
,
uint16_t
K
,
uint16_t
N
,
uint16_t
E
){
void
nr_polar_rate_matching
(
double
*
input
,
double
*
output
,
uint16_t
*
rmp
,
uint16_t
K
,
uint16_t
N
,
uint16_t
E
)
{
if
(
E
>=
N
)
{
//repetition
if
(
E
>=
N
)
{
//repetition
for
(
int
i
=
0
;
i
<=
N
-
1
;
i
++
)
output
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<=
N
-
1
;
i
++
)
output
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<=
E
-
1
;
i
++
){
for
(
int
i
=
0
;
i
<=
E
-
1
;
i
++
){
...
@@ -311,11 +321,15 @@ void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16
...
@@ -311,11 +321,15 @@ void nr_polar_rate_matching(double *input, double *output, uint16_t *rmp, uint16
output
[
rmp
[
i
]]
=
input
[
i
];
output
[
rmp
[
i
]]
=
input
[
i
];
}
}
}
}
}
}
void
nr_polar_rate_matching_int16
(
int16_t
*
input
,
int16_t
*
output
,
uint16_t
*
rmp
,
uint16_t
K
,
uint16_t
N
,
uint16_t
E
){
void
nr_polar_rate_matching_int16
(
int16_t
*
input
,
int16_t
*
output
,
uint16_t
*
rmp
,
uint16_t
K
,
uint16_t
N
,
uint16_t
E
)
{
if
(
E
>=
N
)
{
//repetition
if
(
E
>=
N
)
{
//repetition
for
(
int
i
=
0
;
i
<=
N
-
1
;
i
++
)
output
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<=
N
-
1
;
i
++
)
output
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<=
E
-
1
;
i
++
){
for
(
int
i
=
0
;
i
<=
E
-
1
;
i
++
){
...
@@ -332,6 +346,4 @@ void nr_polar_rate_matching_int16(int16_t *input, int16_t *output, uint16_t *rmp
...
@@ -332,6 +346,4 @@ void nr_polar_rate_matching_int16(int16_t *input, int16_t *output, uint16_t *rmp
output
[
rmp
[
i
]]
=
input
[
i
];
output
[
rmp
[
i
]]
=
input
[
i
];
}
}
}
}
}
}
openair1/PHY/CODING/nrSmallBlock/decodeSmallBlock.c
0 → 100644
View file @
dd61e5a7
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*!\file PHY/CODING/nrSmallBlock/decodeSmallBlock.c
* \brief
* \author Turker Yilmaz
* \date 2019
* \version 0.1
* \company EURECOM
* \email turker.yilmaz@eurecom.fr
* \note
* \warning
*/
#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
#include "assertions.h"
#include "PHY/sse_intrin.h"
//#define DEBUG_DECODESMALLBLOCK
uint16_t
decodeSmallBlock
(
int8_t
*
in
,
uint8_t
len
){
uint16_t
out
=
0
;
AssertFatal
(
len
>=
3
&&
len
<=
11
,
"[decodeSmallBlock] Message Length = %d (Small Block Coding is only defined for input lengths 3 to 11)"
,
len
);
if
(
len
<
7
)
{
int16_t
Rhat
[
NR_SMALL_BLOCK_CODED_BITS
]
=
{
0
},
Rhatabs
[
NR_SMALL_BLOCK_CODED_BITS
]
=
{
0
};
uint16_t
maxVal
;
uint8_t
maxInd
=
0
;
for
(
int
j
=
0
;
j
<
NR_SMALL_BLOCK_CODED_BITS
;
++
j
)
for
(
int
k
=
0
;
k
<
NR_SMALL_BLOCK_CODED_BITS
;
++
k
)
Rhat
[
j
]
+=
in
[
k
]
*
hadamard32InterleavedTransposed
[
j
][
k
];
#if defined(__AVX2__)
for
(
int
i
=
0
;
i
<
NR_SMALL_BLOCK_CODED_BITS
;
i
+=
16
)
{
__m256i
a15_a0
=
_mm256_loadu_si256
((
__m256i
*
)
&
Rhat
[
i
]);
a15_a0
=
_mm256_abs_epi16
(
a15_a0
);
_mm256_storeu_si256
((
__m256i
*
)(
&
Rhatabs
[
i
]),
a15_a0
);
}
#else
for
(
int
i
=
0
;
i
<
NR_SMALL_BLOCK_CODED_BITS
;
i
+=
8
)
{
__m128i
a7_a0
=
_mm_loadu_si128
((
__m128i
*
)
&
Rhat
[
i
]);
a7_a0
=
_mm_abs_epi16
(
a7_a0
);
_mm_storeu_si128
((
__m128i
*
)(
&
Rhatabs
[
i
]),
a7_a0
);
}
#endif
maxVal
=
Rhatabs
[
0
];
for
(
int
k
=
1
;
k
<
NR_SMALL_BLOCK_CODED_BITS
;
++
k
){
if
(
Rhatabs
[
k
]
>
maxVal
){
maxVal
=
Rhatabs
[
k
];
maxInd
=
k
;
}
}
out
=
properOrderedBasis
[
maxInd
]
|
(
(
Rhat
[
maxInd
]
>
0
)
?
(
uint16_t
)
0
:
(
uint16_t
)
1
);
#ifdef DEBUG_DECODESMALLBLOCK
for
(
int
k
=
0
;
k
<
NR_SMALL_BLOCK_CODED_BITS
;
++
k
)
printf
(
"[decodeSmallBlock]Rhat[%d]=%d %d %d %d
\n
"
,
k
,
Rhat
[
k
],
maxVal
,
maxInd
,
((
uint32_t
)
out
>>
k
)
&
1
);
printf
(
"[decodeSmallBlock]0x%x 0x%x
\n
"
,
out
,
properOrderedBasis
[
maxInd
]);
#endif
}
else
{
int8_t
Dmatrix
[
NR_SMALL_BLOCK_CODED_BITS
][
NR_SMALL_BLOCK_CODED_BITS
]
=
{
0
};
int16_t
DmatrixFHT
[
NR_SMALL_BLOCK_CODED_BITS
][
NR_SMALL_BLOCK_CODED_BITS
]
=
{
0
};
uint16_t
maxVal
;
uint8_t
maxRow
=
0
,
maxCol
=
0
;
for
(
int
j
=
0
;
j
<
NR_SMALL_BLOCK_CODED_BITS
;
++
j
)
for
(
int
k
=
0
;
k
<
NR_SMALL_BLOCK_CODED_BITS
;
++
k
)
Dmatrix
[
j
][
k
]
=
in
[
k
]
*
maskD
[
j
][
k
];
for
(
int
i
=
0
;
i
<
NR_SMALL_BLOCK_CODED_BITS
;
++
i
)
for
(
int
j
=
0
;
j
<
NR_SMALL_BLOCK_CODED_BITS
;
++
j
)
for
(
int
k
=
0
;
k
<
NR_SMALL_BLOCK_CODED_BITS
;
++
k
)
DmatrixFHT
[
i
][
j
]
+=
Dmatrix
[
i
][
k
]
*
hadamard32InterleavedTransposed
[
j
][
k
];
maxVal
=
abs
(
DmatrixFHT
[
0
][
0
]);
for
(
int
i
=
0
;
i
<
NR_SMALL_BLOCK_CODED_BITS
;
++
i
)
for
(
int
j
=
0
;
j
<
NR_SMALL_BLOCK_CODED_BITS
;
++
j
)
if
(
abs
(
DmatrixFHT
[
i
][
j
])
>
maxVal
){
maxVal
=
abs
(
DmatrixFHT
[
i
][
j
]);
maxRow
=
i
;
maxCol
=
j
;
}
out
=
properOrderedBasisExtended
[
maxRow
]
|
properOrderedBasis
[
maxCol
]
|
(
(
DmatrixFHT
[
maxRow
][
maxCol
]
>
0
)
?
(
uint16_t
)
0
:
(
uint16_t
)
1
);
#ifdef DEBUG_DECODESMALLBLOCK
for
(
int
k
=
0
;
k
<
NR_SMALL_BLOCK_CODED_BITS
;
++
k
)
printf
(
"[decodeSmallBlock]maxRow = %d maxCol = %d out[%d]=%d
\n
"
,
maxRow
,
maxCol
,
k
,
((
uint32_t
)
out
>>
k
)
&
1
);
#endif
}
return
out
;
}
openair1/PHY/CODING/nrSmallBlock/encodeSmall.c
deleted
100644 → 0
View file @
9cbfe2e3
openair1/PHY/CODING/nrSmallBlock/encodeSmallBlock.c
0 → 100644
View file @
dd61e5a7
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*!\file PHY/CODING/nrSmallBlock/encodeSmallBlock.c
* \brief
* \author Turker Yilmaz
* \date 2019
* \version 0.1
* \company EURECOM
* \email turker.yilmaz@eurecom.fr
* \note
* \warning
*/
#include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h"
//input = [0 ... 0 c_K-1 ... c_2 c_1 c_0]
//output = [d_31 d_30 ... d_2 d_1 d_0]
uint32_t
encodeSmallBlock
(
uint16_t
*
in
,
uint8_t
len
){
uint32_t
out
=
0
;
for
(
uint16_t
i
=
0
;
i
<
len
;
i
++
)
if
((
*
in
&
(
1
<<
i
))
>
0
)
out
^=
nrSmallBlockBasis
[
i
];
return
out
;
}
openair1/PHY/CODING/nrSmallBlock/nr_small_block_defs.h
0 → 100644
View file @
dd61e5a7
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*!\file PHY/CODING/nrSmallBlock/nr_small_block_defs.h
* \brief
* \author Turker Yilmaz
* \date 2019
* \version 0.1
* \company EURECOM
* \email turker.yilmaz@eurecom.fr
* \note
* \warning
*/
#ifndef __NR_SMALL_BLOCK_DEFS__H__
#define __NR_SMALL_BLOCK_DEFS__H__
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#define NR_SMALL_BLOCK_CODED_BITS 32
#define L1d_CLS 64
uint32_t
encodeSmallBlock
(
uint16_t
*
in
,
uint8_t
len
);
uint16_t
decodeSmallBlock
(
int8_t
*
in
,
uint8_t
len
);
static
const
uint32_t
nrSmallBlockBasis
[
11
]
=
{
0xFFFFFFFF
,
0x4BA5A933
,
0x7D910E5A
,
0x6D26339C
,
0x71C7C3E0
,
0x7E0FFC00
,
0x731D8E64
,
0x6B44F5B0
,
0x7DC218EC
,
0x4DA1B746
,
0x42F0FFFF
};
static
const
uint16_t
properOrderedBasis
[
32
]
=
{
0x0000
,
0x0002
,
0x0004
,
0x0006
,
0x0008
,
0x000A
,
0x000C
,
0x000E
,
0x0010
,
0x0012
,
0x0014
,
0x0016
,
0x0018
,
0x001A
,
0x001C
,
0x001E
,
0x0020
,
0x0022
,
0x0024
,
0x0026
,
0x0028
,
0x002A
,
0x002C
,
0x002E
,
0x0030
,
0x0032
,
0x0034
,
0x0036
,
0x0038
,
0x003A
,
0x003C
,
0x003E
};
static
const
uint16_t
properOrderedBasisExtended
[
32
]
=
{
0x0000
,
0x0040
,
0x0080
,
0x00C0
,
0x0100
,
0x0140
,
0x0180
,
0x01C0
,
0x0200
,
0x0240
,
0x0280
,
0x02C0
,
0x0300
,
0x0340
,
0x0380
,
0x03C0
,
0x0400
,
0x0440
,
0x0480
,
0x04C0
,
0x0500
,
0x0540
,
0x0580
,
0x05C0
,
0x0600
,
0x0640
,
0x0680
,
0x06C0
,
0x0700
,
0x0740
,
0x0780
,
0x07C0
};
static
const
int8_t
hadamard32InterleavedTransposed
[
32
][
32
]
__attribute__
((
alig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-
1
,
-
1
,
-
1
,
1
,
-
1
,
1
,
-
1
,
1
,
1
,
1
,
-
1
,
1
,
-
1
,
1
,
1
,
-
1
,
-
1
,
1
,
-
1
,
1
,
-
1
,
1
,
-
1
,
-
1
,
1
}
};
#endif
openair1/PHY/CODING/nr_polar_init.c
View file @
dd61e5a7
...
@@ -42,9 +42,9 @@ static int intcmp(const void *p1,const void *p2) {
...
@@ -42,9 +42,9 @@ static int intcmp(const void *p1,const void *p2) {
}
}
void
nr_polar_init
(
t_nrPolar_paramsPtr
*
polarParams
,
void
nr_polar_init
(
t_nrPolar_paramsPtr
*
polarParams
,
int8_t
messageType
,
int8_t
messageType
,
uint16_t
messageLength
,
uint16_t
messageLength
,
uint8_t
aggregation_level
)
uint8_t
aggregation_level
)
{
{
t_nrPolar_paramsPtr
currentPtr
=
*
polarParams
;
t_nrPolar_paramsPtr
currentPtr
=
*
polarParams
;
uint16_t
aggregation_prime
=
nr_polar_aggregation_prime
(
aggregation_level
);
uint16_t
aggregation_prime
=
nr_polar_aggregation_prime
(
aggregation_level
);
...
@@ -63,7 +63,8 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
...
@@ -63,7 +63,8 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
if
(
newPolarInitNode
!=
NULL
)
{
if
(
newPolarInitNode
!=
NULL
)
{
newPolarInitNode
->
idx
=
(
messageType
*
messageLength
*
aggregation_prime
);
newPolarInitNode
->
idx
=
(
messageType
*
messageLength
*
aggregation_prime
);
newPolarInitNode
->
nextPtr
=
NULL
;
newPolarInitNode
->
nextPtr
=
(
t_nrPolar_params
*
)
NULL
;
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
//printf("newPolarInitNode->idx %d, (%d,%d,%d:%d)\n",newPolarInitNode->idx,messageType,messageLength,aggregation_prime,aggregation_level);
if
(
messageType
==
0
)
{
//PBCH
if
(
messageType
==
0
)
{
//PBCH
...
@@ -186,9 +187,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
...
@@ -186,9 +187,7 @@ void nr_polar_init(t_nrPolar_paramsPtr *polarParams,
currentPtr
=
currentPtr
->
nextPtr
;
currentPtr
=
currentPtr
->
nextPtr
;
}
}
currentPtr
->
nextPtr
=
newPolarInitNode
;
currentPtr
->
nextPtr
=
newPolarInitNode
;
printf
(
"Adding new polarParams entry to list index %d,%p
\n
"
,
printf
(
"Adding new polarParams entry to list index %d,%p
\n
"
,
newPolarInitNode
->
idx
,
currentPtr
->
nextPtr
);
newPolarInitNode
->
idx
,
currentPtr
->
nextPtr
);
return
;
return
;
}
}
...
@@ -209,9 +208,9 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams)
...
@@ -209,9 +208,9 @@ void nr_polar_print_polarParams(t_nrPolar_paramsPtr polarParams)
}
}
t_nrPolar_paramsPtr
nr_polar_params
(
t_nrPolar_paramsPtr
polarParams
,
t_nrPolar_paramsPtr
nr_polar_params
(
t_nrPolar_paramsPtr
polarParams
,
int8_t
messageType
,
int8_t
messageType
,
uint16_t
messageLength
,
uint16_t
messageLength
,
uint8_t
aggregation_level
)
uint8_t
aggregation_level
)
{
{
t_nrPolar_paramsPtr
currentPtr
=
NULL
;
t_nrPolar_paramsPtr
currentPtr
=
NULL
;
...
...
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