From 15dbd208fa6c1ac4dc0684c95c43cc40b2462cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 8 Apr 2018 11:55:52 +0200 Subject: Integrate cache with rest of the machine core --- qtmips_machine/qtmipsmachine.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'qtmips_machine/qtmipsmachine.cpp') diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp index e96924a..4a2b0f2 100644 --- a/qtmips_machine/qtmipsmachine.cpp +++ b/qtmips_machine/qtmipsmachine.cpp @@ -13,11 +13,13 @@ QtMipsMachine::QtMipsMachine(const MachineConfig &cc) : QObject(), mcnf(&cc) { regs = new Registers(); mem = new Memory(*mem_program_only); + cch_program = new Cache(mem, &cc.cache_program()); + cch_data = new Cache(mem, &cc.cache_data()); if (cc.pipelined()) - cr = new CorePipelined(regs, mem, cc.hazard_unit()); + cr = new CorePipelined(regs, cch_program, cch_data, cc.hazard_unit()); else - cr = new CoreSingle(regs, mem, cc.delay_slot()); + cr = new CoreSingle(regs, cch_program, cch_data, cc.delay_slot()); run_t = new QTimer(this); set_speed(0); // In default run as fast as possible @@ -40,8 +42,12 @@ const Memory *QtMipsMachine::memory() { return mem; } -const Cache *QtMipsMachine::cache() { - return cch; +const Cache *QtMipsMachine::cache_program() { + return cch_program; +} + +const Cache *QtMipsMachine::cache_data() { + return cch_data; } const Core *QtMipsMachine::core() { @@ -105,7 +111,8 @@ void QtMipsMachine::restart() { pause(); regs->reset(); mem->reset(*mem_program_only); - // TODO cache + cch_program->reset(); + cch_data->reset(); cr->reset(); set_status(ST_READY); } -- cgit v1.2.3