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
d82fd51e
Commit
d82fd51e
authored
Feb 13, 2018
by
Florian Kaltenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integrating TCL LDPC decoder into ldpctest
parent
cd0b9525
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
38 deletions
+57
-38
openair1/PHY/CODING/TESTBENCH/ldpctest.c
openair1/PHY/CODING/TESTBENCH/ldpctest.c
+57
-38
No files found.
openair1/PHY/CODING/TESTBENCH/ldpctest.c
View file @
d82fd51e
...
@@ -75,29 +75,36 @@ int test_ldpc(short No_iteration,
...
@@ -75,29 +75,36 @@ int test_ldpc(short No_iteration,
time_stats_t
time
,
time_optim
,
tinput
,
tprep
,
tparity
,
toutput
;
time_stats_t
time
,
time_optim
,
tinput
,
tprep
,
tparity
,
toutput
;
opp_enabled
=
1
;
opp_enabled
=
1
;
cpu_freq_GHz
=
get_cpu_freq_GHz
();
cpu_freq_GHz
=
get_cpu_freq_GHz
();
//short test_input[block_length];
unsigned
char
*
test_input
;
unsigned
char
*
test_input
=
NULL
;
//short *c; //padded codeword
unsigned
char
*
estimated_output
=
NULL
;
short
*
esimated_output
;
unsigned
char
*
channel_input
=
NULL
;
unsigned
char
*
channel_input
;
unsigned
char
*
channel_input_optim
=
NULL
;
unsigned
char
*
channel_input_optim
;
double
*
channel_output
=
NULL
;
double
*
channel_output
;
double
*
modulated_input
=
NULL
;
double
*
modulated_input
;
char
*
channel_output_fixed
=
NULL
;
short
*
channel_output_fixed
;
unsigned
int
i
,
trial
=
0
;
unsigned
int
i
,
trial
=
0
;
short
BG
,
Zc
,
Kb
,
nrows
,
ncols
;
short
BG
,
Zc
,
Kb
,
nrows
,
ncols
;
int
no_punctured_columns
,
removed_bit
;
int
no_punctured_columns
,
removed_bit
;
int
i1
;
int
i1
;
//Table of possible lifting sizes
//Table of possible lifting sizes
short
lift_size
[
51
]
=
{
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
18
,
20
,
22
,
24
,
26
,
28
,
30
,
32
,
36
,
40
,
44
,
48
,
52
,
56
,
60
,
64
,
72
,
80
,
88
,
96
,
104
,
112
,
120
,
128
,
144
,
160
,
176
,
192
,
208
,
224
,
240
,
256
,
288
,
320
,
352
,
384
};
short
lift_size
[
51
]
=
{
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
18
,
20
,
22
,
24
,
26
,
28
,
30
,
32
,
36
,
40
,
44
,
48
,
52
,
56
,
60
,
64
,
72
,
80
,
88
,
96
,
104
,
112
,
120
,
128
,
144
,
160
,
176
,
192
,
208
,
224
,
240
,
256
,
288
,
320
,
352
,
384
};
t_nrLDPC_dec_params
decParams
;
int
n_iter
;
*
errors
=
0
;
*
errors
=
0
;
*
crc_misses
=
0
;
*
crc_misses
=
0
;
// generate input block
// generate input block
test_input
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
block_length
/
8
);
test_input
=
(
unsigned
char
*
)
malloc
16
(
sizeof
(
unsigned
char
)
*
block_length
/
8
);
channel_input
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
68
*
384
);
channel_input
=
(
unsigned
char
*
)
malloc
16
(
sizeof
(
unsigned
char
)
*
68
*
384
);
channel_input_optim
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
68
*
384
);
channel_input_optim
=
(
unsigned
char
*
)
malloc
16
(
sizeof
(
unsigned
char
)
*
68
*
384
);
modulated_input
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
68
*
384
);
modulated_input
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
68
*
384
);
channel_output
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
68
*
384
);
channel_output
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
68
*
384
);
channel_output_fixed
=
(
char
*
)
malloc16
(
sizeof
(
char
)
*
68
*
384
);
estimated_output
=
(
unsigned
char
*
)
malloc16
(
sizeof
(
unsigned
char
)
*
block_length
/
8
);
reset_meas
(
&
time
);
reset_meas
(
&
time
);
reset_meas
(
&
time_optim
);
reset_meas
(
&
time_optim
);
reset_meas
(
&
tinput
);
reset_meas
(
&
tinput
);
...
@@ -159,14 +166,11 @@ int test_ldpc(short No_iteration,
...
@@ -159,14 +166,11 @@ int test_ldpc(short No_iteration,
//// encoder
//// encoder
start_meas
(
&
time
);
start_meas
(
&
time
);
//if (BG==1)
//ldpc_encoder(test_input, channel_input,block_length,nom_rate,denom_rate);
//else
ldpc_encoder_orig
(
test_input
,
channel_input
,
block_length
,
nom_rate
,
denom_rate
,
0
);
ldpc_encoder_orig
(
test_input
,
channel_input
,
block_length
,
nom_rate
,
denom_rate
,
0
);
stop_meas
(
&
time
);
stop_meas
(
&
time
);
start_meas
(
&
time_optim
);
start_meas
(
&
time_optim
);
//ldpc_encoder(test_input,channel_input_optim,block_length,nom_rate,denom_rate);
ldpc_encoder_optim
(
test_input
,
channel_input_optim
,
block_length
,
nom_rate
,
denom_rate
,
&
tinput
,
&
tprep
,
&
tparity
,
&
toutput
);
ldpc_encoder_optim
(
test_input
,
channel_input_optim
,
block_length
,
nom_rate
,
denom_rate
,
&
tinput
,
&
tprep
,
&
tparity
,
&
toutput
);
stop_meas
(
&
time_optim
);
stop_meas
(
&
time_optim
);
...
@@ -181,29 +185,23 @@ int test_ldpc(short No_iteration,
...
@@ -181,29 +185,23 @@ int test_ldpc(short No_iteration,
//printf("channel_input[%d]=%d\n",i,channel_input[i]);
//printf("channel_input[%d]=%d\n",i,channel_input[i]);
//printf("%d ",channel_input[i]);
//printf("%d ",channel_input[i]);
if
((
BG
==
2
)
&&
(
Zc
==
128
||
Zc
==
256
))
//
if ((BG==2) && (Zc==128||Zc==256))
{
{
channel_output_fixed
=
(
short
*
)
malloc
(
(
Kb
+
nrows
)
*
Zc
*
sizeof
(
short
));
memset
(
channel_output_fixed
,
0
,(
Kb
+
nrows
)
*
Zc
*
sizeof
(
short
));
removed_bit
=
(
nrows
-
no_punctured_columns
-
2
)
*
Zc
+
block_length
-
(
int
)(
block_length
/
((
float
)
nom_rate
/
(
float
)
denom_rate
));
//printf("removed_bit:%d\n",removed_bit);
for
(
i
=
2
*
Zc
;
i
<
(
Kb
+
nrows
-
no_punctured_columns
)
*
Zc
-
removed_bit
;
i
++
)
for
(
i
=
2
*
Zc
;
i
<
(
Kb
+
nrows
-
no_punctured_columns
)
*
Zc
-
removed_bit
;
i
++
)
{
{
#ifdef DEBUG_CODER
#ifdef DEBUG_CODER
if
((
i
&
0xf
)
==
0
)
if
((
i
&
0xf
)
==
0
)
printf
(
"
\n
e %d..%d: "
,
i
,
i
+
15
);
printf
(
"
\n
e %d..%d: "
,
i
,
i
+
15
);
#endif
#endif
if
(
channel_input
[
i
-
2
*
Zc
]
==
0
)
if
(
channel_input
[
i
-
2
*
Zc
]
==
0
)
modulated_input
[
i
]
=
1
/
sqrt
(
2
);
//
Q
PSK
modulated_input
[
i
]
=
1
/
sqrt
(
2
);
//
B
PSK
else
else
modulated_input
[
i
]
=-
1
/
sqrt
(
2
);
modulated_input
[
i
]
=-
1
/
sqrt
(
2
);
channel_output
[
i
]
=
modulated_input
[
i
]
+
gaussdouble
(
0
.
0
,
1
.
0
)
*
1
/
sqrt
(
2
*
SNR
);
channel_output
[
i
]
=
modulated_input
[
i
]
+
gaussdouble
(
0
.
0
,
1
.
0
)
*
1
/
sqrt
(
2
*
SNR
);
channel_output_fixed
[
i
]
=
(
short
)
((
channel_output
[
i
]
*
128
)
<
0
?
(
channel_output
[
i
]
*
128
-
0
.
5
)
:
(
channel_output
[
i
]
*
128
+
0
.
5
));
//fixed point 9-7
channel_output_fixed
[
i
]
=
(
char
)
((
channel_output
[
i
]
*
128
)
<
0
?
(
channel_output
[
i
]
*
128
-
0
.
5
)
:
(
channel_output
[
i
]
*
128
+
0
.
5
));
//fixed point 9-7
//printf("llr[%d]=%d\n",i,channel_output_fixed[i]);
}
}
//for (i=(Kb+nrows) * Zc-5;i<(Kb+nrows) * Zc;i++)
//for (i=(Kb+nrows) * Zc-5;i<(Kb+nrows) * Zc;i++)
...
@@ -215,29 +213,46 @@ int test_ldpc(short No_iteration,
...
@@ -215,29 +213,46 @@ int test_ldpc(short No_iteration,
printf
(
"
\n
"
);
printf
(
"
\n
"
);
exit
(
-
1
);
exit
(
-
1
);
#endif
#endif
decParams
.
BG
=
BG
;
decParams
.
Z
=
Zc
;
decParams
.
R
=
13
;
decParams
.
numMaxIter
=
6
;
decParams
.
outMode
=
nrLDPC_outMode_BIT
;
// decode the sequence
// decode the sequence
// decoder supports BG2, Z=128 & 256
// decoder supports BG2, Z=128 & 256
esimated_output
=
ldpc_decoder
(
channel_output_fixed
,
block_length
,
No_iteration
,
(
double
)((
float
)
nom_rate
/
(
float
)
denom_rate
));
//esimated_output=ldpc_decoder(channel_output_fixed, block_length, No_iteration, (double)((float)nom_rate/(float)denom_rate));
n_iter
=
nrLDPC_decoder
(
&
decParams
,
channel_output_fixed
,
estimated_output
,
NULL
);
//for (i=(Kb+nrows) * Zc-5;i<(Kb+nrows) * Zc;i++)
//for (i=(Kb+nrows) * Zc-5;i<(Kb+nrows) * Zc;i++)
// printf("esimated_output[%d]=%d\n",i,esimated_output[i]);
// printf("esimated_output[%d]=%d\n",i,esimated_output[i]);
//count errors
//count errors
for
(
i
=
2
*
Zc
;
i
<
(
Kb
+
nrows
-
no_punctured_columns
)
*
Zc
-
removed_bit
;
i
++
)
for
(
i
=
0
;
i
<
block_length
>>
3
;
i
++
)
{
{
if
(
es
imated_output
[
i
]
!=
channel_input
[
i
-
2
*
Zc
])
if
(
es
timated_output
[
i
]
!=
test_input
[
i
])
{
{
//printf("error pos %d (%d, %d)\n",i,estimated_output[i],test_input[i]);
*
errors
=
(
*
errors
)
+
1
;
*
errors
=
(
*
errors
)
+
1
;
break
;
break
;
}
}
}
}
free
(
channel_output_fixed
);
}
}
else
if
(
trial
==
0
)
/*
else if (trial==0)
printf
(
"decoder is not supported
\n
"
);
printf("decoder is not supported\n");
*/
}
}
free
(
test_input
);
free
(
channel_input
);
free
(
channel_input_optim
);
free
(
modulated_input
);
free
(
channel_output
);
free
(
channel_output_fixed
);
free
(
estimated_output
);
print_meas
(
&
time
,
"ldpc_encoder"
,
NULL
,
NULL
);
print_meas
(
&
time
,
"ldpc_encoder"
,
NULL
,
NULL
);
print_meas
(
&
time_optim
,
"ldpc_encoder_optim"
,
NULL
,
NULL
);
print_meas
(
&
time_optim
,
"ldpc_encoder_optim"
,
NULL
,
NULL
);
print_meas
(
&
tinput
,
"ldpc_encoder_optim(input)"
,
NULL
,
NULL
);
print_meas
(
&
tinput
,
"ldpc_encoder_optim(input)"
,
NULL
,
NULL
);
...
@@ -255,7 +270,7 @@ int main(int argc, char *argv[])
...
@@ -255,7 +270,7 @@ int main(int argc, char *argv[])
//double rate=0.333;
//double rate=0.333;
int
nom_rate
=
1
;
int
nom_rate
=
1
;
int
denom_rate
=
3
;
int
denom_rate
=
3
;
double
SNR
,
SNR_lin
;
double
SNR
0
=-
2
.
0
,
SNR
,
SNR_lin
;
unsigned
char
qbits
=
4
;
unsigned
char
qbits
=
4
;
unsigned
int
decoded_errors
[
100
];
// initiate the size of matrix equivalent to size of SNR
unsigned
int
decoded_errors
[
100
];
// initiate the size of matrix equivalent to size of SNR
int
c
,
i
=
0
;
int
c
,
i
=
0
;
...
@@ -264,7 +279,7 @@ int main(int argc, char *argv[])
...
@@ -264,7 +279,7 @@ int main(int argc, char *argv[])
randominit
(
0
);
randominit
(
0
);
while
((
c
=
getopt
(
argc
,
argv
,
"q:r:s:l:n:"
))
!=
-
1
)
while
((
c
=
getopt
(
argc
,
argv
,
"q:r:s:l:n:
d:
"
))
!=
-
1
)
switch
(
c
)
switch
(
c
)
{
{
case
'q'
:
case
'q'
:
...
@@ -275,7 +290,7 @@ int main(int argc, char *argv[])
...
@@ -275,7 +290,7 @@ int main(int argc, char *argv[])
nom_rate
=
atoi
(
optarg
);
nom_rate
=
atoi
(
optarg
);
break
;
break
;
case
'
s
'
:
case
'
d
'
:
denom_rate
=
atoi
(
optarg
);
denom_rate
=
atoi
(
optarg
);
break
;
break
;
...
@@ -287,6 +302,10 @@ int main(int argc, char *argv[])
...
@@ -287,6 +302,10 @@ int main(int argc, char *argv[])
n_trials
=
atoi
(
optarg
);
n_trials
=
atoi
(
optarg
);
break
;
break
;
case
's'
:
SNR0
=
atoi
(
optarg
);
break
;
default:
default:
abort
();
abort
();
}
}
...
@@ -296,7 +315,7 @@ int main(int argc, char *argv[])
...
@@ -296,7 +315,7 @@ int main(int argc, char *argv[])
printf
(
"block length %d:
\n
"
,
block_length
);
printf
(
"block length %d:
\n
"
,
block_length
);
printf
(
"rate: %d/%d
\n
"
,
nom_rate
,
denom_rate
);
printf
(
"rate: %d/%d
\n
"
,
nom_rate
,
denom_rate
);
for
(
SNR
=
-
2
.
1
;
SNR
<-
2
;
SNR
+=
.
1
)
for
(
SNR
=
SNR0
;
SNR
<
SNR0
+
3
.
0
;
SNR
+=
.
3
)
{
{
SNR_lin
=
pow
(
10
,
SNR
/
10
);
SNR_lin
=
pow
(
10
,
SNR
/
10
);
decoded_errors
[
i
]
=
test_ldpc
(
No_iteration
,
decoded_errors
[
i
]
=
test_ldpc
(
No_iteration
,
...
...
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