Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f6d9c69f884a
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7f3563b6885d
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 23, 2020

  1. EyePattern: Now accept rising, falling, or double rate edges - but mi…

    …ght not work right with non-sparse clocks. Fixes #220.
    azonenberg committed Oct 23, 2020
    Copy the full SHA
    7f3563b View commit details
Showing with 43 additions and 7 deletions.
  1. +35 −7 scopeprotocols/EyePattern.cpp
  2. +8 −0 scopeprotocols/EyePattern.h
42 changes: 35 additions & 7 deletions scopeprotocols/EyePattern.cpp
Original file line number Diff line number Diff line change
@@ -95,24 +95,31 @@ EyePattern::EyePattern(const string& color)
, m_width(1)
, m_xoff(0)
, m_xscale(0)
, m_saturationName("Saturation Level")
, m_centerName("Center Voltage")
, m_maskName("Mask")
, m_polarityName("Clock Edge")
{
//Set up channels
CreateInput("din");
CreateInput("clk");

m_saturationName = "Saturation Level";
m_parameters[m_saturationName] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_COUNTS));
m_parameters[m_saturationName].SetFloatVal(1);

m_centerName = "Center Voltage";
m_parameters[m_centerName] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_VOLTS));
m_parameters[m_centerName].SetFloatVal(0);

m_maskName = "Mask";
m_parameters[m_maskName] = FilterParameter(FilterParameter::TYPE_FILENAME, Unit(Unit::UNIT_COUNTS));
m_parameters[m_maskName].SetFileName("");
m_parameters[m_maskName].m_fileFilterMask = "*.yml";
m_parameters[m_maskName].m_fileFilterName = "YAML files (*.yml)";

m_parameters[m_polarityName] = FilterParameter(FilterParameter::TYPE_ENUM, Unit(Unit::UNIT_COUNTS));
m_parameters[m_polarityName].AddEnumValue("Rising", CLOCK_RISING);
m_parameters[m_polarityName].AddEnumValue("Falling", CLOCK_FALLING);
m_parameters[m_polarityName].AddEnumValue("Both", CLOCK_BOTH);
m_parameters[m_polarityName].SetIntVal(CLOCK_BOTH);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -379,11 +386,14 @@ void EyePattern::Refresh()
}

//Process the eye
size_t iclock = 0;
float yscale = m_height / m_inputs[0].m_channel->GetVoltageRange();
float ymid = m_height / 2;
float yoff = -center*yscale + ymid;
int clkpol = m_parameters[m_polarityName].GetIntVal();
size_t iclock = 0;
bool last_clock = clock->m_samples[0];
size_t wend = waveform->m_samples.size()-1;
size_t num_uis = 0;
for(size_t i=0; i<wend; i++)
{
//If scale isn't defined yet, early out
@@ -401,11 +411,29 @@ void EyePattern::Refresh()
int64_t offset = tstart - clock->m_offsets[iclock] * clock->m_timescale;
if(offset < -10)
continue;
if(offset > twidth)
if( (offset > twidth) || (iclock == 0) )
{
iclock ++;
//Move to the next clock edge
while(iclock < cend)
{
bool b = clock->m_samples[iclock];
if(b != last_clock)
{
last_clock = b;
if(b && (clkpol & CLOCK_RISING))
break;
if(!b && (clkpol & CLOCK_FALLING))
break;
}

iclock ++;
}
num_uis ++;

if(iclock + 1 >= cend)
break;

//Figure out the offset to the next edge
offset = tstart - clock->m_offsets[iclock+1] * clock->m_timescale;
}

@@ -458,7 +486,7 @@ void EyePattern::Refresh()
fflush(stdout);

//Count total number of UIs we've integrated
cap->IntegrateUIs(clock->m_samples.size());
cap->IntegrateUIs(num_uis);
cap->Normalize();
SetData(cap, 0);

8 changes: 8 additions & 0 deletions scopeprotocols/EyePattern.h
Original file line number Diff line number Diff line change
@@ -148,6 +148,13 @@ class EyePattern : public Filter
const EyeMask& GetMask() const
{ return m_mask; }

enum ClockPolarity
{
CLOCK_RISING = 1,
CLOCK_FALLING = 2,
CLOCK_BOTH = 3 //CLOCK_RISING | CLOCK_FALLING
};

PROTOCOL_DECODER_INITPROC(EyePattern)

protected:
@@ -162,6 +169,7 @@ class EyePattern : public Filter
std::string m_saturationName;
std::string m_centerName;
std::string m_maskName;
std::string m_polarityName;

EyeMask m_mask;
};