The Sparta Modeling Framework
Loading...
Searching...
No Matches
MSS.cpp
1
3#include "MSS.hpp"
4
5namespace core_example
6{
7 const char MSS::name[] = "mss";
8
10 // Constructor
12
13 MSS::MSS(sparta::TreeNode *node, const MSSParameterSet *p) :
14 sparta::Unit(node),
15 mss_latency_(p->mss_latency)
16 {
17 in_mss_req_sync_.registerConsumerHandler
18 (CREATE_SPARTA_HANDLER_WITH_DATA(MSS, getReqFromBIU_, ExampleInstPtr));
19 in_mss_req_sync_.setPortDelay(static_cast<sparta::Clock::Cycle>(1));
20
21
22 if(SPARTA_EXPECT_FALSE(info_logger_.observed())) {
23 info_logger_ << "MSS construct: #" << node->getGroupIdx();
24 }
25 }
26
27
29 // Callbacks
31
32 // Receive new MSS request from BIU
33 void MSS::getReqFromBIU_(const ExampleInstPtr & inst_ptr)
34 {
35 sparta_assert((inst_ptr != nullptr), "MSS is not handling a valid request!");
36
37 // Handle MSS request event can only be scheduled when MMS is not busy
38 if (!mss_busy_) {
39 mss_busy_ = true;
40 ev_handle_mss_req_.schedule(mss_latency_);
41 }
42 else {
43 // Assumption: MSS can handle a single request each time
44 sparta_assert(false, "MSS can never receive requests from BIU when it's busy!");
45 }
46
47 if(SPARTA_EXPECT_FALSE(info_logger_.observed())) {
48 info_logger_ << "MSS is busy servicing your request......";
49 }
50 }
51
52 // Handle MSS request
53 void MSS::handle_MSS_req_()
54 {
55 mss_busy_ = false;
56 out_mss_ack_sync_.send(true);
57
58 if(SPARTA_EXPECT_FALSE(info_logger_.observed())) {
59 info_logger_ << "MSS is done!";
60 }
61 }
62
63
65 // Regular Function/Subroutine Call
67
68
69}
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
#define SPARTA_EXPECT_FALSE(x)
A macro for hinting to the compiler a particular condition should be considered most likely false.
#define CREATE_SPARTA_HANDLER_WITH_DATA(clname, meth, dataT)
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
group_idx_type getGroupIdx() const
Gets the group index of this node.
Macros for handling exponential backoff.