Ruby: remove reference to g_system_ptr from class Message
authorNilay Vaish <nilay@cs.wisc.edu>
Mon, 14 Jan 2013 16:05:10 +0000 (10:05 -0600)
committerNilay Vaish <nilay@cs.wisc.edu>
Mon, 14 Jan 2013 16:05:10 +0000 (10:05 -0600)
This patch was initiated so as to remove reference to g_system_ptr,
the pointer to Ruby System that is used for getting the current time.
That simple change actual requires changing a lot many things in slicc and
garnet. All these changes are related to how time is handled.

In most of the places, g_system_ptr has been replaced by another clock
object. The changes have been done under the assumption that all the
components in the memory system are on the same clock frequency, but the
actual clocks might be distributed.

39 files changed:
src/mem/ruby/common/Global.hh
src/mem/ruby/network/garnet/BaseGarnetNetwork.cc
src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh
src/mem/ruby/network/garnet/fixed-pipeline/flit_d.cc
src/mem/ruby/network/garnet/fixed-pipeline/flit_d.hh
src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc
src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc
src/mem/ruby/network/garnet/flexible-pipeline/Router.cc
src/mem/ruby/network/garnet/flexible-pipeline/flit.cc
src/mem/ruby/network/garnet/flexible-pipeline/flit.hh
src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc
src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh
src/mem/ruby/network/orion/NetworkPower.cc
src/mem/ruby/slicc_interface/Message.hh
src/mem/ruby/slicc_interface/NetworkMessage.hh
src/mem/ruby/slicc_interface/RubyRequest.hh
src/mem/ruby/slicc_interface/RubySlicc_Util.hh
src/mem/ruby/structures/Prefetcher.hh
src/mem/ruby/system/DMASequencer.cc
src/mem/ruby/system/Sequencer.cc
src/mem/ruby/system/WireBuffer.cc
src/mem/slicc/ast/EnqueueStatementAST.py
src/mem/slicc/symbols/Type.py

index f76a1a26bf4a86deb3a4aadd8222f58f1f3a961a..d6597be89648027743bd824e566d650df8839e95 100644 (file)
 class RubySystem;
 extern RubySystem* g_system_ptr;
 
-// FIXME: this is required by the contructor of Directory_Entry.hh.
-// It can't go into slicc_util.hh because it opens a can of ugly worms
-extern inline int max_tokens()
-{
-  return 1024;
-}
-
 #endif // __MEM_RUBY_COMMON_GLOBAL_HH__
 
index 78b4b2d4246d78ae515db1f8e774479ba941b4ab..e3196a0e70a99a081b29195f1b6570f32c034c77 100644 (file)
@@ -127,7 +127,7 @@ BaseGarnetNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num,
 void
 BaseGarnetNetwork::clearStats()
 {
-    m_ruby_start = g_system_ptr->getTime();
+    m_ruby_start = curCycle();
 }
 
 Time
index c7ac85ad3fb23d13c20023cf15f9933c6b4b76ae..6404eb6ffc38ecb469d37e18144509677fa69799 100644 (file)
@@ -272,7 +272,7 @@ GarnetNetwork_d::printLinkStats(ostream& out) const
     for (int i = 0; i < m_link_ptr_vector.size(); i++) {
         average_link_utilization +=
             (double(m_link_ptr_vector[i]->getLinkUtilization())) /
-            (double(g_system_ptr->getTime()-m_ruby_start));
+            (double(curCycle() - m_ruby_start));
 
         vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
         for (int j = 0; j < vc_load.size(); j++) {
@@ -290,8 +290,8 @@ GarnetNetwork_d::printLinkStats(ostream& out) const
         if (!m_in_use[i/m_vcs_per_vnet])
             continue;
 
-        average_vc_load[i] = (double(average_vc_load[i]) /
-            (double(g_system_ptr->getTime()) - m_ruby_start));
+        average_vc_load[i] = (double(average_vc_load[i])) /
+            (double(curCycle() - m_ruby_start));
         out << "Average VC Load [" << i << "] = " << average_vc_load[i]
             << " flits/cycle " << endl;
     }
index 62b8cd574ee4701768beca3b3f0e80f94e5dee68..2671d781f8dfd74acdef383d700bd936c9251951 100644 (file)
@@ -53,7 +53,7 @@ InputUnit_d::InputUnit_d(int id, Router_d *router) : Consumer(router)
     // Instantiating the virtual channels
     m_vcs.resize(m_num_vcs);
     for (int i=0; i < m_num_vcs; i++) {
-        m_vcs[i] = new VirtualChannel_d(i);
+        m_vcs[i] = new VirtualChannel_d(i, m_router->curCycle());
     }
 }
 
@@ -67,7 +67,7 @@ void
 InputUnit_d::wakeup()
 {
     flit_d *t_flit;
-    if (m_in_link->isReady()) {
+    if (m_in_link->isReady(m_router->curCycle())) {
 
         t_flit = m_in_link->consumeLink();
         int vc = t_flit->get_vc();
@@ -79,9 +79,9 @@ InputUnit_d::wakeup()
             // Do the route computation for this vc
             m_router->route_req(t_flit, this, vc);
 
-            m_vcs[vc]->set_enqueue_time(g_system_ptr->getTime());
+            m_vcs[vc]->set_enqueue_time(m_router->curCycle());
         } else {
-            t_flit->advance_stage(SA_);
+            t_flit->advance_stage(SA_, m_router->curCycle());
             m_router->swarb_req();
         }
         // write flit into input buffer
index 544c4271bc9a2c4cde1c54a0bcff8f8512ede676..3ebf7c6e9133b1d2269f99e796711dc2bc3ae85c 100644 (file)
@@ -56,9 +56,9 @@ class InputUnit_d : public Consumer
     inline int get_inlink_id() { return m_in_link->get_id(); }
 
     inline void
-    set_vc_state(VC_state_type state, int vc)
+    set_vc_state(VC_state_type state, int vc, Time curTime)
     {
-        m_vcs[vc]->set_state(state);
+        m_vcs[vc]->set_state(state, curTime);
     }
 
     inline void
@@ -86,9 +86,9 @@ class InputUnit_d : public Consumer
     }
 
     inline void
-    increment_credit(int in_vc, bool free_signal)
+    increment_credit(int in_vc, bool free_signal, Time curTime)
     {
-        flit_d *t_flit = new flit_d(in_vc, free_signal);
+        flit_d *t_flit = new flit_d(in_vc, free_signal, curTime);
         creditQueue->insert(t_flit);
         m_credit_link->scheduleEvent(1);
     }
@@ -100,16 +100,16 @@ class InputUnit_d : public Consumer
     }
 
     inline void
-    updateRoute(int vc, int outport)
+    updateRoute(int vc, int outport, Time curTime)
     {
         m_vcs[vc]->set_outport(outport);
-        m_vcs[vc]->set_state(VC_AB_);
+        m_vcs[vc]->set_state(VC_AB_, curTime);
     }
 
     inline void
-    grant_vc(int in_vc, int out_vc)
+    grant_vc(int in_vc, int out_vc, Time curTime)
     {
-        m_vcs[in_vc]->grant_vc(out_vc);
+        m_vcs[in_vc]->grant_vc(out_vc, curTime);
     }
 
     inline flit_d*
@@ -125,21 +125,22 @@ class InputUnit_d : public Consumer
     }
 
     inline bool
-    need_stage(int vc, VC_state_type state, flit_stage stage)
+    need_stage(int vc, VC_state_type state, flit_stage stage, Time curTime)
     {
-        return m_vcs[vc]->need_stage(state, stage);
+        return m_vcs[vc]->need_stage(state, stage, curTime);
     }
 
     inline bool
