From f40dc8910c3cc4f492d97e798a6e81b0e9eeecb0 Mon Sep 17 00:00:00 2001 From: Knute Lingaard Date: Fri, 27 Oct 2023 17:20:59 -0500 Subject: [PATCH] MSS file formats back to origin/master --- mss/BIU.cpp | 31 +++++++++++++++---------------- mss/BIU.hpp | 43 ++++++++++++++++++++++++++++--------------- mss/MSS.cpp | 17 +++++++++-------- mss/MSS.hpp | 33 ++++++++++++++++++++++----------- 4 files changed, 74 insertions(+), 50 deletions(-) diff --git a/mss/BIU.cpp b/mss/BIU.cpp index 7ad33e25..7d0f1773 100644 --- a/mss/BIU.cpp +++ b/mss/BIU.cpp @@ -13,21 +13,23 @@ namespace olympia_mss // Constructor //////////////////////////////////////////////////////////////////////////////// - BIU::BIU(sparta::TreeNode* node, const BIUParameterSet* p) : + BIU::BIU(sparta::TreeNode *node, const BIUParameterSet *p) : sparta::Unit(node), biu_req_queue_size_(p->biu_req_queue_size), biu_latency_(p->biu_latency) { - in_biu_req_.registerConsumerHandler( - CREATE_SPARTA_HANDLER_WITH_DATA(BIU, getReqFromLSU_, olympia::InstPtr)); + in_biu_req_.registerConsumerHandler + (CREATE_SPARTA_HANDLER_WITH_DATA(BIU, getReqFromLSU_, olympia::InstPtr)); - in_mss_ack_sync_.registerConsumerHandler( - CREATE_SPARTA_HANDLER_WITH_DATA(BIU, getAckFromMSS_, bool)); + in_mss_ack_sync_.registerConsumerHandler + (CREATE_SPARTA_HANDLER_WITH_DATA(BIU, getAckFromMSS_, bool)); in_mss_ack_sync_.setPortDelay(static_cast(1)); + ILOG("BIU construct: #" << node->getGroupIdx()); } + //////////////////////////////////////////////////////////////////////////////// // Callbacks //////////////////////////////////////////////////////////////////////////////// @@ -39,8 +41,7 @@ namespace olympia_mss // Schedule BIU request handling event only when: // (1)BIU is not busy, and (2)Request queue is not empty - if (!biu_busy_) - { + if (!biu_busy_) { // NOTE: // We could set this flag immediately here, but a better/cleaner way to do this is: // (1)Schedule the handling event immediately; @@ -51,8 +52,7 @@ namespace olympia_mss // The handling event must be scheduled immediately (0 delay). Otherwise, // BIU could potentially send another request to MSS before the busy flag is set } - else - { + else { ILOG("This request cannot be serviced right now, MSS is already busy!"); } } @@ -75,8 +75,7 @@ namespace olympia_mss // Schedule BIU request handling event only when: // (1)BIU is not busy, and (2)Request queue is not empty - if (biu_req_queue_.size() > 0) - { + if (biu_req_queue_.size() > 0) { ev_handle_biu_req_.schedule(sparta::Clock::Cycle(0)); } @@ -86,8 +85,7 @@ namespace olympia_mss // Receive MSS access acknowledge void BIU::getAckFromMSS_(const bool & done) { - if (done) - { + if (done) { ev_handle_mss_ack_.schedule(sparta::Clock::Cycle(0)); ILOG("MSS Ack is received!"); @@ -99,14 +97,15 @@ namespace olympia_mss sparta_assert(false, "MSS is NOT done!"); } + //////////////////////////////////////////////////////////////////////////////// // Regular Function/Subroutine Call //////////////////////////////////////////////////////////////////////////////// // Append BIU request queue - void BIU::appendReqQueue_(const olympia::InstPtr & inst_ptr) + void BIU::appendReqQueue_(const olympia::InstPtr& inst_ptr) { - sparta_assert(biu_req_queue_.size() <= biu_req_queue_size_, "BIU request queue overflows!"); + sparta_assert(biu_req_queue_.size() <= biu_req_queue_size_ ,"BIU request queue overflows!"); // Push new requests from back biu_req_queue_.emplace_back(inst_ptr); @@ -114,4 +113,4 @@ namespace olympia_mss ILOG("Append BIU request queue!"); } -} // namespace olympia_mss +} diff --git a/mss/BIU.hpp b/mss/BIU.hpp index 7445d9ab..5798907e 100644 --- a/mss/BIU.hpp +++ b/mss/BIU.hpp @@ -24,13 +24,15 @@ namespace olympia_mss { class BIU : public sparta::Unit { - public: + public: //! Parameters for BIU model class BIUParameterSet : public sparta::ParameterSet { - public: + public: // Constructor for BIUParameterSet - BIUParameterSet(sparta::TreeNode* n) : sparta::ParameterSet(n) {} + BIUParameterSet(sparta::TreeNode* n): + sparta::ParameterSet(n) + { } PARAMETER(uint32_t, biu_req_queue_size, 4, "BIU request queue size") PARAMETER(uint32_t, biu_latency, 1, "Send bus request latency") @@ -43,28 +45,34 @@ namespace olympia_mss // name of this resource. static const char name[]; + //////////////////////////////////////////////////////////////////////////////// // Type Name/Alias Declaration //////////////////////////////////////////////////////////////////////////////// - private: + + private: //////////////////////////////////////////////////////////////////////////////// // Input Ports //////////////////////////////////////////////////////////////////////////////// - sparta::DataInPort in_biu_req_{&unit_port_set_, - "in_biu_req", 1}; + sparta::DataInPort in_biu_req_ + {&unit_port_set_, "in_biu_req", 1}; + + sparta::SyncInPort in_mss_ack_sync_ + {&unit_port_set_, "in_mss_ack_sync", getClock()}; - sparta::SyncInPort in_mss_ack_sync_{&unit_port_set_, "in_mss_ack_sync", getClock()}; //////////////////////////////////////////////////////////////////////////////// // Output Ports //////////////////////////////////////////////////////////////////////////////// - sparta::DataOutPort out_biu_ack_{&unit_port_set_, "out_biu_ack"}; + sparta::DataOutPort out_biu_ack_ + {&unit_port_set_, "out_biu_ack"}; + + sparta::SyncOutPort out_mss_req_sync_ + {&unit_port_set_, "out_mss_req_sync", getClock()}; - sparta::SyncOutPort out_mss_req_sync_{&unit_port_set_, "out_mss_req_sync", - getClock()}; //////////////////////////////////////////////////////////////////////////////// // Internal States @@ -78,17 +86,19 @@ namespace olympia_mss bool biu_busy_ = false; + //////////////////////////////////////////////////////////////////////////////// // Event Handlers //////////////////////////////////////////////////////////////////////////////// // Event to handle BIU request from LSU - sparta::UniqueEvent<> ev_handle_biu_req_{&unit_event_set_, "handle_biu_req", - CREATE_SPARTA_HANDLER(BIU, handle_BIU_Req_)}; + sparta::UniqueEvent<> ev_handle_biu_req_ + {&unit_event_set_, "handle_biu_req", CREATE_SPARTA_HANDLER(BIU, handle_BIU_Req_)}; // Event to handle MSS Ack - sparta::UniqueEvent<> ev_handle_mss_ack_{&unit_event_set_, "handle_mss_ack", - CREATE_SPARTA_HANDLER(BIU, handle_MSS_Ack_)}; + sparta::UniqueEvent<> ev_handle_mss_ack_ + {&unit_event_set_, "handle_mss_ack", CREATE_SPARTA_HANDLER(BIU, handle_MSS_Ack_)}; + //////////////////////////////////////////////////////////////////////////////// // Callbacks @@ -107,11 +117,14 @@ namespace olympia_mss // Q: Does the argument list has to be "const DataType &" ? void getAckFromMSS_(const bool &); + //////////////////////////////////////////////////////////////////////////////// // Regular Function/Subroutine Call //////////////////////////////////////////////////////////////////////////////// // Append BIU request queue void appendReqQueue_(const olympia::InstPtr &); + + }; -} // namespace olympia_mss +} diff --git a/mss/MSS.cpp b/mss/MSS.cpp index f1eb6a5b..9f21876b 100644 --- a/mss/MSS.cpp +++ b/mss/MSS.cpp @@ -12,17 +12,18 @@ namespace olympia_mss // Constructor //////////////////////////////////////////////////////////////////////////////// - MSS::MSS(sparta::TreeNode* node, const MSSParameterSet* p) : + MSS::MSS(sparta::TreeNode *node, const MSSParameterSet *p) : sparta::Unit(node), mss_latency_(p->mss_latency) { - in_mss_req_sync_.registerConsumerHandler( - CREATE_SPARTA_HANDLER_WITH_DATA(MSS, getReqFromBIU_, olympia::InstPtr)); + in_mss_req_sync_.registerConsumerHandler + (CREATE_SPARTA_HANDLER_WITH_DATA(MSS, getReqFromBIU_, olympia::InstPtr)); in_mss_req_sync_.setPortDelay(static_cast(1)); ILOG("MSS construct: #" << node->getGroupIdx()); } + //////////////////////////////////////////////////////////////////////////////// // Callbacks //////////////////////////////////////////////////////////////////////////////// @@ -33,13 +34,11 @@ namespace olympia_mss sparta_assert((inst_ptr != nullptr), "MSS is not handling a valid request!"); // Handle MSS request event can only be scheduled when MMS is not busy - if (!mss_busy_) - { + if (!mss_busy_) { mss_busy_ = true; ev_handle_mss_req_.schedule(mss_latency_); } - else - { + else { // Assumption: MSS can handle a single request each time sparta_assert(false, "MSS can never receive requests from BIU when it's busy!"); } @@ -56,8 +55,10 @@ namespace olympia_mss ILOG("MSS is done!"); } + //////////////////////////////////////////////////////////////////////////////// // Regular Function/Subroutine Call //////////////////////////////////////////////////////////////////////////////// -} // namespace olympia_mss + +} diff --git a/mss/MSS.hpp b/mss/MSS.hpp index 1e7180ba..bdde3fac 100644 --- a/mss/MSS.hpp +++ b/mss/MSS.hpp @@ -22,13 +22,15 @@ namespace olympia_mss { class MSS : public sparta::Unit { - public: + public: //! Parameters for MSS model class MSSParameterSet : public sparta::ParameterSet { - public: + public: // Constructor for MSSParameterSet - MSSParameterSet(sparta::TreeNode* n) : sparta::ParameterSet(n) {} + MSSParameterSet(sparta::TreeNode* n): + sparta::ParameterSet(n) + { } PARAMETER(uint32_t, mss_latency, 5, "MSS access latency") }; @@ -40,24 +42,28 @@ namespace olympia_mss // name of this resource. static const char name[]; + //////////////////////////////////////////////////////////////////////////////// // Type Name/Alias Declaration //////////////////////////////////////////////////////////////////////////////// - private: + + private: //////////////////////////////////////////////////////////////////////////////// // Input Ports //////////////////////////////////////////////////////////////////////////////// - sparta::SyncInPort in_mss_req_sync_{&unit_port_set_, "in_mss_req_sync", - getClock()}; + sparta::SyncInPort in_mss_req_sync_ + {&unit_port_set_, "in_mss_req_sync", getClock()}; + //////////////////////////////////////////////////////////////////////////////// // Output Ports //////////////////////////////////////////////////////////////////////////////// - sparta::SyncOutPort out_mss_ack_sync_{&unit_port_set_, "out_mss_ack_sync", - getClock()}; + sparta::SyncOutPort out_mss_ack_sync_ + {&unit_port_set_, "out_mss_ack_sync", getClock()}; + //////////////////////////////////////////////////////////////////////////////// // Internal States @@ -65,13 +71,15 @@ namespace olympia_mss const uint32_t mss_latency_; bool mss_busy_ = false; + //////////////////////////////////////////////////////////////////////////////// // Event Handlers //////////////////////////////////////////////////////////////////////////////// // Event to handle MSS request from BIU - sparta::UniqueEvent<> ev_handle_mss_req_{&unit_event_set_, "handle_mss_req", - CREATE_SPARTA_HANDLER(MSS, handle_MSS_req_)}; + sparta::UniqueEvent<> ev_handle_mss_req_ + {&unit_event_set_, "handle_mss_req", CREATE_SPARTA_HANDLER(MSS, handle_MSS_req_)}; + //////////////////////////////////////////////////////////////////////////////// // Callbacks @@ -83,8 +91,11 @@ namespace olympia_mss // Handle MSS request void handle_MSS_req_(); + //////////////////////////////////////////////////////////////////////////////// // Regular Function/Subroutine Call //////////////////////////////////////////////////////////////////////////////// + + }; -} // namespace olympia_mss +}