summaryrefslogtreecommitdiff
path: root/src/mem/ruby/network/garnet/flexible-pipeline
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2010-01-29 20:29:30 -0800
committerSteve Reinhardt <steve.reinhardt@amd.com>2010-01-29 20:29:30 -0800
commitb5444625056a93cd676c512a891b0c13c44cf58b (patch)
treebff089a597df81cc7960910019ce91254be986d6 /src/mem/ruby/network/garnet/flexible-pipeline
parent6c867f82632fa8d635cd617dd933332f596d0bc4 (diff)
downloadgem5-b5444625056a93cd676c512a891b0c13c44cf58b.tar.xz
Garnet: reorganize directory tree.
Rename the ruby/network/garnet-foo directories to garnet/foo. Move the common NetworkHeader.hh file from garnet-fixed-pipeline up to the common garnet directory. Fix up include paths. --HG-- rename : src/mem/ruby/network/garnet-fixed-pipeline/NetworkHeader.hh => src/mem/ruby/network/garnet/NetworkHeader.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/CreditLink_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/InputUnit_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/NetworkInterface_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/NetworkLink_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/OutVcState_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/OutputUnit_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/Router_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/Router_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/RoutingUnit_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/SConscript => src/mem/ruby/network/garnet/fixed-pipeline/SConscript rename : src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/SWallocator_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/Switch_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/VCallocator_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/VirtualChannel_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/flitBuffer_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh rename : src/mem/ruby/network/garnet-fixed-pipeline/flit_d.cc => src/mem/ruby/network/garnet/fixed-pipeline/flit_d.cc rename : src/mem/ruby/network/garnet-fixed-pipeline/flit_d.hh => src/mem/ruby/network/garnet/fixed-pipeline/flit_d.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/FlexibleConsumer.hh => src/mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.cc => src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.hh => src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/InVcState.cc => src/mem/ruby/network/garnet/flexible-pipeline/InVcState.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/InVcState.hh => src/mem/ruby/network/garnet/flexible-pipeline/InVcState.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh => src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.cc => src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.hh => src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.cc => src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.hh => src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.cc => src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.hh => src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/Router.cc => src/mem/ruby/network/garnet/flexible-pipeline/Router.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/Router.hh => src/mem/ruby/network/garnet/flexible-pipeline/Router.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/SConscript => src/mem/ruby/network/garnet/flexible-pipeline/SConscript rename : src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.cc => src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.hh => src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/flit.cc => src/mem/ruby/network/garnet/flexible-pipeline/flit.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/flit.hh => src/mem/ruby/network/garnet/flexible-pipeline/flit.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.cc => src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc rename : src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.hh => src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh rename : src/mem/ruby/network/garnet-flexible-pipeline/netconfig.defaults => src/mem/ruby/network/garnet/flexible-pipeline/netconfig.defaults
Diffstat (limited to 'src/mem/ruby/network/garnet/flexible-pipeline')
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh46
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc297
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh120
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/InVcState.cc70
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/InVcState.hh55
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh73
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc301
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh94
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc142
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh84
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.cc55
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh50
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/Router.cc384
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/Router.hh93
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/SConscript47
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.cc42
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh51
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/flit.cc108
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/flit.hh92
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc99
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh73
-rw-r--r--src/mem/ruby/network/garnet/flexible-pipeline/netconfig.defaults8
22 files changed, 2384 insertions, 0 deletions
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh b/src/mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh
new file mode 100644
index 000000000..fd12b4ec8
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef FLEXIBLE_CONSUMER_H
+#define FLEXIBLE_CONSUMER_H
+
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/ruby/common/NetDest.hh"
+
+class FlexibleConsumer : public Consumer {
+public:
+ virtual bool isBufferNotFull(int vc, int inport) {return true;}
+ virtual void grant_vc(int out_port, int vc, Time grant_time) {}
+ virtual void release_vc(int out_port, int vc, Time release_time) {}
+ virtual void request_vc(int vc, int in_port, NetDest destination, Time request_time) {}
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
new file mode 100644
index 000000000..a88263c62
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
@@ -0,0 +1,297 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
+#include "mem/protocol/MachineType.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
+#include "mem/ruby/buffers/MessageBuffer.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
+#include "mem/ruby/network/simple/Topology.hh"
+#include "mem/ruby/network/simple/SimpleNetwork.hh"
+#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
+#include "mem/ruby/common/NetDest.hh"
+
+GarnetNetwork::GarnetNetwork(const string & name)
+ : Network(name)
+{
+}
+
+void GarnetNetwork::init()
+{
+// printf("hello\n");
+ Network::init(argv);
+//added by SS
+// assert (m_topology_ptr!=NULL);
+
+ m_network_config_ptr = new NetworkConfig;
+
+ m_network_config_ptr->init(argv);
+
+ m_ruby_start = 0;
+
+ // 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
+ assert (m_topology_ptr!=NULL);
+ m_topology_ptr->makeTopology();
+
+ int number_of_routers = m_topology_ptr->numSwitches();
+ for (int i=0; i<number_of_routers; i++) {
+ m_router_ptr_vector.insertAtBottom(new Router(i, this));
+ }
+
+ for (int i=0; i < m_nodes; i++) {
+ NetworkInterface *ni = new NetworkInterface(i, m_virtual_networks, this);
+ ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
+ m_ni_ptr_vector.insertAtBottom(ni);
+ }
+ m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration
+}
+
+GarnetNetwork::~GarnetNetwork()
+{
+ 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();
+ delete m_topology_ptr;
+}
+
+void GarnetNetwork::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();
+ }
+ }
+}
+
+void GarnetNetwork::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 *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this);
+ m_link_ptr_vector.insertAtBottom(net_link);
+ m_router_ptr_vector[dest]->addInPort(net_link);
+ m_ni_ptr_vector[src]->addOutPort(net_link);
+ }
+ else
+ {
+ ERROR_MSG("Fatal Error:: Reconfiguration not allowed here");
+ // do nothing
+ }
+}
+
+void GarnetNetwork::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 *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this);
+ m_link_ptr_vector.insertAtBottom(net_link);
+ m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight);
+ m_ni_ptr_vector[dest]->addInPort(net_link);
+ }
+ else
+ {
+ ERROR_MSG("Fatal Error:: Reconfiguration not allowed here");
+ //do nothing
+ }
+}
+
+void GarnetNetwork::makeInternalLink(SwitchID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration)
+{
+ if(!isReconfiguration)
+ {
+ NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this);
+ m_link_ptr_vector.insertAtBottom(net_link);
+ m_router_ptr_vector[dest]->addInPort(net_link);
+ m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight);
+ }
+ else
+ {
+ ERROR_MSG("Fatal Error:: Reconfiguration not allowed here");
+ // do nothing
+ }
+
+}
+
+void GarnetNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
+{
+ printf ("id = %i, m_nodes = %i \n", id, m_nodes);
+ 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::getToNetQueue(NodeID id, bool ordered, int network_num)
+{
+ checkNetworkAllocation(id, ordered, network_num);
+ return m_toNetQueues[id][network_num];
+}
+
+MessageBuffer* GarnetNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num)
+{
+ checkNetworkAllocation(id, ordered, network_num);
+ return m_fromNetQueues[id][network_num];
+}
+
+void GarnetNetwork::clearStats()
+{
+ m_ruby_start = g_eventQueue_ptr->getTime();
+}
+
+Time GarnetNetwork::getRubyStartTime()
+{
+ return m_ruby_start;
+}
+
+void GarnetNetwork::printStats(ostream& out) const
+{ double average_link_utilization = 0;
+ Vector<double > average_vc_load;
+ average_vc_load.setSize(m_virtual_networks*m_network_config_ptr->getVCsPerClass());
+
+ for(int i = 0; i < m_virtual_networks*m_network_config_ptr->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 += m_link_ptr_vector[i]->getLinkUtilization();
+ Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad();
+ for(int j = 0; j < vc_load.size(); j++)
+ {
+ assert(vc_load.size() == m_network_config_ptr->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 < m_network_config_ptr->getVCsPerClass()*m_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;
+}
+
+void GarnetNetwork::printConfig(ostream& out) const
+{
+ out << endl;
+ out << "Network Configuration" << endl;
+ out << "---------------------" << endl;
+ out << "network: GARNET_NETWORK" << endl;
+ out << "topology: " << m_topology_ptr->getName() << 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);
+ }
+ m_topology_ptr->printConfig(out);
+}
+
+void GarnetNetwork::print(ostream& out) const
+{
+ out << "[GarnetNetwork]";
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh
new file mode 100644
index 000000000..03a17037f
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef GARNET_NETWORK_H
+#define GARNET_NETWORK_H
+
+#include "mem/ruby/network/garnet/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;
+class MessageBuffer;
+class Router;
+class Topology;
+class NetDest;
+class NetworkLink;
+
+class GarnetNetwork : public Network{
+public:
+ GarnetNetwork(const string & name);
+
+ ~GarnetNetwork();
+
+ void init();
+
+ //added by SS
+ NetworkConfig* getNetworkConfig() { return m_network_config_ptr; }
+
+ // 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;
+
+ bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
+ bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
+
+ Time getRubyStartTime();
+ int getNumNodes(){ return m_nodes; }
+
+ 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(const GarnetNetwork& obj);
+ GarnetNetwork& operator=(const GarnetNetwork& obj);
+
+
+/***********Data Members*************/
+// int m_virtual_networks;
+// int m_nodes;
+
+ Vector<bool> m_in_use;
+ Vector<bool> m_ordered;
+
+ Vector<Vector<MessageBuffer*> > m_toNetQueues;
+ Vector<Vector<MessageBuffer*> > m_fromNetQueues;
+
+ Vector<Router *> m_router_ptr_vector; // All Routers in Network
+ Vector<NetworkLink *> m_link_ptr_vector; // All links in the network
+ Vector<NetworkInterface *> m_ni_ptr_vector; // All NI's in Network
+
+// Topology* m_topology_ptr;
+ Time m_ruby_start;
+
+ NetworkConfig* m_network_config_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const GarnetNetwork& obj);
+
+// ******************* Definitions *******************
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const GarnetNetwork& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //NETWORK_H
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/InVcState.cc b/src/mem/ruby/network/garnet/flexible-pipeline/InVcState.cc
new file mode 100644
index 000000000..84196e45e
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/InVcState.cc
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
+
+InVcState::InVcState(int id)
+{
+ m_id = id;
+ m_vc_state = IDLE_;
+}
+
+bool InVcState::isInState(VC_state_type state, Time request_time)
+{
+ return ((m_vc_state == state) && (request_time >= m_time) );
+}
+
+void InVcState::setRoute(int route)
+{
+ m_route = route;
+}
+
+void InVcState::setState(VC_state_type state, Time time)
+{
+ m_vc_state = state;
+ m_time = time;
+}
+
+void InVcState::grant_vc(int out_vc, Time grant_time)
+{
+ m_vc_state = ACTIVE_;
+ m_time = grant_time;
+ m_output_vc = out_vc;
+}
+
+int InVcState::get_outport()
+{
+ return m_route;
+}
+
+int InVcState::get_outvc()
+{
+ return m_output_vc;
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/InVcState.hh b/src/mem/ruby/network/garnet/flexible-pipeline/InVcState.hh
new file mode 100644
index 000000000..d84bbe81f
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/InVcState.hh
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef IN_VC_STATE_H
+#define IN_VC_STATE_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+
+class InVcState {
+public:
+ InVcState(int id);
+
+ void setRoute(int route);
+ void setState(VC_state_type state, Time time);
+ int get_outport();
+ int get_outvc();
+ void grant_vc(int out_vc, Time grant_time);
+ bool isInState(VC_state_type state, Time time);
+
+private:
+ int m_id;
+ int m_route;
+ int m_output_vc;
+ VC_state_type m_vc_state;
+ Time m_time;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh
new file mode 100644
index 000000000..44900d25e
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+/*
+ * This header file is used to define all configuration parameters
+ * required by the interconnection network.
+ */
+
+#ifndef NETWORKCONFIG_H
+#define NETWORKCONFIG_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/gems_common/util.hh"
+
+class NetworkConfig {
+ private:
+ int m_flit_size;
+ int m_number_of_pipe_stages;
+ int m_vcs_per_class;
+ int m_buffer_size;
+ bool m_using_network_testing;
+ public:
+ NetworkConfig(){}
+ void init() {
+ for (size_t i=0; i<argv.size(); i+=2) {
+ if (argv[i] == "flit_size")
+ m_flit_size = atoi(argv[i+1].c_str());
+ else if (argv[i] == "number_of_pipe_stages")
+ m_number_of_pipe_stages = atoi(argv[i+1].c_str());
+ else if (argv[i] == "vcs_per_class")
+ m_vcs_per_class = atoi(argv[i+1].c_str());
+ else if (argv[i] == "buffer_size")
+ m_buffer_size = atoi(argv[i+1].c_str());
+ else if (argv[i] == "using_network_testing")
+ m_using_network_testing = atoi(argv[i+1].c_str());
+ }
+ }
+ bool isNetworkTesting() {return m_using_network_testing; }
+ int getFlitSize() {return m_flit_size; }
+ int getNumPipeStages() {return m_number_of_pipe_stages; }
+ int getVCsPerClass() {return m_vcs_per_class; }
+ int getBufferSize() {return m_buffer_size; }
+};
+
+
+#endif
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc
new file mode 100644
index 000000000..a8a8fd137
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
+#include "mem/ruby/buffers/MessageBuffer.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
+#include "mem/ruby/slicc_interface/NetworkMessage.hh"
+
+NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *network_ptr)
+{
+ m_id = id;
+ m_net_ptr = network_ptr;
+ m_virtual_networks = virtual_networks;
+ m_vc_per_vnet = m_net_ptr->getNetworkConfig()->getVCsPerClass();
+ m_num_vcs = m_vc_per_vnet*m_virtual_networks;
+
+ m_vc_round_robin = 0;
+ m_ni_buffers.setSize(m_num_vcs);
+ inNode_ptr.setSize(m_virtual_networks);
+ outNode_ptr.setSize(m_virtual_networks);
+
+ for(int i =0; i < m_num_vcs; i++)
+ m_ni_buffers[i] = new flitBuffer(); // instantiating the NI flit buffers
+
+ m_vc_allocator.setSize(m_virtual_networks);
+ 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(i));
+ m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
+ }
+}
+
+NetworkInterface::~NetworkInterface()
+{
+ m_out_vc_state.deletePointers();
+ m_ni_buffers.deletePointers();
+ delete outSrcQueue;
+}
+
+void NetworkInterface::addInPort(NetworkLink *in_link)
+{
+ inNetLink = in_link;
+ in_link->setLinkConsumer(this);
+}
+
+void NetworkInterface::addOutPort(NetworkLink *out_link)
+{
+ outNetLink = out_link;
+ outSrcQueue = new flitBuffer();
+ out_link->setSourceQueue(outSrcQueue);
+ out_link->setSource(this);
+}
+
+void NetworkInterface::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
+ }
+}
+
+void NetworkInterface::request_vc(int in_vc, int in_port, NetDest destination, Time request_time)
+{
+ inNetLink->grant_vc_link(in_vc, request_time);
+}
+
+bool NetworkInterface::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) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getNetworkConfig()->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)
+ {
+ // did not find a free output vc
+ 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++)
+ {
+ flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr);
+ m_ni_buffers[vc]->insert(fl);
+ }
+
+ m_out_vc_state[vc]->setState(VC_AB_, g_eventQueue_ptr->getTime());
+ outNetLink->request_vc_link(vc, new_net_msg_ptr->getInternalDestination(), g_eventQueue_ptr->getTime()); // setting an output vc request for the next hop. It is only when an output vc is acquired at the next hop that this flit will be ready to traverse the link and into the next hop
+ }
+
+ return true ;
+}
+
+// An output vc has been granted at the next hop to one of the vc's. We have to update the state of the vc to reflect this
+void NetworkInterface::grant_vc(int out_port, int vc, Time grant_time)
+{
+
+ assert(m_out_vc_state[vc]->isInState(VC_AB_, grant_time));
+ m_out_vc_state[vc]->grant_vc(grant_time);
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+}
+
+// The tail flit corresponding to this vc has been buffered at the next hop and thus this vc is now free
+void NetworkInterface::release_vc(int out_port, int vc, Time release_time)
+{
+ assert(m_out_vc_state[vc]->isInState(ACTIVE_, release_time));
+ m_out_vc_state[vc]->setState(IDLE_, release_time);
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+}
+
+// Looking for a free output vc
+int NetworkInterface::calculateVC(int vnet)
+{
+ int vc_per_vnet;
+ if(m_net_ptr->isVNetOrdered(vnet))
+ vc_per_vnet = 1;
+ else
+ vc_per_vnet = m_vc_per_vnet;
+
+ for(int i = 0; i < vc_per_vnet; i++)
+ {
+ int delta = m_vc_allocator[vnet];
+ m_vc_allocator[vnet]++;
+ if(m_vc_allocator[vnet] == 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.
+ */
+
+void NetworkInterface::wakeup()
+{
+ 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 *t_flit = inNetLink->consumeLink();
+ if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_)
+ {
+ DEBUG_EXPR(NETWORK_COMP, HighPrio, m_id);
+ DEBUG_MSG(NETWORK_COMP, HighPrio, "Message got delivered");
+ DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime());
+ if(!m_net_ptr->getNetworkConfig()->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
+ }
+ inNetLink->release_vc_link(t_flit->get_vc(), g_eventQueue_ptr->getTime() + 1); // signal the upstream router that this vc can be freed now
+ }
+ 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::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())
+ {
+ if(m_out_vc_state[vc]->isInState(ACTIVE_, g_eventQueue_ptr->getTime()) && outNetLink->isBufferNotFull_link(vc)) // models buffer backpressure
+ {
+ flit *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
+ return;
+ }
+ }
+ }
+}
+
+void NetworkInterface::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::printConfig(ostream& out) const
+{
+ out << "[Network Interface " << m_id << "] - ";
+ out << "[inLink " << inNetLink->get_id() << "] - ";
+ out << "[outLink " << outNetLink->get_id() << "]" << endl;
+}
+
+void NetworkInterface::print(ostream& out) const
+{
+ out << "[Network Interface]";
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh
new file mode 100644
index 000000000..67bba5f04
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef NET_INTERFACE_H
+#define NET_INTERFACE_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
+#include "mem/gems_common/Vector.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
+#include "mem/ruby/slicc_interface/Message.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
+
+class NetworkMessage;
+class MessageBuffer;
+class flitBuffer;
+
+class NetworkInterface : public FlexibleConsumer {
+public:
+ NetworkInterface(int id, int virtual_networks, GarnetNetwork* network_ptr);
+
+ ~NetworkInterface();
+
+ void addInPort(NetworkLink *in_link);
+ void addOutPort(NetworkLink *out_link);
+
+ void wakeup();
+ void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode);
+ void grant_vc(int out_port, int vc, Time grant_time);
+ void release_vc(int out_port, int vc, Time release_time);
+ bool isBufferNotFull(int vc, int inport)
+ {
+ return true;
+ }
+ void request_vc(int in_vc, int in_port, NetDest destination, Time request_time);
+
+ void printConfig(ostream& out) const;
+ void print(ostream& out) const;
+
+private:
+/**************Data Members*************/
+ GarnetNetwork *m_net_ptr;
+ int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
+ NodeID m_id;
+
+ Vector<OutVcState *> m_out_vc_state;
+ Vector<int > m_vc_allocator;
+ int m_vc_round_robin; // For round robin scheduling
+ flitBuffer *outSrcQueue; // For modelling link contention
+
+ NetworkLink *inNetLink;
+ NetworkLink *outNetLink;
+
+ // Input Flit Buffers
+ Vector<flitBuffer *> m_ni_buffers; // The flit buffers which will serve the Consumer
+
+ 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/flexible-pipeline/NetworkLink.cc b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc
new file mode 100644
index 000000000..3b1c84eb6
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
+
+NetworkLink::NetworkLink(int id, int latency, GarnetNetwork *net_ptr)
+{
+ m_id = id;
+ linkBuffer = new flitBuffer();
+ m_in_port = 0;
+ m_out_port = 0;
+ m_link_utilized = 0;
+ m_net_ptr = net_ptr;
+ m_latency = latency;
+ int num_net = net_ptr->getNumberOfVirtualNetworks();
+ int num_vc = m_net_ptr->getNetworkConfig()->getVCsPerClass();
+ m_vc_load.setSize(num_net*num_vc);
+
+ for(int i = 0; i < num_net*num_vc; i++)
+ m_vc_load[i] = 0;
+}
+
+NetworkLink::~NetworkLink()
+{
+ delete linkBuffer;
+}
+
+int NetworkLink::get_id()
+{
+ return m_id;
+}
+
+void NetworkLink::setLinkConsumer(FlexibleConsumer *consumer)
+{
+ link_consumer = consumer;
+}
+
+void NetworkLink::setSourceQueue(flitBuffer *srcQueue)
+{
+ link_srcQueue = srcQueue;
+}
+
+void NetworkLink::setSource(FlexibleConsumer *source)
+{
+ link_source = source;
+}
+void NetworkLink::request_vc_link(int vc, NetDest destination, Time request_time)
+{
+ link_consumer->request_vc(vc, m_in_port, destination, request_time);
+}
+bool NetworkLink::isBufferNotFull_link(int vc)
+{
+ return link_consumer->isBufferNotFull(vc, m_in_port);
+}
+
+void NetworkLink::grant_vc_link(int vc, Time grant_time)
+{
+ link_source->grant_vc(m_out_port, vc, grant_time);
+}
+
+void NetworkLink::release_vc_link(int vc, Time release_time)
+{
+ link_source->release_vc(m_out_port, vc, release_time);
+}
+
+Vector<int> NetworkLink::getVcLoad()
+{
+ return m_vc_load;
+}
+
+double NetworkLink::getLinkUtilization()
+{
+ Time m_ruby_start = m_net_ptr->getRubyStartTime();
+ return (double(m_link_utilized)) / (double(g_eventQueue_ptr->getTime()-m_ruby_start));
+}
+
+bool NetworkLink::isReady()
+{
+ return linkBuffer->isReady();
+}
+
+void NetworkLink::setInPort(int port)
+{
+ m_in_port = port;
+}
+
+void NetworkLink::setOutPort(int port)
+{
+ m_out_port = port;
+}
+
+void NetworkLink::wakeup()
+{
+ if(link_srcQueue->isReady())
+ {
+ flit *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()]++;
+ }
+}
+
+flit* NetworkLink::peekLink()
+{
+ return linkBuffer->peekTopFlit();
+}
+
+flit* NetworkLink::consumeLink()
+{
+ return linkBuffer->getTopFlit();
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh
new file mode 100644
index 000000000..e371d9265
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef NETWORK_LINK_H
+#define NETWORK_LINK_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
+#include "mem/gems_common/PrioHeap.hh"
+#include "mem/ruby/common/NetDest.hh"
+
+class GarnetNetwork;
+
+class NetworkLink : public FlexibleConsumer {
+public:
+ NetworkLink();
+ NetworkLink(int id, int latency, GarnetNetwork *net_ptr);
+ ~NetworkLink();
+
+ void setLinkConsumer(FlexibleConsumer *consumer);
+ void setSourceQueue(flitBuffer *srcQueue);
+ flit* peekLink();
+ flit* consumeLink();
+
+ void print(ostream& out) const {}
+
+ bool is_vc_ready(flit *t_flit);
+
+ int get_id();
+ void setInPort(int port);
+ void setOutPort(int port);
+ void wakeup();
+ bool isReady();
+ void grant_vc_link(int vc, Time grant_time);
+ void release_vc_link(int vc, Time release_time);
+ void request_vc_link(int vc, NetDest destination, Time request_time);
+ bool isBufferNotFull_link(int vc);
+ void setSource(FlexibleConsumer *source);
+ double getLinkUtilization();
+ Vector<int> getVcLoad();
+
+protected:
+ int m_id, m_latency;
+ int m_in_port, m_out_port;
+ int m_link_utilized;
+ Vector<int > m_vc_load;
+ GarnetNetwork *m_net_ptr;
+
+ flitBuffer *linkBuffer;
+ FlexibleConsumer *link_consumer;
+ FlexibleConsumer *link_source;
+ flitBuffer *link_srcQueue;
+};
+
+#endif
+
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.cc b/src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.cc
new file mode 100644
index 000000000..e17db5dcf
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
+
+OutVcState::OutVcState(int id)
+{
+ m_id = id;
+ m_vc_state = IDLE_;
+}
+
+bool OutVcState::isInState(VC_state_type state, Time request_time)
+{
+ return ((m_vc_state == state) && (request_time >= m_time) );
+}
+
+void OutVcState::grant_vc(Time grant_time)
+{
+ m_time = grant_time;
+ m_vc_state = ACTIVE_;
+}
+
+void OutVcState::setState(VC_state_type state, Time time)
+{
+ m_vc_state = state;
+ m_time = time;
+}
+
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh b/src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh
new file mode 100644
index 000000000..a1c0fdfac
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef OUT_VC_STATE_H
+#define OUT_VC_STATE_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+
+class OutVcState {
+public:
+ OutVcState(int id);
+
+ bool isInState(VC_state_type state, Time request_time);
+ void setState(VC_state_type state, Time time);
+ void grant_vc(Time grant_time);
+
+private:
+ int m_id ;
+ Time m_time;
+ VC_state_type m_vc_state;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc
new file mode 100644
index 000000000..63f0373f8
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc
@@ -0,0 +1,384 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
+#include "mem/ruby/slicc_interface/NetworkMessage.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
+
+Router::Router(int id, GarnetNetwork *network_ptr)
+{
+ m_id = id;
+ m_net_ptr = network_ptr;
+ m_virtual_networks = m_net_ptr->getNumberOfVirtualNetworks();
+ m_vc_per_vnet = m_net_ptr->getNetworkConfig()->getVCsPerClass();
+ m_round_robin_inport = 0;
+ m_round_robin_start = 0;
+ m_num_vcs = m_vc_per_vnet*m_virtual_networks;
+ m_vc_arbiter = new VCarbiter(this);
+}
+
+Router::~Router()
+{
+ for (int i = 0; i < m_in_link.size(); i++)
+ {
+ m_in_vc_state[i].deletePointers();
+ }
+ for (int i = 0; i < m_out_link.size(); i++)
+ {
+ m_out_vc_state[i].deletePointers();
+ m_router_buffers[i].deletePointers();
+ }
+ m_out_src_queue.deletePointers();
+ delete m_vc_arbiter;
+
+}
+
+void Router::addInPort(NetworkLink *in_link)
+{
+ int port = m_in_link.size();
+ Vector<InVcState *> in_vc_vector;
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ in_vc_vector.insertAtBottom(new InVcState(i));
+ in_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
+ }
+ m_in_vc_state.insertAtBottom(in_vc_vector);
+ m_in_link.insertAtBottom(in_link);
+ in_link->setLinkConsumer(this);
+ in_link->setInPort(port);
+
+ int start = 0;
+ m_round_robin_invc.insertAtBottom(start);
+
+}
+
+void Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entry, int link_weight)
+{
+ int port = m_out_link.size();
+ out_link->setOutPort(port);
+ int start = 0;
+ m_vc_round_robin.insertAtBottom(start);
+
+ m_out_src_queue.insertAtBottom(new flitBuffer());
+
+ m_out_link.insertAtBottom(out_link);
+ m_routing_table.insertAtBottom(routing_table_entry);
+ out_link->setSourceQueue(m_out_src_queue[port]);
+ out_link->setSource(this);
+
+ Vector<flitBuffer *> intermediateQueues;
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ intermediateQueues.insertAtBottom(new flitBuffer(m_net_ptr->getNetworkConfig()->getBufferSize()));
+ }
+ m_router_buffers.insertAtBottom(intermediateQueues);
+
+ Vector<OutVcState *> out_vc_vector;
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ out_vc_vector.insertAtBottom(new OutVcState(i));
+ out_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime());
+ }
+ m_out_vc_state.insertAtBottom(out_vc_vector);
+ m_link_weights.insertAtBottom(link_weight);
+}
+
+bool Router::isBufferNotFull(int vc, int inport)
+{
+ int outport = m_in_vc_state[inport][vc]->get_outport();
+ int outvc = m_in_vc_state[inport][vc]->get_outvc();
+
+ return (!m_router_buffers[outport][outvc]->isFull());
+}
+
+// A request for an output vc has been placed by an upstream Router/NI. This has to be updated and arbitration performed
+void Router::request_vc(int in_vc, int in_port, NetDest destination, Time request_time)
+{
+ assert(m_in_vc_state[in_port][in_vc]->isInState(IDLE_, request_time));
+
+ int outport = getRoute(destination);
+ m_in_vc_state[in_port][in_vc]->setRoute(outport);
+ m_in_vc_state[in_port][in_vc]->setState(VC_AB_, request_time);
+ assert(request_time >= g_eventQueue_ptr->getTime());
+ if(request_time > g_eventQueue_ptr->getTime())
+ g_eventQueue_ptr->scheduleEventAbsolute(m_vc_arbiter, request_time);
+ else
+ vc_arbitrate();
+}
+
+void Router::vc_arbitrate()
+{
+ int inport = m_round_robin_inport;
+ m_round_robin_inport++;
+ if(m_round_robin_inport == m_in_link.size())
+ m_round_robin_inport = 0;
+
+ for(int port_iter = 0; port_iter < m_in_link.size(); port_iter++)
+ {
+ inport++;
+ if(inport >= m_in_link.size())
+ inport = 0;
+ int invc = m_round_robin_invc[inport];
+ m_round_robin_invc[inport]++;
+
+ if(m_round_robin_invc[inport] >= m_num_vcs)
+ m_round_robin_invc[inport] = 0;
+ for(int vc_iter = 0; vc_iter < m_num_vcs; vc_iter++)
+ {
+ invc++;
+ if(invc >= m_num_vcs)
+ invc = 0;
+ InVcState *in_vc_state = m_in_vc_state[inport][invc];
+
+ if(in_vc_state->isInState(VC_AB_, g_eventQueue_ptr->getTime()))
+ {
+ int outport = in_vc_state->get_outport();
+ Vector<int > valid_vcs = get_valid_vcs(invc);
+ for(int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size(); valid_vc_iter++)
+ {
+ if(m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->isInState(IDLE_, g_eventQueue_ptr->getTime()))
+ {
+ in_vc_state->grant_vc(valid_vcs[valid_vc_iter], g_eventQueue_ptr->getTime());
+ m_in_link[inport]->grant_vc_link(invc, g_eventQueue_ptr->getTime());
+ m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->setState(VC_AB_, g_eventQueue_ptr->getTime());
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+Vector<int > Router::get_valid_vcs(int invc)
+{
+ Vector<int > vc_list;
+
+ for(int vnet = 0; vnet < m_virtual_networks; vnet++)
+ {
+ if(invc >= (vnet*m_vc_per_vnet) && invc < ((vnet+1)*m_vc_per_vnet))
+ {
+ int base = vnet*m_vc_per_vnet;
+ int vc_per_vnet;
+ if(m_net_ptr->isVNetOrdered(vnet))
+ vc_per_vnet = 1;
+ else
+ vc_per_vnet = m_vc_per_vnet;
+
+ for(int offset = 0; offset < vc_per_vnet; offset++)
+ {
+ vc_list.insertAtBottom(base+offset);
+ }
+ break;
+ }
+ }
+ return vc_list;
+}
+
+void Router::grant_vc(int out_port, int vc, Time grant_time)
+{
+ assert(m_out_vc_state[out_port][vc]->isInState(VC_AB_, grant_time));
+ m_out_vc_state[out_port][vc]->grant_vc(grant_time);
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+}
+
+void Router::release_vc(int out_port, int vc, Time release_time)
+{
+ assert(m_out_vc_state[out_port][vc]->isInState(ACTIVE_, release_time));
+ m_out_vc_state[out_port][vc]->setState(IDLE_, release_time);
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+}
+
+// This function calculated the output port for a particular destination.
+int Router::getRoute(NetDest destination)
+{
+ int output_link = -1;
+ int min_weight = INFINITE_;
+ for(int link = 0; link < m_routing_table.size(); link++)
+ {
+ if (destination.intersectionIsNotEmpty(m_routing_table[link]))
+ {
+ if((m_link_weights[link] >= min_weight))
+ continue;
+ output_link = link;
+ min_weight = m_link_weights[link];
+ }
+ }
+ return output_link;
+}
+
+void Router::routeCompute(flit *m_flit, int inport)
+{
+ int invc = m_flit->get_vc();
+ int outport = m_in_vc_state[inport][invc]->get_outport();
+ int outvc = m_in_vc_state[inport][invc]->get_outvc();
+
+ assert(m_net_ptr->getNetworkConfig()->getNumPipeStages() >= 1);
+ m_flit->set_time(g_eventQueue_ptr->getTime() + (m_net_ptr->getNetworkConfig()->getNumPipeStages() - 1)); // Becasuse 1 cycle will be consumed in scheduling the output link
+ m_flit->set_vc(outvc);
+ m_router_buffers[outport][outvc]->insert(m_flit);
+
+ if(m_net_ptr->getNetworkConfig()->getNumPipeStages() > 1)
+ g_eventQueue_ptr->scheduleEvent(this, m_net_ptr->getNetworkConfig()->getNumPipeStages() -1 );
+ if((m_flit->get_type() == HEAD_) || (m_flit->get_type() == HEAD_TAIL_))
+ {
+ NetDest destination = dynamic_cast<NetworkMessage*>(m_flit->get_msg_ptr().ref())->getInternalDestination();
+ if(m_net_ptr->getNetworkConfig()->getNumPipeStages() > 1)
+ {
+ m_out_vc_state[outport][outvc]->setState(VC_AB_, g_eventQueue_ptr->getTime() + 1);
+ m_out_link[outport]->request_vc_link(outvc, destination, g_eventQueue_ptr->getTime() + 1);
+ }
+ else
+ {
+ m_out_vc_state[outport][outvc]->setState(VC_AB_, g_eventQueue_ptr->getTime());
+ m_out_link[outport]->request_vc_link(outvc, destination, g_eventQueue_ptr->getTime());
+ }
+ }
+ if((m_flit->get_type() == TAIL_) || (m_flit->get_type() == HEAD_TAIL_))
+ {
+ m_in_vc_state[inport][invc]->setState(IDLE_, g_eventQueue_ptr->getTime() + 1);
+ m_in_link[inport]->release_vc_link(invc, g_eventQueue_ptr->getTime() + 1);
+ }
+}
+
+void Router::wakeup()
+{
+ flit *t_flit;
+
+ int incoming_port = m_round_robin_start; // This is for round-robin scheduling of incoming ports
+ m_round_robin_start++;
+ if (m_round_robin_start >= m_in_link.size()) {
+ m_round_robin_start = 0;
+ }
+
+ for(int port = 0; port < m_in_link.size(); port++)
+ {
+ // Round robin scheduling
+ incoming_port++;
+ if(incoming_port >= m_in_link.size())
+ incoming_port = 0;
+ if(m_in_link[incoming_port]->isReady()) // checking the incoming link
+ {
+ DEBUG_EXPR(NETWORK_COMP, HighPrio, m_id);
+ DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime());
+ t_flit = m_in_link[incoming_port]->peekLink();
+ routeCompute(t_flit, incoming_port);
+ m_in_link[incoming_port]->consumeLink();
+ }
+ }
+ scheduleOutputLinks();
+ checkReschedule(); // This is for flits lying in the router buffers
+ vc_arbitrate();
+ check_arbiter_reschedule();
+}
+
+void Router::scheduleOutputLinks()
+{
+ for(int port = 0; port < m_out_link.size(); port++)
+ {
+ int vc_tolookat = m_vc_round_robin[port];
+ m_vc_round_robin[port]++;
+ if(m_vc_round_robin[port] == m_num_vcs)
+ m_vc_round_robin[port] = 0;
+
+ for(int i = 0; i < m_num_vcs; i++)
+ {
+ vc_tolookat++;
+ if(vc_tolookat == m_num_vcs)
+ vc_tolookat = 0;
+
+ if(m_router_buffers[port][vc_tolookat]->isReady())
+ {
+ if(m_out_vc_state[port][vc_tolookat]->isInState(ACTIVE_, g_eventQueue_ptr->getTime()) && m_out_link[port]->isBufferNotFull_link(vc_tolookat))
+ // models buffer backpressure
+ {
+ flit *t_flit = m_router_buffers[port][vc_tolookat]->getTopFlit();
+ t_flit->set_time(g_eventQueue_ptr->getTime() + 1 );
+ m_out_src_queue[port]->insert(t_flit);
+ g_eventQueue_ptr->scheduleEvent(m_out_link[port], 1);
+ break; // done for this port
+ }
+ }
+ }
+ }
+}
+
+void Router::checkReschedule()
+{
+ for(int port = 0; port < m_out_link.size(); port++)
+ {
+ for(int vc = 0; vc < m_num_vcs; vc++)
+ {
+ if(m_router_buffers[port][vc]->isReadyForNext())
+ {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ return;
+ }
+ }
+ }
+}
+
+void Router::check_arbiter_reschedule()
+{
+ for(int port = 0; port < m_in_link.size(); port++)
+ {
+ for(int vc = 0; vc < m_num_vcs; vc++)
+ {
+ if(m_in_vc_state[port][vc]->isInState(VC_AB_, g_eventQueue_ptr->getTime() + 1))
+ {
+ g_eventQueue_ptr->scheduleEvent(m_vc_arbiter, 1);
+ return;
+ }
+ }
+ }
+}
+
+void Router::printConfig(ostream& out) const
+{
+ out << "[Router " << m_id << "] :: " << endl;
+ out << "[inLink - ";
+ for(int i = 0;i < m_in_link.size(); i++)
+ out << m_in_link[i]->get_id() << " - ";
+ out << "]" << endl;
+ out << "[outLink - ";
+ for(int i = 0;i < m_out_link.size(); i++)
+ out << m_out_link[i]->get_id() << " - ";
+ out << "]" << endl;
+/* out << "---------- routing table -------------" << endl;
+ for(int i =0; i < m_routing_table.size(); i++)
+ out << m_routing_table[i] << endl;
+*/
+}
+
+void Router::print(ostream& out) const
+{
+ out << "[Router]";
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh b/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh
new file mode 100644
index 000000000..5ec7590a6
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef ROUTER_H
+#define ROUTER_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
+#include "mem/gems_common/PrioHeap.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
+#include "mem/ruby/common/NetDest.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
+
+class VCarbiter;
+
+class Router : public FlexibleConsumer {
+public:
+ Router(int id, GarnetNetwork *network_ptr);
+
+ ~Router();
+
+ void addInPort(NetworkLink *in_link);
+ void addOutPort(NetworkLink *out_link, const NetDest& routing_table_entry, int link_weight);
+ void wakeup();
+ void request_vc(int in_vc, int in_port, NetDest destination, Time request_time);
+ bool isBufferNotFull(int vc, int inport);
+ void grant_vc(int out_port, int vc, Time grant_time);
+ void release_vc(int out_port, int vc, Time release_time);
+ void vc_arbitrate();
+
+ void printConfig(ostream& out) const;
+ void print(ostream& out) const;
+
+private:
+/***************Data Members******************/
+ int m_id;
+ int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
+ GarnetNetwork *m_net_ptr;
+ Vector<int > m_vc_round_robin; // For scheduling of out source queues
+ int m_round_robin_inport, m_round_robin_start; // for vc arbitration
+ Vector<int > m_round_robin_invc; // For every outport. for vc arbitration
+
+ Vector<Vector<flitBuffer *> > m_router_buffers; // These are essentially output buffers
+ Vector<flitBuffer *> m_out_src_queue; // These are source queues for the output link
+ Vector<NetworkLink *> m_in_link;
+ Vector<NetworkLink *> m_out_link;
+ Vector<Vector<InVcState * > > m_in_vc_state;
+ Vector<Vector<OutVcState * > > m_out_vc_state;
+ Vector<NetDest> m_routing_table;
+ Vector<int > m_link_weights;
+ VCarbiter *m_vc_arbiter;
+
+/*********** Private methods *************/
+ int getRoute(NetDest destination);
+ Vector<int > get_valid_vcs(int invc);
+ void routeCompute(flit *m_flit, int inport);
+ void checkReschedule();
+ void check_arbiter_reschedule();
+ void scheduleOutputLinks();
+};
+
+#endif
+
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/SConscript b/src/mem/ruby/network/garnet/flexible-pipeline/SConscript
new file mode 100644
index 000000000..e132741ca
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/SConscript
@@ -0,0 +1,47 @@
+# -*- 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('*')
+
+# temporarily disable
+Return()
+
+if not env['RUBY']:
+ Return()
+
+Source('GarnetNetwork.cc')
+Source('InVcState.cc')
+Source('NetworkInterface.cc')
+Source('NetworkLink.cc')
+Source('OutVcState.cc')
+Source('Router.cc')
+Source('VCarbiter.cc')
+Source('flit.cc')
+Source('flitBuffer.cc')
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.cc b/src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.cc
new file mode 100644
index 000000000..fdf9aadb0
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
+
+VCarbiter::VCarbiter(Router *router)
+{
+ m_router = router;
+}
+
+void VCarbiter::wakeup()
+{
+ m_router->vc_arbitrate();
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh b/src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh
new file mode 100644
index 000000000..6a8c356f1
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef VC_ARBITER_H
+#define VC_ARBITER_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/ruby/common/Consumer.hh"
+
+class Router;
+
+class VCarbiter : public Consumer{
+public:
+ VCarbiter(Router *router);
+ ~VCarbiter() {}
+
+ void print(ostream& out) const {}
+ void wakeup();
+
+private:
+ Router *m_router;
+};
+
+#endif
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/flit.cc b/src/mem/ruby/network/garnet/flexible-pipeline/flit.cc
new file mode 100644
index 000000000..e73a8b9b5
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/flit.cc
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/flit.hh"
+
+flit::flit(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;
+
+ 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_;
+}
+
+int flit::get_size()
+{
+ return m_size;
+}
+int flit::get_id()
+{
+ return m_id;
+}
+Time flit::get_time()
+{
+ return m_time;
+}
+
+Time flit::get_enqueue_time()
+{
+ return m_enqueue_time;
+}
+void flit::set_time(Time time)
+{
+ m_time = time;
+}
+
+int flit::get_vnet()
+{
+ return m_vnet;
+}
+int flit::get_vc()
+{
+ return m_vc;
+}
+void flit::set_vc(int vc)
+{
+ m_vc = vc;
+}
+MsgPtr& flit::get_msg_ptr()
+{
+ return m_msg_ptr;
+}
+flit_type flit::get_type()
+{
+ return m_type;
+}
+
+void flit::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/flexible-pipeline/flit.hh b/src/mem/ruby/network/garnet/flexible-pipeline/flit.hh
new file mode 100644
index 000000000..2cf3eaade
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/flit.hh
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/ruby/slicc_interface/Message.hh"
+
+#ifndef FLIT_H
+#define FLIT_H
+
+class flit {
+public:
+ flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr);
+
+ int get_size();
+ int get_id();
+ Time get_time();
+ Time get_enqueue_time();
+ void set_time(Time time);
+ int get_vnet();
+ int get_vc();
+ void set_vc(int vc);
+ MsgPtr& get_msg_ptr();
+ flit_type get_type();
+ void print(ostream&out) const;
+
+private:
+/************Data Members*************/
+ int m_id;
+ int m_vnet;
+ int m_vc;
+ int m_size;
+ Time m_enqueue_time, m_time;
+ flit_type m_type;
+ MsgPtr m_msg_ptr;
+
+};
+
+inline extern bool node_less_then_eq(flit* n1, flit* n2);
+
+inline extern
+bool node_less_then_eq(flit* n1, flit* 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& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const flit& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc b/src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc
new file mode 100644
index 000000000..d2f9244de
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
+
+flitBuffer::flitBuffer()
+{
+ max_size = INFINITE_;
+}
+
+flitBuffer::flitBuffer(int maximum_size)
+{
+ max_size = maximum_size;
+}
+
+bool flitBuffer::isEmpty()
+{
+ return (m_buffer.size() == 0);
+}
+
+bool flitBuffer::isReady()
+{
+ if(m_buffer.size() != 0 )
+ {
+ flit *t_flit = m_buffer.peekMin();
+ if(t_flit->get_time() <= g_eventQueue_ptr->getTime())
+ return true;
+ }
+ return false;
+}
+
+bool flitBuffer::isReadyForNext()
+{
+ if(m_buffer.size() != 0 )
+ {
+ flit *t_flit = m_buffer.peekMin();
+ if(t_flit->get_time() <= (g_eventQueue_ptr->getTime() + 1))
+ return true;
+ }
+ return false;
+}
+
+bool flitBuffer::isFull()
+{
+ return (m_buffer.size() >= max_size);
+}
+
+void flitBuffer::setMaxSize(int maximum)
+{
+ max_size = maximum;
+}
+
+flit* flitBuffer:: getTopFlit()
+{
+ return m_buffer.extractMin();
+}
+
+flit* flitBuffer::peekTopFlit()
+{
+ return m_buffer.peekMin();
+}
+
+void flitBuffer::insert(flit *flt)
+{
+ m_buffer.insert(flt);
+}
+
+void flitBuffer::print(ostream& out) const
+{
+ out << "[flitBuffer: ";
+ out << m_buffer.size() << "] " << endl;
+}
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh b/src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh
new file mode 100644
index 000000000..f8b34720c
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008 Princeton University
+ * 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: Niket Agarwal
+ */
+
+#ifndef FLIT_BUFFER_H
+#define FLIT_BUFFER_H
+
+#include "mem/ruby/network/garnet/NetworkHeader.hh"
+#include "mem/gems_common/PrioHeap.hh"
+#include "mem/ruby/network/garnet/flexible-pipeline/flit.hh"
+
+class flitBuffer {
+public:
+ flitBuffer();
+ flitBuffer(int maximum_size);
+
+ bool isReady();
+ bool isReadyForNext();
+ bool isFull();
+ bool isEmpty();
+ void setMaxSize(int maximum);
+ flit *getTopFlit();
+ flit *peekTopFlit();
+ void insert(flit *flt);
+ void print(ostream& out) const;
+
+/**********Data Members*********/
+private:
+ PrioHeap <flit *> m_buffer;
+ int size, max_size;
+};
+
+ostream& operator<<(ostream& out, const flitBuffer& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const flitBuffer& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif
+
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/netconfig.defaults b/src/mem/ruby/network/garnet/flexible-pipeline/netconfig.defaults
new file mode 100644
index 000000000..e60f1921d
--- /dev/null
+++ b/src/mem/ruby/network/garnet/flexible-pipeline/netconfig.defaults
@@ -0,0 +1,8 @@
+// Note: You should set Garnet's parameters in config/rubyconfig.defaults and not here
+g_GARNET_NETWORK:true
+g_DETAIL_NETWORK:true
+g_NETWORK_TESTING:false
+g_FLIT_SIZE:16
+g_NUM_PIPE_STAGES:4
+g_VCS_PER_CLASS:4
+g_BUFFER_SIZE:4