Commit abb6fadd authored by Roberto Louro Magueta's avatar Roberto Louro Magueta Committed by luis_pereira87

Implementation of function add_noise()

parent f8160bd3
...@@ -305,7 +305,6 @@ int main(int argc, char **argv) ...@@ -305,7 +305,6 @@ int main(int argc, char **argv)
int Imcs = 9; int Imcs = 9;
uint8_t precod_nbr_layers = 1; uint8_t precod_nbr_layers = 1;
int gNB_id = 0; int gNB_id = 0;
int ap;
int tx_offset; int tx_offset;
int32_t txlev_sum = 0, atxlev[4]; int32_t txlev_sum = 0, atxlev[4];
int start_rb = 0; int start_rb = 0;
...@@ -1319,17 +1318,7 @@ int main(int argc, char **argv) ...@@ -1319,17 +1318,7 @@ int main(int argc, char **argv)
} else { } else {
multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0); multipath_tv_channel(UE2gNB, s_re, s_im, r_re, r_im, 2*slot_length, 0);
} }
add_noise(rxdata, (const double **) r_re, (const double **) r_im, sigma, slot_length, slot_offset, ts, delay, pdu_bit_map, frame_parms->nb_antennas_rx);
for (i=0; i<slot_length; i++) {
for (ap=0; ap<frame_parms->nb_antennas_rx; ap++) {
rxdata[ap][slot_offset+i+delay].r = (int16_t)((r_re[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0))); // convert to fixed point
rxdata[ap][slot_offset+i+delay].i = (int16_t)((r_im[ap][i]) + (sqrt(sigma/2)*gaussdouble(0.0,1.0)));
/* Add phase noise if enabled */
if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
phase_noise(ts, &rxdata[ap][slot_offset].r, &rxdata[ap][slot_offset].i);
}
}
}
} /*End input_fd */ } /*End input_fd */
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include "nfapi_nr_interface_scf.h"
#include "PHY/TOOLS/tools_defs.h" #include "PHY/TOOLS/tools_defs.h"
#include "SIMULATION/RF/rf.h" #include "SIMULATION/RF/rf.h"
#include "sim.h" #include "sim.h"
...@@ -144,6 +145,31 @@ void multipath_channel(channel_desc_t *desc, ...@@ -144,6 +145,31 @@ void multipath_channel(channel_desc_t *desc,
} }
#else #else
void add_noise(c16_t **rxdata,
const double **r_re,
const double **r_im,
const double sigma,
const int length,
const int slot_offset,
const double ts,
const int delay,
const uint16_t pdu_bit_map,
const uint8_t nb_antennas_rx)
{
for (int i = 0; i < length; i++) {
for (int ap = 0; ap < nb_antennas_rx; ap++) {
c16_t *rxd = &rxdata[ap][slot_offset + i + delay];
rxd->r = r_re[ap][i] + sqrt(sigma / 2) * gaussdouble(0.0, 1.0); // convert to fixed point
rxd->i = r_im[ap][i] + sqrt(sigma / 2) * gaussdouble(0.0, 1.0);
/* Add phase noise if enabled */
if (pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) {
phase_noise(ts, &rxdata[ap][slot_offset + i + delay].r, &rxdata[ap][slot_offset + i + delay].i);
}
}
}
}
void multipath_channel(channel_desc_t *desc, void multipath_channel(channel_desc_t *desc,
double *tx_sig_re[NB_ANTENNAS_TX], double *tx_sig_re[NB_ANTENNAS_TX],
double *tx_sig_im[NB_ANTENNAS_TX], double *tx_sig_im[NB_ANTENNAS_TX],
......
...@@ -348,6 +348,30 @@ void set_channeldesc_name(channel_desc_t *cdesc,char *modelname); ...@@ -348,6 +348,30 @@ void set_channeldesc_name(channel_desc_t *cdesc,char *modelname);
*/ */
int random_channel(channel_desc_t *desc, uint8_t abstraction_flag); int random_channel(channel_desc_t *desc, uint8_t abstraction_flag);
/**
\brief Add AWGN noise and phase noise if enabled
\param rxdata output data with noise
\param r_re real part of input data without noise
\param r_im imaginary part of input data without noise
\param sigma noise power
\param length number of samples to apply the noise
\param slot_offset slot offset to start applying the noise
\param ts sampling time
\param delay introduce delay in terms of number of samples
\param pdu_bit_map bitmap indicating presence of optional PDUs
\param nb_antennas_rx number of receive antennas
*/
void add_noise(c16_t **rxdata,
const double **r_re,
const double **r_im,
const double sigma,
const int length,
const int slot_offset,
const double ts,
const int delay,
const uint16_t pdu_bit_map,
const uint8_t nb_antennas_rx);
/**\fn void multipath_channel(channel_desc_t *desc, /**\fn void multipath_channel(channel_desc_t *desc,
double tx_sig_re[NB_ANTENNAS_TX], double tx_sig_re[NB_ANTENNAS_TX],
double tx_sig_im[NB_ANTENANS_TX], double tx_sig_im[NB_ANTENANS_TX],
......
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