aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/core.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-05 18:14:53 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-05 18:14:53 +0100
commit71e2e98d07499c6d0f31596fec52cd8cef5813a9 (patch)
treed2aa2729956464f2aab62bb5f088850b69a5a8d7 /qtmips_machine/core.cpp
parent1a3fbaf22975b1f130998841adb3109b8a543513 (diff)
downloadqtmips-71e2e98d07499c6d0f31596fec52cd8cef5813a9.tar.gz
qtmips-71e2e98d07499c6d0f31596fec52cd8cef5813a9.tar.bz2
qtmips-71e2e98d07499c6d0f31596fec52cd8cef5813a9.zip
Implement machine restart
Diffstat (limited to 'qtmips_machine/core.cpp')
-rw-r--r--qtmips_machine/core.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp
index 53b7cad..faebd87 100644
--- a/qtmips_machine/core.cpp
+++ b/qtmips_machine/core.cpp
@@ -259,11 +259,11 @@ void Core::dtMemoryInit(struct dtMemory &dt) {
CoreSingle::CoreSingle(Registers *regs, MemoryAccess *mem, bool jmp_delay_slot) : \
Core(regs, mem) {
- if (jmp_delay_slot) {
+ if (jmp_delay_slot)
jmp_delay_decode = new struct Core::dtDecode();
- dtDecodeInit(*jmp_delay_decode);
- } else
+ else
jmp_delay_decode = nullptr;
+ reset();
}
CoreSingle::~CoreSingle() {
@@ -284,16 +284,18 @@ void CoreSingle::step() {
handle_pc(d);
}
+void CoreSingle::reset() {
+ if (jmp_delay_decode != nullptr)
+ Core::dtDecodeInit(*jmp_delay_decode);
+}
+
CorePipelined::CorePipelined(Registers *regs, MemoryAccess *mem) : \
Core(regs, mem) {
- dtFetchInit(dt_f);
- dtDecodeInit(dt_d);
- dtExecuteInit(dt_e);
- dtMemoryInit(dt_m);
+ reset();
}
void CorePipelined::step() {
- // TODO implement pipelined
+ // TODO implement forward unit
writeback(dt_m);
dt_m =memory(dt_e);
dt_e = execute(dt_d);
@@ -301,3 +303,10 @@ void CorePipelined::step() {
dt_f = fetch();
handle_pc(dt_d);
}
+
+void CorePipelined::reset() {
+ dtFetchInit(dt_f);
+ dtDecodeInit(dt_d);
+ dtExecuteInit(dt_e);
+ dtMemoryInit(dt_m);
+}