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

Commits on Mar 1, 2020

  1. AntikernelLogicAnalyzer: continued initial implementation. Works, but…

    … still no proper trigger configuration.
    azonenberg committed Mar 1, 2020
    Copy the full SHA
    e5d17f9 View commit details
Showing with 44 additions and 47 deletions.
  1. +40 −47 scopehal/AntikernelLogicAnalyzer.cpp
  2. +4 −0 scopehal/AntikernelLogicAnalyzer.h
87 changes: 40 additions & 47 deletions scopehal/AntikernelLogicAnalyzer.cpp
Original file line number Diff line number Diff line change
@@ -135,18 +135,14 @@ void AntikernelLogicAnalyzer::LoadChannels()
LogDebug("Logic analyzer: loading channel metadata\n");
LogIndenter li;

//Send a long string of nops to reset the LA out of whatever state it might be in
for(int i=0; i<32; i++)
SendCommand(CMD_NOP);

//Get the number of channels
SendCommand(CMD_GET_CHANNEL_COUNT);
uint8_t nchans = Read1ByteReply();

//Get the length of the names
SendCommand(CMD_GET_NAME_LEN);
uint8_t namelen = Read1ByteReply();
LogDebug("We have %d channels, %d chars per name\n", nchans, namelen);
//LogDebug("We have %d channels, %d chars per name\n", nchans, namelen);

char* namebuf = new char[namelen + 1];

@@ -187,11 +183,13 @@ void AntikernelLogicAnalyzer::LoadChannels()
m_highIndexes.push_back(index + width - 1);
index += width;

/*
LogDebug("Channel: %s (%d bits wide, from %zu to %zu)\n",
realname.c_str(),
width,
m_lowIndexes[i],
m_highIndexes[i]);
*/
}

delete[] namebuf;
@@ -200,8 +198,18 @@ void AntikernelLogicAnalyzer::LoadChannels()
SendCommand(CMD_GET_SAMPLE_PERIOD);
m_transport->ReadRawData(3, (unsigned char*)rawperiod);
m_samplePeriod = (rawperiod[0] << 16) | (rawperiod[1] << 8) | rawperiod[2];
LogDebug("Sample period is %u ps\n", m_samplePeriod);
//LogDebug("Sample period is %u ps\n", m_samplePeriod);

