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
zzha zzha
OpenXG-RAN
Commits
34746b24
Commit
34746b24
authored
Jan 05, 2018
by
wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update ldpc encoder segmentation
parent
0b5394b5
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
37 deletions
+75
-37
openair1/PHY/CODING/Gen_shift_value.h
openair1/PHY/CODING/Gen_shift_value.h
+1
-0
openair1/PHY/CODING/defs.h
openair1/PHY/CODING/defs.h
+3
-2
openair1/PHY/CODING/ldpc_encoder.c
openair1/PHY/CODING/ldpc_encoder.c
+52
-23
openair1/PHY/CODING/nr_segmentation.c
openair1/PHY/CODING/nr_segmentation.c
+19
-12
No files found.
openair1/PHY/CODING/Gen_shift_value.h
View file @
34746b24
This diff is collapsed.
Click to expand it.
openair1/PHY/CODING/defs.h
View file @
34746b24
...
...
@@ -571,7 +571,8 @@ uint32_t crcbit (uint8_t * ,
int16_t
reverseBits
(
int32_t
,
int32_t
);
void
phy_viterbi_dot11
(
int8_t
*
,
uint8_t
*
,
uint16_t
);
short
*
ldpc_decoder
(
short
*
msgChannel
,
short
block_length
,
short
No_iteration
,
double
rate
);
short
*
ldpc_encoder
(
char
*
test_input
,
char
*
channel_input
,
short
block_length
,
double
rate
);
//short *ldpc_decoder(short *msgChannel,short block_length,short No_iteration,double rate);
//short *ldpc_encoder(char *test_input,char* channel_input,short block_length,double rate);
int
ldpc_encoder
(
unsigned
char
*
test_input
,
unsigned
char
*
channel_input
,
short
block_length
,
double
rate
);
#endif
openair1/PHY/CODING/ldpc_encoder.c
View file @
34746b24
...
...
@@ -116,11 +116,14 @@ short *choose_generator_matrix(short BG,short Zc)
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;
...
...
@@ -195,8 +198,10 @@ short *choose_generator_matrix(short BG,short Zc)
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;
...
...
@@ -221,31 +226,34 @@ short *choose_generator_matrix(short BG,short Zc)
break;
case 384: Gen_shift_values=(short*) Gen_shift_values_BG2_Z_384;
break;
}
*/
}
}
return
Gen_shift_values
;
}
int
ldpc_encoder
(
char
*
test_input
,
char
*
channel_input
,
short
block_length
,
double
rate
)
int
ldpc_encoder
(
unsigned
char
*
test_input
,
unsigned
char
*
channel_input
,
short
block_length
,
double
rate
)
{
char
c
[
22
*
384
];
//padded input, unpacked, max size
char
d
[
68
*
384
];
//coded output, unpacked, max size
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
,
channel_temp
;
int
i
,
i1
,
i2
,
i3
,
i4
,
i5
,
t
,
t
emp
,
temp_prime
;
int
no_punctured_columns
,
output_length
;
short
BG
,
Zc
,
Kb
,
nrows
,
ncols
;
int
i
,
i1
,
i2
,
i3
,
i4
,
i5
,
t
,
t
1
,
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
)
{
//
if (block_length>3840)
//
{
BG
=
1
;
Kb
=
22
;
nrows
=
46
;
//parity check bits
ncols
=
22
;
//info bits
}
/*
}
else if (block_length<=3840)
{
BG=2;
...
...
@@ -259,7 +267,7 @@ int ldpc_encoder(char *test_input,char* channel_input,short block_length,double
Kb = 8;
else
Kb = 6;
}
}
*/
//find minimum value in all sets of lifting size
for
(
i1
=
0
;
i1
<
51
;
i1
++
)
...
...
@@ -275,8 +283,8 @@ int ldpc_encoder(char *test_input,char* channel_input,short block_length,double
// 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
;
no_shift_values
=
(
short
*
)
no_shift_values_BG1
;
pointer_shift_values
=
(
short
*
)
pointer_shift_values_BG1
;
}
else
if
(
BG
==
2
)
...
...
@@ -286,15 +294,22 @@ int ldpc_encoder(char *test_input,char* channel_input,short block_length,double
}
Gen_shift_values
=
choose_generator_matrix
(
BG
,
Zc
);
no_punctured_columns
=
(
int
)((
nrows
+
Kb
-
2
)
*
Zc
-
block_length
/
rate
)
/
Zc
;
removed_bit
=
(
Kb
+
nrows
-
no_punctured_columns
-
2
)
*
Zc
-
(
int
)(
block_length
/
rate
);
//printf("%d\n",no_punctured_columns);
output_length
=
(
Kb
+
nrows
-
no_punctured_columns
)
*
Zc
;
//
output_length = (Kb+nrows-no_punctured_columns) * Zc;
// 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
))
&
1
;
{
//c[i] = test_input[i/8]<<(i%8);
// c[i]=c[i]>>7&1;
c
[
i
]
=
(
test_input
[
i
/
8
]
&
(
1
<<
(
i
&
7
)))
>>
(
i
&
7
);
}
// parity check part
for
(
i2
=
0
;
i2
<
Zc
;
i2
++
)
{
...
...
@@ -303,7 +318,7 @@ int ldpc_encoder(char *test_input,char* channel_input,short block_length,double
for
(
i5
=
0
;
i5
<
Kb
;
i5
++
)
{
temp
=
c
[
i5
*
Zc
];
memmove
(
&
c
[
i5
*
Zc
],
&
c
[
i5
*
Zc
+
1
],
(
Zc
-
1
)
*
sizeof
(
short
));
memmove
(
&
c
[
i5
*
Zc
],
&
c
[
i5
*
Zc
+
1
],
(
Zc
-
1
)
*
sizeof
(
unsigned
char
));
c
[
i5
*
Zc
+
Zc
-
1
]
=
temp
;
}
...
...
@@ -321,17 +336,31 @@ int ldpc_encoder(char *test_input,char* channel_input,short block_length,double
}
d
[
t
+
i1
*
Zc
]
=
channel_temp
;
//channel_input[t+i1*Zc]=channel_temp;
}
}
// information part
memcpy
(
d
,
c
,
Kb
*
Zc
*
sizeof
(
short
));
memcpy
(
d
,
c
,
Kb
*
Zc
*
sizeof
(
unsigned
char
));
// puncture columns
for
(
i
=
2
*
Zc
,
t1
=
0
;
i
<
(
Kb
+
nrows
-
no_punctured_columns
)
*
Zc
-
removed_bit
;
i
++
)
{
channel_input
[
t1
]
=
d
[
i
];
t1
++
;
}
//memcpy(channel_input,c,Kb*Zc*sizeof(unsigned char));
/*
//pack into output
memset
(
channel_input
,
0
,
output_length
/
8
*
sizeof
(
char
));
memset(channel_input,0,output_length/8*sizeof(
unsigned
char));
for (i=0;i<output_length;i++)
channel_input
[
i
/
8
]
=
channel_input
[
i
/
8
]
|
(
d
[
i
]
<<
(
i
%
8
));
{
//printf("[%d]=%d\n",i,d[i]);
d[i]=d[i] << 7;
channel_input[i/8] = channel_input[i/8] | (d[i] >> (i%8));
}
*/
return
0
;
}
openair1/PHY/CODING/nr_segmentation.c
View file @
34746b24
...
...
@@ -53,9 +53,9 @@ int32_t nr_segmentation(unsigned char *input_buffer,
*
C
=*
C
+
1
;
Bprime
=
B
+
((
*
C
)
*
L
);
#ifdef DEBUG_SEGMENTATION
//
#ifdef DEBUG_SEGMENTATION
printf
(
"Bprime %d
\n
"
,
Bprime
);
#endif
//
#endif
}
if
((
*
C
)
>
MAX_NUM_DLSCH_SEGMENTS
)
{
...
...
@@ -65,7 +65,7 @@ int32_t nr_segmentation(unsigned char *input_buffer,
// Find K+
Bprime_by_C
=
Bprime
/
(
*
C
);
if
(
Bprime
<=
192
)
{
/*
if (Bprime <=192) {
Kb = 6;
} else if (Bprime <=560) {
Kb = 8;
...
...
@@ -73,11 +73,17 @@ int32_t nr_segmentation(unsigned char *input_buffer,
Kb = 9;
} else if (Bprime <=3840) {
Kb = 10;;
}
else
{
} else {
*/
Kb
=
22
;
}
//}
if
((
Bprime_by_C
%
Kb
)
>
0
)
Z
=
(
Bprime_by_C
/
Kb
)
+
1
;
else
Z
=
(
Bprime_by_C
/
Kb
);
printf
(
"nr segmetation B %d Bprime %d Bprime_by_C %d z %d
\n
"
,
B
,
Bprime
,
Bprime_by_C
,
Z
);
if
(
Z
<=
2
)
{
*
Kplus
=
2
;
...
...
@@ -106,9 +112,9 @@ int32_t nr_segmentation(unsigned char *input_buffer,
if
(
*
Kplus
<
Z
)
*
Kplus
=
*
Kplus
+
8
;
#ifdef DEBUG_SEGMENTATION
//
#ifdef DEBUG_SEGMENTATION
printf
(
"Z_by_C %d , Kplus2 %d
\n
"
,
Z
,
*
Kplus
);
#endif
//
#endif
*
Kminus
=
(
*
Kplus
-
8
);
}
else
if
(
Z
<=
256
)
{
// increase by 4 bytes til here
*
Kplus
=
(
Z
>>
4
)
<<
4
;
...
...
@@ -128,13 +134,14 @@ int32_t nr_segmentation(unsigned char *input_buffer,
//msg("nr_segmentation.c: Illegal codeword size !!!\n");
return
(
-
1
);
}
*
Zout
=
*
Kplus
;
*
Kplus
=
*
Kplus
*
Kb
;
*
Kminus
=
*
Kminus
*
Kb
;
*
Zout
=
Z
;
*
F
=
((
*
C
)
*
(
*
Kplus
)
-
(
Bprime
));
printf
(
"final nr seg output Z %d Kplus %d F %d
\n
"
,
*
Zout
,
*
Kplus
,
*
F
);
#ifdef DEBUG_SEGMENTATION
printf
(
"C %d, Kplus %d, Kminus %d, Bprime_bytes %d, Bprime %d, F %d
\n
"
,
*
C
,
*
Kplus
,
*
Kminus
,
Bprime
>>
3
,
Bprime
,
*
F
);
#endif
...
...
@@ -149,10 +156,10 @@ int32_t nr_segmentation(unsigned char *input_buffer,
for
(
r
=
0
;
r
<*
C
;
r
++
)
{
if
(
r
<
(
B
%
(
*
C
)))
//
if (r<(B%(*C)))
Kprime
=
*
Kplus
;
else
Kprime
=
*
Kminus
;
//
else
//
Kprime = *Kminus;
while
(
k
<
((
Kprime
-
L
)
>>
3
))
{
output_buffers
[
r
][
k
]
=
input_buffer
[
s
];
...
...
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