From 68324683cde10c636a4a602644f3e64d24b0e412 Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 1 Apr 2025 20:36:31 -0400 Subject: Lots of fixes and tests --- src/sim/id.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/sim/id.cc') diff --git a/src/sim/id.cc b/src/sim/id.cc index ddac35b..805a4df 100644 --- a/src/sim/id.cc +++ b/src/sim/id.cc @@ -51,6 +51,9 @@ void ID::advance_helper() if (curr_instr->get_mnemonic() == NOP) this->status = OK; else { + std::cout << this->id << ": " << this->curr_instr->get_s1() << "," + << this->curr_instr->get_s2() << "," + << this->curr_instr->get_s3() << std::endl; s1 = curr_instr->get_instr_bits(); get_instr_fields(s1, s2, s3, m, t); if (this->status == OK) { @@ -60,6 +63,9 @@ void ID::advance_helper() curr_instr->set_mnemonic(m); curr_instr->set_type(t); } + std::cout << this->id << ": " << this->curr_instr->get_s1() << "," + << this->curr_instr->get_s2() << "," + << this->curr_instr->get_s3() << std::endl; } } @@ -76,7 +82,7 @@ void ID::get_instr_fields( break; case 0b01: t = I; - this->decode_I_type(s1, s2, s3); + this->decode_I_type(s1, s2, s3, m); break; case 0b10: t = J; @@ -107,9 +113,11 @@ void ID::decode_R_type(signed int &s1, signed int &s2, signed int &s3) this->status = (r1 == OK && r2 == OK) ? OK : STALLED; } -void ID::decode_I_type(signed int &s1, signed int &s2, signed int &s3) +void ID::decode_I_type( + signed int &s1, signed int &s2, signed int &s3, Mnemonic &m) { unsigned int s0b, s1b, s2b; + Response r1; s0b = REG_SIZE; s1b = s0b + REG_SIZE; @@ -118,8 +126,13 @@ void ID::decode_I_type(signed int &s1, signed int &s2, signed int &s3) s2 = GET_MID_BITS(s1, s0b, s1b); s1 = GET_LS_BITS(s1, s0b); - this->status = this->read_guard(s1); - this->write_guard(s2); + std::cout << m << ":" << s2 << std::endl; + r1 = this->read_guard(s1); + if (m != STORE && m != STOREV) { + this->status = r1; + this->write_guard(s2); + } else + this->status = (this->read_guard(s2) == OK && r1 == OK) ? OK : STALLED; } void ID::decode_J_type(signed int &s1, signed int &s2) -- cgit v1.2.3