Skip to content

Commit 6d97434

Browse files
committed
Add STBRD trigger command for the CRORC
1 parent 8d73529 commit 6d97434

File tree

7 files changed

+60
-11
lines changed

7 files changed

+60
-11
lines changed

include/ReadoutCard/Parameters.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,27 @@ class Parameters
8787
/// Type for the gbt mux map parameter
8888
using GbtMuxMapType = std::map<uint32_t, GbtMux::type>;
8989

90+
/// Type for the clock parameter
9091
using ClockType = Clock::type;
92+
93+
/// Type for the datapath mode parameter
9194
using DatapathModeType = DatapathMode::type;
95+
96+
/// Type for the downstream data parameter
9297
using DownstreamDataType = DownstreamData::type;
98+
99+
/// Type for the gbt mux parameter
93100
using GbtMuxType = GbtMux::type;
101+
102+
/// Type for the gbt mode parameter
94103
using GbtModeType = GbtMode::type;
95104

105+
/// Type for the link loopback enabled parameter
96106
using LinkLoopbackEnabledType = bool;
97107

108+
/// Type for the STBRD enabled parameter
109+
using StbrdEnabledType = bool;
110+
98111
// Setters
99112

100113
/// Sets the CardId parameter
@@ -301,6 +314,14 @@ class Parameters
301314
/// \return Reference to this object for chaining calls
302315
auto setGbtMuxMap(GbtMuxMapType value) -> Parameters&;
303316

317+
/// Sets the StbrdEnabled parameter
318+
///
319+
/// If enabled the STBRD command is used to start the CRORC trigger.
320+
///
321+
/// \param value The value to set
322+
/// \return Reference to this object for chaining calls
323+
auto setStbrdEnabled(StbrdEnabledType value) -> Parameters&;
324+
304325

305326
// on-throwing getters
306327

@@ -376,6 +397,10 @@ class Parameters
376397
/// \return The value
377398
auto getGbtMuxMap() const -> boost::optional<GbtMuxMapType>;
378399

400+
/// Gets the StbrdEnabled parameter
401+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
402+
auto getStbrdEnabled() const -> boost::optional<StbrdEnabledType>;
403+
379404
// Throwing getters
380405

381406
/// Gets the CardId parameter
@@ -468,6 +493,11 @@ class Parameters
468493
/// \return The value
469494
auto getGbtMuxMapRequired() const -> GbtMuxMapType;
470495

496+
/// Gets the StbrdEnabled parameter
497+
/// \exception ParameterException The parameter was not present
498+
/// \return The value
499+
auto getStbrdEnabledRequired() const -> StbrdEnabledType;
500+
471501
// Helper functions
472502

473503
/// Convenience function to make a Parameters object with card ID and channel number, since these are the most

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ class ProgramDmaBench: public Program
186186
("readout-mode",
187187
po::value<std::string>(&mOptions.readoutModeString),
188188
"Set readout mode [CONTINUOUS]")
189+
("stbrd",
190+
po::value<bool>(&mOptions.stbrd),
191+
"Set the STBRD trigger command for the CRORC")
189192
("superpage-size",
190193
SuffixOption<size_t>::make(&mSuperpageSize)->default_value("1Mi"),
191194
"Superpage size in bytes. Note that it can't be larger than the buffer. If the IOMMU is not enabled, the "
@@ -225,6 +228,7 @@ class ProgramDmaBench: public Program
225228
if (!mOptions.generatorEnabled) // if generator is not enabled, force loopbackMode=NONE for proper errorchecking
226229
mOptions.loopbackModeString = "NONE";
227230
params.setGeneratorLoopback(LoopbackMode::fromString(mOptions.loopbackModeString));
231+
params.setStbrdEnabled(mOptions.stbrd); //Set STBRD for the CRORC
228232

229233
// Handle file output options
230234
{
@@ -1192,6 +1196,7 @@ class ProgramDmaBench: public Program
11921196
uint64_t pausePush;
11931197
uint64_t pauseRead;
11941198
size_t maxRdhPacketCounter;
1199+
bool stbrd = false;
11951200
} mOptions;
11961201

11971202
/// The DMA channel

src/Crorc/Crorc.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,14 @@ void Crorc::setDiuLoopback(const DiuConfig& diuConfig)
886886
ddlSetDiuLoopBack(diuConfig);
887887
}
888888

889-
void Crorc::startTrigger(const DiuConfig& diuConfig)
889+
void Crorc::startTrigger(const DiuConfig& diuConfig, uint32_t command)
890890
{
891+
if ((command != Fee::RDYRX) && (command != Fee::STBRD)) {
892+
BOOST_THROW_EXCEPTION(Exception() <<
893+
ErrorInfo::Message("Trigger can only be started with RDYRX or STBRD."));
894+
}
891895
uint64_t timeout = Ddl::RESPONSE_TIME * diuConfig.pciLoopPerUsec;
892-
ddlSendCommand(Ddl::Destination::FEE, Fee::RDYRX, 0, 0, timeout);
896+
ddlSendCommand(Ddl::Destination::FEE, command, 0, 0, timeout);
893897
ddlWaitStatus(timeout);
894898
ddlReadStatus();
895899
}

