GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
fpga_buffer_monitor.h
Go to the documentation of this file.
1 /*!
2  * \file fpga_buffer_monitor.h
3  * \brief Check receiver buffer overflow and monitor the status of the receiver
4  * buffers.
5  * \authors
6  * <ul>
7  * <li> Marc Majoral, 2021. mmajoral(at)cttc.es
8  * </ul>
9  *
10  * Class that checks the receiver buffer overflow flags and monitors the status
11  * of the receiver buffers.
12  *
13  *
14  * -----------------------------------------------------------------------------
15  *
16  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
17  * This file is part of GNSS-SDR.
18  *
19  * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
20  * SPDX-License-Identifier: GPL-3.0-or-later
21  *
22  * -----------------------------------------------------------------------------
23  */
24 
25 #ifndef GNSS_SDR_FPGA_BUFFER_MONITOR_H
26 #define GNSS_SDR_FPGA_BUFFER_MONITOR_H
27 
28 #include <cstdint> // for int32_t
29 #include <fstream> // for std::ofstream
30 #include <string> // for std::string
31 
32 /** \addtogroup Signal_Source
33  * \{ */
34 /** \addtogroup Signal_Source_libs
35  * \{ */
36 
37 
38 /*!
39  * \brief Class that checks the receiver buffer overflow flags and monitors the
40  * status of the receiver buffers.
41  */
43 {
44 public:
45  /*!
46  * \brief Constructor
47  */
48  explicit Fpga_buffer_monitor(const std::string& device_name,
49  uint32_t num_freq_bands,
50  bool dump,
51  std::string dump_filename);
52 
53  /*!
54  * \brief Destructor
55  */
57 
58  /*!
59  * \brief This function checks buffer overflow and monitors the FPGA buffer status
60  */
62 
63 private:
64  static const size_t FPGA_PAGE_SIZE = 0x1000;
65  static const uint32_t test_register_writeval = 0x55AA;
66  static const uint32_t num_sapmples_per_buffer_element = 2;
67  // write addresses
68  static const uint32_t reset_overflow_flags_and_max_buff_size_reg_addr = 0;
69  // read-write addresses
70  static const uint32_t test_reg_addr = 7;
71  // read addresses
72  static const uint32_t current_buff_occ_freq_band_0_reg_addr = 0;
73  static const uint32_t current_buff_occ_freq_band_1_reg_addr = 1;
74  static const uint32_t max_buff_occ_freq_band_0_reg_addr = 2;
75  static const uint32_t max_buff_occ_freq_band_1_reg_addr = 3;
76  static const uint32_t overflow_flags_reg_addr = 4;
77  // FPGA-related constants
78  static const uint32_t overflow_freq_band_0_bit_pos = 1;
79  static const uint32_t overflow_freq_band_1_bit_pos = 2;
80 
81  int32_t buffer_monitor_test_register();
82  void close_device();
83 
84  std::string d_dump_filename;
85  std::ofstream d_dump_file;
86 
87  volatile unsigned* d_map_base; // driver memory map corresponding to the FPGA buffer monitor
88  int d_device_descriptor; // driver descriptor corresponding to the FPGA buffer monitor
89 
90  uint32_t d_num_freq_bands;
91 
92  uint32_t d_max_buff_occ_freq_band_0;
93  uint32_t d_max_buff_occ_freq_band_1;
94 
95  bool d_dump;
96 };
97 
98 
99 /** \} */
100 /** \} */
101 #endif // GNSS_SDR_FPGA_BUFFER_MONITOR_H
void check_buffer_overflow_and_monitor_buffer_status()
This function checks buffer overflow and monitors the FPGA buffer status.
Fpga_buffer_monitor(const std::string &device_name, uint32_t num_freq_bands, bool dump, std::string dump_filename)
Constructor.
Class that checks the receiver buffer overflow flags and monitors the status of the receiver buffers...
~Fpga_buffer_monitor()
Destructor.