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: 3539e5ddeed1
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 27098762823c
Choose a head ref
  • 1 commit
  • 9 files changed
  • 1 contributor

Commits on May 23, 2020

  1. Copy the full SHA
    2709876 View commit details
1 change: 0 additions & 1 deletion scopemeasurements/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ link_directories(${GTKMM_LIBRARY_DIRS} ${SIGCXX_LIBRARY_DIRS})
set(SCOPEMEASUREMENTS_SOURCES
#EyeHeightMeasurement.cpp
#EyePeriodMeasurement.cpp
#EyeWidthMeasurement.cpp
#OvershootMeasurement.cpp
#PkPkVoltageMeasurement.cpp
#UndershootMeasurement.cpp
1 change: 0 additions & 1 deletion scopemeasurements/scopemeasurements.cpp
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@ void ScopeMeasurementStaticInit()
/*
AddMeasurementClass(EyeHeightMeasurement);
AddMeasurementClass(EyePeriodMeasurement);
AddMeasurementClass(EyeWidthMeasurement);
AddMeasurementClass(OvershootMeasurement);
AddMeasurementClass(PkPkVoltageMeasurement);
AddMeasurementClass(UndershootMeasurement);
1 change: 0 additions & 1 deletion scopemeasurements/scopemeasurements.h
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@

#include "EyeHeightMeasurement.h"
#include "EyePeriodMeasurement.h"
#include "EyeWidthMeasurement.h"
#include "OvershootMeasurement.h"
#include "PkPkVoltageMeasurement.h"
#include "UndershootMeasurement.h"
1 change: 1 addition & 0 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ set(SCOPEPROTOCOLS_SOURCES
EyeBitRateMeasurementDecoder.cpp
EyeDecoder2.cpp
EyeJitterMeasurementDecoder.cpp
EyeWidthMeasurementDecoder.cpp
FallMeasurementDecoder.cpp
FFTDecoder.cpp
FrequencyMeasurementDecoder.cpp
9 changes: 3 additions & 6 deletions scopeprotocols/EyeJitterMeasurementDecoder.cpp
Original file line number Diff line number Diff line change
@@ -201,12 +201,9 @@ void EyeJitterMeasurementDecoder::Refresh()
m_min = min(m_min, value);
}

//Proper display of flat lines
if( (m_max - m_min) < 10)
{
m_min -= 5;
m_max += 5;
}
//Padding on edges of plot
m_min -= 10;
m_max += 10;

SetData(cap);

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -27,99 +27,177 @@
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of EyeWidthMeasurement
*/

#include "scopemeasurements.h"
#include "EyeWidthMeasurement.h"
#include "../scopeprotocols/EyeDecoder2.h"
#include "scopeprotocols.h"
#include "EyeWidthMeasurementDecoder.h"
#include "EyeDecoder2.h"
#include <algorithm>

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/destruction
// Construction / destruction

EyeWidthMeasurement::EyeWidthMeasurement()
: FloatMeasurement(TYPE_TIME)
EyeWidthMeasurementDecoder::EyeWidthMeasurementDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_MEASUREMENT)
{
//Configure for a single input
m_signalNames.push_back("Vin");
m_xAxisUnit = Unit(Unit::UNIT_MILLIVOLTS);
m_yAxisUnit = Unit(Unit::UNIT_PS);

//Set up channels
m_signalNames.push_back("Eye");
m_channels.push_back(NULL);

m_startname = "Start Voltage";
m_parameters[m_startname] = ProtocolDecoderParameter(ProtocolDecoderParameter::TYPE_INT);
m_parameters[m_startname].SetFloatVal(0);

m_endname = "End Voltage";
m_parameters[m_endname] = ProtocolDecoderParameter(ProtocolDecoderParameter::TYPE_INT);
m_parameters[m_endname].SetFloatVal(0);

m_min = 0;
m_max = 1;
}

