Skip to content

Commit 49477fa

Browse files
committed
[config] Add user-and-common-logic option
1 parent 5152822 commit 49477fa

File tree

12 files changed

+78
-8
lines changed

12 files changed

+78
-8
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,14 @@ metric format for the CRORC and the CRU is different, as different parameters ar
464464
465465
###### Metric: `"CRU"`
466466
467-
| Value name | Value | Type |
468-
| ----------------- | ----------------------- | ------ |
469-
| `"pciAddress"` | - | string |
470-
| `"clock"` | "TTC" or "Local" | string |
471-
| `"dynamicOffset"` | 0/1 (Disabled/Enabled) | int |
472-
| `"userLogic"` | 0/1 (Disabled/Enabled) | int |
467+
| Value name | Value | Type |
468+
| --------------------------- | ----------------------- | ------ |
469+
| `"pciAddress"` | - | string |
470+
| `"clock"` | "TTC" or "Local" | string |
471+
| `"dynamicOffset"` | 0/1 (Disabled/Enabled) | int |
472+
| `"userLogic"` | 0/1 (Disabled/Enabled) | int |
473+
| `"runStats"` | 0/1 (Disabled/Enabled) | int |
474+
| `"commonAndUserLogic"` | 0/1 (Disabled/Enabled) | int |
473475
474476
| Tag key | Value |
475477
| ----------------- | ------------------ |

cru_template.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ userLogicEnabled=false
5353
# [true | false]
5454
runStatsEnabled=true
5555

56+
# [true | false]
57+
userAndCommonLogicEnabled=false
58+
5659
#############################################
5760
# links
5861
#############################################

include/ReadoutCard/Parameters.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class Parameters
122122
/// Type for the Run Statistics enabled parameter
123123
using RunStatsEnabledType = bool;
124124

125+
/// Type for the User and Common Logic enabled parameter
126+
using UserAndCommonLogicEnabledType = bool;
127+
125128
/// Type for the GBT enabled parameter
126129
using GbtEnabledType = bool;
127130

@@ -239,6 +242,14 @@ class Parameters
239242
/// \return Reference to this object for chaining calls
240243
auto setRunStatsEnabled(RunStatsEnabledType value) -> Parameters&;
241244

245+
/// Sets the UserAndCommonLogicEnabled parameter
246+
///
247+
/// If enabled both User and Common Logic is enabled
248+
///
249+
/// \param value The value to set
250+
/// \return Reference to this object for chaining calls
251+
auto setUserAndCommonLogicEnabled(UserAndCommonLogicEnabledType value) -> Parameters&;
252+
242253
/// Sets the OnuAddress parameter
243254
///
244255
/// \param value The value to set
@@ -447,6 +458,10 @@ class Parameters
447458
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
448459
auto getRunStatsEnabled() const -> boost::optional<RunStatsEnabledType>;
449460

461+
/// Gets the UserAndCommonLogicEnabled parameter
462+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
463+
auto getUserAndCommonLogicEnabled() const -> boost::optional<UserAndCommonLogicEnabledType>;
464+
450465
/// Gets the OnuAddress parameter
451466
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
452467
auto getOnuAddress() const -> boost::optional<OnuAddressType>;
@@ -559,6 +574,11 @@ class Parameters
559574
/// \return The value
560575
auto getRunStatsEnabledRequired() const -> RunStatsEnabledType;
561576

577+
/// Gets the UserAndCommonLogicEnabled parameter
578+
/// \exception ParameterException The parameter was not present
579+
/// \return The value
580+
auto getUserAndCommonLogicEnabledRequired() const -> UserAndCommonLogicEnabledType;
581+
562582
/// Gets the OnuAddress parameter
563583
/// \exception ParameterException The parameter was not present
564584
/// \return The value

src/CardConfigurator.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
9393
bool gbtEnabled = false;
9494
bool userLogicEnabled = false;
9595
bool runStatsEnabled = false;
96+
bool userAndCommonLogicEnabled = false;
9697

9798
bool enabled = false;
9899
std::string gbtMux = "ttc";
@@ -145,6 +146,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
145146
gbtEnabled = subtree.get<bool>("gbtEnabled");
146147
userLogicEnabled = subtree.get<bool>("userLogicEnabled");
147148
runStatsEnabled = subtree.get<bool>("runStatsEnabled");
149+
userAndCommonLogicEnabled = subtree.get<bool>("userAndCommonLogicEnabled");
148150

