From 71e2e98d07499c6d0f31596fec52cd8cef5813a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 5 Jan 2018 18:14:53 +0100 Subject: Implement machine restart --- qtmips_machine/core.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'qtmips_machine/core.cpp') 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); +} -- cgit v1.2.3