EyeWidthMeasurement::~EyeWidthMeasurement()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory methods

bool EyeWidthMeasurementDecoder::ValidateChannel(size_t i, OscilloscopeChannel* channel)
{
if( (i == 0) && (channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_EYE) )
return true;
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

Measurement::MeasurementType EyeWidthMeasurement::GetMeasurementType()
void EyeWidthMeasurementDecoder::SetDefaultName()
{
return Measurement::MEAS_HORZ;
float vstart = m_parameters[m_startname].GetFloatVal();
float vend = m_parameters[m_endname].GetFloatVal();

char hwname[256];
snprintf(hwname, sizeof(hwname), "EyeWidth(%s, %.2f, %.2f)",
m_channels[0]->m_displayname.c_str(),
vstart,
vend);
m_hwname = hwname;
m_displayname = m_hwname;
}

string EyeWidthMeasurement::GetMeasurementName()
string EyeWidthMeasurementDecoder::GetProtocolName()
{
return "Eye Width";
}

bool EyeWidthMeasurement::ValidateChannel(size_t i, OscilloscopeChannel* channel)
bool EyeWidthMeasurementDecoder::IsOverlay()
{
if( (i == 0) && dynamic_cast<EyeDecoder2*>(channel) != NULL )
return true;
//we create a new analog channel
return false;
}

bool EyeWidthMeasurementDecoder::NeedsConfig()
{
//need manual config
return true;
}

double EyeWidthMeasurementDecoder::GetVoltageRange()
{
return m_max - m_min;
}

double EyeWidthMeasurementDecoder::GetOffset()
{
return - (m_min + m_max)/2;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Measurement processing
// Actual decoder logic

bool EyeWidthMeasurement::Refresh()
void EyeWidthMeasurementDecoder::Refresh()
{
//Get the input data
if(m_channels[0] == NULL)
return false;
auto chan = dynamic_cast<EyeDecoder2*>(m_channels[0]);
auto din = dynamic_cast<EyeCapture2*>(chan->GetData());
return;
auto din = dynamic_cast<EyeWaveform*>(m_channels[0]->GetData());
if(din == NULL)
return false;
return;

float* fdata = din->GetData();
int64_t w = chan->GetWidth();
//Create the output
auto cap = new AnalogWaveform;

//Measure center 5% of a UI
int64_t ycenter = chan->GetHeight() / 2; //vertical midpoint of the eye
int64_t xcenter = w / 2; //horizontal midpoint of the eye

int64_t rad = chan->GetHeight() / 20; //1/20 of the eye height
int64_t bot = ycenter - rad/2;
int64_t top = ycenter + rad/2;
//Make sure voltages are in the right order
float vstart = m_parameters[m_startname].GetFloatVal();
float vend = m_parameters[m_endname].GetFloatVal();
if(vstart > vend)
{
float tmp = vstart;
vstart = vend;
vend = tmp;
}

int64_t left = 0;
int64_t right = w-1;
for(int64_t y = bot; y <= top; y++)
//Figure out how many volts per eye bin and round everything to nearest eye bin
float vrange = m_channels[0]->GetVoltageRange();
float volts_per_row = vrange / din->GetHeight();
float volts_at_bottom = din->GetCenterVoltage() - vrange/2;

size_t start_bin = round( (vstart - volts_at_bottom) / volts_per_row);
size_t end_bin = round( (vend - volts_at_bottom) / volts_per_row);
start_bin = min(start_bin, din->GetHeight()-1);
end_bin = min(end_bin, din->GetHeight()-1);
float duration_mv = volts_per_row * 1000;
float base_mv = volts_at_bottom * 1000;

m_min = FLT_MAX;
m_max = 0;

float* data = din->GetData();
int64_t w = din->GetWidth();
int64_t xcenter = w / 2;
float ber_max = FLT_EPSILON;
double width_ps = 2 * din->m_uiWidth;
double ps_per_pixel = width_ps / w;
for(size_t i=start_bin; i <= end_bin; i++)
{
float* row = data + i*w;

int64_t cleft = 0; //left side of eye opening
int64_t cright = w-1; //right side of eye opening

//Find the edges of the eye in this scanline
for(int64_t dx = 0; dx < xcenter; dx ++)
{
//left
//left of center
int64_t x = xcenter - dx;
if(fdata[y*w + x] > FLT_EPSILON)
left = max(left, x);
if(row[x] > ber_max)
cleft = max(cleft, x);

//right
//right of center
x = xcenter + dx;
if(fdata[y*w + x] > FLT_EPSILON)
right = min(right, x);
if(row[x] > ber_max)
cright = min(cright, x);
}

float value = ps_per_pixel * (cright - cleft);

//Output waveform generation
cap->m_offsets.push_back(round(i*duration_mv + base_mv));
cap->m_durations.push_back(round(duration_mv));
cap->m_samples.push_back(value);
m_max = max(m_max, value);
m_min = min(m_min, value);
}

int64_t dx = right - left;
double width_ps = 2 * chan->GetUIWidth();
double ps_per_pixel = width_ps / w;
int64_t ps = ps_per_pixel * dx;
m_value = 1.0e-12 * ps;
return true;
//Proper display of flat lines
m_min -= 10;
m_max += 10;

SetData(cap);

//Copy start time etc from the input. Timestamps are in picoseconds.
cap->m_timescale = 1;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startPicoseconds = din->m_startPicoseconds;
}
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -30,27 +30,39 @@
/**
@file
@author Andrew D. Zonenberg
@brief Declaration of EyeWidthMeasurement
@brief Declaration of EyeWidthMeasurementDecoder
*/
#ifndef EyeWidthMeasurement_h
#define EyeWidthMeasurement_h
#ifndef EyeWidthMeasurementDecoder_h
#define EyeWidthMeasurementDecoder_h

#include "../scopehal/Measurement.h"
#include "../scopehal/ProtocolDecoder.h"

class EyeWidthMeasurement : public FloatMeasurement
class EyeWidthMeasurementDecoder : public ProtocolDecoder
{
public:
EyeWidthMeasurement();
virtual ~EyeWidthMeasurement();
EyeWidthMeasurementDecoder(std::string color);

virtual bool Refresh();
virtual void Refresh();

virtual bool NeedsConfig();
virtual bool IsOverlay();

static std::string GetProtocolName();
virtual void SetDefaultName();

virtual double GetVoltageRange();
virtual double GetOffset();

static std::string GetMeasurementName();
virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

virtual MeasurementType GetMeasurementType();
PROTOCOL_DECODER_INITPROC(EyeWidthMeasurementDecoder)

protected:
float m_min;
float m_max;

MEASUREMENT_INITPROC(EyeWidthMeasurement)
std::string m_startname;
std::string m_endname;
};

#endif
1 change: 1 addition & 0 deletions scopeprotocols/scopeprotocols.cpp
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ void ScopeProtocolStaticInit()
AddDecoderClass(EyeBitRateMeasurementDecoder);
AddDecoderClass(EyeDecoder2);
AddDecoderClass(EyeJitterMeasurementDecoder);
AddDecoderClass(EyeWidthMeasurementDecoder);
AddDecoderClass(FallMeasurementDecoder);
AddDecoderClass(FFTDecoder);
AddDecoderClass(FrequencyMeasurementDecoder);
1 change: 1 addition & 0 deletions scopeprotocols/scopeprotocols.h
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@
#include "EyeBitRateMeasurementDecoder.h"
#include "EyeDecoder2.h"
#include "EyeJitterMeasurementDecoder.h"
#include "EyeWidthMeasurementDecoder.h"
#include "FallMeasurementDecoder.h"
#include "FFTDecoder.h"
#include "FrequencyMeasurementDecoder.h"