Skip to content

Commit 2ddcc02

Browse files
committed
added glitchCounter
1 parent d1b3cca commit 2ddcc02

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

doc/releaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ This file describes the main feature changes for released versions of ReadoutCar
2424

2525
## v0.40.2 - 16/02/2023
2626
- Fixed bug with o2-roc-ctp-emulator failing to parse hexadecimal values of the init-orbit option.
27+
28+
## next version
29+
- Added glitchCounter to roc-status (all output styles, including monitoring).

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ class ProgramStatus : public Program
176176
}
177177
}
178178
} else if (cardType == CardType::type::Cru) {
179-
formatHeader = " %-9s %-16s %-10s %-14s %-15s %-10s %-14s %-14s %-8s %-19s %-11s %-7s\n";
180-
formatRow = " %-9s %-16s %-10s %-14s %-15s %-10s %-14.2f %-14.2f %-8s %-19.1f %-11s %-7s\n";
181-
header = (boost::format(formatHeader) % "Link ID" % "GBT Mode Tx/Rx" % "Loopback" % "GBT MUX" % "Datapath Mode" % "Datapath" % "RX freq(MHz)" % "TX freq(MHz)" % "Status" % "Optical power(uW)" % "System ID" % "FEE ID").str();
179+
formatHeader = " %-9s %-16s %-10s %-14s %-15s %-10s %-14s %-14s %-8s %-19s %-11s %-7s %-10s\n";
180+
formatRow = " %-9s %-16s %-10s %-14s %-15s %-10s %-14.2f %-14.2f %-8s %-19.1f %-11s %-7s %-10s\n";
181+
header = (boost::format(formatHeader) % "Link ID" % "GBT Mode Tx/Rx" % "Loopback" % "GBT MUX" % "Datapath Mode" % "Datapath" % "RX freq(MHz)" % "TX freq(MHz)" % "Status" % "Optical power(uW)" % "System ID" % "FEE ID" % "Glitches").str();
182182
lineFat = std::string(header.length(), '=') + '\n';
183183
lineThin = std::string(header.length(), '-') + '\n';
184184

@@ -379,6 +379,7 @@ class ProgramStatus : public Program
379379

380380
float rxFreq = link.rxFreq;
381381
float txFreq = link.txFreq;
382+
int glitchCounter = link.glitchCounter;
382383

383384
std::string linkStatus;
384385
if (link.stickyBit == Cru::LinkStatus::Up) {
@@ -407,6 +408,7 @@ class ProgramStatus : public Program
407408
.addValue(opticalPower, "opticalPower")
408409
.addValue(systemId, "systemId")
409410
.addValue(feeId, "feeId")
411+
.addValue(glitchCounter, "glitchCounter")
410412
.addTag(tags::Key::SerialId, card.serialId.getSerial())
411413
.addTag(tags::Key::Endpoint, card.serialId.getEndpoint())
412414
.addTag(tags::Key::CRU, card.sequenceId)
@@ -427,11 +429,12 @@ class ProgramStatus : public Program
427429
linkNode.put("opticalPower", Utilities::toPreciseString(opticalPower));
428430
linkNode.put("systemId", systemId);
429431
linkNode.put("feeId", feeId);
432+
linkNode.put("glitchCounter", glitchCounter);
430433

431434
// add the link node to the tree
432435
root.add_child(std::to_string(globalId), linkNode);
433436
} else {
434-
auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower % systemId % feeId;
437+
auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower % systemId % feeId % glitchCounter;
435438
table << format;
436439
}
437440
}

src/Cru/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct Link {
7171
uint32_t feeId = 0x0;
7272
/*uint32_t systemId = 0x1ff; // invalid, used as "unset" placeholder
7373
uint32_t feeId = 0x1f; // invalid, used as "unset" placeholder*/
74+
uint32_t glitchCounter = 0;
7475

7576
bool operator==(const Link& dlink) const
7677
{

src/Cru/Constants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ static constexpr Register GBT_LINK_CLEAR_ERRORS(0x00000038);
254254
static constexpr Register GBT_LINK_RX_CLOCK(0x00000008);
255255
static constexpr Register GBT_LINK_TX_CLOCK(0x00000004);
256256

257+
/// Register for getting the glitch counter
258+
static constexpr Register GBT_LINK_GLITCH_COUNTER(0x00000044);
259+
257260
/// Register for selecting the the GBT Multiplexer
258261
static constexpr Register GBT_MUX_SELECT(0x0000001c);
259262
/*static constexpr uint32_t GBT_MUX_TTC(0x0);

src/Cru/CruBar.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ Cru::ReportInfo CruBar::report(bool forConfig)
503503
link.stickyBit = gbt.getStickyBit(link);
504504
link.rxFreq = gbt.getRxClockFrequency(link) / 1e6; // Hz -> Mhz
505505
link.txFreq = gbt.getTxClockFrequency(link) / 1e6; // Hz -> Mhz
506+
link.glitchCounter = gbt.getGlitchCounter(link);
506507
link.systemId = datapathWrapper.getSystemId(link);
507508
link.feeId = datapathWrapper.getFeeId(link);
508509

src/Cru/Gbt.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ uint32_t Gbt::getTxClockFrequency(Link link) //In Hz
315315
return mPdaBar->readRegister(address / 4);
316316
}
317317

318+
uint32_t Gbt::getGlitchCounter(Link link)
319+
{
320+
uint32_t address = Cru::getWrapperBaseAddress(link.wrapper) +
321+
Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1) +
322+
Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1) +
323+
Cru::Registers::GBT_LINK_REGS_OFFSET.address +
324+
Cru::Registers::GBT_LINK_GLITCH_COUNTER.address;
325+
326+
return mPdaBar->readRegister(address / 4);
327+
}
328+
318329
void Gbt::resetFifo()
319330
{
320331
mPdaBar->modifyRegister(Cru::Registers::BSP_USER_CONTROL.index, 7, 1, 0x1); // reset TX

src/Cru/Gbt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Gbt
5151
LinkStatus getStickyBit(Link link);
5252
uint32_t getRxClockFrequency(Link link);
5353
uint32_t getTxClockFrequency(Link link);
54+
uint32_t getGlitchCounter(Link link);
5455
void resetFifo();
5556
std::map<int, LoopbackStats> getLoopbackStats(bool reset, GbtPatternMode::type patternMode = GbtPatternMode::type::Counter,
5657
GbtCounterType::type counterType = GbtCounterType::type::ThirtyBit,

0 commit comments

Comments
 (0)