ngscopeclient 0.1-dev+51fbda87c
EyeWaveform.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 EyeWaveform_h
38#define EyeWaveform_h
39
40#include "../scopehal/DensityFunctionWaveform.h"
41
42#define EYE_ACCUM_SCALE 64
43
58{
59public:
60 enum EyeType
61 {
62 EYE_NORMAL, //Eye is a normal measurement from a realtime or sampling scope
63 EYE_BER, //Eye is a SERDES BER measurement (scaled by 1e15)
64 };
65
66 EyeWaveform(size_t width, size_t height, float center, EyeWaveform::EyeType etype);
67 virtual ~EyeWaveform();
68
69 //not copyable or assignable
70 EyeWaveform(const EyeWaveform&) =delete;
71 EyeWaveform& operator=(const EyeWaveform&) =delete;
72
74 int64_t* GetAccumData()
75 { return m_accumdata; }
76
77 void Normalize();
78
80 size_t GetTotalUIs()
81 { return m_totalUIs; }
82
85 { return m_totalSamples; }
86
93 { return m_centerVoltage; }
94
105 void IntegrateUIs(size_t uis, size_t samples)
106 {
107 m_totalUIs += uis;
108 m_totalSamples += samples;
109 }
110
113 { return m_uiWidth; }
114
121
129
132 { return m_maskHitRate; }
133
139 void SetMaskHitRate(float rate)
140 { m_maskHitRate = rate; }
141
142 double GetBERAtPoint(ssize_t pointx, ssize_t pointy, ssize_t xmid, ssize_t ymid);
143
145 EyeType GetType()
146 { return m_type; }
147
148 virtual void FreeGpuMemory() override
149 {}
150
151 virtual bool HasGpuBuffer() override
152 { return false; }
153
154protected:
155
157 int64_t* m_accumdata;
158
161
164
167
170
172 EyeType m_type;
173};
174
175#endif
Base class for waveforms such as eye patterns, spectrograms, and waterfalls which are conceptually a ...
Definition: DensityFunctionWaveform.h:51
An eye-pattern waveform.
Definition: EyeWaveform.h:58
size_t GetTotalSamples()
Get the total number of samples integrated in this eye.
Definition: EyeWaveform.h:84
size_t m_totalUIs
Total UIs integrated.
Definition: EyeWaveform.h:160
double GetBERAtPoint(ssize_t pointx, ssize_t pointy, ssize_t xmid, ssize_t ymid)
Gets the BER at a single point, relative to the center of the eye opening.
Definition: EyeWaveform.cpp:128
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: EyeWaveform.h:151
void Normalize()
Normalize the integrated integer buffer into float32 output buffer.
Definition: EyeWaveform.cpp:81
int64_t * m_accumdata
Accumulator buffer.
Definition: EyeWaveform.h:157
virtual void FreeGpuMemory() override
Free GPU-side memory if we are short on VRAM or do not anticipate using this waveform for a while.
Definition: EyeWaveform.h:148
size_t GetTotalUIs()
Get the total number of UIs integrated in this eye.
Definition: EyeWaveform.h:80
float m_saturationLevel
Saturation level for normalization.
Definition: EyeWaveform.h:128
float m_uiWidth
Nominal unit interval width of the eye.
Definition: EyeWaveform.h:120
int64_t * GetAccumData()
Returns a pointer to the raw (not normalized) accumulator data.
Definition: EyeWaveform.h:74
EyeWaveform(size_t width, size_t height, float center, EyeWaveform::EyeType etype)
Create a new blank eye waveform.
Definition: EyeWaveform.cpp:56
void SetMaskHitRate(float rate)
Set the mask hit rate (normally called by the filter or instrument owning the waveform)
Definition: EyeWaveform.h:139
EyeType GetType()
Return the eye type (normal or BER)
Definition: EyeWaveform.h:145
float m_centerVoltage
Voltage of the vertical midpoint of the plot.
Definition: EyeWaveform.h:166
EyeType m_type
Type of the eye pattern.
Definition: EyeWaveform.h:172
float GetCenterVoltage()
Get the center voltage of the eye plot (not the center of the opening)
Definition: EyeWaveform.h:92
float m_maskHitRate
Mask hit rate.
Definition: EyeWaveform.h:169
void IntegrateUIs(size_t uis, size_t samples)
Marks a given number of UIs as integrated.
Definition: EyeWaveform.h:105
float GetMaskHitRate()
Return the mask hit rate, or zero if there is no mask defined.
Definition: EyeWaveform.h:131
size_t m_totalSamples
Total samples integrated.
Definition: EyeWaveform.h:163
float GetUIWidth()
Return the UI width, in X axis units.
Definition: EyeWaveform.h:112