diff options
Diffstat (limited to 'src/sim/if.cc')
-rw-r--r-- | src/sim/if.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sim/if.cc b/src/sim/if.cc index 7d3291b..43132ed 100644 --- a/src/sim/if.cc +++ b/src/sim/if.cc @@ -6,17 +6,21 @@ IF::IF(Stage *stage) : Stage(stage) { this->id = FETCH; } -Response IF::advance(InstrDTO &next_instr, Response p) +InstrDTO *IF::advance(Response p) { + InstrDTO *r = nullptr; + this->advance_helper(); if (this->status == OK && p == OK) { // mutual consent ++this->pc; this->curr_instr->set_time_of(this->id, this->clock_cycle); - next_instr = *this->curr_instr; + r = new InstrDTO(*this->curr_instr); + delete curr_instr; curr_instr = nullptr; } - return this->status; + + return r; } void IF::advance_helper() @@ -28,7 +32,7 @@ void IF::advance_helper() r = this->storage->read_word(this->id, this->pc, bits); if (r == OK) { this->status = r; - this->curr_instr = std::make_unique<InstrDTO>(); + this->curr_instr = new InstrDTO(); this->curr_instr->set_instr_bits(bits); } else this->status = STALLED; |