GNSS-SDR  0.0.17
An Open Source GNSS Software Defined Receiver
ad9361_fpga_signal_source.h
Go to the documentation of this file.
1 /*!
2  * \file ad9361_fpga_signal_source.h
3  * \brief signal source for Analog Devices front-end AD9361 connected directly
4  * to FPGA accelerators.
5  * This source implements only the AD9361 control. It is NOT compatible with
6  * conventional SDR acquisition and tracking blocks.
7  * Please use the fmcomms2 source if conventional SDR acquisition and tracking
8  * is selected in the configuration file.
9  *
10  * -----------------------------------------------------------------------------
11  *
12  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
13  * This file is part of GNSS-SDR.
14  *
15  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
16  * SPDX-License-Identifier: GPL-3.0-or-later
17  *
18  * -----------------------------------------------------------------------------
19  */
20 
21 #ifndef GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H
22 #define GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H
23 
24 #include "concurrent_queue.h"
25 #include "fpga_buffer_monitor.h"
27 #include "fpga_switch.h"
28 #include "gnss_block_interface.h"
29 #include "signal_source_base.h"
30 #include <pmt/pmt.h>
31 #include <cstdint>
32 #include <memory>
33 #include <mutex>
34 #include <string>
35 #include <thread>
36 
37 
38 /** \addtogroup Signal_Source
39  * \{ */
40 /** \addtogroup Signal_Source_adapters
41  * \{ */
42 
43 
45 
47 {
48 public:
50  const std::string &role, unsigned int in_stream,
51  unsigned int out_stream, Concurrent_Queue<pmt::pmt_t> *queue);
52 
54 
55  void start() override;
56 
57  inline size_t item_size() override
58  {
59  return item_size_;
60  }
61 
62  void connect(gr::top_block_sptr top_block) override;
63  void disconnect(gr::top_block_sptr top_block) override;
64  gr::basic_block_sptr get_left_block() override;
65  gr::basic_block_sptr get_right_block() override;
66 
67 private:
68  const std::string switch_device_name = std::string("AXIS_Switch_v1_0_0"); // Switch UIO device name
69  const std::string dyn_bit_sel_device_name = std::string("dynamic_bits_selector"); // Switch dhnamic bit selector device name
70  const std::string buffer_monitor_device_name = std::string("buffer_monitor"); // buffer monitor device name
71  const std::string default_dump_filename = std::string("FPGA_buffer_monitor_dump.dat");
72  const std::string default_rf_port_select = std::string("A_BALANCED");
73  const std::string default_gain_mode = std::string("slow_attack");
74  const double default_tx_attenuation_db = -10.0;
75  const double default_manual_gain_rx1 = 64.0;
76  const double default_manual_gain_rx2 = 64.0;
77  const uint64_t default_bandwidth = 12500000;
78 
79  // perform dynamic bit selection every 500 ms by default
80  const uint32_t Gain_control_period_ms = 500;
81  // check buffer overflow and perform buffer monitoring every 1s by default
82  const uint32_t buffer_monitor_period_ms = 1000;
83  // buffer overflow and buffer monitoring initial delay
84  const uint32_t buffer_monitoring_initial_delay_ms = 2000;
85  // sample block size when running in post-processing mode
86  const int sample_block_size = 16384;
87 
88  void run_DMA_process(const std::string &filename0,
89  const std::string &filename1,
90  uint64_t &samples_to_skip,
91  size_t &item_size,
92  int64_t &samples,
93  bool &repeat,
94  uint32_t &dma_buff_offset_pos,
96 
97  void run_dynamic_bit_selection_process();
98  void run_buffer_monitor_process();
99 
100  std::thread thread_file_to_dma;
101  std::thread thread_dynamic_bit_selection;
102  std::thread thread_buffer_monitor;
103 
104  std::shared_ptr<Fpga_Switch> switch_fpga;
105  std::shared_ptr<Fpga_dynamic_bit_selection> dynamic_bit_selection_fpga;
106  std::shared_ptr<Fpga_buffer_monitor> buffer_monitor_fpga;
107 
108  std::mutex dma_mutex;
109  std::mutex dynamic_bit_selection_mutex;
110  std::mutex buffer_monitor_mutex;
111 
113 
114  // Front-end settings
115  std::string gain_mode_rx1_;
116  std::string gain_mode_rx2_;
117  std::string rf_port_select_;
118  std::string filter_file_;
119  std::string filter_source_;
120  std::string filter_filename_;
121  std::string filename0;
122  std::string filename1;
123 
124  double rf_gain_rx1_;
125  double rf_gain_rx2_;
126  uint64_t freq_; // frequency of local oscillator
127  uint64_t sample_rate_;
128  uint64_t bandwidth_;
129  uint64_t samples_to_skip_;
130  int64_t samples_;
131  float Fpass_;
132  float Fstop_;
133  uint32_t num_freq_bands_;
134  uint32_t dma_buff_offset_pos_;
135 
136  // DDS configuration for LO generation for external mixer
137  double scale_dds_dbfs_;
138  double phase_dds_deg_;
139  double tx_attenuation_db_;
140  uint64_t freq_dds_tx_hz_;
141  uint64_t freq_rf_tx_hz_;
142  uint64_t tx_bandwidth_;
143  size_t item_size_;
144  uint32_t in_stream_;
145  uint32_t out_stream_;
146  int32_t switch_position_;
147  bool enable_dds_lo_;
148 
149  bool filter_auto_;
150  bool quadrature_;
151  bool rf_dc_;
152  bool bb_dc_;
153  bool rx1_enable_;
154  bool rx2_enable_;
155  bool enable_DMA_;
156  bool enable_dynamic_bit_selection_;
157  bool enable_ovf_check_buffer_monitor_active_;
158  bool dump_;
159  bool rf_shutdown_;
160  bool repeat_;
161 };
162 
163 
164 /** \} */
165 /** \} */
166 #endif // GNSS_SDR_AD9361_FPGA_SIGNAL_SOURCE_H
Interface of a thread-safe std::queue.
void start() override
Start the flow of samples if needed.
Header file of the base class to signal_source GNSS blocks.
Check receiver buffer overflow and monitor the status of the receiver buffers.
This interface represents a GNSS block.
This abstract class represents an interface to configuration parameters.
Switch that connects the HW accelerator queues to the analog front end or the DMA.
Dynamic bit selection in the received signal.