From 5ae765b304be3f0f78ae7adcac7686422ca9c58e Mon Sep 17 00:00:00 2001 From: mariusmonton Date: Mon, 15 Oct 2018 17:32:37 +0200 Subject: [PATCH] Proper initialization of sp register --- inc/Registers.h | 10 ++++++++-- src/Registers.cpp | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/inc/Registers.h b/inc/Registers.h index 4467108..575f006 100644 --- a/inc/Registers.h +++ b/inc/Registers.h @@ -14,6 +14,7 @@ #include "tlm.h" #include "Performance.h" +#include "Memory.h" using namespace sc_core; using namespace sc_dt; @@ -126,8 +127,13 @@ public: /** * Increments PC couunter to next address */ - inline void incPC() { - register_PC += 4; + inline void incPC(bool C_ext=false) { + if (C_ext == true) { + register_PC += 2; + } else { + register_PC += 4; + } + } /** diff --git a/src/Registers.cpp b/src/Registers.cpp index 94391f5..f24618f 100644 --- a/src/Registers.cpp +++ b/src/Registers.cpp @@ -6,7 +6,8 @@ Registers::Registers() { memset(CSR, 0, sizeof(uint32_t)*4096); perf = Performance::getInstance(); - register_bank[sp] = 1024-1; // SP points to end of memory + //register_bank[sp] = 1024-1; // SP points to end of memory + register_bank[sp] = Memory::SIZE-1; register_PC = 0x10000; // default _start address }