Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG UE
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
OpenXG
OpenXG UE
Commits
571239f6
Commit
571239f6
authored
Feb 18, 2022
by
Laurent THOMAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code review comments (incl. actual bugs)
parent
a17007bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
99 deletions
+67
-99
openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
+67
-99
No files found.
openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c
View file @
571239f6
...
...
@@ -45,14 +45,15 @@
//#include "PHY_INTERFACE/defs.h"
#define PBCH_A 24
#define PBCH_MAX_RE_PER_SYMBOL (20*12)
#define PBCH_MAX_RE (PBCH_MAX_RE_PER_SYMBOL*4)
#define print_shorts(s,x) printf("%s : %d,%d,%d,%d,%d,%d,%d,%d\n",s,((int16_t*)x)[0],((int16_t*)x)[1],((int16_t*)x)[2],((int16_t*)x)[3],((int16_t*)x)[4],((int16_t*)x)[5],((int16_t*)x)[6],((int16_t*)x)[7])
static
uint16_t
nr_pbch_extract
(
int
**
rxdataF
,
const
int
estimateSz
,
struct
complex16
dl_ch_estimates
[][
estimateSz
],
struct
complex16
rxdataF_ext
[][
20
*
12
*
4
],
struct
complex16
dl_ch_estimates_ext
[][
20
*
12
*
4
],
struct
complex16
rxdataF_ext
[][
PBCH_MAX_RE_PER_SYMBOL
],
struct
complex16
dl_ch_estimates_ext
[][
PBCH_MAX_RE_PER_SYMBOL
],
uint32_t
symbol
,
uint32_t
s_offset
,
NR_DL_FRAME_PARMS
*
frame_parms
)
{
...
...
@@ -90,12 +91,11 @@ static uint16_t nr_pbch_extract(int **rxdataF,
(
i
!=
(
nushiftmod4
+
8
)))
{
rxF_ext
[
j
]
=
rxF
[
rx_offset
];
#ifdef DEBUG_PBCH
printf
(
"rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)
\n
"
,
(
9
*
rb
)
+
j
,
((
int16_t
*
)
&
rxF_ext
[
j
])[
0
]
,
((
int16_t
*
)
&
rxF_ext
[
j
])[
1
]
,
printf
(
"rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)
\n
"
,
(
9
*
rb
)
+
j
,
rxF_ext
[
j
].
r
,
rxF_ext
[
j
].
i
,
rx_offset
,
((
int16_t
*
)
&
rxF
[
rx_offset
])[
0
],
((
int16_t
*
)
&
rxF
[
rx_offset
])[
1
]);
rxF
[
rx_offset
].
r
,
rxF
[
rx_offset
].
j
;
#endif
j
++
;
}
...
...
@@ -114,11 +114,9 @@ static uint16_t nr_pbch_extract(int **rxdataF,
rxF_ext
[
j
]
=
rxF
[
rx_offset
];
#ifdef DEBUG_PBCH
printf
(
"rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)
\n
"
,(
rb
<
4
)
?
(
9
*
rb
)
+
j
:
(
9
*
(
rb
-
12
))
+
j
,
((
int16_t
*
)
&
rxF_ext
[
j
])[
0
],
((
int16_t
*
)
&
rxF_ext
[
j
])[
1
],
rxF_ext
[
j
].
r
,
rxF_ext
[
j
].
i
,
rx_offset
,
((
int16_t
*
)
&
rxF
[
rx_offset
])[
0
],
((
int16_t
*
)
&
rxF
[
rx_offset
])[
1
]);
rxF
[
rx_offset
].
r
,
rxF
[
rx_offset
].
j
;
#endif
j
++
;
}
...
...
@@ -137,7 +135,7 @@ static uint16_t nr_pbch_extract(int **rxdataF,
struct
complex16
*
dl_ch0
=
&
dl_ch_estimates
[
aarx
][((
symbol
+
s_offset
)
*
(
frame_parms
->
ofdm_symbol_size
))];
//printf("dl_ch0 addr %p\n",dl_ch0);
struct
complex16
*
dl_ch0_ext
=
&
dl_ch_estimates_ext
[
aarx
][
symbol
*
20
*
12
];
struct
complex16
*
dl_ch0_ext
=
dl_ch_estimates_ext
[
aarx
];
for
(
rb
=
0
;
rb
<
20
;
rb
++
)
{
j
=
0
;
...
...
@@ -149,15 +147,11 @@ static uint16_t nr_pbch_extract(int **rxdataF,
(
i
!=
(
nushiftmod4
+
8
)))
{
dl_ch0_ext
[
j
]
=
dl_ch0
[
i
];
#ifdef DEBUG_PBCH
if
((
rb
==
0
)
&&
(
i
<
2
))
printf
(
"dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)
\n
"
,
j
,
((
int16_t
*
)
&
dl_ch0_ext
[
j
])[
0
],
((
int16_t
*
)
&
dl_ch0_ext
[
j
])[
1
],
dl_ch0_ext
[
j
].
r
,
dl_ch0_ext
[
j
].
i
,
i
,
((
int16_t
*
)
&
dl_ch0
[
i
])[
0
],
((
int16_t
*
)
&
dl_ch0
[
i
])[
1
]);
dl_ch0
[
j
].
r
,
dl_ch0
[
j
].
i
,
#endif
j
++
;
}
...
...
@@ -174,11 +168,9 @@ static uint16_t nr_pbch_extract(int **rxdataF,
dl_ch0_ext
[
j
]
=
dl_ch0
[
i
];
#ifdef DEBUG_PBCH
printf
(
"dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)
\n
"
,
j
,
((
int16_t
*
)
&
dl_ch0_ext
[
j
])[
0
],
((
int16_t
*
)
&
dl_ch0_ext
[
j
])[
1
],
dl_ch0_ext
[
j
].
r
,
dl_ch0_ext
[
j
].
i
,
i
,
((
int16_t
*
)
&
dl_ch0
[
i
])[
0
],
((
int16_t
*
)
&
dl_ch0
[
i
])[
1
]);
dl_ch0
[
j
].
r
,
dl_ch0
[
j
].
i
,
#endif
j
++
;
}
...
...
@@ -198,11 +190,10 @@ static uint16_t nr_pbch_extract(int **rxdataF,
//__m128i avg128;
//compute average channel_level on each (TX,RX) antenna pair
int
nr_pbch_channel_level
(
struct
complex16
dl_ch_estimates_ext
[][
20
*
12
*
4
],
int
nr_pbch_channel_level
(
struct
complex16
dl_ch_estimates_ext
[][
PBCH_MAX_RE_PER_SYMBOL
],
NR_DL_FRAME_PARMS
*
frame_parms
,
uint32_t
symbol
)
{
int16_t
rb
,
nb_rb
=
20
;
uint8_t
aarx
;
int
nb_re
)
{
int16_t
nb_rb
=
nb_re
/
12
;
#if defined(__x86_64__) || defined(__i386__)
__m128i
avg128
;
__m128i
*
dl_ch128
;
...
...
@@ -212,22 +203,23 @@ int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4],
#endif
int
avg1
=
0
,
avg2
=
0
;
for
(
aarx
=
0
;
aarx
<
frame_parms
->
nb_antennas_rx
;
aarx
++
)
{
for
(
int
aarx
=
0
;
aarx
<
frame_parms
->
nb_antennas_rx
;
aarx
++
)
{
//clear average level
#if defined(__x86_64__) || defined(__i386__)
avg128
=
_mm_setzero_si128
();
dl_ch128
=
(
__m128i
*
)
&
dl_ch_estimates_ext
[
aarx
][
symbol
*
20
*
12
];
dl_ch128
=
(
__m128i
*
)
dl_ch_estimates_ext
[
aarx
];
#elif defined(__arm__)
avg128
=
vdupq_n_s32
(
0
);
dl_ch128
=
(
int16x8_t
*
)
&
dl_ch_estimates_ext
[
aarx
][
symbol
*
20
*
12
];
dl_ch128
=
(
int16x8_t
*
)
dl_ch_estimates_ext
[
aarx
];
#endif
for
(
rb
=
0
;
rb
<
nb_rb
;
rb
++
)
{
for
(
int
rb
=
0
;
rb
<
nb_rb
;
rb
++
)
{
#if defined(__x86_64__) || defined(__i386__)
avg128
=
_mm_add_epi32
(
avg128
,
_mm_madd_epi16
(
dl_ch128
[
0
],
dl_ch128
[
0
]));
avg128
=
_mm_add_epi32
(
avg128
,
_mm_madd_epi16
(
dl_ch128
[
1
],
dl_ch128
[
1
]));
avg128
=
_mm_add_epi32
(
avg128
,
_mm_madd_epi16
(
dl_ch128
[
2
],
dl_ch128
[
2
]));
#elif defined(__arm__)
abort
();
// to be filled in
#endif
dl_ch128
+=
3
;
...
...
@@ -250,37 +242,21 @@ int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][20*12*4],
//LOG_I(PHY,"Channel level : %d, %d\n",avg1, avg2);
}
#if defined(__x86_64__) || defined(__i386__)
_mm_empty
();
_m_empty
();
#endif
return
(
avg2
);
}
static
void
nr_pbch_channel_compensation
(
struct
complex16
rxdataF_ext
[][
20
*
12
*
4
],
struct
complex16
dl_ch_estimates_ext
[][
20
*
12
*
4
],
int
cols
,
struct
complex16
rxdataF_comp
[][
cols
],
static
void
nr_pbch_channel_compensation
(
struct
complex16
rxdataF_ext
[][
PBCH_MAX_RE_PER_SYMBOL
],
struct
complex16
dl_ch_estimates_ext
[][
PBCH_MAX_RE_PER_SYMBOL
],
int
nb_re
,
struct
complex16
rxdataF_comp
[][
PBCH_MAX_RE_PER_SYMBOL
],
NR_DL_FRAME_PARMS
*
frame_parms
,
uint32_t
symbol
,
uint8_t
output_shift
)
{
AssertFatal
((
symbol
>
0
&&
symbol
<
4
),
"symbol %d is illegal for PBCH DM-RS
\n
"
,
symbol
);
// printf("comp: symbol %d : nb_re %d\n",symbol,nb_re);
for
(
int
aarx
=
0
;
aarx
<
frame_parms
->
nb_antennas_rx
;
aarx
++
)
{
vect128
*
dl_ch128
=
(
vect128
*
)
&
dl_ch_estimates_ext
[
aarx
][
symbol
*
20
*
12
];
vect128
*
dl_ch128
=
(
vect128
*
)
dl_ch_estimates_ext
[
aarx
];
vect128
*
rxdataF128
=
(
vect128
*
)
rxdataF_ext
[
aarx
];
vect128
*
rxdataF_comp128
=
(
vect128
*
)
rxdataF_comp
[
aarx
];
/*
printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[aarx][symbol*20*12]);
printf("rxdataf ext addr %p symbol %d\n", rxdataF_ext[aarx], symbol);
printf("rxdataf_comp addr %p\n",&rxdataF_comp[aarx][symbol*20*12]);
*/
for
(
int
re
=
0
;
re
<
cols
;
re
+=
12
)
{
for
(
int
re
=
0
;
re
<
nb_re
;
re
+=
12
)
{
*
rxdataF_comp128
++
=
mulByConjugate128
(
rxdataF128
++
,
dl_ch128
++
,
output_shift
);
*
rxdataF_comp128
++
=
mulByConjugate128
(
rxdataF128
++
,
dl_ch128
++
,
output_shift
);
*
rxdataF_comp128
++
=
mulByConjugate128
(
rxdataF128
++
,
dl_ch128
++
,
output_shift
);
...
...
@@ -453,10 +429,8 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
for
(
symbol
=
1
;
symbol
<
4
;
symbol
++
)
{
const
uint16_t
nb_re
=
symbol
==
2
?
72
:
180
;
struct
complex16
rxdataF_ext
[
frame_parms
->
nb_antennas_rx
][
20
*
12
*
4
];
struct
complex16
rxdataF_comp
[
frame_parms
->
nb_antennas_rx
][
nb_re
];
//was dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
struct
complex16
dl_ch_estimates_ext
[
frame_parms
->
nb_antennas_rx
][
20
*
12
*
4
];
struct
complex16
rxdataF_ext
[
frame_parms
->
nb_antennas_rx
][
PBCH_MAX_RE_PER_SYMBOL
];
struct
complex16
dl_ch_estimates_ext
[
frame_parms
->
nb_antennas_rx
][
PBCH_MAX_RE_PER_SYMBOL
];
memset
(
dl_ch_estimates_ext
,
0
,
sizeof
dl_ch_estimates_ext
);
nr_pbch_extract
(
nr_ue_common_vars
->
common_vars_rx_data_per_thread
[
proc
->
thread_id
].
rxdataF
,
estimateSz
,
...
...
@@ -474,19 +448,19 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
if
(
symbol
==
1
)
{
max_h
=
nr_pbch_channel_level
(
dl_ch_estimates_ext
,
frame_parms
,
symbol
);
nb_re
);
log2_maxh
=
3
+
(
log2_approx
(
max_h
)
/
2
);
}
#ifdef DEBUG_PBCH
LOG_I
(
PHY
,
"[PHY] PBCH log2_maxh = %d (%d)
\n
"
,
nr_ue_pbch_vars
->
log2_maxh
,
max_h
);
#endif
struct
complex16
rxdataF_comp
[
frame_parms
->
nb_antennas_rx
][
PBCH_MAX_RE_PER_SYMBOL
];
nr_pbch_channel_compensation
(
rxdataF_ext
,
dl_ch_estimates_ext
,
nb_re
,
rxdataF_comp
,
frame_parms
,
symbol
,
log2_maxh
);
// log2_maxh+I0_shift
/*if (frame_parms->nb_antennas_rx > 1)
...
...
@@ -502,19 +476,12 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
return(-1);
}
*/
i
f
(
symbol
==
2
)
{
i
nt
nb
=
symbol
==
2
?
144
:
360
;
nr_pbch_quantize
(
pbch_e_rx
+
pbch_e_rx_idx
,
(
short
*
)
rxdataF_comp
[
0
],
144
);
memcpy
(
pbch_unClipped
+
pbch_e_rx_idx
,
rxdataF_comp
[
0
],
144
*
sizeof
(
int16_t
));
pbch_e_rx_idx
+=
144
;
}
else
{
nr_pbch_quantize
(
pbch_e_rx
+
pbch_e_rx_idx
,
(
short
*
)
rxdataF_comp
[
0
],
360
);
memcpy
(
pbch_unClipped
+
pbch_e_rx_idx
,
rxdataF_comp
[
0
],
144
*
sizeof
(
int16_t
));
pbch_e_rx_idx
+=
360
;
}
nb
);
memcpy
(
pbch_unClipped
+
pbch_e_rx_idx
,
rxdataF_comp
[
0
],
nb
*
sizeof
(
int16_t
));
pbch_e_rx_idx
+=
nb
;
}
// legacy code use int16, but it is complex16
...
...
@@ -522,14 +489,10 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
UEscopeCopy
(
ue
,
pbchLlr
,
pbch_e_rx
,
sizeof
(
int16_t
),
frame_parms
->
nb_antennas_rx
,
pbch_e_rx_idx
);
#ifdef DEBUG_PBCH
write_output
(
"rxdataF_comp.m"
,
"rxFcomp"
,
rxdataF_comp
[
0
],
240
*
3
,
1
,
1
);
#endif
//demod_pbch_e = nr_ue_pbch_vars->demod_pbch_e;
// FT?? cppcheck fix - pbch_a = nr_ue_pbch_vars->pbch_a;
#ifdef DEBUG_PBCH
short
*
p
=
(
short
*
)
rxdataF_comp
[
0
]);
for
(
int
cnt
=
0
;
cnt
<
864
;
cnt
++
)
printf
(
"pbch rx llr %d
\n
"
,
*
(
pbch_e_rx
+
cnt
));
printf
(
"pbch rx llr %d
\n
"
,
*
(
pbch_e_rx
+
cnt
));
#endif
//un-scrambling
...
...
@@ -538,27 +501,32 @@ printf("pbch rx llr %d\n",*(pbch_e_rx+cnt));
uint32_t
unscrambling_mask
=
(
Lmax
==
64
)
?
0x100006D
:
0x1000041
;
uint32_t
pbch_a_interleaved
=
0
;
uint32_t
pbch_a_prime
=
0
;
nr_pbch_unscrambling
(
nr_ue_pbch_vars
,
pbch_e_rx
,
frame_parms
->
Nid_cell
,
nushift
,
M
,
NR_POLAR_PBCH_E
,
0
,
0
,
pbch_a_prime
,
&
pbch_a_interleaved
);
nr_pbch_unscrambling
(
nr_ue_pbch_vars
,
pbch_e_rx
,
frame_parms
->
Nid_cell
,
nushift
,
M
,
NR_POLAR_PBCH_E
,
0
,
0
,
pbch_a_prime
,
&
pbch_a_interleaved
);
//polar decoding de-rate matching
const
t_nrPolar_params
*
currentPtr
=
nr_polar_params
(
NR_POLAR_PBCH_MESSAGE_TYPE
,
NR_POLAR_PBCH_PAYLOAD_BITS
,
NR_POLAR_PBCH_AGGREGATION_LEVEL
,
1
,
&
ue
->
polarList
);
uint64_t
tmp
=
pbch_a_prime
;
decoderState
=
polar_decoder_int16
(
pbch_e_rx
,
&
tmp
,
0
,
currentPtr
);
pbch_a_prime
=
tmp
;
const
t_nrPolar_params
*
currentPtr
=
nr_polar_params
(
NR_POLAR_PBCH_MESSAGE_TYPE
,
NR_POLAR_PBCH_PAYLOAD_BITS
,
NR_POLAR_PBCH_AGGREGATION_LEVEL
,
1
,
&
ue
->
polarList
);
uint64_t
tmp
=
pbch_a_prime
;
decoderState
=
polar_decoder_int16
(
pbch_e_rx
,
&
tmp
,
0
,
currentPtr
);
pbch_a_prime
=
tmp
;
if
(
decoderState
)
return
(
decoderState
);
if
(
decoderState
)
return
(
decoderState
);
// printf("polar decoder output 0x%08x\n",pbch_a_prime);
// Decoder reversal
uint32_t
a_reversed
=
0
;
for
(
int
i
=
0
;
i
<
NR_POLAR_PBCH_PAYLOAD_BITS
;
i
++
)
a_reversed
|=
(((
uint64_t
)
pbch_a_prime
>>
i
)
&
1
)
<<
(
31
-
i
);
a_reversed
|=
(((
uint64_t
)
pbch_a_prime
>>
i
)
&
1
)
<<
(
31
-
i
);
pbch_a_prime
=
a_reversed
;
//payload un-scrambling
M
=
(
Lmax
==
64
)
?
(
NR_POLAR_PBCH_PAYLOAD_BITS
-
6
)
:
(
NR_POLAR_PBCH_PAYLOAD_BITS
-
3
);
nushift
=
((
pbch_a_prime
>>
24
)
&
1
)
^
(((
pbch_a_prime
>>
6
)
&
1
)
<<
1
);
nr_pbch_unscrambling
(
nr_ue_pbch_vars
,
pbch_e_rx
,
frame_parms
->
Nid_cell
,
nushift
,
M
,
NR_POLAR_PBCH_PAYLOAD_BITS
,
1
,
unscrambling_mask
,
pbch_a_prime
,
&
pbch_a_interleaved
);
pbch_a_interleaved
=
0
;
nr_pbch_unscrambling
(
nr_ue_pbch_vars
,
pbch_e_rx
,
frame_parms
->
Nid_cell
,
nushift
,
M
,
NR_POLAR_PBCH_PAYLOAD_BITS
,
1
,
unscrambling_mask
,
pbch_a_prime
,
&
pbch_a_interleaved
);
//printf("nushift %d sfn 3rd %d 2nd %d", nushift,((pbch_a_prime>>6)&1), ((pbch_a_prime>>24)&1) );
//payload deinterleaving
//uint32_t in=0;
...
...
@@ -575,10 +543,10 @@ a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i);
result
->
xtra_byte
=
(
out
>>
24
)
&
0xff
;
for
(
int
i
=
0
;
i
<
NR_POLAR_PBCH_PAYLOAD_BITS
;
i
++
)
payload
|=
((
out
>>
i
)
&
1
)
<<
(
NR_POLAR_PBCH_PAYLOAD_BITS
-
i
-
1
);
payload
|=
((
out
>>
i
)
&
1
)
<<
(
NR_POLAR_PBCH_PAYLOAD_BITS
-
i
-
1
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
result
->
decoded_output
[
i
]
=
(
uint8_t
)((
payload
>>
((
3
-
i
)
<<
3
))
&
0xff
);
result
->
decoded_output
[
i
]
=
(
uint8_t
)((
payload
>>
((
3
-
i
)
<<
3
))
&
0xff
);
frame_parms
->
half_frame_bit
=
(
result
->
xtra_byte
>>
4
)
&
0x01
;
// computing the half frame index from the extra byte
frame_parms
->
ssb_index
=
i_ssb
;
// ssb index corresponds to i_ssb for Lmax = 4,8
...
...
@@ -596,7 +564,7 @@ result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
uint8_t
frame_number_4lsb
=
0
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
frame_number_4lsb
|=
((
result
->
xtra_byte
>>
i
)
&
1
)
<<
(
3
-
i
);
frame_number_4lsb
|=
((
result
->
xtra_byte
>>
i
)
&
1
)
<<
(
3
-
i
);
proc
->
decoded_frame_rx
=
frame_number_4lsb
;
#ifdef DEBUG_PBCH
...
...
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