summaryrefslogtreecommitdiff
path: root/src/sim/wb.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-17 01:17:48 -0400
committerbd <bdunahu@operationnull.com>2025-04-17 01:17:48 -0400
commit94a0435da91501d2320d6081c552cb5df0c4433d (patch)
tree13d2528bbe9cdbd391297ddd150414e576cdaa8e /src/sim/wb.cc
parent5e1d59feaa353e7ea4179fd0c8104fc4450a7a16 (diff)
Keep track of checked out in DTO to simplify wb cond logic (bug)
Diffstat (limited to 'src/sim/wb.cc')
-rw-r--r--src/sim/wb.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/sim/wb.cc b/src/sim/wb.cc
index 01768e8..3fa7dd3 100644
--- a/src/sim/wb.cc
+++ b/src/sim/wb.cc
@@ -3,6 +3,8 @@
#include "instrDTO.h"
#include "response.h"
#include "stage.h"
+#include <array>
+#include <algorithm>
WB::WB(Stage *stage) : Stage(stage) { this->id = WRITE; }
@@ -10,7 +12,7 @@ void WB::advance_helper()
{
if (this->curr_instr->get_mnemonic() != NOP &&
this->curr_instr->get_type() != INV) {
- if (this->should_write())
+ if (this->curr_instr->get_checked_out() > 0)
this->write_handler();
else if (this->should_jump())
this->jump_handler();
@@ -26,8 +28,9 @@ void WB::write_handler()
throw std::runtime_error("instruction tried to pop a register out of "
"an empty queue during writeback.");
- reg = this->checked_out.front();
this->checked_out.pop_front();
+ reg = this->curr_instr->get_checked_out();
+ std::cout << "checked in: " << reg << std::endl;
this->store_register(reg, this->curr_instr->get_s1());
}
@@ -49,13 +52,3 @@ bool WB::should_jump()
t = this->curr_instr->get_type();
return t == J;
}
-
-bool WB::should_write()
-{
- Mnemonic m;
- Type t;
-
- m = this->curr_instr->get_mnemonic();
- t = this->curr_instr->get_type();
- return (t == R || t == I) && (m != STORE && m != STOREV);
-}