Skip to content

Commit 24bc708

Browse files
committed
[ul] Introduce tool to control the dummy UL
1 parent fadf191 commit 24bc708

File tree

7 files changed

+132
-1
lines changed

7 files changed

+132
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ list(APPEND EXE_SRCS
225225
ProgramSiuStatus.cxx
226226
ProgramStatus.cxx
227227
ProgramTriggerMonitor.cxx
228+
ProgramUserLogic.cxx
228229
)
229230

230231
list(APPEND EXE_NAMES
@@ -242,6 +243,7 @@ list(APPEND EXE_NAMES
242243
roc-siu-status
243244
roc-status
244245
roc-trig-monitor
246+
roc-ul
245247
)
246248

247249

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file ProgramUserLogic.cxx
12+
/// \brief Tool to control and report on the dummy(!) User Logic
13+
///
14+
/// \author Kostas Alexopoulos ([email protected])
15+
16+
#include <iostream>
17+
#include "Cru/CruBar.h"
18+
#include "ReadoutCard/ChannelFactory.h"
19+
#include "CommandLineUtilities/Options.h"
20+
#include "CommandLineUtilities/Program.h"
21+
22+
using namespace AliceO2::roc::CommandLineUtilities;
23+
using namespace AliceO2::roc;
24+
namespace po = boost::program_options;
25+
26+
class ProgramUserLogic : public Program
27+
{
28+
public:
29+
virtual Description getDescription()
30+
{
31+
return { "User Logic", "Control the dummy User Logic",
32+
"roc-ul --id 0042:0 --event-size=128 \n"
33+
"roc-ul --id 0042:0 --random-event-size \n"
34+
"roc-ul --id 0042:0 --status \n" };
35+
}
36+
37+
virtual void addOptions(boost::program_options::options_description& options)
38+
{
39+
Options::addOptionCardId(options);
40+
options.add_options()("random-event-size",
41+
po::bool_switch(&mOptions.randomEventSize),
42+
"Toggle random event size");
43+
options.add_options()("event-size",
44+
po::value<uint32_t>(&mOptions.eventSize)->default_value(100),
45+
"Set the event size (in GBT words = 128bits)");
46+
options.add_options()("status",
47+
po::bool_switch(&mOptions.status),
48+
"Print UL status only");
49+
}
50+
51+
virtual void run(const boost::program_options::variables_map& map)
52+
{
53+
54+
auto cardId = Options::getOptionCardId(map);
55+
auto card = RocPciDevice(cardId).getCardDescriptor();
56+
auto cardType = card.cardType;
57+
if (cardType != CardType::type::Cru) {
58+
std::cerr << "Unsupported card type, only CRU supported." << std::endl;
59+
return;
60+
}
61+
62+
Parameters params = Parameters::makeParameters(cardId, 2);
63+
auto bar = ChannelFactory().getBar(params);
64+
auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar);
65+
if (mOptions.status) {
66+
Cru::UserLogicInfo ulInfo = cruBar2->reportUserLogic();
67+
std::cout << "==========================" << std::endl;
68+
std::cout << "Event size: " << ulInfo.eventSize << " GBT words" << std::endl;
69+
std::cout << "Event size: " << (ulInfo.eventSize * 128) / 1024.0 << "Kb" << std::endl;
70+
std::cout << "Event size: " << (ulInfo.eventSize * 128) / (1024.0 * 8) << "KB" << std::endl;
71+
std::cout << "Randomized: " << std::boolalpha << ulInfo.random << std::endl;
72+
std::cout << "==========================" << std::endl;
73+
} else {
74+
cruBar2->controlUserLogic(mOptions.eventSize, mOptions.randomEventSize);
75+
}
76+
}
77+
78+
private:
79+
struct OptionsStruct {
80+
uint32_t eventSize;
81+
bool randomEventSize;
82+
bool status;
83+
} mOptions;
84+
};
85+
86+
int main(int argc, char** argv)
87+
{
88+
return ProgramUserLogic().execute(argc, argv);
89+
}

