ngscopeclient v0.2.2
Loading...
Searching...
No Matches
ClockRecoveryFilter.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
35#ifndef ClockRecoveryFilter_h
36#define ClockRecoveryFilter_h
37
38#include "../scopehal/LevelCrossingDetector.h"
39
41{
42public:
43 int64_t initialPeriod;
44 int64_t fnyquist;
45 int64_t tend;
46 int64_t timescale;
47 int64_t triggerPhase;
48 uint32_t nedges;
49 uint32_t numEdgesPerThread;
50 uint32_t maxOffsetsPerThread;
51 uint32_t maxInputSamples;
52};
53
55{
56public:
57 ClockRecoveryFilter(const std::string& color);
58 virtual ~ClockRecoveryFilter();
59
60 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
61
62 static std::string GetProtocolName();
63
64 PROTOCOL_DECODER_INITPROC(ClockRecoveryFilter)
65
66
68 { return m_detector.GetResults(); }
69
70 float GetThreshold()
71 { return m_threshold.GetFloatVal(); }
72
73protected:
75
79 size_t nedges,
80 int64_t tend,
81 int64_t initialPeriod,
83 int64_t fnyquist,
87
88 void InnerLoopWithNoGating(
91 size_t nedges,
92 int64_t tend,
93 int64_t initialPeriod,
95 int64_t fnyquist);
96
97#ifdef __x86_64__
99#endif
100
103
106
107 enum MtModes
108 {
109 MT_SINGLE_THREAD,
110 MT_GPU
111 };
112
120
121 LevelCrossingDetector m_detector;
122
124 std::shared_ptr<ComputePipeline> m_fillSquarewaveAndDurationsComputePipeline;
125
127 std::shared_ptr<ComputePipeline> m_firstPassComputePipeline;
128
130 std::shared_ptr<ComputePipeline> m_secondPassComputePipeline;
131
133 std::shared_ptr<ComputePipeline> m_finalPassComputePipeline;
134
144
147};
148
149#endif
Definition AcceleratorBuffer.h:204
A buffer of memory which may be used by GPU acceleration.
Definition AcceleratorBuffer.h:343
Definition ClockRecoveryFilter.h:41
Definition ClockRecoveryFilter.h:55
AcceleratorBuffer< int64_t > & GetZeroCrossings()
Allow our zero crossings to be reused in downstream filters (e.g. TIE) if valid (input is uniform)
Definition ClockRecoveryFilter.h:67
std::shared_ptr< ComputePipeline > m_secondPassComputePipeline
Compute pipeline for second PLL pass.
Definition ClockRecoveryFilter.h:130
void InnerLoopWithGating(SparseDigitalWaveform &cap, AcceleratorBuffer< int64_t > &edges, size_t nedges, int64_t tend, int64_t initialPeriod, int64_t halfPeriod, int64_t fnyquist, WaveformBase *gate, SparseDigitalWaveform *sgate, UniformDigitalWaveform *ugate)
Main PLL inner loop supporting an external gate/squelch signal.
Definition ClockRecoveryFilter.cpp:574
size_t m_lastIterationOutputCount
Number of edges found last PLL iteration.
Definition ClockRecoveryFilter.h:146
std::shared_ptr< ComputePipeline > m_firstPassComputePipeline
Compute pipeline for first PLL pass.
Definition ClockRecoveryFilter.h:127
void FillSquarewaveGeneric(SparseDigitalWaveform &cap)
Fills a waveform with a squarewave.
Definition ClockRecoveryFilter.cpp:558
std::shared_ptr< ComputePipeline > m_fillSquarewaveAndDurationsComputePipeline
Compute pipeline for filling output.
Definition ClockRecoveryFilter.h:124
AcceleratorBuffer< int64_t > m_secondPassState
Output status buffer for second PLL pass.
Definition ClockRecoveryFilter.h:143
std::shared_ptr< ComputePipeline > m_finalPassComputePipeline
Compute pipeline for final reduction pass.
Definition ClockRecoveryFilter.h:133
FilterParameter & m_threshold
Threshold for edge detection.
Definition ClockRecoveryFilter.h:105
FilterParameter & m_mtMode
Enable the GPU version of the filter where possible.
Definition ClockRecoveryFilter.h:119
FilterParameter & m_baudRate
Nominal symbol rate, in Hz.
Definition ClockRecoveryFilter.h:102
A parameter to a filter.
Definition FilterParameter.h:86
float GetFloatVal() const
Returns the value of the parameter interpreted as a floating point number.
Definition FilterParameter.h:144
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition Filter.h:105
Helper for GPU accelerated level-crossing searches.
Definition LevelCrossingDetector.h:65
A waveform sampled at irregular intervals.
Definition Waveform.h:514
A waveform sampled at uniform intervals.
Definition Waveform.h:404
Base class for all Waveform specializations.
Definition Waveform.h:59