Skip to content

Commit 46e07b7

Browse files
committed
[bench-dma] Add TF-orbit check for the CRORC
1 parent d5eab3c commit 46e07b7

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ class ProgramDmaBench : public Program
195195
options.add_options()("time",
196196
po::value<std::string>(&mOptions.timeLimitString),
197197
"Time limit for benchmark. Any combination of [n]h, [n]m, & [n]s. For example: '5h30m', '10s', '1s2h3m'.");
198+
options.add_options()("timeframe-length",
199+
po::value<uint32_t>(&mOptions.timeFrameLength)->default_value(256),
200+
"Time Frame length");
198201
options.add_options()("to-file-ascii",
199202
po::value<std::string>(&mOptions.fileOutputPathAscii),
200203
"Read out to given file in ASCII format");
@@ -622,7 +625,7 @@ class ProgramDmaBench : public Program
622625
if (mEventCounters[linkId] % mErrorCheckFrequency == 0) {
623626
switch (mCardType) {
624627
case CardType::Crorc:
625-
hasError = checkErrorsCrorc(pageAddress, pageSize, readoutCount, linkId);
628+
hasError = checkErrorsCrorc(pageAddress, pageSize, readoutCount, linkId, atStartOfSuperpage);
626629
break;
627630
case CardType::Cru:
628631
hasError = checkErrorsCru(pageAddress, pageSize, readoutCount, linkId, atStartOfSuperpage);
@@ -799,7 +802,7 @@ class ProgramDmaBench : public Program
799802
}
800803
}
801804

802-
bool checkErrorsCrorc(uintptr_t pageAddress, size_t pageSize, int64_t eventNumber, int linkId)
805+
bool checkErrorsCrorc(uintptr_t pageAddress, size_t pageSize, int64_t eventNumber, int linkId, bool atStartOfSuperpage)
803806
{
804807
const auto memBytes = DataFormat::getMemsize(reinterpret_cast<const char*>(pageAddress));
805808
if (memBytes > pageSize) {
@@ -826,6 +829,32 @@ class ProgramDmaBench : public Program
826829
mPacketCounters[linkId] = packetCounter;
827830
}
828831

832+
// check that the TimeFrame starts at the beginning of the superpage
833+
const auto triggerType = DataFormat::getTriggerType(reinterpret_cast<const char*>(pageAddress));
834+
const auto orbit = DataFormat::getOrbit(reinterpret_cast<const char*>(pageAddress));
835+
const auto pagesCounter = DataFormat::getPagesCounter(reinterpret_cast<const char*>(pageAddress));
836+
const auto bunchCrossing = DataFormat::getBunchCrossing(reinterpret_cast<const char*>(pageAddress));
837+
838+
//std::cout << atStartOfSuperpage << " " << triggerType << " " << orbit << " " << mNextTFOrbit << " " << bunchCrossing << " " << pagesCounter << std::endl;
839+
//std::cout << atStartOfSuperpage << " " << orbit << " " << mNextTFOrbit << std::endl;
840+
841+
if (Utilities::getBit(triggerType, 9) == 0x1 || Utilities::getBit(triggerType, 7) == 0x1) { // If SOX, use current orbit as the first one
842+
mNextTFOrbit = (orbit + mOptions.timeFrameLength) % (0x100000000);
843+
//std::cout << mNextTFOrbit << std::endl;
844+
} else if (orbit >= mNextTFOrbit) { // next orbit should be previous orbit + time frame length
845+
if (!atStartOfSuperpage || (orbit >= (mNextTFOrbit + mOptions.timeFrameLength) % (0x100000000))) { // but not more than orbit + 2 * time frame length
846+
// log TF not at the beginning of the superpage error
847+
mErrorCount++;
848+
//std::cout << "ERROR" << std::endl;
849+
if (mErrorCount < MAX_RECORDED_ERRORS) {
850+
mErrorStream << b::format("[RDHERR]\tevent:%1% l:%2% payloadBytes:%3% size:%4% packet_cnt:%5% mpacket_cnt:%6% levent:%7% orbit:%8%: TF unaligned w/ start of superpage\n") % eventNumber % linkId % memBytes % pageSize % packetCounter % mPacketCounters[linkId] % mEventCounters[linkId] % orbit;
851+
}
852+
}
853+
// Update next TF orbit expected
854+
mNextTFOrbit = (mNextTFOrbit + mOptions.timeFrameLength) % (0x100000000);
855+
//std::cout << mNextTFOrbit << std::endl;
856+
}
857+
829858
if (mFastCheckEnabled) {
830859
return false;
831860
}
@@ -1110,6 +1139,7 @@ class ProgramDmaBench : public Program
11101139
bool stbrd = false;
11111140
bool byteCountEnabled = false;
11121141
bool bypassFirmwareCheck = false;
1142+
uint32_t timeFrameLength = 256;
11131143
} mOptions;
11141144

11151145
/// The DMA channel
@@ -1214,6 +1244,9 @@ class ProgramDmaBench : public Program
12141244

12151245
/// Data Source
12161246
DataSource::type mDataSource;
1247+
1248+
/// The orbit number that coincides with the next TimeFrame
1249+
uint32_t mNextTFOrbit = 0x0;
12171250
};
12181251

12191252
int main(int argc, char** argv)

0 commit comments

Comments
 (0)