Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openairinterface5G
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bin He
openairinterface5G
Commits
8c16f16c
Commit
8c16f16c
authored
5 years ago
by
Thomas Laurent
Browse files
Options
Downloads
Patches
Plain Diff
add channel simulator in rfsimulator
parent
cba07363
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
targets/ARCH/rfsimulator/simulator.c
+13
-15
13 additions, 15 deletions
targets/ARCH/rfsimulator/simulator.c
with
13 additions
and
15 deletions
targets/ARCH/rfsimulator/simulator.c
+
13
−
15
View file @
8c16f16c
...
@@ -104,9 +104,8 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
...
@@ -104,9 +104,8 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
// Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ?
// Fixme: how to convert a noise in Watt into a 12 bits value out of the RF ADC ?
// the parameter "-s" is declared as SNR, but the input power is not well defined
// the parameter "-s" is declared as SNR, but the input power is not well defined
// −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise)
// −132.24 dBm is a LTE subcarrier noise, that was used in origin code (15KHz BW thermal noise)
const
double
rxGain
=
132
.
24
-
snr_dB
;
const
double
rxGain
=
132
.
24
-
snr_dB
;
const
double
noise_per_sample
=
sqrt
(
0
.
5
*
noise_figure_watt
)
*
pow
(
10
,
rxGain
/
20
);
const
double
noise_per_sample
=
sqrt
(
0
.
5
*
noise_figure_watt
)
*
pow
(
10
,
rxGain
/
20
);
// Fixme: we don't fill the offset length samples at begining ?
// Fixme: we don't fill the offset length samples at begining ?
// anyway, in today code, channel_offset=0
// anyway, in today code, channel_offset=0
const
int
dd
=
abs
(
channelDesc
->
channel_offset
);
const
int
dd
=
abs
(
channelDesc
->
channel_offset
);
...
@@ -136,20 +135,20 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
...
@@ -136,20 +135,20 @@ void rxAddInput( struct complex16 *input_sig, struct complex16 *after_channel_si
out_ptr
->
r
+=
round
(
rx_tmp
.
x
*
pathLossLinear
+
noise_per_sample
*
gaussdouble
(
0
.
0
,
1
.
0
));
out_ptr
->
r
+=
round
(
rx_tmp
.
x
*
pathLossLinear
+
noise_per_sample
*
gaussdouble
(
0
.
0
,
1
.
0
));
/*
/*
printf("in: %d, out %d= %f*%f + %f*%f\n",
printf("in: %d, out %d= %f*%f + %f*%f\n",
input_sig[((TS+i)*nbTx)%CirSize].r, out_ptr->r , rx_tmp.x,
input_sig[((TS+i)*nbTx)%CirSize].r, out_ptr->r , rx_tmp.x,
pathLossLinear, noise_per_sample,gaussdouble(0.0,1.0));
pathLossLinear, noise_per_sample,gaussdouble(0.0,1.0));
*/
*/
out_ptr
->
i
+=
round
(
rx_tmp
.
y
*
pathLossLinear
+
noise_per_sample
*
gaussdouble
(
0
.
0
,
1
.
0
));
out_ptr
->
i
+=
round
(
rx_tmp
.
y
*
pathLossLinear
+
noise_per_sample
*
gaussdouble
(
0
.
0
,
1
.
0
));
out_ptr
++
;
out_ptr
++
;
}
}
if
(
(
TS
*
nbTx
)
%
CirSize
+
nbSamples
<=
CirSize
)
if
(
(
TS
*
nbTx
)
%
CirSize
+
nbSamples
<=
CirSize
)
// Cast to a wrong type for compatibility !
// Cast to a wrong type for compatibility !
LOG_
I
(
HW
,
"Input power %f, output power: %f, channel path loss %f, noise coeff: %f
\n
"
,
LOG_
D
(
HW
,
"Input power %f, output power: %f, channel path loss %f, noise coeff: %f
\n
"
,
10
*
log10
((
double
)
signal_energy
((
int32_t
*
)
&
input_sig
[(
TS
*
nbTx
)
%
CirSize
],
nbSamples
)),
10
*
log10
((
double
)
signal_energy
((
int32_t
*
)
&
input_sig
[(
TS
*
nbTx
)
%
CirSize
],
nbSamples
)),
10
*
log10
((
double
)
signal_energy
((
int32_t
*
)
after_channel_sig
,
nbSamples
)),
10
*
log10
((
double
)
signal_energy
((
int32_t
*
)
after_channel_sig
,
nbSamples
)),
channelDesc
->
path_loss_dB
,
channelDesc
->
path_loss_dB
,
10
*
log10
(
noise_per_sample
));
10
*
log10
(
noise_per_sample
));
}
}
void
allocCirBuf
(
rfsimulator_state_t
*
bridge
,
int
sock
)
{
void
allocCirBuf
(
rfsimulator_state_t
*
bridge
,
int
sock
)
{
...
@@ -541,14 +540,13 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
...
@@ -541,14 +540,13 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
if
(
reGenerateChannel
)
if
(
reGenerateChannel
)
random_channel
(
ptr
->
channel_model
,
0
);
random_channel
(
ptr
->
channel_model
,
0
);
for
(
int
a
=
0
;
a
<
nbAnt
;
a
++
)
for
(
int
a
=
0
;
a
<
nbAnt
;
a
++
)
rxAddInput
(
ptr
->
circularBuf
,
(
struct
complex16
*
)
samplesVoid
[
a
],
rxAddInput
(
ptr
->
circularBuf
,
(
struct
complex16
*
)
samplesVoid
[
a
],
a
,
a
,
ptr
->
channel_model
,
ptr
->
channel_model
,
nsamps
,
nsamps
,
t
->
nextTimestamp
t
->
nextTimestamp
);
);
}
}
}
}
...
@@ -587,9 +585,9 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c
...
@@ -587,9 +585,9 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c
}
}
__attribute__
((
__visibility__
(
"default"
)))
__attribute__
((
__visibility__
(
"default"
)))
int
device_init
(
openair0_device
*
device
,
openair0_config_t
*
openair0_cfg
)
{
int
device_init
(
openair0_device
*
device
,
openair0_config_t
*
openair0_cfg
)
{
//
set_log(HW,OAILOG_DEBUG);
//
to change the log level, use this on command line
set_log
(
TMR
,
OAILOG_DEBUG
);
// --log_config.hw_log_level debug
//
set_log(PHY,OAILOG_DEBUG);
//
(for phy layer, replace "hw" by "phy"
rfsimulator_state_t
*
rfsimulator
=
(
rfsimulator_state_t
*
)
calloc
(
sizeof
(
rfsimulator_state_t
),
1
);
rfsimulator_state_t
*
rfsimulator
=
(
rfsimulator_state_t
*
)
calloc
(
sizeof
(
rfsimulator_state_t
),
1
);
if
((
rfsimulator
->
ip
=
getenv
(
"RFSIMULATOR"
))
==
NULL
)
{
if
((
rfsimulator
->
ip
=
getenv
(
"RFSIMULATOR"
))
==
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment