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
5344e567
Commit
5344e567
authored
Mar 12, 2019
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
intermediate commit of list decoding extension
parent
cc4182a3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
142 deletions
+108
-142
openair1/PHY/CODING/TESTBENCH/polartest.c
openair1/PHY/CODING/TESTBENCH/polartest.c
+10
-13
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
+53
-86
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
+34
-39
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
+8
-2
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
+3
-2
No files found.
openair1/PHY/CODING/TESTBENCH/polartest.c
View file @
5344e567
...
...
@@ -372,22 +372,19 @@ int main(int argc, char *argv[]) {
printf("estimatedOutput: [0]->0x%08x\n", estimatedOutput[0]);*/
//calculate errors
if
(
decoderState
!=
0
)
{
blockErrorState
=-
1
;
nBitError
=-
1
;
}
else
{
for
(
int
j
=
0
;
j
<
currentPtr
->
payloadBits
;
j
++
)
{
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);
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
);
}
}
if
(
nBitError
>
0
)
{
blockErrorState
=
1
;
// printf("Error: Input %x, Output %x\n",testInput[0],estimatedOutput[0]);
}
printf
(
"Error: Input %x, Output %x
\n
"
,
testInput
[
0
],
estimatedOutput
[
0
]);
}
//Iteration times are in microseconds.
timeEncoderCumulative
+=
(
timeEncoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
));
timeDecoderCumulative
+=
(
timeDecoder
.
diff
/
(
cpu_freq_GHz
*
1000
.
0
));
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
View file @
5344e567
...
...
@@ -1153,6 +1153,8 @@ void init_polar_deinterleaver_table(t_nrPolar_params *polarParams) {
}
}
uint64_t
Cprimetest
;
uint32_t
polar_decoder_int16
(
int16_t
*
input
,
uint64_t
*
out
,
const
t_nrPolar_params
*
polarParams
)
{
...
...
@@ -1166,17 +1168,14 @@ uint32_t polar_decoder_int16(int16_t *input,
memcpy
((
void
*
)
&
polarParams
->
tree
.
root
->
alpha
[
0
],(
void
*
)
&
d_tilde
[
0
],
sizeof
(
int16_t
)
*
polarParams
->
N
);
for
(
int
iter
=
0
;
iter
<
4
;
iter
++
)
{
generic_polar_decoder
(
polarParams
,
polarParams
->
tree
.
root
,
1
);
generic_polar_decoder
(
polarParams
,
polarParams
->
tree
.
root
);
//Extract the information bits (û to ĉ)
uint64_t
Cprime
[
4
]
=
{
0
,
0
,
0
,
0
};
uint64_t
B
[
4
]
=
{
0
,
0
,
0
,
0
};
for
(
int
i
=
0
;
i
<
polarParams
->
K
;
i
++
)
Cprime
[
i
>>
6
]
=
Cprime
[
i
>>
6
]
|
((
uint64_t
)
polarParams
->
nr_polar_U
[
polarParams
->
Q_I_N
[
i
]])
<<
(
i
&
63
);
printf
(
"iter %d : Cprime %llx|%llx
\n
"
,
iter
,
Cprime
[
1
],
Cprime
[
0
]);
//Deinterleaving (ĉ to b)
uint8_t
*
Cprimebyte
=
(
uint8_t
*
)
Cprime
;
if
(
polarParams
->
K
<
65
)
{
...
...
@@ -1237,42 +1236,10 @@ uint32_t polar_decoder_int16(int16_t *input,
//#endif
out
[
0
]
=
Ar
;
printf
(
"iter %d
: A %llx B %llx|%llx Cprime %llx|%llx (crc %x,rxcrc %llx %d)
\n
"
,
iter
,
Ar
,
if
(
crc
!=
rxcrc
)
printf
(
"CRC mismatch
: A %llx B %llx|%llx Cprime %llx|%llx (crc %x,rxcrc %llx %d)
\n
"
,
Ar
,
B
[
1
],
B
[
0
],
Cprime
[
1
],
Cprime
[
0
],
crc
,
rxcrc
,
polarParams
->
payloadBits
);
if
(
crc
==
rxcrc
)
return
(
0
);
int32_t
avg_llr
=
0
,
llr_tmp
;
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
llr_tmp
=
abs
(
polarParams
->
tree
.
root
->
softbeta
[
i
]);
avg_llr
+=
llr_tmp
;
}
avg_llr
/=
polarParams
->
N
;
int
shift
=
log2_approx
(
avg_llr
)
-
3
;
printf
(
"iter %d: avg_llr %d shift %d
\n
"
,
iter
,
avg_llr
,
shift
);
// for (int i=0;i<polarParams->N;i++) printf("i %d: alpha %d, beta %d\n",i,polarParams->tree.root->alpha[i],polarParams->tree.root->softbeta[i]);
/* for (int i=0; i<polarParams->N; i++) {
if (polarParams->tree.root->softbeta[i]<-128) polarParams->tree.root->alpha[i]=-128;
else if (polarParams->tree.root->softbeta[i]>127) polarParams->tree.root->alpha[i]=127;
else polarParams->tree.root->alpha[i]=polarParams->tree.root->softbeta[i];
}*/
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
if
((
polarParams
->
tree
.
root
->
alpha
[
i
]
*
(
polarParams
->
tree
.
root
->
softbeta
[
i
]))
<
0
)
printf
(
"i %d: alpha %d => %d
\n
"
,
i
,
polarParams
->
tree
.
root
->
alpha
[
i
],
polarParams
->
tree
.
root
->
softbeta
[
i
]
>>
shift
);
polarParams
->
tree
.
root
->
alpha
[
i
]
=
polarParams
->
tree
.
root
->
softbeta
[
i
]
>>
shift
;
}
//for (int i=0;i<polarParams->N;i++) printf("i %d: %d => %d\n",i,polarParams->tree.root->alpha[i],d_tilde[i]);;
}
return
(
-
1
);
return
(
crc
^
rxcrc
);
}
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
View file @
5344e567
...
...
@@ -206,7 +206,6 @@ decoder_node_t *new_decoder_node(int first_leaf_index,int level) {
node
->
all_frozen
=
0
;
node
->
alpha
=
(
int16_t
*
)
malloc16
(
node
->
Nv
*
sizeof
(
int16_t
));
node
->
beta
=
(
int16_t
*
)
malloc16
(
node
->
Nv
*
sizeof
(
int16_t
));
node
->
softbeta
=
(
int16_t
*
)
malloc16
(
node
->
Nv
*
sizeof
(
int16_t
));
memset
((
void
*
)
node
->
beta
,
-
1
,
node
->
Nv
*
sizeof
(
int16_t
));
...
...
@@ -384,17 +383,36 @@ void applyFtoleft(t_nrPolar_params *pp,decoder_node_t *node) {
}
if
(
node
->
Nv
==
2
)
{
// apply hard decision on left node
betal
[
0
]
=
(
alpha_l
[
0
]
>
0
)
?
-
1
:
1
;
node
->
left
->
softbeta
[
0
]
=
alpha_l
[
0
];
#ifdef DEBUG_NEW_IMPL
printf
(
"betal[0] %d (%p), softbeta %d
\n
"
,
betal
[
0
],
&
betal
[
0
],
node
->
left
->
softbeta
[
0
]);
printf
(
"betal[0] %d (%p)
\n
"
,
betal
[
0
],
&
betal
[
0
]);
#endif
// pp->nr_polar_U[node->first_leaf_index] = (1+betal[0])>>1;
int
bi
=
node
->
left
->
bit_bitindex
;
int
ne1
=
pp
->
tree
.
num_entries
;
int16_t
abs_alpha
=
((
alpha_l
[
0
]
>
0
)
?
alpha_l
[
0
]
:
-
alpha_l
[
0
]);
if
(
pp
->
tree
.
num_entries
<
pp
->
tree
.
list_size
)
{
// update list for SC hard-decision
for
(
int
i
=
0
;
i
<
pp
->
tree
.
num_entries
;
i
++
)
pp
->
tree
.
decoderout
[
i
][
bi
>>
6
]
|=
(((
1
+
betal
[
0
])
>>
1
)
<<
(
bi
&
63
));
// update list for flipped SC hard-decision
int
ne2
=
pp
->
tree
.
num_entries
<<
1
;
if
(
ne2
>
pp
->
tree
.
list_size
)
ne2
=
pp
->
tree
.
list_size
;
for
(
int
i
=
pp
->
tree
.
num_entries
;
i
<
ne2
;
i
++
)
{
pp
->
tree
.
decoderout
[
i
][
bi
>>
6
]
=
pp
->
tree
.
decoderout
[
i
-
pp
->
tree
.
num_entries
][
bi
>>
6
]
^
(((
uint64_t
)
1
)
<<
(
bi
&
63
));
pp
->
tree
.
PM
[
i
]
=
pp
->
tree
.
PM
[
i
-
pp
->
tree
.
num_entries
]
-
abs_alpha
;
}
}
for
(
int
i
=
0
;
i
<
pp
->
tree
.
num_entries
-
(
ne2
-
pp
->
tree
.
num_entries
);
i
++
)
update_min
(
pp
->
tree
,
abs_alpha
);
#ifdef DEBUG_NEW_IMPL
int
j
;
printf
(
"Setting bit %d (%d) to %d (LLR %d)
\n
"
,
node
->
first_leaf_index
,
bit_index
,(
betal
[
0
]
+
1
)
>>
1
,
alpha_l
[
0
]);
#endif
pp
->
nr_polar_U
[
node
->
first_leaf_index
]
=
(
1
+
betal
[
0
])
>>
1
;
//#ifdef DEBUG_NEW_IMPL
printf
(
"Setting bit %d to %d (LLR %d)
\n
"
,
node
->
first_leaf_index
,(
betal
[
0
]
+
1
)
>>
1
,
alpha_l
[
0
]);
//#endif
}
}
else
for
(
int
i
=
0
;
i
<
node
->
Nv
/
2
;
i
++
)
node
->
left
->
softbeta
[
i
]
=
32767
;
}
void
applyGtoright
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
...
...
@@ -458,10 +476,11 @@ void applyGtoright(t_nrPolar_params *pp,decoder_node_t *node) {
}
if
(
node
->
Nv
==
2
)
{
// apply hard decision on right node
betar
[
0
]
=
(
alpha_r
[
0
]
>
0
)
?
-
1
:
1
;
node
->
right
->
softbeta
[
0
]
=
alpha_r
[
0
];
pp
->
nr_polar_U
[
node
->
first_leaf_index
+
1
]
=
(
1
+
betar
[
0
])
>>
1
;
//#ifdef DEBUG_NEW_IMPL
printf
(
"Setting bit %d to %d (LLR %d)
\n
"
,
node
->
first_leaf_index
+
1
,(
betar
[
0
]
+
1
)
>>
1
,
alpha_r
[
0
]);
int
j
;
for
(
j
=
0
;
j
<
pp
->
K
;
j
++
)
if
(
pp
->
Q_I_N
[
j
]
==
(
node
->
first_leaf_index
+
1
))
break
;
printf
(
"Setting bit %d (%d) to %d (LLR %d)
\n
"
,
node
->
first_leaf_index
+
1
,
j
,(
betar
[
0
]
+
1
)
>>
1
,
alpha_r
[
0
]);
//#endif
}
}
...
...
@@ -473,14 +492,11 @@ int16_t all1[16] = {1,1,1,1,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
void
computeBeta
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
,
int
do_softbeta
)
{
void
computeBeta
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
int16_t
*
betav
=
node
->
beta
;
int16_t
*
betal
=
node
->
left
->
beta
;
int16_t
*
betar
=
node
->
right
->
beta
;
int16_t
*
softbetav
=
node
->
softbeta
;
int16_t
*
softbetal
=
node
->
left
->
softbeta
;
int16_t
*
softbetar
=
node
->
right
->
softbeta
;
#ifdef DEBUG_NEW_IMPL
printf
(
"Computing beta @ level %d first_leaf_index %d (all_frozen %d)
\n
"
,
node
->
level
,
node
->
first_leaf_index
,
node
->
left
->
all_frozen
);
...
...
@@ -532,42 +548,21 @@ void computeBeta(t_nrPolar_params *pp,decoder_node_t *node, int do_softbeta) {
memcpy
((
void
*
)
&
betav
[
node
->
Nv
/
2
],
betar
,(
node
->
Nv
/
2
)
*
sizeof
(
int16_t
));
// softbeta computation
if
(
do_softbeta
==
1
)
{
int16_t
a
,
b
,
absa
,
absb
,
maska
,
maskb
,
minabs
;
for
(
int
i
=
0
;
i
<
node
->
Nv
/
2
;
i
++
)
{
a
=
softbetal
[
i
];
b
=
softbetar
[
i
];
maska
=
a
>>
15
;
maskb
=
b
>>
15
;
absa
=
(
a
+
maska
)
^
maska
;
absb
=
(
b
+
maskb
)
^
maskb
;
minabs
=
absa
<
absb
?
absa
:
absb
;
softbetav
[
i
]
=
(
maska
^
maskb
)
!=
0
?
-
minabs
:
minabs
;
#ifdef DEBUG_NEW_IMPL
printf
(
"Nv %d, first_leaf %d: beta_v[%d] %d (%d,%d) softbetav[%d] %d (%d,%d)
\n
"
,
node
->
Nv
,
node
->
first_leaf_index
,
i
,
betav
[
i
],
betal
[
i
],
betar
[
i
],
i
,
softbetav
[
i
],
a
,
b
);
#endif
}
memcpy
((
void
*
)
&
softbetav
[
node
->
Nv
/
2
],(
void
*
)
softbetar
,
sizeof
(
int16_t
)
*
node
->
Nv
/
2
);
}
}
void
generic_polar_decoder
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
,
int
do_softbeta
)
{
void
generic_polar_decoder
(
t_nrPolar_params
*
pp
,
decoder_node_t
*
node
)
{
// Apply F to left
applyFtoleft
(
pp
,
node
);
// if left is not a leaf recurse down to the left
if
(
node
->
left
->
leaf
==
0
)
generic_polar_decoder
(
pp
,
node
->
left
,
do_softbeta
);
if
(
node
->
left
->
leaf
==
0
)
generic_polar_decoder
(
pp
,
node
->
left
);
applyGtoright
(
pp
,
node
);
if
(
node
->
right
->
leaf
==
0
)
generic_polar_decoder
(
pp
,
node
->
right
,
do_softbeta
);
if
(
node
->
right
->
leaf
==
0
)
generic_polar_decoder
(
pp
,
node
->
right
);
computeBeta
(
pp
,
node
,
do_softbeta
);
computeBeta
(
pp
,
node
);
}
openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h
View file @
5344e567
...
...
@@ -68,14 +68,20 @@ typedef struct decoder_node_t_s {
int
Nv
;
int
first_leaf_index
;
int
all_frozen
;
int
bit_index
;
int16_t
*
alpha
;
int16_t
*
beta
;
int16_t
*
softbeta
;
}
decoder_node_t
;
#define LISTSIZE_MAX 8
typedef
struct
decoder_tree_t_s
{
decoder_node_t
*
root
;
int
num_nodes
;
int
list_size
;
int32_t
PM
[
LISTSIZE_MAX
];
uint64_t
decoderout
[
LISTSIZE_MAX
][
4
];
int
numentries
;
int
minentry
;
}
decoder_tree_t
;
struct
nrPolar_params
{
...
...
@@ -186,7 +192,7 @@ int8_t polar_decoder_dci(double *input,
uint16_t
n_RNTI
);
void
generic_polar_decoder
(
t_nrPolar_params
*
,
decoder_node_t
*
,
int
);
decoder_node_t
*
);
void
build_decoder_tree
(
t_nrPolar_params
*
pp
);
void
build_polar_tables
(
t_nrPolar_params
*
polarParams
);
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
View file @
5344e567
...
...
@@ -412,6 +412,7 @@ void build_polar_tables(t_nrPolar_params *polarParams) {
polarParams
->
rm_tab
[
tcnt
]
=
polarParams
->
rate_matching_pattern
[
outpos
]
>>
shift
;
}
void
polar_encoder_fast
(
uint64_t
*
A
,
uint32_t
*
out
,
int32_t
crcmask
,
...
...
@@ -484,7 +485,7 @@ void polar_encoder_fast(uint64_t *A,
}
}
//
#ifdef DEBUG_POLAR_ENCODER
#ifdef DEBUG_POLAR_ENCODER
if
(
polarParams
->
K
<
65
)
printf
(
"A %llx B %llx Cprime %llx (payload bits %d,crc %x)
\n
"
,
...
...
@@ -510,7 +511,7 @@ void polar_encoder_fast(uint64_t *A,
crc24c
((
uint8_t
*
)
A
,
bitlen
)
>>
8
);
}
//
#endif
#endif
/* printf("Bbytes : %x.%x.%x.%x.%x.%x.%x.%x\n",Bbyte[0],Bbyte[1],Bbyte[2],Bbyte[3],Bbyte[4],Bbyte[5],Bbyte[6],Bbyte[7]);
printf("%llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",polarParams->cprime_tab[0][Bbyte[0]] ,
polarParams->cprime_tab[1][Bbyte[1]] ,
...
...
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