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: e1148b1b0da3
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c193ae1cf9b3
Choose a head ref
  • 3 commits
  • 14 files changed
  • 1 contributor

Commits on May 18, 2020

  1. Copy the full SHA
    f7316af View commit details
  2. Copy the full SHA
    2fc5228 View commit details
  3. Copy the full SHA
    c193ae1 View commit details
14 changes: 7 additions & 7 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -14,20 +14,20 @@ set(SCOPEPROTOCOLS_SOURCES
DramRefreshActivateMeasurementDecoder.cpp
DramRowColumnLatencyMeasurementDecoder.cpp
DVIDecoder.cpp
#Ethernet10BaseTDecoder.cpp
Ethernet10BaseTDecoder.cpp
Ethernet100BaseTDecoder.cpp
#EthernetAutonegotiationDecoder.cpp
#EthernetGMIIDecoder.cpp
EthernetAutonegotiationDecoder.cpp
EthernetGMIIDecoder.cpp
EthernetProtocolDecoder.cpp
EyeDecoder2.cpp
#FallMeasurementDecoder.cpp
FallMeasurementDecoder.cpp
FFTDecoder.cpp
#FrequencyMeasurementDecoder.cpp
FrequencyMeasurementDecoder.cpp
HorizontalBathtubDecoder.cpp
I2CDecoder.cpp
IBM8b10bDecoder.cpp
#JtagDecoder.cpp
#MDIODecoder.cpp
JtagDecoder.cpp
MDIODecoder.cpp
MovingAverageDecoder.cpp
ParallelBusDecoder.cpp
PeriodMeasurementDecoder.cpp
45 changes: 22 additions & 23 deletions scopeprotocols/Ethernet10BaseTDecoder.cpp
Original file line number Diff line number Diff line change
@@ -71,22 +71,23 @@ void Ethernet10BaseTDecoder::Refresh()
SetData(NULL);
return;
}
AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
auto din = dynamic_cast<AnalogWaveform*>(m_channels[0]->GetData());
if(din == NULL)
{
SetData(NULL);
return;
}

//Can't do much if we have no samples to work with
if(din->GetDepth() == 0)
size_t len = din->m_samples.size();
if(len == 0)
{
SetData(NULL);
return;
}

//Copy our time scales from the input
EthernetCapture* cap = new EthernetCapture;
auto cap = new EthernetWaveform;
cap->m_timescale = din->m_timescale;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startPicoseconds = din->m_startPicoseconds;
@@ -100,7 +101,7 @@ void Ethernet10BaseTDecoder::Refresh()