-    need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage)
+    need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage,
+                         Time curTime)
     {
-        return m_vcs[vc]->need_stage_nextcycle(state, stage);
+        return m_vcs[vc]->need_stage_nextcycle(state, stage, curTime);
     }
 
     inline bool
-    isReady(int invc)
+    isReady(int invc, Time curTime)
     {
-        return m_vcs[invc]->isReady();
+        return m_vcs[invc]->isReady(curTime);
     }
 
     inline int
index 62bee1850b9a2a2320009e1926fb7740bf542502..f0e117aadd93d3a56763e5927844ef0032b712dc 100644 (file)
@@ -71,7 +71,7 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks,
 
     for (int i = 0; i < m_num_vcs; i++) {
         m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr));
-        m_out_vc_state[i]->setState(IDLE_, g_system_ptr->getTime());
+        m_out_vc_state[i]->setState(IDLE_, m_net_ptr->curCycle());
     }
 }
 
@@ -170,12 +170,15 @@ NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet)
 
         for (int i = 0; i < num_flits; i++) {
             m_net_ptr->increment_injected_flits(vnet);
-            flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr);
-            fl->set_delay(g_system_ptr->getTime() - msg_ptr->getTime());
+            flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr,
+                m_net_ptr->curCycle());
+
+            fl->set_delay(m_net_ptr->curCycle() - msg_ptr->getTime());
             m_ni_buffers[vc]->insert(fl);
         }
-        m_ni_enqueue_time[vc] = g_system_ptr->getTime();
-        m_out_vc_state[vc]->setState(ACTIVE_, g_system_ptr->getTime());
+
+        m_ni_enqueue_time[vc] = m_net_ptr->curCycle();
+        m_out_vc_state[vc]->setState(ACTIVE_, m_net_ptr->curCycle());
     }
     return true ;
 }
@@ -191,7 +194,7 @@ NetworkInterface_d::calculateVC(int vnet)
                         m_vc_allocator[vnet] = 0;
 
                 if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(
-                    IDLE_, g_system_ptr->getTime())) {
+                    IDLE_, m_net_ptr->curCycle())) {
                         return ((vnet*m_vc_per_vnet) + delta);
                 }
         }
@@ -212,7 +215,7 @@ void
 NetworkInterface_d::wakeup()
 {
     DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld",
-            m_id, g_system_ptr->getTime());
+            m_id, m_net_ptr->curCycle());
 
     MsgPtr msg_ptr;
 
@@ -234,7 +237,7 @@ NetworkInterface_d::wakeup()
 
     /*********** Picking messages destined for this NI **********/
 
-    if (inNetLink->isReady()) {
+    if (inNetLink->isReady(m_net_ptr->curCycle())) {
         flit_d *t_flit = inNetLink->consumeLink();
         bool free_signal = false;
         if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
@@ -245,13 +248,14 @@ NetworkInterface_d::wakeup()
         }
         // Simply send a credit back since we are not buffering
         // this flit in the NI
-        flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal);
+        flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal,
+                                         m_net_ptr->curCycle());
         creditQueue->insert(credit_flit);
         m_ni_credit_link->scheduleEvent(1);
 
         int vnet = t_flit->get_vnet();
         m_net_ptr->increment_received_flits(vnet);
-        int network_delay = g_system_ptr->getTime() -
+        int network_delay = m_net_ptr->curCycle() -
                             t_flit->get_enqueue_time();
         int queueing_delay = t_flit->get_delay();
         m_net_ptr->increment_network_latency(network_delay, vnet);
@@ -261,12 +265,12 @@ NetworkInterface_d::wakeup()
 
     /****************** Checking for credit link *******/
 
-    if (m_credit_link->isReady()) {
+    if (m_credit_link->isReady(m_net_ptr->curCycle())) {
         flit_d *t_flit = m_credit_link->consumeLink();
         m_out_vc_state[t_flit->get_vc()]->increment_credit();
         if (t_flit->is_free_signal()) {
             m_out_vc_state[t_flit->get_vc()]->setState(IDLE_,
-                g_system_ptr->getTime());
+                m_net_ptr->curCycle());
         }
         delete t_flit;
     }
@@ -292,7 +296,9 @@ NetworkInterface_d::scheduleOutputLink()
             vc = 0;
 
         // model buffer backpressure
