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

Commits on Apr 7, 2021

  1. Refactoring: pulled a lot of common code out of DDR3 decoder to a com…

    …mon base class so we can share it with DDR1/2/4 decodes
    azonenberg committed Apr 7, 2021
    Copy the full SHA
    470dfa5 View commit details
1 change: 1 addition & 0 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ set(SCOPEPROTOCOLS_SOURCES
RiseMeasurement.cpp
SDCmdDecoder.cpp
SDDataDecoder.cpp
SDRAMDecoderBase.cpp
SPIDecoder.cpp
SPIFlashDecoder.cpp
SubtractFilter.cpp
105 changes: 12 additions & 93 deletions scopeprotocols/DDR3Decoder.cpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ using namespace std;
// Construction / destruction

DDR3Decoder::DDR3Decoder(const string& color)
: Filter(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_MEMORY)
: SDRAMDecoderBase(color)
{
CreateInput("CLK");
CreateInput("WE#");
@@ -57,11 +57,6 @@ DDR3Decoder::DDR3Decoder(const string& color)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory methods

bool DDR3Decoder::NeedsConfig()
{
return true;
}

bool DDR3Decoder::ValidateChannel(size_t i, StreamDescriptor stream)
{
if(stream.m_channel == NULL)
@@ -121,7 +116,7 @@ void DDR3Decoder::Refresh()
SampleOnRisingEdges(caps[6], cclk, a10);

//Create the capture
auto cap = new DDR3Waveform;
auto cap = new SDRAMWaveform;
cap->m_timescale = 1;
cap->m_startTimestamp = cclk->m_startTimestamp;
cap->m_startFemtoseconds = 0;
@@ -148,31 +143,31 @@ void DDR3Decoder::Refresh()
if(sras && scas && swe)
continue;

DDR3Symbol sym(DDR3Symbol::TYPE_ERROR);
SDRAMSymbol sym(SDRAMSymbol::TYPE_ERROR);

if(!sras && !scas && !swe)
sym.m_stype = DDR3Symbol::TYPE_MRS;
sym.m_stype = SDRAMSymbol::TYPE_MRS;
else if(!sras && !scas && swe)
sym.m_stype = DDR3Symbol::TYPE_REF;
sym.m_stype = SDRAMSymbol::TYPE_REF;
else if(!sras && scas && !swe && !sa10)
sym.m_stype = DDR3Symbol::TYPE_PRE;
sym.m_stype = SDRAMSymbol::TYPE_PRE;
else if(!sras && scas && !swe && sa10)
sym.m_stype = DDR3Symbol::TYPE_PREA;
sym.m_stype = SDRAMSymbol::TYPE_PREA;
else if(!sras && scas && swe)
sym.m_stype = DDR3Symbol::TYPE_ACT;
sym.m_stype = SDRAMSymbol::TYPE_ACT;
else if(sras && !scas && !swe)
{
if(!sa10)
sym.m_stype = DDR3Symbol::TYPE_WR;
sym.m_stype = SDRAMSymbol::TYPE_WR;
else
sym.m_stype = DDR3Symbol::TYPE_WRA;
sym.m_stype = SDRAMSymbol::TYPE_WRA;
}
else if(sras && !scas && swe)
{
if(!sa10)
sym.m_stype = DDR3Symbol::TYPE_RD;
sym.m_stype = SDRAMSymbol::TYPE_RD;
else
sym.m_stype = DDR3Symbol::TYPE_RDA;
sym.m_stype = SDRAMSymbol::TYPE_RDA;
}

//Unknown
@@ -188,79 +183,3 @@ void DDR3Decoder::Refresh()
}
SetData(cap, 0);
}

Gdk::Color DDR3Decoder::GetColor(int i)
{
auto capture = dynamic_cast<DDR3Waveform*>(GetData(0));
if(capture != NULL)
{
const DDR3Symbol& s = capture->m_samples[i];

switch(s.m_stype)
{
case DDR3Symbol::TYPE_MRS:
case DDR3Symbol::TYPE_REF:
case DDR3Symbol::TYPE_PRE:
case DDR3Symbol::TYPE_PREA:
return m_standardColors[COLOR_CONTROL];

case DDR3Symbol::TYPE_ACT:
case DDR3Symbol::TYPE_WR:
case DDR3Symbol::TYPE_WRA:
case DDR3Symbol::TYPE_RD:
case DDR3Symbol::TYPE_RDA:
return m_standardColors[COLOR_ADDRESS];

case DDR3Symbol::TYPE_ERROR:
default:
return m_standardColors[COLOR_ERROR];
}
}

//error
return m_standardColors[COLOR_ERROR];
}

string DDR3Decoder::GetText(int i)
{
auto capture = dynamic_cast<DDR3Waveform*>(GetData(0));
if(capture != NULL)
{
const DDR3Symbol& s = capture->m_samples[i];

switch(s.m_stype)
{
case DDR3Symbol::TYPE_MRS:
return "MRS";

case DDR3Symbol::TYPE_REF:
return "REF";

case DDR3Symbol::TYPE_PRE:
return "PRE";

case DDR3Symbol::TYPE_PREA:
return "PREA";

case DDR3Symbol::TYPE_ACT:
return "ACT";

case DDR3Symbol::TYPE_WR:
return "WR";

case DDR3Symbol::TYPE_WRA:
return "WRA";

case DDR3Symbol::TYPE_RD:
return "RD";

case DDR3Symbol::TYPE_RDA:
return "RDA";

case DDR3Symbol::TYPE_ERROR:
default:
return "ERR";
}
}
return "";
}
43 changes: 2 additions & 41 deletions scopeprotocols/DDR3Decoder.h
Original file line number Diff line number Diff line change
@@ -36,53 +36,14 @@
#ifndef DDR3Decoder_h
#define DDR3Decoder_h

class DDR3Symbol
{
public:
enum stype
{
TYPE_MRS,
TYPE_REF,
TYPE_PRE,
TYPE_PREA,
TYPE_ACT,
TYPE_WR,
TYPE_WRA,
TYPE_RD,
TYPE_RDA,

TYPE_ERROR
};

DDR3Symbol()
{}

DDR3Symbol(stype t, int bank = 0)
: m_stype(t)
, m_bank(bank)
{}
#include "SDRAMDecoderBase.h"

stype m_stype;
int m_bank;

bool operator== (const DDR3Symbol& s) const
{
return (m_stype == s.m_stype) && (m_bank == s.m_bank);
}
};

typedef Waveform<DDR3Symbol> DDR3Waveform;

class DDR3Decoder : public Filter
class DDR3Decoder : public SDRAMDecoderBase
{
public:
DDR3Decoder(const std::string& color);

virtual std::string GetText(int i);
virtual Gdk::Color GetColor(int i);

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

static std::string GetProtocolName();
virtual void SetDefaultName();
8 changes: 4 additions & 4 deletions scopeprotocols/DramRefreshActivateMeasurement.cpp
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ bool DramRefreshActivateMeasurement::ValidateChannel(size_t i, StreamDescriptor
if(stream.m_channel == NULL)
return false;

if( (i == 0) && (dynamic_cast<DDR3Waveform*>(stream.m_channel->GetData(stream.m_stream)) != NULL ) )
if( (i == 0) && (dynamic_cast<SDRAMWaveform*>(stream.m_channel->GetData(stream.m_stream)) != NULL ) )
return true;

return false;
@@ -110,7 +110,7 @@ void DramRefreshActivateMeasurement::Refresh()
}

//Get the input data
auto din = dynamic_cast<DDR3Waveform*>(GetInputWaveform(0));
auto din = dynamic_cast<SDRAMWaveform*>(GetInputWaveform(0));

//Create the output
auto cap = new AnalogWaveform;
@@ -133,11 +133,11 @@ void DramRefreshActivateMeasurement::Refresh()
continue;

//If it's a refresh, update the last refresh time
if(sample.m_stype == DDR3Symbol::TYPE_REF)
if(sample.m_stype == SDRAMSymbol::TYPE_REF)
lastRef[sample.m_bank] = din->m_offsets[i] * din->m_timescale;

//If it's an activate, measure the latency
else if(sample.m_stype == DDR3Symbol::TYPE_ACT)
else if(sample.m_stype == SDRAMSymbol::TYPE_ACT)
{
int64_t tact = din->m_offsets[i] * din->m_timescale;

14 changes: 7 additions & 7 deletions scopeprotocols/DramRowColumnLatencyMeasurement.cpp
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ bool DramRowColumnLatencyMeasurement::ValidateChannel(size_t i, StreamDescriptor
if(stream.m_channel == NULL)
return false;

if( (i == 0) && (dynamic_cast<DDR3Waveform*>(stream.m_channel->GetData(stream.m_stream)) != NULL ) )
if( (i == 0) && (dynamic_cast<SDRAMWaveform*>(stream.m_channel->GetData(stream.m_stream)) != NULL ) )
return true;

return false;
@@ -110,7 +110,7 @@ void DramRowColumnLatencyMeasurement::Refresh()
}

//Get the input data
auto din = dynamic_cast<DDR3Waveform*>(GetInputWaveform(0));
auto din = dynamic_cast<SDRAMWaveform*>(GetInputWaveform(0));

//Create the output
auto cap = new AnalogWaveform;
@@ -133,14 +133,14 @@ void DramRowColumnLatencyMeasurement::Refresh()
continue;

//If it's an activate, update the last activation time
if(sample.m_stype == DDR3Symbol::TYPE_ACT)
if(sample.m_stype == SDRAMSymbol::TYPE_ACT)
lastAct[sample.m_bank] = tnow;

//If it's a read or write, measure the latency
else if( (sample.m_stype == DDR3Symbol::TYPE_WR) |
(sample.m_stype == DDR3Symbol::TYPE_WRA) |
(sample.m_stype == DDR3Symbol::TYPE_RD) |
(sample.m_stype == DDR3Symbol::TYPE_RDA) )
else if( (sample.m_stype == SDRAMSymbol::TYPE_WR) |
(sample.m_stype == SDRAMSymbol::TYPE_WRA) |
(sample.m_stype == SDRAMSymbol::TYPE_RD) |
(sample.m_stype == SDRAMSymbol::TYPE_RDA) )
{
int64_t tcol = tnow;

134 changes: 134 additions & 0 deletions scopeprotocols/SDRAMDecoderBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2021 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

#include "../scopehal/scopehal.h"
#include "SDRAMDecoderBase.h"
#include <algorithm>

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SDRAMDecoderBase

SDRAMDecoderBase::SDRAMDecoderBase(const string& color)
: Filter(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_MEMORY)
{

}

SDRAMDecoderBase::~SDRAMDecoderBase()
{
}

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

bool SDRAMDecoderBase::NeedsConfig()
{
return true;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pretty printing

Gdk::Color SDRAMDecoderBase::GetColor(int i)
{
auto capture = dynamic_cast<SDRAMWaveform*>(GetData(0));
if(capture != NULL)
{
const SDRAMSymbol& s = capture->m_samples[i];

switch(s.m_stype)
{
case SDRAMSymbol::TYPE_MRS:
case SDRAMSymbol::TYPE_REF:
case SDRAMSymbol::TYPE_PRE:
case SDRAMSymbol::TYPE_PREA:
return m_standardColors[COLOR_CONTROL];

case SDRAMSymbol::TYPE_ACT:
case SDRAMSymbol::TYPE_WR:
case SDRAMSymbol::TYPE_WRA:
case SDRAMSymbol::TYPE_RD:
case SDRAMSymbol::TYPE_RDA:
return m_standardColors[COLOR_ADDRESS];

case SDRAMSymbol::TYPE_ERROR:
default:
return m_standardColors[COLOR_ERROR];
}
}

//error
return m_standardColors[COLOR_ERROR];
}

string SDRAMDecoderBase::GetText(int i)
{
auto capture = dynamic_cast<SDRAMWaveform*>(GetData(0));
if(capture != NULL)
{
const SDRAMSymbol& s = capture->m_samples[i];

switch(s.m_stype)
{
case SDRAMSymbol::TYPE_MRS:
return "MRS";

case SDRAMSymbol::TYPE_REF:
return "REF";

case SDRAMSymbol::TYPE_PRE:
return "PRE";

case SDRAMSymbol::TYPE_PREA:
return "PREA";

case SDRAMSymbol::TYPE_ACT:
return "ACT";

case SDRAMSymbol::TYPE_WR:
return "WR";

case SDRAMSymbol::TYPE_WRA:
return "WRA";

case SDRAMSymbol::TYPE_RD:
return "RD";

case SDRAMSymbol::TYPE_RDA:
return "RDA";

case SDRAMSymbol::TYPE_ERROR:
default:
return "ERR";
}
}
return "";
}
87 changes: 87 additions & 0 deletions scopeprotocols/SDRAMDecoderBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2021 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Base class for all SDRAM decodes
*/
#ifndef SDRAMDecoder_h
#define SDRAMDecoder_h

class SDRAMSymbol
{
public:
enum stype
{
TYPE_MRS,
TYPE_REF,
TYPE_PRE,
TYPE_PREA,
TYPE_ACT,
TYPE_WR,
TYPE_WRA,
TYPE_RD,
TYPE_RDA,

TYPE_ERROR
};

SDRAMSymbol()
{}

SDRAMSymbol(stype t, int bank = 0)
: m_stype(t)
, m_bank(bank)
{}

stype m_stype;
int m_bank;

bool operator== (const SDRAMSymbol& s) const
{
return (m_stype == s.m_stype) && (m_bank == s.m_bank);
}
};

typedef Waveform<SDRAMSymbol> SDRAMWaveform;

class SDRAMDecoderBase : public Filter
{
public:
SDRAMDecoderBase(const std::string& color);
virtual ~SDRAMDecoderBase();

virtual std::string GetText(int i);
virtual Gdk::Color GetColor(int i);

virtual bool NeedsConfig();
};

#endif