diff options
author | bd <bdunahu@operationnull.com> | 2025-04-22 20:49:26 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-22 20:49:26 -0400 |
commit | 95d09e12792cf5ececd32b8dc84f2cd090c496ef (patch) | |
tree | 8660a5fba2e60df5d34712383d727ad46809307d | |
parent | 1bbc5b157e16dae032b5e44a7dcf009766eb9ca5 (diff) |
Remove the accessor object
-rw-r--r-- | inc/accessor.h | 35 | ||||
-rw-r--r-- | inc/dum.h | 7 | ||||
-rw-r--r-- | inc/id.h | 6 | ||||
-rw-r--r-- | inc/if.h | 8 | ||||
-rw-r--r-- | inc/instrDTO.h | 1 | ||||
-rw-r--r-- | inc/mm.h | 7 | ||||
-rw-r--r-- | inc/stage.h | 5 | ||||
-rw-r--r-- | inc/wb.h | 7 | ||||
-rw-r--r-- | src/sim/controller.cc | 2 | ||||
-rw-r--r-- | src/sim/dum.cc | 8 | ||||
-rw-r--r-- | src/sim/ex.cc | 2 | ||||
-rw-r--r-- | src/sim/id.cc | 3 | ||||
-rw-r--r-- | src/sim/if.cc | 3 | ||||
-rw-r--r-- | src/sim/instrDTO.cc | 1 | ||||
-rw-r--r-- | src/sim/mm.cc | 3 | ||||
-rw-r--r-- | src/sim/stage.cc | 6 | ||||
-rw-r--r-- | src/sim/wb.cc | 3 | ||||
-rw-r--r-- | src/utils/accessor.cc | 27 |
18 files changed, 7 insertions, 127 deletions
diff --git a/inc/accessor.h b/inc/accessor.h deleted file mode 100644 index 67a68b9..0000000 --- a/inc/accessor.h +++ /dev/null @@ -1,35 +0,0 @@ -// Simulator for the RISC-V[ECTOR] mini-ISA -// Copyright (C) 2025 Siddarth Suresh -// Copyright (C) 2025 bdunahu - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -#ifndef ACCESSOR_H -#define ACCESSOR_H -#include <iostream> - -enum Accessor { - IDLE, - WRITE, - MEM, - EXEC, - DCDE, - FETCH, - L1CACHE, - SIDE, -}; - -std::ostream &operator<<(std::ostream &os, Accessor a); - -#endif /* ACCESSOR_H_INCLUDED */ @@ -27,12 +27,7 @@ class DUM : public Stage { public: - /** - * Constructor. - * @param The next stage in the pipeline. - * @return A newly allocated DUM object. - */ - DUM(Stage *next); + using Stage::Stage; InstrDTO *advance(Response p) override; @@ -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 @@ -17,7 +17,6 @@ #ifndef IF_H #define IF_H -#include "accessor.h" #include "instrDTO.h" #include "response.h" #include "stage.h" @@ -25,12 +24,7 @@ class IF : public Stage { public: - /** - * Constructor. - * @param The next stage in the pipeline. - * @return A newly allocated IF object. - */ - IF(Stage *next); + using Stage::Stage; InstrDTO *advance(Response p) override; diff --git a/inc/instrDTO.h b/inc/instrDTO.h index d4af389..e6c9852 100644 --- a/inc/instrDTO.h +++ b/inc/instrDTO.h @@ -17,7 +17,6 @@ #ifndef INSTRDTO_H #define INSTRDTO_H -#include "accessor.h" #include "instr.h" #include <functional> #include <string> @@ -24,12 +24,7 @@ class MM : public Stage { public: - /** - * Constructor. - * @param The next stage in the pipeline. - * @return A newly allocated MM object. - */ - MM(Stage *next); + using Stage::Stage; using Stage::advance; private: diff --git a/inc/stage.h b/inc/stage.h index 448c61a..745e0ff 100644 --- a/inc/stage.h +++ b/inc/stage.h @@ -17,7 +17,6 @@ #ifndef STAGE_H #define STAGE_H -#include "accessor.h" #include "instrDTO.h" #include "pipe_spec.h" #include "response.h" @@ -112,10 +111,6 @@ class Stage */ signed int dereference_register(signed int v); /** - * The name of the pipeline stage. - */ - Accessor id; - /** * The shared pool of general-purpose integer registers. */ static std::array<signed int, GPR_NUM> gprs; @@ -24,12 +24,7 @@ class WB : public Stage { public: - /** - * Constructor. - * @param The next stage in the pipeline. - * @return A newly allocated WB object. - */ - WB(Stage *next); + using Stage::Stage; using Stage::advance; private: diff --git a/src/sim/controller.cc b/src/sim/controller.cc index 59fbbb7..1c379ec 100644 --- a/src/sim/controller.cc +++ b/src/sim/controller.cc @@ -31,8 +31,6 @@ Controller::Controller(Stage *stage, Storage *storage, bool is_pipelined) this->checked_out = {}; this->gprs = {0}; this->gprs.at(2) = MEM_WORDS; // set the stack pointer - // grant side-door access - this->id = SIDE; } void Controller::run_for(int number) diff --git a/src/sim/dum.cc b/src/sim/dum.cc index 744c110..fd3b7a6 100644 --- a/src/sim/dum.cc +++ b/src/sim/dum.cc @@ -16,13 +16,10 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "dum.h" -#include "accessor.h" #include "instrDTO.h" #include "response.h" #include "stage.h" -DUM::DUM(Stage *stage) : Stage(stage) { this->id = IDLE; } - InstrDTO *DUM::advance(Response p) { InstrDTO *r = nullptr; @@ -38,7 +35,4 @@ InstrDTO *DUM::advance(Response p) void DUM::advance_helper() {} -void DUM::set_curr_instr(InstrDTO *d) -{ - this->curr_instr = d; -} +void DUM::set_curr_instr(InstrDTO *d) { this->curr_instr = d; } diff --git a/src/sim/ex.cc b/src/sim/ex.cc index d345ecf..117002c 100644 --- a/src/sim/ex.cc +++ b/src/sim/ex.cc @@ -16,7 +16,6 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "ex.h" -#include "accessor.h" #include "instrDTO.h" #include "pipe_spec.h" #include "response.h" @@ -32,7 +31,6 @@ EX::EX(Stage *stage) : Stage(stage) { - this->id = EXEC; instr_map = { /* R type instructions */ diff --git a/src/sim/id.cc b/src/sim/id.cc index cdbaba9..b2bc0e5 100644 --- a/src/sim/id.cc +++ b/src/sim/id.cc @@ -16,14 +16,13 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "id.h" -#include "accessor.h" #include "instr.h" #include "instrDTO.h" #include "logger.h" #include "response.h" #include "stage.h" -ID::ID(Stage *stage) : Stage(stage) { this->id = DCDE; } +ID::ID(Stage *stage) : Stage(stage) { } void ID::split_instr(signed int &raw, unsigned int &type, Mnemonic &m) { diff --git a/src/sim/if.cc b/src/sim/if.cc index e8e7272..054c77c 100644 --- a/src/sim/if.cc +++ b/src/sim/if.cc @@ -16,13 +16,10 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "if.h" -#include "accessor.h" #include "instrDTO.h" #include "response.h" #include "stage.h" -IF::IF(Stage *stage) : Stage(stage) { this->id = FETCH; } - InstrDTO *IF::advance(Response p) { InstrDTO *r = nullptr; diff --git a/src/sim/instrDTO.cc b/src/sim/instrDTO.cc index 00b6d5f..cb093bb 100644 --- a/src/sim/instrDTO.cc +++ b/src/sim/instrDTO.cc @@ -16,7 +16,6 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "instrDTO.h" -#include "accessor.h" InstrDTO::InstrDTO() { diff --git a/src/sim/mm.cc b/src/sim/mm.cc index e1057d5..3df1578 100644 --- a/src/sim/mm.cc +++ b/src/sim/mm.cc @@ -16,13 +16,10 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "mm.h" -#include "accessor.h" #include "instrDTO.h" #include "response.h" #include "stage.h" -MM::MM(Stage *stage) : Stage(stage) { this->id = MEM; } - void MM::advance_helper() { signed int data; diff --git a/src/sim/stage.cc b/src/sim/stage.cc index 35c6936..b7be595 100644 --- a/src/sim/stage.cc +++ b/src/sim/stage.cc @@ -45,12 +45,6 @@ InstrDTO *Stage::advance(Response p) InstrDTO *s = nullptr; Response n; - // std::cout << "advance: " << this->id << ": " << this->curr_instr << "?: " - // << p << ": " << this->checked_out.size() << ": "; if (curr_instr) - // std::cout << curr_instr->get_mnemonic(); - // for (long unsigned int i = 0; i < this->checked_out.size(); ++i) - // std::cout << this->checked_out[i] << " "; - // std::cout << std::endl; if (this->curr_instr && this->curr_instr->is_squashed() == 1) this->status = OK; if (this->curr_instr && this->status != OK) { diff --git a/src/sim/wb.cc b/src/sim/wb.cc index 0348b51..55591b6 100644 --- a/src/sim/wb.cc +++ b/src/sim/wb.cc @@ -16,15 +16,12 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. #include "wb.h" -#include "accessor.h" #include "instrDTO.h" #include "response.h" #include "stage.h" #include <array> #include <algorithm> -WB::WB(Stage *stage) : Stage(stage) { this->id = WRITE; } - void WB::advance_helper() { if (this->curr_instr->get_mnemonic() != NOP && diff --git a/src/utils/accessor.cc b/src/utils/accessor.cc deleted file mode 100644 index c49a2b2..0000000 --- a/src/utils/accessor.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Simulator for the RISC-V[ECTOR] mini-ISA -// Copyright (C) 2025 Siddarth Suresh -// Copyright (C) 2025 bdunahu - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -#include "accessor.h" -#include <iostream> - -std::ostream &operator<<(std::ostream &os, Accessor a) -{ - const std::string nameA[] = { - "IDLE", "WRITE", "MEM", "EXEC", "DCDE", "FETCH", "L1CACHE", "SIDE", - }; - return os << nameA[a]; -} |