Skip to content

Commit 8385019

Browse files
committed
Ethernet64b66bDecoder: initial refactoring and error reporting
1 parent 0979b79 commit 8385019

2 files changed

Lines changed: 31 additions & 13 deletions

File tree

scopeprotocols/Ethernet64b66bDecoder.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopeprotocols *
44
* *
5-
* Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -56,7 +56,7 @@ Ethernet64b66bDecoder::Ethernet64b66bDecoder(const string& color)
5656

5757
bool Ethernet64b66bDecoder::ValidateChannel(size_t i, StreamDescriptor stream)
5858
{
59-
if(stream.m_channel == NULL)
59+
if(stream.m_channel == nullptr)
6060
return false;
6161

6262
if( (i < 2) && (stream.GetType() == Stream::STREAM_TYPE_DIGITAL) )
@@ -73,12 +73,33 @@ string Ethernet64b66bDecoder::GetProtocolName()
7373
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7474
// Actual decoder logic
7575

76-
void Ethernet64b66bDecoder::Refresh()
76+
Filter::DataLocation Ethernet64b66bDecoder::GetInputLocation()
7777
{
78+
//We explicitly manage our input memory and don't care where it is when Refresh() is called
79+
return LOC_DONTCARE;
80+
}
81+
82+
void Ethernet64b66bDecoder::Refresh(
83+
[[maybe_unused]] vk::raii::CommandBuffer& cmdBuf,
84+
[[maybe_unused]] shared_ptr<QueueHandle> queue)
85+
{
86+
#ifdef HAVE_NVTX
87+
nvtx3::scoped_range nrange("Ethernet64b66bDecoder::Refresh");
88+
#endif
89+
7890
//Get the input data
91+
ClearErrors();
7992
if(!VerifyAllInputsOK())
8093
{
81-
SetData(NULL, 0);
94+
for(int i=0; i<2; i++)
95+
{
96+
if(!GetInput(i))
97+
AddErrorMessage("Missing inputs", string("No signal input connected to ") + m_signalNames[i] );
98+
else if(!GetInputWaveform(i))
99+
AddErrorMessage("Missing inputs", string("No waveform available at input ") + m_signalNames[i] );
100+
}
101+
102+
SetData(nullptr, 0);
82103
return;
83104
}
84105
auto din = GetInputWaveform(0);
@@ -87,10 +108,9 @@ void Ethernet64b66bDecoder::Refresh()
87108
clkin->PrepareForCpuAccess();
88109

89110
//Create the capture
90-
auto cap = new Ethernet64b66bWaveform;
111+
auto cap = SetupEmptyWaveform<Ethernet64b66bWaveform>(din, 0);
91112
cap->m_timescale = 1;
92-
cap->m_startTimestamp = din->m_startTimestamp;
93-
cap->m_startFemtoseconds = din->m_startFemtoseconds;
113+
cap->m_triggerPhase = 0;
94114
cap->PrepareForCpuAccess();
95115

96116
//Record the value of the data stream at each clock edge
@@ -117,7 +137,6 @@ void Ethernet64b66bDecoder::Refresh()
117137
}
118138
}
119139

120-
121140
//Decode the actual data
122141
bool first = true;
123142
uint64_t lfsr = 0;
@@ -178,11 +197,10 @@ void Ethernet64b66bDecoder::Refresh()
178197
}
179198
}
180199

181-
SetData(cap, 0);
182200
cap->MarkModifiedFromCpu();
183201
}
184202

185-
std::string Ethernet64b66bWaveform::GetColor(size_t i)
203+
string Ethernet64b66bWaveform::GetColor(size_t i)
186204
{
187205
const Ethernet64b66bSymbol& s = m_samples[i];
188206

@@ -207,4 +225,3 @@ string Ethernet64b66bWaveform::GetText(size_t i)
207225
snprintf(tmp, sizeof(tmp), "%016" PRIx64, s.m_data);
208226
return string(tmp);
209227
}
210-

scopeprotocols/Ethernet64b66bDecoder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopeprotocols *
44
* *
5-
* Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -69,7 +69,8 @@ class Ethernet64b66bDecoder : public Filter
6969
public:
7070
Ethernet64b66bDecoder(const std::string& color);
7171

72-
virtual void Refresh() override;
72+
virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
73+
virtual DataLocation GetInputLocation() override;
7374

7475
static std::string GetProtocolName();
7576

0 commit comments

Comments
 (0)