Use std::function instead of signal for syscall handler
MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -212,7 +212,7 @@ void ProcessorHandler::_selectProcessor(const ProcessorID& id, const QStringList
m_currentProcessor->isExecutableAddress = [=](uint32_t address) { return _isExecutableAddress(address); };
// Syscall handling initialization
- m_currentProcessor->handleSysCall.Connect(this, &ProcessorHandler::asyncTrap);
+ m_currentProcessor->handleSysCall = [=] { syscallTrap(); };
// Register initializations
auto& regs = m_currentProcessor->getArchRegisters();
@@ -293,7 +293,7 @@ QString ProcessorHandler::_disassembleInstr(const uint32_t addr) const {
}
}
-void ProcessorHandler::asyncTrap() {
+void ProcessorHandler::syscallTrap() {
auto futureWatcher = QFutureWatcher<bool>();
futureWatcher.setFuture(QtConcurrent::run([=] {
const unsigned int function =

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -186,11 +186,11 @@ public slots:
private slots:
/**
- * @brief asyncTrap
+ * @brief syscallTrap
* Connects to the processors system call request interface. Will concurrently run the systemcall manager to handle
* the requested functionality, and return once the system call was handled.
*/
- void asyncTrap();
+ void syscallTrap();
private:
RipesProcessor* _getProcessorNonConst() { return m_currentProcessor.get(); }

MODIFY
src/processors/RISC-V/rv5s/rv5s.h
src/processors/RISC-V/rv5s/rv5s.h
@@ -150,7 +150,7 @@ public:
// Ecall checker
idex_reg->opcode_out >> ecallChecker->opcode;
- ecallChecker->setSysCallSignal(&handleSysCall);
+ ecallChecker->setSyscallCallback(&handleSysCall);
hzunit->stallEcallHandling >> ecallChecker->stallEcallHandling;
// -----------------------------------------------------------------------

MODIFY
src/processors/RISC-V/rv5s_no_fw/rv5s_no_fw.h
src/processors/RISC-V/rv5s_no_fw/rv5s_no_fw.h
@@ -38,7 +38,8 @@ class RV5S_NO_FW : public RipesVSRTLProcessor {
public:
enum Stage { IF = 0, ID = 1, EX = 2, MEM = 3, WB = 4, STAGECOUNT };
- RV5S_NO_FW(const QStringList& extensions) : RipesVSRTLProcessor("5-Stage RISC-V Processor without forwarding unit") {
+ RV5S_NO_FW(const QStringList& extensions)
+ : RipesVSRTLProcessor("5-Stage RISC-V Processor without forwarding unit") {
m_enabledISA = std::make_shared<ISAInfo<XLenToRVISA<XLEN>()>>(extensions);
decode->setISA(m_enabledISA);
@@ -135,7 +136,7 @@ public:
// Ecall checker
idex_reg->opcode_out >> ecallChecker->opcode;
- ecallChecker->setSysCallSignal(&handleSysCall);
+ ecallChecker->setSyscallCallback(&handleSysCall);
hzunit->stallEcallHandling >> ecallChecker->stallEcallHandling;
// -----------------------------------------------------------------------

MODIFY
src/processors/RISC-V/rv5s_no_fw_hz/rv5s_no_fw_hz.h
src/processors/RISC-V/rv5s_no_fw_hz/rv5s_no_fw_hz.h
@@ -127,7 +127,7 @@ public:
// -----------------------------------------------------------------------
// Ecall checker
decode->opcode >> ecallChecker->opcode;
- ecallChecker->setSysCallSignal(&handleSysCall);
+ ecallChecker->setSyscallCallback(&handleSysCall);
0 >> ecallChecker->stallEcallHandling;
// -----------------------------------------------------------------------

MODIFY
src/processors/RISC-V/rv5s_no_hz/rv5s_no_hz.h
src/processors/RISC-V/rv5s_no_hz/rv5s_no_hz.h
@@ -140,7 +140,7 @@ public:
// -----------------------------------------------------------------------
// Ecall checker
decode->opcode >> ecallChecker->opcode;
- ecallChecker->setSysCallSignal(&handleSysCall);
+ ecallChecker->setSyscallCallback(&handleSysCall);
0 >> ecallChecker->stallEcallHandling;
// -----------------------------------------------------------------------

MODIFY
src/processors/RISC-V/rv6s_dual/rv6s_dual.h
src/processors/RISC-V/rv6s_dual/rv6s_dual.h
@@ -286,7 +286,7 @@ public:
// Ecall checker
iiex_reg->opcode_out >> ecallChecker->opcode;
- ecallChecker->setSysCallSignal(&handleSysCall);
+ ecallChecker->setSyscallCallback(&handleSysCall);
hzunit->stallEcallHandling >> ecallChecker->stallEcallHandling;
// -----------------------------------------------------------------------

MODIFY
src/processors/RISC-V/rv_ecallchecker.h
src/processors/RISC-V/rv_ecallchecker.h
@@ -14,8 +14,9 @@ public:
EcallChecker(std::string name, SimComponent* parent) : Component(name, parent) {
dummy << [=] {
if (opcode.uValue() == RVInstr::ECALL && !stallEcallHandling.uValue() && !handlingEcall) {
+ assert(m_callback != nullptr && "No syscall callback was set!");
handlingEcall = true;
- m_signal->Emit();
+ (*m_callback)();
handlingEcall = false;
}
return 0;
@@ -28,7 +29,7 @@ public:
syscallExit << [=] { return m_syscallExit; };
}
- void setSysCallSignal(Gallant::Signal0<>* sig) { m_signal = sig; }
+ void setSyscallCallback(std::function<void(void)> const* cb) { m_callback = cb; }
/**
* @brief setSysCallExiting
@@ -37,7 +38,7 @@ public:
void setSysCallExiting(bool state) { m_syscallExit = state; }
bool isSysCallExiting() const { return m_syscallExit; }
- Gallant::Signal0<>* m_signal;
+ std::function<void(void)> const* m_callback = nullptr;
INPUTPORT_ENUM(opcode, RVInstr);

MODIFY
src/processors/RISC-V/rvss/rvss.h
src/processors/RISC-V/rvss/rvss.h
@@ -114,7 +114,7 @@ public:
// -----------------------------------------------------------------------
// Ecall checker
decode->opcode >> ecallChecker->opcode;
- ecallChecker->setSysCallSignal(&handleSysCall);
+ ecallChecker->setSyscallCallback(&handleSysCall);
0 >> ecallChecker->stallEcallHandling;
}

MODIFY
src/processors/ripesprocessor.h
src/processors/ripesprocessor.h
@@ -232,9 +232,11 @@ public:
/**
* @brief handleSysCall
* Signal that the processor can use to pass control to the outside environment whenever a system call must be
- * handled (RISC-V ecall instruction).
+ * handled.
+ * No arguments are passed - the Ripes environment will look at the syscall register for the ISA of the processor,
+ * alongside the syscall argument registers, and perform a corresponding syscall.
*/
- Gallant::Signal0<> handleSysCall;
+ std::function<void(void)> handleSysCall;
/** ======================== FEATURE: Reversible ======================== */
// Enabled by setting m_features.isReversible = true

MODIFY
test/tst_cosimulate.cpp
test/tst_cosimulate.cpp
@@ -266,8 +266,7 @@ void tst_Cosimulate::cosimulate(const ProcessorID& id, const QStringList& extens
// Override the ProcessorHandler's ECALL handling. In doing so, we verify whether the correct test value was
// reached.
- ProcessorHandler::get()->getProcessorNonConst()->handleSysCall.Connect(this, &tst_Cosimulate::handleSysCall);
-
+ ProcessorHandler::get()->getProcessorNonConst()->handleSysCall = [=] { handleSysCall(); };
std::cout << test.filepath.toStdString() << std::endl;
auto referenceTrace = generateReferenceTrace(extensions);
ProcessorHandler::get()->selectProcessor(id, extensions);

MODIFY
test/tst_riscv.cpp
test/tst_riscv.cpp
@@ -167,7 +167,7 @@ void tst_RISCV::runTests(const ProcessorID& id, const QString& testdir) {
// Override the ProcessorHandler's ECALL handling. In doing so, we verify whether the correct test value was
// reached.
- ProcessorHandler::getProcessorNonConst()->handleSysCall.Connect(this, &tst_RISCV::handleSysCall);
+ ProcessorHandler::getProcessorNonConst()->handleSysCall = [=] { handleSysCall(); };
ProcessorHandler::get()->loadProgram(spProgram);
RipesSettings::getObserver(RIPES_GLOBALSIGNAL_REQRESET)->trigger();

Use std::function instead of signal for syscall handler