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

Commits on Dec 1, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f0fbd17 View commit details
  2. Copy the full SHA
    8338bf1 View commit details
5 changes: 1 addition & 4 deletions scopehal/LeCroyOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -2227,11 +2227,8 @@ void LeCroyOscilloscope::Convert8BitSamplesAVX2(

for(unsigned int k=0; k<end; k += 32)
{
//This is likely a lot faster, but assumes we have 64 byte alignment on pin which is not guaranteed.
//TODO: fix alignment
//__m256i raw_samples = _mm256_load_si256(reinterpret_cast<__m256i*>(pin + k));

//Load all 32 raw ADC samples, without assuming alignment
//(on most modern Intel processors, load and loadu have same latency/throughput)
__m256i raw_samples = _mm256_loadu_si256(reinterpret_cast<__m256i*>(pin + k));

//Fill duration
1 change: 1 addition & 0 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ set(SCOPEPROTOCOLS_SOURCES
DSIPacketDecoder.cpp
DutyCycleMeasurement.cpp
DVIDecoder.cpp
EmphasisFilter.cpp
EmphasisRemovalFilter.cpp
Ethernet10BaseTDecoder.cpp
Ethernet100BaseTDecoder.cpp
187 changes: 187 additions & 0 deletions scopeprotocols/EmphasisFilter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* 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 *
* 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 "scopeprotocols.h"
#include "EmphasisFilter.h"
#include "TappedDelayLineFilter.h"

using namespace std;

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

EmphasisFilter::EmphasisFilter(const string& color)
: Filter(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_ANALYSIS)
, m_dataRateName("Data Rate")
, m_emphasisTypeName("Emphasis Type")
, m_emphasisAmountName("Emphasis Amount")
{
CreateInput("in");

m_range = 1;
m_offset = 0;
m_min = FLT_MAX;
m_max = -FLT_MAX;

m_parameters[m_dataRateName] = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_BITRATE));
m_parameters[m_dataRateName].SetIntVal(1250e6);

m_parameters[m_emphasisTypeName] = FilterParameter(FilterParameter::TYPE_ENUM, Unit(Unit::UNIT_COUNTS));
m_parameters[m_emphasisTypeName].AddEnumValue("De-emphasis", DE_EMPHASIS);
m_parameters[m_emphasisTypeName].AddEnumValue("Pre-emphasis", PRE_EMPHASIS);
m_parameters[m_emphasisTypeName].SetIntVal(DE_EMPHASIS);

m_parameters[m_emphasisAmountName] = FilterParameter(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_DB));
m_parameters[m_emphasisAmountName].SetFloatVal(6);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory methods

bool EmphasisFilter::ValidateChannel(size_t i, StreamDescriptor stream)
{
if(stream.m_channel == NULL)
return false;

if( (i == 0) && (stream.m_channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) )
return true;

return false;
}

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

void EmphasisFilter::ClearSweeps()
{
m_range = 1;
m_offset = 0;
m_min = FLT_MAX;
m_max = -FLT_MAX;
}

void EmphasisFilter::SetDefaultName()
{
char hwname[256];
snprintf(hwname, sizeof(hwname), "Emphasis(%s, %s)",
GetInputDisplayName(0).c_str(),
m_parameters[m_emphasisAmountName].ToString().c_str());
m_hwname = hwname;
m_displayname = m_hwname;
}

string EmphasisFilter::GetProtocolName()
{
return "Emphasis";
}

bool EmphasisFilter::IsOverlay()
{
//we create a new analog channel
return false;
}

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

double EmphasisFilter::GetVoltageRange()
{
return m_range;
}

double EmphasisFilter::GetOffset()
{
return m_offset;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actual decoder logic

void EmphasisFilter::Refresh()
{
if(!VerifyAllInputsOKAndAnalog())
{
SetData(NULL, 0);
return;
}

//Get the input data
auto din = GetAnalogInputWaveform(0);
size_t len = din->m_samples.size();
if(len < 8)
{
SetData(NULL, 0);
return;
}
m_xAxisUnit = m_inputs[0].m_channel->GetXAxisUnits();
m_yAxisUnit = m_inputs[0].m_channel->GetYAxisUnits();

//Set up output
auto cap = new AnalogWaveform;
cap->m_timescale = din->m_timescale;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startFemtoseconds = din->m_startFemtoseconds;
SetData(cap, 0);

//Convert data rate to tap delay
int64_t tap_delay = round(FS_PER_SECOND / m_parameters[m_dataRateName].GetFloatVal());

//Calculate the tap values
//Reference: "Dealing with De-Emphasis in Jitter Testing", P. Pupalaikis, LeCroy technical brief, 2008
const int64_t tap_count = 8;
float db = m_parameters[m_emphasisAmountName].GetFloatVal();
float emphasisLevel = pow(10, -db/20);
float coeff = 0.5 * emphasisLevel;
float c = coeff + 0.5;
float p = coeff - 0.5;
float taps[tap_count] = {0};
taps[0] = c;
taps[1] = p;

//If we're doing pre-emphasis rather than de-emphasis, we need to scale everything accordingly.
auto type = static_cast<EmphasisType>(m_parameters[m_emphasisTypeName].GetIntVal());
if(type == PRE_EMPHASIS)
{
for(int64_t i=0; i<tap_count; i++)
taps[i] /= emphasisLevel;
}

//Run the actual filter
float vmin;
float vmax;
TappedDelayLineFilter::DoFilterKernel(tap_delay, taps, din, cap, vmin, vmax);

//Calculate bounds
m_max = max(m_max, vmax);
m_min = min(m_min, vmin);
m_range = (m_max - m_min) * 1.05;
m_offset = -( (m_max - m_min)/2 + m_min );
}
78 changes: 78 additions & 0 deletions scopeprotocols/EmphasisFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* 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 *
* 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 Declaration of EmphasisFilter
*/
#ifndef EmphasisFilter_h
#define EmphasisFilter_h

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

virtual void Refresh();

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

virtual void ClearSweeps();

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

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

virtual bool ValidateChannel(size_t i, StreamDescriptor stream);

PROTOCOL_DECODER_INITPROC(EmphasisFilter)

enum EmphasisType
{
PRE_EMPHASIS,
DE_EMPHASIS
};

protected:

float m_min;
float m_max;
float m_range;
float m_offset;

std::string m_dataRateName;
std::string m_emphasisTypeName;
std::string m_emphasisAmountName;
};

#endif
1 change: 1 addition & 0 deletions scopeprotocols/scopeprotocols.cpp
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ void ScopeProtocolStaticInit()
AddDecoderClass(DSIPacketDecoder);
AddDecoderClass(DutyCycleMeasurement);
AddDecoderClass(DVIDecoder);
AddDecoderClass(EmphasisFilter);
AddDecoderClass(EmphasisRemovalFilter);
AddDecoderClass(Ethernet10BaseTDecoder);
AddDecoderClass(Ethernet100BaseTDecoder);
1 change: 1 addition & 0 deletions scopeprotocols/scopeprotocols.h
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@
#include "DSIPacketDecoder.h"
#include "DutyCycleMeasurement.h"
#include "DVIDecoder.h"
#include "EmphasisFilter.h"
#include "EmphasisRemovalFilter.h"
#include "EthernetProtocolDecoder.h" //must be before all other ethernet decodes
#include "EthernetAutonegotiationDecoder.h"