From 6726b59c3c14bae33bbe4d0496cc256dcb79b7a7 Mon Sep 17 00:00:00 2001 From: mariusmonton Date: Thu, 22 Nov 2018 12:39:16 +0100 Subject: [PATCH] bug on SLLI --- inc/Instruction.h | 4 ++++ inc/Registers.h | 2 +- src/Execute.cpp | 5 +++-- src/Registers.cpp | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/inc/Instruction.h b/inc/Instruction.h index dab7342..4c646c5 100644 --- a/inc/Instruction.h +++ b/inc/Instruction.h @@ -360,6 +360,10 @@ public: m_instr.range(19,12) = aux.range(19,12); } + inline int32_t get_shamt() { + return m_instr.range(25, 20); + } + inline int32_t get_csr() { int32_t aux = 0; diff --git a/inc/Registers.h b/inc/Registers.h index 6368104..2d7a61f 100644 --- a/inc/Registers.h +++ b/inc/Registers.h @@ -19,7 +19,7 @@ #define WARL_M_EXTENSION (1 << 12) #define WARL_C_EXTENSION (1 << 2) #define WARL_I_BASE (1 << 8) -#define WARL_MXL (1 << 29) +#define WARL_MXL (1 << 30) #define CSR_MSTATUS (0x300) diff --git a/src/Execute.cpp b/src/Execute.cpp index fe53e8a..9839a23 100644 --- a/src/Execute.cpp +++ b/src/Execute.cpp @@ -542,10 +542,11 @@ void Execute::SLLI(Instruction &inst) { rd = inst.get_rd(); rs1 = inst.get_rs1(); - rs2 = inst.get_rs2(); + rs2 = inst.get_shamt(); if (rs2 >= 0x20) { // raise an exception, but how? + cout << "ILEGAL INSTRUCTION, shamt[5] != 0" << endl; } shift = rs2 & 0x1F; @@ -555,7 +556,7 @@ void Execute::SLLI(Instruction &inst) { log->SC_log(Log::INFO) << "SLLI: x" << rs1 << " << " << shift << " -> x" - << rd << endl; + << rd << "(0x" << hex << calc << ")" << endl; } void Execute::SRLI(Instruction &inst) { diff --git a/src/Registers.cpp b/src/Registers.cpp index 9a17355..a8930fc 100644 --- a/src/Registers.cpp +++ b/src/Registers.cpp @@ -94,6 +94,6 @@ void Registers::setCSR(int csr, uint32_t value) { } void Registers::initCSR() { - CSR[0x301] = WARL_MXL | WARL_M_EXTENSION | WARL_C_EXTENSION | WARL_I_BASE; + CSR[CSR_MISA] = WARL_MXL | WARL_M_EXTENSION | WARL_C_EXTENSION | WARL_I_BASE; }