src/Crorc/Crorc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class Crorc
9292
/// Checks if the C-RORC's Free FIFO is empty
9393
void assertFreeFifoEmpty();
9494

95-
/// Starts the trigger
96-
void startTrigger(const DiuConfig& diuConfig);
95+
/// Starts the trigger (RDYRX or STBRD)
96+
void startTrigger(const DiuConfig& diuConfig, uint32_t command);
9797

9898
/// Stops the trigger
9999
void stopTrigger(const DiuConfig& diuConfig);

src/Crorc/CrorcDmaChannel.cxx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CrorcDmaChannel::CrorcDmaChannel(const Parameters& parameters)
3131
: DmaChannelPdaBase(parameters, allowedChannels()), //
3232
mPageSize(parameters.getDmaPageSize().get_value_or(DMA_PAGE_SIZE)), // 8 kB default for uniformity with CRU
3333
mInitialResetLevel(ResetLevel::Internal), // It's good to reset at least the card channel in general
34-
mNoRDYRX(false), // Not sure
34+
mSTBRD(parameters.getStbrdEnabled().get_value_or(false)), //TODO: Set as a parameter
3535
mUseFeeAddress(false), // Not sure
3636
mLoopbackMode(parameters.getGeneratorLoopback().get_value_or(LoopbackMode::Internal)), // Internal loopback by default
3737
mGeneratorEnabled(parameters.getGeneratorEnabled().get_value_or(true)), // Use data generator by default
@@ -55,6 +55,11 @@ CrorcDmaChannel::CrorcDmaChannel(const Parameters& parameters)
5555
BOOST_THROW_EXCEPTION(CruException() << ErrorInfo::Message("CRORC does not support given loopback mode")
5656
<< ErrorInfo::LoopbackMode(mLoopbackMode));
5757
}
58+
59+
// Set mRDYRX if generator is disabled and mSTBRD is false
60+
if (!mGeneratorEnabled) {
61+
mRDYRX = mSTBRD ? false : true;
62+
}
5863

5964
// Prep for BAR
6065
auto bar = ChannelFactory().getBar(parameters);
@@ -145,16 +150,18 @@ void CrorcDmaChannel::startPendingDma()
145150
log("Starting data generator");
146151
startDataGenerator();
147152
} else {
148-
if (!mNoRDYRX) {
153+
if (mRDYRX || mSTBRD) {
149154
log("Starting trigger");
150155

151156
// Clearing SIU/DIU status.
152157
getCrorc().assertLinkUp();
153158
getCrorc().siuCommand(Ddl::RandCIFST);
154159
getCrorc().diuCommand(Ddl::RandCIFST);
155160

161+
uint32_t command = (mRDYRX) ? Fee::RDYRX : Fee::STBRD;
162+
156163
// RDYRX command to FEE
157-
getCrorc().startTrigger(mDiuConfig);
164+
getCrorc().startTrigger(mDiuConfig, command);
158165
}
159166
}
160167

@@ -169,7 +176,7 @@ void CrorcDmaChannel::deviceStopDma()
169176
if (mGeneratorEnabled) {
170177
getCrorc().stopDataGenerator();
171178
} else {
172-
if (!mNoRDYRX) {
179+
if (mRDYRX || mSTBRD) {
173180
// Sending EOBTR to FEE.
174181
getCrorc().stopTrigger(mDiuConfig);
175182
}

src/Crorc/CrorcDmaChannel.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,11 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
171171
/// Reset level on initialization of channel
172172
const ResetLevel::type mInitialResetLevel;
173173

174-
/// Prevents sending the RDYRX and EOBTR commands. TODO This switch is implicitly set when data generator or the
175-
/// STBRD command is used (???)
176-
const bool mNoRDYRX;
174+
/// Allows sending the RDYRX and EOBTR commands.
175+
bool mRDYRX;
176+
177+
/// Allows sending the STBRD and EOBTR commands for FEE configuration
178+
const bool mSTBRD;
177179

178180
/// Enforces that the data reading is carried out with the Start Block Read (STBRD) command
179181
/// XXX Not sure if this should be a parameter...

src/Parameters.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ _PARAMETER_FUNCTIONS(GbtMode, "gbt_mode")
119119
_PARAMETER_FUNCTIONS(GbtMux, "gbt_mux")
120120
_PARAMETER_FUNCTIONS(GbtMuxMap, "gbt_mux_map")
121121
_PARAMETER_FUNCTIONS(LinkLoopbackEnabled, "link_loopback_enabled")
122+
_PARAMETER_FUNCTIONS(StbrdEnabled, "stbrd_enabled")
122123
#undef _PARAMETER_FUNCTIONS
123124

124125
Parameters::Parameters() : mPimpl(std::make_unique<ParametersPimpl>())

0 commit comments

Comments
 (0)