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: 927f8bbb5a3f
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 069e8429e421
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Nov 7, 2020

  1. Copy the full SHA
    069e842 View commit details
Showing with 21 additions and 14 deletions.
  1. +21 −14 scopeprotocols/EyePattern.cpp
35 changes: 21 additions & 14 deletions scopeprotocols/EyePattern.cpp
Original file line number Diff line number Diff line change
@@ -79,10 +79,6 @@ void EyeWaveform::Normalize()

//Copy right half to left half
memcpy(row, row+halfwidth, blocksize);

//Fix singularity at midpoint (TODO: better option)
row[halfwidth+1] = row[halfwidth+2];
row[halfwidth] = row[halfwidth-1];
}
if(nmax == 0)
nmax = 1;
@@ -458,8 +454,8 @@ void EyePattern::Refresh()
size_t cend = clock_edges.size() - 1;
size_t iclock = 0;
size_t wend = waveform->m_samples.size()-1;
int64_t ymax = m_height - 1;
int64_t xmax = m_width;
size_t ymax = m_height - 1;
size_t xmax = m_width - 1;
if(m_xscale > FLT_EPSILON)
{
for(size_t i=0; i<wend && iclock < cend; i++)
@@ -468,12 +464,11 @@ void EyePattern::Refresh()
//If it's past the end of the current UI, move to the next clock edge
int64_t tstart = waveform->m_offsets[i] * waveform->m_timescale + waveform->m_triggerPhase;
int64_t offset = tstart - clock_edges[iclock];
if(offset < -10)
if(offset < 0)
continue;
size_t nextclk = iclock + 1;
int64_t tnext = clock_edges[nextclk];
int64_t twidth = tnext - clock_edges[iclock];
if(offset > twidth)
if(tstart >= tnext)
{
//Move to the next clock edge
iclock ++;
@@ -492,17 +487,17 @@ void EyePattern::Refresh()
pixel_x_f += (prng & 0xff) * xscale_div255 - xscale_div2;
prng = 0x343fd * prng + 0x269ec3;

//Early out if off the end of the plot
int64_t pixel_x_round = round(pixel_x_f);
if(pixel_x_round >= xmax)
//Early out if off end of plot
size_t pixel_x_round = floor(pixel_x_f);
if(pixel_x_round > xmax)
continue;

//Interpolate voltage, early out if clipping
float dv = waveform->m_samples[i+1] - waveform->m_samples[i];
float nominal_voltage = waveform->m_samples[i] + dv*dx_frac;
float nominal_pixel_y = nominal_voltage*yscale + yoff;
int64_t y1 = static_cast<size_t>(nominal_pixel_y);
if( (y1 >= ymax) || (y1 < 0) )
size_t y1 = static_cast<size_t>(nominal_pixel_y);
if(y1 >= ymax)
continue;

//Calculate how much of the pixel's intensity to put in each row
@@ -516,6 +511,18 @@ void EyePattern::Refresh()
}
}

//Rightmost picosecond of the eye has some rounding artifacts.
//For now, just replace it with the value from 1ps to its left.
size_t delta = ceil(m_xscale);
size_t xstart = xmax - delta;
size_t xend = xmax;
for(size_t y=0; y<m_height; y++)
{
int64_t* row = data + y*m_width;
for(size_t x=xstart; x<=xend; x++)
row[x] = row[x-delta];
}

//Count total number of UIs we've integrated
cap->IntegrateUIs(clock_edges.size());
cap->Normalize();