Skip to content

Commit

Permalink
MSS file formats back to origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
klingaard committed Oct 27, 2023
1 parent 62849eb commit f40dc89
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 50 deletions.
31 changes: 15 additions & 16 deletions mss/BIU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sparta::Clock::Cycle>(1));


ILOG("BIU construct: #" << node->getGroupIdx());
}


////////////////////////////////////////////////////////////////////////////////
// Callbacks
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -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;
Expand All @@ -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!");
}
}
Expand All @@ -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));
}

Expand All @@ -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!");
Expand All @@ -99,19 +97,20 @@ 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);

ILOG("Append BIU request queue!");
}

} // namespace olympia_mss
}
43 changes: 28 additions & 15 deletions mss/BIU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<olympia::InstQueue::value_type> in_biu_req_{&unit_port_set_,
"in_biu_req", 1};
sparta::DataInPort<olympia::InstQueue::value_type> in_biu_req_
{&unit_port_set_, "in_biu_req", 1};

sparta::SyncInPort<bool> in_mss_ack_sync_
{&unit_port_set_, "in_mss_ack_sync", getClock()};

sparta::SyncInPort<bool> in_mss_ack_sync_{&unit_port_set_, "in_mss_ack_sync", getClock()};

////////////////////////////////////////////////////////////////////////////////
// Output Ports
////////////////////////////////////////////////////////////////////////////////

sparta::DataOutPort<olympia::InstPtr> out_biu_ack_{&unit_port_set_, "out_biu_ack"};
sparta::DataOutPort<olympia::InstPtr> out_biu_ack_
{&unit_port_set_, "out_biu_ack"};

sparta::SyncOutPort<olympia::InstPtr> out_mss_req_sync_
{&unit_port_set_, "out_mss_req_sync", getClock()};

sparta::SyncOutPort<olympia::InstPtr> out_mss_req_sync_{&unit_port_set_, "out_mss_req_sync",
getClock()};

////////////////////////////////////////////////////////////////////////////////
// Internal States
Expand All @@ -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
Expand All @@ -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
}
17 changes: 9 additions & 8 deletions mss/MSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sparta::Clock::Cycle>(1));

ILOG("MSS construct: #" << node->getGroupIdx());
}


////////////////////////////////////////////////////////////////////////////////
// Callbacks
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -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!");
}
Expand All @@ -56,8 +55,10 @@ namespace olympia_mss
ILOG("MSS is done!");
}


////////////////////////////////////////////////////////////////////////////////
// Regular Function/Subroutine Call
////////////////////////////////////////////////////////////////////////////////

} // namespace olympia_mss

}
33 changes: 22 additions & 11 deletions mss/MSS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
};
Expand All @@ -40,38 +42,44 @@ namespace olympia_mss
// name of this resource.
static const char name[];


////////////////////////////////////////////////////////////////////////////////
// Type Name/Alias Declaration
////////////////////////////////////////////////////////////////////////////////

private:

private:
////////////////////////////////////////////////////////////////////////////////
// Input Ports
////////////////////////////////////////////////////////////////////////////////

sparta::SyncInPort<olympia::InstPtr> in_mss_req_sync_{&unit_port_set_, "in_mss_req_sync",
getClock()};
sparta::SyncInPort<olympia::InstPtr> in_mss_req_sync_
{&unit_port_set_, "in_mss_req_sync", getClock()};


////////////////////////////////////////////////////////////////////////////////
// Output Ports
////////////////////////////////////////////////////////////////////////////////

sparta::SyncOutPort<bool> out_mss_ack_sync_{&unit_port_set_, "out_mss_ack_sync",
getClock()};
sparta::SyncOutPort<bool> out_mss_ack_sync_
{&unit_port_set_, "out_mss_ack_sync", getClock()};


////////////////////////////////////////////////////////////////////////////////
// Internal States
////////////////////////////////////////////////////////////////////////////////
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
Expand All @@ -83,8 +91,11 @@ namespace olympia_mss
// Handle MSS request
void handle_MSS_req_();


////////////////////////////////////////////////////////////////////////////////
// Regular Function/Subroutine Call
////////////////////////////////////////////////////////////////////////////////


};
} // namespace olympia_mss
}

0 comments on commit f40dc89

Please sign in to comment.