PhotonicClos.cc revision 10448
110448Snilay@cs.wisc.edu/* Copyright (c) 2012 Massachusetts Institute of Technology
210448Snilay@cs.wisc.edu *
310448Snilay@cs.wisc.edu * Permission is hereby granted, free of charge, to any person obtaining a copy
410448Snilay@cs.wisc.edu * of this software and associated documentation files (the "Software"), to deal
510448Snilay@cs.wisc.edu * in the Software without restriction, including without limitation the rights
610448Snilay@cs.wisc.edu * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
710448Snilay@cs.wisc.edu * copies of the Software, and to permit persons to whom the Software is
810448Snilay@cs.wisc.edu * furnished to do so, subject to the following conditions:
910448Snilay@cs.wisc.edu *
1010448Snilay@cs.wisc.edu * The above copyright notice and this permission notice shall be included in
1110448Snilay@cs.wisc.edu * all copies or substantial portions of the Software.
1210448Snilay@cs.wisc.edu *
1310448Snilay@cs.wisc.edu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1410448Snilay@cs.wisc.edu * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1510448Snilay@cs.wisc.edu * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1610448Snilay@cs.wisc.edu * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1710448Snilay@cs.wisc.edu * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1810448Snilay@cs.wisc.edu * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1910448Snilay@cs.wisc.edu * THE SOFTWARE.
2010448Snilay@cs.wisc.edu */
2110448Snilay@cs.wisc.edu
2210447Snilay@cs.wisc.edu#include "model/network/PhotonicClos.h"
2310447Snilay@cs.wisc.edu
2410447Snilay@cs.wisc.edu#include <cmath>
2510447Snilay@cs.wisc.edu
2610447Snilay@cs.wisc.edu#include "model/ModelGen.h"
2710447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalTimingTree.h"
2810447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalNet.h"
2910447Snilay@cs.wisc.edu
3010447Snilay@cs.wisc.edunamespace DSENT
3110447Snilay@cs.wisc.edu{
3210447Snilay@cs.wisc.edu    using std::sqrt;
3310447Snilay@cs.wisc.edu
3410447Snilay@cs.wisc.edu    PhotonicClos::PhotonicClos(const String& instance_name_, const TechModel* tech_model_)
3510447Snilay@cs.wisc.edu        : ElectricalModel(instance_name_, tech_model_)
3610447Snilay@cs.wisc.edu    {
3710447Snilay@cs.wisc.edu        initParameters();
3810447Snilay@cs.wisc.edu        initProperties();
3910447Snilay@cs.wisc.edu    }
4010447Snilay@cs.wisc.edu
4110447Snilay@cs.wisc.edu    PhotonicClos::~PhotonicClos()
4210447Snilay@cs.wisc.edu    {}
4310447Snilay@cs.wisc.edu
4410447Snilay@cs.wisc.edu    void PhotonicClos::initParameters()
4510447Snilay@cs.wisc.edu    {
4610447Snilay@cs.wisc.edu        // Clock Frequency
4710447Snilay@cs.wisc.edu        addParameterName("Frequency");
4810447Snilay@cs.wisc.edu        // Physical Parameters
4910447Snilay@cs.wisc.edu        addParameterName("NumberInputSites");
5010447Snilay@cs.wisc.edu        addParameterName("NumberOutputSites");
5110447Snilay@cs.wisc.edu        addParameterName("NumberBitsPerFlit");
5210447Snilay@cs.wisc.edu        // Number of each type of routers
5310447Snilay@cs.wisc.edu        addParameterName("NumberIngressRouters");
5410447Snilay@cs.wisc.edu        addParameterName("NumberMiddleRouters");
5510447Snilay@cs.wisc.edu        addParameterName("NumberEgressRouters");
5610447Snilay@cs.wisc.edu        // Optical link parameters
5710447Snilay@cs.wisc.edu        addParameterName("SWSR->LinkDataRate");
5810447Snilay@cs.wisc.edu        addParameterName("SWSR->LaserType");
5910447Snilay@cs.wisc.edu        addParameterName("SWSR->RingTuningMethod");
6010447Snilay@cs.wisc.edu        // Router parameters
6110447Snilay@cs.wisc.edu        addParameterName("Router->NumberVirtualNetworks");
6210447Snilay@cs.wisc.edu        addParameterName("Router->NumberVirtualChannelsPerVirtualNetwork");
6310447Snilay@cs.wisc.edu        addParameterName("Router->NumberBuffersPerVirtualChannel");
6410447Snilay@cs.wisc.edu        addParameterName("Router->InputPort->BufferModel");
6510447Snilay@cs.wisc.edu        addParameterName("Router->CrossbarModel");
6610447Snilay@cs.wisc.edu        addParameterName("Router->SwitchAllocator->ArbiterModel");
6710447Snilay@cs.wisc.edu        addParameterName("Router->ClockTreeModel");
6810447Snilay@cs.wisc.edu        addParameterName("Router->ClockTree->NumberLevels");
6910447Snilay@cs.wisc.edu        addParameterName("Router->ClockTree->WireLayer");
7010447Snilay@cs.wisc.edu        addParameterName("Router->ClockTree->WireWidthMultiplier");
7110447Snilay@cs.wisc.edu        addParameterName("Router->ClockTree->WireSpacingMultiplier", 3.0);
7210447Snilay@cs.wisc.edu        // Link parameters
7310447Snilay@cs.wisc.edu        addParameterName("Link->WireLayer");
7410447Snilay@cs.wisc.edu        addParameterName("Link->WireWidthMultiplier");
7510447Snilay@cs.wisc.edu        addParameterName("Link->WireSpacingMultiplier");
7610447Snilay@cs.wisc.edu        return;
7710447Snilay@cs.wisc.edu    }
7810447Snilay@cs.wisc.edu
7910447Snilay@cs.wisc.edu    void PhotonicClos::initProperties()
8010447Snilay@cs.wisc.edu    {
8110447Snilay@cs.wisc.edu        addPropertyName("InputSitePitch");
8210447Snilay@cs.wisc.edu        addPropertyName("OutputSitePitch");
8310447Snilay@cs.wisc.edu		addPropertyName("SWSR->OptUtil", 1.0);
8410447Snilay@cs.wisc.edu        return;
8510447Snilay@cs.wisc.edu    }
8610447Snilay@cs.wisc.edu
8710447Snilay@cs.wisc.edu    PhotonicClos* PhotonicClos::clone() const
8810447Snilay@cs.wisc.edu    {
8910447Snilay@cs.wisc.edu        // TODO
9010447Snilay@cs.wisc.edu        return NULL;
9110447Snilay@cs.wisc.edu    }
9210447Snilay@cs.wisc.edu
9310447Snilay@cs.wisc.edu    void PhotonicClos::constructModel()
9410447Snilay@cs.wisc.edu    {
9510447Snilay@cs.wisc.edu        // Get input parameters
9610447Snilay@cs.wisc.edu        double clock_freq = getParameter("Frequency");
9710447Snilay@cs.wisc.edu        unsigned int number_input_sites = getParameter("NumberInputSites").toUInt();
9810447Snilay@cs.wisc.edu        unsigned int number_output_sites = getParameter("NumberOutputSites").toUInt();
9910447Snilay@cs.wisc.edu        unsigned int number_bits_per_flit = getParameter("NumberBitsPerFlit").toUInt();
10010447Snilay@cs.wisc.edu        unsigned int number_ingress_routers = getParameter("NumberIngressRouters").toUInt();
10110447Snilay@cs.wisc.edu        unsigned int number_middle_routers = getParameter("NumberMiddleRouters").toUInt();
10210447Snilay@cs.wisc.edu        unsigned int number_egress_routers = getParameter("NumberEgressRouters").toUInt();
10310447Snilay@cs.wisc.edu
10410447Snilay@cs.wisc.edu        ASSERT(clock_freq > 0, "[Error] " + getInstanceName() +
10510447Snilay@cs.wisc.edu                " -> Clock frequency must be > 0!");
10610447Snilay@cs.wisc.edu        ASSERT(number_input_sites > 0, "[Error] " + getInstanceName() +
10710447Snilay@cs.wisc.edu                " -> Number of input sites must be > 0!");
10810447Snilay@cs.wisc.edu        ASSERT(number_output_sites > 0, "[Error] " + getInstanceName() +
10910447Snilay@cs.wisc.edu                " -> Number of output sites must be > 0!");
11010447Snilay@cs.wisc.edu        ASSERT(number_bits_per_flit > 0, "[Error] " + getInstanceName() +
11110447Snilay@cs.wisc.edu                " -> Number of bits per flit must be > 0!");
11210447Snilay@cs.wisc.edu        ASSERT(number_ingress_routers > 0, "[Error] " + getInstanceName() +
11310447Snilay@cs.wisc.edu                " -> Number of ingress routers must be > 0!");
11410447Snilay@cs.wisc.edu        ASSERT(number_middle_routers > 0, "[Error] " + getInstanceName() +
11510447Snilay@cs.wisc.edu                " -> Number of middle routers must be > 0!");
11610447Snilay@cs.wisc.edu        ASSERT(number_egress_routers > 0, "[Error] " + getInstanceName() +
11710447Snilay@cs.wisc.edu                " -> Number of egress routers must be > 0!");
11810447Snilay@cs.wisc.edu
11910447Snilay@cs.wisc.edu        // Get input parameters that will be forwarded to the sub instances
12010447Snilay@cs.wisc.edu        const String& swsr_link_data_rate = getParameter("SWSR->LinkDataRate");
12110447Snilay@cs.wisc.edu        const String& swsr_laser_type = getParameter("SWSR->LaserType");
12210447Snilay@cs.wisc.edu        const String& swsr_ring_tuning_method = getParameter("SWSR->RingTuningMethod");
12310447Snilay@cs.wisc.edu        const String& router_number_vns = getParameter("Router->NumberVirtualNetworks");
12410447Snilay@cs.wisc.edu        const String& router_number_vcs_per_vn = getParameter("Router->NumberVirtualChannelsPerVirtualNetwork");
12510447Snilay@cs.wisc.edu        const String& router_number_bufs_per_vc = getParameter("Router->NumberBuffersPerVirtualChannel");
12610447Snilay@cs.wisc.edu        const String& router_buffer_model = getParameter("Router->InputPort->BufferModel");
12710447Snilay@cs.wisc.edu        const String& router_crossbar_model = getParameter("Router->CrossbarModel");
12810447Snilay@cs.wisc.edu        const String& link_wire_layer = getParameter("Link->WireLayer");
12910447Snilay@cs.wisc.edu        const String& link_wire_width_multiplier = getParameter("Link->WireWidthMultiplier");
13010447Snilay@cs.wisc.edu        const String& link_wire_spacing_multiplier = getParameter("Link->WireSpacingMultiplier");
13110447Snilay@cs.wisc.edu
13210447Snilay@cs.wisc.edu        // Calculate properties from input parameters
13310447Snilay@cs.wisc.edu        unsigned int ingress_router_number_input_ports = number_input_sites / number_ingress_routers;
13410447Snilay@cs.wisc.edu        unsigned int ingress_router_number_output_ports = number_middle_routers;
13510447Snilay@cs.wisc.edu        unsigned int middle_router_number_input_ports = number_ingress_routers;
13610447Snilay@cs.wisc.edu        unsigned int middle_router_number_output_ports = number_egress_routers;
13710447Snilay@cs.wisc.edu        unsigned int egress_router_number_input_ports = number_middle_routers;
13810447Snilay@cs.wisc.edu        unsigned int egress_router_number_output_ports = number_output_sites / number_egress_routers;
13910447Snilay@cs.wisc.edu        unsigned int number_input_to_ingress_links = number_input_sites;
14010447Snilay@cs.wisc.edu        unsigned int number_ingress_to_middle_links = number_ingress_routers * number_middle_routers;
14110447Snilay@cs.wisc.edu        unsigned int number_middle_to_egress_links = number_middle_routers * number_egress_routers;
14210447Snilay@cs.wisc.edu        unsigned int number_egress_to_output_links = number_output_sites;
14310447Snilay@cs.wisc.edu
14410447Snilay@cs.wisc.edu        getGenProperties()->set("NumberInputSitesPerIngressRouter", ingress_router_number_input_ports);
14510447Snilay@cs.wisc.edu        getGenProperties()->set("NumberOutputSitesPerEgressRouter", egress_router_number_output_ports);
14610447Snilay@cs.wisc.edu        getGenProperties()->set("IngressRouter->NumberInputPorts", ingress_router_number_input_ports);
14710447Snilay@cs.wisc.edu        getGenProperties()->set("IngressRouter->NumberOutputPorts", ingress_router_number_output_ports);
14810447Snilay@cs.wisc.edu        getGenProperties()->set("MiddleRouter->NumberInputPorts", middle_router_number_input_ports);
14910447Snilay@cs.wisc.edu        getGenProperties()->set("MiddleRouter->NumberOutputPorts", middle_router_number_output_ports);
15010447Snilay@cs.wisc.edu        getGenProperties()->set("EgressRouter->NumberInputPorts", egress_router_number_input_ports);
15110447Snilay@cs.wisc.edu        getGenProperties()->set("EgressRouter->NumberOutputPorts", egress_router_number_output_ports);
15210447Snilay@cs.wisc.edu
15310447Snilay@cs.wisc.edu        // Create ports
15410447Snilay@cs.wisc.edu        createInputPort("CK");
15510447Snilay@cs.wisc.edu
15610447Snilay@cs.wisc.edu        // Init ingress router
15710447Snilay@cs.wisc.edu        ElectricalModel* ingress_router = (ElectricalModel*)ModelGen::createModel("Router", "IngressRouter", getTechModel());
15810447Snilay@cs.wisc.edu        ingress_router->setParameter("NumberInputPorts", ingress_router_number_input_ports);
15910447Snilay@cs.wisc.edu        ingress_router->setParameter("NumberOutputPorts", ingress_router_number_output_ports);
16010447Snilay@cs.wisc.edu        ingress_router->setParameter("NumberVirtualNetworks", router_number_vns);
16110447Snilay@cs.wisc.edu        ingress_router->setParameter("NumberVirtualChannelsPerVirtualNetwork", router_number_vcs_per_vn);
16210447Snilay@cs.wisc.edu        ingress_router->setParameter("NumberBuffersPerVirtualChannel", router_number_bufs_per_vc);
16310447Snilay@cs.wisc.edu        ingress_router->setParameter("NumberBitsPerFlit", number_bits_per_flit);
16410447Snilay@cs.wisc.edu        ingress_router->setParameter("InputPort->BufferModel", router_buffer_model);
16510447Snilay@cs.wisc.edu        ingress_router->setParameter("CrossbarModel", router_crossbar_model);
16610447Snilay@cs.wisc.edu        ingress_router->setParameter("SwitchAllocator->ArbiterModel", getParameter("Router->SwitchAllocator->ArbiterModel"));
16710447Snilay@cs.wisc.edu        ingress_router->setParameter("ClockTreeModel", getParameter("Router->ClockTreeModel"));
16810447Snilay@cs.wisc.edu        ingress_router->setParameter("ClockTree->NumberLevels", getParameter("Router->ClockTree->NumberLevels"));
16910447Snilay@cs.wisc.edu        ingress_router->setParameter("ClockTree->WireLayer", getParameter("Router->ClockTree->WireLayer"));
17010447Snilay@cs.wisc.edu        ingress_router->setParameter("ClockTree->WireWidthMultiplier", getParameter("Router->ClockTree->WireWidthMultiplier"));
17110447Snilay@cs.wisc.edu        ingress_router->setParameter("ClockTree->WireSpacingMultiplier", getParameter("Router->ClockTree->WireSpacingMultiplier"));
17210447Snilay@cs.wisc.edu        ingress_router->construct();
17310447Snilay@cs.wisc.edu        // Init middle routers
17410447Snilay@cs.wisc.edu        ElectricalModel* middle_router = (ElectricalModel*)ModelGen::createModel("Router", "MiddleRouter", getTechModel());
17510447Snilay@cs.wisc.edu        middle_router->setParameter("NumberInputPorts", middle_router_number_input_ports);
17610447Snilay@cs.wisc.edu        middle_router->setParameter("NumberOutputPorts", middle_router_number_output_ports);
17710447Snilay@cs.wisc.edu        middle_router->setParameter("NumberVirtualNetworks", router_number_vns);
17810447Snilay@cs.wisc.edu        middle_router->setParameter("NumberVirtualChannelsPerVirtualNetwork", router_number_vcs_per_vn);
17910447Snilay@cs.wisc.edu        middle_router->setParameter("NumberBuffersPerVirtualChannel", router_number_bufs_per_vc);
18010447Snilay@cs.wisc.edu        middle_router->setParameter("NumberBitsPerFlit", number_bits_per_flit);
18110447Snilay@cs.wisc.edu        middle_router->setParameter("InputPort->BufferModel", router_buffer_model);
18210447Snilay@cs.wisc.edu        middle_router->setParameter("CrossbarModel", router_crossbar_model);
18310447Snilay@cs.wisc.edu        middle_router->setParameter("SwitchAllocator->ArbiterModel", getParameter("Router->SwitchAllocator->ArbiterModel"));
18410447Snilay@cs.wisc.edu        middle_router->setParameter("ClockTreeModel", getParameter("Router->ClockTreeModel"));
18510447Snilay@cs.wisc.edu        middle_router->setParameter("ClockTree->NumberLevels", getParameter("Router->ClockTree->NumberLevels"));
18610447Snilay@cs.wisc.edu        middle_router->setParameter("ClockTree->WireLayer", getParameter("Router->ClockTree->WireLayer"));
18710447Snilay@cs.wisc.edu        middle_router->setParameter("ClockTree->WireWidthMultiplier", getParameter("Router->ClockTree->WireWidthMultiplier"));
18810447Snilay@cs.wisc.edu        middle_router->setParameter("ClockTree->WireSpacingMultiplier", getParameter("Router->ClockTree->WireSpacingMultiplier"));
18910447Snilay@cs.wisc.edu        middle_router->construct();
19010447Snilay@cs.wisc.edu        // Init egress routers
19110447Snilay@cs.wisc.edu        ElectricalModel* egress_router = (ElectricalModel*)ModelGen::createModel("Router", "EgressRouter", getTechModel());
19210447Snilay@cs.wisc.edu        egress_router->setParameter("NumberInputPorts", egress_router_number_input_ports);
19310447Snilay@cs.wisc.edu        egress_router->setParameter("NumberOutputPorts", egress_router_number_output_ports);
19410447Snilay@cs.wisc.edu        egress_router->setParameter("NumberVirtualNetworks", router_number_vns);
19510447Snilay@cs.wisc.edu        egress_router->setParameter("NumberVirtualChannelsPerVirtualNetwork", router_number_vcs_per_vn);
19610447Snilay@cs.wisc.edu        egress_router->setParameter("NumberBuffersPerVirtualChannel", router_number_bufs_per_vc);
19710447Snilay@cs.wisc.edu        egress_router->setParameter("NumberBitsPerFlit", number_bits_per_flit);
19810447Snilay@cs.wisc.edu        egress_router->setParameter("InputPort->BufferModel", router_buffer_model);
19910447Snilay@cs.wisc.edu        egress_router->setParameter("CrossbarModel", router_crossbar_model);
20010447Snilay@cs.wisc.edu        egress_router->setParameter("SwitchAllocator->ArbiterModel", getParameter("Router->SwitchAllocator->ArbiterModel"));
20110447Snilay@cs.wisc.edu        egress_router->setParameter("ClockTreeModel", getParameter("Router->ClockTreeModel"));
20210447Snilay@cs.wisc.edu        egress_router->setParameter("ClockTree->NumberLevels", getParameter("Router->ClockTree->NumberLevels"));
20310447Snilay@cs.wisc.edu        egress_router->setParameter("ClockTree->WireLayer", getParameter("Router->ClockTree->WireLayer"));
20410447Snilay@cs.wisc.edu        egress_router->setParameter("ClockTree->WireWidthMultiplier", getParameter("Router->ClockTree->WireWidthMultiplier"));
20510447Snilay@cs.wisc.edu        egress_router->setParameter("ClockTree->WireSpacingMultiplier", getParameter("Router->ClockTree->WireSpacingMultiplier"));
20610447Snilay@cs.wisc.edu        egress_router->construct();
20710447Snilay@cs.wisc.edu        // Init input to ingress link
20810447Snilay@cs.wisc.edu        ElectricalModel* input_to_ingress_link = (ElectricalModel*)ModelGen::createModel("RepeatedLink", "InputToIngressLink", getTechModel());
20910447Snilay@cs.wisc.edu        input_to_ingress_link->setParameter("NumberBits", number_bits_per_flit);
21010447Snilay@cs.wisc.edu        input_to_ingress_link->setParameter("WireLayer", link_wire_layer);
21110447Snilay@cs.wisc.edu        input_to_ingress_link->setParameter("WireWidthMultiplier", link_wire_width_multiplier);
21210447Snilay@cs.wisc.edu        input_to_ingress_link->setParameter("WireSpacingMultiplier", link_wire_spacing_multiplier);
21310447Snilay@cs.wisc.edu        input_to_ingress_link->construct();
21410447Snilay@cs.wisc.edu        // Init ingress to middle link
21510447Snilay@cs.wisc.edu        ElectricalModel* ingress_to_middle_link = (ElectricalModel*)ModelGen::createModel("SWSRLink", "IngressToMiddleLink", getTechModel());
21610447Snilay@cs.wisc.edu        ingress_to_middle_link->setParameter("NumberBits", number_bits_per_flit);
21710447Snilay@cs.wisc.edu        ingress_to_middle_link->setParameter("CoreDataRate", clock_freq);
21810447Snilay@cs.wisc.edu        ingress_to_middle_link->setParameter("LinkDataRate", swsr_link_data_rate);
21910447Snilay@cs.wisc.edu        ingress_to_middle_link->setParameter("LaserType", swsr_laser_type);
22010447Snilay@cs.wisc.edu        ingress_to_middle_link->setParameter("RingTuningMethod", swsr_ring_tuning_method);
22110447Snilay@cs.wisc.edu        ingress_to_middle_link->construct();
22210447Snilay@cs.wisc.edu        // Init middle to egress link
22310447Snilay@cs.wisc.edu        ElectricalModel* middle_to_egress_link = (ElectricalModel*)ModelGen::createModel("SWSRLink", "MiddleToEgressLink", getTechModel());
22410447Snilay@cs.wisc.edu        middle_to_egress_link->setParameter("NumberBits", number_bits_per_flit);
22510447Snilay@cs.wisc.edu        middle_to_egress_link->setParameter("CoreDataRate", clock_freq);
22610447Snilay@cs.wisc.edu        middle_to_egress_link->setParameter("LinkDataRate", swsr_link_data_rate);
22710447Snilay@cs.wisc.edu        middle_to_egress_link->setParameter("LaserType", swsr_laser_type);
22810447Snilay@cs.wisc.edu        middle_to_egress_link->setParameter("RingTuningMethod", swsr_ring_tuning_method);
22910447Snilay@cs.wisc.edu        middle_to_egress_link->construct();
23010447Snilay@cs.wisc.edu        // Init egress to output link
23110447Snilay@cs.wisc.edu        ElectricalModel* egress_to_output_link = (ElectricalModel*)ModelGen::createModel("RepeatedLink", "EgressToOutputLink", getTechModel());
23210447Snilay@cs.wisc.edu        egress_to_output_link->setParameter("NumberBits", number_bits_per_flit);
23310447Snilay@cs.wisc.edu        egress_to_output_link->setParameter("WireLayer", link_wire_layer);
23410447Snilay@cs.wisc.edu        egress_to_output_link->setParameter("WireWidthMultiplier", link_wire_width_multiplier);
23510447Snilay@cs.wisc.edu        egress_to_output_link->setParameter("WireSpacingMultiplier", link_wire_spacing_multiplier);
23610447Snilay@cs.wisc.edu        egress_to_output_link->construct();
23710447Snilay@cs.wisc.edu
23810447Snilay@cs.wisc.edu        // Connect ports
23910447Snilay@cs.wisc.edu        createNet("InputToIngressLink_Out", makeNetIndex(0, number_bits_per_flit - 1));
24010447Snilay@cs.wisc.edu        createNet("InputToIngressLink_In", makeNetIndex(0, number_bits_per_flit - 1));
24110447Snilay@cs.wisc.edu        portConnect(input_to_ingress_link, "In", "InputToIngressLink_In");
24210447Snilay@cs.wisc.edu        portConnect(input_to_ingress_link, "Out", "InputToIngressLink_Out");
24310447Snilay@cs.wisc.edu
24410447Snilay@cs.wisc.edu        createNet("IngressToMiddleLink_In", makeNetIndex(0, number_bits_per_flit - 1));
24510447Snilay@cs.wisc.edu        createNet("IngressToMiddleLink_Out", makeNetIndex(0, number_bits_per_flit - 1));
24610447Snilay@cs.wisc.edu        portConnect(ingress_to_middle_link, "In", "IngressToMiddleLink_In");
24710447Snilay@cs.wisc.edu        portConnect(ingress_to_middle_link, "Out", "IngressToMiddleLink_Out");
24810447Snilay@cs.wisc.edu
24910447Snilay@cs.wisc.edu        createNet("MiddleToEgressLink_In", makeNetIndex(0, number_bits_per_flit - 1));
25010447Snilay@cs.wisc.edu        createNet("MiddleToEgressLink_Out", makeNetIndex(0, number_bits_per_flit - 1));
25110447Snilay@cs.wisc.edu        portConnect(middle_to_egress_link, "In", "MiddleToEgressLink_In");
25210447Snilay@cs.wisc.edu        portConnect(middle_to_egress_link, "Out", "MiddleToEgressLink_Out");
25310447Snilay@cs.wisc.edu
25410447Snilay@cs.wisc.edu        createNet("EgressToOutputLink_In", makeNetIndex(0, number_bits_per_flit - 1));
25510447Snilay@cs.wisc.edu        createNet("EgressToOutputLink_Out", makeNetIndex(0, number_bits_per_flit - 1));
25610447Snilay@cs.wisc.edu        portConnect(egress_to_output_link, "In", "EgressToOutputLink_In");
25710447Snilay@cs.wisc.edu        portConnect(egress_to_output_link, "Out", "EgressToOutputLink_Out");
25810447Snilay@cs.wisc.edu
25910447Snilay@cs.wisc.edu        portConnect(ingress_router, "CK", "CK");
26010447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < ingress_router_number_input_ports; ++i)
26110447Snilay@cs.wisc.edu        {
26210447Snilay@cs.wisc.edu            createNet("IngressRouter_In" + (String)i, makeNetIndex(0, number_bits_per_flit-1));
26310447Snilay@cs.wisc.edu            for (unsigned int j = 0; j < number_bits_per_flit; ++j)
26410447Snilay@cs.wisc.edu                assignVirtualFanout("IngressRouter_In" + (String)i, makeNetIndex(j), "InputToIngressLink_Out", makeNetIndex(j));
26510447Snilay@cs.wisc.edu            portConnect(ingress_router, "FlitIn" + (String)i, "IngressRouter_In" + (String)i);
26610447Snilay@cs.wisc.edu        }
26710447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < ingress_router_number_output_ports; ++i)
26810447Snilay@cs.wisc.edu        {
26910447Snilay@cs.wisc.edu            // VFI
27010447Snilay@cs.wisc.edu            portConnect(ingress_router, "FlitOut" + (String)i, "IngressToMiddleLink_In");
27110447Snilay@cs.wisc.edu        }
27210447Snilay@cs.wisc.edu        portConnect(middle_router, "CK", "CK");
27310447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < middle_router_number_input_ports; ++i)
27410447Snilay@cs.wisc.edu        {
27510447Snilay@cs.wisc.edu            createNet("MiddleRouter_In" + (String)i, makeNetIndex(0, number_bits_per_flit-1));
27610447Snilay@cs.wisc.edu            for (unsigned int j = 0; j < number_bits_per_flit; ++j)
27710447Snilay@cs.wisc.edu                assignVirtualFanout("MiddleRouter_In" + (String)i, makeNetIndex(j), "IngressToMiddleLink_Out", makeNetIndex(j));
27810447Snilay@cs.wisc.edu            portConnect(middle_router, "FlitIn" + (String)i, "MiddleRouter_In" + (String)i);
27910447Snilay@cs.wisc.edu        }
28010447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < middle_router_number_output_ports; ++i)
28110447Snilay@cs.wisc.edu        {
28210447Snilay@cs.wisc.edu            // VFI
28310447Snilay@cs.wisc.edu            portConnect(middle_router, "FlitOut" + (String)i, "MiddleToEgressLink_In");
28410447Snilay@cs.wisc.edu        }
28510447Snilay@cs.wisc.edu        portConnect(egress_router, "CK", "CK");
28610447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < egress_router_number_input_ports; ++i)
28710447Snilay@cs.wisc.edu        {
28810447Snilay@cs.wisc.edu            createNet("EgressRouter_In" + (String)i, makeNetIndex(0, number_bits_per_flit-1));
28910447Snilay@cs.wisc.edu            for (unsigned int j = 0; j < number_bits_per_flit; ++j)
29010447Snilay@cs.wisc.edu                assignVirtualFanout("EgressRouter_In" + (String)i, makeNetIndex(j), "MiddleToEgressLink_Out", makeNetIndex(j));
29110447Snilay@cs.wisc.edu            portConnect(egress_router, "FlitIn" + (String)i, "EgressRouter_In" + (String)i);
29210447Snilay@cs.wisc.edu        }
29310447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < egress_router_number_output_ports; ++i)
29410447Snilay@cs.wisc.edu        {
29510447Snilay@cs.wisc.edu            // VFI
29610447Snilay@cs.wisc.edu            portConnect(egress_router, "FlitOut" + (String)i, "EgressToOutputLink_In");
29710447Snilay@cs.wisc.edu        }
29810447Snilay@cs.wisc.edu
29910447Snilay@cs.wisc.edu        // Create area, power, and event results
30010447Snilay@cs.wisc.edu        createElectricalResults();
30110447Snilay@cs.wisc.edu        createElectricalEventResult("AvgUnicast");
30210447Snilay@cs.wisc.edu        createElectricalEventResult("AvgBroadcast");
30310447Snilay@cs.wisc.edu        addNddPowerResult(new Result("Laser"));
30410447Snilay@cs.wisc.edu        addNddPowerResult(new Result("RingTuning"));
30510447Snilay@cs.wisc.edu        addAreaResult(new Result("Photonic"));
30610447Snilay@cs.wisc.edu
30710447Snilay@cs.wisc.edu        // Add all instances
30810447Snilay@cs.wisc.edu        addSubInstances(ingress_router, number_ingress_routers);
30910447Snilay@cs.wisc.edu        addElectricalSubResults(ingress_router, number_ingress_routers);
31010447Snilay@cs.wisc.edu        addSubInstances(middle_router, number_middle_routers);
31110447Snilay@cs.wisc.edu        addElectricalSubResults(middle_router, number_middle_routers);
31210447Snilay@cs.wisc.edu        addSubInstances(egress_router, number_egress_routers);
31310447Snilay@cs.wisc.edu        addElectricalSubResults(egress_router, number_egress_routers);
31410447Snilay@cs.wisc.edu        addSubInstances(input_to_ingress_link, number_input_to_ingress_links);
31510447Snilay@cs.wisc.edu        addElectricalSubResults(input_to_ingress_link, number_input_to_ingress_links);
31610447Snilay@cs.wisc.edu        addSubInstances(ingress_to_middle_link, number_ingress_to_middle_links);
31710447Snilay@cs.wisc.edu        addElectricalSubResults(ingress_to_middle_link, number_ingress_to_middle_links);
31810447Snilay@cs.wisc.edu        getAreaResult("Photonic")->addSubResult(ingress_to_middle_link->getAreaResult("Photonic"), "IngressToMiddleLink", number_ingress_to_middle_links);
31910447Snilay@cs.wisc.edu        getNddPowerResult("Laser")->addSubResult(ingress_to_middle_link->getNddPowerResult("Laser"), "IngressToMiddleLink", number_ingress_to_middle_links);
32010447Snilay@cs.wisc.edu        getNddPowerResult("RingTuning")->addSubResult(ingress_to_middle_link->getNddPowerResult("RingTuning"), "IngressToMiddleLink", number_ingress_to_middle_links);
32110447Snilay@cs.wisc.edu        addSubInstances(middle_to_egress_link, number_middle_to_egress_links);
32210447Snilay@cs.wisc.edu        addElectricalSubResults(middle_to_egress_link, number_middle_to_egress_links);
32310447Snilay@cs.wisc.edu        getAreaResult("Photonic")->addSubResult(middle_to_egress_link->getAreaResult("Photonic"), "MiddletoEgressLink", number_middle_to_egress_links);
32410447Snilay@cs.wisc.edu        getNddPowerResult("Laser")->addSubResult(middle_to_egress_link->getNddPowerResult("Laser"), "MiddleToEgressLink", number_middle_to_egress_links);
32510447Snilay@cs.wisc.edu        getNddPowerResult("RingTuning")->addSubResult(middle_to_egress_link->getNddPowerResult("RingTuning"), "MiddleToEgressLink", number_middle_to_egress_links);
32610447Snilay@cs.wisc.edu        addSubInstances(egress_to_output_link, number_egress_to_output_links);
32710447Snilay@cs.wisc.edu        addElectricalSubResults(egress_to_output_link, number_egress_to_output_links);
32810447Snilay@cs.wisc.edu
32910447Snilay@cs.wisc.edu        // Update unicast event
33010447Snilay@cs.wisc.edu        Result* avg_unicast_event = getEventResult("AvgUnicast");
33110447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(input_to_ingress_link->getEventResult("Send"), "InputToIngressLink", 1.0);
33210447Snilay@cs.wisc.edu        if(ingress_router->hasEventResult("WriteBuffer"))
33310447Snilay@cs.wisc.edu        {
33410447Snilay@cs.wisc.edu            avg_unicast_event->addSubResult(ingress_router->getEventResult("WriteBuffer"), "IngressRouter", 1.0);
33510447Snilay@cs.wisc.edu        }
33610447Snilay@cs.wisc.edu        if(ingress_router->hasEventResult("ReadBuffer"))
33710447Snilay@cs.wisc.edu        {
33810447Snilay@cs.wisc.edu            avg_unicast_event->addSubResult(ingress_router->getEventResult("ReadBuffer"), "IngressRouter", 1.0);
33910447Snilay@cs.wisc.edu        }
34010447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(ingress_router->getEventResult("TraverseCrossbar->Multicast1"), "IngressRouter", 1.0);
34110447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(ingress_to_middle_link->getEventResult("Send"), "IngressToMiddleLink", 1.0);
34210447Snilay@cs.wisc.edu        if(middle_router->hasEventResult("WriteBuffer"))
34310447Snilay@cs.wisc.edu        {
34410447Snilay@cs.wisc.edu            avg_unicast_event->addSubResult(middle_router->getEventResult("WriteBuffer"), "MiddleRouter", 1.0);
34510447Snilay@cs.wisc.edu        }
34610447Snilay@cs.wisc.edu        if(middle_router->hasEventResult("ReadBuffer"))
34710447Snilay@cs.wisc.edu        {
34810447Snilay@cs.wisc.edu            avg_unicast_event->addSubResult(middle_router->getEventResult("ReadBuffer"), "MiddleRouter", 1.0);
34910447Snilay@cs.wisc.edu        }
35010447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(middle_router->getEventResult("TraverseCrossbar->Multicast1"), "MiddleRouter", 1.0);
35110447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(middle_to_egress_link->getEventResult("Send"), "MiddleToEgressLink", 1.0);
35210447Snilay@cs.wisc.edu        if(egress_router->hasEventResult("WriteBuffer"))
35310447Snilay@cs.wisc.edu        {
35410447Snilay@cs.wisc.edu            avg_unicast_event->addSubResult(egress_router->getEventResult("WriteBuffer"), "EgressRouter", 1.0);
35510447Snilay@cs.wisc.edu        }
35610447Snilay@cs.wisc.edu        if(egress_router->hasEventResult("ReadBuffer"))
35710447Snilay@cs.wisc.edu        {
35810447Snilay@cs.wisc.edu            avg_unicast_event->addSubResult(egress_router->getEventResult("ReadBuffer"), "EgressRouter", 1.0);
35910447Snilay@cs.wisc.edu        }
36010447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(egress_router->getEventResult("TraverseCrossbar->Multicast1"), "EgressRouter", 1.0);
36110447Snilay@cs.wisc.edu        avg_unicast_event->addSubResult(egress_to_output_link->getEventResult("Send"), "EgressToOutputLink", 1.0);
36210447Snilay@cs.wisc.edu
36310447Snilay@cs.wisc.edu        // Update broadcast event
36410447Snilay@cs.wisc.edu        Result* avg_broadcast_event = getEventResult("AvgBroadcast");
36510447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(input_to_ingress_link->getEventResult("Send"), "InputToIngressLink", 1.0);
36610447Snilay@cs.wisc.edu        if(ingress_router->hasEventResult("WriteBuffer"))
36710447Snilay@cs.wisc.edu        {
36810447Snilay@cs.wisc.edu            avg_broadcast_event->addSubResult(ingress_router->getEventResult("WriteBuffer"), "IngressRouter", 1.0);
36910447Snilay@cs.wisc.edu        }
37010447Snilay@cs.wisc.edu        if(ingress_router->hasEventResult("ReadBuffer"))
37110447Snilay@cs.wisc.edu        {
37210447Snilay@cs.wisc.edu            avg_broadcast_event->addSubResult(ingress_router->getEventResult("ReadBuffer"), "IngressRouter", 1.0);
37310447Snilay@cs.wisc.edu        }
37410447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(ingress_router->getEventResult("TraverseCrossbar->Multicast1"), "IngressRouter", 1.0);
37510447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(ingress_to_middle_link->getEventResult("Send"), "IngressToMiddleLink", 1.0);
37610447Snilay@cs.wisc.edu        if(middle_router->hasEventResult("WriteBuffer"))
37710447Snilay@cs.wisc.edu        {
37810447Snilay@cs.wisc.edu            avg_broadcast_event->addSubResult(middle_router->getEventResult("WriteBuffer"), "MiddleRouter", 1.0);
37910447Snilay@cs.wisc.edu        }
38010447Snilay@cs.wisc.edu        if(middle_router->hasEventResult("ReadBuffer"))
38110447Snilay@cs.wisc.edu        {
38210447Snilay@cs.wisc.edu            avg_broadcast_event->addSubResult(middle_router->getEventResult("ReadBuffer"), "MiddleRouter", 1.0);
38310447Snilay@cs.wisc.edu        }
38410447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(middle_router->getEventResult("TraverseCrossbar->Multicast1"), "MiddleRouter", 1.0);
38510447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(middle_to_egress_link->getEventResult("Send"), "MiddleToEgressLink", number_egress_routers);
38610447Snilay@cs.wisc.edu        if(egress_router->hasEventResult("WriteBuffer"))
38710447Snilay@cs.wisc.edu        {
38810447Snilay@cs.wisc.edu            avg_broadcast_event->addSubResult(egress_router->getEventResult("WriteBuffer"), "EgressRouter", number_egress_routers);
38910447Snilay@cs.wisc.edu        }
39010447Snilay@cs.wisc.edu        if(egress_router->hasEventResult("ReadBuffer"))
39110447Snilay@cs.wisc.edu        {
39210447Snilay@cs.wisc.edu            avg_broadcast_event->addSubResult(egress_router->getEventResult("ReadBuffer"), "EgressRouter", number_egress_routers);
39310447Snilay@cs.wisc.edu        }
39410447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(egress_router->getEventResult("TraverseCrossbar->Multicast" + (String)number_egress_routers), "EgressRouter", 1.0);
39510447Snilay@cs.wisc.edu        avg_broadcast_event->addSubResult(egress_to_output_link->getEventResult("Send"), "EgressToOutputLink", number_output_sites);
39610447Snilay@cs.wisc.edu        return;
39710447Snilay@cs.wisc.edu    }
39810447Snilay@cs.wisc.edu
39910447Snilay@cs.wisc.edu    void PhotonicClos::updateModel()
40010447Snilay@cs.wisc.edu    {
40110447Snilay@cs.wisc.edu        // Assumes waveguide runs adjacent to ingress and egress routers
40210447Snilay@cs.wisc.edu        // Assumes input sites belonging to each ingress router are centered around the ingress router
40310447Snilay@cs.wisc.edu        // Assumes middle routers are distributed around the chip adjacent to the main waveguide
40410447Snilay@cs.wisc.edu        // Assumes output sites belonging to each egress router are centered around the egress router
40510447Snilay@cs.wisc.edu
40610447Snilay@cs.wisc.edu        // Get properties
40710447Snilay@cs.wisc.edu        double input_site_pitch = getProperty("InputSitePitch").toDouble();
40810447Snilay@cs.wisc.edu        double output_site_pitch = getProperty("OutputSitePitch").toDouble();
40910447Snilay@cs.wisc.edu        double clock_freq = getParameter("Frequency");
41010447Snilay@cs.wisc.edu		const double swsr_opt_util = getProperty("SWSR->OptUtil");
41110447Snilay@cs.wisc.edu
41210447Snilay@cs.wisc.edu        ASSERT(input_site_pitch > 0, "[Error] " + getInstanceName() +
41310447Snilay@cs.wisc.edu                " -> Input site pitch must be > 0!");
41410447Snilay@cs.wisc.edu        ASSERT(output_site_pitch > 0, "[Error] " + getInstanceName() +
41510447Snilay@cs.wisc.edu                " -> Output site pitch must be > 0!");
41610447Snilay@cs.wisc.edu
41710447Snilay@cs.wisc.edu        unsigned int number_input_sites_per_ingress_router = getGenProperties()->get("NumberInputSitesPerIngressRouter");
41810447Snilay@cs.wisc.edu        unsigned int number_ingress_routers = getParameter("NumberIngressRouters");
41910447Snilay@cs.wisc.edu        unsigned int number_output_sites_per_egress_router = getGenProperties()->get("NumberOutputSitesPerEgressRouter");
42010447Snilay@cs.wisc.edu        unsigned int number_egress_routers = getParameter("NumberEgressRouters");
42110447Snilay@cs.wisc.edu        double delay = 1.0 / clock_freq;
42210447Snilay@cs.wisc.edu
42310447Snilay@cs.wisc.edu        //Calculate the length of the waveguide
42410447Snilay@cs.wisc.edu        double input_to_ingress_link_length = input_site_pitch * (sqrt(number_input_sites_per_ingress_router) - 1.0);
42510447Snilay@cs.wisc.edu        double input_to_ingress_link_delay = delay * 0.8;
42610447Snilay@cs.wisc.edu        double ingress_to_middle_link_length = input_site_pitch * (sqrt(number_input_sites_per_ingress_router) * number_ingress_routers);
42710447Snilay@cs.wisc.edu        double middle_to_egress_link_length = output_site_pitch * (sqrt(number_output_sites_per_egress_router) * number_egress_routers);
42810447Snilay@cs.wisc.edu        double egress_to_output_link_length = output_site_pitch * (sqrt(number_output_sites_per_egress_router) - 1.0);
42910447Snilay@cs.wisc.edu        double egress_to_output_link_delay = delay * 0.8;
43010447Snilay@cs.wisc.edu        double ingress_router_delay = delay;
43110447Snilay@cs.wisc.edu        double middle_router_delay = delay;
43210447Snilay@cs.wisc.edu        double egress_router_delay = delay;
43310447Snilay@cs.wisc.edu
43410447Snilay@cs.wisc.edu        Model* input_to_ingress_link = getSubInstance("InputToIngressLink");
43510447Snilay@cs.wisc.edu        input_to_ingress_link->setProperty("WireLength", input_to_ingress_link_length);
43610447Snilay@cs.wisc.edu        input_to_ingress_link->setProperty("Delay", input_to_ingress_link_delay);
43710447Snilay@cs.wisc.edu        input_to_ingress_link->setProperty("IsKeepParity", "TRUE");
43810447Snilay@cs.wisc.edu        input_to_ingress_link->update();
43910447Snilay@cs.wisc.edu
44010447Snilay@cs.wisc.edu        Model* ingress_to_middle_link = getSubInstance("IngressToMiddleLink");
44110447Snilay@cs.wisc.edu        ingress_to_middle_link->setProperty("Length", ingress_to_middle_link_length);
44210447Snilay@cs.wisc.edu		ingress_to_middle_link->setProperty("OptUtil", swsr_opt_util);
44310447Snilay@cs.wisc.edu        ingress_to_middle_link->update();
44410447Snilay@cs.wisc.edu
44510447Snilay@cs.wisc.edu        Model* middle_to_egress_link = getSubInstance("MiddleToEgressLink");
44610447Snilay@cs.wisc.edu        middle_to_egress_link->setProperty("Length", middle_to_egress_link_length);
44710447Snilay@cs.wisc.edu		middle_to_egress_link->setProperty("OptUtil", swsr_opt_util);
44810447Snilay@cs.wisc.edu        middle_to_egress_link->update();
44910447Snilay@cs.wisc.edu
45010447Snilay@cs.wisc.edu        Model* egress_to_output_link = getSubInstance("EgressToOutputLink");
45110447Snilay@cs.wisc.edu        egress_to_output_link->setProperty("WireLength", egress_to_output_link_length);
45210447Snilay@cs.wisc.edu        egress_to_output_link->setProperty("Delay", egress_to_output_link_delay);
45310447Snilay@cs.wisc.edu        egress_to_output_link->setProperty("IsKeepParity", "TRUE");
45410447Snilay@cs.wisc.edu        egress_to_output_link->update();
45510447Snilay@cs.wisc.edu
45610447Snilay@cs.wisc.edu        ElectricalModel* ingress_router = (ElectricalModel*)getSubInstance("IngressRouter");
45710447Snilay@cs.wisc.edu        ingress_router->update();
45810447Snilay@cs.wisc.edu        ElectricalTimingTree ingress_router_timing_tree("IngressRouter", ingress_router);
45910447Snilay@cs.wisc.edu        ingress_router_timing_tree.performTimingOpt(ingress_router->getNet("CK"), ingress_router_delay);
46010447Snilay@cs.wisc.edu
46110447Snilay@cs.wisc.edu        ElectricalModel* middle_router = (ElectricalModel*)getSubInstance("MiddleRouter");
46210447Snilay@cs.wisc.edu        middle_router->update();
46310447Snilay@cs.wisc.edu        ElectricalTimingTree middle_router_timing_tree("MiddleRouter", middle_router);
46410447Snilay@cs.wisc.edu        middle_router_timing_tree.performTimingOpt(middle_router->getNet("CK"), middle_router_delay);
46510447Snilay@cs.wisc.edu
46610447Snilay@cs.wisc.edu        ElectricalModel* egress_router = (ElectricalModel*)getSubInstance("EgressRouter");
46710447Snilay@cs.wisc.edu        egress_router->update();
46810447Snilay@cs.wisc.edu        ElectricalTimingTree egress_router_timing_tree("EgressRouter", egress_router);
46910447Snilay@cs.wisc.edu        egress_router_timing_tree.performTimingOpt(egress_router->getNet("CK"), egress_router_delay);
47010447Snilay@cs.wisc.edu
47110447Snilay@cs.wisc.edu        return;
47210447Snilay@cs.wisc.edu    }
47310447Snilay@cs.wisc.edu
47410447Snilay@cs.wisc.edu    void PhotonicClos::propagateTransitionInfo()
47510447Snilay@cs.wisc.edu    {
47610447Snilay@cs.wisc.edu        // Get parameters
47710447Snilay@cs.wisc.edu        double clock_freq = getParameter("Frequency");
47810447Snilay@cs.wisc.edu        double swsr_link_data_rate = getParameter("SWSR->LinkDataRate");
47910447Snilay@cs.wisc.edu
48010447Snilay@cs.wisc.edu        // Get properties
48110447Snilay@cs.wisc.edu        unsigned int ingress_router_number_input_ports = getGenProperties()->get("IngressRouter->NumberInputPorts");
48210447Snilay@cs.wisc.edu        unsigned int middle_router_number_input_ports = getGenProperties()->get("MiddleRouter->NumberInputPorts");
48310447Snilay@cs.wisc.edu        unsigned int egress_router_number_input_ports = getGenProperties()->get("EgressRouter->NumberInputPorts");
48410447Snilay@cs.wisc.edu
48510447Snilay@cs.wisc.edu        ElectricalModel* input_to_ingress_link = (ElectricalModel*)getSubInstance("InputToIngressLink");
48610447Snilay@cs.wisc.edu        assignPortTransitionInfo(input_to_ingress_link, "In", TransitionInfo(0.25, 0.25, 0.25));
48710447Snilay@cs.wisc.edu        input_to_ingress_link->use();
48810447Snilay@cs.wisc.edu
48910447Snilay@cs.wisc.edu        ElectricalModel* ingress_to_middle_link = (ElectricalModel*)getSubInstance("IngressToMiddleLink");
49010447Snilay@cs.wisc.edu        assignPortTransitionInfo(ingress_to_middle_link, "LinkCK", TransitionInfo(0.0, (double) clock_freq / (swsr_link_data_rate * 2.0), 0.0));
49110447Snilay@cs.wisc.edu        assignPortTransitionInfo(ingress_to_middle_link, "In", TransitionInfo(0.25, 0.25, 0.25));
49210447Snilay@cs.wisc.edu        ingress_to_middle_link->use();
49310447Snilay@cs.wisc.edu
49410447Snilay@cs.wisc.edu        ElectricalModel* middle_to_egress_link = (ElectricalModel*)getSubInstance("MiddleToEgressLink");
49510447Snilay@cs.wisc.edu        assignPortTransitionInfo(middle_to_egress_link, "LinkCK", TransitionInfo(0.0, (double) clock_freq / (swsr_link_data_rate * 2.0), 0.0));
49610447Snilay@cs.wisc.edu        assignPortTransitionInfo(middle_to_egress_link, "In", TransitionInfo(0.25, 0.25, 0.25));
49710447Snilay@cs.wisc.edu        middle_to_egress_link->use();
49810447Snilay@cs.wisc.edu
49910447Snilay@cs.wisc.edu        ElectricalModel* egress_to_output_link = (ElectricalModel*)getSubInstance("EgressToOutputLink");
50010447Snilay@cs.wisc.edu        assignPortTransitionInfo(egress_to_output_link, "In", TransitionInfo(0.25, 0.25, 0.25));
50110447Snilay@cs.wisc.edu        egress_to_output_link->use();
50210447Snilay@cs.wisc.edu
50310447Snilay@cs.wisc.edu        ElectricalModel* ingress_router = (ElectricalModel*)getSubInstance("IngressRouter");
50410447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < ingress_router_number_input_ports; ++i)
50510447Snilay@cs.wisc.edu        {
50610447Snilay@cs.wisc.edu            assignPortTransitionInfo(ingress_router, "FlitIn" + (String)i, TransitionInfo(0.25, 0.25, 0.25));
50710447Snilay@cs.wisc.edu        }
50810447Snilay@cs.wisc.edu        assignPortTransitionInfo(ingress_router, "CK", TransitionInfo(0.0, 1.0, 0.0));
50910447Snilay@cs.wisc.edu        ingress_router->getGenProperties()->set("UseModelEvent", "");
51010447Snilay@cs.wisc.edu        ingress_router->use();
51110447Snilay@cs.wisc.edu
51210447Snilay@cs.wisc.edu        ElectricalModel* middle_router = (ElectricalModel*)getSubInstance("MiddleRouter");
51310447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < middle_router_number_input_ports; ++i)
51410447Snilay@cs.wisc.edu        {
51510447Snilay@cs.wisc.edu            assignPortTransitionInfo(middle_router, "FlitIn" + (String)i, TransitionInfo(0.25, 0.25, 0.25));
51610447Snilay@cs.wisc.edu        }
51710447Snilay@cs.wisc.edu        assignPortTransitionInfo(middle_router, "CK", TransitionInfo(0.0, 1.0, 0.0));
51810447Snilay@cs.wisc.edu        middle_router->getGenProperties()->set("UseModelEvent", "");
51910447Snilay@cs.wisc.edu        middle_router->use();
52010447Snilay@cs.wisc.edu
52110447Snilay@cs.wisc.edu        ElectricalModel* egress_router = (ElectricalModel*)getSubInstance("EgressRouter");
52210447Snilay@cs.wisc.edu        for(unsigned int i = 0; i < egress_router_number_input_ports; ++i)
52310447Snilay@cs.wisc.edu        {
52410447Snilay@cs.wisc.edu            assignPortTransitionInfo(egress_router, "FlitIn" + (String)i, TransitionInfo(0.25, 0.25, 0.25));
52510447Snilay@cs.wisc.edu        }
52610447Snilay@cs.wisc.edu        assignPortTransitionInfo(egress_router, "CK", TransitionInfo(0.0, 1.0, 0.0));
52710447Snilay@cs.wisc.edu        egress_router->getGenProperties()->set("UseModelEvent", "");
52810447Snilay@cs.wisc.edu        egress_router->use();
52910447Snilay@cs.wisc.edu
53010447Snilay@cs.wisc.edu        return;
53110447Snilay@cs.wisc.edu    }
53210447Snilay@cs.wisc.edu} // namespace DSENT
53310447Snilay@cs.wisc.edu
534