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: dc629affcb08
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 77a2f328c75c
Choose a head ref
  • 5 commits
  • 4 files changed
  • 2 contributors

Commits on Dec 21, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3efbaaf View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b68bb9b View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7ab6a19 View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e83ab8c View commit details

Commits on Dec 22, 2020

  1. Merge pull request #390 from miek/usb_hs

    USB high-speed decoding
    azonenberg authored Dec 22, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    77a2f32 View commit details
Showing with 62 additions and 7 deletions.
  1. +33 −3 scopeprotocols/USB2PCSDecoder.cpp
  2. +2 −0 scopeprotocols/USB2PCSDecoder.h
  3. +24 −4 scopeprotocols/USB2PMADecoder.cpp
  4. +3 −0 scopeprotocols/USB2PacketDecoder.cpp
36 changes: 33 additions & 3 deletions scopeprotocols/USB2PCSDecoder.cpp
Original file line number Diff line number Diff line change
@@ -129,14 +129,15 @@ void USB2PCSDecoder::Refresh()
break;

case STATE_SYNC:
RefreshIterationSync(i, state, ui_width, cap, din, count, offset, data, first);
RefreshIterationSync(i, state, speed, ui_width, cap, din, count, offset, data, first);
break;

case STATE_DATA:
RefreshIterationData(
i,
i-1,
state,
speed,
ui_width,
cap,
din,
@@ -220,6 +221,7 @@ void USB2PCSDecoder::RefreshIterationIdle(
void USB2PCSDecoder::RefreshIterationSync(
size_t nin,
DecodeState& state,
BusSpeed speed,
size_t& ui_width,
USB2PCSWaveform* cap,
USB2PMAWaveform* din,
@@ -235,8 +237,23 @@ void USB2PCSDecoder::RefreshIterationSync(
count ++;
auto sin = din->m_samples[nin];


bool sync_odd, sync_even;

if (speed == SPEED_480M)
{
// TODO: rather than hard-coding the count, detect 2 K symbols for end of sync
sync_odd = (count & 1) && count < 30;
sync_even = !(count & 1) && count < 30;
}
else
{
sync_odd = (count == 1) || (count == 3) || (count == 5);
sync_even = (count == 2) || (count == 4);
}

//Odd numbered position
if( (count == 1) || (count == 3) || (count == 5) )
if(sync_odd)
{
//Should be one UI long, and a J. Complain if not.
if( (sample_width_ui > 1.5) || (sample_width_ui < 0.5) ||
@@ -270,7 +287,7 @@ void USB2PCSDecoder::RefreshIterationSync(
}

//Even numbered position, but not the last
else if( (count == 2) || (count == 4) )
else if(sync_even)
{
//Should be one UI long, and a K. Complain if not.
if( (sample_width_ui > 1.5) || (sample_width_ui < 0.5) ||
@@ -397,6 +414,7 @@ void USB2PCSDecoder::RefreshIterationData(
size_t nin,
size_t nlast,
DecodeState& state,
BusSpeed speed,
size_t& ui_width,
USB2PCSWaveform* cap,
USB2PMAWaveform* din,
@@ -451,6 +469,18 @@ void USB2PCSDecoder::RefreshIterationData(
//Process the actual data
size_t num_bits = round(sample_width_ui);
size_t last_num_bits = round(last_sample_width_ui);

//For high speed, bitstuff errors should be interpreted as EOP.
if(speed == SPEED_480M && num_bits > 7) {
cap->m_offsets.push_back(din->m_offsets[nin]);
cap->m_durations.push_back(din->m_durations[nin]);
cap->m_samples.push_back(USB2PCSSymbol(USB2PCSSymbol::TYPE_EOP, 0));

state = STATE_IDLE;
count = 0;
return;
}

for(size_t i=0; i<num_bits; i++)
{
//First bit is either a bitstuff or 0 bit
2 changes: 2 additions & 0 deletions scopeprotocols/USB2PCSDecoder.h
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@ class USB2PCSDecoder : public Filter
void RefreshIterationSync(
size_t nin,
DecodeState& state,
BusSpeed speed,
size_t& ui_width,
USB2PCSWaveform* cap,
USB2PMAWaveform* din,
@@ -136,6 +137,7 @@ class USB2PCSDecoder : public Filter
size_t nin,
size_t nlast,
DecodeState& state,
BusSpeed speed,
size_t& ui_width,
USB2PCSWaveform* cap,
USB2PMAWaveform* din,
28 changes: 24 additions & 4 deletions scopeprotocols/USB2PMADecoder.cpp
Original file line number Diff line number Diff line change
@@ -120,16 +120,36 @@ void USB2PMADecoder::Refresh()
//Figure out our speed so we know what's going on
auto speed = static_cast<Speed>(m_parameters[m_speedname].GetIntVal());

//Set appropriate thresholds for different speeds
auto threshold = (speed == SPEED_HIGH) ? 0.2 : 0.4;
int64_t transition_time;
switch(speed)
{
case SPEED_HIGH:
// 1 UI width
transition_time = 2083000;
break;
case SPEED_FULL:
// TFST = 14ns (Section 7.1.4.1)
transition_time = 14000000;
break;
case SPEED_LOW:
// TLST = 210ns (Section 7.1.4.1)
transition_time = 210000000;
break;
}


//Figure out the line state for each input (no clock recovery yet)
auto cap = new USB2PMAWaveform;
for(size_t i=0; i<len; i++)
{
bool bp = (din_p->m_samples[i] > 0.4);
bool bn = (din_n->m_samples[i] > 0.4);
bool bp = (din_p->m_samples[i] > threshold);
bool bn = (din_n->m_samples[i] > threshold);
float vdiff = din_p->m_samples[i] - din_n->m_samples[i];

USB2PMASymbol::SegmentType type = USB2PMASymbol::TYPE_SE1;
if(fabs(vdiff) > 0.4)
if(fabs(vdiff) > threshold)
{
if( (speed == SPEED_FULL) || (speed == SPEED_HIGH) )
{
@@ -173,7 +193,7 @@ void USB2PMADecoder::Refresh()
int64_t last_fs = cap->m_durations[iold] * din_p->m_timescale;
if(
( (oldtype == USB2PMASymbol::TYPE_SE0) || (oldtype == USB2PMASymbol::TYPE_SE1) ) &&
(last_fs < 100000000))
(last_fs < transition_time))
{
cap->m_samples[iold].m_type = type;
cap->m_durations[iold] += din_p->m_durations[i];
3 changes: 3 additions & 0 deletions scopeprotocols/USB2PacketDecoder.cpp
Original file line number Diff line number Diff line change
@@ -424,6 +424,9 @@ void USB2PacketDecoder::FindPackets(USB2PacketWaveform* cap)
ClearPackets();

//Stop when we have no chance of fitting a full packet
if(cap->m_samples.size() < 2)
return;

for(size_t i=0; i<cap->m_samples.size() - 2;)
{
//Every packet should start with a PID. Discard unknown garbage.