ngscopeclient 0.1-dev+51fbda87c
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TestWaveformSource Class Reference

Helper class for generating test waveforms. More...

#include <TestWaveformSource.h>

Collaboration diagram for TestWaveformSource:
Collaboration graph
[legend]

Public Member Functions

 TestWaveformSource (std::minstd_rand &rng)
 
 TestWaveformSource (const TestWaveformSource &)=delete
 
TestWaveformSourceoperator= (const TestWaveformSource &)=delete
 
WaveformBaseGenerateNoisySinewave (float amplitude, float startphase, float period, int64_t sampleperiod, size_t depth, float noise_stdev=0.01, std::function< void(float)> downloadCallback=nullptr)
 Generates a sinewave with AWGN added. More...
 
WaveformBaseGenerateNoisySinewaveSum (float amplitude, float startphase1, float startphase2, float period1, float period2, int64_t sampleperiod, size_t depth, float noise_stdev=0.01, std::function< void(float)> downloadCallback=nullptr)
 Generates a sum of two sinewaves with AWGN added. More...
 
WaveformBaseGeneratePRBS31 (vk::raii::CommandBuffer &cmdBuf, std::shared_ptr< QueueHandle > queue, float amplitude, float period, int64_t sampleperiod, size_t depth, bool lpf=true, float noise_stdev=0.01, std::function< void(float)> downloadCallback=nullptr)
 Generates a PRBS-31 waveform through a lossy channel with AWGN. More...
 
WaveformBaseGenerate8b10b (vk::raii::CommandBuffer &cmdBuf, std::shared_ptr< QueueHandle > queue, float amplitude, float period, int64_t sampleperiod, size_t depth, bool lpf=true, float noise_stdev=0.01, std::function< void(float)> downloadCallback=nullptr)
 Generates a K28.5 D16.2 (1000base-X / SGMII idle) waveform through a lossy channel with AWGN. More...
 
WaveformBaseGenerateStep (float vlo, float vhi, int64_t sampleperiod, size_t depth)
 Generates a step waveform. More...
 
void DegradeSerialData (UniformAnalogWaveform *cap, int64_t sampleperiod, size_t depth, bool lpf, float noise_stdev, vk::raii::CommandBuffer &cmdBuf, std::shared_ptr< QueueHandle > queue)
 Takes an idealized serial data stream and turns it into something less pretty. More...
 

Protected Member Functions

void InterpolateSparameters (float bin_hz, size_t nouts)
 Recalculate the cached S-parameters used for channel emulation. More...
 

Protected Attributes

std::minstd_rand & m_rng
 Random number generator.
 
AcceleratorBuffer< float > m_forwardInBuf
 Input buffer for FFTs.
 
AcceleratorBuffer< float > m_forwardOutBuf
 Output buffer for FFTs.
 
AcceleratorBuffer< float > m_reverseOutBuf
 Output buffer for IFFTs.
 
std::unique_ptr< VulkanFFTPlanm_vkForwardPlan
 FFT plan.
 
std::unique_ptr< VulkanFFTPlanm_vkReversePlan
 Inverse FFT plan.
 
double m_cachedBinSize
 FFT bin size, in Hz.
 
AcceleratorBuffer< float > m_resampledSparamSines
 Serial channel S-parameter real part.
 
AcceleratorBuffer< float > m_resampledSparamCosines
 Serial channel S-parameter imaginary part.
 
ComputePipeline m_rectangularComputePipeline
 Compute pipeline for our window function.
 
ComputePipeline m_channelEmulationComputePipeline
 Compute pipeline for channel emulation.
 
SParameters m_sparams
 S-parameters of the channel.
 
size_t m_cachedNumPoints
 FFT point count as of last cache update.
 
size_t m_cachedRawSize
 Input size of FFT as of last cache update.
 

Detailed Description

Helper class for generating test waveforms.

Used by DemoOscilloscope as well as various unit tests

Member Function Documentation

◆ DegradeSerialData()

void TestWaveformSource::DegradeSerialData ( UniformAnalogWaveform cap,
int64_t  sampleperiod,
size_t  depth,
bool  lpf,
float  noise_stdev,
vk::raii::CommandBuffer &  cmdBuf,
std::shared_ptr< QueueHandle queue 
)

Takes an idealized serial data stream and turns it into something less pretty.

The channel is a combination of a lossy S-parameter channel (approximately 300mm of microstrip on Shengyi S1000-2M) and AWGN with configurable standard deviation

