SDR  - srsLTE - API Doc                                                        Home : www.sharetechnote.com

 

 

 

 

< Data Structure Description >

 

    typedef _Complex float cf_t;

     

     

    typedef struct {

      cf_t *corr;

      uint32_t symbol_sz;

    } srslte_cp_synch_t

     

     

    typedef enum {

      SRSLTE_DFT_COMPLEX, SRSLTE_REAL

    }srslte_dft_mode_t;

     

     

    typedef enum {

      SRSLTE_DFT_FORWARD, SRSLTE_DFT_BACKWARD

    }srslte_dft_dir_t;

     

     

    typedef struct SRSLTE_API {

      int size;           // DFT length

      void *in;           // Input buffer

      void *out;          // Output buffer

      void *p;            // DFT plan

      bool forward;       // Forward transform?

      bool mirror;        // Shift negative and positive frequencies?

      bool db;            // Provide output in dB?

      bool norm;          // Normalize output?

      bool dc;            // Handle insertion/removal of null DC carrier internally?

      srslte_dft_dir_t dir;     // Forward/Backward

      srslte_dft_mode_t mode;   // Complex/Real

    }srslte_dft_plan_t;

     

     

    typedef struct SRSLTE_API {

      cf_t *input_fft;

      cf_t *filter_fft;

      cf_t *output_fft;

      cf_t *output_fft2;

      uint32_t input_len;

      uint32_t filter_len;

      uint32_t output_len;

      srslte_dft_plan_t input_plan;

      srslte_dft_plan_t filter_plan;

      srslte_dft_plan_t output_plan;

    }srslte_conv_fft_cc_t;

     

     

    typedef struct SRSLTE_API {

      

      srslte_dft_plan_t dftp_input;

      

    #ifdef CONVOLUTION_FFT

      srslte_conv_fft_cc_t conv_fft;

    #endif

     

      uint32_t frame_size;

      uint32_t N_id_2;

      uint32_t fft_size;

     

      cf_t *pss_signal_time[3];

      cf_t pss_signal_freq[3][SRSLTE_PSS_LEN]; // One sequence for each N_id_2

      cf_t *tmp_input;

      cf_t *conv_output;

      float *conv_output_abs;

      float ema_alpha;

      float *conv_output_avg;

      float peak_value;

    }srslte_pss_synch_t;

     

    typedef enum {SRSLTE_CP_NORM, SRSLTE_CP_EXT} srslte_cp_t;

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      // Saves the reference signal per subframe for ports 0,1 and ports 2,3

      cf_t *pilots[2][SRSLTE_NSUBFRAMES_X_FRAME];

    } srslte_refsignal_cs_t;

     

    typedef struct SRSLTE_API {

      uint32_t nof_prb;

      uint32_t nof_ports;

      uint32_t bw_idx;

      uint32_t id;

      srslte_cp_t cp;

      srslte_phich_length_t phich_length;

      srslte_phich_resources_t phich_resources;

    }srslte_cell_t;

     

     

    typedef struct {

      cf_t symbol[8];

    } bpsk_packed_t;

     

    typedef struct {

      cf_t symbol[4];

    } qpsk_packed_t;

     

    typedef struct {

      cf_t symbol[2];

    } qam16_packed_t;

     

    typedef struct SRSLTE_API {

      cf_t* symbol_table;             // bit-to-symbol mapping

      uint32_t nsymbols;              // number of modulation symbols

      uint32_t nbits_x_symbol;        // number of bits per symbol

      

      bool byte_tables_init;

      bpsk_packed_t *symbol_table_bpsk;

      qpsk_packed_t *symbol_table_qpsk;

      qam16_packed_t *symbol_table_16qam;  

    }srslte_modem_table_t;

     

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      

      uint32_t nof_symbols;

     

      /* buffers */

      cf_t *ce[SRSLTE_MAX_PORTS];

      cf_t *symbols[SRSLTE_MAX_PORTS];

      cf_t *x[SRSLTE_MAX_PORTS];

      cf_t *d;

      float *llr;

      float *temp;

      float rm_f[SRSLTE_BCH_ENCODED_LEN];

      uint8_t *rm_b;

      uint8_t data[SRSLTE_BCH_PAYLOADCRC_LEN];

      uint8_t data_enc[SRSLTE_BCH_ENCODED_LEN];

     

      uint32_t frame_idx;

     

      /* tx & rx objects */

      srslte_modem_table_t mod;

      srslte_sequence_t seq;

      srslte_viterbi_t decoder;

      srslte_crc_t crc;

      srslte_convcoder_t encoder;

      srslte_precoding_t precoding;

      bool search_all_ports;

      

    } srslte_pbch_t;

     

     

    typedef struct SRSLTE_API {

      uint8_t *c;

      uint8_t *c_bytes;

      float *c_float;

      short *c_short;

      uint32_t len;

    } srslte_sequence_t;

     

     

    typedef struct SRSLTE_API {

      uint32_t R;

      uint32_t K;

      uint32_t poly[3];

      bool tail_biting;

    }srslte_convcoder_t;

     

    typedef enum SRSLTE_API {

      SRSLTE_MIMO_TYPE_SINGLE_ANTENNA,

      SRSLTE_MIMO_TYPE_TX_DIVERSITY,

      SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX

    } srslte_mimo_type_t;

     

    typedef struct {

      cf_t *h_mod;

      cf_t *tmp1;

      cf_t *tmp2;

      cf_t *tmp3;

      float *y_mod;

      float *z_real;

      float *z_imag;

      uint32_t max_frame_len;

    } srslte_precoding_t;

     

    typedef struct SRSLTE_API {

      uint32_t k[4];

      uint32_t k0;

      uint32_t l;

      bool assigned;

    }srslte_regs_reg_t;

     

    typedef struct SRSLTE_API {

      uint32_t nof_regs;

      srslte_regs_reg_t **regs;

    }srslte_regs_ch_t;

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      uint32_t max_ctrl_symbols;

      uint32_t cfi;

      bool cfi_initiated;

      uint32_t ngroups_phich;

      

      srslte_phich_resources_t phich_res;

      srslte_phich_length_t phich_len;

      

      srslte_regs_ch_t pcfich;

      srslte_regs_ch_t *phich; // there are several phich

      srslte_regs_ch_t pdcch[3]; /* PDCCH indexing, permutation and interleaving is computed for

                the three possible CFI value */

      

      uint32_t nof_regs;

      srslte_regs_reg_t *regs;

    }srslte_regs_t;

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      int nof_symbols;

     

      /* handler to REGs resource mapper */

      srslte_regs_t *regs;

     

      /* buffers */

      cf_t ce[SRSLTE_MAX_PORTS][PCFICH_RE];

      cf_t symbols[SRSLTE_MAX_PORTS][PCFICH_RE];

      cf_t x[SRSLTE_MAX_PORTS][PCFICH_RE];

      cf_t d[PCFICH_RE];

      

      // cfi table in floats

      float cfi_table_float[3][PCFICH_CFI_LEN];

     

      /* bit message */

      uint8_t data[PCFICH_CFI_LEN];

     

      /* received soft bits */

      float data_f[PCFICH_CFI_LEN];

     

      /* tx & rx objects */

      srslte_modem_table_t mod;  

      srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];

      srslte_precoding_t precoding;

     

    } srslte_pcfich_t;

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      

      /* handler to REGs resource mapper */

      srslte_regs_t *regs;

     

      /* buffers */

      cf_t ce[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB];

      cf_t symbols[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB];

      cf_t x[SRSLTE_MAX_PORTS][SRSLTE_PHICH_MAX_NSYMB];

      cf_t d[SRSLTE_PHICH_MAX_NSYMB];

      cf_t d0[SRSLTE_PHICH_MAX_NSYMB];

      cf_t z[SRSLTE_PHICH_NBITS];

     

      /* bit message */

      uint8_t data[SRSLTE_PHICH_NBITS];

      float data_rx[SRSLTE_PHICH_NBITS];

     

      /* tx & rx objects */

      srslte_modem_table_t mod;

      srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];

      srslte_precoding_t precoding;

     

    } srslte_phich_t;

     

    typedef struct SRSLTE_API {

      uint64_t table[256];

      int polynom;

      int order;

      uint64_t crcinit;

      uint64_t crcmask;

      uint64_t crchighbit;

      uint32_t srslte_crc_out;

    } srslte_crc_t;

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      uint32_t nof_regs;

      uint32_t nof_cce;

      uint32_t max_bits;

     

      srslte_regs_t *regs;

     

      /* buffers */

      cf_t *ce[SRSLTE_MAX_PORTS];

      cf_t *symbols[SRSLTE_MAX_PORTS];

      cf_t *x[SRSLTE_MAX_PORTS];

      cf_t *d;

      uint8_t *e;

      float rm_f[3 * (SRSLTE_DCI_MAX_BITS + 16)];

      float *llr;

     

      /* tx & rx objects */

      srslte_modem_table_t mod;

      srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];

      srslte_viterbi_t decoder;

      srslte_crc_t crc;

      srslte_precoding_t precoding;

     

    } srslte_pdcch_t;

     

    typedef struct SRSLTE_API {

      uint32_t L;    // Aggregation level

      uint32_t ncce; // Position of first CCE of the dci

    } srslte_dci_location_t;

     

     

    typedef struct SRSLTE_API {

      uint8_t data[SRSLTE_DCI_MAX_BITS];

      uint32_t nof_bits;

    } srslte_dci_msg_t;

     

     

    typedef struct SRSLTE_API {

      uint32_t rba;

      uint32_t trunc_mcs;

      uint32_t tpc_pusch;

      bool ul_delay;

      bool cqi_request;

      bool hopping_flag;

    } srslte_dci_rar_grant_t;

     

     

    typedef struct SRSLTE_API {

      srslte_cell_t cell;

      

      uint32_t max_re;

      bool rnti_is_set;

      uint16_t rnti;

      

      /* buffers */

      // void buffers are shared for tx and rx

      cf_t *ce[SRSLTE_MAX_PORTS];

      cf_t *symbols[SRSLTE_MAX_PORTS];

      cf_t *x[SRSLTE_MAX_PORTS];

      cf_t *d;

      void *e;

     

      /* tx & rx objects */

      srslte_modem_table_t mod[4];

      

      srslte_sequence_t seq[SRSLTE_NSUBFRAMES_X_FRAME];

      srslte_precoding_t precoding;

     

      srslte_sch_t dl_sch;

      

    } srslte_pdsch_t;

     

     

    typedef struct SRSLTE_API {

      

      uint32_t max_iterations;

      uint32_t nof_iterations;

      float average_nof_iterations;

      

      /* buffers */

      uint8_t *cb_in;

      uint8_t *parity_bits;  

      void *e;

      uint8_t *temp_g_bits;

      uint16_t *ul_interleaver;

      srslte_uci_bit_t ack_ri_bits[12*288];

      uint32_t nof_ri_ack_bits;

      

      srslte_tcod_t encoder;

      srslte_tdec_t decoder;  

      srslte_crc_t crc_tb;

      srslte_crc_t crc_cb;

      

      srslte_uci_cqi_pusch_t uci_cqi;

      

    } srslte_sch_t;

     

     

    typedef struct SRSLTE_API {

      srslte_cbsegm_t cb_segm;

      srslte_ra_dl_grant_t grant;

      srslte_ra_nbits_t nbits;

      uint32_t rv;

      uint32_t sf_idx;  

    } srslte_pdsch_cfg_t;

     

     

     typedef struct SRSLTE_API {

      uint32_t F;

      uint32_t C;

      uint32_t K1;

      uint32_t K2;

      uint32_t K1_idx;

      uint32_t K2_idx;

      uint32_t C1;

      uint32_t C2;

      uint32_t tbs;

    } srslte_cbsegm_t;

     

     

    typedef struct SRSLTE_API {

      bool prb_idx[2][SRSLTE_MAX_PRB];

      uint32_t nof_prb;  

      uint32_t Qm;

      srslte_ra_mcs_t mcs;

    } srslte_ra_dl_grant_t;

     

     

    typedef struct {

      uint32_t lstart;

      uint32_t nof_symb;

      uint32_t nof_bits;

      uint32_t nof_re;

    } srslte_ra_nbits_t;

     

     

    typedef struct SRSLTE_API {

      FILE *f;

      srslte_datatype_t type;

    } srslte_filesource_t;

     

     

    typedef enum {

      SRSLTE_FLOAT,

      SRSLTE_COMPLEX_FLOAT,

      SRSLTE_COMPLEX_SHORT,

      SRSLTE_FLOAT_BIN,

      SRSLTE_COMPLEX_FLOAT_BIN,

      SRSLTE_COMPLEX_SHORT_BIN  

    } srslte_datatype_t;

     

     

    typedef struct SRSLTE_API {

      srslte_sync_t sfind;

      srslte_sync_t strack;

      

      srslte_agc_t agc;

      bool do_agc;

      uint32_t agc_period;

      

      void *stream;

      int (*recv_callback)(void*, void*, uint32_t, srslte_timestamp_t*);

      srslte_timestamp_t last_timestamp;

      

      srslte_filesource_t file_source;

      bool file_mode;

      float file_cfo;

      srslte_cfo_t file_cfo_correct;

      

      srslte_ue_sync_state_t state;

      

      cf_t *input_buffer;

      

      uint32_t frame_len;

      uint32_t fft_size;

      uint32_t nof_recv_sf;  // Number of subframes received each call to srslte_ue_sync_get_buffer

      uint32_t nof_avg_find_frames;

      uint32_t frame_find_cnt;

      uint32_t sf_len;

     

      /* These count half frames (5ms) */

      uint64_t frame_ok_cnt;

      uint32_t frame_no_cnt;

      uint32_t frame_total_cnt;

      

      /* this is the system frame number (SFN) */

      uint32_t frame_number;

      

      srslte_cell_t cell;

      uint32_t sf_idx;

          

      bool decode_sss_on_track;

      bool correct_cfo;

      

      uint32_t peak_idx;

      int next_rf_sample_offset;

      int last_sample_offset;

      float mean_sample_offset;

      float mean_sfo;

      uint32_t sample_offset_correct_period;

      float sfo_ema;

     

      #ifdef MEASURE_EXEC_TIME

      float mean_exec_time;

      #endif

    } srslte_ue_sync_t;

     

     

    typedef struct SRSLTE_API {

      srslte_pss_synch_t pss;

      srslte_pss_synch_t pss_i[2];

      srslte_sss_synch_t sss;

      srslte_cp_synch_t cp_synch;

      cf_t *cfo_i_corr[2];

      

      float threshold;

      float peak_value;

      uint32_t N_id_2;

      uint32_t N_id_1;

      uint32_t sf_idx;

      uint32_t fft_size;

      uint32_t frame_size;

      uint32_t max_offset;

      bool enable_cfo_corr;

      float mean_cfo;

      int cfo_i;

      bool find_cfo_i;

      bool find_cfo_i_initiated;

      float cfo_ema_alpha;

      uint32_t nof_symbols;

      uint32_t cp_len;

      srslte_cfo_t cfocorr;

      sss_alg_t sss_alg;

      bool detect_cp;

      bool sss_en;

      srslte_cp_t cp;

      uint32_t m0;

      uint32_t m1;

      float m0_value;

      float m1_value;

      float M_norm_avg;

      float M_ext_avg;

     

    }srslte_sync_t;

     

     

    typedef struct SRSLTE_API{

      float bandwidth;

      double gain;

      float y_out;

      bool lock;

      bool isfirst;

      void *uhd_handler;

      double (*set_gain_callback) (void*,double);

      srslte_agc_mode_t mode;

      float target;

      uint32_t nof_frames;

      uint32_t frame_cnt;

      float *y_tmp;

    } srslte_agc_t;

     

     

    typedef struct SRSLTE_API{

      time_t full_secs;

      double frac_secs;

    }srslte_timestamp_t;

     

     

    typedef struct SRSLTE_API {

      float last_freq;

      float tol;

      int nsamples;

      srslte_cexptab_t tab;

      cf_t *cur_cexp;

    }srslte_cfo_t;

     

     

    typedef enum SRSLTE_API { SF_FIND, SF_TRACK} srslte_ue_sync_state_t;

     

     

    typedef struct SRSLTE_API {

      srslte_sync_t sfind;

     

      cf_t *sf_symbols;

      cf_t *ce[SRSLTE_MAX_PORTS];

      

      srslte_ofdm_t fft;

      srslte_chest_dl_t chest;

      srslte_pbch_t pbch;

      

      uint8_t bch_payload[SRSLTE_BCH_PAYLOAD_LEN];

      uint32_t nof_tx_ports;

      uint32_t sfn_offset;

      

      uint32_t frame_cnt;

    } srslte_ue_mib_t;

     

     

    typedef struct SRSLTE_API{

      srslte_dft_plan_t fft_plan;

      uint32_t nof_symbols;

      uint32_t symbol_sz;

      uint32_t nof_guards;

      uint32_t nof_re;

      uint32_t slot_sz;

      srslte_cp_t cp;

      cf_t *tmp; // for removing zero padding

      

      bool freq_shift;

      cf_t *shift_buffer;

    }srslte_ofdm_t;

     

     

    typedef struct {

      srslte_cell_t cell;

      srslte_refsignal_cs_t csr_signal;

      cf_t *pilot_estimates;

      cf_t *pilot_estimates_average;

      cf_t *pilot_recv_signal;

      cf_t *tmp_noise;

      

    #ifdef FREQ_SEL_SNR  

      float snr_vector[12000];

      float pilot_power[12000];

    #endif

      uint32_t smooth_filter_len;

      float smooth_filter[SRSLTE_CHEST_DL_MAX_SMOOTH_FIL_LEN];

     

      srslte_interp_linsrslte_vec_t srslte_interp_linvec;

      srslte_interp_lin_t srslte_interp_lin;

      

      float rssi[SRSLTE_MAX_PORTS];

      float rsrp[SRSLTE_MAX_PORTS];

      float noise_estimate[SRSLTE_MAX_PORTS];

      

      /* Use PSS for noise estimation in LS linear interpolation mode */

      cf_t pss_signal[SRSLTE_PSS_LEN];

      cf_t tmp_pss[SRSLTE_PSS_LEN];

      cf_t tmp_pss_noisy[SRSLTE_PSS_LEN];

      

      srslte_chest_dl_noise_alg_t noise_alg;

     

    } srslte_chest_dl_t;

     

     

    typedef enum {

      SRSLTE_NOISE_ALG_REFS,

      SRSLTE_NOISE_ALG_PSS,

      SRSLTE_NOISE_ALG_EMPTY,

    } srslte_chest_dl_noise_alg_t;

     

     

    typedef struct SRSLTE_API {

      srslte_pcfich_t pcfich;

      srslte_pdcch_t pdcch;

      srslte_pdsch_t pdsch;

      srslte_phich_t phich;

      srslte_regs_t regs;

      srslte_ofdm_t fft;

      srslte_chest_dl_t chest;

      

      srslte_cfo_t sfo_correct;

      

      srslte_pdsch_cfg_t pdsch_cfg;

      srslte_softbuffer_rx_t softbuffer;

      srslte_ra_dl_dci_t dl_dci;

      srslte_cell_t cell;

     

      cf_t *sf_symbols;

      cf_t *ce[SRSLTE_MAX_PORTS];

      

      srslte_dci_format_t dci_format;

      uint32_t cfi;

      uint64_t pkt_errors;

      uint64_t pkts_total;

      uint64_t nof_detected;

     

      uint16_t current_rnti;

      uint32_t last_n_cce;

      srslte_dci_location_t last_location;

      

      srslte_dci_msg_t pending_ul_dci_msg;

      uint16_t pending_ul_dci_rnti;

      

      float sample_offset;

    }srslte_ue_dl_t;

     

     

    typedef struct SRSLTE_API {

      uint32_t max_cb;

      int16_t **buffer_f;  

    } srslte_softbuffer_rx_t;

     

     

    typedef struct SRSLTE_API {

      uint32_t max_cb;

      uint8_t **buffer_b;  

    } srslte_softbuffer_tx_t;

     

     

    typedef enum {

      SRSLTE_DCI_FORMAT0 = 0,

      SRSLTE_DCI_FORMAT1,

      SRSLTE_DCI_FORMAT1A,

      SRSLTE_DCI_FORMAT1C,

      SRSLTE_DCI_FORMAT_ERROR

    } srslte_dci_format_t;

     

     

    typedef struct SRSLTE_API {

      

      enum {

        SRSLTE_RA_DCI_FORMAT1,

        SRSLTE_RA_DCI_FORMAT1A,

        SRSLTE_RA_DCI_FORMAT1C,

      } dci_format;

      

      srslte_ra_type_t alloc_type;

      union {

        srslte_ra_type0_t type0_alloc;

        srslte_ra_type1_t type1_alloc;

        srslte_ra_type2_t type2_alloc;

      };

      

      uint32_t mcs_idx;

      uint32_t harq_process;

      int      rv_idx;

      bool ndi;

    } srslte_ra_dl_dci_t;

     

     

    typedef enum {

      SRSLTE_SYNC_FOUND = 1,

      SRSLTE_SYNC_FOUND_NOSPACE = 2,

      SRSLTE_SYNC_NOFOUND = 0,

      SRSLTE_SYNC_ERROR = -1  

    } srslte_sync_find_ret_t;