Commit 435dfd57 authored by Bartosz Podrygajlo's avatar Bartosz Podrygajlo

RFsim: Optimization for operation without chanmod

parent 643be878
...@@ -1167,7 +1167,7 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t, ...@@ -1167,7 +1167,7 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t,
int rx_beam_id) int rx_beam_id)
{ {
cf_t temp_array[nbAnt][nsamps]; cf_t temp_array[nbAnt][nsamps];
memset(temp_array, 0, sizeof(temp_array)); bool channel_modelling = false;
// Add all input nodes signal in the output buffer // Add all input nodes signal in the output buffer
for (int sock = 0; sock < MAX_FD_RFSIMU; sock++) { for (int sock = 0; sock < MAX_FD_RFSIMU; sock++) {
buffer_t *ptr = &t->buf[sock]; buffer_t *ptr = &t->buf[sock];
...@@ -1182,6 +1182,10 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t, ...@@ -1182,6 +1182,10 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t,
random_channel(ptr->channel_model, 0); random_channel(ptr->channel_model, 0);
if (ptr->channel_model != NULL) { // apply a channel model if (ptr->channel_model != NULL) { // apply a channel model
if (!channel_modelling) {
memset(temp_array, 0, sizeof(temp_array));
channel_modelling = true;
}
const uint64_t dd = ptr->channel_model->channel_offset; const uint64_t dd = ptr->channel_model->channel_offset;
const uint64_t channel_length = ptr->channel_model->channel_length; const uint64_t channel_length = ptr->channel_model->channel_length;
std::vector<std::vector<c16_t>> ant_buffers = combine_received_beams(t, std::vector<std::vector<c16_t>> ant_buffers = combine_received_beams(t,
...@@ -1220,19 +1224,25 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t, ...@@ -1220,19 +1224,25 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t,
bool apply_global_noise = get_noise_power_dBFS() != INVALID_DBFS_VALUE; bool apply_global_noise = get_noise_power_dBFS() != INVALID_DBFS_VALUE;
if (apply_global_noise) { if (apply_global_noise) {
if (!channel_modelling) {
memset(temp_array, 0, sizeof(temp_array));
channel_modelling = true;
}
int16_t noise_power = (int16_t)(32767.0 / powf(10.0, .05 * -get_noise_power_dBFS()));
for (int a = 0; a < nbAnt; a++) { for (int a = 0; a < nbAnt; a++) {
for (int i = 0; i < nsamps; i++) { for (int i = 0; i < nsamps; i++) {
int16_t noise_power = (int16_t)(32767.0 / powf(10.0, .05 * -get_noise_power_dBFS()));
temp_array[a][i].r += noise_power + gaussZiggurat(0.0, 1.0); temp_array[a][i].r += noise_power + gaussZiggurat(0.0, 1.0);
temp_array[a][i].i += noise_power * gaussZiggurat(0.0, 1.0); temp_array[a][i].i += noise_power * gaussZiggurat(0.0, 1.0);
} }
} }
} }
for (int a = 0; a < nbAnt; a++) { if (channel_modelling) {
for (int i = 0; i < nsamps; i++) { for (int a = 0; a < nbAnt; a++) {
samples[a][i].r += lroundf(temp_array[a][i].r); for (int i = 0; i < nsamps; i++) {
samples[a][i].i += lroundf(temp_array[a][i].i); samples[a][i].r += lroundf(temp_array[a][i].r);
samples[a][i].i += lroundf(temp_array[a][i].i);
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment