Skip to content

Commit 49b9e2e

Browse files
committed
[config] Add discrete options to enable UL link 15 & disable GBT
1 parent 0553557 commit 49b9e2e

File tree

11 files changed

+143
-20
lines changed

11 files changed

+143
-20
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ The Parameters that affect the configuration of the CRU, their possible values (
163163

164164
`TriggerWindowSize (0 - 4095) [1000]`
165165

166+
`GbtEnabled (true | false) [true]`
167+
168+
`UserLogicEnabled (true | false) [false]`
169+
166170
To set any of the above parameters the usual template can be followed.
167171

168172
```
@@ -180,13 +184,14 @@ params.setClock(Parameters::Clock::type::Local);
180184
The above parameters will be set for the enabled links, as specified by the `LinkMask` parameter. See the [LinkMask](#linkmask) section
181185
for more info.
182186

183-
Note that for `AllowRejection`, `LinkLoopbackEnabled`, `PonUpstreamEnabled` and `DynamicOffsetEnabled` it is sufficient to do the following, as they are simply booleans.
187+
Note that for `AllowRejection`, `LinkLoopbackEnabled`, `PonUpstreamEnabled`, `DynamicOffsetEnabled`, `GbtEnabled` and `UserLogicEnabled` it is sufficient to do the following, as they are simply booleans.
184188

185189
```
186190
params.setAllowRejection(true);
187191
params.setLinkLoopbackEnabled(true);
188192
params.setPonUpstreamEnabled(true);
189193
params.setDynamicOffsetEnabled(true);
194+
...
190195
```
191196

192197
Likewise for `OnuAddress`, passing the hex is enough.
@@ -213,6 +218,8 @@ ponUpstream
213218
onuAddress
214219
dynamicOffsetEnabled
215220
triggerWindowSize
221+
gbtEnabled
222+
UserLogicEnabled
216223
```
217224

218225
The "per link" parameters are

cru_template.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ dynamicOffset=false
4444
# [<4096]
4545
triggerWindowSize=1000
4646

47+
# [true | false]
48+
gbtEnabled=true
49+
50+
# [true | false]
51+
userLogicEnabled=false
52+
4753
#############################################
4854
# links
4955
#############################################

include/ReadoutCard/Parameters.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ class Parameters
116116
/// Type for the Dynamic Offset enabled parameter
117117
using DynamicOffsetEnabledType = bool;
118118

119+
/// Type for the User Logic enabled parameter
120+
using UserLogicEnabledType = bool;
121+
122+
/// Type for the GBT enabled parameter
123+
using GbtEnabledType = bool;
124+
119125
/// Type for the ONU address parameter
120126
using OnuAddressType = Hex::type;
121127

@@ -183,12 +189,28 @@ class Parameters
183189

184190
/// Sets the DynamicOffsetEnabled parameter
185191
///
186-
/// If enabled the PON upstream is used.
192+
/// If enabled the Dynamic Offset is used.
187193
///
188194
/// \param value The value to set
189195
/// \return Reference to this object for chaining calls
190196
auto setDynamicOffsetEnabled(DynamicOffsetEnabledType value) -> Parameters&;
191197

198+
/// Sets the GbtEnabled parameter
199+
///
200+
/// If enabled the GBT is used.
201+
///
202+
/// \param value The value to set
203+
/// \return Reference to this object for chaining calls
204+
auto setGbtEnabled(GbtEnabledType value) -> Parameters&;
205+
206+
/// Sets the UserLogicEnabled parameter
207+
///
208+
/// If enabled the User Logic is used.
209+
///
210+
/// \param value The value to set
211+
/// \return Reference to this object for chaining calls
212+
auto setUserLogicEnabled(UserLogicEnabledType value) -> Parameters&;
213+
192214
/// Sets the OnuAddress parameter
193215
///
194216
/// \param value The value to set
@@ -369,6 +391,14 @@ class Parameters
369391
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
370392
auto getDynamicOffsetEnabled() const -> boost::optional<DynamicOffsetEnabledType>;
371393

394+
/// Gets the GbtEnabled parameter
395+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
396+
auto getGbtEnabled() const -> boost::optional<GbtEnabledType>;
397+
398+
/// Gets the UserLogicEnabled parameter
399+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
400+
auto getUserLogicEnabled() const -> boost::optional<UserLogicEnabledType>;
401+
372402
/// Gets the OnuAddress parameter
373403
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
374404
auto getOnuAddress() const -> boost::optional<OnuAddressType>;
@@ -453,6 +483,16 @@ class Parameters
453483
/// \return The value
454484
auto getDynamicOffsetEnabledRequired() const -> DynamicOffsetEnabledType;
455485

486+
/// Gets the GbtEnabled parameter
487+
/// \exception ParameterException The parameter was not present
488+
/// \return The value
489+
auto getGbtEnabledRequired() const -> GbtEnabledType;
490+
491+
/// Gets the UserLogicEnabled parameter
492+
/// \exception ParameterException The parameter was not present
493+
/// \return The value
494+
auto getUserLogicEnabledRequired() const -> UserLogicEnabledType;
495+
456496
/// Gets the OnuAddress parameter
457497
/// \exception ParameterException The parameter was not present
458498
/// \return The value

src/CardConfigurator.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
9090
GbtMode::type gbtMode = GbtMode::type::Gbt;
9191
DownstreamData::type downstreamData = DownstreamData::type::Ctp;
9292
uint32_t triggerWindowSize = 1000;
93+
bool gbtEnabled = false;
94+
bool userLogicEnabled = false;
9395

9496
bool enabled = false;
9597
std::string gbtMux = "ttc";
@@ -139,6 +141,9 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
139141

140142
triggerWindowSize = conf->get<int>("triggerWindowSize");
141143

144+
gbtEnabled = conf->get<bool>("gbtEnabled");
145+
userLogicEnabled = conf->get<bool>("userLogicEnabled");
146+
142147
conf->setPrefix("");
143148

144149
parameters.setClock(clock);
@@ -152,6 +157,8 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
152157
parameters.setCruId(cruId);
153158
parameters.setAllowRejection(allowRejection);
154159
parameters.setTriggerWindowSize(triggerWindowSize);
160+
parameters.setGbtEnabled(gbtEnabled);
161+
parameters.setUserLogicEnabled(userLogicEnabled);
155162

156163
} else if (group == "links") { // Configure all links with default values
157164

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ class ProgramConfig : public Program
9999
options.add_options()("gen-cfg-file",
100100
po::value<std::string>(&mOptions.genConfigFile),
101101
"If set generates a configuration file from the command line options. [DOES NOT CONFIGURE]");
102+
options.add_options()("no-gbt",
103+
po::bool_switch(&mOptions.noGbt),
104+
"Flag to switch off GBT");
105+
options.add_options()("user-logic",
106+
po::bool_switch(&mOptions.userLogicEnabled),
107+
"Flag to enable the User Logic link");
102108
Options::addOptionCardId(options);
103109
}
104110

