diff options
author | Karel Kočí <cynerd@email.cz> | 2018-01-03 17:52:45 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-01-03 17:52:45 +0100 |
commit | 08d7e3dabd81e9d6e4f73aa5889a1d709242177c (patch) | |
tree | 1ad8277b3be1534f3d2a451e6c4fe659f9d9cb24 /qtmips_machine/core.cpp | |
parent | 4a40dddda4d3839814be2f00fb9a62f95b1b3f21 (diff) | |
download | qtmips-08d7e3dabd81e9d6e4f73aa5889a1d709242177c.tar.gz qtmips-08d7e3dabd81e9d6e4f73aa5889a1d709242177c.tar.bz2 qtmips-08d7e3dabd81e9d6e4f73aa5889a1d709242177c.zip |
Allow delay slot disable for non-pipelined core
Diffstat (limited to 'qtmips_machine/core.cpp')
-rw-r--r-- | qtmips_machine/core.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp index 276931c..53b7cad 100644 --- a/qtmips_machine/core.cpp +++ b/qtmips_machine/core.cpp @@ -257,9 +257,18 @@ void Core::dtMemoryInit(struct dtMemory &dt) { dt.towrite_val = 0; } -CoreSingle::CoreSingle(Registers *regs, MemoryAccess *mem) : \ +CoreSingle::CoreSingle(Registers *regs, MemoryAccess *mem, bool jmp_delay_slot) : \ Core(regs, mem) { - dtDecodeInit(jmp_delay_decode); + if (jmp_delay_slot) { + jmp_delay_decode = new struct Core::dtDecode(); + dtDecodeInit(*jmp_delay_decode); + } else + jmp_delay_decode = nullptr; +} + +CoreSingle::~CoreSingle() { + if (jmp_delay_decode != nullptr) + delete jmp_delay_decode; } void CoreSingle::step() { @@ -268,8 +277,11 @@ void CoreSingle::step() { struct dtExecute e = execute(d); struct dtMemory m = memory(e); writeback(m); - handle_pc(jmp_delay_decode); - jmp_delay_decode = d; // Copy current decode + if (jmp_delay_decode != nullptr) { + handle_pc(*jmp_delay_decode); + *jmp_delay_decode = d; // Copy current decode + } else + handle_pc(d); } CorePipelined::CorePipelined(Registers *regs, MemoryAccess *mem) : \ |