3030 @file
3131 @author Andrew D. Zonenberg
3232 @brief Implementation of TestWaveformSource
33+
34+ @ingroup core
3335 */
3436#include " scopehal.h"
3537#include " TestWaveformSource.h"
@@ -40,6 +42,13 @@ using namespace std;
4042// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4143// Construction / destruction
4244
45+ /* *
46+ @brief Initializes a TestWaveformSource
47+
48+ @param rng Random number generator instance that the source should use.
49+ The source maintains a persistent reference to the RNG so it must remain valid
50+ for the entire lifespan of the TestWaveformSource.
51+ */
4352TestWaveformSource::TestWaveformSource (minstd_rand& rng)
4453 : m_rng(rng)
4554 , m_cachedBinSize(0 )
@@ -69,7 +78,15 @@ TestWaveformSource::~TestWaveformSource()
6978// Signal generation
7079
7180/* *
72- @brief Generates a unit step
81+ @brief Generates a step waveform
82+
83+ The waveform starts at vlo for half of the total duration, the instantly transitions to vhi and remains at vhi
84+ for the remainder of the total length.
85+
86+ @param vlo Starting voltage
87+ @param vhi Ending voltage
88+ @param sampleperiod Interval, in femtoseconds, between samples
89+ @param depth Number of points in the waveform
7390 */
7491WaveformBase* TestWaveformSource::GenerateStep (
7592 float vlo,
@@ -94,21 +111,28 @@ WaveformBase* TestWaveformSource::GenerateStep(
94111}
95112
96113/* *
97- @brief Generates a sinewave with a bit of extra noise added
114+ @brief Generates a sinewave with AWGN added
115+
116+ @param amplitude P-P amplitude of the waveform
117+ @param startphase Starting phase in radians
118+ @param period Period of the sine, in femtoseconds
119+ @param sampleperiod Interval between samples, in femtoseconds
120+ @param depth Total number of samples to generate
121+ @param noise_stdev Standard deviation of the AWGN
98122 */
99123WaveformBase* TestWaveformSource::GenerateNoisySinewave (
100124 float amplitude,
101125 float startphase,
102126 float period,
103127 int64_t sampleperiod,
104128 size_t depth,
105- float noise_amplitude )
129+ float noise_stdev )
106130{
107131 auto ret = new UniformAnalogWaveform (" NoisySine" );
108132 ret->m_timescale = sampleperiod;
109133 ret->Resize (depth);
110134
111- normal_distribution<> noise (0 , noise_amplitude );
135+ normal_distribution<> noise (0 , noise_stdev );
112136
113137 float samples_per_cycle = period * 1.0 / sampleperiod;
114138 float radians_per_sample = 2 * M_PI / samples_per_cycle;
@@ -133,13 +157,13 @@ WaveformBase* TestWaveformSource::GenerateNoisySinewaveMix(
133157 float period2,
134158 int64_t sampleperiod,
135159 size_t depth,
136- float noise_amplitude )
160+ float noise_stdev )
137161{
138162 auto ret = new UniformAnalogWaveform (" NoisySineMix" );
139163 ret->m_timescale = sampleperiod;
140164 ret->Resize (depth);
141165
142- normal_distribution<> noise (0 , noise_amplitude );
166+ normal_distribution<> noise (0 , noise_stdev );
143167
144168 float radians_per_sample1 = 2 * M_PI * sampleperiod / period1;
145169 float radians_per_sample2 = 2 * M_PI * sampleperiod / period2;
@@ -166,7 +190,7 @@ WaveformBase* TestWaveformSource::GeneratePRBS31(
166190 int64_t sampleperiod,
167191 size_t depth,
168192 bool lpf,
169- float noise_amplitude
193+ float noise_stdev
170194 )
171195{
172196 auto ret = new UniformAnalogWaveform (" PRBS31" );
@@ -211,7 +235,7 @@ WaveformBase* TestWaveformSource::GeneratePRBS31(
211235 }
212236 }
213237
214- DegradeSerialData (ret, sampleperiod, depth, lpf, noise_amplitude , cmdBuf, queue);
238+ DegradeSerialData (ret, sampleperiod, depth, lpf, noise_stdev , cmdBuf, queue);
215239
216240 return ret;
217241}
@@ -224,7 +248,7 @@ WaveformBase* TestWaveformSource::Generate8b10b(
224248 int64_t sampleperiod,
225249 size_t depth,
226250 bool lpf,
227- float noise_amplitude )
251+ float noise_stdev )
228252{
229253 auto ret = new UniformAnalogWaveform (" 8B10B" );
230254 ret->m_timescale = sampleperiod;
@@ -275,7 +299,7 @@ WaveformBase* TestWaveformSource::Generate8b10b(
275299 }
276300 }
277301
278- DegradeSerialData (ret, sampleperiod, depth, lpf, noise_amplitude , cmdBuf, queue);
302+ DegradeSerialData (ret, sampleperiod, depth, lpf, noise_stdev , cmdBuf, queue);
279303
280304 return ret;
281305}
@@ -290,15 +314,15 @@ void TestWaveformSource::DegradeSerialData(
290314 int64_t sampleperiod,
291315 size_t depth,
292316 bool lpf,
293- float noise_amplitude ,
317+ float noise_stdev ,
294318 vk::raii::CommandBuffer& cmdBuf,
295319 shared_ptr<QueueHandle> queue)
296320{
297321 // assume input came from CPU
298322 cap->MarkModifiedFromCpu ();
299323
300324 // RNGs
301- normal_distribution<> noise (0 , noise_amplitude );
325+ normal_distribution<> noise (0 , noise_stdev );
302326
303327 // Prepare for second pass: reallocate FFT buffer if sample depth changed
304328 const size_t npoints = next_pow2 (depth);
0 commit comments