src/Cru/Common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ struct CtpInfo {
174174
uint32_t orbitInit;
175175
};
176176

177+
struct UserLogicInfo {
178+
uint32_t eventSize;
179+
bool random;
180+
};
181+
177182
uint32_t getWrapperBaseAddress(int wrapper);
178183
uint32_t getXcvrRegisterAddress(int wrapper, int bank, int link, int reg = 0);
179184
void atxcal0(std::shared_ptr<BarInterface> bar, uint32_t baseAddress);

src/Cru/Constants.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ static constexpr Register SI5345_1(0x00030500);
338338
static constexpr Register SI5345_2(0x00030600);
339339
static constexpr Register SI5344(0x00030400);
340340

341+
/// User Logic related addresses
342+
static constexpr Register USER_LOGIC_RESET(0x00c80000);
343+
static constexpr Register USER_LOGIC_EVSIZE(0x00c80004);
344+
static constexpr Register USER_LOGIC_EVSIZE_RAND(0x00c80008);
345+
341346
} // namespace Registers
342347
} // namespace Cru
343348
} // namespace roc

src/Cru/CruBar.cxx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,5 +1094,26 @@ boost::optional<std::string> CruBar::getUserLogicVersion()
10941094
return (boost::format("%x") % firmwareHash).str();
10951095
}
10961096

1097+
void CruBar::controlUserLogic(uint32_t eventSize, bool random)
1098+
{
1099+
// reset UL
1100+
writeRegister(Cru::Registers::USER_LOGIC_RESET.index, 0x0);
1101+
1102+
// set event size
1103+
writeRegister(Cru::Registers::USER_LOGIC_EVSIZE.index, eventSize);
1104+
1105+
bool randomEventSize = readRegister(Cru::Registers::USER_LOGIC_EVSIZE_RAND.index) == 0x1;
1106+
if (random != randomEventSize) { // toggle random evsize
1107+
writeRegister(Cru::Registers::USER_LOGIC_EVSIZE_RAND.index, 0x1);
1108+
}
1109+
}
1110+
1111+
Cru::UserLogicInfo CruBar::reportUserLogic()
1112+
{
1113+
bool randomEventSize = readRegister(Cru::Registers::USER_LOGIC_EVSIZE_RAND.index) == 0x1;
1114+
uint32_t eventSize = readRegister(Cru::Registers::USER_LOGIC_EVSIZE.index);
1115+
return { eventSize, randomEventSize };
1116+
}
1117+
10971118
} // namespace roc
10981119
} // namespace AliceO2

src/Cru/CruBar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class CruBar final : public BarInterfaceBase
9898

9999
Cru::OnuStatus reportOnuStatus();
100100
Cru::FecStatus reportFecStatus();
101+
102+
void controlUserLogic(uint32_t eventSize, bool random);
103+
Cru::UserLogicInfo reportUserLogic();
104+
101105
std::map<int, Link> initializeLinkMap();
102106

103107
std::shared_ptr<Pda::PdaBar> getPdaBar()

src/Cru/cru_constants_populate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@
137137

138138
'add_gbt_swt_cmd':'SWT_CMD',
139139
'add_gbt_swt_mon':'SWT_MON',
140-
'add_gbt_swt_word_mon':'SWT_WORD_MON'
140+
'add_gbt_swt_word_mon':'SWT_WORD_MON',
141+
142+
### USER LOGIC ###
143+
'add_user_logic_reset':'USER_LOGIC_RESET',
144+
'add_user_logic_eventsize':'USER_LOGIC_EVSIZE',
145+
'add_user_logic_rand_eventsize_toggle':'USER_LOGIC_EVSIZE_RAND'
141146
}
142147

143148
# e.g. 'TEMPERATURE':0x00010008

0 commit comments

Comments
 (0)