-        if (m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) {
+        if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle()) &&
+            m_out_vc_state[vc]->has_credits()) {
+
             bool is_candidate_vc = true;
             int t_vnet = get_vnet(vc);
             int vc_base = t_vnet * m_vc_per_vnet;
@@ -301,7 +307,7 @@ NetworkInterface_d::scheduleOutputLink()
                 for (int vc_offset = 0; vc_offset < m_vc_per_vnet;
                      vc_offset++) {
                     int t_vc = vc_base + vc_offset;
-                    if (m_ni_buffers[t_vc]->isReady()) {
+                    if (m_ni_buffers[t_vc]->isReady(m_net_ptr->curCycle())) {
                         if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) {
                             is_candidate_vc = false;
                             break;
@@ -315,7 +321,7 @@ NetworkInterface_d::scheduleOutputLink()
             m_out_vc_state[vc]->decrement_credit();
             // Just removing the flit
             flit_d *t_flit = m_ni_buffers[vc]->getTopFlit();
-            t_flit->set_time(g_system_ptr->getTime() + 1);
+            t_flit->set_time(m_net_ptr->curCycle() + 1);
             outSrcQueue->insert(t_flit);
             // schedule the out link
             outNetLink->scheduleEvent(1);
@@ -350,7 +356,7 @@ NetworkInterface_d::checkReschedule()
         }
     }
     for (int vc = 0; vc < m_num_vcs; vc++) {
-        if (m_ni_buffers[vc]->isReadyForNext()) {
+        if (m_ni_buffers[vc]->isReadyForNext(m_net_ptr->curCycle())) {
             scheduleEvent(1);
             return;
         }
index 6d12fc30ea623f91cfe6efb947eaa36a68c9decf..80a050207f91aba2a3a2d394982345aeb64f969f 100644 (file)
@@ -66,9 +66,9 @@ NetworkLink_d::setSourceQueue(flitBuffer_d *srcQueue)
 void
 NetworkLink_d::wakeup()
 {
-    if (link_srcQueue->isReady()) {
+    if (link_srcQueue->isReady(curCycle())) {
         flit_d *t_flit = link_srcQueue->getTopFlit();
-        t_flit->set_time(g_system_ptr->getTime() + m_latency);
+        t_flit->set_time(curCycle() + m_latency);
         linkBuffer->insert(t_flit);
         link_consumer->scheduleEvent(m_latency);
         m_link_utilized++;
index f27e60757b611cf0306779d4b1ad74eab24c81f0..c52c903e0fce9acc16641ea8a9157ea0f4941b5b 100644 (file)
@@ -62,7 +62,7 @@ class NetworkLink_d : public ClockedObject, public Consumer
 
     double calculate_power();
 
-    inline bool isReady()           { return linkBuffer->isReady(); }
+    inline bool isReady(Time curTime) { return linkBuffer->isReady(curTime); }
     inline flit_d* peekLink()       { return linkBuffer->peekTopFlit(); }
     inline flit_d* consumeLink()    { return linkBuffer->getTopFlit(); }
     void init_net_ptr(GarnetNetwork_d* net_ptr)
index 33d1583e1ceae24f674b27cb52d636c973ca5e96..7422a51653fdc6ba0566620818afdcd4b0981846 100644 (file)
@@ -66,7 +66,7 @@ OutputUnit_d::decrement_credit(int out_vc)
 void
 OutputUnit_d::wakeup()
 {
-    if (m_credit_link->isReady()) {
+    if (m_credit_link->isReady(m_router->curCycle())) {
         flit_d *t_flit = m_credit_link->consumeLink();
         int out_vc = t_flit->get_vc();
         m_outvc_state[out_vc]->increment_credit();
@@ -75,7 +75,7 @@ OutputUnit_d::wakeup()
                                   m_outvc_state[out_vc]->get_credit_count());
 
         if (t_flit->is_free_signal())
-            set_vc_state(IDLE_, out_vc);
+            set_vc_state(IDLE_, out_vc, m_router->curCycle());
 
         delete t_flit;
     }
@@ -102,7 +102,7 @@ OutputUnit_d::set_credit_link(CreditLink_d *credit_link)
 void
 OutputUnit_d::update_vc(int vc, int in_port, int in_vc)
 {
-    m_outvc_state[vc]->setState(ACTIVE_, g_system_ptr->getTime() + 1);
+    m_outvc_state[vc]->setState(ACTIVE_, m_router->curCycle() + 1);
     m_outvc_state[vc]->set_inport(in_port);
     m_outvc_state[vc]->set_invc(in_vc);
     m_router->update_incredit(in_port, in_vc,
index 750c71b3269c95984ec11f5784c4ec34353507e0..4fa7dcb90afc46d98c31c4ab48b2703d8e9e0035 100644 (file)
@@ -69,16 +69,15 @@ class OutputUnit_d : public Consumer
     }
 
     inline void
-    set_vc_state(VC_state_type state, int vc)
+    set_vc_state(VC_state_type state, int vc, Time curTime)
     {
-        m_outvc_state[vc]->setState(state, g_system_ptr->getTime() + 1);
+        m_outvc_state[vc]->setState(state, curTime + 1);
     }
 
     inline bool
-    is_vc_idle(int vc)
+    is_vc_idle(int vc, Time curTime)
     {
-        return (m_outvc_state[vc]->isInState(IDLE_,
-                                             g_system_ptr->getTime()));
+        return (m_outvc_state[vc]->isInState(IDLE_, curTime));
     }
 
     inline void
index 35a9f06e102575e15aef62e6883b847e7f6b28b8..e68c08613fbc4461ea6b53f5301b1d8415f7cec4 100644 (file)
@@ -57,8 +57,8 @@ void
 RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc)
 {
     int outport = routeCompute(t_flit);
-    in_unit->updateRoute(invc, outport);
-    t_flit->advance_stage(VA_);
+    in_unit->updateRoute(invc, outport, m_router->curCycle());
+    t_flit->advance_stage(VA_, m_router->curCycle());
     m_router->vcarb_req();
 }
 
index 41ff8d48250ead845be25c0d11c26fea65a7422b..ab3f4b761359c938defa8a2b39daaf742fb70dde 100644 (file)
@@ -113,8 +113,10 @@ SWallocator_d::arbitrate_inports()
                 get_vnet(invc))))
                 continue;
 
-            if (m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_) &&
-               m_input_unit[inport]->has_credits(invc)) {
+            if (m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_,
+                                                 m_router->curCycle()) &&
+                m_input_unit[inport]->has_credits(invc)) {
+
                 if (is_candidate_inport(inport, invc)) {
                     int outport = m_input_unit[inport]->get_route(invc);
                     m_local_arbiter_activity++;
@@ -137,7 +139,8 @@ SWallocator_d::is_candidate_inport(int inport, int invc)
     if ((m_router->get_net_ptr())->isVNetOrdered(t_vnet)) {
         for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
             int temp_vc = vc_base + vc_offset;
-            if (m_input_unit[inport]->need_stage(temp_vc, ACTIVE_, SA_) &&
+            if (m_input_unit[inport]->need_stage(temp_vc, ACTIVE_, SA_,
+                                                 m_router->curCycle()) &&
                (m_input_unit[inport]->get_route(temp_vc) == outport) &&
                (m_input_unit[inport]->get_enqueue_time(temp_vc) <
                     t_enqueue_time)) {
@@ -175,28 +178,34 @@ SWallocator_d::arbitrate_outports()
 
                 // remove flit from Input Unit
                 flit_d *t_flit = m_input_unit[inport]->getTopFlit(invc);
-                t_flit->advance_stage(ST_);
+                t_flit->advance_stage(ST_, m_router->curCycle());
                 t_flit->set_vc(outvc);
                 t_flit->set_outport(outport);
-                t_flit->set_time(g_system_ptr->getTime() + 1);
+                t_flit->set_time(m_router->curCycle() + 1);
                 m_output_unit[outport]->decrement_credit(outvc);
                 m_router->update_sw_winner(inport, t_flit);
                 m_global_arbiter_activity++;
 
                 if ((t_flit->get_type() == TAIL_) ||
                     t_flit->get_type() == HEAD_TAIL_) {
+
                     // Send a credit back
                     // along with the information that this VC is now idle
-                    m_input_unit[inport]->increment_credit(invc, true);
+                    m_input_unit[inport]->increment_credit(invc, true,
+                        m_router->curCycle());
+
                     // This Input VC should now be empty
-                    assert(m_input_unit[inport]->isReady(invc) == false);
+                    assert(m_input_unit[inport]->isReady(invc,
+                        m_router->curCycle()) == false);
 
-                    m_input_unit[inport]->set_vc_state(IDLE_, invc);
+                    m_input_unit[inport]->set_vc_state(IDLE_, invc,
+                        m_router->curCycle());
                     m_input_unit[inport]->set_enqueue_time(invc, INFINITE_);
                 } else {
                     // Send a credit back
                     // but do not indicate that the VC is idle
-                    m_input_unit[inport]->increment_credit(invc, false);
+                    m_input_unit[inport]->increment_credit(invc, false,
+                        m_router->curCycle());
                 }
                 break; // got a in request for this outport
             }
@@ -209,7 +218,8 @@ SWallocator_d::check_for_wakeup()
 {
     for (int i = 0; i < m_num_inports; i++) {
         for (int j = 0; j < m_num_vcs; j++) {
-            if (m_input_unit[i]->need_stage_nextcycle(j, ACTIVE_, SA_)) {
+            if (m_input_unit[i]->need_stage_nextcycle(j, ACTIVE_, SA_,
+                                                      m_router->curCycle())) {
                 scheduleEvent(1);
                 return;
             }
index 1cb31c3e38bb5ad19ee2bab6659456ba8eef335b..db7446f7a79b4a8874c80cd0f1fb7706a8037df1 100644 (file)
@@ -65,16 +65,16 @@ void
 Switch_d::wakeup()
 {
     DPRINTF(RubyNetwork, "Switch woke up at time: %lld\n",
-            g_system_ptr->getTime());
+            m_router->curCycle());
 
     for (int inport = 0; inport < m_num_inports; inport++) {
-        if (!m_switch_buffer[inport]->isReady())
+        if (!m_switch_buffer[inport]->isReady(m_router->curCycle()))
             continue;
         flit_d *t_flit = m_switch_buffer[inport]->peekTopFlit();
-        if (t_flit->is_stage(ST_)) {
+        if (t_flit->is_stage(ST_, m_router->curCycle())) {
             int outport = t_flit->get_outport();
-            t_flit->advance_stage(LT_);
-            t_flit->set_time(g_system_ptr->getTime() + 1);
+            t_flit->advance_stage(LT_, m_router->curCycle());
+            t_flit->set_time(m_router->curCycle() + 1);
 
             // This will take care of waking up the Network Link
             m_output_unit[outport]->insert_flit(t_flit);
@@ -89,7 +89,7 @@ void
 Switch_d::check_for_wakeup()
 {
     for (int inport = 0; inport < m_num_inports; inport++) {
-        if (m_switch_buffer[inport]->isReadyForNext()) {
+        if (m_switch_buffer[inport]->isReadyForNext(m_router->curCycle())) {
             scheduleEvent(1);
             break;
         }
index 75533fb1001deb632b26f55fa2f2e80489d77d7e..012837362e18a57f2caf93109d25a7b766223bf3 100644 (file)
@@ -132,7 +132,8 @@ VCallocator_d::is_invc_candidate(int inport_iter, int invc_iter)
     if ((m_router->get_net_ptr())->isVNetOrdered(vnet)) {
         for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
             int temp_vc = invc_base + vc_offset;
-            if (m_input_unit[inport_iter]->need_stage(temp_vc, VC_AB_, VA_) &&
+            if (m_input_unit[inport_iter]->need_stage(temp_vc, VC_AB_, VA_,
+                                                      m_router->curCycle()) &&
                (m_input_unit[inport_iter]->get_route(temp_vc) == outport) &&
                (m_input_unit[inport_iter]->get_enqueue_time(temp_vc) <
                     t_enqueue_time)) {
@@ -163,7 +164,7 @@ VCallocator_d::select_outvc(int inport_iter, int invc_iter)
         if (outvc_offset >= num_vcs_per_vnet)
             outvc_offset = 0;
         int outvc = outvc_base + outvc_offset;
-        if (m_output_unit[outport]->is_vc_idle(outvc)) {
+        if (m_output_unit[outport]->is_vc_idle(outvc, m_router->curCycle())) {
             m_local_arbiter_activity[vnet]++;
             m_outvc_req[outport][outvc][inport_iter][invc_iter] = true;
             if (!m_outvc_is_req[outport][outvc])
@@ -182,8 +183,8 @@ VCallocator_d::arbitrate_invcs()
                 get_vnet(invc_iter))))
                 continue;
 
-            if (m_input_unit[inport_iter]->need_stage(
-                invc_iter, VC_AB_, VA_)) {
+            if (m_input_unit[inport_iter]->need_stage(invc_iter, VC_AB_,
+                    VA_, m_router->curCycle())) {
                 if (!is_invc_candidate(inport_iter, invc_iter))
                     continue;
 
@@ -231,7 +232,8 @@ VCallocator_d::arbitrate_outvcs()
                 int invc = invc_base + invc_offset;
                 if (m_outvc_req[outport_iter][outvc_iter][inport][invc]) {
                     m_global_arbiter_activity[vnet]++;
-                    m_input_unit[inport]->grant_vc(invc, outvc_iter);
+                    m_input_unit[inport]->grant_vc(invc, outvc_iter,
+                        m_router->curCycle());
                     m_output_unit[outport_iter]->update_vc(
                         outvc_iter, inport, invc);
                     m_router->swarb_req();
@@ -256,7 +258,8 @@ VCallocator_d::check_for_wakeup()
 {
     for (int i = 0; i < m_num_inports; i++) {
         for (int j = 0; j < m_num_vcs; j++) {
-            if (m_input_unit[i]->need_stage_nextcycle(j, VC_AB_, VA_)) {
+            if (m_input_unit[i]->need_stage_nextcycle(j, VC_AB_, VA_,
+                   m_router->curCycle())) {
                 scheduleEvent(1);
                 return;
             }
index 96d873009c879f53750d361896f1547b48f4f9fb..4fd2ebbbf3f79d2d32802a9b22d5ce6177fc715f 100644 (file)
 
 #include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
 
-VirtualChannel_d::VirtualChannel_d(int id)
+VirtualChannel_d::VirtualChannel_d(int id, Time curTime)
 {
     m_id = id;
     m_input_buffer = new flitBuffer_d();
     m_vc_state.first = IDLE_;
-    m_vc_state.second = g_system_ptr->getTime();
+    m_vc_state.second = curTime;
     m_enqueue_time = INFINITE_;
 }
 
@@ -51,37 +51,36 @@ VirtualChannel_d::set_outport(int outport)
 }
 
 void
-VirtualChannel_d::grant_vc(int out_vc)
+VirtualChannel_d::grant_vc(int out_vc, Time curTime)
 {
     m_output_vc = out_vc;
     m_vc_state.first = ACTIVE_;
-    m_vc_state.second = g_system_ptr->getTime() + 1;
+    m_vc_state.second = curTime + 1;
     flit_d *t_flit = m_input_buffer->peekTopFlit();
-    t_flit->advance_stage(SA_);
+    t_flit->advance_stage(SA_, curTime);
 }
 
 bool
-VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage)
+VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage,
+                             Time curTime)
 {
-    if ((m_vc_state.first == state) &&
-       (g_system_ptr->getTime() >= m_vc_state.second)) {
-        if (m_input_buffer->isReady()) {
+    if ((m_vc_state.first == state) && (curTime >= m_vc_state.second)) {
+        if (m_input_buffer->isReady(curTime)) {
             flit_d *t_flit = m_input_buffer->peekTopFlit();
-            return(t_flit->is_stage(stage)) ;
+            return(t_flit->is_stage(stage, curTime)) ;
         }
     }
     return false;
-
 }
 
 bool
-VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage)
+VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage,
+                                       Time curTime)
 {
-    if ((m_vc_state.first == state) &&
-       ((g_system_ptr->getTime()+1) >= m_vc_state.second)) {
-        if (m_input_buffer->isReadyForNext()) {
+    if ((m_vc_state.first == state) && ((curTime + 1) >= m_vc_state.second)) {
+        if (m_input_buffer->isReadyForNext(curTime)) {
             flit_d *t_flit = m_input_buffer->peekTopFlit();
-            return(t_flit->is_next_stage(stage)) ;
+            return(t_flit->is_next_stage(stage, curTime)) ;
         }
     }
     return false;
index 18553fe2b8a9ec590a6f114439f0206854313b36..6217be1d0f5afe4dfd9797faeedfa59dc618e485 100644 (file)
 class VirtualChannel_d
 {
   public:
-    VirtualChannel_d(int id);
+    VirtualChannel_d(int id, Time curTime);
     ~VirtualChannel_d();
 
-    bool need_stage(VC_state_type state, flit_stage stage);
-    bool need_stage_nextcycle(VC_state_type state, flit_stage stage);
+    bool need_stage(VC_state_type state, flit_stage stage, Time curTime);
+    bool need_stage_nextcycle(VC_state_type state, flit_stage stage,
+                              Time curTime);
     void set_outport(int outport);
-    void grant_vc(int out_vc);
+    void grant_vc(int out_vc, Time curTime);
 
     inline Time get_enqueue_time()          { return m_enqueue_time; }
     inline void set_enqueue_time(Time time) { m_enqueue_time = time; }
@@ -56,7 +57,10 @@ class VirtualChannel_d
     inline void update_credit(int credit)   { m_credit_count = credit; }
     inline void increment_credit()          { m_credit_count++; }
 
-    inline bool isReady() { return m_input_buffer->isReady(); }
+    inline bool isReady(Time curTime)
+    {
+        return m_input_buffer->isReady(curTime);
+    }
 
     inline void
     insertFlit(flit_d *t_flit)
@@ -65,10 +69,10 @@ class VirtualChannel_d
     }
 
     inline void
-    set_state(VC_state_type m_state)
+    set_state(VC_state_type m_state, Time curTime)
     {
         m_vc_state.first = m_state;
-        m_vc_state.second = g_system_ptr->getTime() + 1;
+        m_vc_state.second = curTime + 1;
     }
 
     inline flit_d*
index 2c4f4e09e8f8c883db238b94ad7b9eab9d3378c2..e31989a541a962805331fd24a5b22172cb45db56 100644 (file)
@@ -47,22 +47,22 @@ flitBuffer_d::isEmpty()
 }
 
 bool
-flitBuffer_d::isReady()
+flitBuffer_d::isReady(Time curTime)
 {
     if (m_buffer.size() != 0 ) {
         flit_d *t_flit = peekTopFlit();
-        if (t_flit->get_time() <= g_system_ptr->getTime())
+        if (t_flit->get_time() <= curTime)
             return true;
     }
     return false;
 }
 
 bool
-flitBuffer_d::isReadyForNext()
+flitBuffer_d::isReadyForNext(Time curTime)
 {
     if (m_buffer.size() != 0 ) {
         flit_d *t_flit = peekTopFlit();
-        if (t_flit->get_time() <= (g_system_ptr->getTime() + 1))
+        if (t_flit->get_time() <= (curTime + 1))
             return true;
     }
     return false;
index 23cbd0bb3bc5f91a0b4070e6f30f502a06de44a0..eb7729bef8e6cb39aba5e824faae9ee34c285738 100644 (file)
@@ -44,8 +44,8 @@ class flitBuffer_d
     flitBuffer_d();
     flitBuffer_d(int maximum_size);
 
-    bool isReady();
-    bool isReadyForNext();
+    bool isReady(Time curTime);
+    bool isReadyForNext(Time curTime);
     bool isEmpty();
     void print(std::ostream& out) const;
     bool isFull();
index 93364348ea098519eecc7d454a43b47812f2d379..07aea133f150398c729f12f17adc9e6b3d9f4aa5 100644 (file)
 
 #include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
 
-flit_d::flit_d(int id, int  vc, int vnet, int size, MsgPtr msg_ptr)
+flit_d::flit_d(int id, int  vc, int vnet, int size, MsgPtr msg_ptr,
+    Time curTime)
 {
     m_size = size;
     m_msg_ptr = msg_ptr;
-    m_enqueue_time = g_system_ptr->getTime();
-    m_time = g_system_ptr->getTime();
+    m_enqueue_time = curTime;
+    m_time = curTime;
     m_id = id;
     m_vnet = vnet;
     m_vc = vc;
@@ -54,12 +55,12 @@ flit_d::flit_d(int id, int  vc, int vnet, int size, MsgPtr msg_ptr)
         m_type = BODY_;
 }
 
-flit_d::flit_d(int vc, bool is_free_signal)
+flit_d::flit_d(int vc, bool is_free_signal, Time curTime)
 {
     m_id = 0;
     m_vc = vc;
     m_is_free_signal = is_free_signal;
-    m_time = g_system_ptr->getTime();
+    m_time = curTime;
 }
 
 void
index 4295cbf6b7d58c8d4e86aa3fb861cdea6a9a042c..549dd59d565f0ee4d99b3680aff7f6451d624815 100644 (file)
@@ -40,8 +40,8 @@
 class flit_d
 {
   public:
-    flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr);
-    flit_d(int vc, bool is_free_signal);
+    flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Time curTime);
+    flit_d(int vc, bool is_free_signal, Time curTime);
     void set_outport(int port) { m_outport = port; }
     int get_outport() {return m_outport; }
     void print(std::ostream& out) const;
@@ -58,25 +58,26 @@ class flit_d
     flit_type get_type() { return m_type; }
 
     bool
-    is_stage(flit_stage t_stage)
+    is_stage(flit_stage t_stage, Time curTime)
     {
         return (m_stage.first == t_stage &&
-                g_system_ptr->getTime() >= m_stage.second);
+                curTime >= m_stage.second);
     }
 
     bool
-    is_next_stage(flit_stage t_stage)
+    is_next_stage(flit_stage t_stage, Time curTime)
     {
         return (m_stage.first == t_stage &&
-                (g_system_ptr->getTime() + 1) >= m_stage.second);
+                (curTime + 1) >= m_stage.second);
     }
 
     void
-    advance_stage(flit_stage t_stage)
+    advance_stage(flit_stage t_stage, Time curTime)
     {
         m_stage.first = t_stage;
-        m_stage.second = g_system_ptr->getTime() + 1;
+        m_stage.second = curTime + 1;
     }
+
     std::pair<flit_stage, Time>
     get_stage()
     {
index 9916f4ba561d493761a271990a00e452dd12efa1..a60d2345783cc8b36f553ac8a18a284d07c427de 100644 (file)
@@ -255,7 +255,7 @@ GarnetNetwork::printLinkStats(ostream& out) const
     for (int i = 0; i < m_link_ptr_vector.size(); i++) {
         average_link_utilization +=
             (double(m_link_ptr_vector[i]->getLinkUtilization())) /
-            (double(g_system_ptr->getTime()-m_ruby_start));
+            (double(curCycle() - m_ruby_start));
 
         vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
         for (int j = 0; j < vc_load.size(); j++) {
@@ -273,8 +273,8 @@ GarnetNetwork::printLinkStats(ostream& out) const
         if (!m_in_use[i/m_vcs_per_vnet])
             continue;
 
-        average_vc_load[i] = (double(average_vc_load[i]) /
-            (double(g_system_ptr->getTime()) - m_ruby_start));
+        average_vc_load[i] = double(average_vc_load[i]) /
+            (double(curCycle() - m_ruby_start));
         out << "Average VC Load [" << i << "] = " << average_vc_load[i]
             << " flits/cycle " << endl;
     }
index 9e4c1ef9ad9cd6fc2b529c94a26deb2fcd6995ca..7267da36d1ec3f5c5d30192e9f53d8ded9e6e35d 100644 (file)
@@ -68,7 +68,7 @@ NetworkInterface::NetworkInterface(int id, int virtual_networks,
 
     for (int i = 0; i < m_num_vcs; i++) {
         m_out_vc_state.push_back(new OutVcState(i));
-        m_out_vc_state[i]->setState(IDLE_, g_system_ptr->getTime());
+        m_out_vc_state[i]->setState(IDLE_, m_net_ptr->curCycle());
     }
 }
 
@@ -167,19 +167,20 @@ NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet)
         }
         for (int i = 0; i < num_flits; i++) {
             m_net_ptr->increment_injected_flits(vnet);
-            flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr);
-            fl->set_delay(g_system_ptr->getTime() - msg_ptr->getTime());
+            flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr,
+                                m_net_ptr->curCycle());
+            fl->set_delay(m_net_ptr->curCycle() - msg_ptr->getTime());
             m_ni_buffers[vc]->insert(fl);
         }
 
-        m_out_vc_state[vc]->setState(VC_AB_, g_system_ptr->getTime());
+        m_out_vc_state[vc]->setState(VC_AB_, m_net_ptr->curCycle());
 
         // setting an output vc request for the next hop.
         // This flit will be ready to traverse the link and into the next hop
         // only when an output vc is acquired at the next hop
         outNetLink->request_vc_link(vc,
                                     new_net_msg_ptr->getInternalDestination(),
-                                    g_system_ptr->getTime());
+                                    m_net_ptr->curCycle());
     }
 
     return true ;
@@ -222,7 +223,7 @@ NetworkInterface::calculateVC(int vnet)
             m_vc_allocator[vnet] = 0;
 
         if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(IDLE_,
-            g_system_ptr->getTime())) {
+            m_net_ptr->curCycle())) {
             return ((vnet*m_vc_per_vnet) + delta);
         }
     }
@@ -266,18 +267,18 @@ NetworkInterface::wakeup()
         flit *t_flit = inNetLink->consumeLink();
         if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
             DPRINTF(RubyNetwork, "m_id: %d, Message delivered at time: %lld\n",
-                    m_id, g_system_ptr->getTime());
+                    m_id, m_net_ptr->curCycle());
 
             outNode_ptr[t_flit->get_vnet()]->enqueue(
                 t_flit->get_msg_ptr(), 1);
 
             // signal the upstream router that this vc can be freed now
             inNetLink->release_vc_link(t_flit->get_vc(),
-                g_system_ptr->getTime() + 1);
+                m_net_ptr->curCycle() + 1);
         }
         int vnet = t_flit->get_vnet();
         m_net_ptr->increment_received_flits(vnet);
-        int network_delay = g_system_ptr->getTime() -
+        int network_delay = m_net_ptr->curCycle() -
                             t_flit->get_enqueue_time();
         int queueing_delay = t_flit->get_delay();
         m_net_ptr->increment_network_latency(network_delay, vnet);
@@ -304,14 +305,14 @@ NetworkInterface::scheduleOutputLink()
         vc++;
         if (vc == m_num_vcs)
             vc = 0;
-        if (m_ni_buffers[vc]->isReady()) {
+        if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle())) {
             if (m_out_vc_state[vc]->isInState(ACTIVE_,
-               g_system_ptr->getTime()) &&
+               m_net_ptr->curCycle()) &&
                outNetLink->isBufferNotFull_link(vc)) {  // buffer backpressure
 
                 // Just removing the flit
                 flit *t_flit = m_ni_buffers[vc]->getTopFlit();
-                t_flit->set_time(g_system_ptr->getTime() + 1);
+                t_flit->set_time(m_net_ptr->curCycle() + 1);
                 outSrcQueue->insert(t_flit);
 
                 // schedule the out link
@@ -332,7 +333,7 @@ NetworkInterface::checkReschedule()
         }
     }
     for (int vc = 0; vc < m_num_vcs; vc++) {
-        if (m_ni_buffers[vc]->isReadyForNext()) {
+        if (m_ni_buffers[vc]->isReadyForNext(m_net_ptr->curCycle())) {
             scheduleEvent(1);
             return;
         }
index 2d94f6484dd9ecea3b196c3f003170461215aa6d..b9faef28d044733eb2ead11c8f4faf6bc9b47306 100644 (file)
@@ -116,7 +116,7 @@ NetworkLink::getLinkUtilization()
 bool
 NetworkLink::isReady()
 {
-    return linkBuffer->isReady();
+    return linkBuffer->isReady(curCycle());
 }
 
 void
@@ -134,11 +134,11 @@ NetworkLink::setOutPort(int port)
 void
 NetworkLink::wakeup()
 {
-    if (!link_srcQueue->isReady())
+    if (!link_srcQueue->isReady(curCycle()))
         return;
 
     flit *t_flit = link_srcQueue->getTopFlit();
-    t_flit->set_time(g_system_ptr->getTime() + m_latency);
+    t_flit->set_time(curCycle() + m_latency);
     linkBuffer->insert(t_flit);
     link_consumer->scheduleEvent(m_latency);
     m_link_utilized++;
index 8e064a01fc8e195374909c0114852abc3dd3dfc0..ca82f075731592799b47d0ecfe7c90c54ae4923e 100644 (file)
@@ -71,7 +71,7 @@ Router::addInPort(NetworkLink *in_link)
     vector<InVcState *> in_vc_vector;
     for (int i = 0; i < m_num_vcs; i++) {
         in_vc_vector.push_back(new InVcState(i));
-        in_vc_vector[i]->setState(IDLE_, g_system_ptr->getTime());
+        in_vc_vector[i]->setState(IDLE_, curCycle());
     }
     m_in_vc_state.push_back(in_vc_vector);
     m_in_link.push_back(in_link);
@@ -111,7 +111,7 @@ Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entry,
     vector<OutVcState *> out_vc_vector;
     for (int i = 0; i < m_num_vcs; i++) {
         out_vc_vector.push_back(new OutVcState(i));
-        out_vc_vector[i]->setState(IDLE_, g_system_ptr->getTime());
+        out_vc_vector[i]->setState(IDLE_, curCycle());
     }
     m_out_vc_state.push_back(out_vc_vector);
     m_link_weights.push_back(link_weight);
@@ -137,8 +137,8 @@ Router::request_vc(int in_vc, int in_port, NetDest destination,
     int outport = getRoute(destination);
     m_in_vc_state[in_port][in_vc]->setRoute(outport);
     m_in_vc_state[in_port][in_vc]->setState(VC_AB_, request_time);
-    assert(request_time >= g_system_ptr->getTime());
-    if (request_time > g_system_ptr->getTime())
+    assert(request_time >= curCycle());
+    if (request_time > curCycle())
         m_vc_arbiter->scheduleEventAbsolute(request_time);
     else
         vc_arbitrate();
@@ -180,22 +180,21 @@ Router::vc_arbitrate()
 
             InVcState *in_vc_state = m_in_vc_state[inport][invc];
 
-            if (in_vc_state->isInState(VC_AB_, g_system_ptr->getTime())) {
+            if (in_vc_state->isInState(VC_AB_, curCycle())) {
                 int outport = in_vc_state->get_outport();
                 vector<int> valid_vcs = get_valid_vcs(invc);
                 for (int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size();
                         valid_vc_iter++) {
                     if (m_out_vc_state[outport][valid_vcs[valid_vc_iter]]
-                            ->isInState(IDLE_, g_system_ptr->getTime())) {
+                            ->isInState(IDLE_, curCycle())) {
 
                         in_vc_state->grant_vc(valid_vcs[valid_vc_iter],
-                                g_system_ptr->getTime());
+                                curCycle());
 
-                        m_in_link[inport]->grant_vc_link(invc,
-                                g_system_ptr->getTime());
+                        m_in_link[inport]->grant_vc_link(invc, curCycle());
 
                         m_out_vc_state[outport][valid_vcs[valid_vc_iter]]
-                            ->setState(VC_AB_, g_system_ptr->getTime());
+                            ->setState(VC_AB_, curCycle());
                         break;
                     }
                 }
@@ -270,8 +269,7 @@ Router::routeCompute(flit *m_flit, int inport)
     assert(m_net_ptr->getNumPipeStages() >= 1);
 
     // Subtract 1 as 1 cycle will be consumed in scheduling the output link
-    m_flit->set_time(g_system_ptr->getTime() +
-                     (m_net_ptr->getNumPipeStages() - 1));
+    m_flit->set_time(curCycle() + (m_net_ptr->getNumPipeStages() - 1));
     m_flit->set_vc(outvc);
     m_router_buffers[outport][outvc]->insert(m_flit);
 
@@ -283,25 +281,18 @@ Router::routeCompute(flit *m_flit, int inport)
         NetDest destination = nm->getInternalDestination();
 
         if (m_net_ptr->getNumPipeStages() > 1) {
-            m_out_vc_state[outport][outvc]->setState(VC_AB_,
-                g_system_ptr->getTime() + 1);
-
+            m_out_vc_state[outport][outvc]->setState(VC_AB_, curCycle() + 1);
             m_out_link[outport]->request_vc_link(outvc, destination,
-                g_system_ptr->getTime() + 1);
+                curCycle() + 1);
         } else {
-            m_out_vc_state[outport][outvc]->setState(VC_AB_,
-                g_system_ptr->getTime());
-
+            m_out_vc_state[outport][outvc]->setState(VC_AB_, curCycle());
             m_out_link[outport]->request_vc_link(outvc, destination,
-                g_system_ptr->getTime());
+                curCycle());
         }
     }
     if ((m_flit->get_type() == TAIL_) || (m_flit->get_type() == HEAD_TAIL_)) {
-        m_in_vc_state[inport][invc]->setState(IDLE_,
-            g_system_ptr->getTime() + 1);
-
-        m_in_link[inport]->release_vc_link(invc,
-            g_system_ptr->getTime() + 1);
+        m_in_vc_state[inport][invc]->setState(IDLE_, curCycle() + 1);
+        m_in_link[inport]->release_vc_link(invc, curCycle() + 1);
     }
 }
 
@@ -325,8 +316,7 @@ Router::wakeup()
 
         // checking the incoming link
         if (m_in_link[incoming_port]->isReady()) {
-            DPRINTF(RubyNetwork, "m_id: %d, Time: %lld\n",
-                    m_id, g_system_ptr->getTime());
+            DPRINTF(RubyNetwork, "m_id: %d, Time: %lld\n", m_id, curCycle());
             t_flit = m_in_link[incoming_port]->peekLink();
             routeCompute(t_flit, incoming_port);
             m_in_link[incoming_port]->consumeLink();
@@ -360,16 +350,16 @@ Router::scheduleOutputLinks()
             if (vc_tolookat == m_num_vcs)
                 vc_tolookat = 0;
 
-            if (m_router_buffers[port][vc_tolookat]->isReady()) {
+            if (m_router_buffers[port][vc_tolookat]->isReady(curCycle())) {
 
                 // models buffer backpressure
                 if (m_out_vc_state[port][vc_tolookat]->isInState(ACTIVE_,
-                   g_system_ptr->getTime()) &&
+                   curCycle()) &&
                    m_out_link[port]->isBufferNotFull_link(vc_tolookat)) {
 
                     flit *t_flit =
                         m_router_buffers[port][vc_tolookat]->getTopFlit();
-                    t_flit->set_time(g_system_ptr->getTime() + 1 );
+                    t_flit->set_time(curCycle() + 1 );
                     m_out_src_queue[port]->insert(t_flit);
                     m_out_link[port]->scheduleEvent(1);
                     break; // done for this port
@@ -392,7 +382,7 @@ Router::checkReschedule()
 {
     for (int port = 0; port < m_out_link.size(); port++) {
         for (int vc = 0; vc < m_num_vcs; vc++) {
-            if (m_router_buffers[port][vc]->isReadyForNext()) {
+            if (m_router_buffers[port][vc]->isReadyForNext(curCycle())) {
                 scheduleEvent(1);
                 return;
             }
@@ -405,9 +395,7 @@ Router::check_arbiter_reschedule()
 {
     for (int port = 0; port < m_in_link.size(); port++) {
         for (int vc = 0; vc < m_num_vcs; vc++) {
-            if (m_in_vc_state[port][vc]->isInState(VC_AB_,
-               g_system_ptr->getTime() + 1)) {
-
+            if (m_in_vc_state[port][vc]->isInState(VC_AB_, curCycle() + 1)) {
                 m_vc_arbiter->scheduleEvent(1);
                 return;
             }
index 161625978c0c292868e3df6c4f26dccf155b627b..6e858199bbe6798f33dde88cfd939a17d5b4f325 100644 (file)
 
 #include "mem/ruby/network/garnet/flexible-pipeline/flit.hh"
 
-flit::flit(int id, int  vc, int vnet, int size, MsgPtr msg_ptr)
+flit::flit(int id, int  vc, int vnet, int size, MsgPtr msg_ptr, Time curTime)
 {
     m_size = size;
     m_msg_ptr = msg_ptr;
-    m_enqueue_time = g_system_ptr->getTime();
-    m_time = g_system_ptr->getTime();
+    m_enqueue_time = curTime;
+    m_time = curTime;
     m_id = id;
     m_vnet = vnet;
     m_vc = vc;
index 66cd604abfc41113cf9d99dc69b712619fffe2a2..9e1168409eee55d6940e5efe6d6adb1cff00b3ac 100644 (file)
@@ -40,7 +40,7 @@
 class flit
 {
   public:
-    flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr);
+    flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Time curTime);
 
     int get_size();
     int get_id();
index 9446c812a111bbe3bb37e31207e602724056a31d..fd9922af7d2bbd2cc20e7382de7638ce48fb7b7f 100644 (file)
@@ -51,22 +51,22 @@ flitBuffer::isEmpty()
 }
 
 bool
-flitBuffer::isReady()
+flitBuffer::isReady(Time curTime)
 {
     if (m_buffer.size() != 0 ) {
         flit *t_flit = m_buffer.front();
-        if (t_flit->get_time() <= g_system_ptr->getTime())
+        if (t_flit->get_time() <= curTime)
             return true;
     }
     return false;
 }
 
 bool
-flitBuffer::isReadyForNext()
+flitBuffer::isReadyForNext(Time curTime)
 {
     if (m_buffer.size() != 0 ) {
         flit *t_flit = m_buffer.front();
-        if (t_flit->get_time() <= (g_system_ptr->getTime() + 1))
+        if (t_flit->get_time() <= (curTime + 1))
             return true;
     }
     return false;
index 3170c6c78398ab6f46da72afcf41deeafc34d771..263dcb9029f94ba92e23bcfe2565ff864a691ff1 100644 (file)
@@ -43,8 +43,8 @@ class flitBuffer
     flitBuffer();
     flitBuffer(int maximum_size);
 
-    bool isReady();
-    bool isReadyForNext();
+    bool isReady(Time curTime);
+    bool isReadyForNext(Time curTime);
     bool isFull();
     bool isEmpty();
     void setMaxSize(int maximum);
index 9ac0dd8156fa6eaddf4fb65a28411f1d155f855a..6d4fc19234fa8f1f9d11b3d2ab71dd85d69f435b 100644 (file)
@@ -39,9 +39,7 @@ Router_d::calculate_power()
 {
     //Network Activities from garnet
     calculate_performance_numbers();
-    double sim_cycles;
-    sim_cycles =
-        g_system_ptr->getTime() - m_network_ptr->getRubyStartTime();
+    double sim_cycles = curCycle() - m_network_ptr->getRubyStartTime();
 
     // Number of virtual networks/message classes declared in Ruby
     // maybe greater than active virtual networks.
@@ -248,7 +246,7 @@ NetworkLink_d::calculate_power()
         orion_cfg_ptr);
 
     double sim_cycles =
-        (double)(g_system_ptr->getTime() - m_net_ptr->getRubyStartTime());
+        (double)(m_net_ptr->curCycle() - m_net_ptr->getRubyStartTime());
 
     // Dynamic Power
     // Assume half the bits flipped on every link activity
index 201ec4b6094f40f44a4454a90ce54e50aadaf826..74b405312bcb0f5c0e3973f80eb4a65108ce3321 100644 (file)
@@ -32,9 +32,8 @@
 #include <iostream>
 
 #include "base/refcnt.hh"
-#include "mem/ruby/common/Global.hh"
 #include "mem/ruby/common/TypeDefines.hh"
-#include "mem/ruby/system/System.hh"
+#include "mem/packet.hh"
 
 class Message;
 typedef RefCountingPtr<Message> MsgPtr;
@@ -42,9 +41,9 @@ typedef RefCountingPtr<Message> MsgPtr;
 class Message : public RefCounted
 {
   public:
-    Message()
-        : m_time(g_system_ptr->getTime()),
-          m_LastEnqueueTime(g_system_ptr->getTime()),
+    Message(Time curTime)
+        : m_time(curTime),
+          m_LastEnqueueTime(curTime),
           m_DelayedCycles(0)
     { }
 
index d2bcb1241b137395a0560e5692be50cee89a2c3e..e26612e0f7867c60dd294661247f2c1c6c765c7d 100644 (file)
 #include "mem/ruby/common/NetDest.hh"
 #include "mem/ruby/slicc_interface/Message.hh"
 
-class Address;
-
 class NetworkMessage;
 typedef RefCountingPtr<NetworkMessage> NetMsgPtr;
 
 class NetworkMessage : public Message
 {
   public:
-    NetworkMessage()
-        : m_internal_dest_valid(false)
+    NetworkMessage(Time curTime)
+        : Message(curTime), m_internal_dest_valid(false)
     { }
 
     NetworkMessage(const NetworkMessage &other)
index a4dadc7a72b0104343e7f62e24fbf03113054919..37b89dc8f63143aa6d1b8ad27323ca81c07dc43a 100644 (file)
@@ -36,7 +36,6 @@
 #include "mem/protocol/RubyAccessMode.hh"
 #include "mem/protocol/RubyRequestType.hh"
 #include "mem/ruby/common/Address.hh"
-#include "mem/packet.hh"
 
 class RubyRequest : public Message
 {
@@ -52,12 +51,12 @@ class RubyRequest : public Message
     PacketPtr pkt;
     unsigned m_contextId;
 
-    RubyRequest() {}
-    RubyRequest(uint64_t _paddr, uint8_t* _data, int _len, uint64_t _pc,
-                RubyRequestType _type, RubyAccessMode _access_mode,
-                PacketPtr _pkt, PrefetchBit _pb = PrefetchBit_No,
-                 unsigned _proc_id = 100)
-        : m_PhysicalAddress(_paddr),
+    RubyRequest(Time curTime, uint64_t _paddr, uint8_t* _data, int _len,
+        uint64_t _pc, RubyRequestType _type, RubyAccessMode _access_mode,
+        PacketPtr _pkt, PrefetchBit _pb = PrefetchBit_No,
+        unsigned _proc_id = 100)
+        : Message(curTime),
+          m_PhysicalAddress(_paddr),
           m_Type(_type),
           m_ProgramCounter(_pc),
           m_AccessMode(_access_mode),
@@ -71,10 +70,8 @@ class RubyRequest : public Message
       m_LineAddress.makeLineAddress();
     }
 
-    static RubyRequest*
-    create()
+    RubyRequest(Time curTime) : Message(curTime)
     {
-        return new RubyRequest();
     }
 
     RubyRequest*
index 06c540db59094b206894c9fb399f6d19e7764141..178c4cd1effde64b130c5e68f542078e3ba5e2e2 100644 (file)
@@ -130,6 +130,11 @@ mod(int val, int mod)
     return val % mod;
 }
 
+inline int max_tokens()
+{
+  return 1024;
+}
+
 /**
  * This function accepts an address, a data block and a packet. If the address
  * range for the data block contains the address which the packet needs to
index f64d39f8a34e289de0560e84d1f7cffcec817c8f..967d9608624d184dacd854224d91ee510da4ace5 100644 (file)
@@ -36,9 +36,9 @@
 #include "base/statistics.hh"
 #include "mem/ruby/buffers/MessageBuffer.hh"
 #include "mem/ruby/common/Address.hh"
-#include "mem/ruby/common/Global.hh"
 #include "mem/ruby/slicc_interface/AbstractController.hh"
 #include "mem/ruby/slicc_interface/RubyRequest.hh"
+#include "mem/ruby/system/System.hh"
 #include "params/Prefetcher.hh"
 #include "sim/sim_object.hh"
 
index 84450fda43c501d0006fea2b99363e02ade97e88..fe9ab39bedf49bc4ced0c435b3bd6a00ebb309e1 100644 (file)
@@ -70,7 +70,7 @@ DMASequencer::makeRequest(PacketPtr pkt)
     active_request.bytes_issued = 0;
     active_request.pkt = pkt;
 
-    SequencerMsg *msg = new SequencerMsg;
+    SequencerMsg *msg = new SequencerMsg(curCycle());
     msg->getPhysicalAddress() = Address(paddr);
     msg->getLineAddress() = line_address(msg->getPhysicalAddress());
     msg->getType() = write ? SequencerRequestType_ST : SequencerRequestType_LD;
@@ -108,7 +108,7 @@ DMASequencer::issueNext()
         return;
     }
 
-    SequencerMsg *msg = new SequencerMsg;
+    SequencerMsg *msg = new SequencerMsg(curCycle());
     msg->getPhysicalAddress() = Address(active_request.start_paddr +
                                        active_request.bytes_completed);
 
index 9e3fd686438accc7cb41adf7adf7f1d14adfcc56..d57f80468e8f221bbd5cd65847aee486ca002118 100644 (file)
@@ -657,7 +657,7 @@ Sequencer::issueRequest(PacketPtr pkt, RubyRequestType secondary_type)
         pc = pkt->req->getPC();
     }
 
-    RubyRequest *msg = new RubyRequest(pkt->getAddr(),
+    RubyRequest *msg = new RubyRequest(curCycle(), pkt->getAddr(),
                                        pkt->getPtr<uint8_t>(true),
                                        pkt->getSize(), pc, secondary_type,
                                        RubyAccessMode_Supervisor, pkt,
index 0845b3c8df1aef994acd170a5cfe52abbcfa4303..b5a2849ce00892d82173c848e815bff07d752188 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "base/cprintf.hh"
 #include "base/stl_helpers.hh"
+#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/system/System.hh"
 #include "mem/ruby/system/WireBuffer.hh"
 
 using namespace std;
index b27bff6290e7ac61acac346f53953b3138b3ea0f..a8785c9af3877a90b10ac17e33ec30b6b9e4223d 100644 (file)
@@ -53,7 +53,8 @@ class EnqueueStatementAST(StatementAST):
         self.symtab.newSymbol(v)
 
         # Declare message
-        code("${{msg_type.ident}} *out_msg = new ${{msg_type.ident}};")
+        code("${{msg_type.ident}} *out_msg = \
+                new ${{msg_type.ident}}(curCycle());")
 
         # The other statements
         t = self.statements.generate(code, None)
index 19c144048f34b62b3acf13696f6aa51cecaaa9ac..ebf187630c345786ab2c23311ea642fdf896bc00 100644 (file)
@@ -226,7 +226,7 @@ class Type(Symbol):
 
 #include <iostream>
 
-#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/slicc_interface/RubySlicc_Util.hh"
 ''')
 
         for dm in self.data_members.values():
@@ -242,10 +242,14 @@ class Type(Symbol):
 $klass ${{self.c_ident}}$parent
 {
   public:
-    ${{self.c_ident}}()
-    {
+    ${{self.c_ident}}
 ''', klass="class")
 
+        if self.isMessage:
+            code('(Time curTime) : %s(curTime) {' % self["interface"])
+        else:
+            code('()\n\t\t{')
+
         code.indent()
         if not self.isGlobal:
             code.indent()
@@ -284,13 +288,19 @@ $klass ${{self.c_ident}}$parent
         if not self.isGlobal:
             params = [ 'const %s& local_%s' % (dm.type.c_ident, dm.ident) \
                        for dm in self.data_members.itervalues() ]
-
             params = ', '.join(params)
+
+            if self.isMessage:
+                params = "const Time curTime, " + params
+
             code('${{self.c_ident}}($params)')
 
             # Call superclass constructor
             if "interface" in self:
-                code('    : ${{self["interface"]}}()')
+                if self.isMessage:
+                    code('    : ${{self["interface"]}}(curTime)')
+                else:
+                    code('    : ${{self["interface"]}}()')
 
             code('{')
             code.indent()
@@ -302,14 +312,8 @@ $klass ${{self.c_ident}}$parent
             code.dedent()
             code('}')
 
-        # create a static factory method and a clone member
+        # create a clone member
         code('''
-static ${{self.c_ident}}*
-create()
-{
-    return new ${{self.c_ident}}();
-}
-
 ${{self.c_ident}}*
 clone() const
 {
@@ -419,7 +423,6 @@ operator<<(std::ostream& out, const ${{self.c_ident}}& obj)
 #include <iostream>
 
 #include "mem/protocol/${{self.c_ident}}.hh"
-#include "mem/ruby/slicc_interface/RubySlicc_Util.hh"
 
 using namespace std;
 ''')