summaryrefslogtreecommitdiff
path: root/src/mem/ruby/network/garnet-fixed-pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/ruby/network/garnet-fixed-pipeline')
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh17
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.cc349
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh142
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.cc95
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh172
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh54
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.cc351
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh96
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.cc103
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh91
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.cc46
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh86
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.cc111
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh95
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/Router_d.cc167
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/Router_d.hh101
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.cc93
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh61
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/SConscript49
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.cc230
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh82
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.cc98
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh73
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.cc271
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh86
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.cc92
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh119
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.cc88
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh87
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/flit_d.cc134
-rw-r--r--src/mem/ruby/network/garnet-fixed-pipeline/flit_d.hh166
31 files changed, 3805 insertions, 0 deletions
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh
new file mode 100644
index 000000000..28da0ac73
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh
@@ -0,0 +1,17 @@
+/*
+ * CreditLink_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+#ifndef CREDIT_LINK_D_H
+#define CREDIT_LINK_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+
+class CreditLink_d : public NetworkLink_d {
+public:
+ CreditLink_d(int id):NetworkLink_d(id) {}
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.cc
new file mode 100644
index 000000000..28d22c89d
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.cc
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * GarnetNetwork_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
+#include "mem/protocol/MachineType.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh"
+#include "mem/ruby/buffers/MessageBuffer.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/simple/Topology.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh"
+#include "mem/ruby/common/NetDest.hh"
+
+GarnetNetwork_d::GarnetNetwork_d(int nodes)
+{
+ m_nodes = MachineType_base_number(MachineType_NUM); // Total nodes in network
+ m_virtual_networks = NUMBER_OF_VIRTUAL_NETWORKS; // Number of virtual networks = number of message classes in the coherence protocol
+ m_ruby_start = 0;
+ m_flits_recieved = 0;
+ m_flits_injected = 0;
+ m_network_latency = 0.0;
+ m_queueing_latency = 0.0;
+
+ m_router_ptr_vector.clear();
+
+ // Allocate to and from queues
+ m_toNetQueues.setSize(m_nodes); // Queues that are getting messages from protocol
+ m_fromNetQueues.setSize(m_nodes); // Queues that are feeding the protocol
+ m_in_use.setSize(m_virtual_networks);
+ m_ordered.setSize(m_virtual_networks);
+ for (int i = 0; i < m_virtual_networks; i++)
+ {
+ m_in_use[i] = false;
+ m_ordered[i] = false;
+ }
+
+ for (int node = 0; node < m_nodes; node++)
+ {
+ //Setting how many vitual message buffers will there be per Network Queue
+ m_toNetQueues[node].setSize(m_virtual_networks);
+ m_fromNetQueues[node].setSize(m_virtual_networks);
+
+ for (int j = 0; j < m_virtual_networks; j++)
+ {
+ m_toNetQueues[node][j] = new MessageBuffer(); // Instantiating the Message Buffers that interact with the coherence protocol
+ m_fromNetQueues[node][j] = new MessageBuffer();
+ }
+ }
+
+ // Setup the network switches
+ m_topology_ptr = new Topology(this, m_nodes);
+
+ int number_of_routers = m_topology_ptr->numSwitches();
+ for (int i=0; i<number_of_routers; i++) {
+ m_router_ptr_vector.insertAtBottom(new Router_d(i, this));
+ }
+
+ for (int i=0; i < m_nodes; i++) {
+ NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks, this);
+ ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
+ m_ni_ptr_vector.insertAtBottom(ni);
+ }
+ m_topology_ptr->createLinks(false); // false because this isn't a reconfiguration
+ for(int i = 0; i < m_router_ptr_vector.size(); i++)
+ {
+ m_router_ptr_vector[i]->init();
+ }
+}
+
+GarnetNetwork_d::~GarnetNetwork_d()
+{
+ for (int i = 0; i < m_nodes; i++)
+ {
+ m_toNetQueues[i].deletePointers();
+ m_fromNetQueues[i].deletePointers();
+ }
+ m_router_ptr_vector.deletePointers();
+ m_ni_ptr_vector.deletePointers();
+ m_link_ptr_vector.deletePointers();
+ m_creditlink_ptr_vector.deletePointers();
+ delete m_topology_ptr;
+}
+
+void GarnetNetwork_d::reset()
+{
+ for (int node = 0; node < m_nodes; node++)
+ {
+ for (int j = 0; j < m_virtual_networks; j++)
+ {
+ m_toNetQueues[node][j]->clear();
+ m_fromNetQueues[node][j]->clear();
+ }
+ }
+}
+
+/*
+ * This function creates a link from the Network Interface (NI) into the Network.
+ * It creates a Network Link from the NI to a Router and a Credit Link from
+ * the Router to the NI
+*/
+
+void GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration)
+{
+ assert(src < m_nodes);
+
+ if(!isReconfiguration)
+ {
+ NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this);
+ CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size());
+ m_link_ptr_vector.insertAtBottom(net_link);
+ m_creditlink_ptr_vector.insertAtBottom(credit_link);
+
+ m_router_ptr_vector[dest]->addInPort(net_link, credit_link);
+ m_ni_ptr_vector[src]->addOutPort(net_link, credit_link);
+ }
+ else
+ {
+ ERROR_MSG("Fatal Error:: Reconfiguration not allowed here");
+ // do nothing
+ }
+}
+
+/*
+ * This function creates a link from the Network to a NI.
+ * It creates a Network Link from a Router to the NI and
+ * a Credit Link from NI to the Router
+*/
+
+void GarnetNetwork_d::makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration)
+{
+ assert(dest < m_nodes);
+ assert(src < m_router_ptr_vector.size());
+ assert(m_router_ptr_vector[src] != NULL);
+
+ if(!isReconfiguration)
+ {
+ NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this);
+ CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size());
+ m_link_ptr_vector.insertAtBottom(net_link);
+ m_creditlink_ptr_vector.insertAtBottom(credit_link);
+
+ m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link);
+ m_ni_ptr_vector[dest]->addInPort(net_link, credit_link);
+ }
+ else
+ {
+ ERROR_MSG("Fatal Error:: Reconfiguration not allowed here");
+ //do nothing
+ }
+}
+
+/*
+ * This function creates a internal network links
+*/
+
+void GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration)
+{
+ if(!isReconfiguration)
+ {
+ NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this);
+ CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size());
+ m_link_ptr_vector.insertAtBottom(net_link);
+ m_creditlink_ptr_vector.insertAtBottom(credit_link);
+
+ m_router_ptr_vector[dest]->addInPort(net_link, credit_link);
+ m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link);
+ }
+ else
+ {
+ ERROR_MSG("Fatal Error:: Reconfiguration not allowed here");
+ // do nothing
+ }
+}
+
+void GarnetNetwork_d::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
+{
+ ASSERT(id < m_nodes);
+ ASSERT(network_num < m_virtual_networks);
+
+ if (ordered)
+ {
+ m_ordered[network_num] = true;
+ }
+ m_in_use[network_num] = true;
+}
+
+MessageBuffer* GarnetNetwork_d::getToNetQueue(NodeID id, bool ordered, int network_num)
+{
+ checkNetworkAllocation(id, ordered, network_num);
+ return m_toNetQueues[id][network_num];
+}
+
+MessageBuffer* GarnetNetwork_d::getFromNetQueue(NodeID id, bool ordered, int network_num)
+{
+ checkNetworkAllocation(id, ordered, network_num);
+ return m_fromNetQueues[id][network_num];
+}
+
+void GarnetNetwork_d::clearStats()
+{
+ m_ruby_start = g_eventQueue_ptr->getTime();
+}
+
+Time GarnetNetwork_d::getRubyStartTime()
+{
+ return m_ruby_start;
+}
+
+void GarnetNetwork_d::printStats(ostream& out) const
+{ double average_link_utilization = 0;
+ Vector<double > average_vc_load;
+ average_vc_load.setSize(m_virtual_networks*NetworkConfig::getVCsPerClass());
+
+ for(int i = 0; i < m_virtual_networks*NetworkConfig::getVCsPerClass(); i++)
+ {
+ average_vc_load[i] = 0;
+ }
+
+ out << endl;
+ out << "Network Stats" << endl;
+ out << "-------------" << endl;
+ out << endl;
+ for(int i = 0; i < m_link_ptr_vector.size(); i++)
+ {
+ average_link_utilization += (double(m_link_ptr_vector[i]->getLinkUtilization())) / (double(g_eventQueue_ptr->getTime()-m_ruby_start));
+
+ Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad();
+ for(int j = 0; j < vc_load.size(); j++)
+ {
+ assert(vc_load.size() == NetworkConfig::getVCsPerClass()*m_virtual_networks);
+ average_vc_load[j] += vc_load[j];
+ }
+ }
+ average_link_utilization = average_link_utilization/m_link_ptr_vector.size();
+ out << "Average Link Utilization :: " << average_link_utilization << " flits/cycle" << endl;
+ out << "-------------" << endl;
+
+ for(int i = 0; i < NetworkConfig::getVCsPerClass()*NUMBER_OF_VIRTUAL_NETWORKS; i++)
+ {
+ average_vc_load[i] = (double(average_vc_load[i]) / (double(g_eventQueue_ptr->getTime()) - m_ruby_start));
+ out << "Average VC Load [" << i << "] = " << average_vc_load[i] << " flits/cycle " << endl;
+ }
+ out << "-------------" << endl;
+
+ // out << "Total flits injected = " << m_flits_injected << endl;
+ // out << "Total flits recieved = " << m_flits_recieved << endl;
+ out << "Average network latency = " << ((double) m_network_latency/ (double) m_flits_recieved)<< endl;
+ // out << "Average queueing latency = " << ((double) m_queueing_latency/ (double) m_flits_recieved)<< endl;
+ // out << "Average latency = " << ((double) (m_queueing_latency + m_network_latency) / (double) m_flits_recieved)<< endl;
+ out << "-------------" << endl;
+
+ double m_total_link_power = 0.0;
+ double m_total_router_power = 0.0;
+
+ for(int i = 0; i < m_link_ptr_vector.size(); i++)
+ {
+ m_total_link_power += m_link_ptr_vector[i]->calculate_power();
+ }
+
+ for(int i = 0; i < m_router_ptr_vector.size(); i++)
+ {
+ m_total_router_power += m_router_ptr_vector[i]->calculate_power();
+ }
+ out << "Total Link Power = " << m_total_link_power << " W " << endl;
+ out << "Total Router Power = " << m_total_router_power << " W " <<endl;
+ out << "-------------" << endl;
+}
+
+void GarnetNetwork_d::printConfig(ostream& out) const
+{
+ out << endl;
+ out << "Network Configuration" << endl;
+ out << "---------------------" << endl;
+ out << "network: GarnetNetwork_d" << endl;
+ out << "topology: " << g_NETWORK_TOPOLOGY << endl;
+ out << endl;
+
+ for (int i = 0; i < m_virtual_networks; i++)
+ {
+ out << "virtual_net_" << i << ": ";
+ if (m_in_use[i])
+ {
+ out << "active, ";
+ if (m_ordered[i])
+ {
+ out << "ordered" << endl;
+ }
+ else
+ {
+ out << "unordered" << endl;
+ }
+ }
+ else
+ {
+ out << "inactive" << endl;
+ }
+ }
+ out << endl;
+
+ for(int i = 0; i < m_ni_ptr_vector.size(); i++)
+ {
+ m_ni_ptr_vector[i]->printConfig(out);
+ }
+ for(int i = 0; i < m_router_ptr_vector.size(); i++)
+ {
+ m_router_ptr_vector[i]->printConfig(out);
+ }
+ if (g_PRINT_TOPOLOGY)
+ {
+ m_topology_ptr->printConfig(out);
+ }
+}
+
+void GarnetNetwork_d::print(ostream& out) const
+{
+ out << "[GarnetNetwork_d]";
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh
new file mode 100644
index 000000000..f1dd5d2c7
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * GarnetNetwork_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef GARNETNETWORK_D_H
+#define GARNETNETWORK_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/gems_common/Vector.hh"
+#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh"
+#include "mem/ruby/network/Network.hh"
+
+class NetworkInterface_d;
+class MessageBuffer;
+class Router_d;
+class Topology;
+class NetDest;
+class NetworkLink_d;
+class CreditLink_d;
+
+class GarnetNetwork_d : public Network{
+public:
+ GarnetNetwork_d(int nodes);
+
+ ~GarnetNetwork_d();
+
+ int getNumNodes(){ return m_nodes;}
+
+ // returns the queue requested for the given component
+ MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num);
+ MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num);
+
+ void clearStats();
+ void printStats(ostream& out) const;
+ void printConfig(ostream& out) const;
+ void print(ostream& out) const;
+
+ inline void increment_injected_flits()
+ {
+ m_flits_injected++;
+ }
+ inline void increment_recieved_flits()
+ {
+ m_flits_recieved++;
+ }
+ inline void increment_network_latency(Time latency)
+ {
+ m_network_latency += latency;
+ }
+ inline void increment_queueing_latency(Time latency)
+ {
+ m_queueing_latency += latency;
+ }
+
+ bool isVNetOrdered(int vnet)
+ {
+ return m_ordered[vnet];
+ }
+ bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
+
+ Time getRubyStartTime();
+
+ void reset();
+
+ // Methods used by Topology to setup the network
+ void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration);
+ void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration);
+ void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration);
+
+private:
+ void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
+
+// Private copy constructor and assignment operator
+ GarnetNetwork_d(const GarnetNetwork_d& obj);
+ GarnetNetwork_d& operator=(const GarnetNetwork_d& obj);
+
+/***********Data Members*************/
+ int m_virtual_networks;
+ int m_nodes;
+ int m_flits_recieved, m_flits_injected;
+ double m_network_latency, m_queueing_latency;
+
+ Vector<bool> m_in_use;
+ Vector<bool> m_ordered;
+
+ Vector<Vector<MessageBuffer*> > m_toNetQueues;
+ Vector<Vector<MessageBuffer*> > m_fromNetQueues;
+
+ Vector<Router_d *> m_router_ptr_vector; // All Routers in Network
+ Vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network
+ Vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in the network
+ Vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network
+
+ Topology* m_topology_ptr;
+ Time m_ruby_start;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const GarnetNetwork_d& obj);
+
+// ******************* Definitions *******************
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const GarnetNetwork_d& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //GARNETNETWORK_D_H
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.cc
new file mode 100644
index 000000000..0ae32de13
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.cc
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * InputUnit_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+
+InputUnit_d::InputUnit_d(int id, Router_d *router)
+{
+ m_id = id;
+ m_router = router;
+ m_num_vcs = m_router->get_num_vcs();
+
+ m_num_buffer_reads = 0;
+ m_num_buffer_writes = 0;
+
+ creditQueue = new flitBuffer_d();
+ // Instantiating the virtual channels
+ m_vcs.setSize(m_num_vcs);
+ for(int i=0; i < m_num_vcs; i++)
+ {
+ m_vcs[i] = new VirtualChannel_d(i);
+ }
+}
+
+InputUnit_d::~InputUnit_d()
+{
+ delete creditQueue;
+ m_vcs.deletePointers();
+}
+
+void InputUnit_d::wakeup()
+{
+ flit_d *t_flit;
+ if(m_in_link->isReady())
+ {
+ t_flit = m_in_link->consumeLink();
+ int vc = t_flit->get_vc();
+ if((t_flit->get_type() == HEAD_) || (t_flit->get_type() == HEAD_TAIL_))
+ {
+ assert(m_vcs[vc]->get_state() == IDLE_);
+ m_router->route_req(t_flit, this, vc); // Do the route computation for this vc
+ m_vcs[vc]->set_enqueue_time(g_eventQueue_ptr->getTime());
+ }
+ else
+ {
+ t_flit->advance_stage(SA_);
+ m_router->swarb_req();
+ }
+ m_vcs[vc]->insertFlit(t_flit); // write flit into input buffer
+ m_num_buffer_writes++;
+ m_num_buffer_reads++; // same as read because any flit that is written will be read only once
+ }
+}
+
+
+void InputUnit_d::printConfig(ostream& out)
+{
+ out << endl;
+ out << "InputUnit Configuration" << endl;
+ out << "---------------------" << endl;
+ out << "id = " << m_id << endl;
+ out << "In link is " << m_in_link->get_id() << endl;
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh
new file mode 100644
index 000000000..fafa29135
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * InputUnit_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef INPUT_UNIT_D_H
+#define INPUT_UNIT_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/gems_common/Vector.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh"
+
+class Router_d;
+
+class InputUnit_d : public Consumer {
+public:
+ InputUnit_d(int id, Router_d *router);
+ ~InputUnit_d();
+
+ void wakeup();
+ void printConfig(ostream& out);
+ flitBuffer_d* getCreditQueue() { return creditQueue; }
+ void print(ostream& out) const {};
+
+ inline int get_inlink_id()
+ {
+ return m_in_link->get_id();
+ }
+
+ inline void set_vc_state(VC_state_type state, int vc)
+ {
+ m_vcs[vc]->set_state(state);
+ }
+ inline void set_enqueue_time(int invc, Time time)
+ {
+ m_vcs[invc]->set_enqueue_time(time);
+ }
+ inline Time get_enqueue_time(int invc)
+ {
+ return m_vcs[invc]->get_enqueue_time();
+ }
+ inline void update_credit(int in_vc, int credit)
+ {
+ m_vcs[in_vc]->update_credit(credit);
+ }
+
+ inline bool has_credits(int vc)
+ {
+ return m_vcs[vc]->has_credits();
+ }
+
+ inline void increment_credit(int in_vc, bool free_signal)
+ {
+ flit_d *t_flit = new flit_d(in_vc, free_signal);
+ creditQueue->insert(t_flit);
+ g_eventQueue_ptr->scheduleEvent(m_credit_link, 1);
+ }
+
+ inline int get_outvc(int invc)
+ {
+ return m_vcs[invc]->get_outvc();
+ }
+
+ inline void updateRoute(int vc, int outport)
+ {
+ m_vcs[vc]->set_outport(outport);
+ m_vcs[vc]->set_state(VC_AB_);
+ }
+
+ inline void grant_vc(int in_vc, int out_vc)
+ {
+ m_vcs[in_vc]->grant_vc(out_vc);
+ }
+
+ inline flit_d* peekTopFlit(int vc)
+ {
+ return m_vcs[vc]->peekTopFlit();
+ }
+
+ inline flit_d* getTopFlit(int vc)
+ {
+ return m_vcs[vc]->getTopFlit();
+ }
+
+ inline bool need_stage(int vc, VC_state_type state, flit_stage stage)
+ {
+ return m_vcs[vc]->need_stage(state, stage);
+ }
+
+ inline bool need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage)
+ {
+ return m_vcs[vc]->need_stage_nextcycle(state, stage);
+ }
+
+ inline bool isReady(int invc)
+ {
+ return m_vcs[invc]->isReady();
+ }
+
+ inline int get_route(int vc)
+ {
+ return m_vcs[vc]->get_route();
+ }
+ inline void set_in_link(NetworkLink_d *link)
+ {
+ m_in_link = link;
+ }
+
+ inline void set_credit_link(CreditLink_d *credit_link)
+ {
+ m_credit_link = credit_link;
+ }
+
+ inline double get_buf_read_count()
+ {
+ return m_num_buffer_reads;
+ }
+
+ inline double get_buf_write_count()
+ {
+ return m_num_buffer_writes;
+ }
+
+private:
+ int m_id;
+ int m_num_vcs;
+ double m_num_buffer_writes, m_num_buffer_reads;
+
+ Router_d *m_router;
+ NetworkLink_d *m_in_link;
+ CreditLink_d *m_credit_link;
+ flitBuffer_d *creditQueue;
+
+ // Virtual channels
+ Vector<VirtualChannel_d *> m_vcs; // [vc]
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh
new file mode 100644
index 000000000..4cc73a3d4
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * NetworkHeader.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef NETWORK_HEADER_H
+#define NETWORK_HEADER_H
+
+#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/system/NodeID.hh"
+
+using namespace std;
+using namespace __gnu_cxx;
+
+enum flit_type {HEAD_, BODY_, TAIL_, HEAD_TAIL_, NUM_FLIT_TYPE_};
+enum VC_state_type {IDLE_, VC_AB_, ACTIVE_, NUM_VC_STATE_TYPE_};
+enum flit_stage {I_, VA_, SA_, ST_, LT_, NUM_FLIT_STAGE_};
+
+#define NETCONFIG_DEFAULTS "netconfig.defaults"
+
+#define INFINITE_ 10000
+
+#endif
+
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.cc
new file mode 100644
index 000000000..e36504356
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.cc
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * NetworkInterface_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh"
+#include "mem/ruby/buffers/MessageBuffer.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+#include "mem/ruby/slicc_interface/NetworkMessage.hh"
+
+NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d *network_ptr)
+{
+ m_id = id;
+ m_net_ptr = network_ptr;
+ m_virtual_networks = virtual_networks;
+ m_vc_per_vnet = NetworkConfig::getVCsPerClass();
+ m_num_vcs = m_vc_per_vnet*m_virtual_networks;
+
+ m_vc_round_robin = 0;
+ m_ni_buffers.setSize(m_num_vcs);
+ m_ni_enqueue_time.setSize(m_num_vcs);
+ inNode_ptr.setSize(m_virtual_networks);
+ outNode_ptr.setSize(m_virtual_networks);
+ creditQueue = new flitBuffer_d();
+
+ for(int i =0; i < m_num_vcs; i++)
+ {
+ m_ni_buffers[i] = new flitBuffer_d(); // instantiating the NI flit buffers
+ m_ni_enqueue_time[i] = INFINITE_;
+ }
+ m_vc_allocator.setSize(m_virtual_networks); // 1 allocator per virtual net
+ for(int i = 0; i < m_virtual_networks; i++)
+ {
+ m_vc_allocator[i] = 0;
+ }
+
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ m_out_vc_state.insertAtBottom(new OutVcState_d(i));
+ m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
+ }
+}
+
+NetworkInterface_d::~NetworkInterface_d()
+{
+ m_out_vc_state.deletePointers();
+ m_ni_buffers.deletePointers();
+ delete creditQueue;
+ delete outSrcQueue;
+}
+
+void NetworkInterface_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link)
+{
+ inNetLink = in_link;
+ in_link->setLinkConsumer(this);
+ m_ni_credit_link = credit_link;
+ credit_link->setSourceQueue(creditQueue);
+}
+
+void NetworkInterface_d::addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link)
+{
+ m_credit_link = credit_link;
+ credit_link->setLinkConsumer(this);
+
+ outNetLink = out_link;
+ outSrcQueue = new flitBuffer_d();
+ out_link->setSourceQueue(outSrcQueue);
+}
+
+void NetworkInterface_d::addNode(Vector<MessageBuffer*>& in, Vector<MessageBuffer*>& out)
+{
+ ASSERT(in.size() == m_virtual_networks);
+ inNode_ptr = in;
+ outNode_ptr = out;
+ for (int j = 0; j < m_virtual_networks; j++)
+ {
+ inNode_ptr[j]->setConsumer(this); // So that protocol injects messages into the NI
+ }
+}
+
+bool NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet)
+{
+ NetworkMessage *net_msg_ptr = dynamic_cast<NetworkMessage*>(msg_ptr.ref());
+ NetDest net_msg_dest = net_msg_ptr->getInternalDestination();
+ Vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message.
+
+ int num_flits = (int) ceil((double) MessageSizeType_to_int(net_msg_ptr->getMessageSize())/NetworkConfig::getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size
+
+ for(int ctr = 0; ctr < dest_nodes.size(); ctr++) // loop because we will be converting all multicast messages into unicast messages
+ {
+ int vc = calculateVC(vnet); // this will return a free output virtual channel
+ if(vc == -1)
+ {
+ return false ;
+ }
+ MsgPtr new_msg_ptr = *(msg_ptr.ref());
+ NodeID destID = dest_nodes[ctr];
+
+ NetworkMessage *new_net_msg_ptr = dynamic_cast<NetworkMessage*>(new_msg_ptr.ref());
+ if(dest_nodes.size() > 1)
+ {
+ NetDest personal_dest;
+ for(int m = 0; m < (int) MachineType_NUM; m++)
+ {
+ if((destID >= MachineType_base_number((MachineType) m)) && destID < MachineType_base_number((MachineType) (m+1)))
+ {
+ // calculating the NetDest associated with this destination ID
+ personal_dest.clear();
+ personal_dest.add((MachineID) {(MachineType) m, (destID - MachineType_base_number((MachineType) m))});
+ new_net_msg_ptr->getInternalDestination() = personal_dest;
+ break;
+ }
+ }
+ net_msg_dest.removeNetDest(personal_dest);
+ net_msg_ptr->getInternalDestination().removeNetDest(personal_dest); // removing the destination from the original message to reflect that a message with this particular destination has been flitisized and an output vc is acquired
+ }
+ for(int i = 0; i < num_flits; i++)
+ {
+ m_net_ptr->increment_injected_flits();
+ flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr);
+ fl->set_delay(g_eventQueue_ptr->getTime() - (msg_ptr.ref())->getTime());
+ m_ni_buffers[vc]->insert(fl);
+ }
+ m_ni_enqueue_time[vc] = g_eventQueue_ptr->getTime();
+ m_out_vc_state[vc]->setState(ACTIVE_, g_eventQueue_ptr->getTime());
+ }
+ return true ;
+}
+
+// Looking for a free output vc
+int NetworkInterface_d::calculateVC(int vnet)
+{
+ for(int i = 0; i < m_vc_per_vnet; i++)
+ {
+ int delta = m_vc_allocator[vnet];
+ m_vc_allocator[vnet]++;
+ if(m_vc_allocator[vnet] == m_vc_per_vnet)
+ m_vc_allocator[vnet] = 0;
+
+ if(m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(IDLE_, g_eventQueue_ptr->getTime()))
+ {
+ return ((vnet*m_vc_per_vnet) + delta);
+ }
+ }
+ return -1;
+}
+
+/*
+ * The NI wakeup checks whether there are any ready messages in the protocol buffer. If yes,
+ * it picks that up, flitisizes it into a number of flits and puts it into an output buffer
+ * and schedules the output link. On a wakeup it also checks whether there are flits in the
+ * input link. If yes, it picks them up and if the flit is a tail, the NI inserts the
+ * corresponding message into the protocol buffer. It also checks for credits being sent
+ * by the downstream router.
+ */
+
+void NetworkInterface_d::wakeup()
+{
+ DEBUG_EXPR(NETWORK_COMP, MedPrio, m_id);
+ DEBUG_MSG(NETWORK_COMP, MedPrio, "NI WOKE UP");
+ DEBUG_EXPR(NETWORK_COMP, MedPrio, g_eventQueue_ptr->getTime());
+
+ MsgPtr msg_ptr;
+
+ //Checking for messages coming from the protocol
+ for (int vnet = 0; vnet < m_virtual_networks; vnet++) // can pick up a message/cycle for each virtual net
+ {
+ while(inNode_ptr[vnet]->isReady()) // Is there a message waiting
+ {
+ msg_ptr = inNode_ptr[vnet]->peekMsgPtr();
+ if(flitisizeMessage(msg_ptr, vnet))
+ {
+ inNode_ptr[vnet]->pop();
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ scheduleOutputLink();
+ checkReschedule();
+
+/*********** Picking messages destined for this NI **********/
+
+ if(inNetLink->isReady())
+ {
+ flit_d *t_flit = inNetLink->consumeLink();
+ bool free_signal = false;
+ if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_)
+ {
+ free_signal = true;
+ if(!NetworkConfig::isNetworkTesting()) // When we are doing network only testing, the messages do not have to be buffered into the message buffers
+ {
+ outNode_ptr[t_flit->get_vnet()]->enqueue(t_flit->get_msg_ptr(), 1); // enqueueing for protocol buffer. This is not required when doing network only testing
+ }
+ }
+ flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal); // Simply send a credit back since we are not buddering this flit in the NI
+ creditQueue->insert(credit_flit);
+ g_eventQueue_ptr->scheduleEvent(m_ni_credit_link, 1);
+
+ m_net_ptr->increment_recieved_flits();
+ int network_delay = g_eventQueue_ptr->getTime() - t_flit->get_enqueue_time();
+ int queueing_delay = t_flit->get_delay();
+ m_net_ptr->increment_network_latency(network_delay);
+ m_net_ptr->increment_queueing_latency(queueing_delay);
+ delete t_flit;
+ }
+
+ /****************** Checking for credit link *******/
+
+ if(m_credit_link->isReady())
+ {
+ 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_eventQueue_ptr->getTime());
+ }
+ delete t_flit;
+ }
+}
+
+// This function look at the NI buffers and if some buffer has flits which are ready to traverse the link in the next cycle and also the downstream output vc associated with this flit has buffers left, the link is scheduled for the next cycle
+
+void NetworkInterface_d::scheduleOutputLink()
+{
+ int vc = m_vc_round_robin;
+ m_vc_round_robin++;
+ if(m_vc_round_robin == m_num_vcs)
+ m_vc_round_robin = 0;
+
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ vc++;
+ if(vc == m_num_vcs)
+ vc = 0;
+ if(m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) // models buffer backpressure
+ {
+ bool is_candidate_vc = true;
+ int t_vnet = get_vnet(vc);
+ int vc_base = t_vnet * m_vc_per_vnet;
+
+ if(m_net_ptr->isVNetOrdered(t_vnet))
+ {
+ 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_enqueue_time[t_vc] < m_ni_enqueue_time[vc])
+ {
+ is_candidate_vc = false;
+ break;
+ }
+ }
+ }
+ }
+ if(!is_candidate_vc)
+ continue;
+
+ m_out_vc_state[vc]->decrement_credit();
+ flit_d *t_flit = m_ni_buffers[vc]->getTopFlit(); // Just removing the flit
+ t_flit->set_time(g_eventQueue_ptr->getTime() + 1);
+ outSrcQueue->insert(t_flit);
+ g_eventQueue_ptr->scheduleEvent(outNetLink, 1); // schedule the out link
+
+ if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_)
+ {
+ m_ni_enqueue_time[vc] = INFINITE_;
+ }
+ return;
+ }
+ }
+}
+
+int NetworkInterface_d::get_vnet(int vc)
+{
+ for(int i = 0; i < NUMBER_OF_VIRTUAL_NETWORKS; i++)
+ {
+ if(vc >= (i*m_vc_per_vnet) && vc < ((i+1)*m_vc_per_vnet))
+ {
+ return i;
+ }
+ }
+ ERROR_MSG("Could not determine vc");
+ return -1;
+}
+
+void NetworkInterface_d::checkReschedule()
+{
+ for(int vnet = 0; vnet < m_virtual_networks; vnet++)
+ {
+ if(inNode_ptr[vnet]->isReady()) // Is there a message waiting
+ {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ return;
+ }
+ }
+ for(int vc = 0; vc < m_num_vcs; vc++)
+ {
+ if(m_ni_buffers[vc]->isReadyForNext())
+ {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ return;
+ }
+ }
+}
+
+void NetworkInterface_d::printConfig(ostream& out) const
+{
+ out << "[Network Interface " << m_id << "] - ";
+ out << "[inLink " << inNetLink->get_id() << "] - ";
+ out << "[outLink " << outNetLink->get_id() << "]" << endl;
+}
+
+void NetworkInterface_d::print(ostream& out) const
+{
+ out << "[Network Interface]";
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh
new file mode 100644
index 000000000..00aaff8d3
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * NetworkInterface_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef NET_INTERFACE_D_H
+#define NET_INTERFACE_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
+#include "mem/gems_common/Vector.hh"
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/slicc_interface/Message.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh"
+
+class NetworkMessage;
+class MessageBuffer;
+class flitBuffer_d;
+
+class NetworkInterface_d : public Consumer {
+public:
+ NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d* network_ptr);
+
+ ~NetworkInterface_d();
+
+ void addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link);
+ void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link);
+
+ void wakeup();
+ void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode);
+ void printConfig(ostream& out) const;
+ void print(ostream& out) const;
+ int get_vnet(int vc);
+
+private:
+/**************Data Members*************/
+ GarnetNetwork_d *m_net_ptr;
+ int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
+ NodeID m_id;
+ Vector<OutVcState_d *> m_out_vc_state;
+ Vector<int > m_vc_allocator;
+ int m_vc_round_robin; // For round robin scheduling
+ flitBuffer_d *outSrcQueue; // For modelling link contention
+ flitBuffer_d *creditQueue;
+
+ NetworkLink_d *inNetLink;
+ NetworkLink_d *outNetLink;
+ CreditLink_d *m_credit_link;
+ CreditLink_d *m_ni_credit_link;
+
+ // Input Flit Buffers
+ Vector<flitBuffer_d *> m_ni_buffers; // The flit buffers which will serve the Consumer
+ Vector<Time > m_ni_enqueue_time;
+
+ Vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol
+ Vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol
+
+ bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
+ int calculateVC(int vnet);
+ void scheduleOutputLink();
+ void checkReschedule();
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.cc
new file mode 100644
index 000000000..931f0f3a7
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.cc
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * NetworkLink_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
+
+NetworkLink_d::NetworkLink_d(int id)
+{
+ m_id = id;
+ m_latency = 1;
+ m_flit_width = NetworkConfig::getFlitSize();
+
+ linkBuffer = new flitBuffer_d();
+ m_link_utilized = 0;
+ m_vc_load.setSize(NetworkConfig::getVCsPerClass()*NUMBER_OF_VIRTUAL_NETWORKS);
+
+ for(int i = 0; i < NetworkConfig::getVCsPerClass()*NUMBER_OF_VIRTUAL_NETWORKS; i++)
+ m_vc_load[i] = 0;
+}
+
+NetworkLink_d::NetworkLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr)
+{
+ m_net_ptr = net_ptr;
+ m_id = id;
+ m_latency = link_latency;
+ linkBuffer = new flitBuffer_d();
+ m_link_utilized = 0;
+ m_vc_load.setSize(NetworkConfig::getVCsPerClass()*NUMBER_OF_VIRTUAL_NETWORKS);
+
+ for(int i = 0; i < NetworkConfig::getVCsPerClass()*NUMBER_OF_VIRTUAL_NETWORKS; i++)
+ m_vc_load[i] = 0;
+}
+
+NetworkLink_d::~NetworkLink_d()
+{
+ delete linkBuffer;
+}
+
+void NetworkLink_d::setLinkConsumer(Consumer *consumer)
+{
+ link_consumer = consumer;
+}
+
+void NetworkLink_d::setSourceQueue(flitBuffer_d *srcQueue)
+{
+ link_srcQueue = srcQueue;
+}
+
+void NetworkLink_d::wakeup()
+{
+ if(link_srcQueue->isReady())
+ {
+ flit_d *t_flit = link_srcQueue->getTopFlit();
+ t_flit->set_time(g_eventQueue_ptr->getTime() + m_latency);
+ linkBuffer->insert(t_flit);
+ g_eventQueue_ptr->scheduleEvent(link_consumer, m_latency);
+ m_link_utilized++;
+ m_vc_load[t_flit->get_vc()]++;
+ }
+}
+
+Vector<int> NetworkLink_d::getVcLoad()
+{
+ return m_vc_load;
+}
+
+int NetworkLink_d::getLinkUtilization()
+{
+ return m_link_utilized;
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh
new file mode 100644
index 000000000..28b613faa
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * NetworkLink_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef NETWORK_LINK_D_H
+#define NETWORK_LINK_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+#include "mem/gems_common/PrioHeap.hh"
+#include "mem/ruby/network/orion/power_bus.hh"
+
+class GarnetNetwork_d;
+
+class NetworkLink_d : public Consumer {
+public:
+ NetworkLink_d(int id);
+ ~NetworkLink_d();
+
+ NetworkLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr);
+ void setLinkConsumer(Consumer *consumer);
+ void setSourceQueue(flitBuffer_d *srcQueue);
+ void print(ostream& out) const{}
+ int getLinkUtilization();
+ Vector<int> getVcLoad();
+ int get_id(){return m_id;}
+ void wakeup();
+
+ double calculate_offline_power(power_bus*);
+ double calculate_power();
+
+ inline bool isReady()
+ {
+ return linkBuffer->isReady();
+ }
+ inline flit_d* peekLink()
+ {
+ return linkBuffer->peekTopFlit();
+ }
+ inline flit_d* consumeLink()
+ {
+ return linkBuffer->getTopFlit();
+ }
+
+protected:
+ int m_id;
+ int m_latency;
+ GarnetNetwork_d *m_net_ptr;
+
+ flitBuffer_d *linkBuffer;
+ Consumer *link_consumer;
+ flitBuffer_d *link_srcQueue;
+ int m_link_utilized;
+ Vector<int > m_vc_load;
+ int m_flit_width;
+};
+
+#endif
+
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.cc
new file mode 100644
index 000000000..4fd040099
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.cc
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * OutVCState_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh"
+#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh"
+#include "mem/ruby/eventqueue/RubyEventQueue.hh"
+
+OutVcState_d::OutVcState_d(int id)
+{
+ m_id = id;
+ m_vc_state = IDLE_;
+ m_time = g_eventQueue_ptr->getTime();
+ m_credit_count = NetworkConfig::getBufferSize();
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh
new file mode 100644
index 000000000..0bb3d8ced
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * OutVCState_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef OUT_VC_STATE_D_H
+#define OUT_VC_STATE_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+
+class OutVcState_d {
+public:
+ OutVcState_d(int id);
+
+ int get_inport() {return m_in_port; }
+ int get_invc() { return m_in_vc; }
+ int get_credit_count() {return m_credit_count; }
+ void set_inport(int port) {m_in_port = port; }
+ void set_invc(int vc) {m_in_vc = vc; }
+
+ inline bool isInState(VC_state_type state, Time request_time)
+ {
+ return ((m_vc_state == state) && (request_time >= m_time) );
+ }
+
+ inline void setState(VC_state_type state, Time time)
+ {
+ m_vc_state = state;
+ m_time = time;
+ }
+
+ inline bool has_credits()
+ {
+ return (m_credit_count > 0);
+ }
+
+ inline void increment_credit()
+ {
+ m_credit_count++;
+ }
+
+ inline void decrement_credit()
+ {
+ m_credit_count--;
+ }
+
+private:
+ int m_id ;
+ Time m_time;
+ VC_state_type m_vc_state;
+ int m_in_port;
+ int m_in_vc;
+ int m_credit_count;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.cc
new file mode 100644
index 000000000..1b8b8097b
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.cc
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * OutputUnit_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh"
+
+OutputUnit_d::OutputUnit_d(int id, Router_d *router)
+{
+ m_id = id;
+ m_router = router;
+ m_num_vcs = m_router->get_num_vcs();
+ m_out_buffer = new flitBuffer_d();
+
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ m_outvc_state.insertAtBottom(new OutVcState_d(i));
+ }
+}
+
+OutputUnit_d::~OutputUnit_d()
+{
+ delete m_out_buffer;
+ m_outvc_state.deletePointers();
+}
+
+void OutputUnit_d::decrement_credit(int out_vc)
+{
+ m_outvc_state[out_vc]->decrement_credit();
+ m_router->update_incredit(m_outvc_state[out_vc]->get_inport(), m_outvc_state[out_vc]->get_invc(), m_outvc_state[out_vc]->get_credit_count());
+}
+
+void OutputUnit_d::wakeup()
+{
+ if(m_credit_link->isReady())
+ {
+ flit_d *t_flit = m_credit_link->consumeLink();
+ int out_vc = t_flit->get_vc();
+ m_outvc_state[out_vc]->increment_credit();
+ m_router->update_incredit(m_outvc_state[out_vc]->get_inport(), m_outvc_state[out_vc]->get_invc(), m_outvc_state[out_vc]->get_credit_count());
+
+ if(t_flit->is_free_signal())
+ set_vc_state(IDLE_, out_vc);
+
+ delete t_flit;
+ }
+}
+
+flitBuffer_d* OutputUnit_d::getOutQueue()
+{
+ return m_out_buffer;
+}
+
+void OutputUnit_d::set_out_link(NetworkLink_d *link)
+{
+ m_out_link = link;
+}
+
+void OutputUnit_d::set_credit_link(CreditLink_d *credit_link)
+{
+ m_credit_link = credit_link;
+}
+
+void OutputUnit_d::update_vc(int vc, int in_port, int in_vc)
+{
+ m_outvc_state[vc]->setState(ACTIVE_, g_eventQueue_ptr->getTime() + 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, m_outvc_state[vc]->get_credit_count());
+}
+
+void OutputUnit_d::printConfig(ostream& out)
+{
+ out << endl;
+ out << "OutputUnit Configuration" << endl;
+ out << "---------------------" << endl;
+ out << "id = " << m_id << endl;
+ out << "Out link is " << m_out_link->get_id() << endl;
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh
new file mode 100644
index 000000000..62de62a4f
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * OutputUnit_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef OUTPUT_UNIT_D_H
+#define OUTPUT_UNIT_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh"
+
+class Router_d;
+
+class OutputUnit_d : public Consumer {
+public:
+ OutputUnit_d(int id, Router_d *router);
+ ~OutputUnit_d();
+ void set_out_link(NetworkLink_d *link);
+ void set_credit_link(CreditLink_d *credit_link);
+ void wakeup();
+ flitBuffer_d* getOutQueue();
+ void printConfig(ostream& out);
+ void update_vc(int vc, int in_port, int in_vc);
+ void print(ostream& out) const {};
+ int get_credit_cnt(int vc) { return m_outvc_state[vc]->get_credit_count(); }
+ void decrement_credit(int out_vc);
+
+ inline int get_outlink_id()
+ {
+ return m_out_link->get_id();
+ }
+
+ inline void set_vc_state(VC_state_type state, int vc)
+ {
+ m_outvc_state[vc]->setState(state, g_eventQueue_ptr->getTime() + 1);
+ }
+ inline bool is_vc_idle(int vc)
+ {
+ return (m_outvc_state[vc]->isInState(IDLE_, g_eventQueue_ptr->getTime()) );
+ }
+ inline void insert_flit(flit_d *t_flit)
+ {
+ m_out_buffer->insert(t_flit);
+ g_eventQueue_ptr->scheduleEvent(m_out_link, 1);
+ }
+
+
+
+private:
+ int m_id;
+ int m_num_vcs;
+ Router_d *m_router;
+ NetworkLink_d *m_out_link;
+ CreditLink_d *m_credit_link;
+
+ flitBuffer_d *m_out_buffer; // This is for the network link to consume
+ Vector<OutVcState_d *> m_outvc_state; // vc state of downstream router
+
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/Router_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/Router_d.cc
new file mode 100644
index 000000000..60c9d36a9
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/Router_d.cc
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Router_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh"
+
+Router_d::Router_d(int id, GarnetNetwork_d *network_ptr)
+{
+ m_id = id;
+ m_network_ptr = network_ptr;
+ m_virtual_networks = NUMBER_OF_VIRTUAL_NETWORKS;
+ m_vc_per_vnet = NetworkConfig::getVCsPerClass();
+ m_num_vcs = m_virtual_networks*m_vc_per_vnet;
+ m_flit_width = NetworkConfig::getFlitSize();
+
+ m_routing_unit = new RoutingUnit_d(this);
+ m_vc_alloc = new VCallocator_d(this);
+ m_sw_alloc = new SWallocator_d(this);
+ m_switch = new Switch_d(this);
+
+ m_input_unit.clear();
+ m_output_unit.clear();
+
+ buf_read_count = 0;
+ buf_write_count = 0;
+ crossbar_count = 0;
+ vc_local_arbit_count = 0;
+ vc_global_arbit_count = 0;
+ sw_local_arbit_count = 0;
+ sw_global_arbit_count = 0;
+}
+
+Router_d::~Router_d()
+{
+ m_input_unit.deletePointers();
+ m_output_unit.deletePointers();
+ delete m_routing_unit;
+ delete m_vc_alloc;
+ delete m_sw_alloc;
+ delete m_switch;
+}
+
+void Router_d::init()
+{
+ m_vc_alloc->init();
+ m_sw_alloc->init();
+ m_switch->init();
+}
+
+void Router_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link)
+{
+ int port_num = m_input_unit.size();
+ InputUnit_d *input_unit = new InputUnit_d(port_num, this);
+
+ input_unit->set_in_link(in_link);
+ input_unit->set_credit_link(credit_link);
+ in_link->setLinkConsumer(input_unit);
+ credit_link->setSourceQueue(input_unit->getCreditQueue());
+
+ m_input_unit.insertAtBottom(input_unit);
+}
+
+void Router_d::addOutPort(NetworkLink_d *out_link, const NetDest& routing_table_entry, int link_weight, CreditLink_d *credit_link)
+{
+ int port_num = m_output_unit.size();
+ OutputUnit_d *output_unit = new OutputUnit_d(port_num, this);
+
+ output_unit->set_out_link(out_link);
+ output_unit->set_credit_link(credit_link);
+ credit_link->setLinkConsumer(output_unit);
+ out_link->setSourceQueue(output_unit->getOutQueue());
+
+ m_output_unit.insertAtBottom(output_unit);
+
+ m_routing_unit->addRoute(routing_table_entry);
+ m_routing_unit->addWeight(link_weight);
+}
+
+void Router_d::route_req(flit_d *t_flit, InputUnit_d *in_unit, int invc)
+{
+ m_routing_unit->RC_stage(t_flit, in_unit, invc);
+}
+void Router_d::vcarb_req()
+{
+ g_eventQueue_ptr->scheduleEvent(m_vc_alloc, 1);
+}
+void Router_d::swarb_req()
+{
+ g_eventQueue_ptr->scheduleEvent(m_sw_alloc, 1);
+}
+void Router_d::update_incredit(int in_port, int in_vc, int credit)
+{
+ m_input_unit[in_port]->update_credit(in_vc, credit);
+}
+void Router_d::update_sw_winner(int inport, flit_d *t_flit)
+{
+ m_switch->update_sw_winner(inport, t_flit);
+ g_eventQueue_ptr->scheduleEvent(m_switch, 1);
+}
+
+void Router_d::calculate_performance_numbers()
+{
+ for(int i = 0; i < m_input_unit.size(); i++)
+ {
+ buf_read_count += m_input_unit[i]->get_buf_read_count();
+ buf_write_count += m_input_unit[i]->get_buf_write_count();
+ }
+ crossbar_count = m_switch->get_crossbar_count();
+ vc_local_arbit_count = m_vc_alloc->get_local_arbit_count();
+ vc_global_arbit_count = m_vc_alloc->get_global_arbit_count();
+ sw_local_arbit_count = m_sw_alloc->get_local_arbit_count();
+ sw_global_arbit_count = m_sw_alloc->get_global_arbit_count();
+}
+
+void Router_d::printConfig(ostream& out)
+{
+ out << "[Router " << m_id << "] :: " << endl;
+ out << "[inLink - ";
+ for(int i = 0;i < m_input_unit.size(); i++)
+ out << m_input_unit[i]->get_inlink_id() << " - ";
+ out << "]" << endl;
+ out << "[outLink - ";
+ for(int i = 0;i < m_output_unit.size(); i++)
+ out << m_output_unit[i]->get_outlink_id() << " - ";
+ out << "]" << endl;
+}
+
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/Router_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/Router_d.hh
new file mode 100644
index 000000000..87b3f38e2
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/Router_d.hh
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Router_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+#ifndef ROUTER_D_H
+#define ROUTER_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/gems_common/Vector.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flit_d.hh"
+#include "mem/ruby/common/NetDest.hh"
+#include "mem/ruby/network/orion/power_router_init.hh"
+
+class GarnetNetwork_d;
+class NetworkLink_d;
+class CreditLink_d;
+class InputUnit_d;
+class OutputUnit_d;
+class RoutingUnit_d;
+class VCallocator_d;
+class SWallocator_d;
+class Switch_d;
+
+class Router_d {
+public:
+ Router_d(int id, GarnetNetwork_d *network_ptr);
+
+ ~Router_d();
+
+ void init();
+ void addInPort(NetworkLink_d *link, CreditLink_d *credit_link);
+ void addOutPort(NetworkLink_d *link, const NetDest& routing_table_entry, int link_weight, CreditLink_d *credit_link);
+ int get_num_vcs() { return m_num_vcs; }
+ int get_vc_per_vnet() {return m_vc_per_vnet; }
+ int get_num_inports() { return m_input_unit.size(); }
+ int get_num_outports() { return m_output_unit.size(); }
+ void printConfig(ostream& out);
+ int get_id() { return m_id; }
+ GarnetNetwork_d* get_net_ptr() { return m_network_ptr; }
+
+ Vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; }
+ Vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; }
+
+ void update_sw_winner(int inport, flit_d *t_flit);
+ void update_incredit(int in_port, int in_vc, int credit);
+ void route_req(flit_d *t_flit, InputUnit_d* in_unit, int invc);
+ void vcarb_req();
+ void swarb_req();
+
+ void power_router_initialize(power_router *router, power_router_info *info);
+ double calculate_power();
+ double calculate_offline_power(power_router*, power_router_info*);
+ void calculate_performance_numbers();
+
+private:
+ int m_id;
+ int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
+ GarnetNetwork_d *m_network_ptr;
+ int m_flit_width;
+
+ double buf_read_count, buf_write_count, crossbar_count, vc_local_arbit_count, vc_global_arbit_count, sw_local_arbit_count, sw_global_arbit_count;
+
+ Vector<InputUnit_d *> m_input_unit;
+ Vector<OutputUnit_d *> m_output_unit;
+ RoutingUnit_d *m_routing_unit;
+ VCallocator_d *m_vc_alloc;
+ SWallocator_d *m_sw_alloc;
+ Switch_d *m_switch;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.cc
new file mode 100644
index 000000000..488741055
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.cc
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Routingunit_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh"
+#include "mem/ruby/slicc_interface/NetworkMessage.hh"
+
+RoutingUnit_d::RoutingUnit_d(Router_d *router)
+{
+ m_router = router;
+ m_routing_table.clear();
+ m_weight_table.clear();
+}
+
+void RoutingUnit_d::addRoute(const NetDest& routing_table_entry)
+{
+ m_routing_table.insertAtBottom(routing_table_entry);
+}
+
+void RoutingUnit_d::addWeight(int link_weight)
+{
+ m_weight_table.insertAtBottom(link_weight);
+}
+
+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_);
+ m_router->vcarb_req();
+}
+
+int RoutingUnit_d::routeCompute(flit_d *t_flit)
+{
+ MsgPtr msg_ptr = t_flit->get_msg_ptr();
+ NetworkMessage* net_msg_ptr = NULL;
+ net_msg_ptr = dynamic_cast<NetworkMessage*>(msg_ptr.ref());
+ NetDest msg_destination = net_msg_ptr->getInternalDestination();
+
+ int output_link = -1;
+ int min_weight = INFINITE_;
+
+ for(int link = 0; link < m_routing_table.size(); link++)
+ {
+ if (msg_destination.intersectionIsNotEmpty(m_routing_table[link]))
+ {
+ if(m_weight_table[link] >= min_weight)
+ continue;
+ output_link = link;
+ min_weight = m_weight_table[link];
+ }
+ }
+ if(output_link == -1)
+ {
+ ERROR_MSG("Fatal Error:: No Route exists from this Router.");
+ exit(0);
+ }
+ return output_link;
+
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh
new file mode 100644
index 000000000..093fd7abe
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Routerunit_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef ROUTING_UNIT_D_H
+#define ROUTING_UNIT_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flit_d.hh"
+#include "mem/ruby/common/NetDest.hh"
+
+class InputUnit_d;
+class Router_d;
+
+class RoutingUnit_d {
+public:
+ RoutingUnit_d(Router_d *router);
+ void addRoute(const NetDest& routing_table_entry);
+ int routeCompute(flit_d *t_flit);
+ void addWeight(int link_weight);
+ void RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc);
+
+private:
+ Router_d *m_router;
+ Vector<NetDest > m_routing_table;
+ Vector<int > m_weight_table;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/SConscript b/src/mem/ruby/network/garnet-fixed-pipeline/SConscript
new file mode 100644
index 000000000..0814df2f5
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/SConscript
@@ -0,0 +1,49 @@
+# -*- mode:python -*-
+
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Nathan Binkert
+
+Import('*')
+
+if not env['RUBY']:
+ Return()
+
+Source('GarnetNetwork_d.cc')
+Source('InputUnit_d.cc')
+Source('NetworkInterface_d.cc')
+Source('NetworkLink_d.cc')
+Source('OutVcState_d.cc')
+Source('OutputUnit_d.cc')
+Source('Router_d.cc')
+Source('RoutingUnit_d.cc')
+Source('SWallocator_d.cc')
+Source('Switch_d.cc')
+Source('VCallocator_d.cc')
+Source('VirtualChannel_d.cc')
+Source('flitBuffer_d.cc')
+Source('flit_d.cc')
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.cc
new file mode 100644
index 000000000..02dee31a4
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.cc
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * SWallocator_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
+
+SWallocator_d::SWallocator_d(Router_d *router)
+{
+ m_router = router;
+ m_num_vcs = m_router->get_num_vcs();
+ m_vc_per_vnet = m_router->get_vc_per_vnet();
+
+ m_local_arbiter_activity = 0;
+ m_global_arbiter_activity = 0;
+}
+
+void SWallocator_d::init()
+{
+ m_input_unit = m_router->get_inputUnit_ref();
+ m_output_unit = m_router->get_outputUnit_ref();
+
+ m_num_inports = m_router->get_num_inports();
+ m_num_outports = m_router->get_num_outports();
+ m_round_robin_outport.setSize(m_num_outports);
+ m_round_robin_inport.setSize(m_num_inports);
+ m_port_req.setSize(m_num_outports);
+ m_vc_winners.setSize(m_num_outports);
+
+ for(int i = 0; i < m_num_inports; i++)
+ {
+ m_round_robin_inport[i] = 0;
+ }
+
+ for(int i = 0; i < m_num_outports; i++)
+ {
+ m_port_req[i].setSize(m_num_inports);
+ m_vc_winners[i].setSize(m_num_inports);
+
+ m_round_robin_outport[i] = 0;
+
+ for(int j = 0; j < m_num_inports; j++)
+ {
+ m_port_req[i][j] = false; // [outport][inport]
+ }
+ }
+}
+
+void SWallocator_d::wakeup()
+{
+ arbitrate_inports(); // First stage of allocation
+ arbitrate_outports(); // Second stage of allocation
+
+ clear_request_vector();
+ check_for_wakeup();
+
+}
+
+void SWallocator_d::arbitrate_inports()
+{
+ // First I will do round robin arbitration on a set of input vc requests
+ for(int inport = 0; inport < m_num_inports; inport++)
+ {
+ int invc = m_round_robin_inport[inport];
+ m_round_robin_inport[inport]++;
+
+ if(m_round_robin_inport[inport] >= m_num_vcs)
+ m_round_robin_inport[inport] = 0;
+ for(int j = 0; j < m_num_vcs; j++)
+ {
+ invc++;
+ if(invc >= m_num_vcs)
+ invc = 0;
+ if(m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_) && 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++;
+ m_port_req[outport][inport] = true;
+ m_vc_winners[outport][inport]= invc;
+ break; // got one vc winner for this port
+ }
+ }
+ }
+ }
+}
+
+bool SWallocator_d::is_candidate_inport(int inport, int invc)
+{
+ int outport = m_input_unit[inport]->get_route(invc);
+ int t_enqueue_time = m_input_unit[inport]->get_enqueue_time(invc);
+ int t_vnet = get_vnet(invc);
+ int vc_base = t_vnet*m_vc_per_vnet;
+ 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_) && (m_input_unit[inport]->get_route(temp_vc) == outport) && (m_input_unit[inport]->get_enqueue_time(temp_vc) < t_enqueue_time))
+ {
+ return false;
+ break;
+ }
+ }
+ }
+ return true;
+}
+
+
+void SWallocator_d::arbitrate_outports()
+{
+// now I have a set of input vc requests for output vcs. Again do round robin arbitration on these requests
+ for(int outport = 0; outport < m_num_outports; outport++)
+ {
+ int in_port = m_round_robin_outport[outport];
+ m_round_robin_outport[outport]++;
+
+ if(m_round_robin_outport[outport] >= m_num_outports)
+ m_round_robin_outport[outport] = 0;
+
+ for(int inport = 0; inport < m_num_inports; inport++)
+ {
+ in_port++;
+ if(in_port >= m_num_inports)
+ in_port = 0;
+ if(m_port_req[outport][in_port]) // This Inport has a request this cycle for this port
+ {
+ m_port_req[outport][in_port] = false;
+ int invc = m_vc_winners[outport][in_port];
+ int outvc = m_input_unit[in_port]->get_outvc(invc);
+ flit_d *t_flit = m_input_unit[in_port]->getTopFlit(invc); // removes flit from Input Unit
+ t_flit->advance_stage(ST_);
+ t_flit->set_vc(outvc);
+ t_flit->set_outport(outport);
+ t_flit->set_time(g_eventQueue_ptr->getTime() + 1);
+ m_output_unit[outport]->decrement_credit(outvc);
+ m_router->update_sw_winner(in_port, t_flit);
+ m_global_arbiter_activity++;
+
+ if((t_flit->get_type() == TAIL_) || t_flit->get_type() == HEAD_TAIL_)
+ {
+ m_input_unit[in_port]->increment_credit(invc, true); // Send a credit back along with the information that this VC is not idle
+ assert(m_input_unit[in_port]->isReady(invc) == false); // This Input VC should now be empty
+
+ m_input_unit[in_port]->set_vc_state(IDLE_, invc);
+ m_input_unit[in_port]->set_enqueue_time(invc, INFINITE_);
+ }
+ else
+ {
+ m_input_unit[in_port]->increment_credit(invc, false); // Send a credit back but do not indicate that the VC is idle
+ }
+ break; // got a in request for this outport
+ }
+ }
+ }
+}
+
+void 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_))
+ {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ return;
+ }
+ }
+ }
+}
+
+int SWallocator_d::get_vnet(int invc)
+{
+ for(int i = 0; i < NUMBER_OF_VIRTUAL_NETWORKS; i++)
+ {
+ if(invc >= (i*m_vc_per_vnet) && invc < ((i+1)*m_vc_per_vnet))
+ {
+ return i;
+ }
+ }
+ ERROR_MSG("Could not determine vc");
+ return -1;
+}
+
+void SWallocator_d::clear_request_vector()
+{
+ for(int i = 0; i < m_num_outports; i++)
+ {
+ for(int j = 0; j < m_num_inports; j++)
+ {
+ m_port_req[i][j] = false;
+ }
+ }
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh
new file mode 100644
index 000000000..16485c539
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * SWallocator_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef SW_ALLOCATOR_D_H
+#define SW_ALLOCATOR_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+
+class Router_d;
+class InputUnit_d;
+class OutputUnit_d;
+
+class SWallocator_d : public Consumer {
+public:
+ SWallocator_d(Router_d *router);
+ void wakeup();
+ void init();
+ void clear_request_vector();
+ void check_for_wakeup();
+ int get_vnet (int invc);
+ void print(ostream& out) const {};
+ void arbitrate_inports();
+ void arbitrate_outports();
+ bool is_candidate_inport(int inport, int invc);
+ inline double get_local_arbit_count()
+ {
+ return m_local_arbiter_activity;
+ }
+ inline double get_global_arbit_count()
+ {
+ return m_global_arbiter_activity;
+ }
+
+private:
+ int m_num_inports, m_num_outports;
+ int m_num_vcs, m_vc_per_vnet;
+
+ double m_local_arbiter_activity, m_global_arbiter_activity;
+
+ Router_d *m_router;
+ Vector<int > m_round_robin_outport;
+ Vector<int > m_round_robin_inport;
+ Vector<Vector<bool > > m_port_req;
+ Vector<Vector<int > > m_vc_winners; // a list for each outport
+ Vector<InputUnit_d *> m_input_unit;
+ Vector<OutputUnit_d *> m_output_unit;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.cc
new file mode 100644
index 000000000..e1ca64864
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.cc
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Switch_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh"
+
+Switch_d::Switch_d(Router_d *router)
+{
+ m_router = router;
+ m_num_vcs = m_router->get_num_vcs();
+ m_crossbar_activity = 0;
+}
+
+Switch_d::~Switch_d()
+{
+ m_switch_buffer.deletePointers();
+}
+
+void Switch_d::init()
+{
+ m_output_unit = m_router->get_outputUnit_ref();
+
+ m_num_inports = m_router->get_num_inports();
+ m_switch_buffer.setSize(m_num_inports);
+ for(int i = 0; i < m_num_inports; i++)
+ {
+ m_switch_buffer[i] = new flitBuffer_d();
+ }
+}
+
+void Switch_d::wakeup()
+{
+ DEBUG_MSG(NETWORK_COMP, HighPrio, "Switch woke up");
+ DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime());
+
+ for(int inport = 0; inport < m_num_inports; inport++)
+ {
+ if(!m_switch_buffer[inport]->isReady())
+ continue;
+ flit_d *t_flit = m_switch_buffer[inport]->peekTopFlit();
+ if(t_flit->is_stage(ST_))
+ {
+ int outport = t_flit->get_outport();
+ t_flit->advance_stage(LT_);
+ t_flit->set_time(g_eventQueue_ptr->getTime() + 1);
+ m_output_unit[outport]->insert_flit(t_flit); // This will take care of waking up the Network Link
+ m_switch_buffer[inport]->getTopFlit();
+ m_crossbar_activity++;
+ }
+ }
+ check_for_wakeup();
+}
+
+void Switch_d::check_for_wakeup()
+{
+ for(int inport = 0; inport < m_num_inports; inport++)
+ {
+ if(m_switch_buffer[inport]->isReadyForNext())
+ {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ break;
+ }
+ }
+}
+
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh
new file mode 100644
index 000000000..0b45172b5
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Switch_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef SWITCH_D_H
+#define SWITCH_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+
+class Router_d;
+class OutputUnit_d;
+
+class Switch_d : public Consumer {
+public:
+ Switch_d(Router_d *router);
+ ~Switch_d();
+ void wakeup();
+ void init();
+ void check_for_wakeup();
+ void print(ostream& out) const {};
+ inline void update_sw_winner(int inport, flit_d *t_flit)
+ {
+ m_switch_buffer[inport]->insert(t_flit);
+ }
+ inline double get_crossbar_count()
+ {
+ return m_crossbar_activity;
+ }
+
+
+private:
+ int m_num_vcs;
+ int m_num_inports;
+ double m_crossbar_activity;
+ Router_d *m_router;
+ Vector<flitBuffer_d *> m_switch_buffer;
+ Vector<OutputUnit_d *> m_output_unit;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.cc
new file mode 100644
index 000000000..dc6d170e5
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.cc
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * VCallocator_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/Router_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh"
+
+VCallocator_d::VCallocator_d(Router_d *router)
+{
+ m_router = router;
+ m_num_vcs = m_router->get_num_vcs();
+ m_vc_per_vnet = m_router->get_vc_per_vnet();
+ m_local_arbiter_activity = 0;
+ m_global_arbiter_activity = 0;
+}
+
+void VCallocator_d::init()
+{
+ m_input_unit = m_router->get_inputUnit_ref();
+ m_output_unit = m_router->get_outputUnit_ref();
+
+ m_num_inports = m_router->get_num_inports();
+ m_num_outports = m_router->get_num_outports();
+ m_round_robin_invc.setSize(m_num_inports);
+ m_round_robin_outvc.setSize(m_num_outports);
+ m_outvc_req.setSize(m_num_outports);
+ m_outvc_is_req.setSize(m_num_outports);
+
+ for(int i = 0; i < m_num_inports; i++)
+ {
+ m_round_robin_invc[i].setSize(m_num_vcs);
+
+ for(int j = 0; j < m_num_vcs; j++)
+ {
+ m_round_robin_invc[i][j] = 0;
+ }
+ }
+
+ for(int i = 0; i < m_num_outports; i++)
+ {
+ m_round_robin_outvc[i].setSize(m_num_vcs);
+ m_outvc_req[i].setSize(m_num_vcs);
+ m_outvc_is_req[i].setSize(m_num_vcs);
+
+ for(int j = 0; j < m_num_vcs; j++)
+ {
+ m_round_robin_outvc[i][j].first = 0;
+ m_round_robin_outvc[i][j].second = 0;
+ m_outvc_is_req[i][j] = false;
+
+ m_outvc_req[i][j].setSize(m_num_inports);
+
+ for(int k = 0; k < m_num_inports; k++)
+ {
+ m_outvc_req[i][j][k].setSize(m_num_vcs);
+ for(int l = 0; l < m_num_vcs; l++)
+ {
+ m_outvc_req[i][j][k][l] = false;
+ }
+ }
+ }
+ }
+}
+
+void VCallocator_d::clear_request_vector()
+{
+ for(int i = 0; i < m_num_outports; i++)
+ {
+ for(int j = 0; j < m_num_vcs; j++)
+ {
+ if(!m_outvc_is_req[i][j])
+ continue;
+ m_outvc_is_req[i][j] = false;
+ for(int k = 0; k < m_num_inports; k++)
+ {
+ for(int l = 0; l < m_num_vcs; l++)
+ {
+ m_outvc_req[i][j][k][l] = false;
+ }
+ }
+ }
+ }
+}
+
+void VCallocator_d::wakeup()
+{
+ arbitrate_invcs(); // First stage of allocation
+ arbitrate_outvcs(); // Second stage of allocation
+
+ clear_request_vector();
+ check_for_wakeup();
+}
+
+bool VCallocator_d::is_invc_candidate(int inport_iter, int invc_iter)
+{
+ int outport = m_input_unit[inport_iter]->get_route(invc_iter);
+ int vnet = get_vnet(invc_iter);
+ int t_enqueue_time = m_input_unit[inport_iter]->get_enqueue_time(invc_iter);
+
+ int invc_base = vnet*m_vc_per_vnet;
+
+ 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_) && (m_input_unit[inport_iter]->get_route(temp_vc) == outport) && (m_input_unit[inport_iter]->get_enqueue_time(temp_vc) < t_enqueue_time))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+void VCallocator_d::select_outvc(int inport_iter, int invc_iter)
+{
+ int outport = m_input_unit[inport_iter]->get_route(invc_iter);
+ int vnet = get_vnet(invc_iter);
+ int outvc_base = vnet*m_vc_per_vnet;
+ int num_vcs_per_vnet = m_vc_per_vnet;
+
+ int outvc_offset = m_round_robin_invc[inport_iter][invc_iter];
+ m_round_robin_invc[inport_iter][invc_iter]++;
+
+ if(m_round_robin_invc[inport_iter][invc_iter] >= num_vcs_per_vnet)
+ m_round_robin_invc[inport_iter][invc_iter] = 0;
+
+ for(int outvc_offset_iter = 0; outvc_offset_iter < num_vcs_per_vnet; outvc_offset_iter++)
+ {
+ outvc_offset++;
+ 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))
+ {
+ m_local_arbiter_activity++;
+ m_outvc_req[outport][outvc][inport_iter][invc_iter] = true;
+ if(!m_outvc_is_req[outport][outvc])
+ m_outvc_is_req[outport][outvc] = true;
+ return; // out vc acquired
+ }
+ }
+}
+
+void VCallocator_d::arbitrate_invcs()
+{
+ for(int inport_iter = 0; inport_iter < m_num_inports; inport_iter++)
+ {
+ for(int invc_iter = 0; invc_iter < m_num_vcs; invc_iter++)
+ {
+ if(m_input_unit[inport_iter]->need_stage(invc_iter, VC_AB_, VA_))
+ {
+ if(!is_invc_candidate(inport_iter, invc_iter))
+ continue;
+
+ select_outvc(inport_iter, invc_iter);
+ }
+ }
+ }
+}
+
+void VCallocator_d::arbitrate_outvcs()
+{
+ for(int outport_iter = 0; outport_iter < m_num_outports; outport_iter++)
+ {
+ for(int outvc_iter = 0; outvc_iter < m_num_vcs; outvc_iter++)
+ {
+ if(!m_outvc_is_req[outport_iter][outvc_iter]) // No requests for this outvc in this cycle
+ continue;
+
+ int inport = m_round_robin_outvc[outport_iter][outvc_iter].first;
+ int invc_offset = m_round_robin_outvc[outport_iter][outvc_iter].second;
+ int vnet = get_vnet(outvc_iter);
+ int invc_base = vnet*m_vc_per_vnet;
+ int num_vcs_per_vnet = m_vc_per_vnet;
+
+ m_round_robin_outvc[outport_iter][outvc_iter].second++;
+ if(m_round_robin_outvc[outport_iter][outvc_iter].second >= num_vcs_per_vnet)
+ {
+ m_round_robin_outvc[outport_iter][outvc_iter].second = 0;
+ m_round_robin_outvc[outport_iter][outvc_iter].first++;
+ if(m_round_robin_outvc[outport_iter][outvc_iter].first >= m_num_inports)
+ m_round_robin_outvc[outport_iter][outvc_iter].first = 0;
+ }
+ for(int in_iter = 0; in_iter < m_num_inports*num_vcs_per_vnet; in_iter++)
+ {
+ invc_offset++;
+ if(invc_offset >= num_vcs_per_vnet)
+ {
+ invc_offset = 0;
+ inport++;
+ if(inport >= m_num_inports)
+ inport = 0;
+ }
+ int invc = invc_base + invc_offset;
+ if(m_outvc_req[outport_iter][outvc_iter][inport][invc])
+ {
+ m_global_arbiter_activity++;
+ m_input_unit[inport]->grant_vc(invc, outvc_iter);
+ m_output_unit[outport_iter]->update_vc(outvc_iter, inport, invc);
+ m_router->swarb_req();
+ break;
+ }
+ }
+ }
+ }
+}
+
+int VCallocator_d::get_vnet(int invc)
+{
+ for(int i = 0; i < NUMBER_OF_VIRTUAL_NETWORKS; i++)
+ {
+ if(invc >= (i*m_vc_per_vnet) && invc < ((i+1)*m_vc_per_vnet))
+ {
+ return i;
+ }
+ }
+ ERROR_MSG("Could not determine vc");
+ return -1;
+}
+
+void 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_))
+ {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ return;
+ }
+ }
+ }
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh
new file mode 100644
index 000000000..8b40d602d
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * VCallocator_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef VC_ALLOCATOR_D_H
+#define VC_ALLOCATOR_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+
+class Router_d;
+class InputUnit_d;
+class OutputUnit_d;
+
+class VCallocator_d : public Consumer {
+public:
+ VCallocator_d(Router_d *router);
+ void init();
+ void wakeup();
+ void check_for_wakeup();
+ void clear_request_vector();
+ int get_vnet(int invc);
+ void print(ostream& out) const {};
+ void arbitrate_invcs();
+ void arbitrate_outvcs();
+ bool is_invc_candidate(int inport_iter, int invc_iter);
+ void select_outvc(int inport_iter, int invc_iter);
+ inline double get_local_arbit_count()
+ {
+ return m_local_arbiter_activity;
+ }
+ inline double get_global_arbit_count()
+ {
+ return m_global_arbiter_activity;
+ }
+
+private:
+ int m_num_vcs, m_vc_per_vnet;
+ int m_num_inports;
+ int m_num_outports;
+
+ double m_local_arbiter_activity, m_global_arbiter_activity;
+
+ Router_d *m_router;
+ Vector<Vector <int > > m_round_robin_invc; // First stage of arbitration where all vcs select an output vc to content for
+ Vector<Vector <pair<int, int> > > m_round_robin_outvc; // Arbiter for every output vc
+ Vector<Vector<Vector<Vector<bool > > > > m_outvc_req; // [outport][outvc][inpotr][invc]. set true in the first phase of allocation
+ Vector<Vector<bool > > m_outvc_is_req;
+
+ Vector<InputUnit_d *> m_input_unit ;
+ Vector<OutputUnit_d *> m_output_unit ;
+
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.cc
new file mode 100644
index 000000000..2e4473a29
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.cc
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * VirtualChannel_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh"
+
+VirtualChannel_d::VirtualChannel_d(int id)
+{
+ m_id = id;
+ m_input_buffer = new flitBuffer_d();
+ m_vc_state.first = IDLE_;
+ m_vc_state.second = g_eventQueue_ptr->getTime();
+ m_enqueue_time = INFINITE_;
+}
+
+VirtualChannel_d::~VirtualChannel_d()
+{
+ delete m_input_buffer;
+}
+
+void VirtualChannel_d::set_outport(int outport)
+{
+ route = outport;
+}
+
+void VirtualChannel_d::grant_vc(int out_vc)
+{
+ m_output_vc = out_vc;
+ m_vc_state.first = ACTIVE_;
+ m_vc_state.second = g_eventQueue_ptr->getTime() + 1;
+ flit_d *t_flit = m_input_buffer->peekTopFlit();
+ t_flit->advance_stage(SA_);
+}
+
+bool VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage)
+{
+ if((m_vc_state.first == state) && (g_eventQueue_ptr->getTime() >= m_vc_state.second))
+ {
+ if(m_input_buffer->isReady())
+ {
+ flit_d *t_flit = m_input_buffer->peekTopFlit();
+ return(t_flit->is_stage(stage)) ;
+ }
+ }
+ return false;
+
+}
+
+bool VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage)
+{
+ if((m_vc_state.first == state) && ((g_eventQueue_ptr->getTime()+1) >= m_vc_state.second))
+ {
+ if(m_input_buffer->isReadyForNext())
+ {
+ flit_d *t_flit = m_input_buffer->peekTopFlit();
+ return(t_flit->is_next_stage(stage)) ;
+ }
+ }
+ return false;
+}
+
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh
new file mode 100644
index 000000000..8c32482ea
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * VirtualChannel_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef VIRTUAL_CHANNEL_D_H
+#define VIRTUAL_CHANNEL_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+
+class VirtualChannel_d {
+public:
+ VirtualChannel_d(int id);
+ ~VirtualChannel_d();
+
+ bool need_stage(VC_state_type state, flit_stage stage);
+ bool need_stage_nextcycle(VC_state_type state, flit_stage stage);
+ void set_outport(int outport);
+ void grant_vc(int out_vc);
+
+ inline Time get_enqueue_time()
+ {
+ return m_enqueue_time;
+ }
+
+ inline void set_enqueue_time(Time time)
+ {
+ m_enqueue_time = time;
+ }
+
+ inline VC_state_type get_state()
+ {
+ return m_vc_state.first;
+ }
+ inline int get_outvc()
+ {
+ return m_output_vc;
+ }
+ inline bool isReady()
+ {
+ return m_input_buffer->isReady();
+ }
+ inline bool has_credits()
+ {
+ return (m_credit_count > 0);
+ }
+ inline int get_route()
+ {
+ return route;
+ }
+ inline void update_credit(int credit)
+ {
+ m_credit_count = credit;
+ }
+ inline void increment_credit()
+ {
+ m_credit_count++;
+ }
+ inline void insertFlit(flit_d *t_flit)
+ {
+ m_input_buffer->insert(t_flit);
+ }
+ inline void set_state(VC_state_type m_state)
+ {
+ m_vc_state.first = m_state;
+ m_vc_state.second = g_eventQueue_ptr->getTime() + 1;
+ }
+
+ inline flit_d* peekTopFlit()
+ {
+ return m_input_buffer->peekTopFlit();
+ }
+
+ inline flit_d* getTopFlit()
+ {
+ return m_input_buffer->getTopFlit();
+ }
+
+private:
+ int m_id;
+ flitBuffer_d *m_input_buffer;
+ pair<VC_state_type, Time> m_vc_state; // I/R/V/A/C
+ int route;
+ Time m_enqueue_time;
+ int m_output_vc;
+ int m_credit_count;
+};
+#endif
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.cc
new file mode 100644
index 000000000..f3ddca0f2
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.cc
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * flitBuffer_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#include "mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh"
+
+flitBuffer_d::flitBuffer_d()
+{
+ max_size = INFINITE_;
+}
+
+flitBuffer_d::flitBuffer_d(int maximum_size)
+{
+ max_size = maximum_size;
+}
+
+bool flitBuffer_d::isEmpty()
+{
+ return (m_buffer.size() == 0);
+}
+
+bool flitBuffer_d::isReady()
+{
+ if(m_buffer.size() != 0 )
+ {
+ flit_d *t_flit = m_buffer.peekMin();
+ if(t_flit->get_time() <= g_eventQueue_ptr->getTime())
+ return true;
+ }
+ return false;
+}
+
+bool flitBuffer_d::isReadyForNext()
+{
+ if(m_buffer.size() != 0 )
+ {
+ flit_d *t_flit = m_buffer.peekMin();
+ if(t_flit->get_time() <= (g_eventQueue_ptr->getTime() + 1))
+ return true;
+ }
+ return false;
+}
+
+void flitBuffer_d::print(ostream& out) const
+{
+ out << "[flitBuffer: ";
+ out << m_buffer.size() << "] " << endl;
+}
+
+bool flitBuffer_d::isFull()
+{
+ return (m_buffer.size() >= max_size);
+}
+void flitBuffer_d::setMaxSize(int maximum)
+{
+ max_size = maximum;
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh
new file mode 100644
index 000000000..5ac69b22e
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * flitBuffer_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#ifndef FLIT_BUFFER_D_H
+#define FLIT_BUFFER_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/gems_common/PrioHeap.hh"
+#include "mem/ruby/network/garnet-fixed-pipeline/flit_d.hh"
+
+class flitBuffer_d {
+public:
+ flitBuffer_d();
+ flitBuffer_d(int maximum_size);
+
+ bool isReady();
+ bool isReadyForNext();
+ bool isEmpty();
+ void print(ostream& out) const;
+ bool isFull();
+ void setMaxSize(int maximum);
+
+ inline flit_d* getTopFlit()
+ {
+ return m_buffer.extractMin();
+ }
+ inline flit_d* peekTopFlit()
+ {
+ return m_buffer.peekMin();
+ }
+ inline void insert(flit_d *flt)
+ {
+ m_buffer.insert(flt);
+ }
+ /**********Data Members*********/
+private:
+ PrioHeap <flit_d *> m_buffer;
+ int size, max_size;
+};
+
+ostream& operator<<(ostream& out, const flitBuffer_d& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const flitBuffer_d& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif
+
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/flit_d.cc b/src/mem/ruby/network/garnet-fixed-pipeline/flit_d.cc
new file mode 100644
index 000000000..3defb8029
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/flit_d.cc
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * flit_d.C
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+#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)
+{
+ m_size = size;
+ m_msg_ptr = msg_ptr;
+ m_enqueue_time = g_eventQueue_ptr->getTime();
+ m_time = g_eventQueue_ptr->getTime();
+ m_id = id;
+ m_vnet = vnet;
+ m_vc = vc;
+ m_stage.first = I_;
+ m_stage.second = m_time;
+
+ if(size == 1)
+ {
+ m_type = HEAD_TAIL_;
+ return;
+ }
+ if(id == 0)
+ m_type = HEAD_;
+ else if(id == (size - 1))
+ m_type = TAIL_;
+ else
+ m_type = BODY_;
+}
+
+flit_d::flit_d(int vc, bool is_free_signal)
+{
+ m_id = 0;
+ m_vc = vc;
+ m_is_free_signal = is_free_signal;
+ m_time = g_eventQueue_ptr->getTime();
+}
+/*
+int flit_d::get_size()
+{
+ return m_size;
+}
+Time flit_d::get_enqueue_time()
+{
+ return m_enqueue_time;
+}
+int flit_d::get_id()
+{
+ return m_id;
+}
+Time flit_d::get_time()
+{
+ return m_time;
+}
+void flit_d::set_time(Time time)
+{
+ m_time = time;
+}
+int flit_d::get_vnet()
+{
+ return m_vnet;
+}
+int flit_d::get_vc()
+{
+ return m_vc;
+}
+void flit_d::set_vc(int vc)
+{
+ m_vc = vc;
+}
+MsgPtr& flit_d::get_msg_ptr()
+{
+ return m_msg_ptr;
+}
+flit_type flit_d::get_type()
+{
+ return m_type;
+}
+bool flit_d::is_stage(flit_stage t_stage)
+{
+ return ((m_stage.first == t_stage) && (g_eventQueue_ptr->getTime() >= m_stage.second));
+}
+bool flit_d::is_next_stage(flit_stage t_stage)
+{
+ return ((m_stage.first == t_stage) && ((g_eventQueue_ptr->getTime()+1) >= m_stage.second));
+}
+void flit_d::advance_stage(flit_stage t_stage)
+{
+ m_stage.first = t_stage;
+ m_stage.second = g_eventQueue_ptr->getTime() + 1;
+}
+*/
+void flit_d::print(ostream& out) const
+{
+ out << "[flit:: ";
+ out << "Id=" << m_id << " ";
+ out << "Type=" << m_type << " ";
+ out << "Vnet=" << m_vnet << " ";
+ out << "VC=" << m_vc << " ";
+ out << "Enqueue Time=" << m_enqueue_time << " ";
+ out << "]";
+}
diff --git a/src/mem/ruby/network/garnet-fixed-pipeline/flit_d.hh b/src/mem/ruby/network/garnet-fixed-pipeline/flit_d.hh
new file mode 100644
index 000000000..4d69984d2
--- /dev/null
+++ b/src/mem/ruby/network/garnet-fixed-pipeline/flit_d.hh
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * flit_d.h
+ *
+ * Niket Agarwal, Princeton University
+ *
+ * */
+
+
+#ifndef FLIT_D_H
+#define FLIT_D_H
+
+#include "mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh"
+#include "mem/ruby/slicc_interface/Message.hh"
+
+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);
+ void set_outport(int port) { m_outport = port; }
+ int get_outport() {return m_outport; }
+ void print(ostream& out) const;
+ bool is_free_signal()
+ {
+ return m_is_free_signal;
+ }
+
+ inline int get_size()
+ {
+ return m_size;
+ }
+ inline Time get_enqueue_time()
+ {
+ return m_enqueue_time;
+ }
+ inline int get_id()
+ {
+ return m_id;
+ }
+ inline Time get_time()
+ {
+ return m_time;
+ }
+ inline void set_time(Time time)
+ {
+ m_time = time;
+ }
+ inline int get_vnet()
+ {
+ return m_vnet;
+ }
+ inline int get_vc()
+ {
+ return m_vc;
+ }
+ inline void set_vc(int vc)
+ {
+ m_vc = vc;
+ }
+ inline MsgPtr& get_msg_ptr()
+ {
+ return m_msg_ptr;
+ }
+ inline flit_type get_type()
+ {
+ return m_type;
+ }
+ inline bool is_stage(flit_stage t_stage)
+ {
+ return ((m_stage.first == t_stage) && (g_eventQueue_ptr->getTime() >= m_stage.second));
+ }
+ inline bool is_next_stage(flit_stage t_stage)
+ {
+ return ((m_stage.first == t_stage) && ((g_eventQueue_ptr->getTime()+1) >= m_stage.second));
+ }
+ inline void advance_stage(flit_stage t_stage)
+ {
+ m_stage.first = t_stage;
+ m_stage.second = g_eventQueue_ptr->getTime() + 1;
+ }
+ inline pair<flit_stage, Time> get_stage()
+ {
+ return m_stage;
+ }
+ inline void set_delay(int delay)
+ {
+ src_delay = delay;
+ }
+
+ inline int get_delay()
+ {
+ return src_delay;
+ }
+
+
+private:
+ /************Data Members*************/
+ int m_id;
+ int m_vnet;
+ int m_vc;
+ int m_size;
+ bool m_is_free_signal;
+ Time m_enqueue_time, m_time;
+ flit_type m_type;
+ MsgPtr m_msg_ptr;
+ int m_outport;
+ int src_delay;
+ pair<flit_stage, Time> m_stage;
+
+};
+
+inline extern bool node_less_then_eq(flit_d* n1, flit_d* n2);
+
+inline extern
+bool node_less_then_eq(flit_d* n1, flit_d* n2)
+{
+ if (n1->get_time() == n2->get_time()) {
+// ASSERT(n1->flit_id != n2->flit_id);
+ return (n1->get_id() <= n2->get_id());
+ } else {
+ return (n1->get_time() <= n2->get_time());
+ }
+}
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const flit_d& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const flit_d& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif