Skip to content

Commit 74f3a33

Browse files
committed
[sc] Separate global SC from module resets
1 parent 6687896 commit 74f3a33

File tree

10 files changed

+61
-39
lines changed

10 files changed

+61
-39
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ The services are DIM RPC services. Every RPC is called with a string and expects
8181
* An SCA command and data pair (e.g. `0x0000f00d,0x0000cafe`)
8282
* A wait operation (e.g. `30,wait`) in ms, defaults to 3
8383
* An SCA connect operation (e.g. `connect`)
84-
* An SCA reset operation (e.g. `reset`)
84+
* An SCA reset operation (`reset`)
85+
* An SC global reset operation (`sc_reset`)
8586
* An instruction to execute the sequence atomically (`lock` - needs to lead the sequence)
8687
* Returns:
8788
* Sequence of SCA output as follows:
8889
* SCA command and SCA read pairs
8990
* Wait confirmations with time waited
9091
* Connect confirmations made up of a "connect" string
91-
* No entries for `reset` directives
92-
* No entries for `lock` directives
92+
* No entries for `reset`, `sc_reset`, and `lock` directives
9393

9494
* Example:
9595
* DIM input: `0x00000010,0x00000011\n3\n0x000000020,0x00000021`
@@ -101,21 +101,21 @@ The services are DIM RPC services. Every RPC is called with a string and expects
101101
* Sequence of SWT word and operation pairs as follows:
102102
* Operations may be:
103103
* `write` with SWT prefix (e.g. `0x0000f00d,write`)
104-
* `reset` (without SWT word)
104+
* `sc_reset` without prefix, is global
105105
* `read` with optional TimeOut prefix (e.g. `2,read`)
106106
* `wait` with optional WaitTime prefix in ms (e.g. `5,wait`), defaults to 3
107107
* `lock` which instructs ALF to execute the sequence atomically (needs to lead the sequence)
108108
* Returns:
109109
* Sequence of SWT output as follows:
110110
* `write` always retuns `0`
111111
* `read` returns the SWT words present in the CRU SWT FIFO
112-
* `reset` returns nothing
112+
* `sc_reset` returns nothing
113113
* `wait` returns time waited
114114
* `lock` returns nothing
115115

116116
* Example:
117-
* DIM input `reset\n0x0000000000badc0ffee,write\nread\n0xbadf00d,write\n4,read`
118-
* DIM input (atomic) `lock\nreset\n0x0000000000badc0ffee,write\nread\n0xbadf00d,write\n4,read`
117+
* DIM input `sc_reset\n0x0000000000badc0ffee,write\nread\n0xbadf00d,write\n4,read`
118+
* DIM input (atomic) `lock\nsc_reset\n0x0000000000badc0ffee,write\nread\n0xbadf00d,write\n4,read`
119119
* DIM output `0\n0x0000000000badc0ffee\n0\n0x000000000000badf00d\n`
120120

121121
##### IC_SEQUENCE
@@ -216,7 +216,7 @@ The services are DIM RPC services. Every RPC is called with a string and expects
216216
## Slow Control library
217217
ALF can also be used as a C++ library to access the Slow Control interface of the CRU. The three available interfaces (IC, SCA & SWT) can be accessed through single operations, or sequences of operations.
218218

219-
For each Slow Control (SC) class a handle can be acquired by passing the card ID as an `std::string` argument and, optionally, the SC channel to use as an `int`. Constructors have no side-effects; an SC reset would need to be performed manually before starting operations (e.g. `swt.reset()`).
219+
For each Slow Control (SC) class a handle can be acquired by passing the card ID as an `std::string` argument and, optionally, the SC channel to use as an `int`. Constructors have no side-effects; an SC reset would need to be performed manually before starting operations (e.g. `swt.scReset()`).
220220

221221
### Single operations
222222
Depending on the type, an SC class offers a different interface for single operation execution. `SWT` and `IC` offer `read()` and `write()` standalone operations, while `SCA` only offers `executeCommand()`.
@@ -226,7 +226,7 @@ All the above offer **no implicit locking** and should be manually locked throug
226226
### Sequences of operations
227227
All SC classes offer a function to execute a sequence of their respective operations. This function receives an `std::vector`, consisting of an `std::pair` made up of the compatible SC operation and SC data, as these are defined in their headers.
228228

229-
For example, `SWT` offers `Read, Write, Wait, and Reset` operations which expect a `TimeOut`, an `SwtWord`, a `WaitTime`, and no argument, respectively.
229+
For example, `SWT` offers `Read, Write, Wait, and SCReset` operations which expect a `TimeOut`, an `SwtWord`, a `WaitTime`, and no argument, respectively.
230230

231231
```
232232
typedef int TimeOut;
@@ -239,7 +239,7 @@ typedef boost::variant<boost::blank, TimeOut, WaitTime, SwtWord, std::string> Da
239239
enum Operation { Read,
240240
Write,
241241
Wait,
242-
Reset,
242+
SCReset,
243243
Error };
244244
245245
std::vector<std::pair<Operation, Data>> executeSequence(const std::vector<std::pair<Operation, Data>>& operations, bool lock = false);

apps/AlfClient.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class AlfClient : public AliceO2::Common::Program
157157
if (mOptions.swt) {
158158
auto swtOut = swtSequence.write({ std::make_pair("", "lock"),
159159
std::make_pair("0x0000000000000000000", "write"),
160-
std::make_pair("", "reset"),
160+
std::make_pair("", "sc_reset"),
161161
std::make_pair("0x0000000000000000000", "write"),
162162
std::make_pair("0x000000001234", "write"),
163163
std::make_pair("", "read"),
@@ -189,7 +189,8 @@ class AlfClient : public AliceO2::Common::Program
189189
}
190190

191191
if (mOptions.sca) {
192-
auto scaOut = scaSequence.write({ std::make_pair("", "reset"),
192+
auto scaOut = scaSequence.write({ std::make_pair("", "sc_reset"),
193+
std::make_pair("", "reset"),
193194
std::make_pair("", "connect"),
194195
std::make_pair("1000", "wait"),
195196
std::make_pair("0x00010002", "0xff000000"),

apps/AlfLibClient.cxx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ class AlfLibClient : public AliceO2::Common::Program
6666
if (mOptions.sca) {
6767
std::cout << "Running SCA test" << std::endl;
6868
auto sca = Sca(roc::SerialId{ mOptions.serial, mOptions.endpoint }, mOptions.link);
69-
sca.reset();
69+
sca.scReset();
7070

7171
std::cout << "Running simple SCA operations" << std::endl;
7272
try {
73+
sca.reset();
7374
sca.connect();
7475
auto scaOut = sca.executeCommand({ 0x00010002, 0xff000000 });
7576
std::cout << scaOut.command << " " << scaOut.data << std::endl;
@@ -80,7 +81,8 @@ class AlfLibClient : public AliceO2::Common::Program
8081
std::cout << "Running an SCA sequence" << std::endl;
8182
std::vector<std::pair<Sca::Operation, Sca::Data>> ops;
8283
sca.setChannel(1);
83-
ops.push_back({ Sca::Operation::Reset , {} });
84+
ops.push_back({ Sca::Operation::SCReset, {} });
85+
ops.push_back({ Sca::Operation::Reset, {} });
8486
ops.push_back({ Sca::Operation::Connect, {} });
8587
ops.push_back({ Sca::Operation::Command, Sca::CommandData{ 0x00100002, 0xff000000 } });
8688
ops.push_back({ Sca::Operation::Command, Sca::CommandData{ 0x00100003, 0xff000000 } });
@@ -94,6 +96,8 @@ class AlfLibClient : public AliceO2::Common::Program
9496
std::cout << "Wait: " << std::dec << boost::get<Sca::WaitTime>(out.second) << std::endl;
9597
} else if (out.first == Sca::Operation::Reset) {
9698
std::cout << "Reset" << std::endl;
99+
} else if (out.first == Sca::Operation::SCReset) {
100+
std::cout << "SC Reset" << std::endl;
97101
} else if (out.first == Sca::Operation::Connect) {
98102
std::cout << "Connect " << std::endl;
99103
} else if (out.first == Sca::Operation::Error) {
@@ -110,7 +114,7 @@ class AlfLibClient : public AliceO2::Common::Program
110114

111115
std::cout << "Running simple SWT operations" << std::endl;
112116
try {
113-
swt.reset();
117+
swt.scReset();
114118
swt.write({ 0xcafe, 0x41d, 0x0 });
115119
swt.write({ 0xb00f, 0x42, 0x88 });
116120
swt.write({ 0xb00f, 0x42, 0x88 });
@@ -128,7 +132,7 @@ class AlfLibClient : public AliceO2::Common::Program
128132
std::vector<std::pair<Swt::Operation, Swt::Data>> ops;
129133
swt = Swt(roc::SerialId{ mOptions.serial, mOptions.endpoint });
130134
swt.setChannel(1);
131-
ops.push_back({ Swt::Operation::Reset, {} });
135+
ops.push_back({ Swt::Operation::SCReset, {} });
132136
ops.push_back({ Swt::Operation::Write, SwtWord{ 0xcafe, 0x41d, 0x0 } });
133137
ops.push_back({ Swt::Operation::Write, SwtWord{ 0xb00f, 0x42, 0x88, SwtWord::Size::High } });
134138
ops.push_back({ Swt::Operation::Write, SwtWord{ 0xb00f, 0x42, 0x88 } });
@@ -149,8 +153,8 @@ class AlfLibClient : public AliceO2::Common::Program
149153
std::cout << "Write | " << boost::get<SwtWord>(out.second) << std::endl;
150154
} else if (out.first == Swt::Operation::Read) {
151155
std::cout << "Read | " << boost::get<SwtWord>(out.second) << std::endl;
152-
} else if (out.first == Swt::Operation::Reset) {
153-
std::cout << "Reset |" /* boost::blank here */ << std::endl;
156+
} else if (out.first == Swt::Operation::SCReset) {
157+
std::cout << "SC Reset |" /* boost::blank here */ << std::endl;
154158
} else if (out.first == Swt::Operation::Wait) {
155159
std::cout << "Wait | " << std::dec << boost::get<int>(out.second) << std::endl;
156160
} else if (out.first == Swt::Operation::Error) {
@@ -164,7 +168,7 @@ class AlfLibClient : public AliceO2::Common::Program
164168
if (mOptions.ic) {
165169
std::cout << "Running IC test" << std::endl;
166170
auto ic = Ic(roc::SerialId{ mOptions.serial, mOptions.endpoint }, mOptions.link);
167-
ic.reset();
171+
ic.scReset();
168172

169173
std::cout << "Running Simple IC operations" << std::endl;
170174
try {

include/Alf/Ic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Ic
7979
void checkChannelSet();
8080

8181
/// Executes an SC reset
82-
void reset();
82+
void scReset();
8383

8484
/// Performs an IC read
8585
/// \param address IC address to read from

include/Alf/Sca.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Sca
5252
/// Enum for the different SCA operation types as seen from DIM RPCs
5353
enum Operation { Command,
5454
Wait,
55+
SCReset,
5556
Reset,
5657
Connect,
5758
Error,
@@ -79,6 +80,9 @@ class Sca
7980
/// \throws o2::alf::ScaException if no SCA channel selected
8081
void checkChannelSet();
8182

83+
/// Executes a global SC reset
84+
void scReset();
85+
8286
/// Executes an SCA reset
8387
void reset();
8488

include/Alf/Swt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Swt
5757
/// Enum for the different SWT operation types
5858
enum Operation { Read,
5959
Write,
60-
Reset,
60+
SCReset,
6161
Wait,
6262
Error,
6363
Lock };
@@ -85,7 +85,7 @@ class Swt
8585
void checkChannelSet();
8686

8787
/// Executes an SC reset
88-
void reset();
88+
void scReset();
8989

9090
/// Writes an SWT word
9191
/// \param swtWord The SWT word to write

src/AlfServer.cxx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ std::pair<Sca::Operation, Sca::Data> AlfServer::stringToScaPair(const std::strin
302302
BOOST_THROW_EXCEPTION(
303303
AlfException() << ErrorInfo::Message("Too many arguments for RESET operation"));
304304
}
305+
} else if (scaPair[scaPair.size() - 1] == "sc_reset") {
306+
operation = Sca::Operation::SCReset;
307+
if (scaPair.size() != 1) {
308+
BOOST_THROW_EXCEPTION(
309+
AlfException() << ErrorInfo::Message("Too many arguments for SC RESET operation"));
310+
}
305311
} else if (scaPair[scaPair.size() - 1] == "connect") {
306312
operation = Sca::Operation::Connect;
307313
if (scaPair.size() != 1) {
@@ -348,11 +354,11 @@ std::pair<Swt::Operation, Swt::Data> AlfServer::stringToSwtPair(const std::strin
348354
BOOST_THROW_EXCEPTION(
349355
AlfException() << ErrorInfo::Message("Too few arguments for WRITE operation"));
350356
}
351-
} else if (swtPair[swtPair.size() - 1] == "reset") {
352-
operation = Swt::Operation::Reset;
357+
} else if (swtPair[swtPair.size() - 1] == "sc_reset") {
358+
operation = Swt::Operation::SCReset;
353359
if (swtPair.size() == 2) {
354360
BOOST_THROW_EXCEPTION(
355-
AlfException() << ErrorInfo::Message("Too many arguments for RESET operation"));
361+
AlfException() << ErrorInfo::Message("Too many arguments for SC RESET operation"));
356362
}
357363
} else if (swtPair[swtPair.size() - 1] == "wait") {
358364
operation = Swt::Operation::Wait;

src/Ic.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static constexpr roc::Register IC_RD_DATA(IC_BASE.address + 0x30);
5454

5555
Ic::Ic(AlfLink link) : mBar2(link.bar), mLink(link)
5656
{
57-
reset();
57+
scReset();
5858

5959
// Set CFG to 0x3 by default
6060
barWrite(ic_regs::IC_WR_CFG.index, 0x3);
@@ -117,7 +117,7 @@ void Ic::checkChannelSet()
117117
}
118118
}
119119

120-
void Ic::reset()
120+
void Ic::scReset()
121121
{
122122
barWrite(sc_regs::SC_RESET.index, 0x1);
123123
barWrite(sc_regs::SC_RESET.index, 0x0); //void cmd to sync clocks

src/Sca.cxx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,22 @@ void Sca::checkChannelSet()
9696
}
9797
}
9898

99+
void Sca::scReset()
100+
{
101+
barWrite(sc_regs::SC_RESET.index, 0x1);
102+
barWrite(sc_regs::SC_RESET.index, 0x0); //void cmd to sync clocks
103+
}
104+
99105
void Sca::reset()
100106
{
101107
barWrite(sc_regs::SCA_WR_CTRL.index, 0x1);
102108
barWrite(sc_regs::SCA_WR_CTRL.index, 0x0);
103-
/* DO I NEED THIS?
104-
waitOnBusyClear(); */
105109
}
106110

107111
void Sca::connect()
108112
{
109113
barWrite(sc_regs::SCA_WR_CTRL.index, 0x2);
110114
barWrite(sc_regs::SCA_WR_CTRL.index, 0x0);
111-
/* DO I NEED THIS?
112-
waitOnBusyClear(); */
113115
}
114116

115117
Sca::CommandData Sca::executeCommand(uint32_t command, uint32_t data, bool lock)
@@ -299,6 +301,9 @@ std::vector<std::pair<Sca::Operation, Sca::Data>> Sca::executeSequence(const std
299301
} else if (operation == Operation::Reset) {
300302
reset();
301303
ret.push_back({ Operation::Reset, {} });
304+
} else if (operation == Operation::SCReset) {
305+
scReset();
306+
ret.push_back({ Operation::SCReset, {} });
302307
} else if (operation == Operation::Connect) {
303308
connect();
304309
ret.push_back({ Operation::Connect, {} });
@@ -315,6 +320,8 @@ std::vector<std::pair<Sca::Operation, Sca::Data>> Sca::executeSequence(const std
315320
meaningfulMessage = (boost::format("SCA_SEQUENCE WAIT waitTime=%d serialId=%s link=%d error='%s'") % boost::get<WaitTime>(data) % mLink.serialId % mLink.linkId % e.what()).str();
316321
} else if (operation == Operation::Reset) {
317322
meaningfulMessage = (boost::format("SCA_SEQUENCE RESET serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
323+
} else if (operation == Operation::SCReset) {
324+
meaningfulMessage = (boost::format("SCA_SEQUENCE SC RESET serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
318325
} else if (operation == Operation::Connect) {
319326
meaningfulMessage = (boost::format("SCA_SEQUENCE CONNECT serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
320327
} else {
@@ -345,7 +352,7 @@ std::string Sca::writeSequence(const std::vector<std::pair<Operation, Data>>& op
345352
resultBuffer << data << "\n"; // "[cmd],[data]\n"
346353
} else if (operation == Operation::Wait) {
347354
resultBuffer << std::dec << data << "\n"; // "[time]\n"
348-
} else if (operation == Operation::Reset) {
355+
} else if (operation == Operation::Reset || operation == Operation::SCReset) {
349356
/* DO NOTHING */
350357
} else if (operation == Operation::Connect) {
351358
resultBuffer << "connect\n"; // echo

src/Swt.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void Swt::setChannel(int gbtChannel)
8686
barWrite(sc_regs::SC_LINK.index, mLink.rawLinkId);
8787
}
8888

89-
void Swt::reset()
89+
void Swt::scReset()
9090
{
9191
barWrite(sc_regs::SC_RESET.index, 0x1);
9292
barWrite(sc_regs::SC_RESET.index, 0x0); //void cmd to sync clocks
@@ -207,9 +207,9 @@ std::vector<std::pair<Swt::Operation, Swt::Data>> Swt::executeSequence(std::vect
207207
write(word);
208208
ret.push_back({ Operation::Write, word });
209209
//ret.push_back({ Operation::Write, {} }); // TODO: Is it better to return {} ?
210-
} else if (operation == Operation::Reset) {
211-
reset();
212-
ret.push_back({ Operation::Reset, {} });
210+
} else if (operation == Operation::SCReset) {
211+
scReset();
212+
ret.push_back({ Operation::SCReset, {} });
213213
} else if (operation == Operation::Wait) {
214214
int waitTime;
215215
try {
@@ -229,8 +229,8 @@ std::vector<std::pair<Swt::Operation, Swt::Data>> Swt::executeSequence(std::vect
229229
meaningfulMessage = (boost::format("SWT_SEQUENCE READ timeout=%d serialId=%s link=%d, error='%s'") % boost::get<TimeOut>(data) % mLink.serialId % mLink.linkId % e.what()).str();
230230
} else if (operation == Operation::Write) {
231231
meaningfulMessage = (boost::format("SWT_SEQUENCE WRITE data=%s serialId=%s link=%d, error='%s'") % boost::get<SwtWord>(data) % mLink.serialId % mLink.linkId % e.what()).str();
232-
} else if (operation == Operation::Reset) {
233-
meaningfulMessage = (boost::format("SWT_SEQUENCE RESET serialId=%d link=%s, error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
232+
} else if (operation == Operation::SCReset) {
233+
meaningfulMessage = (boost::format("SWT_SEQUENCE SC RESET serialId=%d link=%s, error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
234234
} else if (operation == Operation::Wait) {
235235
meaningfulMessage = (boost::format("SWT_SEQUENCE WAIT waitTime=%d serialId=%s link=%d error='%s'") % boost::get<WaitTime>(data) % mLink.serialId % mLink.linkId % e.what()).str();
236236
} else {
@@ -261,7 +261,7 @@ std::string Swt::writeSequence(std::vector<std::pair<Operation, Data>> sequence,
261261
resultBuffer << data << "\n";
262262
} else if (operation == Operation::Write) {
263263
resultBuffer << "0\n";
264-
} else if (operation == Operation::Reset) {
264+
} else if (operation == Operation::SCReset) {
265265
/* DO NOTHING */
266266
} else if (operation == Operation::Wait) {
267267
resultBuffer << std::dec << data << "\n";

0 commit comments

Comments
 (0)