From 796b2691146a3a4eaace4fa155d3c0c2f7379832 Mon Sep 17 00:00:00 2001 From: bd Date: Wed, 16 Apr 2025 23:35:59 -0400 Subject: Fix a bug related to parsing immediates in decode --- src/sim/id.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/sim/id.cc b/src/sim/id.cc index 46694ad..d4b56d2 100644 --- a/src/sim/id.cc +++ b/src/sim/id.cc @@ -116,8 +116,8 @@ void ID::decode_I_type( s0b = REG_SIZE; s1b = s0b + REG_SIZE; - s2b = WORD_SPEC; - s3 = GET_MID_BITS(s1, s1b, s2b); + s2b = WORD_SPEC - LINE_SPEC - OPCODE_SIZE; + s3 = GET_BITS_SIGN_EXTEND(s1, s1b, s2b); s2 = GET_MID_BITS(s1, s0b, s1b); s1 = GET_LS_BITS(s1, s0b); @@ -135,19 +135,20 @@ void ID::decode_J_type(signed int &s1, signed int &s2, signed int &s3) unsigned int s0b, s1b; s0b = REG_SIZE; - s1b = WORD_SPEC; + s1b = WORD_SPEC - LINE_SPEC - OPCODE_SIZE; s3 = 0; - s2 = GET_MID_BITS(s1, s0b, s1b); + s2 = GET_BITS_SIGN_EXTEND(s1, s0b, s1b); s1 = GET_LS_BITS(s1, s0b); + std::cout << "s1: " << s1 << ", s2: " << s2 << ", s3: " << s3 << std::endl; this->status = this->read_guard(*&s1); } -std::vector ID::stage_info() { +std::vector ID::stage_info() { std::vector info; if(this->curr_instr){ info.push_back(this->curr_instr->get_pc()); info.push_back(this->curr_instr->get_instr_bits()); - } + } return info; } -- cgit v1.2.3