diff options
author | bd <bdunahu@operationnull.com> | 2025-03-30 14:28:45 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-30 14:28:45 -0400 |
commit | 8c46ba4f216aec9f512cd398317f891be9b07e84 (patch) | |
tree | cb502366f721c6bca60becc309fd9de288769d87 /src/sim/dum.cc | |
parent | 916949133a5797772dcd6966e469c12230ffc3fa (diff) |
Add mock stage, proper decode tests
Diffstat (limited to 'src/sim/dum.cc')
-rw-r--r-- | src/sim/dum.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/sim/dum.cc b/src/sim/dum.cc new file mode 100644 index 0000000..f14c89a --- /dev/null +++ b/src/sim/dum.cc @@ -0,0 +1,41 @@ +#include "dum.h" +#include "accessor.h" +#include "instrDTO.h" +#include "response.h" +#include "stage.h" +#include "utils.h" + +static Logger *global_log = Logger::getInstance(); + +DUM::DUM(Stage *stage) : Stage(stage) { this->id = IDLE; } + +InstrDTO *DUM::advance(Response p) +{ + InstrDTO *r = curr_instr; + + this->advance_helper(); + if (this->status == OK && p == OK) { + this->curr_instr->set_time_of(this->id, this->clock_cycle); + r = new InstrDTO(*this->curr_instr); + delete curr_instr; + curr_instr = nullptr; + } + + return r; +} + +void DUM::advance_helper() +{ + if (this->curr_instr) + global_log->log( + DEBUG, string_format( + "Using bits: %i ", this->curr_instr->get_instr_bits())); + else + global_log->log(DEBUG, "curr_instr is null"); +} + +void DUM::set_curr_instr(InstrDTO *d) +{ + this->curr_instr = d; + this->status = OK; +} |