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
spbro
OpenXG-RAN
Commits
01ae8fbb
Commit
01ae8fbb
authored
Aug 16, 2024
by
francescomani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prach code cleanup
parent
dc5df35f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
115 deletions
+110
-115
openair1/PHY/INIT/nr_init.c
openair1/PHY/INIT/nr_init.c
+0
-2
openair1/PHY/NR_TRANSPORT/nr_prach.c
openair1/PHY/NR_TRANSPORT/nr_prach.c
+100
-99
openair1/PHY/defs_gNB.h
openair1/PHY/defs_gNB.h
+0
-3
openair1/SIMULATION/NR_PHY/prachsim.c
openair1/SIMULATION/NR_PHY/prachsim.c
+10
-11
No files found.
openair1/PHY/INIT/nr_init.c
View file @
01ae8fbb
...
...
@@ -190,7 +190,6 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB)
common_vars
->
debugBuff_sample_offset
=
0
;
// PRACH
prach_vars
->
prachF
=
(
int16_t
*
)
malloc16_clear
(
1024
*
2
*
sizeof
(
int16_t
)
);
prach_vars
->
rxsigF
=
(
int16_t
**
)
malloc16_clear
(
Prx
*
sizeof
(
int16_t
*
));
prach_vars
->
prach_ifft
=
(
int32_t
*
)
malloc16_clear
(
1024
*
2
*
sizeof
(
int32_t
));
...
...
@@ -273,7 +272,6 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
free_and_zero
(
common_vars
->
debugBuff
);
NR_gNB_PRACH
*
prach_vars
=
&
gNB
->
prach_vars
;
free_and_zero
(
prach_vars
->
prachF
);
free_and_zero
(
prach_vars
->
rxsigF
);
free_and_zero
(
prach_vars
->
prach_ifft
);
...
...
openair1/PHY/NR_TRANSPORT/nr_prach.c
View file @
01ae8fbb
...
...
@@ -432,18 +432,14 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
uint16_t
*
max_preamble_energy
,
uint16_t
*
max_preamble_delay
)
{
AssertFatal
(
gNB
!=
NULL
,
"Can only be called from gNB
\n
"
);
int
i
;
nfapi_nr_prach_config_t
*
cfg
=&
gNB
->
gNB_config
.
prach_config
;
AssertFatal
(
gNB
!=
NULL
,
"Can only be called from gNB
\n
"
);
nfapi_nr_prach_config_t
*
cfg
=
&
gNB
->
gNB_config
.
prach_config
;
NR_DL_FRAME_PARMS
*
fp
;
uint16_t
rootSequenceIndex
;
int
numrootSequenceIndex
;
uint8_t
restricted_set
;
uint8_t
n_ra_prb
=
0xFF
;
int16_t
*
prachF
=
NULL
;
int
nb_rx
;
int16_t
**
rxsigF
=
gNB
->
prach_vars
.
rxsigF
;
...
...
@@ -460,10 +456,8 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
uint8_t
not_found
;
uint16_t
u
;
int16_t
*
Xu
=
0
;
uint16_t
offset
;
uint16_t
first_nonzero_root_idx
=
0
;
uint8_t
new_dft
=
0
;
uint8_t
aa
;
int32_t
lev
;
int16_t
levdB
;
int
log2_ifft_size
=
10
;
...
...
@@ -489,7 +483,6 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
LOG_D
(
PHY
,
"L1 PRACH RX: rooSequenceIndex %d, numRootSeqeuences %d, NCS %d, N_ZC %d, format %d
\n
"
,
rootSequenceIndex
,
numrootSequenceIndex
,
NCS
,
N_ZC
,
prach_fmt
);
prach_ifft
=
gNB
->
prach_vars
.
prach_ifft
;
prachF
=
gNB
->
prach_vars
.
prachF
;
if
(
LOG_DEBUGFLAG
(
PRACH
)){
if
((
frame
&
1023
)
<
20
)
LOG_D
(
PHY
,
"PRACH (gNB) : running rx_prach for slot %d, msg1_frequencystart %d, rootSequenceIndex %d
\n
"
,
slot
,
msg1_frequencystart
,
rootSequenceIndex
);
}
...
...
@@ -508,10 +501,10 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
preamble_offset_old
=
99
;
*
max_preamble_energy
=
0
;
*
max_preamble_delay
=
0
;
*
max_preamble
=
0
;
*
max_preamble_energy
=
0
;
*
max_preamble_delay
=
0
;
*
max_preamble
=
0
;
int16_t
prachF
[
2
*
1024
];
for
(
preamble_index
=
0
;
preamble_index
<
64
;
preamble_index
++
)
{
if
(
LOG_DEBUGFLAG
(
PRACH
)){
...
...
@@ -555,29 +548,28 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
uint16_t
n_group_ra
=
0
;
if
(
(
nr_du
[
u
]
<
(
N_ZC
/
3
))
&&
(
nr_du
[
u
]
>=
NCS
)
)
{
n_shift_ra
=
nr_du
[
u
]
/
NCS
;
d_start
=
(
nr_du
[
u
]
<<
1
)
+
(
n_shift_ra
*
NCS
);
n_group_ra
=
N_ZC
/
d_start
;
n_shift_ra_bar
=
max
(
0
,(
N_ZC
-
(
nr_du
[
u
]
<<
1
)
-
(
n_group_ra
*
d_start
))
/
N_ZC
);
}
else
if
(
(
nr_du
[
u
]
>=
(
N_ZC
/
3
))
&&
(
nr_du
[
u
]
<=
((
N_ZC
-
NCS
)
>>
1
))
)
{
n_shift_ra
=
(
N_ZC
-
(
nr_du
[
u
]
<<
1
))
/
NCS
;
d_start
=
N_ZC
-
(
nr_du
[
u
]
<<
1
)
+
(
n_shift_ra
*
NCS
);
n_group_ra
=
nr_du
[
u
]
/
d_start
;
n_shift_ra_bar
=
min
(
n_shift_ra
,
max
(
0
,(
nr_du
[
u
]
-
(
n_group_ra
*
d_start
))
/
NCS
));
if
((
nr_du
[
u
]
<
(
N_ZC
/
3
))
&&
(
nr_du
[
u
]
>=
NCS
)
)
{
n_shift_ra
=
nr_du
[
u
]
/
NCS
;
d_start
=
(
nr_du
[
u
]
<<
1
)
+
(
n_shift_ra
*
NCS
);
n_group_ra
=
N_ZC
/
d_start
;
n_shift_ra_bar
=
max
(
0
,
(
N_ZC
-
(
nr_du
[
u
]
<<
1
)
-
(
n_group_ra
*
d_start
))
/
N_ZC
);
}
else
if
((
nr_du
[
u
]
>=
(
N_ZC
/
3
))
&&
(
nr_du
[
u
]
<=
((
N_ZC
-
NCS
)
>>
1
))
)
{
n_shift_ra
=
(
N_ZC
-
(
nr_du
[
u
]
<<
1
))
/
NCS
;
d_start
=
N_ZC
-
(
nr_du
[
u
]
<<
1
)
+
(
n_shift_ra
*
NCS
);
n_group_ra
=
nr_du
[
u
]
/
d_start
;
n_shift_ra_bar
=
min
(
n_shift_ra
,
max
(
0
,
(
nr_du
[
u
]
-
(
n_group_ra
*
d_start
))
/
NCS
));
}
else
{
n_shift_ra
=
0
;
n_shift_ra_bar
=
0
;
}
// This is the number of cyclic shifts for the current root u
numshift
=
(
n_shift_ra
*
n_group_ra
)
+
n_shift_ra_bar
;
numshift
=
(
n_shift_ra
*
n_group_ra
)
+
n_shift_ra_bar
;
// skip to next root and recompute parameters if numshift==0
(
numshift
>
0
)
?
(
not_found
=
0
)
:
(
preamble_offset
++
);
}
}
if
(
n_shift_ra
>
0
)
preamble_shift
=
-
((
d_start
*
(
preamble_index0
/
n_shift_ra
))
+
((
preamble_index0
%
n_shift_ra
)
*
NCS
));
// minus because the channel is h(t -\tau + Cv)
else
...
...
@@ -595,8 +587,17 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
// Compute DFT of RX signal (conjugate input, results in conjugate output) for each new rootSequenceIndex
if
(
LOG_DEBUGFLAG
(
PRACH
))
{
int
en
=
dB_fixed
(
signal_energy
((
int32_t
*
)
&
rxsigF
[
0
][
0
],
840
));
if
(
en
>
60
)
LOG_D
(
PHY
,
"frame %d, slot %d : preamble index %d, NCS %d, N_ZC/NCS %d: offset %d, preamble shift %d , en %d)
\n
"
,
frame
,
slot
,
preamble_index
,
NCS
,
N_ZC
/
NCS
,
preamble_offset
,
preamble_shift
,
en
);
if
(
en
>
60
)
LOG_D
(
PHY
,
"frame %d, slot %d : preamble index %d, NCS %d, N_ZC/NCS %d: offset %d, preamble shift %d , en %d)
\n
"
,
frame
,
slot
,
preamble_index
,
NCS
,
N_ZC
/
NCS
,
preamble_offset
,
preamble_shift
,
en
);
}
LOG_D
(
PHY
,
"PRACH RX preamble_index %d, preamble_offset %d
\n
"
,
preamble_index
,
preamble_offset
);
...
...
@@ -605,57 +606,56 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
if
(
new_dft
==
1
)
{
new_dft
=
0
;
Xu
=
(
int16_t
*
)
gNB
->
X_u
[
preamble_offset
-
first_nonzero_root_idx
];
Xu
=
(
int16_t
*
)
gNB
->
X_u
[
preamble_offset
-
first_nonzero_root_idx
];
LOG_D
(
PHY
,
"PRACH RX new dft preamble_offset-first_nonzero_root_idx %d
\n
"
,
preamble_offset
-
first_nonzero_root_idx
);
memset
(
prach_ifft
,
0
,((
N_ZC
==
839
)
?
2048
:
256
)
*
sizeof
(
int32_t
));
memset
(
prachF
,
0
,
sizeof
(
int16_t
)
*
2
*
1024
);
memset
(
prachF
,
0
,
sizeof
(
int16_t
)
*
2
*
1024
);
if
(
LOG_DUMPFLAG
(
PRACH
))
{
LOG_M
(
"prach_rxF0.m"
,
"prach_rxF0"
,
rxsigF
[
0
],
N_ZC
,
1
,
1
);
LOG_M
(
"prach_rxF1.m"
,
"prach_rxF1"
,
rxsigF
[
1
],
6144
,
1
,
1
);
}
for
(
aa
=
0
;
aa
<
nb_rx
;
aa
++
)
{
for
(
int
aa
=
0
;
aa
<
nb_rx
;
aa
++
)
{
// Do componentwise product with Xu* on each antenna
for
(
offset
=
0
;
offset
<
(
N_ZC
<<
1
);
offset
+=
2
)
{
for
(
int
offset
=
0
;
offset
<
(
N_ZC
<<
1
);
offset
+=
2
)
{
prachF
[
offset
]
=
(
int16_t
)(((
int32_t
)
Xu
[
offset
]
*
rxsigF
[
aa
][
offset
]
+
(
int32_t
)
Xu
[
offset
+
1
]
*
rxsigF
[
aa
][
offset
+
1
])
>>
15
);
prachF
[
offset
+
1
]
=
(
int16_t
)(((
int32_t
)
Xu
[
offset
]
*
rxsigF
[
aa
][
offset
+
1
]
-
(
int32_t
)
Xu
[
offset
+
1
]
*
rxsigF
[
aa
][
offset
])
>>
15
);
}
// Now do IFFT of size 1024 (N_ZC=839) or 256 (N_ZC=139)
if
(
N_ZC
==
839
)
{
idft
(
IDFT_1024
,
prachF
,
prach_ifft_tmp
,
1
);
idft
(
IDFT_1024
,
prachF
,
prach_ifft_tmp
,
1
);
// compute energy and accumulate over receive antennas
for
(
i
=
0
;
i
<
1024
;
i
++
)
for
(
int
i
=
0
;
i
<
1024
;
i
++
)
prach_ifft
[
i
]
+=
(
int32_t
)
prach_ifft_tmp
[
i
<<
1
]
*
(
int32_t
)
prach_ifft_tmp
[
i
<<
1
]
+
(
int32_t
)
prach_ifft_tmp
[
1
+
(
i
<<
1
)]
*
(
int32_t
)
prach_ifft_tmp
[
1
+
(
i
<<
1
)];
}
else
{
idft
(
IDFT_256
,
prachF
,
prach_ifft_tmp
,
1
);
idft
(
IDFT_256
,
prachF
,
prach_ifft_tmp
,
1
);
log2_ifft_size
=
8
;
// compute energy and accumulate over receive antennas and repetitions for BR
for
(
i
=
0
;
i
<
256
;
i
++
)
for
(
int
i
=
0
;
i
<
256
;
i
++
)
prach_ifft
[
i
]
+=
(
int32_t
)
prach_ifft_tmp
[
i
<<
1
]
*
(
int32_t
)
prach_ifft_tmp
[(
i
<<
1
)]
+
(
int32_t
)
prach_ifft_tmp
[
1
+
(
i
<<
1
)]
*
(
int32_t
)
prach_ifft_tmp
[
1
+
(
i
<<
1
)];
}
if
(
LOG_DUMPFLAG
(
PRACH
))
{
if
(
aa
==
0
)
LOG_M
(
"prach_rxF_comp0.m"
,
"prach_rxF_comp0"
,
prachF
,
1024
,
1
,
1
);
if
(
aa
==
1
)
LOG_M
(
"prach_rxF_comp1.m"
,
"prach_rxF_comp1"
,
prachF
,
1024
,
1
,
1
);
if
(
aa
==
0
)
LOG_M
(
"prach_rxF_comp0.m"
,
"prach_rxF_comp0"
,
prachF
,
1024
,
1
,
1
);
if
(
aa
==
1
)
LOG_M
(
"prach_rxF_comp1.m"
,
"prach_rxF_comp1"
,
prachF
,
1024
,
1
,
1
);
}
}
// antennas_rx
}
// antennas_rx
// Normalization of energy over ifft and receive antennas
if
(
N_ZC
==
839
)
{
log2_ifft_size
=
10
;
for
(
i
=
0
;
i
<
1024
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
1024
;
i
++
)
prach_ifft
[
i
]
=
(
prach_ifft
[
i
]
>>
log2_ifft_size
)
/
nb_rx
;
}
else
{
log2_ifft_size
=
8
;
for
(
i
=
0
;
i
<
256
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
256
;
i
++
)
prach_ifft
[
i
]
=
(
prach_ifft
[
i
]
>>
log2_ifft_size
)
/
nb_rx
;
}
...
...
@@ -665,7 +665,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
preamble_shift2
=
((
preamble_shift
==
0
)
?
0
:
((
preamble_shift
<<
log2_ifft_size
)
/
N_ZC
));
for
(
i
=
0
;
i
<
NCS2
;
i
++
)
{
for
(
i
nt
i
=
0
;
i
<
NCS2
;
i
++
)
{
lev
=
(
int32_t
)
prach_ifft
[(
preamble_shift2
+
i
)];
levdB
=
dB_fixed_times10
(
lev
);
if
(
levdB
>*
max_preamble_energy
)
{
...
...
@@ -695,9 +695,11 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
// max_preamble_delay * ( (2048/2^mu*(fs/30.72M)) / 256 ) / fs = TA * 16 * 64 / 2^mu * Tc
uint16_t
*
TA
=
max_preamble_delay
;
int
mu
=
fp
->
numerology_index
;
if
(
cfg
->
prach_sequence_length
.
value
==
0
)
{
if
(
prach_fmt
==
0
||
prach_fmt
==
1
||
prach_fmt
==
2
)
*
TA
=
*
TA
*
3
*
(
1
<<
mu
)
/
2
;
else
if
(
prach_fmt
==
3
)
*
TA
=
*
TA
*
3
*
(
1
<<
mu
)
/
8
;
if
(
cfg
->
prach_sequence_length
.
value
==
0
)
{
if
(
prach_fmt
==
0
||
prach_fmt
==
1
||
prach_fmt
==
2
)
*
TA
=
*
TA
*
3
*
(
1
<<
mu
)
/
2
;
else
if
(
prach_fmt
==
3
)
*
TA
=
*
TA
*
3
*
(
1
<<
mu
)
/
8
;
}
else
*
TA
=
*
TA
/
2
;
...
...
@@ -705,19 +707,18 @@ void rx_nr_prach(PHY_VARS_gNB *gNB,
if
(
LOG_DUMPFLAG
(
PRACH
))
{
//int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],840));
// if (en>60) {
int
k
=
(
12
*
n_ra_prb
)
-
6
*
fp
->
N_RB_UL
;
if
(
k
<
0
)
k
+=
fp
->
ofdm_symbol_size
;
int
k
=
(
12
*
n_ra_prb
)
-
6
*
fp
->
N_RB_UL
;
if
(
k
<
0
)
k
+=
fp
->
ofdm_symbol_size
;
k
*=
12
;
k
+=
13
;
k
*=
2
;
LOG_M
(
"rxsigF.m"
,
"prach_rxF"
,
&
rxsigF
[
0
][
0
],
12288
,
1
,
1
);
LOG_M
(
"prach_rxF_comp0.m"
,
"prach_rxF_comp0"
,
prachF
,
1024
,
1
,
1
);
LOG_M
(
"Xu.m"
,
"xu"
,
Xu
,
N_ZC
,
1
,
1
);
LOG_M
(
"prach_ifft0.m"
,
"prach_t0"
,
prach_ifft
,
1024
,
1
,
1
);
LOG_M
(
"rxsigF.m"
,
"prach_rxF"
,
&
rxsigF
[
0
][
0
],
12288
,
1
,
1
);
LOG_M
(
"prach_rxF_comp0.m"
,
"prach_rxF_comp0"
,
prachF
,
1024
,
1
,
1
);
LOG_M
(
"Xu.m"
,
"xu"
,
Xu
,
N_ZC
,
1
,
1
);
LOG_M
(
"prach_ifft0.m"
,
"prach_t0"
,
prach_ifft
,
1024
,
1
,
1
);
// }
}
/* LOG_DUMPFLAG(PRACH) */
stop_meas
(
&
gNB
->
rx_prach
);
...
...
openair1/PHY/defs_gNB.h
View file @
01ae8fbb
...
...
@@ -145,9 +145,6 @@ typedef struct {
#define NUMBER_OF_NR_PRACH_MAX 8
typedef
struct
{
/// \brief ?.
/// first index: ? [0..1023] (hard coded)
int16_t
*
prachF
;
/// \brief ?.
/// second index: rx antenna [0..63] (hard coded) \note Hard coded array size indexed by \c nb_antennas_rx.
/// third index: frequency-domain sample [0..ofdm_symbol_size*12[
...
...
openair1/SIMULATION/NR_PHY/prachsim.c
View file @
01ae8fbb
...
...
@@ -779,16 +779,15 @@ int main(int argc, char **argv){
if
(
n_frames
==
1
)
{
printf
(
"preamble %d (tx %d) : energy %d, delay %d
\n
"
,
preamble_rx
,
preamble_tx
,
preamble_energy
,
preamble_delay
);
#ifdef NR_PRACH_DEBUG
#ifdef NR_PRACH_DEBUG
LOG_M
(
"prach0.m"
,
"prach0"
,
&
txdata
[
0
][
prach_start
],
frame_parms
->
samples_per_subframe
,
1
,
1
);
LOG_M
(
"prachF0.m"
,
"prachF0"
,
&
gNB
->
prach_vars
.
prachF
[
0
],
N_ZC
,
1
,
1
);
LOG_M
(
"rxsig0.m"
,
"rxs0"
,
&
ru
->
common
.
rxdata
[
0
][
subframe
*
frame_parms
->
samples_per_subframe
],
frame_parms
->
samples_per_subframe
,
1
,
1
);
LOG_M
(
"ru_rxsig0.m"
,
"rxs0"
,
&
ru
->
common
.
rxdata
[
0
][
subframe
*
frame_parms
->
samples_per_subframe
],
frame_parms
->
samples_per_subframe
,
1
,
1
);
LOG_M
(
"ru_rxsigF0.m"
,
"rxsF0"
,
ru
->
common
.
rxdataF
[
0
],
frame_parms
->
ofdm_symbol_size
*
frame_parms
->
symbols_per_slot
,
1
,
1
);
LOG_M
(
"ru_prach_rxsigF0.m"
,
"rxsF0"
,
ru
->
prach_rxsigF
[
0
][
0
],
N_ZC
,
1
,
1
);
LOG_M
(
"prach_preamble.m"
,
"prachp"
,
&
gNB
->
X_u
[
0
],
N_ZC
,
1
,
1
);
LOG_M
(
"ue_prach_preamble.m"
,
"prachp"
,
&
UE
->
X_u
[
0
],
N_ZC
,
1
,
1
);
#endif
#endif
}
}
...
...
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