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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
OpenXG
OpenXG-RAN
Commits
9aba6d72
Commit
9aba6d72
authored
Feb 21, 2022
by
Laurent THOMAS
Committed by
Robert Schmidt
Feb 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs in polar encode, when len+crc_len>64
parent
e8278de1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
50 deletions
+54
-50
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
+26
-23
openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c
openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c
+1
-1
openair1/SIMULATION/NR_PHY/pucchsim.c
openair1/SIMULATION/NR_PHY/pucchsim.c
+27
-26
No files found.
openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c
View file @
9aba6d72
...
...
@@ -422,7 +422,6 @@ void polar_encoder_fast(uint64_t *A,
// AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K);
AssertFatal
(
polarParams
->
K
<
129
,
"K = %d > 128, is not supported yet
\n
"
,
polarParams
->
K
);
AssertFatal
(
polarParams
->
payloadBits
<
65
,
"payload bits = %d > 64, is not supported yet
\n
"
,
polarParams
->
payloadBits
);
uint64_t
B
[
4
]
=
{
0
,
0
,
0
,
0
},
Cprime
[
4
]
=
{
0
,
0
,
0
,
0
};
int
bitlen
=
polarParams
->
payloadBits
;
// append crc
AssertFatal
(
bitlen
<
129
,
"support for payloads <= 128 bits
\n
"
);
...
...
@@ -451,9 +450,12 @@ void polar_encoder_fast(uint64_t *A,
A32_flip
[
1
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
2
];
A32_flip
[
2
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
1
];
A32_flip
[
3
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
0
];
if
(
polarParams
->
crcParityBits
==
24
)
tcrc
=
(
uint64_t
)(((
crcmask
^
(
crc24c
(
A32_flip
,
8
*
offset
+
bitlen
)
>>
8
)))
&
0xffffff
);
else
if
(
polarParams
->
crcParityBits
==
11
)
tcrc
=
(
uint64_t
)(((
crcmask
^
(
crc11
(
A32_flip
,
bitlen
)
>>
21
)))
&
0x7ff
);
else
if
(
polarParams
->
crcParityBits
==
6
)
tcrc
=
(
uint64_t
)(((
crcmask
^
(
crc6
(
A32_flip
,
bitlen
)
>>
26
)))
&
0x3f
);
if
(
polarParams
->
crcParityBits
==
24
)
tcrc
=
(
uint64_t
)(((
crcmask
^
(
crc24c
(
A32_flip
,
8
*
offset
+
bitlen
)
>>
8
)))
&
0xffffff
);
else
if
(
polarParams
->
crcParityBits
==
11
)
tcrc
=
(
uint64_t
)(((
crcmask
^
(
crc11
(
A32_flip
,
bitlen
)
>>
21
)))
&
0x7ff
);
else
if
(
polarParams
->
crcParityBits
==
6
)
tcrc
=
(
uint64_t
)(((
crcmask
^
(
crc6
(
A32_flip
,
bitlen
)
>>
26
)))
&
0x3f
);
}
else
if
(
bitlen
<=
64
)
{
uint8_t
A64_flip
[
8
+
offset
];
if
(
ones_flag
)
{
...
...
@@ -470,8 +472,10 @@ void polar_encoder_fast(uint64_t *A,
A64_flip
[
5
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
2
];
A64_flip
[
6
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
1
];
A64_flip
[
7
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
0
];
if
(
polarParams
->
crcParityBits
==
24
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc24c
(
A64_flip
,
8
*
offset
+
bitlen
)
>>
8
)))
&
0xffffff
;
else
if
(
polarParams
->
crcParityBits
==
11
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc11
(
A64_flip
,
bitlen
)
>>
21
)))
&
0x7ff
;
if
(
polarParams
->
crcParityBits
==
24
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc24c
(
A64_flip
,
8
*
offset
+
bitlen
)
>>
8
)))
&
0xffffff
;
else
if
(
polarParams
->
crcParityBits
==
11
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc11
(
A64_flip
,
bitlen
)
>>
21
)))
&
0x7ff
;
}
else
if
(
bitlen
<=
128
)
{
uint8_t
A128_flip
[
16
+
offset
];
...
...
@@ -481,38 +485,37 @@ void polar_encoder_fast(uint64_t *A,
A128_flip
[
2
]
=
0xff
;
}
uint128_t
Aprime
=
(
uint128_t
)(((
uint128_t
)
*
A
)
<<
(
128
-
bitlen
));
A128_flip
[
0
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
15
];
A128_flip
[
1
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
14
];
A128_flip
[
2
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
13
];
A128_flip
[
3
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
12
];
A128_flip
[
4
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
11
];
A128_flip
[
5
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
10
];
A128_flip
[
6
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
9
];
A128_flip
[
7
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
8
];
A128_flip
[
8
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
7
];
A128_flip
[
9
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
6
];
A128_flip
[
10
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
5
];
A128_flip
[
11
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
4
];
A128_flip
[
12
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
3
];
A128_flip
[
13
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
2
];
A128_flip
[
14
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
1
];
A128_flip
[
15
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
0
];
if
(
polarParams
->
crcParityBits
==
24
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc24c
(
A128_flip
,
8
*
offset
+
bitlen
)
>>
8
)))
&
0xffffff
;
else
if
(
polarParams
->
crcParityBits
==
11
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc11
(
A128_flip
,
bitlen
)
>>
21
)))
&
0x7ff
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
A128_flip
[
i
+
offset
]
=
((
uint8_t
*
)
&
Aprime
)[
15
-
i
];
if
(
polarParams
->
crcParityBits
==
24
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc24c
(
A128_flip
,
8
*
offset
+
bitlen
)
>>
8
)))
&
0xffffff
;
else
if
(
polarParams
->
crcParityBits
==
11
)
tcrc
=
(
uint64_t
)((
crcmask
^
(
crc11
(
A128_flip
,
bitlen
)
>>
21
)))
&
0x7ff
;
}
int
n
;
// this is number of quadwords in the bit string
int
quadwlen
=
(
polarParams
->
K
>>
6
);
if
((
polarParams
->
K
&
63
)
>
0
)
quadwlen
++
;
int
quadwlen
=
(
polarParams
->
K
+
63
)
/
64
;
// Create the B bit string as
// 0, 0, ..., 0, a'_0, a'_1, ..., a'_A-1, p_0, p_1, ..., p_{N_parity-1}
//??? b_{N'-1} b_{N'-2} ... b_{N'-A} b_{N'-A-1} ... b_{N'-A-Nparity} = a_{N-1} a_{N-2} ... a_{N-A} p_{N_parity-1} ... p_0
for
(
n
=
0
;
n
<
quadwlen
;
n
++
)
if
(
n
==
0
)
B
[
n
]
=
(
A
[
n
]
<<
polarParams
->
crcParityBits
)
|
tcrc
;
else
B
[
n
]
=
(
A
[
n
]
<<
polarParams
->
crcParityBits
)
|
(
A
[
n
-
1
]
>>
(
64
-
polarParams
->
crcParityBits
));
uint64_t
B
[
4
]
=
{
0
};
B
[
0
]
=
(
A
[
0
]
<<
polarParams
->
crcParityBits
)
|
tcrc
;
for
(
n
=
1
;
n
<
quadwlen
;
n
++
)
if
((
bitlen
+
63
)
/
64
>
n
)
B
[
n
]
=
(
A
[
n
]
<<
polarParams
->
crcParityBits
)
|
(
A
[
n
-
1
]
>>
(
64
-
polarParams
->
crcParityBits
));
else
B
[
n
]
=
(
A
[
n
-
1
]
>>
(
64
-
polarParams
->
crcParityBits
));
uint8_t
*
Bbyte
=
(
uint8_t
*
)
B
;
// for each byte of B, lookup in corresponding table for 64-bit word corresponding to that byte and its position
uint64_t
Cprime
[
4
]
=
{
0
};
if
(
polarParams
->
K
<
65
)
Cprime
[
0
]
=
polarParams
->
cprime_tab0
[
0
][
Bbyte
[
0
]]
|
polarParams
->
cprime_tab0
[
1
][
Bbyte
[
1
]]
|
polarParams
->
cprime_tab0
[
1
][
Bbyte
[
1
]]
|
polarParams
->
cprime_tab0
[
2
][
Bbyte
[
2
]]
|
polarParams
->
cprime_tab0
[
3
][
Bbyte
[
3
]]
|
polarParams
->
cprime_tab0
[
4
][
Bbyte
[
4
]]
|
...
...
openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c
View file @
9aba6d72
...
...
@@ -850,7 +850,7 @@ static inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_
printf
(
"
\t\t
[nr_pucch2_3_4_scrambling] scrambling M_bit=%d bits
\n
"
,
M_bit
);
#endif
}
void
nr_uci_encoding
(
uint64_t
payload
,
static
void
nr_uci_encoding
(
uint64_t
payload
,
uint8_t
nr_bit
,
int
fmt
,
uint8_t
is_pi_over_2_bpsk_enabled
,
...
...
openair1/SIMULATION/NR_PHY/pucchsim.c
View file @
9aba6d72
...
...
@@ -552,19 +552,17 @@ int main(int argc, char **argv)
if
(
n_trials
==
1
)
printf
(
"txlev %d (%f dB), offset %d, sigma2 %f ( %f dB)
\n
"
,
txlev
,
10
*
log10
(
txlev
),
startingSymbolIndex
*
frame_parms
->
ofdm_symbol_size
,
sigma2
,
sigma2_dB
);
int
i0
;
double
txr
,
txi
,
rxr
,
rxi
,
nr
,
ni
;
int
**
rxdataF
=
gNB
->
common_vars
.
rxdataF
;
struct
complex16
**
rxdataF
=
(
struct
complex16
**
)
gNB
->
common_vars
.
rxdataF
;
for
(
int
symb
=
0
;
symb
<
gNB
->
frame_parms
.
symbols_per_slot
;
symb
++
)
{
if
(
symb
<
startingSymbolIndex
||
symb
>=
startingSymbolIndex
+
nrofSymbols
)
{
i0
=
symb
*
gNB
->
frame_parms
.
ofdm_symbol_size
;
i
nt
i
0
=
symb
*
gNB
->
frame_parms
.
ofdm_symbol_size
;
for
(
int
re
=
0
;
re
<
N_RB_DL
*
12
;
re
++
)
{
i
=
i0
+
((
gNB
->
frame_parms
.
first_carrier_offset
+
re
)
%
gNB
->
frame_parms
.
ofdm_symbol_size
);
for
(
int
aarx
=
0
;
aarx
<
n_rx
;
aarx
++
)
{
nr
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
ni
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
((
int16_t
*
)
rxdataF
[
aarx
])[
i
<<
1
]
=
(
int16_t
)(
100
.
0
*
(
nr
)
/
sqrt
((
double
)
txlev
));
((
int16_t
*
)
rxdataF
[
aarx
])[
1
+
(
i
<<
1
)]
=
(
int16_t
)(
100
.
0
*
(
ni
)
/
sqrt
((
double
)
txlev
));
double
nr
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
double
ni
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
rxdataF
[
aarx
][
i
].
r
=
(
int16_t
)(
100
.
0
*
(
nr
)
/
sqrt
((
double
)
txlev
));
rxdataF
[
aarx
][
i
].
i
=
(
int16_t
)(
100
.
0
*
(
ni
)
/
sqrt
((
double
)
txlev
));
}
}
}
...
...
@@ -572,43 +570,45 @@ int main(int argc, char **argv)
random_channel
(
UE2gNB
,
0
);
freq_channel
(
UE2gNB
,
N_RB_DL
,
2
*
N_RB_DL
+
1
,
scs
/
1000
);
struct
complexd
phasor
;
double
rxr_tmp
;
for
(
int
symb
=
0
;
symb
<
nrofSymbols
;
symb
++
)
{
i0
=
(
startingSymbolIndex
+
symb
)
*
gNB
->
frame_parms
.
ofdm_symbol_size
;
i
nt
i
0
=
(
startingSymbolIndex
+
symb
)
*
gNB
->
frame_parms
.
ofdm_symbol_size
;
for
(
int
re
=
0
;
re
<
N_RB_DL
*
12
;
re
++
)
{
i
=
i0
+
((
gNB
->
frame_parms
.
first_carrier_offset
+
re
)
%
gNB
->
frame_parms
.
ofdm_symbol_size
);
phasor
.
r
=
cos
(
2
*
M_PI
*
phase
*
re
);
struct
complexd
phasor
;
phasor
.
r
=
cos
(
2
*
M_PI
*
phase
*
re
);
phasor
.
i
=
sin
(
2
*
M_PI
*
phase
*
re
);
for
(
int
aarx
=
0
;
aarx
<
n_rx
;
aarx
++
)
{
txr
=
(
double
)(((
int16_t
*
)
txdataF
[
0
])[(
i
<<
1
)]);
txi
=
(
double
)(((
int16_t
*
)
txdataF
[
0
])[
1
+
(
i
<<
1
)]);
rxr
=
txr
*
UE2gNB
->
chF
[
aarx
][
re
].
r
-
txi
*
UE2gNB
->
chF
[
aarx
][
re
].
i
;
rxi
=
txr
*
UE2gNB
->
chF
[
aarx
][
re
].
i
+
txi
*
UE2gNB
->
chF
[
aarx
][
re
].
r
;
rxr_tmp
=
rxr
*
phasor
.
r
-
rxi
*
phasor
.
i
;
double
txr
=
(
double
)(((
int16_t
*
)
txdataF
[
0
])[(
i
<<
1
)]);
double
txi
=
(
double
)(((
int16_t
*
)
txdataF
[
0
])[
1
+
(
i
<<
1
)]);
double
rxr
=
{
0
},
rxi
=
{
0
};
for
(
int
l
=
0
;
l
<
UE2gNB
->
channel_length
;
l
++
)
{
rxr
=
txr
*
UE2gNB
->
chF
[
aarx
][
l
].
r
-
txi
*
UE2gNB
->
chF
[
aarx
][
l
].
i
;
rxi
=
txr
*
UE2gNB
->
chF
[
aarx
][
l
].
i
+
txi
*
UE2gNB
->
chF
[
aarx
][
l
].
r
;
}
double
rxr_tmp
=
rxr
*
phasor
.
r
-
rxi
*
phasor
.
i
;
rxi
=
rxr
*
phasor
.
i
+
rxi
*
phasor
.
r
;
rxr
=
rxr_tmp
;
nr
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
ni
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
((
int16_t
*
)
rxdataF
[
aarx
])[
i
<<
1
]
=
(
int16_t
)(
100
.
0
*
(
rxr
+
nr
)
/
sqrt
((
double
)
txlev
));
((
int16_t
*
)
rxdataF
[
aarx
])[
1
+
(
i
<<
1
)]
=
(
int16_t
)(
100
.
0
*
(
rxi
+
ni
)
/
sqrt
((
double
)
txlev
));
double
nr
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
double
ni
=
sqrt
(
sigma2
/
2
)
*
gaussdouble
(
0
.
0
,
1
.
0
);
rxdataF
[
aarx
][
i
].
r
=
(
int16_t
)(
100
.
0
*
(
rxr
+
nr
)
/
sqrt
((
double
)
txlev
));
rxdataF
[
aarx
][
i
].
i
=
(
int16_t
)(
100
.
0
*
(
rxi
+
ni
)
/
sqrt
((
double
)
txlev
));
if
(
n_trials
==
1
&&
abs
(
txr
)
>
0
)
printf
(
"symb %d, re %d , aarx %d : txr %f, txi %f, chr %f, chi %f, nr %f, ni %f, rxr %f, rxi %f => %d,%d
\n
"
,
symb
,
re
,
aarx
,
txr
,
txi
,
UE2gNB
->
chF
[
aarx
][
re
].
r
,
UE2gNB
->
chF
[
aarx
][
re
].
i
,
nr
,
ni
,
rxr
,
rxi
,
((
int16_t
*
)
rxdataF
[
aarx
])[
i
<<
1
],((
int16_t
*
)
rxdataF
[
aarx
])[
1
+
(
i
<<
1
)]
);
rxdataF
[
aarx
][
i
].
r
,
rxdataF
[
aarx
][
i
].
i
);
}
}
}
int
rxlev
=
0
;
for
(
int
aarx
=
0
;
aarx
<
n_rx
;
aarx
++
)
rxlev
+=
signal_energy
(
&
rxdataF
[
aarx
][
startingSymbolIndex
*
frame_parms
->
ofdm_symbol_size
],
for
(
int
aarx
=
0
;
aarx
<
n_rx
;
aarx
++
)
rxlev
+=
signal_energy
(
(
int32_t
*
)
&
rxdataF
[
aarx
][
startingSymbolIndex
*
frame_parms
->
ofdm_symbol_size
],
frame_parms
->
ofdm_symbol_size
);
int
rxlev_pucch
=
0
;
for
(
int
aarx
=
0
;
aarx
<
n_rx
;
aarx
++
)
rxlev_pucch
+=
signal_energy
(
&
rxdataF
[
aarx
][
startingSymbolIndex
*
frame_parms
->
ofdm_symbol_size
],
for
(
int
aarx
=
0
;
aarx
<
n_rx
;
aarx
++
)
rxlev_pucch
+=
signal_energy
(
(
int32_t
*
)
&
rxdataF
[
aarx
][
startingSymbolIndex
*
frame_parms
->
ofdm_symbol_size
],
12
);
// set UL mask for pucch allocation
...
...
@@ -672,7 +672,7 @@ int main(int argc, char **argv)
free
(
uci_pdu
.
harq
);
}
else
if
(
format
==
1
)
{
nr_decode_pucch1
(
rxdataF
,
PUCCH_GroupHopping
,
hopping_id
,
nr_decode_pucch1
(
(
int32_t
**
)
rxdataF
,
PUCCH_GroupHopping
,
hopping_id
,
&
(
payload_received
),
frame_parms
,
amp
,
nr_slot_tx
,
m0
,
nrofSymbols
,
startingSymbolIndex
,
startingPRB
,
startingPRB_intraSlotHopping
,
timeDomainOCC
,
nr_bit
);
...
...
@@ -728,7 +728,8 @@ int main(int argc, char **argv)
break
;
}
}
if
(
gNB
->
uci_polarParams
)
nr_polar_delete
(
gNB
->
uci_polarParams
);
free_channel_desc_scm
(
UE2gNB
);
term_freq_channel
();
...
...
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