Skip to content

Commit 320abc9

Browse files
committed
[crorc] Add options for Time Frame Length & Detection
1 parent 7011fd4 commit 320abc9

File tree

7 files changed

+117
-8
lines changed

7 files changed

+117
-8
lines changed

include/ReadoutCard/Parameters.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ class Parameters
134134
// Type for the Trigger Window Size parameter
135135
using TriggerWindowSizeType = uint32_t;
136136

137+
// Type for the Time Frame Length parameter
138+
using TimeFrameLengthType = uint32_t;
139+
140+
/// Type for the Time Frame Detection enabled parameter
141+
using TimeFrameDetectionEnabledType = bool;
142+
137143
// Setters
138144

139145
/// Sets the CardId parameter
@@ -364,6 +370,18 @@ class Parameters
364370
/// \return Reference to this object for chaining calls
365371
auto setTriggerWindowSize(TriggerWindowSizeType value) -> Parameters&;
366372

373+
/// Sets the TimeFrameLength parameter
374+
///
375+
/// \param value The value to set
376+
/// \return Reference to this object for chaining calls
377+
auto setTimeFrameLength(TimeFrameLengthType value) -> Parameters&;
378+
379+
/// Sets the TimeFrameDetectionEnabled parameter
380+
///
381+
/// \param value The value to set
382+
/// \return Reference to this object for chaining calls
383+
auto setTimeFrameDetectionEnabled(TimeFrameDetectionEnabledType value) -> Parameters&;
384+
367385
// on-throwing getters
368386

369387
/// Gets the AllowRejection parameter
@@ -461,6 +479,14 @@ class Parameters
461479
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
462480
auto getTriggerWindowSize() const -> boost::optional<TriggerWindowSizeType>;
463481

482+
/// Gets the TimeFrameLength parameter
483+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
484+
auto getTimeFrameLength() const -> boost::optional<TimeFrameLengthType>;
485+
486+
/// Gets the TimeFrameDetectionEnabled parameter
487+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
488+
auto getTimeFrameDetectionEnabled() const -> boost::optional<TimeFrameDetectionEnabledType>;
489+
464490
// Throwing getters
465491

466492
/// Gets the AllowRejection parameter
@@ -583,6 +609,16 @@ class Parameters
583609
/// \return The value
584610
auto getTriggerWindowSizeRequired() const -> TriggerWindowSizeType;
585611

612+
/// Gets the TimeFrameLength parameter
613+
/// \exception ParameterException The parameter was not present
614+
/// \return The value
615+
auto getTimeFrameLengthRequired() const -> TimeFrameLengthType;
616+
617+
/// Gets the TimeFrameDetectionEnabled parameter
618+
/// \exception ParameterException The parameter was not present
619+
/// \return The value
620+
auto getTimeFrameDetectionEnabledRequired() const -> TimeFrameDetectionEnabledType;
621+
586622
// Helper functions
587623

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

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ProgramConfig : public Program
3737
return { "Config", "Configure the ReadoutCard(s)",
3838
"roc-config --config-uri ini:///home/flp/roc.cfg\n"
3939
"roc-config --id 42:00.0 --links 0-23 --clock local --datapathmode packet --loopback --gbtmux ttc #CRU\n"
40-
"roc-config --id #0 --crorc-id 0x42 --dyn-offset #CRORC\n" };
40+
"roc-config --id #0 --crorc-id 0x42 --dyn-offset --tf-length 255 #CRORC\n" };
4141
}
4242

4343
virtual void addOptions(boost::program_options::options_description& options)
@@ -96,6 +96,12 @@ class ProgramConfig : public Program
9696
options.add_options()("trigger-window-size",
9797
po::value<uint32_t>(&mOptions.triggerWindowSize),
9898
"The size of the trigger window in GBT words");
99+
options.add_options()("tf-length",
100+
po::value<uint32_t>(&mOptions.timeFrameLength),
101+
"Sets the length of the Time Frame");
102+
options.add_options()("no-tf-detection",
103+
po::bool_switch(&mOptions.timeFrameDetectionDisabled),
104+
"Flag to enable the Time Frame Detection");
99105
options.add_options()("gen-cfg-file",
100106
po::value<std::string>(&mOptions.genConfigFile),
101107
"If set generates a configuration file from the command line options. [DOES NOT CONFIGURE]");
@@ -165,6 +171,8 @@ class ProgramConfig : public Program
165171
params.setTriggerWindowSize(mOptions.triggerWindowSize);
166172
params.setGbtEnabled(!mOptions.noGbt);
167173
params.setUserLogicEnabled(mOptions.userLogicEnabled);
174+
params.setTimeFrameLength(mOptions.timeFrameLength);
175+
params.setTimeFrameDetectionEnabled(!mOptions.timeFrameDetectionDisabled);
168176

