ngscopeclient v0.2.2
Loading...
Searching...
No Matches
EyePattern.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2026 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 EyePattern_h
37#define EyePattern_h
38
39#include "EyeMask.h"
40#include "../scopehal/EyeWaveform.h"
41
43{
44public:
45 int64_t timescale;
46 int64_t triggerPhase;
47 uint32_t len;
48 uint32_t numSamplesPerThread;
49};
50
52{
53public:
54 uint64_t width;
55 uint64_t halfwidth;
56 int64_t timescale;
57 int64_t triggerPhase;
58 int64_t xoff;
59 uint32_t wend;
60 uint32_t cend;
61 uint32_t xmax;
62 uint32_t ymax;
63 uint32_t mwidth;
64 uint32_t numSamplesPerThread;
65 float xtimescale;
66 float yscale;
67 float yoff;
68 float xscale;
69};
70
71class EyePattern : public Filter
72{
73public:
74 EyePattern(const std::string& color);
75
76 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
77
78 static std::string GetProtocolName();
79
80 virtual float GetVoltageRange(size_t stream) override;
81 virtual float GetOffset(size_t stream) override;
82
83 virtual void ClearSweeps() override;
84
85 EyeWaveform* ReallocateWaveform();
86
87 void SetWidth(size_t width)
88 {
89 if(m_width != width)
90 {
91 SetData(nullptr, 0);
92 m_width = width;
93 }
94 }
95
96 void SetHeight(size_t height)
97 {
98 if(m_height != height)
99 {
100 SetData(nullptr, 0);
101 m_height = height;
102 }
103 }
104
105 int64_t GetXOffset()
106 { return m_xoff; }
107
108 float GetXScale()
109 { return m_xscale; }
110
111 size_t GetWidth() const
112 { return m_width; }
113
114 size_t GetHeight() const
115 { return m_height; }
116
117 EyeMask& GetMask()
118 { return m_mask; }
119
120 enum ClockPolarity
121 {
122 CLOCK_RISING = 1,
123 CLOCK_FALLING = 2,
124 CLOCK_BOTH = 3 //CLOCK_RISING | CLOCK_FALLING
125 };
126
127 enum RangeMode
128 {
129 RANGE_AUTO = 0,
130 RANGE_FIXED = 1
131 };
132
133 enum ClockAlignment
134 {
135 ALIGN_CENTER,
136 ALIGN_EDGE
137 };
138
139 enum UIMode
140 {
141 MODE_AUTO,
142 MODE_FIXED
143 };
144
145 PROTOCOL_DECODER_INITPROC(EyePattern)
146
147protected:
149
150 void RecalculateUIWidth(EyeWaveform* cap);
151
152 void SparsePackedInnerLoop(
154 int64_t* data,
155 size_t wend,
156 size_t cend,
157 int32_t xmax,
158 int32_t ymax,
159 float xtimescale,
160 float yscale,
161 float yoff
162 );
163
164 void DensePackedInnerLoop(
166 int64_t* data,
167 size_t wend,
168 size_t cend,
169 int32_t xmax,
170 int32_t ymax,
171 float xtimescale,
172 float yscale,
173 float yoff
174 );
175
176 void DensePackedInnerLoopGPU(
177 vk::raii::CommandBuffer& cmdBuf,
178 std::shared_ptr<QueueHandle> queue,
181 size_t wend,
182 size_t cend,
183 int32_t xmax,
184 int32_t ymax,
185 float xtimescale,
186 float yscale,
187 float yoff
188 );
189
190#ifdef __x86_64__
193 int64_t* data,
194 size_t wend,
195 size_t cend,
196 int32_t xmax,
197 int32_t ymax,
198 float xtimescale,
199 float yscale,
200 float yoff
201 );
202
205 int64_t* data,
206 size_t wend,
207 size_t cend,
208 int32_t xmax,
209 int32_t ymax,
210 float xtimescale,
211 float yscale,
212 float yoff
213 );
214
217 int64_t* data,
218 size_t wend,
219 size_t cend,
220 int32_t xmax,
221 int32_t ymax,
222 float xtimescale,
223 float yscale,
224 float yoff
225 );
226#endif
227
228 size_t m_height;
229 size_t m_width;
230
231 int64_t m_xoff;
232 float m_xscale;
233 ClockAlignment m_lastClockAlign;
234
235 std::string m_saturationName;
236 std::string m_centerName;
237 std::string m_maskName;
238 std::string m_polarityName;
239 std::string m_vmodeName;
240 std::string m_rangeName;
241 std::string m_clockAlignName;
242 std::string m_rateModeName;
243 std::string m_rateName;
244 std::string m_numLevelsName;
245
246 EyeMask m_mask;
247
248 AcceleratorBuffer<int64_t> m_clockEdges;
249 AcceleratorBuffer<uint32_t> m_indexBuffer;
250
251 AcceleratorBuffer<int64_t>* m_clockEdgesMuxed;
252 AcceleratorBuffer<int64_t> m_normalizeMaxBuf;
253
254 std::shared_ptr<ComputePipeline> m_scratchZeroComputePipeline;
255 std::shared_ptr<ComputePipeline> m_eyeIntegrateComputePipeline;
256 std::shared_ptr<ComputePipeline> m_eyeComputePipeline;
257 std::shared_ptr<ComputePipeline> m_eyeNormalizeReduceComputePipeline;
258 std::shared_ptr<ComputePipeline> m_eyeNormalizeScaleComputePipeline;
259 std::shared_ptr<ComputePipeline> m_eyeIndexSearchPipeline;
260
261 size_t FindCenterOfMass(std::vector<float>& hist, size_t start, size_t end);
262};
263
264#endif
Declaration of EyeMask, EyeMaskPoint, and EyeMaskPolygon.
Definition AcceleratorBuffer.h:204
Definition EyePattern.h:52
Definition EyePattern.h:43
A mask used for checking eye patterns.
Definition EyeMask.h:98
Definition EyePattern.h:72
size_t FindCenterOfMass(std::vector< float > &hist, size_t start, size_t end)
Finds the mass weighted center of a histogram peak.
Definition EyePattern.cpp:482
void DoMaskTest(EyeWaveform *cap)
Checks the current capture against the eye mask.
Definition EyePattern.cpp:1399
virtual void ClearSweeps() override
Clears any integrated data from past triggers (e.g. eye patterns).
Definition EyePattern.cpp:162
An eye-pattern waveform.
Definition EyeWaveform.h:66
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition Filter.h:105
void SetData(WaveformBase *pNew, size_t stream)
Sets the waveform data for a given stream, replacing any previous waveform.
Definition InstrumentChannel.cpp:144
A waveform sampled at irregular intervals.
Definition Waveform.h:514
A waveform sampled at uniform intervals.
Definition Waveform.h:404