@@ -157,6 +163,8 @@ class ProgramConfig : public Program
157163
params.setDynamicOffsetEnabled(mOptions.dynamicOffsetEnabled);
158164
params.setOnuAddress(mOptions.onuAddress);
159165
params.setTriggerWindowSize(mOptions.triggerWindowSize);
166+
params.setGbtEnabled(!mOptions.noGbt);
167+
params.setUserLogicEnabled(mOptions.userLogicEnabled);
160168

161169
// Generate a configuration file base on the parameters provided
162170
if (mOptions.genConfigFile != "") { //TODO: To be updated for the CRORC
@@ -228,6 +236,8 @@ class ProgramConfig : public Program
228236
std::string cruId = "0x0";
229237
std::string crorcId = "0x0";
230238
uint32_t triggerWindowSize = 1000;
239+
bool userLogicEnabled = false;
240+
bool noGbt = false;
231241
} mOptions;
232242

233243
private:

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ class ProgramStatus : public Program
187187
} else {
188188
std::cout << "Fixed offset" << std::endl;
189189
}
190+
if (reportInfo.userLogicEnabled) {
191+
std::cout << "User Logic Enabled" << std::endl;
192+
} else {
193+
std::cout << "User Logic Disabled" << std::endl;
194+
}
190195
std::cout << "----------------------------" << std::endl;
191196
}
192197

src/Cru/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ struct ReportInfo {
9292
uint16_t cruId;
9393
bool dynamicOffset;
9494
uint32_t triggerWindowSize;
95+
bool gbtEnabled;
96+
bool userLogicEnabled;
9597
};
9698

9799
struct OnuStatus {

src/Cru/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Cru
2727
{
2828

2929
/// Maximum amount of available links
30-
static constexpr int MAX_LINKS = 12;
30+
static constexpr int MAX_LINKS = 16;
3131

3232
/// Amount of available superpage descriptors per link
3333
static constexpr int MAX_SUPERPAGE_DESCRIPTORS = 128;

src/Cru/CruBar.cxx

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ CruBar::CruBar(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPc
5050
mPonUpstream(parameters.getPonUpstreamEnabled().get_value_or(false)),
5151
mOnuAddress(parameters.getOnuAddress().get_value_or(0x0)),
5252
mDynamicOffset(parameters.getDynamicOffsetEnabled().get_value_or(false)),
53-
mTriggerWindowSize(parameters.getTriggerWindowSize().get_value_or(1000))
53+
mTriggerWindowSize(parameters.getTriggerWindowSize().get_value_or(1000)),
54+
mGbtEnabled(parameters.getGbtEnabled().get_value_or(true)),
55+
mUserLogicEnabled(parameters.getUserLogicEnabled().get_value_or(false))
5456
{
5557
if (getIndex() == 0) {
5658
mFeatures = parseFirmwareFeatures();
@@ -406,6 +408,7 @@ Cru::ReportInfo CruBar::report()
406408
{
407409
std::map<int, Link> linkMap = initializeLinkMap();
408410

411+
bool gbtEnabled = false;
409412
// Update linkMap
410413
Gbt gbt = Gbt(mPdaBar, linkMap, mWrapperCount);
411414
gbt.getGbtModes();
@@ -422,6 +425,10 @@ Cru::ReportInfo CruBar::report()
422425
link.stickyBit = gbt.getStickyBit(link);
423426
link.rxFreq = gbt.getRxClockFrequency(link) / 1e6; // Hz -> Mhz
424427
link.txFreq = gbt.getTxClockFrequency(link) / 1e6; // Hz -> Mhz
428+
429+
if (link.enabled) {
430+
gbtEnabled = true;
431+
}
425432
}
426433

427434
// Update the link map with optical power information through I2C
@@ -440,6 +447,12 @@ Cru::ReportInfo CruBar::report()
440447
bool dynamicOffset = datapathWrapper.getDynamicOffsetEnabled(mEndpoint);
441448
uint32_t triggerWindowSize = datapathWrapper.getTriggerWindowSize(mEndpoint);
442449

450+
Link userLogicLink;
451+
userLogicLink.dwrapper = mEndpoint;
452+
userLogicLink.dwrapperId = 15;
453+
454+
bool userLogicEnabled = datapathWrapper.getLinkEnabled(userLogicLink);
455+
443456
Cru::ReportInfo reportInfo = {
444457
linkMap,
445458
clock,
@@ -448,7 +461,9 @@ Cru::ReportInfo CruBar::report()
448461
onuAddress,
449462
cruId,
450463
dynamicOffset,
451-
triggerWindowSize
464+
triggerWindowSize,
465+
gbtEnabled,
466+
userLogicEnabled
452467
};
453468

454469
return reportInfo;
@@ -500,6 +515,8 @@ void CruBar::configure(bool force)
500515
mCruId == reportInfo.cruId &&
501516
mDynamicOffset == reportInfo.dynamicOffset &&
502517
mTriggerWindowSize == reportInfo.triggerWindowSize &&
518+
mUserLogicEnabled == reportInfo.userLogicEnabled &&
519+
mGbtEnabled == reportInfo.gbtEnabled &&
503520
!force) {
504521
log("No need to reconfigure further");
505522
return;
@@ -527,11 +544,13 @@ void CruBar::configure(bool force)
527544
}
528545
}
529546

530-
log("Calibrating the fPLLs");
531-
Gbt gbt = Gbt(mPdaBar, mLinkMap, mWrapperCount);
532-
gbt.calibrateGbt(mLinkMap);
533-
Cru::fpllref(mLinkMap, mPdaBar, 2);
534-
Cru::fpllcal(mLinkMap, mPdaBar);
547+
if (mGbtEnabled) {
548+
log("Calibrating the fPLLs");
549+
Gbt gbt = Gbt(mPdaBar, mLinkMap, mWrapperCount);
550+
gbt.calibrateGbt(mLinkMap);
551+
Cru::fpllref(mLinkMap, mPdaBar, 2);
552+
Cru::fpllcal(mLinkMap, mPdaBar);
553+
}
535554
}
536555

537556
if (static_cast<uint32_t>(mDownstreamData) != reportInfo.downstreamData || force) {
@@ -540,11 +559,11 @@ void CruBar::configure(bool force)
540559
}
541560

542561
/* GBT */
543-
if (!std::equal(mLinkMap.begin(), mLinkMap.end(), reportInfo.linkMap.begin()) || force) {
544-
//log("Calibrating GBT");
545-
//Gbt gbt = Gbt(mPdaBar, mLinkMap, mWrapperCount);
546-
//gbt.calibrateGbt({ std::pair<int, Link>(el.first, el.second) });
547-
562+
if (!mGbtEnabled && ((mGbtEnabled != reportInfo.gbtEnabled) || force)) {
563+
// Disable all links
564+
datapathWrapper.setLinksEnabled(mEndpoint, 0x0);
565+
toggleUserLogicLink(reportInfo.userLogicEnabled); // Make sure the user logic link retains its state
566+
} else if (mGbtEnabled && (!std::equal(mLinkMap.begin(), mLinkMap.end(), reportInfo.linkMap.begin()) || force)) {
548567
/* BSP */
549568
disableDataTaking();
550569

@@ -577,8 +596,15 @@ void CruBar::configure(bool force)
577596
}
578597
}
579598

599+
/* USER LOGIC */
600+
if (mUserLogicEnabled != reportInfo.userLogicEnabled || force) {
601+
log("Toggling the User Logic link");
602+
toggleUserLogicLink(mUserLogicEnabled);
603+
}
604+
580605
/* BSP */
581606
if (mCruId != reportInfo.cruId || force) {
607+
log("Setting the CRU ID");
582608
setCruId(mCruId);
583609
}
584610

@@ -625,7 +651,7 @@ std::map<int, Link> CruBar::initializeLinkMap()
625651
uint32_t address = Cru::getWrapperBaseAddress(wrapper) + Cru::Registers::GBT_WRAPPER_CONF0.address;
626652
uint32_t wrapperConfig = readRegister(address / 4);
627653

628-
for (int bank = mEndpoint * 2; bank < (mEndpoint * 2 + 2); bank++) {
654+
for (int bank = mEndpoint * 2; bank < (mEndpoint * 2 + 4); bank++) {
629655
//for (int bank = 0; bank < 4; bank++) { //for 0-23 range
630656
// endpoint 0 -> banks {0,1}
631657
// endpoint 1 -> banks {2,3}
@@ -860,5 +886,20 @@ Cru::OnuStatus CruBar::reportOnuStatus()
860886
return ttc.onuStatus();
861887
}
862888

889+
void CruBar::toggleUserLogicLink(bool userLogicEnabled)
890+
{
891+
Link userLogicLink;
892+
userLogicLink.dwrapper = mEndpoint;
893+
userLogicLink.dwrapperId = 15;
894+
895+
DatapathWrapper datapathWrapper = DatapathWrapper(mPdaBar);
896+
if (userLogicEnabled) {
897+
datapathWrapper.setLinkEnabled(userLogicLink);
898+
} else {
899+
datapathWrapper.setLinkDisabled(userLogicLink);
900+
}
901+
datapathWrapper.setDatapathMode(userLogicLink, mDatapathMode);
902+
}
903+
863904
} // namespace roc
864905
} // namespace AliceO2

src/Cru/CruBar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class CruBar final : public BarInterfaceBase
9090
void setDebugModeEnabled(bool enabled);
9191
bool getDebugModeEnabled();
9292

93+
void toggleUserLogicLink(bool mUserLogicEnabled);
94+
9395
Cru::OnuStatus reportOnuStatus();
9496
std::map<int, Link> initializeLinkMap();
9597

@@ -141,6 +143,8 @@ class CruBar final : public BarInterfaceBase
141143
uint32_t mOnuAddress;
142144
bool mDynamicOffset;
143145
uint32_t mTriggerWindowSize;
146+
bool mGbtEnabled;
147+
bool mUserLogicEnabled;
144148

145149
int mEndpoint;
146150

0 commit comments

Comments
 (0)