Parameters
capWaveform to degrade
sampleperiodPeriod of the input waveform
depthNumber of points in the input waveform
lpfTrue to perform channel emulation, false to only add noise
noise_stdevStandard deviation of the AWGN, in volts
cmdBufVulkan command buffer to use for channel emulation
queueVulkan queue to use for channel emulation

◆ Generate8b10b()

WaveformBase * TestWaveformSource::Generate8b10b ( vk::raii::CommandBuffer &  cmdBuf,
std::shared_ptr< QueueHandle queue,
float  amplitude,
float  period,
int64_t  sampleperiod,
size_t  depth,
bool  lpf = true,
float  noise_stdev = 0.01,
std::function< void(float)>  downloadCallback = nullptr 
)

Generates a K28.5 D16.2 (1000base-X / SGMII idle) waveform through a lossy channel with AWGN.

Parameters
cmdBufVulkan command buffer to use for channel emulation
queueVulkan queue to use for channel emulation
amplitudeP-P amplitude of the waveform in volts
periodUnit interval, in femtoseconds
sampleperiodInterval between samples, in femtoseconds
depthTotal number of samples to generate
lpfEmulate a lossy channel if true, no channel emulation if false
noise_stdevStandard deviation of the AWGN in volts
downloadCallbackCallback for download progress

◆ GenerateNoisySinewave()

WaveformBase * TestWaveformSource::GenerateNoisySinewave ( float  amplitude,
float  startphase,
float  period,
int64_t  sampleperiod,
size_t  depth,
float  noise_stdev = 0.01,
std::function< void(float)>  downloadCallback = nullptr 
)

Generates a sinewave with AWGN added.

Parameters
amplitudeP-P amplitude of the waveform in volts
startphaseStarting phase in radians
periodPeriod of the sine, in femtoseconds
sampleperiodInterval between samples, in femtoseconds
depthTotal number of samples to generate
noise_stdevStandard deviation of the AWGN in volts
downloadCallbackCallback for download progress

◆ GenerateNoisySinewaveSum()

WaveformBase * TestWaveformSource::GenerateNoisySinewaveSum ( float  amplitude,
float  startphase1,
float  startphase2,
float  period1,
float  period2,
int64_t  sampleperiod,
size_t  depth,
float  noise_stdev = 0.01,
std::function< void(float)>  downloadCallback = nullptr 
)

Generates a sum of two sinewaves with AWGN added.

Parameters
amplitudeP-P amplitude of the waveform in volts
startphase1Starting phase of the first sine in radians
startphase2Starting phase of the second sine in radians
period1Period of the first sine, in femtoseconds
period2Period of the second sine, in femtoseconds
sampleperiodInterval between samples, in femtoseconds
depthTotal number of samples to generate
noise_stdevStandard deviation of the AWGN in volts
downloadCallbackCallback for download progress

◆ GeneratePRBS31()

WaveformBase * TestWaveformSource::GeneratePRBS31 ( vk::raii::CommandBuffer &  cmdBuf,
std::shared_ptr< QueueHandle queue,
float  amplitude,
float  period,
int64_t  sampleperiod,
size_t  depth,
bool  lpf = true,
float  noise_stdev = 0.01,
std::function< void(float)>  downloadCallback = nullptr 
)

Generates a PRBS-31 waveform through a lossy channel with AWGN.

Parameters
cmdBufVulkan command buffer to use for channel emulation
queueVulkan queue to use for channel emulation
amplitudeP-P amplitude of the waveform in volts
periodUnit interval, in femtoseconds
sampleperiodInterval between samples, in femtoseconds
depthTotal number of samples to generate
lpfEmulate a lossy channel if true, no channel emulation if false
noise_stdevStandard deviation of the AWGN in volts
downloadCallbackCallback for download progress

◆ GenerateStep()

WaveformBase * TestWaveformSource::GenerateStep ( float  vlo,
float  vhi,
int64_t  sampleperiod,
size_t  depth 
)

Generates a step waveform.

The waveform starts at vlo for half of the total duration, the instantly transitions to vhi and remains at vhi for the remainder of the total length.

Parameters
vloStarting voltage
vhiEnding voltage
sampleperiodInterval, in femtoseconds, between samples
depthNumber of points in the waveform

◆ InterpolateSparameters()

void TestWaveformSource::InterpolateSparameters ( float  bin_hz,
size_t  nouts 
)
protected

Recalculate the cached S-parameters used for channel emulation.

Parameters
bin_hzSize of each FFT bin, in Hz
noutsNumber of FFT bins

The documentation for this class was generated from the following files: