GNSS-SDR  0.0.19
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"
26 #include "fpga_dma-proxy.h"
28 #include "fpga_switch.h"
29 #include "gnss_block_interface.h"
30 #include "signal_source_base.h"
31 #include <pmt/pmt.h>
32 #include <cstdint>
33 #include <memory>
34 #include <mutex>
35 #include <string>
36 #include <thread>
37 
38 
39 /** \addtogroup Signal_Source
40  * \{ */
41 /** \addtogroup Signal_Source_adapters
42  * \{ */
43 
44 
46 
48 {
49 public:
51  const std::string &role, unsigned int in_stream,
52  unsigned int out_stream, Concurrent_Queue<pmt::pmt_t> *queue);
53 
55 
56  void start() override;
57 
58  inline size_t item_size() override
59  {
60  return item_size_;
61  }
62 
63  void connect(gr::top_block_sptr top_block) override;
64  void disconnect(gr::top_block_sptr top_block) override;
65  gr::basic_block_sptr get_left_block() override;
66  gr::basic_block_sptr get_right_block() override;
67 
68 private:
69  const std::string switch_device_name = std::string("AXIS_Switch_v1_0_0"); // Switch UIO device name
70  const std::string dyn_bit_sel_device_name = std::string("dynamic_bits_selector"); // Switch dhnamic bit selector device name
71  const std::string buffer_monitor_device_name = std::string("buffer_monitor"); // buffer monitor device name
72  const std::string default_dump_filename = std::string("FPGA_buffer_monitor_dump.dat");
73  const std::string default_rf_port_select = std::string("A_BALANCED");
74  const std::string default_gain_mode = std::string("slow_attack");
75  const std::string empty_string;
76  const double default_tx_attenuation_db = -10.0;
77  const double default_manual_gain_rx1 = 64.0;
78  const double default_manual_gain_rx2 = 64.0;
79  const uint64_t default_bandwidth = 12500000;
80 
81  // perform dynamic bit selection every 500 ms by default
82  const uint32_t Gain_control_period_ms = 500;
83  // check buffer overflow and perform buffer monitoring every 1s by default
84  const uint32_t buffer_monitor_period_ms = 1000;
85  // buffer overflow and buffer monitoring initial delay
86  const uint32_t buffer_monitoring_initial_delay_ms = 2000;
87  // sample block size when running in post-processing mode
88  const int sample_block_size = 16384;
89 
90  void run_DMA_process(const std::string &filename0,
91  const std::string &filename1,
92  uint64_t &samples_to_skip,
93  size_t &item_size,
94  int64_t &samples,
95  bool &repeat,
96  uint32_t &dma_buff_offset_pos,
98 
99  void run_dynamic_bit_selection_process();
100  void run_buffer_monitor_process();
101 
102  std::thread thread_file_to_dma;
103  std::thread thread_dynamic_bit_selection;
104  std::thread thread_buffer_monitor;
105 
106  std::shared_ptr<Fpga_Switch> switch_fpga;
107  std::shared_ptr<Fpga_dynamic_bit_selection> dynamic_bit_selection_fpga;
108  std::shared_ptr<Fpga_buffer_monitor> buffer_monitor_fpga;
109  std::shared_ptr<Fpga_DMA> dma_fpga;
110 
111  std::mutex dma_mutex;
112  std::mutex dynamic_bit_selection_mutex;
113  std::mutex buffer_monitor_mutex;
114 
116 
117  std::string gain_mode_rx1_;
118  std::string gain_mode_rx2_;
119  std::string rf_port_select_;
120  std::string filter_file_;
121  std::string filter_source_;
122  std::string filter_filename_;
123  std::string filename0_;
124  std::string filename1_;
125 
126  double rf_gain_rx1_;
127  double rf_gain_rx2_;
128  double scale_dds_dbfs_;
129  double phase_dds_deg_;
130  double tx_attenuation_db_;
131 
132  uint64_t freq0_; // frequency of local oscillator for ADRV9361-A 0
133  uint64_t freq1_; // frequency of local oscillator for ADRV9361-B (if present)
134  uint64_t sample_rate_;
135  uint64_t bandwidth_;
136  uint64_t samples_to_skip_;
137  int64_t samples_;
138  uint64_t freq_dds_tx_hz_;
139  uint64_t freq_rf_tx_hz_;
140  uint64_t tx_bandwidth_;
141 
142  float Fpass_;
143  float Fstop_;
144  uint32_t num_input_files_;
145  uint32_t dma_buff_offset_pos_;
146  uint32_t in_stream_;
147  uint32_t out_stream_;
148  int32_t switch_position_;
149 
150  size_t item_size_;
151 
152  bool enable_dds_lo_;
153  bool filter_auto_;
154  bool quadrature_;
155  bool rf_dc_;
156  bool bb_dc_;
157  bool rx1_enable_;
158  bool rx2_enable_;
159  bool enable_DMA_;
160  bool enable_dynamic_bit_selection_;
161  bool enable_ovf_check_buffer_monitor_active_;
162  bool dump_;
163  bool rf_shutdown_;
164  bool repeat_;
165 };
166 
167 
168 /** \} */
169 /** \} */
170 #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.
FPGA DMA control. This code is based in the Xilinx DMA proxy test application: https://github.com/Xilinx-Wiki-Projects/software-prototypes/tree/master/linux-user-space-dma/Software.
Switch that connects the HW accelerator queues to the analog front end or the DMA.
Dynamic bit selection in the received signal.