USRP_Server  2.0
A flexible, GPU-accelerated radio-frequency readout software.
USRP_buffer_generator.hpp
Go to the documentation of this file.
1 /* @file USRP_buffer_generator.hpp
2  * @brief class prototypes for the buffer generator.
3  *
4  * Contains the prototype of the TX_buffer_generator class. Such class is used to generate the transmission buffer for the SDR.
5  *
6  * @bug The queue_prefiller method is not working as expected. This is non-critical for most applications
7  * @todo Test the behaviour of multiple class instances driving multiple USRPs/channels
8  *
9 */
10 #pragma once
11 #ifndef USRP_BUFFER_GEN_INCLUDED
12 #define USRP_BUFFER_GEN_INCLUDED
13 
14 #include "kernels.cuh"
15 #include "USRP_server_settings.hpp"
18 
21 
48 class TX_buffer_generator{
50 
51  public:
53  int buffer_len;
54 
56  param* parameters;
57  //initialization of the class
58  TX_buffer_generator(param* init_parameters);
59 
60  //wrapper to the correct get function
61  void get(float2** __restrict__ in);
62 
63  //wrapper to the correct cleaning function
64  void close();
65 
66  //pre-fill the queue with some packets. WARNING: for some reason it doesn't update the index parameter inside the called function
67  //causing the waveform to restart when get() method is called outside the class (TODO: why?)
68  int prefill_queue(tx_queue* queue, preallocator<float2>* memory, param* parameter_tx);
69 
70  private:
71 
72  //check if the requested buffer is a mixed type or if every buffer is the same
73  bool mixed_buffer_type;
74 
75  //CPU bookeeping
76  size_t last_index;
77 
78  //this variables are initialized and used only in case of TONES buffer generation.
79  size_t TONES_last_sample,TONES_buffer_len;
80 
81  //scale the chirp buffer
82  float scale;
83 
84  //can be a device or host buffer depending on the kind of buffer that is requested
85  float2* base_buffer;
86 
87  //high prioriry stream used for Async operation. Note: this stream is used only for recursive TX operations and not for initializations.
88  cudaStream_t internal_stream;
89 
90  //pointer to chirp parameters space on device memory
91  chirp_parameter* d_parameter;
92 
93  //chirp parameter
94  chirp_parameter h_parameter;
95 
96  //pointer to function to be assigned in function of the requested kind of buffer
97  //the final buffer will be always written in a float2* host buffer
98  void (TX_buffer_generator::*get_ptr)(float2** __restrict__);
99 
100  //pointer to the cleaning function
101  void (TX_buffer_generator::*clr_ptr)();
102 
103  //effective function to get the chirp buffer
104  void get_from_chirp(float2** __restrict__ target);
105 
106  void get_from_noise(float2** __restrict__ target);
107 
108  //effective function to get the tone buffer
109  void get_from_tones(float2** __restrict__ target);
110 
111  void get_from_noise();
112 
113  //versions of the cleaning function
114  void close_host();
115 
116  void close_device_chirp();
117 
118  void close_noise();
119 
120 };
121 
122 #endif