size_t i = 0;
bool done = false;
while(i<din->m_samples.size())
while(i < len)
{
if(done)
break;
@@ -123,10 +124,10 @@ void Ethernet10BaseTDecoder::Refresh()

//Recover the Manchester bitstream
bool current_state = false;
int64_t ui_start = din->m_samples[i].m_offset * cap->m_timescale;
int64_t ui_start = din->m_offsets[i] * cap->m_timescale;
int64_t byte_start = ui_start;
//LogDebug("[T = %.3f ns] Found initial falling edge\n", ui_start * 1e-3f);
while(i < din->m_samples.size())
while(i < len)
{
//When we get here, i points to the start of our UI
//Expect an opposite polarity edge at the center of our bit
@@ -140,7 +141,7 @@ void Ethernet10BaseTDecoder::Refresh()

//If the edge came too soon or too late, possible sync error - restart from this edge
//If the delta was more than ten UIs, it's a new frame - end this one
int64_t edgepos = din->m_samples[i].m_offset * cap->m_timescale;
int64_t edgepos = din->m_offsets[i] * cap->m_timescale;
int64_t delta = edgepos - ui_start;
/*LogDebug("[T = %.3f ns] Found edge! edgepos=%d ui_start = %d, Delta = %.3f ns (%.2f UI)\n",
edgepos * 1e-3f,
@@ -158,12 +159,12 @@ void Ethernet10BaseTDecoder::Refresh()
{
LogDebug("Edge was in the wrong place, skipping it and attempting resync\n");
i++;
ui_start = din->m_samples[i].m_offset * cap->m_timescale;
ui_start = din->m_offsets[i] * cap->m_timescale;
current_state = !current_state;
continue;
}
int64_t i_middle = i;
int64_t ui_middle = din->m_samples[i].m_offset * cap->m_timescale;
int64_t ui_middle = din->m_offsets[i] * cap->m_timescale;

//Edge is in the right spot! Decode it. Ethernet sends LSB first.
//Ethernet says rising edge in the middle of the bit = 1
@@ -192,7 +193,7 @@ void Ethernet10BaseTDecoder::Refresh()
done = true;
break;
}
edgepos = din->m_samples[i].m_offset * cap->m_timescale;
edgepos = din->m_offsets[i] * cap->m_timescale;
delta = edgepos - ui_middle;

//If the next edge is more than ten UIs after this one, declare the frame over
@@ -213,9 +214,9 @@ void Ethernet10BaseTDecoder::Refresh()
//Move back until we're about half a UI after the center edge of this bit
i = i_middle;
int64_t target = ui_middle + ui_halfwidth;
while(i < din->m_samples.size())
while(i < len)
{
int64_t pos = din->m_samples[i].m_offset * cap->m_timescale;
int64_t pos = din->m_offsets[i] * cap->m_timescale;
if(pos >= target)
break;
else
@@ -232,7 +233,7 @@ void Ethernet10BaseTDecoder::Refresh()
}

//Either way, i now points to the beginning of the next bit's UI
ui_start = din->m_samples[i].m_offset * cap->m_timescale;
ui_start = din->m_offsets[i] * cap->m_timescale;
}

//Crunch the Manchester-coded data
@@ -242,14 +243,13 @@ void Ethernet10BaseTDecoder::Refresh()
SetData(cap);
}

bool Ethernet10BaseTDecoder::FindFallingEdge(size_t& i, AnalogCapture* cap)
bool Ethernet10BaseTDecoder::FindFallingEdge(size_t& i, AnalogWaveform* cap)
{
size_t j = i;

while(j < cap->m_samples.size())
size_t len = cap->m_samples.size();
while(j < len)
{
AnalogSample sin = cap->m_samples[j];
if(sin < -1)
if(cap->m_samples[j] < -1)
{
i = j;
return true;
@@ -260,14 +260,13 @@ bool Ethernet10BaseTDecoder::FindFallingEdge(size_t& i, AnalogCapture* cap)
return false; //not found
}

bool Ethernet10BaseTDecoder::FindRisingEdge(size_t& i, AnalogCapture* cap)
bool Ethernet10BaseTDecoder::FindRisingEdge(size_t& i, AnalogWaveform* cap)
{
size_t j = i;

while(j < cap->m_samples.size())
size_t len = cap->m_samples.size();
while(j < len)
{
AnalogSample sin = cap->m_samples[j];
if(sin > 1)
if(cap->m_samples[j] > 1)
{
i = j;
return true;
8 changes: 4 additions & 4 deletions scopeprotocols/Ethernet10BaseTDecoder.h
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 *
@@ -49,10 +49,10 @@ class Ethernet10BaseTDecoder : public EthernetProtocolDecoder
PROTOCOL_DECODER_INITPROC(Ethernet10BaseTDecoder)

protected:
bool FindFallingEdge(size_t& i, AnalogCapture* cap);
bool FindRisingEdge(size_t& i, AnalogCapture* cap);
bool FindFallingEdge(size_t& i, AnalogWaveform* cap);
bool FindRisingEdge(size_t& i, AnalogWaveform* cap);

bool FindEdge(size_t& i, AnalogCapture* cap, bool polarity)
bool FindEdge(size_t& i, AnalogWaveform* cap, bool polarity)
{
if(polarity)
return FindRisingEdge(i, cap);
24 changes: 11 additions & 13 deletions scopeprotocols/EthernetAutonegotiationDecoder.cpp
Original file line number Diff line number Diff line change
@@ -88,15 +88,15 @@ void EthernetAutonegotiationDecoder::Refresh()
SetData(NULL);
return;
}
AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
auto din = dynamic_cast<AnalogWaveform*>(m_channels[0]->GetData());
if(din == NULL)
{
SetData(NULL);
return;
}

//Create the outbound data
auto* cap = new EthernetAutonegotiationCapture;
auto* cap = new EthernetAutonegotiationWaveform;
cap->m_timescale = din->m_timescale;

//Crunch it
@@ -106,12 +106,11 @@ void EthernetAutonegotiationDecoder::Refresh()
int nbit = 0;
int64_t frame_start = 0;
bool last_was_data = false;
for(size_t i = 0; i < din->m_samples.size(); i ++)
auto len = din->m_samples.size();
for(size_t i = 0; i < len; i ++)
{
auto sample = din->m_samples[i];
float v = sample;
bool sample_value = (v > 1.25);
int64_t tm = sample.m_offset * din->m_timescale;
bool sample_value = (din->m_samples[i] > 1.25);
int64_t tm = din->m_offsets[i] * din->m_timescale;
float dt = (tm - last_pulse) * 1e-6f;

if(sample_value && !old_value)
@@ -121,7 +120,7 @@ void EthernetAutonegotiationDecoder::Refresh()
{
nbit = 0;
last_was_data = false;
frame_start = sample.m_offset;
frame_start = din->m_offsets[i];
}

//If delta is less than 30 us, it's a glitch - skip it
@@ -156,10 +155,9 @@ void EthernetAutonegotiationDecoder::Refresh()
for(int j=0; j<16; j++)
ncode |= (code[j] << j);

cap->m_samples.push_back(EthernetAutonegotiationSample(
frame_start,
sample.m_offset + sample.m_duration - frame_start,
ncode));
cap->m_offsets.push_back(frame_start);
cap->m_durations.push_back(din->m_offsets[i] + din->m_durations[i] - frame_start);
cap->m_samples.push_back(ncode);

nbit = 0;
}
@@ -180,7 +178,7 @@ Gdk::Color EthernetAutonegotiationDecoder::GetColor(int i)

string EthernetAutonegotiationDecoder::GetText(int i)
{
EthernetAutonegotiationCapture* data = dynamic_cast<EthernetAutonegotiationCapture*>(GetData());
auto data = dynamic_cast<EthernetAutonegotiationWaveform*>(GetData());
if(data == NULL)
return "";
if(i >= (int)data->m_samples.size())
3 changes: 1 addition & 2 deletions scopeprotocols/EthernetAutonegotiationDecoder.h
Original file line number Diff line number Diff line change
@@ -38,8 +38,7 @@

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

typedef OscilloscopeSample<uint16_t> EthernetAutonegotiationSample;
typedef CaptureChannel<uint16_t> EthernetAutonegotiationCapture;
typedef Waveform<uint16_t> EthernetAutonegotiationWaveform;

class EthernetAutonegotiationDecoder : public ProtocolDecoder
{
36 changes: 19 additions & 17 deletions scopeprotocols/EthernetGMIIDecoder.cpp
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 *
@@ -28,6 +28,7 @@
***********************************************************************************************************************/

#include "scopeprotocols.h"
#include <algorithm>

using namespace std;

@@ -107,34 +108,36 @@ void EthernetGMIIDecoder::Refresh()
return;
}
}
DigitalBusCapture* data = dynamic_cast<DigitalBusCapture*>(m_channels[0]->GetData());
DigitalCapture* clk = dynamic_cast<DigitalCapture*>(m_channels[1]->GetData());
DigitalCapture* en = dynamic_cast<DigitalCapture*>(m_channels[2]->GetData());
DigitalCapture* er = dynamic_cast<DigitalCapture*>(m_channels[3]->GetData());
auto data = dynamic_cast<DigitalBusWaveform*>(m_channels[0]->GetData());
auto clk = dynamic_cast<DigitalWaveform*>(m_channels[1]->GetData());
auto en = dynamic_cast<DigitalWaveform*>(m_channels[2]->GetData());
auto er = dynamic_cast<DigitalWaveform*>(m_channels[3]->GetData());
if( (data == NULL) || (clk == NULL) || (en == NULL) || (er == NULL) )
{
SetData(NULL);
return;
}

