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
4c86d4fb
Commit
4c86d4fb
authored
Jan 23, 2018
by
Florian Kaltenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding latest version of ldpc_encoder from branch feature_ldpc_coding
parent
188a6013
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5925 additions
and
601 deletions
+5925
-601
cmake_targets/CMakeLists.txt
cmake_targets/CMakeLists.txt
+1
-0
openair1/PHY/CODING/TESTBENCH/ldpctest.c
openair1/PHY/CODING/TESTBENCH/ldpctest.c
+61
-48
openair1/PHY/CODING/defs.h
openair1/PHY/CODING/defs.h
+1
-0
openair1/PHY/CODING/ldpc_encoder.c
openair1/PHY/CODING/ldpc_encoder.c
+5414
-553
openair1/PHY/CODING/ldpc_generate_coefficient.c
openair1/PHY/CODING/ldpc_generate_coefficient.c
+448
-0
No files found.
cmake_targets/CMakeLists.txt
View file @
4c86d4fb
...
...
@@ -1089,6 +1089,7 @@ set(PHY_SRC
${
OPENAIR1_DIR
}
/PHY/CODING/nr_segmentation.c
${
OPENAIR1_DIR
}
/PHY/CODING/ldpc_decoder.c
${
OPENAIR1_DIR
}
/PHY/CODING/ldpc_encoder.c
${
OPENAIR1_DIR
}
/PHY/CODING/ldpc_generate_coefficient.c
${
OPENAIR1_DIR
}
/PHY/CODING/ccoding_byte.c
${
OPENAIR1_DIR
}
/PHY/CODING/ccoding_byte_lte.c
${
OPENAIR1_DIR
}
/PHY/CODING/3gpplte_sse.c
...
...
openair1/PHY/CODING/TESTBENCH/ldpctest.c
View file @
4c86d4fb
...
...
@@ -26,6 +26,8 @@
#include "SIMULATION/TOOLS/defs.h"
// 4-bit quantizer
char
quantize4bit
(
double
D
,
double
x
)
{
...
...
@@ -81,7 +83,7 @@ int test_ldpc(short No_iteration,
double
*
modulated_input
;
short
*
channel_output_fixed
;
unsigned
int
i
,
trial
=
0
;
short
BG
,
Zc
,
Kb
,
nrows
,
ncols
,
channel_temp
;
short
BG
,
Zc
,
Kb
,
nrows
,
ncols
;
int
no_punctured_columns
,
removed_bit
;
int
i1
;
//Table of possible lifting sizes
...
...
@@ -89,14 +91,13 @@ int test_ldpc(short No_iteration,
*
errors
=
0
;
*
crc_misses
=
0
;
// generate input block
test_input
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
block_length
/
8
);
test_input
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
block_length
/
8
);
channel_input
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
68
*
384
);
modulated_input
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
68
*
384
);
channel_output
=
(
double
*
)
malloc
(
sizeof
(
double
)
*
68
*
384
);
reset_meas
(
&
time
);
while
(
trial
++
<
ntrials
)
{
for
(
i
=
0
;
i
<
block_length
/
8
;
i
++
)
{
//test_input[i]=(unsigned char) rand();
...
...
@@ -104,32 +105,31 @@ int test_ldpc(short No_iteration,
}
//determine number of bits in codeword
//if (block_length>3840)
//{
BG
=
1
;
Kb
=
22
;
nrows
=
46
;
//parity check bits
ncols
=
22
;
//info bits
// }
/*
else if (block_length<=3840)
{
BG=2;
nrows=42; //parity check bits
ncols=10; // info bits
if (block_length>640)
Kb = 10;
else if (block_length>560)
Kb = 9;
else if (block_length>192)
Kb = 8;
else
Kb = 6;
}
*/
if
(
block_length
>
3840
)
{
BG
=
1
;
Kb
=
22
;
nrows
=
46
;
//parity check bits
ncols
=
22
;
//info bits
}
else
if
(
block_length
<=
3840
)
{
BG
=
2
;
nrows
=
42
;
//parity check bits
ncols
=
10
;
// info bits
if
(
block_length
>
640
)
Kb
=
10
;
else
if
(
block_length
>
560
)
Kb
=
9
;
else
if
(
block_length
>
192
)
Kb
=
8
;
else
Kb
=
6
;
}
//find minimum value in all sets of lifting size
Zc
=
0
;
for
(
i1
=
0
;
i1
<
51
;
i1
++
)
{
if
(
lift_size
[
i1
]
>=
(
double
)
block_length
/
Kb
)
...
...
@@ -140,21 +140,30 @@ int test_ldpc(short No_iteration,
}
}
printf
(
"BG %d, Zc %d, Kb %d
\n
"
,
BG
,
Zc
,
Kb
);
no_punctured_columns
=
(
int
)((
nrows
-
2
)
*
Zc
+
block_length
-
block_length
/
rate
)
/
Zc
;
//printf("%d\n",no_punctured_columns);
start_meas
(
&
time
);
//// encoder
ldpc_encoder
(
test_input
,
channel_input
,
block_length
,
rate
);
stop_meas
(
&
time
);
print_meas_now
(
&
time
,
""
,
stdout
);
for
(
i
=
0
;
i
<
10
;
i
++
)
printf
(
"channel_input[%d]=%d
\n
"
,
i
,
channel_input
[
i
]);
for
(
trial
=
0
;
trial
<
ntrials
;
trial
++
)
{
//// encoder
if
(
ntrials
==
1
)
ldpc_encoder_orig
(
test_input
,
channel_input
,
block_length
,
rate
,
1
);
else
{
start_meas
(
&
time
);
if
(
BG
==
1
)
ldpc_encoder
(
test_input
,
channel_input
,
block_length
,
rate
);
else
ldpc_encoder_orig
(
test_input
,
channel_input
,
block_length
,
rate
,
0
);
stop_meas
(
&
time
);
}
//print_meas_now(&time, "", stdout);
ldpc_encoder_orig
(
test_input
,
channel_input
,
block_length
,
rate
);
for
(
i
=
0
;
i
<
10
;
i
++
)
printf
(
"channel_input[%d]=%d
\n
"
,
i
,
channel_input
[
i
]);
// for (i=0;i<8448;i++)
//printf("channel_input[%d]=%d\n",i,channel_input[i]);
//printf("%d ",channel_input[i]);
if
((
BG
==
2
)
&&
(
Zc
==
128
||
Zc
==
256
))
{
...
...
@@ -210,24 +219,27 @@ int test_ldpc(short No_iteration,
free
(
channel_output_fixed
);
}
else
printf
(
"decoder is not supported
\n
"
);
if
(
trial
==
0
)
printf
(
"decoder is not supported
\n
"
);
}
print_meas
(
&
time
,
"ldpc encoder"
,
NULL
,
NULL
);
print_meas
(
&
time
,
"ldpc_encoder"
,
NULL
,
NULL
);
return
*
errors
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
unsigned
int
errors
,
crc_misses
;
short
block_length
=
22
*
128
;
// decoder supports length: 1201 -> 1280, 2401 -> 2560
short
block_length
=
22
*
384
;
// decoder supports length: 1201 -> 1280, 2401 -> 2560
short
No_iteration
=
25
;
double
rate
=
0
.
333
;
double
SNR
,
SNR_lin
;
unsigned
char
qbits
=
4
;
unsigned
int
decoded_errors
[
100
];
// initiate the size of matrix equivalent to size of SNR
int
c
,
i
=
0
;
int
ntrials
=
100
;
int
n
_
trials
=
100
;
randominit
(
0
);
while
((
c
=
getopt
(
argc
,
argv
,
"q:r:l:n:"
))
!=
-
1
)
...
...
@@ -245,9 +257,9 @@ int main(int argc, char *argv[])
block_length
=
atoi
(
optarg
);
break
;
case
'n'
:
n
trials
=
atoi
(
optarg
);
break
;
case
'n'
:
n_
trials
=
atoi
(
optarg
);
break
;
default:
abort
();
...
...
@@ -266,10 +278,10 @@ int main(int argc, char *argv[])
SNR_lin
,
// noise standard deviation
qbits
,
block_length
,
// block length bytes
ntrials
,
n
_
trials
,
&
errors
,
&
crc_misses
);
printf
(
"SNR %f, BLER %f (%d/%d)
\n
"
,
SNR
,(
float
)
decoded_errors
[
i
]
/
(
float
)
n
trials
,
decoded_errors
[
i
],
n
trials
);
printf
(
"SNR %f, BLER %f (%d/%d)
\n
"
,
SNR
,(
float
)
decoded_errors
[
i
]
/
(
float
)
n
_trials
,
decoded_errors
[
i
],
n_
trials
);
i
=
i
+
1
;
}
...
...
@@ -277,3 +289,4 @@ int main(int argc, char *argv[])
}
openair1/PHY/CODING/defs.h
View file @
4c86d4fb
...
...
@@ -573,5 +573,6 @@ void phy_viterbi_dot11(int8_t *,uint8_t *,uint16_t);
short
*
ldpc_decoder
(
short
*
msgChannel
,
short
block_length
,
short
No_iteration
,
double
rate
);
int
ldpc_encoder
(
unsigned
char
*
test_input
,
unsigned
char
*
channel_input
,
short
block_length
,
double
rate
);
int
ldpc_encoder_orig
(
unsigned
char
*
test_input
,
unsigned
char
*
channel_input
,
short
block_length
,
double
rate
,
unsigned
char
gen_code
);
#endif
openair1/PHY/CODING/ldpc_encoder.c
View file @
4c86d4fb
This source diff could not be displayed because it is too large. You can
view the blob
instead.
openair1/PHY/CODING/ldpc_generate_coefficient.c
0 → 100644
View file @
4c86d4fb
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "Gen_shift_value.h"
short
*
choose_generator_matrix
(
short
BG
,
short
Zc
)
{
short
*
Gen_shift_values
;
if
(
BG
==
1
)
{
switch
(
Zc
)
{
case
2
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_2
;
break
;
case
3
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_3
;
break
;
case
4
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_4
;
break
;
case
5
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_5
;
break
;
case
6
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_6
;
break
;
case
7
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_7
;
break
;
case
8
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_8
;
break
;
case
9
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_9
;
break
;
case
10
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_10
;
break
;
case
11
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_11
;
break
;
case
12
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_12
;
break
;
case
13
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_13
;
break
;
case
14
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_14
;
break
;
case
15
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_15
;
break
;
case
16
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_16
;
break
;
case
18
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_18
;
break
;
case
20
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_20
;
break
;
case
22
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_22
;
break
;
case
24
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_24
;
break
;
case
26
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_26
;
break
;
case
28
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_28
;
break
;
case
30
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_30
;
break
;
case
32
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_32
;
break
;
case
36
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_36
;
break
;
case
40
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_40
;
break
;
case
44
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_44
;
break
;
case
48
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_48
;
break
;
case
52
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_52
;
break
;
case
56
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_56
;
break
;
case
60
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_60
;
break
;
case
64
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_64
;
break
;
case
72
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_72
;
break
;
case
80
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_80
;
break
;
case
88
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_88
;
break
;
case
96
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_96
;
break
;
case
104
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_104
;
break
;
case
112
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_112
;
break
;
case
120
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_120
;
break
;
case
128
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_128
;
break
;
case
144
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_144
;
break
;
case
160
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_160
;
break
;
case
176
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_176
;
break
;
case
192
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_192
;
break
;
case
208
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_208
;
break
;
case
224
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_224
;
break
;
case
240
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_240
;
break
;
case
256
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_256
;
break
;
case
288
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_288
;
break
;
case
320
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_320
;
break
;
case
352
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_352
;
break
;
case
384
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG1_Z_384
;
break
;
}
}
else
if
(
BG
==
2
)
{
switch
(
Zc
)
{
case
2
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_2
;
break
;
case
3
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_3
;
break
;
case
4
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_4
;
break
;
case
5
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_5
;
break
;
case
6
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_6
;
break
;
case
7
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_7
;
break
;
case
8
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_8
;
break
;
case
9
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_9
;
break
;
case
10
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_10
;
break
;
case
11
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_11
;
break
;
case
12
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_12
;
break
;
case
13
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_13
;
break
;
case
14
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_14
;
break
;
case
15
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_15
;
break
;
case
16
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_16
;
break
;
case
18
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_18
;
break
;
case
20
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_20
;
break
;
case
22
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_22
;
break
;
case
24
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_24
;
break
;
case
26
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_26
;
break
;
case
28
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_28
;
break
;
case
30
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_30
;
break
;
case
32
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_32
;
break
;
case
36
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_36
;
break
;
case
40
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_40
;
break
;
case
44
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_44
;
break
;
case
48
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_48
;
break
;
case
52
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_52
;
break
;
case
56
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_56
;
break
;
case
60
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_60
;
break
;
case
64
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_64
;
break
;
case
72
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_72
;
break
;
case
80
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_80
;
break
;
case
88
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_88
;
break
;
case
96
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_96
;
break
;
case
104
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_104
;
break
;
case
112
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_112
;
break
;
case
120
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_120
;
break
;
case
128
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_128
;
break
;
case
144
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_144
;
break
;
case
160
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_160
;
break
;
case
176
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_176
;
break
;
case
192
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_192
;
break
;
case
208
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_208
;
break
;
case
224
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_224
;
break
;
case
240
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_240
;
break
;
case
256
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_256
;
break
;
case
288
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_288
;
break
;
case
320
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_320
;
break
;
case
352
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_352
;
break
;
case
384
:
Gen_shift_values
=
(
short
*
)
Gen_shift_values_BG2_Z_384
;
break
;
}
}
return
Gen_shift_values
;
}
int
ldpc_encoder_orig
(
unsigned
char
*
test_input
,
unsigned
char
*
channel_input
,
short
block_length
,
double
rate
,
unsigned
char
gen_code
)
{
unsigned
char
c
[
22
*
384
];
//padded input, unpacked, max size
unsigned
char
d
[
68
*
384
];
//coded output, unpacked, max size
unsigned
char
channel_temp
,
temp
;
short
*
Gen_shift_values
,
*
no_shift_values
,
*
pointer_shift_values
;
short
BG
,
Zc
,
Kb
,
nrows
,
ncols
;
int
i
,
i1
,
i2
,
i3
,
i4
,
i5
,
t
,
t1
,
temp_prime
;
int
no_punctured_columns
,
removed_bit
;
//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
};
//determine number of bits in codeword
if
(
block_length
>
3840
)
{
BG
=
1
;
Kb
=
22
;
nrows
=
46
;
//parity check bits
ncols
=
22
;
//info bits
}
else
if
(
block_length
<=
3840
)
{
BG
=
2
;
nrows
=
42
;
//parity check bits
ncols
=
10
;
// info bits
if
(
block_length
>
640
)
Kb
=
10
;
else
if
(
block_length
>
560
)
Kb
=
9
;
else
if
(
block_length
>
192
)
Kb
=
8
;
else
Kb
=
6
;
}
//find minimum value in all sets of lifting size
for
(
i1
=
0
;
i1
<
51
;
i1
++
)
{
if
(
lift_size
[
i1
]
>=
(
double
)
block_length
/
Kb
)
{
Zc
=
lift_size
[
i1
];
//printf("%d\n",Zc);
break
;
}
}
// load base graph of generator matrix
if
(
BG
==
1
)
{
no_shift_values
=
(
short
*
)
no_shift_values_BG1
;
pointer_shift_values
=
(
short
*
)
pointer_shift_values_BG1
;
}
else
if
(
BG
==
2
)
{
no_shift_values
=
(
short
*
)
no_shift_values_BG2
;
pointer_shift_values
=
(
short
*
)
pointer_shift_values_BG2
;
}
Gen_shift_values
=
choose_generator_matrix
(
BG
,
Zc
);
// calculate number of punctured bits
no_punctured_columns
=
(
int
)((
nrows
-
2
)
*
Zc
+
block_length
-
block_length
/
rate
)
/
Zc
;
removed_bit
=
(
nrows
-
no_punctured_columns
-
2
)
*
Zc
+
block_length
-
(
int
)(
block_length
/
rate
);
//printf("%d\n",no_punctured_columns);
//printf("%d\n",removed_bit);
// unpack input
memset
(
c
,
0
,
sizeof
(
unsigned
char
)
*
Kb
*
Zc
);
for
(
i
=
0
;
i
<
block_length
;
i
++
)
{
c
[
i
]
=
test_input
[
i
/
8
]
<<
(
i
%
8
);
c
[
i
]
=
c
[
i
]
>>
7
&
1
;
}
// parity check part
for
(
i2
=
0
;
i2
<
1
;
i2
++
)
{
t
=
Kb
*
Zc
+
i2
;
//rotate matrix here
for
(
i5
=
0
;
i5
<
Kb
;
i5
++
)
{
temp
=
c
[
i5
*
Zc
];
memmove
(
&
c
[
i5
*
Zc
],
&
c
[
i5
*
Zc
+
1
],
(
Zc
-
1
)
*
sizeof
(
unsigned
char
));
c
[
i5
*
Zc
+
Zc
-
1
]
=
temp
;
}
// calculate each row in base graph
for
(
i1
=
0
;
i1
<
nrows
-
no_punctured_columns
;
i1
++
)
{
channel_temp
=
0
;
if
(
gen_code
)
{
printf
(
"//row: %d
\n
"
,
i1
);
printf
(
"d[i2+%d*Zc]="
,
i1
);
}
for
(
i3
=
0
;
i3
<
Kb
;
i3
++
)
{
temp_prime
=
i1
*
ncols
+
i3
;
for
(
i4
=
0
;
i4
<
no_shift_values
[
temp_prime
];
i4
++
)
{
channel_temp
=
channel_temp
^
c
[
i3
*
Zc
+
Gen_shift_values
[
pointer_shift_values
[
temp_prime
]
+
i4
]
];
if
(
gen_code
)
printf
(
"c[%d]^"
,
i3
*
Zc
+
Gen_shift_values
[
pointer_shift_values
[
temp_prime
]
+
i4
]
);
}
}
if
(
gen_code
)
printf
(
"
\n
"
);
d
[
t
+
i1
*
Zc
]
=
channel_temp
;
//channel_input[t+i1*Zc]=channel_temp;
}
}
// information part and puncture columns
memcpy
(
&
channel_input
[
0
],
&
c
[
2
*
Zc
],
(
block_length
-
2
*
Zc
)
*
sizeof
(
unsigned
char
));
memcpy
(
&
channel_input
[
block_length
-
2
*
Zc
],
&
d
[
Kb
*
Zc
],
((
nrows
-
no_punctured_columns
)
*
Zc
-
removed_bit
)
*
sizeof
(
unsigned
char
));
//memcpy(channel_input,c,Kb*Zc*sizeof(unsigned char));
return
0
;
}
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