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

Commits on Jul 26, 2020

  1. Copy the full SHA
    cf9a397 View commit details
  2. Initial implementation of channel emulation. Not closing the ticket b…

    …ecause phase correction is screwed up for some reason.
    azonenberg committed Jul 26, 2020
    Copy the full SHA
    0109bda View commit details
2 changes: 2 additions & 0 deletions scopehal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ set(SCOPEHAL_SOURCES
SCPISocketTransport.cpp
VICPSocketTransport.cpp
SCPILxiTransport.cpp
SCPINullTransport.cpp
SCPITMCTransport.cpp
SCPIDevice.cpp

@@ -44,6 +45,7 @@ set(SCOPEHAL_SOURCES
MockOscilloscope.cpp
SiglentSCPIOscilloscope.cpp
RigolOscilloscope.cpp
SignalGeneratorOscilloscope.cpp
TektronixOscilloscope.cpp
RohdeSchwarzOscilloscope.cpp
RohdeSchwarzHMC8012Multimeter.cpp
19 changes: 6 additions & 13 deletions scopehal/IBISParser.cpp
Original file line number Diff line number Diff line change
@@ -307,17 +307,12 @@ vector<float> IBISModel::CalculateTurnonCurve(
*/
AnalogWaveform* IBISModel::SimulatePRBS(
/*DigitalWaveform* input, */
uint32_t seed,
IBISCorner corner,
int64_t timescale,
size_t length,
size_t ui)
{
//Look up some properties of this buffer
float vcc = m_voltages[corner];
auto& pulldown = m_pulldown[corner];
auto& pullup = m_pullup[corner];
float cap = m_dieCapacitance[corner];

//Find the rising and falling edge waveform terminated to the highest voltage (Vcc etc)
//TODO: make this configurable
VTCurves* rising = GetHighestRisingWaveform();
@@ -326,7 +321,7 @@ AnalogWaveform* IBISModel::SimulatePRBS(
const float dt = timescale * 1e-12;

//PRBS-31 generator
uint32_t prbs = 0x5eadbeef;
uint32_t prbs = seed;

//Create the output waveform
auto ret = new AnalogWaveform;
@@ -345,8 +340,6 @@ AnalogWaveform* IBISModel::SimulatePRBS(
bool current_edge_started = false;
for(size_t nstep=0; nstep<length; nstep ++)
{
float time = dt*nstep;

//Advance to next UI
if(0 == (nstep % ui))
{
@@ -373,15 +366,15 @@ AnalogWaveform* IBISModel::SimulatePRBS(
//Get value for current and previous edge
float current_v;
if(current_bit)
current_v = rising->InterpolateVoltage(CORNER_TYP, current_phase*dt);
current_v = rising->InterpolateVoltage(corner, current_phase*dt);
else
current_v = falling->InterpolateVoltage(CORNER_TYP, current_phase*dt);
current_v = falling->InterpolateVoltage(corner, current_phase*dt);

float last_v;
if(last_bit)
last_v = rising->InterpolateVoltage(CORNER_TYP, last_phase*dt);
last_v = rising->InterpolateVoltage(corner, last_phase*dt);
else
last_v = falling->InterpolateVoltage(CORNER_TYP, last_phase*dt);
last_v = falling->InterpolateVoltage(corner, last_phase*dt);

//See if the current UI's edge has started
float delta = current_v - current_v_old;
1 change: 1 addition & 0 deletions scopehal/IBISParser.h
Original file line number Diff line number Diff line change
@@ -176,6 +176,7 @@ class IBISModel

AnalogWaveform* SimulatePRBS(
/*DigitalWaveform* input, */
uint32_t seed,
IBISCorner corner,
int64_t timescale,
size_t length,
33 changes: 18 additions & 15 deletions scopehal/SCPIDevice.cpp
Original file line number Diff line number Diff line change
@@ -39,25 +39,28 @@ SCPIDevice::SCPIDevice()
//mostly used by not-quite-really-scpi devices that use SCPITransport but don't implement *IDN?
}

SCPIDevice::SCPIDevice(SCPITransport* transport)
SCPIDevice::SCPIDevice(SCPITransport* transport, bool identify)
: m_transport(transport)
{
//Ask for the ID
m_transport->SendCommand("*IDN?");
string reply = m_transport->ReadReply();
char vendor[128] = "";
char model[128] = "";
char serial[128] = "";
char version[128] = "";
if(4 != sscanf(reply.c_str(), "%127[^,],%127[^,],%127[^,],%127s", vendor, model, serial, version))
if(identify)
{
LogError("Bad IDN response %s\n", reply.c_str());
return;
//Ask for the ID
m_transport->SendCommand("*IDN?");
string reply = m_transport->ReadReply();
char vendor[128] = "";
char model[128] = "";
char serial[128] = "";
char version[128] = "";
if(4 != sscanf(reply.c_str(), "%127[^,],%127[^,],%127[^,],%127s", vendor, model, serial, version))
{
LogError("Bad IDN response %s\n", reply.c_str());
return;
}
m_vendor = vendor;
m_model = model;
m_serial = serial;
m_fwVersion = version;
}
m_vendor = vendor;
m_model = model;
m_serial = serial;
m_fwVersion = version;
}

SCPIDevice::~SCPIDevice()
2 changes: 1 addition & 1 deletion scopehal/SCPIDevice.h
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ class SCPIDevice
{
public:
SCPIDevice();
SCPIDevice(SCPITransport* transport);
SCPIDevice(SCPITransport* transport, bool identify = true);
virtual ~SCPIDevice();

protected:
98 changes: 98 additions & 0 deletions scopehal/SCPINullTransport.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/***********************************************************************************************************************
* *
* 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 Implementation of SCPINullTransport
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>

#include "scopehal.h"

using namespace std;

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

SCPINullTransport::SCPINullTransport(string args)
: m_args(args)
{
}

SCPINullTransport::~SCPINullTransport()
{

}

bool SCPINullTransport::IsConnected()
{
return true;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actual transport code

string SCPINullTransport::GetTransportName()
{
return "null";
}

string SCPINullTransport::GetConnectionString()
{
return m_args;
}

bool SCPINullTransport::SendCommand(string /*cmd*/)
{
return true;
}

string SCPINullTransport::ReadReply()
{
return "";
}

void SCPINullTransport::SendRawData(size_t /*len*/, const unsigned char* /*buf*/)
{
}

void SCPINullTransport::ReadRawData(size_t /*len*/, unsigned char* /*buf*/)
{
}

bool SCPINullTransport::IsCommandBatchingSupported()
{
return false;
}
65 changes: 65 additions & 0 deletions scopehal/SCPINullTransport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/***********************************************************************************************************************
* *
* 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 SCPINullTransport
*/

#ifndef SCPINullTransport_h
#define SCPINullTransport_h

/**
@brief Null SCPITransport for simulated scopes (signal generator etc)
*/
class SCPINullTransport : public SCPITransport
{
public:
SCPINullTransport(std::string args);
virtual ~SCPINullTransport();

virtual std::string GetConnectionString();
static std::string GetTransportName();

virtual bool SendCommand(std::string cmd);
virtual std::string ReadReply();
virtual void ReadRawData(size_t len, unsigned char* buf);
virtual void SendRawData(size_t len, const unsigned char* buf);

virtual bool IsCommandBatchingSupported();
virtual bool IsConnected();

TRANSPORT_INITPROC(SCPINullTransport)

protected:
std::string m_args;
};

#endif
4 changes: 2 additions & 2 deletions scopehal/SCPIOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

SCPIOscilloscope::SCPIOscilloscope(SCPITransport* transport)
: SCPIDevice(transport)
SCPIOscilloscope::SCPIOscilloscope(SCPITransport* transport, bool identify)
: SCPIDevice(transport, identify)
{

}
2 changes: 1 addition & 1 deletion scopehal/SCPIOscilloscope.h
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ class SCPIOscilloscope : public Oscilloscope
, public SCPIDevice
{
public:
SCPIOscilloscope(SCPITransport* transport);
SCPIOscilloscope(SCPITransport* transport, bool identify = true);
virtual ~SCPIOscilloscope();

virtual std::string IDPing();
Loading