Remove checkValidExecutionRange as a finalize reason
Valid execution range is now delegated to the processor itself for deciding stage validity.
MODIFY
external/VSRTL
external/VSRTL
-Subproject commit 0ceb6d333d80bf98535c8eeed003e7b89371ee8d
+Subproject commit 87cc5cdadd9248b7d65c3de07794820a75030cd5

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -125,7 +125,6 @@ public:
explicit ProcessorClocker(bool& finished) : m_finished(finished) {}
void run() override {
ProcessorHandler::getProcessorNonConst()->clockProcessor();
- ProcessorHandler::checkValidExecutionRange();
ProcessorHandler::checkProcessorFinished();
if (ProcessorHandler::checkBreakpoint()) {
ProcessorHandler::stopRun();
@@ -154,7 +153,6 @@ void ProcessorHandler::_run() {
*/
const auto& cycleFunctor = [=] {
bool stopRunning = m_stopRunningFlag;
- _checkValidExecutionRange();
stopRunning |= _checkBreakpoint() || m_currentProcessor->finished() || m_stopRunningFlag;
if (stopRunning) {
@@ -385,15 +383,6 @@ bool ProcessorHandler::_isExecutableAddress(AInt address) const {
return false;
}
-void ProcessorHandler::_checkValidExecutionRange() const {
- const auto pc = m_currentProcessor->nextFetchedAddress();
- unsigned fr = 0;
- if (!_isExecutableAddress(pc)) {
- fr |= RipesProcessor::FinalizeReason::exitedExecutableRegion;
- }
- m_currentProcessor->finalize(fr);
-}
-
void ProcessorHandler::_setRegisterValue(RegisterFileType rfid, const unsigned idx, VInt value) {
m_currentProcessor->setRegister(rfid, idx, value);
}

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -60,14 +60,6 @@ public:
get()->_selectProcessor(id, extensions, setup);
}
- /**
- * @brief checkValidExecutionRange
- * Checks whether the processor, given continued clocking, that it will execute within the currently validated
- * execution range. If the processor in the next cycle will start to fetch instructions outside of the validated
- * range, the processor is instead requested to start finalizing.
- */
- static void checkValidExecutionRange() { get()->_checkValidExecutionRange(); }
-
/**
* @brief isExecutableAddress
* @returns whether @param address is within the executable section of the currently loaded program.
@@ -205,7 +197,6 @@ private:
void _loadProcessorToWidget(vsrtl::VSRTLWidget* widget);
void _selectProcessor(const ProcessorID& id, const QStringList& extensions = {},
RegisterInitialization setup = RegisterInitialization());
- void _checkValidExecutionRange() const;
bool _isExecutableAddress(AInt address) const;
int _getCurrentProgramSize() const;
AInt _getTextStart() const;

MODIFY
src/processors/RISC-V/rv5s/rv5s.h
src/processors/RISC-V/rv5s/rv5s.h
@@ -421,7 +421,7 @@ public:
void setPCInitialValue(AInt address) override { pc_reg->setInitValue(address); }
AddressSpaceMM& getMemory() override { return *m_memory; }
VInt getRegister(RegisterFileType, unsigned i) const override { return registerFile->getRegister(i); }
- void finalize(const unsigned& fr) override {
+ void finalize(FinalizeReason fr) override {
if ((fr & FinalizeReason::exitSyscall) && !ecallChecker->isSysCallExiting()) {
// An exit system call was executed. Record the cycle of the execution, and enable the ecallChecker's system
// call exiting signal.

MODIFY
src/processors/RISC-V/rv5s_no_fw/rv5s_no_fw.h
src/processors/RISC-V/rv5s_no_fw/rv5s_no_fw.h
@@ -397,7 +397,7 @@ public:
void setPCInitialValue(AInt address) override { pc_reg->setInitValue(address); }
AddressSpaceMM& getMemory() override { return *m_memory; }
VInt getRegister(RegisterFileType, unsigned i) const override { return registerFile->getRegister(i); }
- void finalize(const unsigned& fr) override {
+ void finalize(FinalizeReason fr) override {
if ((fr & FinalizeReason::exitSyscall) && !ecallChecker->isSysCallExiting()) {
// An exit system call was executed. Record the cycle of the execution, and enable the ecallChecker's system
// call exiting signal.

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
@@ -348,7 +348,7 @@ public:
void setPCInitialValue(AInt address) override { pc_reg->setInitValue(address); }
AddressSpaceMM& getMemory() override { return *m_memory; }
VInt getRegister(RegisterFileType, unsigned i) const override { return registerFile->getRegister(i); }
- void finalize(const unsigned& fr) override {
+ void finalize(FinalizeReason fr) override {
if ((fr & FinalizeReason::exitSyscall) && !ecallChecker->isSysCallExiting()) {
// An exit system call was executed. Record the cycle of the execution, and enable the ecallChecker's system
// call exiting signal.

MODIFY
src/processors/RISC-V/rv5s_no_hz/rv5s_no_hz.h
src/processors/RISC-V/rv5s_no_hz/rv5s_no_hz.h
@@ -381,7 +381,7 @@ public:
void setPCInitialValue(AInt address) override { pc_reg->setInitValue(address); }
AddressSpaceMM& getMemory() override { return *m_memory; }
VInt getRegister(RegisterFileType, unsigned i) const override { return registerFile->getRegister(i); }
- void finalize(const unsigned& fr) override {
+ void finalize(FinalizeReason fr) override {
if ((fr & FinalizeReason::exitSyscall) && !ecallChecker->isSysCallExiting()) {
// An exit system call was executed. Record the cycle of the execution, and enable the ecallChecker's system
// call exiting signal.

MODIFY
src/processors/RISC-V/rv6s_dual/rv6s_dual.h
src/processors/RISC-V/rv6s_dual/rv6s_dual.h
@@ -727,7 +727,7 @@ public:
void setPCInitialValue(AInt address) override { pc_reg->setInitValue(address); }
AddressSpaceMM& getMemory() override { return *m_memory; }
VInt getRegister(RegisterFileType, unsigned i) const override { return registerFile->getRegister(i); }
- void finalize(const unsigned& fr) override {
+ void finalize(FinalizeReason fr) override {
if ((fr & FinalizeReason::exitSyscall) && !ecallChecker->isSysCallExiting()) {
// An exit system call was executed. Record the cycle of the execution, and enable the ecallChecker's
// system call exiting signal.

MODIFY
src/processors/RISC-V/rvss/rvss.h
src/processors/RISC-V/rvss/rvss.h
@@ -167,13 +167,13 @@ public:
void setPCInitialValue(AInt address) override { pc_reg->setInitValue(address); }
AddressSpaceMM& getMemory() override { return *m_memory; }
VInt getRegister(RegisterFileType, unsigned i) const override { return registerFile->getRegister(i); }
- void finalize(const unsigned& fr) override {
- if (fr) {
+ void finalize(FinalizeReason fr) override {
+ if (fr == FinalizeReason::exitSyscall) {
// Allow one additional clock cycle to clear the current instruction
m_finishInNextCycle = true;
}
}
- bool finished() const override { return m_finished; }
+ bool finished() const override { return m_finished || !stageInfo(0).stage_valid; }
const std::vector<unsigned> breakpointTriggeringStages() const override { return {0}; }
MemoryAccess dataMemAccess() const override { return memToAccessInfo(data_mem); }

MODIFY
src/processors/interface/ripesprocessor.h
src/processors/interface/ripesprocessor.h
@@ -191,8 +191,8 @@ public:
* segment to inside the .text segment. This will typically happen when a control-flow instruction is near the end
* of the .text segment.
*/
- enum FinalizeReason { exitedExecutableRegion = 0b1, exitSyscall = 0b10 };
- virtual void finalize(const unsigned& finalizeReason) = 0;
+ enum FinalizeReason { None = 0b0, exitSyscall = 0b10 };
+ virtual void finalize(FinalizeReason finalizeReason) = 0;
/**
* @brief finished

MODIFY
src/syscall/control.h
src/syscall/control.h
@@ -16,8 +16,7 @@ public:
ExitSyscall() : BaseSyscall("Exit", "Exits the program with code 0") {}
void execute() {
SystemIO::printString("\nProgram exited with code: 0");
- auto fr = RipesProcessor::FinalizeReason::exitSyscall;
- ProcessorHandler::getProcessorNonConst()->finalize(fr);
+ ProcessorHandler::getProcessorNonConst()->finalize(RipesProcessor::FinalizeReason::exitSyscall);
}
};
@@ -30,8 +29,7 @@ public:
void execute() {
SystemIO::printString("\nProgram exited with code: " +
QString::number(BaseSyscall::getArg(RegisterFileType::GPR, 0)));
- auto fr(RipesProcessor::FinalizeReason::exitSyscall);
- ProcessorHandler::getProcessorNonConst()->finalize(fr);
+ ProcessorHandler::getProcessorNonConst()->finalize(RipesProcessor::FinalizeReason::exitSyscall);
}
};

Remove checkValidExecutionRange as a finalize reason

Valid execution range is now delegated to the processor itself for deciding stage validity.