149151
parameters.setClock(clock);
150152
parameters.setDatapathMode(datapathMode);
@@ -160,6 +162,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
160162
parameters.setGbtEnabled(gbtEnabled);
161163
parameters.setUserLogicEnabled(userLogicEnabled);
162164
parameters.setRunStatsEnabled(runStatsEnabled);
165+
parameters.setUserAndCommonLogicEnabled(userAndCommonLogicEnabled);
163166
} else if (group == "links") { // Configure all links with default values
164167

165168
enabled = subtree.get<bool>("enabled");

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class ProgramConfig : public Program
114114
options.add_options()("run-stats",
115115
po::bool_switch(&mOptions.runStatsEnabled),
116116
"Flag to enable the Run Statistics link");
117+
options.add_options()("user-and-common-logic",
118+
po::bool_switch(&mOptions.userAndCommonLogicEnabled),
119+
"Flag to enable the User and Common Logic");
117120
Options::addOptionCardId(options);
118121
}
119122

@@ -175,6 +178,7 @@ class ProgramConfig : public Program
175178
params.setGbtEnabled(!mOptions.noGbt);
176179
params.setUserLogicEnabled(mOptions.userLogicEnabled);
177180
params.setRunStatsEnabled(mOptions.runStatsEnabled);
181+
params.setUserAndCommonLogicEnabled(mOptions.userAndCommonLogicEnabled);
178182
params.setTimeFrameLength(mOptions.timeFrameLength);
179183
params.setTimeFrameDetectionEnabled(!mOptions.timeFrameDetectionDisabled);
180184

@@ -196,6 +200,10 @@ class ProgramConfig : public Program
196200
cfgFile << "onuAddress=" << mOptions.onuAddress << "\n";
197201
cfgFile << "dynamicOffset=" << std::boolalpha << mOptions.dynamicOffsetEnabled << "\n";
198202
cfgFile << "triggerWindowSize=" << mOptions.triggerWindowSize << "\n";
203+
cfgFile << "gbtEnabled=" << std::boolalpha << !mOptions.noGbt << "\n";
204+
cfgFile << "userLogicEnabled=" << std::boolalpha << mOptions.userLogicEnabled << "\n";
205+
cfgFile << "runStatsEnabled=" << std::boolalpha << mOptions.runStatsEnabled << "\n";
206+
cfgFile << "userAndCommonLogicEnabled=" << std::boolalpha << mOptions.userAndCommonLogicEnabled << "\n";
199207

200208
cfgFile << "[links]\n";
201209
cfgFile << "enabled=false\n";
@@ -252,6 +260,7 @@ class ProgramConfig : public Program
252260
bool timeFrameDetectionDisabled = false;
253261
bool userLogicEnabled = false;
254262
bool runStatsEnabled = false;
263+
bool userAndCommonLogicEnabled = false;
255264
bool noGbt = false;
256265
} mOptions;
257266

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class ProgramStatus : public Program
193193
std::string offset = (reportInfo.dynamicOffset ? "Dynamic" : "Fixed");
194194
std::string userLogic = (reportInfo.userLogicEnabled ? "Enabled" : "Disabled");
195195
std::string runStats = (reportInfo.runStatsEnabled ? "Enabled" : "Disabled");
196+
std::string userAndCommonLogic = (reportInfo.userAndCommonLogicEnabled ? "Enabled" : "Disabled");
196197

197198
/* GENERAL PARAMETERS */
198199
if (mOptions.monitoring) {
@@ -202,13 +203,15 @@ class ProgramStatus : public Program
202203
.addValue(reportInfo.dynamicOffset, "dynamicOffset")
203204
.addValue(reportInfo.userLogicEnabled, "userLogic")
204205
.addValue(reportInfo.runStatsEnabled, "runStats")
206+
.addValue(reportInfo.userAndCommonLogicEnabled, "userAndCommonLogic")
205207
.addTag(tags::Key::ID, card.sequenceId)
206208
.addTag(tags::Key::Type, tags::Value::CRU));
207209
} else if (mOptions.jsonOut) {
208210
root.put("clock", clock);
209211
root.put("offset", offset);
210212
root.put("userLogic", userLogic);
211213
root.put("runStats", runStats);
214+
root.put("userAndCommonLogic", userAndCommonLogic);
212215
} else if (mOptions.csvOut) {
213216
auto csvLine = ",,,,,,,,,," + clock + "," + offset + "," + userLogic + "," + runStats + "\n";
214217
std::cout << csvLine;
@@ -218,6 +221,7 @@ class ProgramStatus : public Program
218221
std::cout << offset << " offset" << std::endl;
219222
std::cout << "User Logic " << userLogic << std::endl;
220223
std::cout << "Run statistics " << runStats << std::endl;
224+
std::cout << "User and Common logic " << runStats << std::endl;
221225
std::cout << "----------------------------" << std::endl;
222226
}
223227

