diff options
author | bd <bdunahu@operationnull.com> | 2025-04-22 23:55:32 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-22 23:55:32 -0400 |
commit | 263a5d86e0b1acde39523bdd9a49521752255c72 (patch) | |
tree | 9267d91cf1624a9fc092d5f2f5ddc05cc2716129 /src | |
parent | 302bbdc7ac18cd355f9f081cae202f5434427262 (diff) |
Remove 'type' field out of InstrDTO
Diffstat (limited to 'src')
-rw-r--r-- | src/id.cc | 10 | ||||
-rw-r--r-- | src/if.cc | 1 | ||||
-rw-r--r-- | src/wb.cc | 21 |
3 files changed, 14 insertions, 18 deletions
@@ -66,44 +66,38 @@ void ID::advance_helper() { signed int s1, s2, s3; Mnemonic m; - Type t; if (curr_instr->mnemonic == NOP) this->status = OK; else { s1 = curr_instr->slot_A; - get_instr_fields(s1, s2, s3, m, t); + get_instr_fields(s1, s2, s3, m); if (this->status == OK) { curr_instr->operands.integer.slot_one = s1; curr_instr->operands.integer.slot_two = s2; curr_instr->operands.integer.slot_three = s3; curr_instr->mnemonic = m; - curr_instr->type = t; } } } void ID::get_instr_fields( - signed int &s1, signed int &s2, signed int &s3, Mnemonic &m, Type &t) + signed int &s1, signed int &s2, signed int &s3, Mnemonic &m) { unsigned int type; this->split_instr(s1, type, m); switch (type) { case 0b00: - t = R; this->decode_R_type(s1, s2, s3, m); break; case 0b01: - t = I; this->decode_I_type(s1, s2, s3, m); break; case 0b10: - t = J; this->decode_J_type(s1, s2, s3, m); break; case 0b11: - t = INV; this->status = OK; } } @@ -59,7 +59,6 @@ void IF::advance_helper() this->curr_instr = new InstrDTO(); this->curr_instr->slot_A = bits; this->curr_instr->slot_B = this->pc; - this->curr_instr->type = INV; this->curr_instr->is_squashed = 0; this->curr_instr->checked_out = -1; this->curr_instr->mnemonic = ADD; @@ -19,13 +19,12 @@ #include "instrDTO.h" #include "response.h" #include "stage.h" -#include <array> #include <algorithm> +#include <array> void WB::advance_helper() { - if (this->curr_instr->mnemonic != NOP && - this->curr_instr->type != INV) { + if (this->curr_instr->mnemonic != NOP) { if (this->curr_instr->checked_out > 0) this->write_handler(); else if (this->should_jump()) @@ -46,30 +45,34 @@ void WB::write_handler() // POP performs a second register write reg = this->checked_out.front(); this->checked_out.pop_front(); - this->store_register(reg, this->curr_instr->operands.integer.slot_three); + this->store_register( + reg, this->curr_instr->operands.integer.slot_three); } this->checked_out.pop_front(); reg = this->curr_instr->checked_out; this->store_register(reg, this->curr_instr->operands.integer.slot_one); - } void WB::jump_handler() { if (this->curr_instr->operands.integer.slot_one > 0) { if (this->curr_instr->mnemonic == JAL) - this->gprs[1] = this->curr_instr->slot_B + 1;; + this->gprs[1] = this->curr_instr->slot_B + 1; + ; this->pc = this->curr_instr->operands.integer.slot_one; this->checked_out = {}; this->next->squash(); } } +// TODO clean this up... bool WB::should_jump() { - Type t; + vector<Mnemonic> Js = {JMP, JRL, JAL, BEQ, BGT, BUF, BOF, PUSH, POP, RET}; - t = this->curr_instr->type; - return t == J; + if (find(Js.begin(), Js.end(), this->curr_instr->mnemonic) != Js.end()) + return true; + else + return false; } |