aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_machine')
-rw-r--r--qtmips_machine/machineconfig.cpp14
-rw-r--r--qtmips_machine/machineconfig.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/qtmips_machine/machineconfig.cpp b/qtmips_machine/machineconfig.cpp
index 2e0cf78..b81d7c6 100644
--- a/qtmips_machine/machineconfig.cpp
+++ b/qtmips_machine/machineconfig.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "machineconfig.h"
+#include <QMap>
using namespace machine;
@@ -304,6 +305,19 @@ void MachineConfig::set_hazard_unit(enum MachineConfig::HazardUnit hu) {
hunit = hu;
}
+bool MachineConfig::set_hazard_unit(QString hukind) {
+ static QMap<QString, enum HazardUnit> hukind_map = {
+ {"none", HU_NONE},
+ {"stall", HU_STALL},
+ {"forward", HU_STALL_FORWARD},
+ {"stall-forward", HU_STALL_FORWARD},
+ };
+ if (!hukind_map.contains(hukind))
+ return false;
+ set_hazard_unit(hukind_map.value(hukind));
+ return true;
+}
+
void MachineConfig::set_memory_execute_protection(bool v) {
exec_protect = v;
}
diff --git a/qtmips_machine/machineconfig.h b/qtmips_machine/machineconfig.h
index bcd5b76..35373f7 100644
--- a/qtmips_machine/machineconfig.h
+++ b/qtmips_machine/machineconfig.h
@@ -119,6 +119,7 @@ public:
void set_delay_slot(bool);
// Hazard unit
void set_hazard_unit(enum HazardUnit);
+ bool set_hazard_unit(QString hukind);
// Protect data memory from execution. Only program sections can be executed.
void set_memory_execute_protection(bool);
// Protect program memory from accidental writes.