From 95d09e12792cf5ececd32b8dc84f2cd090c496ef Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 22 Apr 2025 20:49:26 -0400 Subject: Remove the accessor object --- inc/id.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'inc/id.h') diff --git a/inc/id.h b/inc/id.h index d6c108a..a10ad49 100644 --- a/inc/id.h +++ b/inc/id.h @@ -25,12 +25,8 @@ class ID : public Stage { public: - /** - * Constructor. - * @param The next stage in the pipeline. - * @return A newly allocated ID object. - */ ID(Stage *next); + using Stage::Stage; using Stage::advance; /* The following methods are made public so that they may be tested, and are -- cgit v1.2.3 From 74b24d15eb1fe48a8e221a0bc061107d6b85d659 Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 22 Apr 2025 21:28:21 -0400 Subject: Add definition for size of vector register --- inc/id.h | 1 - inc/pipe_spec.h | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'inc/id.h') diff --git a/inc/id.h b/inc/id.h index a10ad49..dabf206 100644 --- a/inc/id.h +++ b/inc/id.h @@ -25,7 +25,6 @@ class ID : public Stage { public: - ID(Stage *next); using Stage::Stage; using Stage::advance; diff --git a/inc/pipe_spec.h b/inc/pipe_spec.h index 0433f23..7d65637 100644 --- a/inc/pipe_spec.h +++ b/inc/pipe_spec.h @@ -39,6 +39,11 @@ */ #define V_NUM 8 +/** + * The size, in 32-bit integers, of a vector register. + */ +#define V_R_LIMIT 8 + /** * The number of bits to specify an instruction type */ -- cgit v1.2.3 From 263a5d86e0b1acde39523bdd9a49521752255c72 Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 22 Apr 2025 23:55:32 -0400 Subject: Remove 'type' field out of InstrDTO --- inc/id.h | 2 +- inc/instr.h | 2 -- inc/instrDTO.h | 5 ----- src/id.cc | 10 ++-------- src/if.cc | 1 - src/wb.cc | 21 ++++++++++++--------- 6 files changed, 15 insertions(+), 26 deletions(-) (limited to 'inc/id.h') diff --git a/inc/id.h b/inc/id.h index dabf206..39485b6 100644 --- a/inc/id.h +++ b/inc/id.h @@ -78,7 +78,7 @@ class ID : public Stage * @param the resulting third field, which varies per type. * @param the resulting mnemonic. */ - void get_instr_fields(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m, Type &t); + void get_instr_fields(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m); void decode_R_type(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m); void decode_I_type(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m); void decode_J_type(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m); diff --git a/inc/instr.h b/inc/instr.h index 62af09a..85eae5b 100644 --- a/inc/instr.h +++ b/inc/instr.h @@ -62,8 +62,6 @@ enum Mnemonic { NOP, }; -enum Type { R, I, J, INV }; - namespace instr { // clang-format off diff --git a/inc/instrDTO.h b/inc/instrDTO.h index 7775b20..6ab14b2 100644 --- a/inc/instrDTO.h +++ b/inc/instrDTO.h @@ -48,11 +48,6 @@ struct InstrDTO { * The mnemonic of the instruction. */ Mnemonic mnemonic; - // TODO delete me - /** - * Type of the instruction - */ - Type type; /** * The register this instruction checks out. */ diff --git a/src/id.cc b/src/id.cc index 14fe595..0135c21 100644 --- a/src/id.cc +++ b/src/id.cc @@ -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; } } diff --git a/src/if.cc b/src/if.cc index fd795c7..62a105c 100644 --- a/src/if.cc +++ b/src/if.cc @@ -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; diff --git a/src/wb.cc b/src/wb.cc index 08d512b..cd24c6a 100644 --- a/src/wb.cc +++ b/src/wb.cc @@ -19,13 +19,12 @@ #include "instrDTO.h" #include "response.h" #include "stage.h" -#include #include +#include 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 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; } -- cgit v1.2.3 From a3528b83dd10fa9cdf7ef5635f615c1b295f3f4c Mon Sep 17 00:00:00 2001 From: bd Date: Fri, 25 Apr 2025 21:12:58 -0400 Subject: Pass full DTO to GUI --- gui/gui.cc | 59 +++++++++++++++++++++++++++++------------------------------ gui/gui.h | 10 +++++----- gui/worker.cc | 10 +++++----- gui/worker.h | 10 +++++----- inc/id.h | 2 -- inc/if.h | 2 -- inc/stage.h | 15 ++++++++------- src/id.cc | 10 ---------- src/if.cc | 9 --------- src/stage.cc | 13 +------------ 10 files changed, 53 insertions(+), 87 deletions(-) (limited to 'inc/id.h') diff --git a/gui/gui.cc b/gui/gui.cc index 496a443..bf9e6cf 100644 --- a/gui/gui.cc +++ b/gui/gui.cc @@ -169,36 +169,36 @@ void GUI::on_worker_refresh_gui(int cycles, int pc) ui->cycle_counter->set_value(cycles); } -void GUI::onWorkerFetchInfo(const std::vector info) +void GUI::onWorkerFetchInfo(const InstrDTO *i) { - if (!info.empty()) { - ui->fetch_squashed->setText(QString::number(info[0])); - ui->fetch_bits->set_value(info[1]); + if (i) { + ui->fetch_squashed->setText(QString::number(i->is_squashed)); + ui->fetch_bits->set_value(i->slot_A); } else { ui->fetch_squashed->clear(); ui->fetch_bits->clear(); } } -void GUI::onWorkerDecodeInfo(const std::vector info) +void GUI::onWorkerDecodeInfo(const InstrDTO *i) { - if (!info.empty()) { - ui->decode_squashed->setText(QString::number(info[0])); - ui->decode_bits->set_value(info[1]); + if (i) { + ui->decode_squashed->setText(QString::number(i->is_squashed)); + ui->decode_bits->set_value(i->slot_A); } else { ui->decode_squashed->clear(); ui->decode_bits->clear(); } } -void GUI::onWorkerExecuteInfo(const std::vector info) +void GUI::onWorkerExecuteInfo(const InstrDTO *i) { - if (!info.empty()) { - ui->execute_mnemonic->setText(mnemonicToString((Mnemonic)info[0])); - ui->execute_squashed->setText(QString::number(info[1])); - ui->execute_s1->set_value(info[2]); - ui->execute_s2->set_value(info[3]); - ui->execute_s3->set_value(info[4]); + if (i) { + ui->execute_mnemonic->setText(mnemonicToString(i->mnemonic)); + ui->execute_squashed->setText(QString::number(i->is_squashed)); + ui->execute_s1->set_value(i->operands.integer.slot_one); + ui->execute_s2->set_value(i->operands.integer.slot_two); + ui->execute_s3->set_value(i->operands.integer.slot_three); } else { ui->execute_mnemonic->clear(); ui->execute_squashed->clear(); @@ -208,15 +208,14 @@ void GUI::onWorkerExecuteInfo(const std::vector info) } } -void GUI::onWorkerMemoryInfo(const std::vector info) +void GUI::onWorkerMemoryInfo(const InstrDTO *i) { - if (!info.empty()) { - std::cout << "this " << info[3] << std::endl; - ui->memory_mnemonic->setText(mnemonicToString((Mnemonic)info[0])); - ui->memory_squashed->setText(QString::number(info[1])); - ui->memory_s1->set_value(info[2]); - ui->memory_s2->set_value(info[3]); - ui->memory_s3->set_value(info[4]); + if (i) { + ui->memory_mnemonic->setText(mnemonicToString(i->mnemonic)); + ui->memory_squashed->setText(QString::number(i->is_squashed)); + ui->memory_s1->set_value(i->operands.integer.slot_one); + ui->memory_s2->set_value(i->operands.integer.slot_two); + ui->memory_s3->set_value(i->operands.integer.slot_three); } else { ui->memory_mnemonic->clear(); ui->memory_squashed->clear(); @@ -226,14 +225,14 @@ void GUI::onWorkerMemoryInfo(const std::vector info) } } -void GUI::onWorkerWriteBackInfo(const std::vector info) +void GUI::onWorkerWriteBackInfo(const InstrDTO *i) { - if (!info.empty()) { - ui->write_mnemonic->setText(mnemonicToString((Mnemonic)info[0])); - ui->write_squashed->setText(QString::number(info[1])); - ui->write_s1->set_value(info[2]); - ui->write_s2->set_value(info[3]); - ui->write_s3->set_value(info[4]); + if (i) { + ui->write_mnemonic->setText(mnemonicToString(i->mnemonic)); + ui->write_squashed->setText(QString::number(i->is_squashed)); + ui->write_s1->set_value(i->operands.integer.slot_one); + ui->write_s2->set_value(i->operands.integer.slot_two); + ui->write_s3->set_value(i->operands.integer.slot_three); } else { ui->write_mnemonic->clear(); ui->write_squashed->clear(); diff --git a/gui/gui.h b/gui/gui.h index 7b03f75..b3a3110 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -57,15 +57,15 @@ class GUI : public QMainWindow private slots: void on_worker_refresh_gui(int value, int pc); - void onWorkerFetchInfo(const std::vector info); + void onWorkerFetchInfo(const InstrDTO *); - void onWorkerDecodeInfo(const std::vector info); + void onWorkerDecodeInfo(const InstrDTO *); - void onWorkerExecuteInfo(const std::vector info); + void onWorkerExecuteInfo(const InstrDTO *); - void onWorkerMemoryInfo(const std::vector info); + void onWorkerMemoryInfo(const InstrDTO *); - void onWorkerWriteBackInfo(const std::vector info); + void onWorkerWriteBackInfo(const InstrDTO *); void onWorkerShowStorage( const std::vector> data, int i); diff --git a/gui/worker.cc b/gui/worker.cc index 2652fce..203f907 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -89,10 +89,10 @@ void Worker::runSteps(int steps) emit storage(this->s.at(i - 1)->view(0, 1 << this->size_inc * i), i + 1); emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); - emit if_info(this->if_stage->stage_info()); - emit id_info(this->id_stage->stage_info()); - emit ex_info(this->ex_stage->stage_info()); - emit mm_info(this->mm_stage->stage_info()); - emit wb_info(this->wb_stage->stage_info()); + emit if_info(this->if_stage->get_instr()); + emit id_info(this->id_stage->get_instr()); + emit ex_info(this->ex_stage->get_instr()); + emit mm_info(this->mm_stage->get_instr()); + emit wb_info(this->wb_stage->get_instr()); this->ct_mutex.unlock(); } diff --git a/gui/worker.h b/gui/worker.h index 95c81d5..072263a 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -72,11 +72,11 @@ class Worker : public QObject void storage(const std::vector> data, int i); void register_storage(const std::array data); - void if_info(const std::vector info); - void id_info(const std::vector info); - void ex_info(const std::vector info); - void mm_info(const std::vector info); - void wb_info(const std::vector info); + void if_info(const InstrDTO *); + void id_info(const InstrDTO *); + void ex_info(const InstrDTO *); + void mm_info(const InstrDTO *); + void wb_info(const InstrDTO *); void finished(); }; diff --git a/inc/id.h b/inc/id.h index 39485b6..aafe2e5 100644 --- a/inc/id.h +++ b/inc/id.h @@ -50,8 +50,6 @@ class ID : public Stage */ void write_guard(signed int &r); - std::vector stage_info() override; - private: /** * Helper for `get_instr_fields` diff --git a/inc/if.h b/inc/if.h index c374145..f0eb6e2 100644 --- a/inc/if.h +++ b/inc/if.h @@ -28,8 +28,6 @@ class IF : public Stage InstrDTO *advance(Response p) override; - std::vector stage_info() override; - private: void advance_helper() override; }; diff --git a/inc/stage.h b/inc/stage.h index 7dcb7b4..16f1235 100644 --- a/inc/stage.h +++ b/inc/stage.h @@ -53,8 +53,14 @@ class Stage * Must set the status to READY when the current instruction is evicted.. */ virtual InstrDTO *advance(Response p); - - virtual std::vector stage_info(); + /** + * @return the current instruction. + */ + InstrDTO *get_instr(); + /** + * Squashes the pipeline. + */ + void squash(); /* The following methods are made public so that they may be tested, and are * not to be called from outside classes during standard execution. @@ -72,11 +78,6 @@ class Stage */ void set_condition(CC c, bool v); - /** - * Squashes the pipeline. - */ - void squash(); - /** * The set of registers currently checked out. */ diff --git a/src/id.cc b/src/id.cc index d8368c8..d2a8f02 100644 --- a/src/id.cc +++ b/src/id.cc @@ -211,13 +211,3 @@ void ID::decode_J_type( } } - -std::vector ID::stage_info() -{ - std::vector info; - if (this->curr_instr) { - info.push_back(this->curr_instr->is_squashed); - info.push_back(this->curr_instr->slot_A); - } - return info; -} diff --git a/src/if.cc b/src/if.cc index 5f07ee2..0f622d4 100644 --- a/src/if.cc +++ b/src/if.cc @@ -37,15 +37,6 @@ InstrDTO *IF::advance(Response p) return r; } -std::vector IF::stage_info() { - std::vector info; - if(this->curr_instr){ - info.push_back(this->curr_instr->is_squashed); - info.push_back(this->curr_instr->slot_A); - } - return info; -} - void IF::advance_helper() { Response r; diff --git a/src/stage.cc b/src/stage.cc index 55756b6..4efe2fe 100644 --- a/src/stage.cc +++ b/src/stage.cc @@ -65,18 +65,7 @@ InstrDTO *Stage::advance(Response p) return r; } -std::vector Stage::stage_info() -{ - std::vector info; - if (this->curr_instr) { - info.push_back(this->curr_instr->mnemonic); - info.push_back(this->curr_instr->is_squashed); - info.push_back(this->curr_instr->operands.integer.slot_one); - info.push_back(this->curr_instr->operands.integer.slot_two); - info.push_back(this->curr_instr->operands.integer.slot_three); - } - return info; -} +InstrDTO *Stage::get_instr() { return this->curr_instr; } void Stage::set_condition(CC c, bool v) { -- cgit v1.2.3