169177
// Generate a configuration file base on the parameters provided
170178
if (mOptions.genConfigFile != "") { //TODO: To be updated for the CRORC
@@ -236,6 +244,8 @@ class ProgramConfig : public Program
236244
std::string cruId = "0x0";
237245
std::string crorcId = "0x0";
238246
uint32_t triggerWindowSize = 1000;
247+
uint32_t timeFrameLength = 0x100;
248+
bool timeFrameDetectionDisabled = false;
239249
bool userLogicEnabled = false;
240250
bool noGbt = false;
241251
} mOptions;

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ProgramStatus : public Program
7777
lineThin = std::string(header.length(), '-') + '\n';
7878

7979
if (mOptions.csvOut) {
80-
auto csvHeader = "Link ID,Status,Optical Power(uW),QSFP Enabled,Offset\n";
80+
auto csvHeader = "Link ID,Status,Optical Power(uW),QSFP Enabled,Offset,Time Frame Detection, Time Frame Length\n";
8181
std::cout << csvHeader;
8282
} else if (!mOptions.jsonOut) {
8383
table << lineFat << header << lineThin;
@@ -102,11 +102,19 @@ class ProgramStatus : public Program
102102
} else {
103103
root.put("offset", "Fixed");
104104
}
105+
106+
if (reportInfo.timeFrameDetectionEnabled) {
107+
root.put("timeFrameDetection", "Enabled");
108+
} else {
109+
root.put("timeFrameDetection", "Disabled");
110+
}
111+
112+
root.put("timeFrameLength", reportInfo.timeFrameLength);
105113
} else if (mOptions.csvOut) {
106-
auto csvLine = std::string(",,,") + (reportInfo.qsfpEnabled ? "Enabled" : "Disabled") + "," + (reportInfo.dynamicOffset ? "Dynamic" : "Fixed") + "\n";
114+
auto csvLine = std::string(",,,") + (reportInfo.qsfpEnabled ? "Enabled" : "Disabled") + "," + (reportInfo.dynamicOffset ? "Dynamic" : "Fixed") + "," + (reportInfo.timeFrameDetectionEnabled ? "Enabled" : "Disabled") + "," + std::to_string(reportInfo.timeFrameLength) + "\n";
107115
std::cout << csvLine;
108116
} else {
109-
std::cout << "----------------------------" << std::endl;
117+
std::cout << "-----------------------------" << std::endl;
110118
if (reportInfo.qsfpEnabled) {
111119
std::cout << "QSFP enabled | ";
112120
} else {
@@ -118,7 +126,18 @@ class ProgramStatus : public Program
118126
} else {
119127
std::cout << "Fixed offset" << std::endl;
120128
}
121-
std::cout << "----------------------------" << std::endl;
129+
130+
std::cout << "-----------------------------" << std::endl;
131+
132+
if (reportInfo.timeFrameDetectionEnabled) {
133+
std::cout << "Time Frame Detection enabled" << std::endl;
134+
} else {
135+
std::cout << "Time Frame Detection disabled" << std::endl;
136+
}
137+
138+
std::cout << "Time Frame Length: " << reportInfo.timeFrameLength << std::endl;
139+
140+
std::cout << "-----------------------------" << std::endl;
122141
}
123142

124143
/* PARAMETERS PER LINK */

src/Crorc/Common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct Link {
3636
struct ReportInfo {
3737
std::map<int, Link> linkMap;
3838
uint16_t crorcId;
39+
uint16_t timeFrameLength;
40+
bool timeFrameDetectionEnabled;
3941
bool qsfpEnabled;
4042
bool dynamicOffset;
4143
};

src/Crorc/CrorcBar.cxx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ namespace roc
3131
CrorcBar::CrorcBar(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPciDevice)
3232
: BarInterfaceBase(parameters, std::move(rocPciDevice)),
3333
mCrorcId(parameters.getCrorcId().get_value_or(0x0)),
34-
mDynamicOffset(parameters.getDynamicOffsetEnabled().get_value_or(false))
34+
mDynamicOffset(parameters.getDynamicOffsetEnabled().get_value_or(false)),
35+
mTimeFrameLength(parameters.getTimeFrameLength().get_value_or(0x100)),
36+
mTimeFrameDetectionEnabled(parameters.getTimeFrameDetectionEnabled().get_value_or(true))
3537
{
3638
}
3739

@@ -73,6 +75,13 @@ void CrorcBar::configure(bool /*force*/)
7375
// set crorc id
7476
log("Setting the CRORC ID");
7577
setCrorcId(mCrorcId);
78+
79+
// set timeframe length
80+
log("Setting the Time Frame length");
81+
setTimeFrameLength(mTimeFrameLength);
82+
83+
log("Configuring Time Frame detection");
84+
setTimeFrameDetectionEnabled(mTimeFrameDetectionEnabled);
7685
}
7786