src/Cru/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct ReportInfo {
9292
bool gbtEnabled;
9393
bool userLogicEnabled;
9494
bool runStatsEnabled;
95+
bool userAndCommonLogicEnabled;
9596
};
9697

9798
struct OnuStatus {

src/Cru/CruBar.cxx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ CruBar::CruBar(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPc
5555
mTriggerWindowSize(parameters.getTriggerWindowSize().get_value_or(1000)),
5656
mGbtEnabled(parameters.getGbtEnabled().get_value_or(true)),
5757
mUserLogicEnabled(parameters.getUserLogicEnabled().get_value_or(false)),
58-
mRunStatsEnabled(parameters.getRunStatsEnabled().get_value_or(false))
58+
mRunStatsEnabled(parameters.getRunStatsEnabled().get_value_or(false)),
59+
mUserAndCommonLogicEnabled(parameters.getUserAndCommonLogicEnabled().get_value_or(false))
5960
{
6061
if (getIndex() == 0) {
6162
mFeatures = parseFirmwareFeatures();
@@ -502,6 +503,8 @@ Cru::ReportInfo CruBar::report()
502503
runStatsLink.dwrapperId = (mEndpoint == 0) ? 13 : 14;
503504
bool runStatsEnabled = datapathWrapper.getLinkEnabled(runStatsLink);
504505

506+
bool userAndCommonLogicEnabled = datapathWrapper.getUserAndCommonLogicEnabled(mEndpoint);
507+
505508
Cru::ReportInfo reportInfo = {
506509
linkMap,
507510
clock,
@@ -513,7 +516,8 @@ Cru::ReportInfo CruBar::report()
513516
triggerWindowSize,
514517
gbtEnabled,
515518
userLogicEnabled,
516-
runStatsEnabled
519+
runStatsEnabled,
520+
userAndCommonLogicEnabled
517521
};
518522

519523
return reportInfo;
@@ -670,6 +674,12 @@ void CruBar::configure(bool force)
670674
toggleRunStatsLink(mRunStatsEnabled);
671675
}
672676

677+
/* UL + CL */
678+
if (mUserAndCommonLogicEnabled != reportInfo.userAndCommonLogicEnabled || force) {
679+
log("Enabling User and Common Logic");
680+
datapathWrapper.enableUserAndCommonLogic(mUserAndCommonLogicEnabled, mEndpoint);
681+
}
682+
673683
/* BSP */
674684
if (mCruId != reportInfo.cruId || force) {
675685
log("Setting the CRU ID");

src/Cru/CruBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class CruBar final : public BarInterfaceBase
150150
bool mGbtEnabled;
151151
bool mUserLogicEnabled;
152152
bool mRunStatsEnabled;
153+
bool mUserAndCommonLogicEnabled;
153154

154155
int mEndpoint;
155156

src/Cru/DatapathWrapper.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,19 @@ uint32_t DatapathWrapper::getTriggerWindowSize(int wrapper)
284284
return mPdaBar->readRegister(address / 4);
285285
}
286286

287+
void DatapathWrapper::enableUserAndCommonLogic(bool enable, int wrapper)
288+
{
289+
uint32_t value = enable ? 0x1 : 0x0;
290+
uint32_t address = (wrapper == 0) ? Cru::Registers::DWRAPPER_BASE0.index : Cru::Registers::DWRAPPER_BASE1.index;
291+
292+
mPdaBar->modifyRegister(address, 30, 1, value);
293+
}
294+
295+
bool DatapathWrapper::getUserAndCommonLogicEnabled(int wrapper)
296+
{
297+
uint32_t address = (wrapper == 0) ? Cru::Registers::DWRAPPER_BASE0.index : Cru::Registers::DWRAPPER_BASE1.index;
298+
return (Utilities::getBit(mPdaBar->readRegister(address), 30) == 0x1);
299+
}
300+
287301
} // namespace roc
288302
} // namespace AliceO2

0 commit comments

Comments
 (0)