ngscopeclient 0.1-dev+51fbda87c
BERTInputChannel.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
37#ifndef BERTInputChannel_h
38#define BERTInputChannel_h
39
40class BERT;
41#include "EyeMask.h"
42
51{
52public:
53
55 const std::string& hwname,
56 std::weak_ptr<BERT> bert,
57 const std::string& color = "#808080",
58 size_t index = 0);
59
60 virtual ~BERTInputChannel();
61
62 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
63 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
64
66 std::weak_ptr<BERT> GetBERT() const
67 { return m_bert; }
68
70 // All of these inline accessors don't null-check because the channel is contained by the parent BERT
71 // (and thus it's impossible for us to outlive it)
72
74 bool GetInvert()
75 { return m_bert.lock()->GetRxInvert(GetIndex()); }
76
82 void SetInvert(bool invert)
83 { m_bert.lock()->SetRxInvert(GetIndex(), invert); }
84
87 { return m_bert.lock()->GetRxCdrLockState(GetIndex()); }
88
95 { m_bert.lock()->SetRxPattern(GetIndex(), pattern); }
96
99 { return m_bert.lock()->GetRxPattern(GetIndex()); }
100
102 std::vector<BERT::Pattern> GetAvailablePatterns()
103 { return m_bert.lock()->GetAvailableRxPatterns(GetIndex()); }
104
110 int64_t GetScanDepth()
111 { return m_bert.lock()->GetScanDepth(GetIndex()); }
112
114 std::vector<int64_t> GetScanDepths()
115 { return m_bert.lock()->GetScanDepths(GetIndex()); }
116
122 void SetScanDepth(int64_t depth)
123 { m_bert.lock()->SetScanDepth(GetIndex(), depth); }
124
127 {
130
133
136
139 };
140
143 { return StreamDescriptor(this, STREAM_HBATHTUB); }
144
147 { return StreamDescriptor(this, STREAM_EYE); }
148
151 { return StreamDescriptor(this, STREAM_BER); }
152
154 bool HasCTLE()
155 { return m_bert.lock()->HasRxCTLE(); }
156
158 std::vector<float> GetCTLEGainSteps()
159 { return m_bert.lock()->GetRxCTLEGainSteps(); }
160
167 { return m_bert.lock()->GetRxCTLEGainStep(GetIndex()); }
168
176 void SetCTLEGainStep(size_t step)
177 { m_bert.lock()->SetRxCTLEGainStep(GetIndex(), step); }
178
185 void SetBERSamplingPoint(int64_t dx, float dy)
186 { m_bert.lock()->SetBERSamplingPoint(GetIndex(), dx, dy); }
187
194 void GetBERSamplingPoint(int64_t& dx, float& dy)
195 { m_bert.lock()->GetBERSamplingPoint(GetIndex(), dx, dy); }
196
200 int64_t GetDataRate()
201 { return m_bert.lock()->GetDataRate(GetIndex()); }
202
213 void SetDataRate(int64_t rate)
214 { m_bert.lock()->SetDataRate(GetIndex(), rate); }
215
217 std::string GetMaskFile()
218 { return m_maskFile; }
219
225 void SetMaskFile(const std::string& fname);
226
229 { return m_mask; }
230
231 virtual PhysicalConnector GetPhysicalConnector() override;
232
241 { return m_bert.lock()->GetExpectedBathtubCaptureTime(GetIndex()); }
242
251 { return m_bert.lock()->GetExpectedEyeCaptureTime(GetIndex()); }
252
259 { return m_bert.lock()->IsEyeScanInProgress(GetIndex()); }
260
267 { return m_bert.lock()->GetScanProgress(GetIndex()); }
268
275 { return m_bert.lock()->IsHBathtubScanInProgress(GetIndex()); }
276
278 // Vertical scaling and stream management
279
280public:
281 virtual void ClearStreams() override;
282 virtual size_t AddStream(Unit yunit, const std::string& name, Stream::StreamType stype, uint8_t flags = 0) override;
283
284 virtual float GetVoltageRange(size_t stream) override;
285 virtual void SetVoltageRange(float range, size_t stream) override;
286
287 virtual float GetOffset(size_t stream) override;
288 virtual void SetOffset(float offset, size_t stream) override;
289
290protected:
291
293 std::vector<float> m_ranges;
294
296 std::vector<float> m_offsets;
297
299 std::string m_maskFile;
300
303
304protected:
305
311 std::weak_ptr<BERT> m_bert;
312};
313
314#endif
Declaration of EyeMask, EyeMaskPoint, and EyeMaskPolygon.
A pattern checker channel of a BERT.
Definition: BERTInputChannel.h:51
void SetCTLEGainStep(size_t step)
Sets the gain for the CTLE.
Definition: BERTInputChannel.h:176
StreamDescriptor GetHBathtubStream()
Gets the stream for the horizontal bathtub output.
Definition: BERTInputChannel.h:142
bool HasCTLE()
Returns true if the channel has a CTLE on the input.
Definition: BERTInputChannel.h:154
StreamIDs
Well known indexes of output streams.
Definition: BERTInputChannel.h:127
@ STREAM_MASKHITRATE
Definition: BERTInputChannel.h:138
@ STREAM_BER
Definition: BERTInputChannel.h:135
@ STREAM_EYE
Definition: BERTInputChannel.h:132
@ STREAM_HBATHTUB
Horizontal bathtub.
Definition: BERTInputChannel.h:129
void SetPattern(BERT::Pattern pattern)
Set the pattern this channel is expecting to see.
Definition: BERTInputChannel.h:94
int64_t GetScanDepth()
Gets the currently selected integration depth for eye / bathtub scans.
Definition: BERTInputChannel.h:110
std::string GetMaskFile()
Gets the path of the mask file for pass/fail testing (if any)
Definition: BERTInputChannel.h:217
bool GetCdrLockState()
Check if the CDR is currently locked.
Definition: BERTInputChannel.h:86
int64_t GetExpectedEyeCaptureTime()
Estimate the time needed to capture an eye pattern with the current settings.
Definition: BERTInputChannel.h:250
std::vector< float > m_offsets
Vertical offset of each stream.
Definition: BERTInputChannel.h:296
void SetMaskFile(const std::string &fname)
Sets the path of the mask file for pass/fail testing.
Definition: BERTInputChannel.cpp:159
bool GetInvert()
Get the polarity inversion state.
Definition: BERTInputChannel.h:74
EyeMask m_mask
Eye mask used for pass/fail testing.
Definition: BERTInputChannel.h:302
void SetBERSamplingPoint(int64_t dx, float dy)
Sets the sampling location for real time offset BER measurements.
Definition: BERTInputChannel.h:185
void SetScanDepth(int64_t depth)
Sets the currently selected integration depth for eye / bathtub scans.
Definition: BERTInputChannel.h:122
std::vector< int64_t > GetScanDepths()
Gets the available integration depths for eye / bathtub scans.
Definition: BERTInputChannel.h:114
void GetBERSamplingPoint(int64_t &dx, float &dy)
Gets the sampling location for real time offset BER measurements.
Definition: BERTInputChannel.h:194
virtual void ClearStreams() override
Clears out any existing streams.
Definition: BERTInputChannel.cpp:106
float GetScanProgress()
Returns an estimate of the current scan progress (if an eye or bathtub scan is executing)
Definition: BERTInputChannel.h:266
int64_t GetDataRate()
Gets the data rate of this channel, in symbols per second.
Definition: BERTInputChannel.h:200
int64_t GetExpectedBathtubCaptureTime()
Estimate the time needed to capture a bathtub curve with the current settings.
Definition: BERTInputChannel.h:240
BERTInputChannel(const std::string &hwname, std::weak_ptr< BERT > bert, const std::string &color="#808080", size_t index=0)
Initialize the channel.
Definition: BERTInputChannel.cpp:52
std::weak_ptr< BERT > m_bert
Pointer to the parent instrument.
Definition: BERTInputChannel.h:311
bool IsHBathtubScanInProgress()
Check if a bathtub scan is currently executing.
Definition: BERTInputChannel.h:274
bool IsEyeScanInProgress()
Check if an eye scan is currently executing.
Definition: BERTInputChannel.h:258
std::vector< BERT::Pattern > GetAvailablePatterns()
Get a list of all patterns this channel knows how to match.
Definition: BERTInputChannel.h:102
StreamDescriptor GetEyeStream()
Gets the stream for the eye pattern output.
Definition: BERTInputChannel.h:146
std::vector< float > m_ranges
Voltage range of each stream.
Definition: BERTInputChannel.h:293
StreamDescriptor GetBERStream()
Gets the stream for the realtime BER output.
Definition: BERTInputChannel.h:150
std::string m_maskFile
Path to the YAML file, if any, that m_mask was loaded from.
Definition: BERTInputChannel.h:299
void SetDataRate(int64_t rate)
Sets the data rate of this channel, in symbols per second.
Definition: BERTInputChannel.h:213
std::vector< float > GetCTLEGainSteps()
Get the set of available gain steps for the CTLE, in dB.
Definition: BERTInputChannel.h:158
size_t GetCTLEGainStep()
Gets the currently selected CTLE gain step.
Definition: BERTInputChannel.h:166
EyeMask & GetMask()
Gets the EyeMask being used for pass/fail testing (may be blank)
Definition: BERTInputChannel.h:228
std::weak_ptr< BERT > GetBERT() const
Get the BERT we're part of.
Definition: BERTInputChannel.h:66
virtual size_t AddStream(Unit yunit, const std::string &name, Stream::StreamType stype, uint8_t flags=0) override
Adds a new data stream to the channel.
Definition: BERTInputChannel.cpp:113
void SetInvert(bool invert)
Set the polarity inversion state.
Definition: BERTInputChannel.h:82
BERT::Pattern GetPattern()
Get the pattern this channel is expecting to see.
Definition: BERTInputChannel.h:98
Base class for bit error rate tester drivers.
Definition: BERT.h:45
Pattern
Set of patterns we can generate or accept.
Definition: BERT.h:54
A mask used for checking eye patterns.
Definition: EyeMask.h:98
virtual void Refresh()
Evaluates a filter graph node.
Definition: FlowGraphNode.cpp:87
size_t GetIndex()
Gets the (zero based) index of the channel.
Definition: InstrumentChannel.h:94
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
StreamType
General data type stored in a stream.
Definition: Stream.h:58
A unit of measurement, plus conversion to pretty-printed output.
Definition: Unit.h:57