7887
Crorc::ReportInfo CrorcBar::report()
@@ -82,8 +91,10 @@ Crorc::ReportInfo CrorcBar::report()
8291
Crorc::ReportInfo reportInfo = {
8392
linkMap,
8493
getCrorcId(),
94+
getTimeFrameLength(),
95+
getTimeFrameDetectionEnabled(),
8596
getQsfpEnabled(),
86-
getDynamicOffsetEnabled()
97+
getDynamicOffsetEnabled(),
8798
};
8899
return reportInfo;
89100
}
@@ -138,6 +149,29 @@ bool CrorcBar::getDynamicOffsetEnabled()
138149
return (readRegister(Crorc::Registers::CFG_CONTROL.index) & 0x1);
139150
}
140151

152+
void CrorcBar::setTimeFrameLength(uint16_t timeFrameLength)
153+
{
154+
if (timeFrameLength > 256) {
155+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("BAD TF LENGTH, should be less or equal to 256") << ErrorInfo::ConfigValue(timeFrameLength));
156+
}
157+
modifyRegister(Crorc::Registers::CFG_CONTROL.index, 16, 12, timeFrameLength);
158+
}
159+
160+
uint16_t CrorcBar::getTimeFrameLength()
161+
{
162+
return (readRegister(Crorc::Registers::CFG_CONTROL.index) >> 16) & 0x0fff;
163+
}
164+
165+
void CrorcBar::setTimeFrameDetectionEnabled(bool enabled)
166+
{
167+
modifyRegister(Crorc::Registers::CFG_CONTROL.index, 28, 1, enabled ? 0x1 : 0x0);
168+
}
169+
170+
bool CrorcBar::getTimeFrameDetectionEnabled()
171+
{
172+
return (readRegister(Crorc::Registers::CFG_CONTROL.index) >> 28) & 0x1;
173+
}
174+
141175
void CrorcBar::getOpticalPowers(std::map<int, Crorc::Link>& linkMap)
142176
{
143177
for (auto& el : linkMap) {

src/Crorc/CrorcBar.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ class CrorcBar final : public BarInterfaceBase
5858
bool getQsfpEnabled();
5959
void setDynamicOffsetEnabled(bool enabled);
6060
bool getDynamicOffsetEnabled();
61-
void setCrorcId(uint16_t cruId);
61+
void setCrorcId(uint16_t crorcId);
6262
uint16_t getCrorcId();
63+
void setTimeFrameLength(uint16_t timeFrameLength);
64+
uint16_t getTimeFrameLength();
65+
void setTimeFrameDetectionEnabled(bool enabled);
66+
bool getTimeFrameDetectionEnabled();
6367
void getOpticalPowers(std::map<int, Crorc::Link>& linkMap);
6468

6569
uint16_t mCrorcId;
6670
bool mDynamicOffset;
71+
uint16_t mTimeFrameLength;
72+
bool mTimeFrameDetectionEnabled;
6773
};
6874

6975
} // namespace roc

src/Parameters.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ _PARAMETER_FUNCTIONS(UserLogicEnabled, "user_logic_enabled")
138138
_PARAMETER_FUNCTIONS(OnuAddress, "onu_address")
139139
_PARAMETER_FUNCTIONS(StbrdEnabled, "stbrd_enabled")
140140
_PARAMETER_FUNCTIONS(TriggerWindowSize, "trigger_window_size")
141+
_PARAMETER_FUNCTIONS(TimeFrameLength, "timeframe_length")
142+
_PARAMETER_FUNCTIONS(TimeFrameDetectionEnabled, "timeframe_detection_enabled")
141143
#undef _PARAMETER_FUNCTIONS
142144

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

0 commit comments

Comments
 (0)