aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2020-04-06 22:38:46 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2020-04-06 22:38:46 +0200
commit27b38375203880cbc991eaac1d97c927346fa7e0 (patch)
treef734e2aead5fe106a7aa837aaa9a21db12138a24
parent7ff1c310a3ab3f7df13026b8bfe58adcf8b0ec81 (diff)
downloadqtmips-27b38375203880cbc991eaac1d97c927346fa7e0.tar.gz
qtmips-27b38375203880cbc991eaac1d97c927346fa7e0.tar.bz2
qtmips-27b38375203880cbc991eaac1d97c927346fa7e0.zip
qtmips_cli: add option to specify used hazard unit - none, stall, forward.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r--qtmips_cli/main.cpp10
-rw-r--r--qtmips_machine/machineconfig.cpp14
-rw-r--r--qtmips_machine/machineconfig.h1
3 files changed, 25 insertions, 0 deletions
diff --git a/qtmips_cli/main.cpp b/qtmips_cli/main.cpp
index c77ba2f..2984d8c 100644
--- a/qtmips_cli/main.cpp
+++ b/qtmips_cli/main.cpp
@@ -59,6 +59,7 @@ void create_parser(QCommandLineParser &p) {
p.addOption({"asm", "Treat provided file argument as assembler source."});
p.addOption({"pipelined", "Configure CPU to use five stage pipeline."});
p.addOption({"no-delay-slot", "Disable jump delay slot."});
+ p.addOption({"hazard-unit", "Specify hazard unit imeplementation [none|stall|forward].", "HUKIND"});
p.addOption({{"trace-fetch", "tr-fetch"}, "Trace fetched instruction (for both pipelined and not core)."});
p.addOption({{"trace-decode", "tr-decode"}, "Trace instruction in decode stage. (only for pipelined core)"});
p.addOption({{"trace-execute", "tr-execute"}, "Trace instruction in execute stage. (only for pipelined core)"});
@@ -145,6 +146,15 @@ void configure_machine(QCommandLineParser &p, MachineConfig &cc) {
cc.set_delay_slot(!p.isSet("no-delay-slot"));
cc.set_pipelined(p.isSet("pipelined"));
+ siz = p.values("hazard-unit").size();
+ if (siz >= 1) {
+ QString hukind = p.values("hazard-unit").at(siz - 1).toLower();
+ if (!cc.set_hazard_unit(hukind)) {
+ std::cerr << "Unknown kind of hazard unit specified" << std::endl;
+ exit(1);
+ }
+ }
+
siz = p.values("read-time").size();
if (siz >= 1)
cc.set_memory_access_time_read(p.values("read-time").at(siz - 1).toLong());
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.