ngscopeclient 0.1-dev+51fbda87c
BERT.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
36#ifndef BERT_h
37#define BERT_h
38
44class BERT : public virtual Instrument
45{
46public:
47 BERT();
48 virtual ~BERT();
49
50 virtual unsigned int GetInstrumentTypes() const override;
51
54 {
57
60
63
66
69
72
75
78
81
84 };
85
87 // TX pattern generator configuration
88
89 static std::string GetPatternName(Pattern pat);
90 static Pattern GetPatternOfName(std::string name);
91
97 virtual Pattern GetTxPattern(size_t i) =0;
98
105 virtual void SetTxPattern(size_t i, Pattern pattern) =0;
106
112 virtual std::vector<Pattern> GetAvailableTxPatterns(size_t i) =0;
113
119 virtual bool IsCustomPatternPerChannel() =0;
120
126 virtual size_t GetCustomPatternLength() =0;
127
133 virtual void SetGlobalCustomPattern(uint64_t pattern) =0;
134
140 virtual uint64_t GetGlobalCustomPattern() =0;
141
142
144 // TX driver configuration
145
151 virtual bool GetTxInvert(size_t i) =0;
152
153
160 virtual void SetTxInvert(size_t i, bool invert) =0;
161
169 virtual std::vector<float> GetAvailableTxDriveStrengths(size_t i) =0;
170
176 virtual float GetTxDriveStrength(size_t i) =0;
177
184 virtual void SetTxDriveStrength(size_t i, float drive) =0;
185
192 virtual void SetTxEnable(size_t i, bool enable) =0;
193
199 virtual bool GetTxEnable(size_t i) =0;
200
211 virtual float GetTxPreCursor(size_t i) =0;
212
224 virtual void SetTxPreCursor(size_t i, float precursor) =0;
225
236 virtual float GetTxPostCursor(size_t i) =0;
237
249 virtual void SetTxPostCursor(size_t i, float postcursor) =0;
250
252 // RX input buffer configuration
253
259 virtual bool GetRxInvert(size_t i) =0;
260
261
268 virtual void SetRxInvert(size_t i, bool invert) =0;
269
277 virtual bool GetRxCdrLockState(size_t i) =0;
278
282 virtual bool HasRxCTLE() =0;
283
287 virtual std::vector<float> GetRxCTLEGainSteps() =0;
288
296 virtual size_t GetRxCTLEGainStep(size_t i) =0;
297
304 virtual void SetRxCTLEGainStep(size_t i, size_t step) =0;
305
307 // RX pattern checker configuration
308
314 virtual Pattern GetRxPattern(size_t i) =0;
315
322 virtual void SetRxPattern(size_t i, Pattern pattern) =0;
323
329 virtual std::vector<Pattern> GetAvailableRxPatterns(size_t i) =0;
330
332 // RX data readout
333
341 virtual int64_t GetExpectedBathtubCaptureTime(size_t i);
342
350 virtual int64_t GetExpectedEyeCaptureTime(size_t i);
351
357 virtual void MeasureHBathtub(size_t i) =0;
358
364 virtual void MeasureEye(size_t i) =0;
365
371 virtual void SetBERIntegrationLength(int64_t uis) =0;
372
376 virtual int64_t GetBERIntegrationLength() =0;
377
385 virtual void SetBERSamplingPoint(size_t i, int64_t dx, float dy) =0;
386
394 virtual void GetBERSamplingPoint(size_t i, int64_t& dx, float& dy) =0;
395
397 // RX capture status
398
404 virtual bool IsHBathtubScanInProgress(size_t i);
405
411 virtual bool IsEyeScanInProgress(size_t i);
412
418 virtual float GetScanProgress(size_t i);
419
421 // RX integration depth control
422
426 virtual bool HasConfigurableScanDepth();
427
435 virtual std::vector<int64_t> GetScanDepths(size_t i);
436
442 virtual int64_t GetScanDepth(size_t i);
443
450 virtual void SetScanDepth(size_t i, int64_t depth);
451
453 // Reference clock control
454
458 virtual bool HasRefclkIn() =0;
459
463 virtual bool HasRefclkOut() =0;
464
468 virtual size_t GetRefclkOutMux() =0;
469
475 virtual void SetRefclkOutMux(size_t i) =0;
476
482 virtual std::vector<std::string> GetRefclkOutMuxNames() =0;
483
487 virtual int64_t GetRefclkOutFrequency() =0;
488
492 virtual int64_t GetRefclkInFrequency() =0;
493
495 // Timebase
496
502 virtual bool IsDataRatePerChannel() =0;
503
509 virtual int64_t GetDataRate(size_t i) =0;
510
517 virtual void SetDataRate(size_t i, int64_t rate) =0;
518
522 virtual std::vector<int64_t> GetAvailableDataRates() =0;
523
529 virtual void SetUseExternalRefclk(bool external) =0;
530
536 virtual bool GetUseExternalRefclk() =0;
537
539 // Configuration storage
540
541protected:
548 void DoSerializeConfiguration(YAML::Node& node, IDTable& table);
549
557 void DoLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap);
558
567 void DoPreLoadConfiguration(int version, const YAML::Node& node, IDTable& idmap, ConfigWarningList& list);
568};
569
570#include "BERTInputChannel.h"
571#include "BERTOutputChannel.h"
572
573#endif
Declaration of BERTInputChannel.
Declaration of BERTOutputChannel.
Base class for bit error rate tester drivers.
Definition: BERT.h:45
virtual bool IsEyeScanInProgress(size_t i)
Returns true if an eye scan is in progress.
Definition: BERT.cpp:175
virtual float GetTxPostCursor(size_t i)=0
Get the post-cursor equalizer tap for a channel.
virtual bool IsDataRatePerChannel()=0
Determines whether the TX/RX clock is a per-instrument or per-channel setting.
virtual void SetTxInvert(size_t i, bool invert)=0
Sets the transmit invert flag for a channel.
virtual int64_t GetScanDepth(size_t i)
Get the configured scan depth for a channel, in UIs per sample/pixel.
Definition: BERT.cpp:150
virtual void SetTxPreCursor(size_t i, float precursor)=0
Set the pre-cursor equalizer tap for a channel.
virtual Pattern GetRxPattern(size_t i)=0
Gets the currently selected receive pattern for a channel.
virtual bool GetRxInvert(size_t i)=0
Gets the transmit invert flag for a channel.
virtual Pattern GetTxPattern(size_t i)=0
Gets the currently selected transmit pattern for a channel.
virtual float GetTxDriveStrength(size_t i)=0
Get the drive strength for a channel.
virtual int64_t GetExpectedBathtubCaptureTime(size_t i)
Returns the expected time, in femtoseconds, to complete a bathtub scan with the current settings.
Definition: BERT.cpp:160
virtual void SetTxPostCursor(size_t i, float postcursor)=0
Set the post-cursor equalizer tap for a channel.
virtual size_t GetCustomPatternLength()=0
Returns the number of bits in a custom pattern (may change with line rate)
static std::string GetPatternName(Pattern pat)
Converts a Pattern enum into a strnig.
Definition: BERT.cpp:64
virtual void SetGlobalCustomPattern(uint64_t pattern)=0
Sets the global custom pattern (only valid if IsCustomPatternPerChannel returns false)
virtual std::vector< int64_t > GetAvailableDataRates()=0
Gets the list of available data rates, in symbols/sec.
virtual bool GetUseExternalRefclk()=0
Sets the reference clock source.
void DoPreLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap, ConfigWarningList &list)
Validate instrument and channel configuration from a save file.
Definition: BERT.cpp:381
virtual bool IsCustomPatternPerChannel()=0
Determines whether custom patterns are settable per channel, or shared by the whole device.
virtual bool GetTxEnable(size_t i)=0
Gets the transmit enable flag for a channel.
virtual void SetUseExternalRefclk(bool external)=0
Sets the reference clock source (internal or external)
virtual int64_t GetDataRate(size_t i)=0
Gets the currently selected line rate (in symbols/sec)
virtual uint64_t GetGlobalCustomPattern()=0
Gets the global custom pattern (only valid if IsCustomPatternPerChannel returns false)
virtual void SetRxPattern(size_t i, Pattern pattern)=0
Sets the receive pattern for the selected channel.
virtual float GetScanProgress(size_t i)
Gets the estimated completion status (0-1) of the current scan.
Definition: BERT.cpp:180
virtual std::vector< float > GetRxCTLEGainSteps()=0
Get the list of available RX CTLE gain values (in dB)
void DoLoadConfiguration(int version, const YAML::Node &node, IDTable &idmap)
Load instrument and channel configuration from a save file.
Definition: BERT.cpp:318
virtual std::vector< Pattern > GetAvailableRxPatterns(size_t i)=0
Gets the list of available receive patterns for a channel.
virtual void MeasureHBathtub(size_t i)=0
Acquires a bathtub curve.
virtual void SetBERIntegrationLength(int64_t uis)=0
Set the integration period for BER measurements.
virtual void MeasureEye(size_t i)=0
Acquires an eye pattern.
virtual void SetTxDriveStrength(size_t i, float drive)=0
Set the drive strength for a channel.
virtual void SetRxInvert(size_t i, bool invert)=0
Sets the receive invert flag for a channel.
virtual bool HasRefclkOut()=0
Returns true if this instrument has a reference clock output port.
virtual void SetTxPattern(size_t i, Pattern pattern)=0
Sets the transmit pattern for the selected channel.
virtual std::vector< std::string > GetRefclkOutMuxNames()=0
Gets the list of available reference clock mux settings.
virtual void SetRefclkOutMux(size_t i)=0
Sets the reference clock output mux.
Pattern
Set of patterns we can generate or accept.
Definition: BERT.h:54
@ PATTERN_PRBS7
Standard PRBS-7 x^7 + x^6 + 1.
Definition: BERT.h:56
@ PATTERN_CUSTOM
Custom output pattern (not valid for input)
Definition: BERT.h:74
@ PATTERN_CLOCK_DIV2
Clock at half the symbol rate (1-0-1-0 pattern)
Definition: BERT.h:77
@ PATTERN_AUTO
Autodetect input pattern (not valid for output)
Definition: BERT.h:83
@ PATTERN_PRBS31
Standard PRBS-31 x^31 + x^28 + 1.
Definition: BERT.h:71
@ PATTERN_PRBS15
Standard PRBS-15 x^15 + x^14 + 1.
Definition: BERT.h:65
@ PATTERN_CLOCK_DIV32
Clock at 1/32 the symbol rate (16 0s followed by 16 1s)
Definition: BERT.h:80
@ PATTERN_PRBS23
Standard PRBS-23 x^23 + x^18 + 1.
Definition: BERT.h:68
@ PATTERN_PRBS11
Standard PRBS-11 x^11 + x^9 + 1.
Definition: BERT.h:62
@ PATTERN_PRBS9
Standard PRBS-9 x^9 + x^5 + 1.
Definition: BERT.h:59
virtual int64_t GetRefclkOutFrequency()=0
Gets the currently selected refclk out frequency, in Hz.
virtual bool GetTxInvert(size_t i)=0
Gets the transmit invert flag for a channel.
virtual void SetTxEnable(size_t i, bool enable)=0
Sets the transmit enable flag for a channel.
virtual bool HasRefclkIn()=0
Returns true if this instrument has a reference clock input port.
virtual int64_t GetRefclkInFrequency()=0
Gets the refclk in frequency, in Hz, required to generate the currently selected data rate.
virtual bool IsHBathtubScanInProgress(size_t i)
Returns true if a horizontal bathtub scan is in progress.
Definition: BERT.cpp:170
virtual void GetBERSamplingPoint(size_t i, int64_t &dx, float &dy)=0
Get the sampling point for BER measurements.
virtual int64_t GetExpectedEyeCaptureTime(size_t i)
Returns the expected time, in femtoseconds, to complete an eye scan with the current settings.
Definition: BERT.cpp:165
virtual int64_t GetBERIntegrationLength()=0
Get the integration period for BER measurements.
virtual size_t GetRxCTLEGainStep(size_t i)=0
Gets the currently selected RX CTLE gain index.
virtual float GetTxPreCursor(size_t i)=0
Get the pre-cursor equalizer tap for a channel.
virtual std::vector< Pattern > GetAvailableTxPatterns(size_t i)=0
Gets the list of available transmit patterns for a channel.
virtual void SetScanDepth(size_t i, int64_t depth)
Set the configured scan depth for a channel.
Definition: BERT.cpp:155
void DoSerializeConfiguration(YAML::Node &node, IDTable &table)
Serializes this BERT's configuration to a YAML node.
Definition: BERT.cpp:188
virtual void SetBERSamplingPoint(size_t i, int64_t dx, float dy)=0
Set the sampling point for BER measurements.
virtual bool HasConfigurableScanDepth()
Determines whether this instrument has configurable integration depth for eye / bathtub scans.
Definition: BERT.cpp:139
virtual unsigned int GetInstrumentTypes() const override
Returns a bitfield describing the set of instrument types that this instrument supports.
Definition: BERT.cpp:54
virtual bool HasRxCTLE()=0
Determines whether the input buffer has a continuous-time linear equalizer.
static Pattern GetPatternOfName(std::string name)
Converts a string name into a Pattern enum.
Definition: BERT.cpp:108
virtual size_t GetRefclkOutMux()=0
Gets the currently selected reference clock output mux setting.
virtual bool GetRxCdrLockState(size_t i)=0
Gets the RX CDR lock state (true=lock, false=unlock)
virtual void SetRxCTLEGainStep(size_t i, size_t step)=0
Sets the RX CTLE gain index.
virtual std::vector< int64_t > GetScanDepths(size_t i)
Returns the list of integration depths for eye / bathtub scans.
Definition: BERT.cpp:144
virtual std::vector< float > GetAvailableTxDriveStrengths(size_t i)=0
Gets the list of available drive strengths (in volts) for a channel.
virtual void SetDataRate(size_t i, int64_t rate)=0
Sets the data rate (in symbols/sec)
All warnings generated by a configuration we're in the process of loading.
Definition: ConfigWarningList.h:90
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition: IDTable.h:49
An arbitrary lab instrument. Oscilloscope, LA, PSU, DMM, etc.
Definition: Instrument.h:58