Loading...
Searching...
No Matches
siggen_block_control.hpp
Go to the documentation of this file.
//
// Copyright 2020 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <uhd/rfnoc/noc_block_base.hpp>
#include <uhd/utils/math.hpp>
#include <complex>
namespace uhd { namespace rfnoc {
enum class siggen_waveform { CONSTANT, SINE_WAVE, NOISE };
class UHD_API siggen_block_control : public noc_block_base
{
public:
RFNOC_DECLARE_BLOCK(siggen_block_control);
static const uint32_t REG_BLOCK_SIZE;
static const uint32_t REG_ENABLE_OFFSET;
static const uint32_t REG_SPP_OFFSET;
static const uint32_t REG_WAVEFORM_OFFSET;
static const uint32_t REG_GAIN_OFFSET;
static const uint32_t REG_CONSTANT_OFFSET;
static const uint32_t REG_PHASE_INC_OFFSET;
static const uint32_t REG_CARTESIAN_OFFSET;
virtual void set_enable(const bool enable, const size_t port) = 0;
virtual bool get_enable(const size_t port) const = 0;
virtual void set_waveform(const siggen_waveform type, const size_t port) = 0;
virtual siggen_waveform get_waveform(const size_t port) const = 0;
virtual void set_amplitude(const double amplitude, const size_t port) = 0;
virtual double get_amplitude(const size_t port) const = 0;
virtual void set_constant(const std::complex<double> constant, const size_t port) = 0;
virtual std::complex<double> get_constant(const size_t port) const = 0;
virtual void set_sine_phase_increment(const double phase_inc, const size_t port) = 0;
virtual double get_sine_phase_increment(const size_t port) const = 0;
virtual void set_samples_per_packet(const size_t spp, const size_t port) = 0;
virtual size_t get_samples_per_packet(const size_t port) const = 0;
inline void set_sine_frequency(
const double frequency, const double sample_rate, const size_t port)
{
if (sample_rate <= 0.0) {
throw uhd::value_error("sample_rate must be > 0.0");
}
const double phase_inc = (frequency / sample_rate) * 2.0 * uhd::math::PI;
if (phase_inc < -uhd::math::PI || phase_inc > uhd::math::PI) {
throw uhd::value_error("frequency must be in [-samp_rate/2, samp_rate/2]");
}
set_sine_phase_increment(phase_inc, port);
}
};
}} // namespace uhd::rfnoc
uhd::rfnoc::noc_block_base::noc_block_base
noc_block_base(make_args_ptr make_args)
uhd::rfnoc::siggen_block_control
Definition siggen_block_control.hpp:29
uhd::rfnoc::siggen_block_control::set_enable
virtual void set_enable(const bool enable, const size_t port)=0
uhd::rfnoc::siggen_block_control::REG_BLOCK_SIZE
static const uint32_t REG_BLOCK_SIZE
Definition siggen_block_control.hpp:33
uhd::rfnoc::siggen_block_control::REG_PHASE_INC_OFFSET
static const uint32_t REG_PHASE_INC_OFFSET
Definition siggen_block_control.hpp:39
uhd::rfnoc::siggen_block_control::set_sine_frequency
void set_sine_frequency(const double frequency, const double sample_rate, const size_t port)
Definition siggen_block_control.hpp:192
uhd::rfnoc::siggen_block_control::get_samples_per_packet
virtual size_t get_samples_per_packet(const size_t port) const =0
uhd::rfnoc::siggen_block_control::get_constant
virtual std::complex< double > get_constant(const size_t port) const =0
uhd::rfnoc::siggen_block_control::set_amplitude
virtual void set_amplitude(const double amplitude, const size_t port)=0
uhd::rfnoc::siggen_block_control::REG_SPP_OFFSET
static const uint32_t REG_SPP_OFFSET
Definition siggen_block_control.hpp:35
uhd::rfnoc::siggen_block_control::get_sine_phase_increment
virtual double get_sine_phase_increment(const size_t port) const =0
uhd::rfnoc::siggen_block_control::REG_CARTESIAN_OFFSET
static const uint32_t REG_CARTESIAN_OFFSET
Definition siggen_block_control.hpp:40
uhd::rfnoc::siggen_block_control::REG_GAIN_OFFSET
static const uint32_t REG_GAIN_OFFSET
Definition siggen_block_control.hpp:37
uhd::rfnoc::siggen_block_control::REG_WAVEFORM_OFFSET
static const uint32_t REG_WAVEFORM_OFFSET
Definition siggen_block_control.hpp:36
uhd::rfnoc::siggen_block_control::get_amplitude
virtual double get_amplitude(const size_t port) const =0
uhd::rfnoc::siggen_block_control::get_waveform
virtual siggen_waveform get_waveform(const size_t port) const =0
uhd::rfnoc::siggen_block_control::set_constant
virtual void set_constant(const std::complex< double > constant, const size_t port)=0
uhd::rfnoc::siggen_block_control::get_enable
virtual bool get_enable(const size_t port) const =0
uhd::rfnoc::siggen_block_control::set_samples_per_packet
virtual void set_samples_per_packet(const size_t spp, const size_t port)=0
uhd::rfnoc::siggen_block_control::set_sine_phase_increment
virtual void set_sine_phase_increment(const double phase_inc, const size_t port)=0
uhd::rfnoc::siggen_block_control::REG_ENABLE_OFFSET
static const uint32_t REG_ENABLE_OFFSET
Definition siggen_block_control.hpp:34
uhd::rfnoc::siggen_block_control::RFNOC_DECLARE_BLOCK
RFNOC_DECLARE_BLOCK(siggen_block_control)
uhd::rfnoc::siggen_block_control::REG_CONSTANT_OFFSET
static const uint32_t REG_CONSTANT_OFFSET
Definition siggen_block_control.hpp:38
uhd::rfnoc::siggen_block_control::set_waveform
virtual void set_waveform(const siggen_waveform type, const size_t port)=0
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
math.hpp
uhd::rfnoc
Definition actions.hpp:24
uhd::rfnoc::siggen_waveform
siggen_waveform
Definition siggen_block_control.hpp:16
uhd::rfnoc::siggen_waveform::SINE_WAVE
@ SINE_WAVE
Definition siggen_block_control.hpp:16
uhd::rfnoc::siggen_waveform::NOISE
@ NOISE
Definition siggen_block_control.hpp:16
uhd::rfnoc::siggen_waveform::CONSTANT
@ CONSTANT
Definition siggen_block_control.hpp:16
uhd
Definition build_info.hpp:12
noc_block_base.hpp
uhd::value_error
Definition exception.hpp:108