diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-04-17 10:50:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-17 10:50:58 -0400 |
commit | 62b9e280d5d0222710e491dcd28fe26bea915dcd (patch) | |
tree | e1f68ac7a6e4dc481c19346e38ad20d113f13825 /src/sim/id.cc | |
parent | b778ccc3e7c2f2ac3c4892a87f5269f342fd895f (diff) | |
parent | 430986b4b1ee1013db070991ce289176f48fa8e8 (diff) |
Merge pull request #52 from bdunahu/bdunahu
[WIP] Partial fixes for changes in DRAM/Cache, including uncovered bug
Diffstat (limited to 'src/sim/id.cc')
-rw-r--r-- | src/sim/id.cc | 72 |
1 files changed, 51 insertions, 21 deletions
diff --git a/src/sim/id.cc b/src/sim/id.cc index 46694ad..37c6773 100644 --- a/src/sim/id.cc +++ b/src/sim/id.cc @@ -38,7 +38,13 @@ Response ID::read_guard(signed int &v) void ID::write_guard(signed int &v) { - this->checked_out.push_back(v); + // zero register shouldn't be written. + if (v != 0) { + // keep track in the instrDTO for displaying to user and writeback + // keep track in checked_out so we can still access this information! + this->checked_out.push_back(v); + this->curr_instr->set_checked_out(v); + } v = this->dereference_register(v); } @@ -72,7 +78,7 @@ void ID::get_instr_fields( switch (type) { case 0b00: t = R; - this->decode_R_type(s1, s2, s3); + this->decode_R_type(s1, s2, s3, m); break; case 0b01: t = I; @@ -88,7 +94,8 @@ void ID::get_instr_fields( } } -void ID::decode_R_type(signed int &s1, signed int &s2, signed int &s3) +void ID::decode_R_type( + signed int &s1, signed int &s2, signed int &s3, Mnemonic &m) { unsigned int s0b, s1b, s2b; Response r1, r2; @@ -104,30 +111,52 @@ void ID::decode_R_type(signed int &s1, signed int &s2, signed int &s3) r2 = this->read_guard(s2); this->status = (r1 == OK && r2 == OK) ? OK : STALLED; - if (this->status == OK) - this->write_guard(s3); + switch (m) { + case CMP: + case CEV: + break; + default: + if (this->status == OK) + this->write_guard(s3); + } } void ID::decode_I_type( signed int &s1, signed int &s2, signed int &s3, Mnemonic &m) { unsigned int s0b, s1b, s2b; - Response r1; + Response r1, r2; s0b = REG_SIZE; s1b = s0b + REG_SIZE; - s2b = WORD_SPEC; - s3 = GET_MID_BITS(s1, s1b, s2b); - s2 = GET_MID_BITS(s1, s0b, s1b); - s1 = GET_LS_BITS(s1, s0b); + s2b = WORD_SPEC - LINE_SPEC - OPCODE_SIZE; + s3 = GET_BITS_SIGN_EXTEND(s1, s1b, s2b); + + switch (m) { + case STORE: + case STOREV: + s2 = GET_MID_BITS(s1, s0b, s1b); + s1 = GET_LS_BITS(s1, s0b); + + // both operands are read values + r1 = this->read_guard(s1); + r2 = this->read_guard(s2); + this->status = (r1 == OK && r2 == OK) ? OK : STALLED; + return; + case LOAD: + case LOADV: + s2 = GET_LS_BITS(s1, s0b); + s1 = GET_MID_BITS(s1, s0b, s1b); + break; + default: + s2 = GET_MID_BITS(s1, s0b, s1b); + s1 = GET_LS_BITS(s1, s0b); + } r1 = this->read_guard(s1); - if (m != STORE && m != STOREV) { - this->status = r1; - if (r1 == OK) - this->write_guard(s2); - } else - this->status = (this->read_guard(s2) == OK && r1 == OK) ? OK : STALLED; + if (r1 == OK) + this->write_guard(s2); + this->status = r1; } void ID::decode_J_type(signed int &s1, signed int &s2, signed int &s3) @@ -135,19 +164,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); this->status = this->read_guard(*&s1); } -std::vector<int> ID::stage_info() { +std::vector<int> ID::stage_info() +{ std::vector<int> info; - if(this->curr_instr){ + if (this->curr_instr) { info.push_back(this->curr_instr->get_pc()); info.push_back(this->curr_instr->get_instr_bits()); - } + } return info; } |