USRP_Server  2.0
A flexible, GPU-accelerated radio-frequency readout software.
USRP_demodulator.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef USRP_DEMODULATOR_INCLUDED
3 #define USRP_DEMODULATOR_INCLUDED
4 
5 #include "kernels.cuh"
9 
10 
14  public:
15 
16  //stores the signal processing parameters
17  param* parameters;
18 
21  float fcut;
22 
25  RX_buffer_demodulator(param* init_parameters, bool init_diagnostic = false);
26 
30  int process(float2** __restrict__ in, float2** __restrict__ out);
31 
33  void close();
34 
35  private:
36 
38  bool diagnostic;
39 
41  bool decimator_active;
42 
43  //pointer to the demodulation function
44  int (RX_buffer_demodulator::*process_ptr)(float2** __restrict__, float2** __restrict__);
45 
46  //pointer to the cleaning function
47  void (RX_buffer_demodulator::*clr_ptr)();
48 
49  //class to manage buffer pointers. Used to determine where to copy a buffer
50  buffer_helper *buf_setting;
51 
52  //helper class for post-pfb decimators
53  pfb_decimator_helper *pfb_decim_helper;
54 
55  //polyphase filter parameter wrapper + utility variables for buffer reminder
56  filter_param settings;
57 
58  //device pointer. will store the window.
59  float2* window;
60 
61  //gpu pointer to the wrapper of the filter parameters for the gpu kernels
62  filter_param *d_params;
63 
64  //gpu pointer to the parameter wrapper for the chirp demodulation kernel
65  //TODO this parameters notation for different functions is confusing. should be changed
66  chirp_parameter* d_parameter;
67 
68  //the total batching used in the fft.
69  //NOTE: last samples do not make sense; they are used to account for eventual buffers ratio irrationalities.
70  int batching;
71 
72  //device pointer accounting for host 2 device memory tranfer of the untouched input
73  float2 *raw_input;
74 
75  //device pointer for the output of the polyphase filter and the input of the fft
76  float2 *input;
77 
78  //device pointer to the output of the fft
79  float2 *output;
80 
81  //device pointer to a reordered portion of the fft output
82  //this buffer will be copied to the host
83  float2 *reduced_output;
84 
85  //host pointer to the result
86  float2 *result;
87 
88  //device pointer to the eventual decimated output
89  float2* decim_output;
90 
91  //plan of for the FFT
92  cufftHandle plan;
93 
94  //internal stream of the class. NOTE: only recursive operation are performed on this stream.
95  cudaStream_t internal_stream;
96 
97  //host version of the filter parameter struct
98  filter_param h_param;
99 
100  //where to copy the new buffer in case of spare buffer back insertion (see decimation & buffermove)
101  int spare_size;
102 
103  //VNA specific variable representing the number of points per tone
104  int ppt;
105 
106  //VNA specific variable representing the number of samples (half) to discard in each tone of the VNA
107  int side;
108 
109  //CPU bookeeping
110  unsigned long int last_index;
111 
112  //helper class for vna decimation
113  VNA_decimator_helper *vna_helper;
114 
115  //eventually used in decimation operations
116  cublasHandle_t handle;
117 
118  cufftComplex zero = {0.0f,0.0f};
119 
120  cufftComplex one = {1.0f,0.0f};
121 
122  float2* profile;
123 
124  //Direct demodulations frequency array on device
125  int* DIRECT_tone_frquencies;
126 
127  //Direct demodulations initial phases array on device
128  int* DIRECT_tone_phases;
129 
130  //Direct demodulator bookeeping.
131  size_t DIRECT_current_index;
132 
133  //Direct demodulation output size.
134  int DIRECT_output_size;
135 
136  //Temporary frequency array storage. Usefull to convert an STL vector to CUDA array with confidence.
137  int *DIRECT_tones;
138 
139  //Direct demodulation input
140  float2* direct_input;
141 
142  //Direct demodulation output
143  float2* direct_output;
144 
145  //wrap RX signal information in the apposite struct
146  chirp_parameter h_parameter;
147 
149  FIR** DIRECT_FIR;
150 
151  //host pointer to device FIR taps for direct demodulation
152  float2* fir_taps;
153 
155  float2* transposed;
156 
157  cuComplex onef = {1.f,0.f};
158 
159  cuComplex zerof = {0.f,0.f};
160 
162  size_t DIRECT_FIR_output_size;
163 
165  float2* FIR_output;
166 
168  int process_chirp(float2** __restrict__ input_buffer, float2** __restrict__ output_buffer);
169 
170  //process a packet with the pfb and set the variables for the next
171  // returns the valid length of the output packet
172  int process_pfb(float2** __restrict__ input_buffer, float2** __restrict__ output_buffer);
173 
174  int pfb_out = 0;
175 
176  int output_len = 0;
177 
178  //same process as the pfb but there is no tone selection and the buffer is bully downloaded
179  int process_pfb_spec(float2** __restrict__ input_buffer, float2** __restrict__ output_buffer);
180 
183  int process_nodsp(float2** __restrict__ input_buffer, float2** __restrict__ output_buffer);
184 
186  int process_direct(float2** __restrict__ input_buffer, float2** __restrict__ output_buffer);
187 
189  void close_direct();
190 
192  void close_nodsp();
193 
194  //clean up the pfb allocations
195  void close_pfb();
196 
197  //clean up the pfb full spectrum
198  void close_pfb_spec();
199 
200  //clean up the chirp demod allocation
201  void close_chirp();
202 
203  //converts general purpose parameters into kernel wrapper parameters on gpu.
204  //THIS ONLY TAKES CARE OF MULTI TONES MEASUREMENT
205  void upload_multitone_parameters();
206 
207 };
208 #endif
RX_buffer_demodulator(param *init_parameters, bool init_diagnostic=false)
Initialization method for the class called when a new command is received. iagnostic allows to print ...
Definition: fir.hpp:7
This class handles the DSP of the buffer coming from the the SDR. This is the class to implement to a...
float fcut
PFB cut-off frequency fo the window. 1.f is Nyquist at the higher sampling frequency. this parameter will be movoed to the param struct soon.
int process(float2 **__restrict__ in, float2 **__restrict__ out)
PAcket handler for DSP class. This method process information pointed by the in parameter and write t...
void close()
Wrapper to the correct cleaning function.