//Get memory aspect ratio info
uint8_t rawlen[3];
uint8_t rawwidth[3];
SendCommand(CMD_GET_DEPTH);
m_transport->ReadRawData(3, (unsigned char*)rawlen);
SendCommand(CMD_GET_TOTAL_WIDTH);
m_transport->ReadRawData(3, (unsigned char*)rawwidth);
m_memoryDepth = (rawlen[0] << 16) | (rawlen[1] << 8) | rawlen[2];
m_memoryWidth = (rawwidth[0] << 16) | (rawwidth[1] << 8) | rawwidth[2];
//LogDebug("Capture memory is %u samples long\n", depth);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -242,25 +250,16 @@ bool AntikernelLogicAnalyzer::AcquireData(bool toQueue)
{
lock_guard<recursive_mutex> lock(m_mutex);

LogDebug("Acquiring data...\n");
//LogDebug("Acquiring data...\n");
LogIndenter li;

//Get memory aspect ratio info
uint8_t rawlen[3];
uint8_t rawwidth[3];
SendCommand(CMD_GET_DEPTH);
m_transport->ReadRawData(3, (unsigned char*)rawlen);
SendCommand(CMD_GET_TOTAL_WIDTH);
m_transport->ReadRawData(3, (unsigned char*)rawwidth);
uint32_t depth = (rawlen[0] << 16) | (rawlen[1] << 8) | rawlen[2];
uint32_t width = (rawwidth[0] << 16) | (rawwidth[1] << 8) | rawwidth[2];
LogDebug("Capture memory is %u samples long\n", depth);
uint32_t bytewidth = width/8;
if(width & 7)
//Calculate some memory dimensions
uint32_t bytewidth = m_memoryWidth/8;
if(m_memoryWidth & 7)
bytewidth ++;
LogDebug("Capture memory is %u bits (%u bytes) wide\n", width, bytewidth);
uint32_t memsize = bytewidth*depth;
LogDebug("Total capture is %u bytes\n", memsize);
//LogDebug("Capture memory is %u bits (%u bytes) wide\n", m_memoryWidth, bytewidth);
uint32_t memsize = bytewidth*m_memoryDepth;
//LogDebug("Total capture is %u bytes\n", memsize);

//Read the actual data
vector<uint8_t> data;
@@ -288,10 +287,11 @@ bool AntikernelLogicAnalyzer::AcquireData(bool toQueue)
cap->m_timescale = m_samplePeriod;
cap->m_triggerPhase = 0;
cap->m_startTimestamp = time;
cap->m_samples.resize(depth);
cap->m_startPicoseconds = (time - floor(time)) * 1e12f;
cap->m_samples.resize(m_memoryDepth);

//Pull the data
for(size_t j=0; j<depth; j++)
for(size_t j=0; j<m_memoryDepth; j++)
{
uint8_t s = data[j*bytewidth + nbyte];
cap->m_samples[j] = DigitalSample(j, 1, (s >> nbit) & 1 ? true : false);
@@ -311,9 +311,10 @@ bool AntikernelLogicAnalyzer::AcquireData(bool toQueue)
cap->m_timescale = m_samplePeriod;
cap->m_triggerPhase = 0;
cap->m_startTimestamp = time;
cap->m_samples.resize(depth);
cap->m_startPicoseconds = (time - floor(time)) * 1e12f;
cap->m_samples.resize(m_memoryDepth);

for(size_t j=0; j<depth; j++)
for(size_t j=0; j<m_memoryDepth; j++)
{
vector<bool> bits;
for(size_t k=0; k<cwidth; k++)
@@ -339,40 +340,32 @@ bool AntikernelLogicAnalyzer::AcquireData(bool toQueue)
m_pendingWaveformsMutex.unlock();

//Re-arm the trigger if not in one-shot mode
/*if(!m_triggerOneShot)
{
SendCommand(CMD_ARM);
m_triggerArmed = true;
//DEBUG: force a trigger
SendCommand(CMD_FORCE);
}*/
m_triggerArmed = false;
if(!m_triggerOneShot)
ArmTrigger();
else
m_triggerArmed = false;

return true;
}

void AntikernelLogicAnalyzer::StartSingleTrigger()
void AntikernelLogicAnalyzer::ArmTrigger()
{
lock_guard<recursive_mutex> lock(m_mutex);

SendCommand(CMD_ARM);

m_triggerArmed = true;

SendCommand(CMD_FORCE);
}

void AntikernelLogicAnalyzer::StartSingleTrigger()
{
m_triggerOneShot = true;
ArmTrigger();
}

void AntikernelLogicAnalyzer::Start()
{
lock_guard<recursive_mutex> lock(m_mutex);

SendCommand(CMD_ARM);

m_triggerArmed = true;
m_triggerOneShot = false;

//DEBUG: force a trigger event (until we have a proper UI for configuring triggers)
SendCommand(CMD_FORCE);
ArmTrigger();
}

void AntikernelLogicAnalyzer::Stop()
4 changes: 4 additions & 0 deletions scopehal/AntikernelLogicAnalyzer.h
Original file line number Diff line number Diff line change
@@ -97,6 +97,8 @@ class AntikernelLogicAnalyzer
void SendCommand(uint8_t opcode, uint8_t chan);
uint8_t Read1ByteReply();

void ArmTrigger();

bool m_triggerArmed;
bool m_triggerOneShot;

@@ -106,6 +108,8 @@ class AntikernelLogicAnalyzer
std::vector<size_t> m_highIndexes;

uint32_t m_samplePeriod;
uint32_t m_memoryDepth;
uint32_t m_memoryWidth;
};

#endif