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
52669a08
Commit
52669a08
authored
Sep 10, 2018
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order of dimensions on llr array
parent
ee1ea7e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
23 deletions
+30
-23
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
+7
-7
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
+23
-16
No files found.
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c
View file @
52669a08
...
@@ -40,7 +40,7 @@ int8_t polar_decoder(
...
@@ -40,7 +40,7 @@ int8_t polar_decoder(
uint8_t
***
bit
=
nr_alloc_uint8_t_3D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
),
2
*
listSize
);
uint8_t
***
bit
=
nr_alloc_uint8_t_3D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
),
2
*
listSize
);
uint8_t
**
bitUpdated
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
));
//0=False, 1=True
uint8_t
**
bitUpdated
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
));
//0=False, 1=True
uint8_t
**
llrUpdated
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
));
//0=False, 1=True
uint8_t
**
llrUpdated
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
));
//0=False, 1=True
double
***
llr
=
nr_alloc_double_3D_array
(
polarParams
->
N
,
(
polarParams
->
n
+
1
),
2
*
listSize
);
double
***
llr
=
nr_alloc_double_3D_array
(
2
*
listSize
,(
polarParams
->
n
+
1
),
polarParams
->
N
);
uint8_t
**
crcChecksum
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
crcParityBits
,
2
*
listSize
);
uint8_t
**
crcChecksum
=
nr_alloc_uint8_t_2D_array
(
polarParams
->
crcParityBits
,
2
*
listSize
);
double
*
pathMetric
=
malloc
(
sizeof
(
double
)
*
(
2
*
listSize
));
double
*
pathMetric
=
malloc
(
sizeof
(
double
)
*
(
2
*
listSize
));
uint8_t
*
crcState
=
malloc
(
sizeof
(
uint8_t
)
*
(
2
*
listSize
));
//0=False, 1=True
uint8_t
*
crcState
=
malloc
(
sizeof
(
uint8_t
)
*
(
2
*
listSize
));
//0=False, 1=True
...
@@ -92,7 +92,7 @@ int8_t polar_decoder(
...
@@ -92,7 +92,7 @@ int8_t polar_decoder(
double
*
d_tilde
=
malloc
(
sizeof
(
double
)
*
polarParams
->
N
);
double
*
d_tilde
=
malloc
(
sizeof
(
double
)
*
polarParams
->
N
);
nr_polar_rate_matching
(
input
,
d_tilde
,
polarParams
->
rate_matching_pattern
,
polarParams
->
K
,
polarParams
->
N
,
polarParams
->
encoderLength
);
nr_polar_rate_matching
(
input
,
d_tilde
,
polarParams
->
rate_matching_pattern
,
polarParams
->
K
,
polarParams
->
N
,
polarParams
->
encoderLength
);
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
llr
[
j
][
polarParams
->
n
][
0
]
=
d_tilde
[
j
];
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
llr
[
0
][
polarParams
->
n
][
j
]
=
d_tilde
[
j
];
/*
/*
...
@@ -130,7 +130,7 @@ int8_t polar_decoder(
...
@@ -130,7 +130,7 @@ int8_t polar_decoder(
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
{
for
(
int
j
=
0
;
j
<
polarParams
->
N
;
j
++
)
{
for
(
int
k
=
0
;
k
<
(
polarParams
->
n
+
1
);
k
++
)
{
for
(
int
k
=
0
;
k
<
(
polarParams
->
n
+
1
);
k
++
)
{
bit
[
j
][
k
][
i
+
currentListSize
]
=
bit
[
j
][
k
][
i
];
bit
[
j
][
k
][
i
+
currentListSize
]
=
bit
[
j
][
k
][
i
];
llr
[
j
][
k
][
i
+
currentListSize
]
=
llr
[
j
][
k
][
i
];}}}
llr
[
i
+
currentListSize
][
k
][
j
]
=
llr
[
i
][
k
][
j
];}}}
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
currentListSize
;
i
++
)
{
bit
[
currentBit
][
0
][
i
]
=
0
;
bit
[
currentBit
][
0
][
i
]
=
0
;
...
@@ -167,7 +167,7 @@ int8_t polar_decoder(
...
@@ -167,7 +167,7 @@ int8_t polar_decoder(
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
bit
[
i
][
j
][
listIndex
[(
2
*
listSize
-
1
)
-
k
]]
=
bit
[
i
][
j
][
listIndex
[
k
]];
bit
[
i
][
j
][
listIndex
[(
2
*
listSize
-
1
)
-
k
]]
=
bit
[
i
][
j
][
listIndex
[
k
]];
llr
[
i
][
j
][
listIndex
[(
2
*
listSize
-
1
)
-
k
]]
=
llr
[
i
][
j
][
listIndex
[
k
]
];
llr
[
listIndex
[(
2
*
listSize
-
1
)
-
k
]][
j
][
i
]
=
llr
[
listIndex
[
k
]][
j
][
i
];
}
}
}
}
}
}
...
@@ -188,7 +188,7 @@ int8_t polar_decoder(
...
@@ -188,7 +188,7 @@ int8_t polar_decoder(
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
i
=
0
;
i
<
polarParams
->
N
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
for
(
int
j
=
0
;
j
<
(
polarParams
->
n
+
1
);
j
++
)
{
bit
[
i
][
j
][
k
]
=
bit
[
i
][
j
][
copyIndex
];
bit
[
i
][
j
][
k
]
=
bit
[
i
][
j
][
copyIndex
];
llr
[
i
][
j
][
k
]
=
llr
[
i
][
j
][
copyIndex
];
llr
[
k
][
j
][
i
]
=
llr
[
copyIndex
][
j
][
i
];
}
}
}
}
}
}
...
@@ -236,7 +236,7 @@ int8_t polar_decoder(
...
@@ -236,7 +236,7 @@ int8_t polar_decoder(
free
(
pathMetric
);
free
(
pathMetric
);
free
(
crcState
);
free
(
crcState
);
nr_free_uint8_t_3D_array
(
bit
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
nr_free_uint8_t_3D_array
(
bit
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
nr_free_double_3D_array
(
llr
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
nr_free_double_3D_array
(
llr
,
2
*
listSize
,
(
polarParams
->
n
+
1
));
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
return
(
-
1
);
return
(
-
1
);
}
}
...
@@ -271,7 +271,7 @@ int8_t polar_decoder(
...
@@ -271,7 +271,7 @@ int8_t polar_decoder(
free
(
pathMetric
);
free
(
pathMetric
);
free
(
crcState
);
free
(
crcState
);
nr_free_uint8_t_3D_array
(
bit
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
nr_free_uint8_t_3D_array
(
bit
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
nr_free_double_3D_array
(
llr
,
polarParams
->
N
,
(
polarParams
->
n
+
1
));
nr_free_double_3D_array
(
llr
,
2
*
listSize
,
(
polarParams
->
n
+
1
));
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
nr_free_uint8_t_2D_array
(
crcChecksum
,
polarParams
->
crcParityBits
);
nr_free_uint8_t_2D_array
(
extended_crc_generator_matrix
,
polarParams
->
K
);
nr_free_uint8_t_2D_array
(
extended_crc_generator_matrix
,
polarParams
->
K
);
nr_free_uint8_t_2D_array
(
tempECGM
,
polarParams
->
K
);
nr_free_uint8_t_2D_array
(
tempECGM
,
polarParams
->
K
);
...
...
openair1/PHY/CODING/nrPolar_tools/nr_polar_decoding_tools.c
View file @
52669a08
...
@@ -36,7 +36,7 @@ void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU,
...
@@ -36,7 +36,7 @@ void updateLLR(double ***llr, uint8_t **llrU, uint8_t ***bit, uint8_t **bitU,
printf
(
"updating LLR (%d,%d,%d) (bit %d,%d,%d, llr0 %d,%d,%d, llr1 %d,%d,%d
\n
"
,
row
,
col
,
i
,
printf
(
"updating LLR (%d,%d,%d) (bit %d,%d,%d, llr0 %d,%d,%d, llr1 %d,%d,%d
\n
"
,
row
,
col
,
i
,
row
-
offset
,
col
,
i
,
row
-
offset
,
col
+
1
,
i
,
row
,
col
+
1
,
i
);
row
-
offset
,
col
,
i
,
row
-
offset
,
col
+
1
,
i
,
row
,
col
+
1
,
i
);
#endif
#endif
llr
[
row
][
col
][
i
]
=
(
pow
((
-
1
),
bit
[
row
-
offset
][
col
][
i
])
*
llr
[
row
-
offset
][
col
+
1
][
i
])
+
llr
[
row
][
col
+
1
][
i
];
llr
[
i
][
col
][
row
]
=
(
pow
((
-
1
),
bit
[
row
-
offset
][
col
][
i
])
*
llr
[
i
][
col
+
1
][
row
-
offset
])
+
llr
[
i
][
col
+
1
][
row
];
}
}
}
else
{
}
else
{
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
if
(
llrU
[
row
][
col
+
1
]
==
0
)
updateLLR
(
llr
,
llrU
,
bit
,
bitU
,
listSize
,
row
,
(
col
+
1
),
xlen
,
ylen
,
approximation
);
...
@@ -84,11 +84,11 @@ void updatePathMetric(double *pathMetric, double ***llr, uint8_t listSize, uint8
...
@@ -84,11 +84,11 @@ void updatePathMetric(double *pathMetric, double ***llr, uint8_t listSize, uint8
if
(
approximation
)
{
//eq. (12)
if
(
approximation
)
{
//eq. (12)
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
{
if
((
2
*
bitValue
)
!=
(
1
-
copysign
(
1
.
0
,
llr
[
row
][
0
][
i
])
))
pathMetric
[
i
]
+=
fabs
(
llr
[
row
][
0
][
i
]);
if
((
2
*
bitValue
)
!=
(
1
-
copysign
(
1
.
0
,
llr
[
i
][
0
][
row
])
))
pathMetric
[
i
]
+=
fabs
(
llr
[
i
][
0
][
row
]);
}
}
}
else
{
//eq. (11b)
}
else
{
//eq. (11b)
int8_t
multiplier
=
(
2
*
bitValue
)
-
1
;
int8_t
multiplier
=
(
2
*
bitValue
)
-
1
;
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
pathMetric
[
i
]
+=
log
(
1
+
exp
(
multiplier
*
llr
[
row
][
0
][
i
])
)
;
for
(
uint8_t
i
=
0
;
i
<
listSize
;
i
++
)
pathMetric
[
i
]
+=
log
(
1
+
exp
(
multiplier
*
llr
[
i
][
0
][
row
])
)
;
}
}
}
}
...
@@ -138,25 +138,27 @@ void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, uint
...
@@ -138,25 +138,27 @@ void updatePathMetric2(double *pathMetric, double ***llr, uint8_t listSize, uint
if
(
appr
)
{
//eq. (12)
if
(
appr
)
{
//eq. (12)
for
(
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
i
=
0
;
i
<
listSize
;
i
++
)
{
// bitValue=0
// bitValue=0
if
(
llr
[
row
][
0
][
i
]
<
0
)
pathMetric
[
i
]
-=
llr
[
row
][
0
][
i
];
if
(
llr
[
i
][
0
][
row
]
<
0
)
pathMetric
[
i
]
-=
llr
[
i
][
0
][
row
];
// bitValue=1
// bitValue=1
else
pm2
[
i
]
+=
llr
[
row
][
0
][
i
];
else
pm2
[
i
]
+=
llr
[
i
][
0
][
row
];
}
}
}
else
{
//eq. (11b)
}
else
{
//eq. (11b)
for
(
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
i
=
0
;
i
<
listSize
;
i
++
)
{
// bitValue=0
// bitValue=0
pathMetric
[
i
]
+=
log
(
1
+
exp
(
-
llr
[
row
][
0
][
i
]));
pathMetric
[
i
]
+=
log
(
1
+
exp
(
-
llr
[
i
][
0
][
row
]));
// bitValue=1
// bitValue=1
pm2
[
i
]
+=
log
(
1
+
exp
(
llr
[
row
][
0
][
i
]));
pm2
[
i
]
+=
log
(
1
+
exp
(
llr
[
i
][
0
][
row
]));
}
}
}
}
}
}
inline
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
col
,
uint8_t
listSize
,
inline
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
col
,
uint8_t
listSize
,
uint16_t
offset
,
uint8_t
approximation
)
__attribute__
((
always_inline
))
{
uint16_t
offset
,
uint8_t
approximation
)
__attribute__
((
always_inline
));
inline
void
computeLLR
(
double
***
llr
,
uint16_t
row
,
uint16_t
col
,
uint8_t
listSize
,
uint16_t
offset
,
uint8_t
approximation
)
{
double
*
a
=
llr
[
row
][
col
+
1
]
;
double
a
;
double
*
b
=
llr
[
row
+
offset
][
col
+
1
]
;
double
b
;
double
absA
,
absB
;
double
absA
,
absB
;
...
@@ -164,14 +166,19 @@ inline void computeLLR(double ***llr, uint16_t row, uint16_t col, uint8_t listSi
...
@@ -164,14 +166,19 @@ inline void computeLLR(double ***llr, uint16_t row, uint16_t col, uint8_t listSi
printf
(
"computeLLR (%d,%d,%d,%d)
\n
"
,
row
,
col
,
offset
,
i
);
printf
(
"computeLLR (%d,%d,%d,%d)
\n
"
,
row
,
col
,
offset
,
i
);
#endif
#endif
if
(
approximation
)
{
//eq. (9)
if
(
approximation
)
{
//eq. (9)
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
{
absA
=
fabs
(
a
[
i
]);
a
=
llr
[
i
][
col
+
1
][
row
];
absB
=
fabs
(
b
[
i
]);
b
=
llr
[
i
][
col
+
1
][
row
+
offset
];
llr
[
row
][
col
][
i
]
=
copysign
(
1
.
0
,
a
[
i
])
*
copysign
(
1
.
0
,
b
[
i
])
*
fmin
(
absA
,
absB
);
absA
=
fabs
(
a
);
absB
=
fabs
(
b
);
llr
[
i
][
col
][
row
]
=
copysign
(
1
.
0
,
a
)
*
copysign
(
1
.
0
,
b
)
*
fmin
(
absA
,
absB
);
}
}
}
else
{
//eq. (8a)
}
else
{
//eq. (8a)
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
for
(
int
i
=
0
;
i
<
listSize
;
i
++
)
{
llr
[
row
][
col
][
i
]
=
log
((
exp
(
a
[
i
]
+
b
[
i
])
+
1
)
/
(
exp
(
a
[
i
])
+
exp
(
b
[
i
])));
a
=
llr
[
i
][
col
+
1
][
row
];
b
=
llr
[
i
][
col
+
1
][
row
+
offset
];
llr
[
i
][
col
][
row
]
=
log
((
exp
(
a
+
b
)
+
1
)
/
(
exp
(
a
)
+
exp
(
b
)));
}
}
}
}
}
...
...
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