//Sample everything on the clock edges
vector<DigitalSample> den;
vector<DigitalSample> der;
vector<DigitalBusSample> ddata;
DigitalWaveform den;
DigitalWaveform der;
DigitalBusWaveform ddata;
SampleOnRisingEdges(en, clk, den);
SampleOnRisingEdges(er, clk, der);
SampleOnRisingEdges(data, clk, ddata);

//Create the output capture
EthernetCapture* cap = new EthernetCapture;
auto cap = new EthernetWaveform;
cap->m_timescale = 1;
cap->m_startTimestamp = data->m_startTimestamp;
cap->m_startPicoseconds = data->m_startPicoseconds;

for(size_t i=0; i<den.size(); i++)
size_t len = den.m_samples.size();
len = min(len, der.m_samples.size());
len = min(len, ddata.m_samples.size());
for(size_t i=0; i < len; i++)
{
bool cur_en = den[i].m_sample;
if(!cur_en)
if(!den.m_samples[i])
continue;

//Set of recovered bytes and timestamps
@@ -143,20 +146,19 @@ void EthernetGMIIDecoder::Refresh()
vector<uint64_t> ends;

//TODO: handle error signal (ignored for now)

while( (i < den.size()) && (den[i].m_sample) )
while( (i < len) && (den.m_samples[i]) )
{
//Convert bits to bytes
uint8_t dval = 0;
for(size_t j=0; j<8; j++)
{
if(ddata[i].m_sample[j])
if(ddata.m_samples[i][j])
dval |= (1 << j);
}

bytes.push_back(dval);
starts.push_back(ddata[i].m_offset);
ends.push_back(ddata[i].m_offset + ddata[i].m_duration);
starts.push_back(ddata.m_offsets[i]);
ends.push_back(ddata.m_offsets[i] + ddata.m_durations[i]);
i++;
}

Loading