noc.cc revision 10152
110152Satgutier@umich.edu/*****************************************************************************
210152Satgutier@umich.edu *                                McPAT
310152Satgutier@umich.edu *                      SOFTWARE LICENSE AGREEMENT
410152Satgutier@umich.edu *            Copyright 2012 Hewlett-Packard Development Company, L.P.
510152Satgutier@umich.edu *                          All Rights Reserved
610152Satgutier@umich.edu *
710152Satgutier@umich.edu * Redistribution and use in source and binary forms, with or without
810152Satgutier@umich.edu * modification, are permitted provided that the following conditions are
910152Satgutier@umich.edu * met: redistributions of source code must retain the above copyright
1010152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer;
1110152Satgutier@umich.edu * redistributions in binary form must reproduce the above copyright
1210152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer in the
1310152Satgutier@umich.edu * documentation and/or other materials provided with the distribution;
1410152Satgutier@umich.edu * neither the name of the copyright holders nor the names of its
1510152Satgutier@umich.edu * contributors may be used to endorse or promote products derived from
1610152Satgutier@umich.edu * this software without specific prior written permission.
1710152Satgutier@umich.edu
1810152Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1910152Satgutier@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2010152Satgutier@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2110152Satgutier@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2210152Satgutier@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2310152Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2410152Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2510152Satgutier@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2610152Satgutier@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2710152Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2810152Satgutier@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.”
2910152Satgutier@umich.edu *
3010152Satgutier@umich.edu ***************************************************************************/
3110152Satgutier@umich.edu
3210152Satgutier@umich.edu#include <algorithm>
3310152Satgutier@umich.edu#include <cassert>
3410152Satgutier@umich.edu#include <cmath>
3510152Satgutier@umich.edu#include <iostream>
3610152Satgutier@umich.edu#include <string>
3710152Satgutier@umich.edu
3810152Satgutier@umich.edu#include "XML_Parse.h"
3910152Satgutier@umich.edu#include "basic_circuit.h"
4010152Satgutier@umich.edu#include "const.h"
4110152Satgutier@umich.edu#include "io.h"
4210152Satgutier@umich.edu#include "noc.h"
4310152Satgutier@umich.edu#include "parameter.h"
4410152Satgutier@umich.edu
4510152Satgutier@umich.eduNoC::NoC(ParseXML *XML_interface, int ithNoC_, InputParameter* interface_ip_, double M_traffic_pattern_, double link_len_)
4610152Satgutier@umich.edu:XML(XML_interface),
4710152Satgutier@umich.eduithNoC(ithNoC_),
4810152Satgutier@umich.eduinterface_ip(*interface_ip_),
4910152Satgutier@umich.edurouter(0),
5010152Satgutier@umich.edulink_bus(0),
5110152Satgutier@umich.edulink_bus_exist(false),
5210152Satgutier@umich.edurouter_exist(false),
5310152Satgutier@umich.eduM_traffic_pattern(M_traffic_pattern_)
5410152Satgutier@umich.edu{
5510152Satgutier@umich.edu        /*
5610152Satgutier@umich.edu         * initialize, compute and optimize individual components.
5710152Satgutier@umich.edu         */
5810152Satgutier@umich.edu
5910152Satgutier@umich.edu        if (XML->sys.Embedded)
6010152Satgutier@umich.edu                        {
6110152Satgutier@umich.edu                        interface_ip.wt                  =Global_30;
6210152Satgutier@umich.edu                        interface_ip.wire_is_mat_type = 0;
6310152Satgutier@umich.edu                        interface_ip.wire_os_mat_type = 1;
6410152Satgutier@umich.edu                        }
6510152Satgutier@umich.edu                else
6610152Satgutier@umich.edu                        {
6710152Satgutier@umich.edu                        interface_ip.wt                  =Global;
6810152Satgutier@umich.edu                        interface_ip.wire_is_mat_type = 2;
6910152Satgutier@umich.edu                        interface_ip.wire_os_mat_type = 2;
7010152Satgutier@umich.edu                        }
7110152Satgutier@umich.edu        set_noc_param();
7210152Satgutier@umich.edu        local_result=init_interface(&interface_ip);
7310152Satgutier@umich.edu        scktRatio = g_tp.sckt_co_eff;
7410152Satgutier@umich.edu
7510152Satgutier@umich.edu        if (nocdynp.type)
7610152Satgutier@umich.edu        {/*
7710152Satgutier@umich.edu                 * if NOC compute router, router links must be computed separately
7810152Satgutier@umich.edu                 * and called from external
7910152Satgutier@umich.edu                 * since total chip area must be known first
8010152Satgutier@umich.edu                 */
8110152Satgutier@umich.edu                init_router();
8210152Satgutier@umich.edu        }
8310152Satgutier@umich.edu        else
8410152Satgutier@umich.edu        {
8510152Satgutier@umich.edu                init_link_bus(link_len_); //if bus compute bus
8610152Satgutier@umich.edu        }
8710152Satgutier@umich.edu
8810152Satgutier@umich.edu        //  //clock power
8910152Satgutier@umich.edu        //  clockNetwork.init_wire_external(is_default, &interface_ip);
9010152Satgutier@umich.edu        //  clockNetwork.clk_area           =area*1.1;//10% of placement overhead. rule of thumb
9110152Satgutier@umich.edu        //  clockNetwork.end_wiring_level   =5;//toplevel metal
9210152Satgutier@umich.edu        //  clockNetwork.start_wiring_level =5;//toplevel metal
9310152Satgutier@umich.edu        //  clockNetwork.num_regs           = corepipe.tot_stage_vector;
9410152Satgutier@umich.edu        //  clockNetwork.optimize_wire();
9510152Satgutier@umich.edu}
9610152Satgutier@umich.edu
9710152Satgutier@umich.eduvoid NoC::init_router()
9810152Satgutier@umich.edu{
9910152Satgutier@umich.edu        router  = new Router(nocdynp.flit_size,
10010152Satgutier@umich.edu                        nocdynp.virtual_channel_per_port*nocdynp.input_buffer_entries_per_vc,
10110152Satgutier@umich.edu                        nocdynp.virtual_channel_per_port, &(g_tp.peri_global),
10210152Satgutier@umich.edu                        nocdynp.input_ports,nocdynp.output_ports, M_traffic_pattern);
10310152Satgutier@umich.edu        //router->print_router();
10410152Satgutier@umich.edu        area.set_area(area.get_area()+ router->area.get_area()*nocdynp.total_nodes);
10510152Satgutier@umich.edu
10610152Satgutier@umich.edu        double long_channel_device_reduction = longer_channel_device_reduction(Uncore_device);
10710152Satgutier@umich.edu        router->power.readOp.longer_channel_leakage          = router->power.readOp.leakage * long_channel_device_reduction;
10810152Satgutier@umich.edu        router->buffer.power.readOp.longer_channel_leakage   = router->buffer.power.readOp.leakage * long_channel_device_reduction;
10910152Satgutier@umich.edu        router->crossbar.power.readOp.longer_channel_leakage = router->crossbar.power.readOp.leakage * long_channel_device_reduction;
11010152Satgutier@umich.edu        router->arbiter.power.readOp.longer_channel_leakage  = router->arbiter.power.readOp.leakage * long_channel_device_reduction;
11110152Satgutier@umich.edu        router_exist = true;
11210152Satgutier@umich.edu}
11310152Satgutier@umich.edu
11410152Satgutier@umich.eduvoid NoC ::init_link_bus(double link_len_)
11510152Satgutier@umich.edu{
11610152Satgutier@umich.edu
11710152Satgutier@umich.edu
11810152Satgutier@umich.edu//	if (nocdynp.min_ports==1 )
11910152Satgutier@umich.edu        if (nocdynp.type)
12010152Satgutier@umich.edu                link_name = "Links";
12110152Satgutier@umich.edu        else
12210152Satgutier@umich.edu                link_name = "Bus";
12310152Satgutier@umich.edu
12410152Satgutier@umich.edu        link_len=link_len_;
12510152Satgutier@umich.edu        assert(link_len>0);
12610152Satgutier@umich.edu
12710152Satgutier@umich.edu        interface_ip.throughput = nocdynp.link_throughput/nocdynp.clockRate;
12810152Satgutier@umich.edu        interface_ip.latency = nocdynp.link_latency/nocdynp.clockRate;
12910152Satgutier@umich.edu
13010152Satgutier@umich.edu        link_len /= (nocdynp.horizontal_nodes + nocdynp.vertical_nodes)/2;
13110152Satgutier@umich.edu
13210152Satgutier@umich.edu        if (nocdynp.total_nodes >1) link_len /=2; //All links are shared by neighbors
13310152Satgutier@umich.edu        link_bus = new interconnect(name, Uncore_device, 1, 1, nocdynp.flit_size,
13410152Satgutier@umich.edu                                  link_len, &interface_ip, 3, true/*pipelinable*/, nocdynp.route_over_perc);
13510152Satgutier@umich.edu
13610152Satgutier@umich.edu        link_bus_tot_per_Router.area.set_area(link_bus_tot_per_Router.area.get_area()+ link_bus->area.get_area()
13710152Satgutier@umich.edu                        * nocdynp.global_linked_ports);
13810152Satgutier@umich.edu
13910152Satgutier@umich.edu        area.set_area(area.get_area()+ link_bus_tot_per_Router.area.get_area()* nocdynp.total_nodes);
14010152Satgutier@umich.edu        link_bus_exist = true;
14110152Satgutier@umich.edu}
14210152Satgutier@umich.eduvoid NoC::computeEnergy(bool is_tdp)
14310152Satgutier@umich.edu{
14410152Satgutier@umich.edu        //power_point_product_masks
14510152Satgutier@umich.edu        double pppm_t[4]    = {1,1,1,1};
14610152Satgutier@umich.edu        double M=nocdynp.duty_cycle;
14710152Satgutier@umich.edu        if (is_tdp)
14810152Satgutier@umich.edu            {
14910152Satgutier@umich.edu                //init stats for TDP
15010152Satgutier@umich.edu                stats_t.readAc.access  = M;
15110152Satgutier@umich.edu            tdp_stats = stats_t;
15210152Satgutier@umich.edu            if (router_exist)
15310152Satgutier@umich.edu            {
15410152Satgutier@umich.edu                set_pppm(pppm_t, 1*M, 1, 1, 1);//reset traffic pattern
15510152Satgutier@umich.edu                router->power = router->power*pppm_t;
15610152Satgutier@umich.edu                set_pppm(pppm_t, nocdynp.total_nodes, nocdynp.total_nodes, nocdynp.total_nodes, nocdynp.total_nodes);
15710152Satgutier@umich.edu                    power     = power + router->power*pppm_t;
15810152Satgutier@umich.edu            }
15910152Satgutier@umich.edu            if (link_bus_exist)
16010152Satgutier@umich.edu            {
16110152Satgutier@umich.edu                if (nocdynp.type)
16210152Satgutier@umich.edu                        set_pppm(pppm_t, 1*M_traffic_pattern*M*(nocdynp.min_ports -1), nocdynp.global_linked_ports,
16310152Satgutier@umich.edu                                nocdynp.global_linked_ports, nocdynp.global_linked_ports);
16410152Satgutier@umich.edu                    //reset traffic pattern; local port do not have router links
16510152Satgutier@umich.edu                else
16610152Satgutier@umich.edu                        set_pppm(pppm_t, 1*M_traffic_pattern*M*(nocdynp.min_ports), nocdynp.global_linked_ports,
16710152Satgutier@umich.edu                                                        nocdynp.global_linked_ports, nocdynp.global_linked_ports);//reset traffic pattern
16810152Satgutier@umich.edu
16910152Satgutier@umich.edu                link_bus_tot_per_Router.power = link_bus->power*pppm_t;
17010152Satgutier@umich.edu
17110152Satgutier@umich.edu                set_pppm(pppm_t, nocdynp.total_nodes,
17210152Satgutier@umich.edu                                         nocdynp.total_nodes,
17310152Satgutier@umich.edu                                         nocdynp.total_nodes,
17410152Satgutier@umich.edu                                         nocdynp.total_nodes);
17510152Satgutier@umich.edu                power     = power + link_bus_tot_per_Router.power*pppm_t;
17610152Satgutier@umich.edu
17710152Satgutier@umich.edu            }
17810152Satgutier@umich.edu            }
17910152Satgutier@umich.edu            else
18010152Satgutier@umich.edu            {
18110152Satgutier@umich.edu                //init stats for runtime power (RTP)
18210152Satgutier@umich.edu                stats_t.readAc.access  = XML->sys.NoC[ithNoC].total_accesses;
18310152Satgutier@umich.edu            rtp_stats = stats_t;
18410152Satgutier@umich.edu                set_pppm(pppm_t, 1, 0 , 0, 0);
18510152Satgutier@umich.edu                if (router_exist)
18610152Satgutier@umich.edu                {
18710152Satgutier@umich.edu                router->buffer.rt_power.readOp.dynamic = (router->buffer.power.readOp.dynamic + router->buffer.power.writeOp.dynamic)*rtp_stats.readAc.access ;
18810152Satgutier@umich.edu                router->crossbar.rt_power.readOp.dynamic = router->crossbar.power.readOp.dynamic*rtp_stats.readAc.access ;
18910152Satgutier@umich.edu                router->arbiter.rt_power.readOp.dynamic = router->arbiter.power.readOp.dynamic*rtp_stats.readAc.access ;
19010152Satgutier@umich.edu
19110152Satgutier@umich.edu                        router->rt_power = router->rt_power + (router->buffer.rt_power + router->crossbar.rt_power + router->arbiter.rt_power)*pppm_t +
19210152Satgutier@umich.edu                                        router->power*pppm_lkg;//TDP power must be calculated first!
19310152Satgutier@umich.edu                        rt_power     = rt_power + router->rt_power;
19410152Satgutier@umich.edu                }
19510152Satgutier@umich.edu                if (link_bus_exist)
19610152Satgutier@umich.edu                {
19710152Satgutier@umich.edu                        set_pppm(pppm_t, rtp_stats.readAc.access, 1 , 1, rtp_stats.readAc.access);
19810152Satgutier@umich.edu                        link_bus->rt_power = link_bus->power * pppm_t;
19910152Satgutier@umich.edu                        rt_power = rt_power + link_bus->rt_power;
20010152Satgutier@umich.edu                }
20110152Satgutier@umich.edu
20210152Satgutier@umich.edu            }
20310152Satgutier@umich.edu}
20410152Satgutier@umich.edu
20510152Satgutier@umich.edu
20610152Satgutier@umich.eduvoid NoC::displayEnergy(uint32_t indent,int plevel,bool is_tdp)
20710152Satgutier@umich.edu{
20810152Satgutier@umich.edu        string indent_str(indent, ' ');
20910152Satgutier@umich.edu        string indent_str_next(indent+2, ' ');
21010152Satgutier@umich.edu        bool long_channel = XML->sys.longer_channel_device;
21110152Satgutier@umich.edu
21210152Satgutier@umich.edu        double M =M_traffic_pattern*nocdynp.duty_cycle;
21310152Satgutier@umich.edu        /*only router as a whole has been applied the M_traffic_pattern(0.6 by default) factor in router.cc;
21410152Satgutier@umich.edu         * 	When power of crossbars, arbiters, etc need to be displayed, the M_traffic_pattern factor need to
21510152Satgutier@umich.edu         * be applied together with McPAT's extra traffic pattern.
21610152Satgutier@umich.edu         * */
21710152Satgutier@umich.edu        if (is_tdp)
21810152Satgutier@umich.edu        {
21910152Satgutier@umich.edu                cout << name << endl;
22010152Satgutier@umich.edu                cout << indent_str << "Area = " << area.get_area()*1e-6<< " mm^2" << endl;
22110152Satgutier@umich.edu                cout << indent_str<< "Peak Dynamic = " << power.readOp.dynamic*nocdynp.clockRate << " W" << endl;
22210152Satgutier@umich.edu                cout << indent_str << "Subthreshold Leakage = "
22310152Satgutier@umich.edu                        << (long_channel? power.readOp.longer_channel_leakage:power.readOp.leakage) <<" W" << endl;
22410152Satgutier@umich.edu                cout << indent_str << "Gate Leakage = " << power.readOp.gate_leakage << " W" << endl;
22510152Satgutier@umich.edu                cout << indent_str<< "Runtime Dynamic = " << rt_power.readOp.dynamic/nocdynp.executionTime << " W" << endl;
22610152Satgutier@umich.edu                cout<<endl;
22710152Satgutier@umich.edu
22810152Satgutier@umich.edu                if (router_exist)
22910152Satgutier@umich.edu                {
23010152Satgutier@umich.edu                        cout << indent_str << "Router: " << endl;
23110152Satgutier@umich.edu                        cout << indent_str_next << "Area = " << router->area.get_area()*1e-6<< " mm^2" << endl;
23210152Satgutier@umich.edu                        cout << indent_str_next<< "Peak Dynamic = " << router->power.readOp.dynamic*nocdynp.clockRate << " W" << endl;
23310152Satgutier@umich.edu                        cout << indent_str_next << "Subthreshold Leakage = "
23410152Satgutier@umich.edu                        << (long_channel? router->power.readOp.longer_channel_leakage:router->power.readOp.leakage)  <<" W" << endl;
23510152Satgutier@umich.edu                        cout << indent_str_next << "Gate Leakage = " << router->power.readOp.gate_leakage << " W" << endl;
23610152Satgutier@umich.edu                        cout << indent_str_next<< "Runtime Dynamic = " << router->rt_power.readOp.dynamic/nocdynp.executionTime << " W" << endl;
23710152Satgutier@umich.edu                        cout<<endl;
23810152Satgutier@umich.edu                        if (plevel >2){
23910152Satgutier@umich.edu                                cout << indent_str<< indent_str << "Virtual Channel Buffer:" << endl;
24010152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Area = " << router->buffer.area.get_area()*1e-6*nocdynp.input_ports<< " mm^2" << endl;
24110152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Peak Dynamic = " <<(router->buffer.power.readOp.dynamic + router->buffer.power.writeOp.dynamic)
24210152Satgutier@umich.edu                                *nocdynp.min_ports*M*nocdynp.clockRate << " W" << endl;
24310152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Subthreshold Leakage = "
24410152Satgutier@umich.edu                                << (long_channel? router->buffer.power.readOp.longer_channel_leakage*nocdynp.input_ports:router->buffer.power.readOp.leakage*nocdynp.input_ports)  <<" W" << endl;
24510152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Gate Leakage = " << router->buffer.power.readOp.gate_leakage*nocdynp.input_ports << " W" << endl;
24610152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Runtime Dynamic = " << router->buffer.rt_power.readOp.dynamic/nocdynp.executionTime << " W" << endl;
24710152Satgutier@umich.edu                                cout <<endl;
24810152Satgutier@umich.edu                                cout << indent_str<< indent_str<< "Crossbar:" << endl;
24910152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Area = " << router->crossbar.area.get_area()*1e-6  << " mm^2" << endl;
25010152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Peak Dynamic = " << router->crossbar.power.readOp.dynamic*nocdynp.clockRate*nocdynp.min_ports*M << " W" << endl;
25110152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Subthreshold Leakage = "
25210152Satgutier@umich.edu                                << (long_channel? router->crossbar.power.readOp.longer_channel_leakage:router->crossbar.power.readOp.leakage)  << " W" << endl;
25310152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Gate Leakage = " << router->crossbar.power.readOp.gate_leakage  << " W" << endl;
25410152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Runtime Dynamic = " << router->crossbar.rt_power.readOp.dynamic/nocdynp.executionTime << " W" << endl;
25510152Satgutier@umich.edu                                cout <<endl;
25610152Satgutier@umich.edu                                cout << indent_str<< indent_str<< "Arbiter:" << endl;
25710152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Peak Dynamic = " << router->arbiter.power.readOp.dynamic*nocdynp.clockRate*nocdynp.min_ports*M  << " W" << endl;
25810152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Subthreshold Leakage = "
25910152Satgutier@umich.edu                                << (long_channel? router->arbiter.power.readOp.longer_channel_leakage:router->arbiter.power.readOp.leakage)  << " W" << endl;
26010152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Gate Leakage = " << router->arbiter.power.readOp.gate_leakage  << " W" << endl;
26110152Satgutier@umich.edu                                cout << indent_str<< indent_str_next << "Runtime Dynamic = " << router->arbiter.rt_power.readOp.dynamic/nocdynp.executionTime << " W" << endl;
26210152Satgutier@umich.edu                                cout <<endl;
26310152Satgutier@umich.edu                        }
26410152Satgutier@umich.edu                }
26510152Satgutier@umich.edu                if (link_bus_exist)
26610152Satgutier@umich.edu                {
26710152Satgutier@umich.edu                        cout << indent_str << (nocdynp.type? "Per Router ":"") << link_name<<": " << endl;
26810152Satgutier@umich.edu                        cout << indent_str_next << "Area = " << link_bus_tot_per_Router.area.get_area()*1e-6<< " mm^2" << endl;
26910152Satgutier@umich.edu                        cout << indent_str_next<< "Peak Dynamic = " << link_bus_tot_per_Router.power.readOp.dynamic*
27010152Satgutier@umich.edu                                nocdynp.clockRate << " W" << endl;
27110152Satgutier@umich.edu                        cout << indent_str_next << "Subthreshold Leakage = "
27210152Satgutier@umich.edu                        << (long_channel? link_bus_tot_per_Router.power.readOp.longer_channel_leakage:link_bus_tot_per_Router.power.readOp.leakage)
27310152Satgutier@umich.edu                             <<" W" << endl;
27410152Satgutier@umich.edu                        cout << indent_str_next << "Gate Leakage = " << link_bus_tot_per_Router.power.readOp.gate_leakage
27510152Satgutier@umich.edu                                << " W" << endl;
27610152Satgutier@umich.edu                        cout << indent_str_next<< "Runtime Dynamic = " << link_bus->rt_power.readOp.dynamic/nocdynp.executionTime << " W" << endl;
27710152Satgutier@umich.edu                        cout<<endl;
27810152Satgutier@umich.edu
27910152Satgutier@umich.edu                }
28010152Satgutier@umich.edu        }
28110152Satgutier@umich.edu        else
28210152Satgutier@umich.edu        {
28310152Satgutier@umich.edu//		cout << indent_str_next << "Instruction Fetch Unit    Peak Dynamic = " << ifu->rt_power.readOp.dynamic*clockRate << " W" << endl;
28410152Satgutier@umich.edu//		cout << indent_str_next << "Instruction Fetch Unit    Subthreshold Leakage = " << ifu->rt_power.readOp.leakage <<" W" << endl;
28510152Satgutier@umich.edu//		cout << indent_str_next << "Instruction Fetch Unit    Gate Leakage = " << ifu->rt_power.readOp.gate_leakage << " W" << endl;
28610152Satgutier@umich.edu//		cout << indent_str_next << "Load Store Unit   Peak Dynamic = " << lsu->rt_power.readOp.dynamic*clockRate  << " W" << endl;
28710152Satgutier@umich.edu//		cout << indent_str_next << "Load Store Unit   Subthreshold Leakage = " << lsu->rt_power.readOp.leakage  << " W" << endl;
28810152Satgutier@umich.edu//		cout << indent_str_next << "Load Store Unit   Gate Leakage = " << lsu->rt_power.readOp.gate_leakage  << " W" << endl;
28910152Satgutier@umich.edu//		cout << indent_str_next << "Memory Management Unit   Peak Dynamic = " << mmu->rt_power.readOp.dynamic*clockRate  << " W" << endl;
29010152Satgutier@umich.edu//		cout << indent_str_next << "Memory Management Unit   Subthreshold Leakage = " << mmu->rt_power.readOp.leakage  << " W" << endl;
29110152Satgutier@umich.edu//		cout << indent_str_next << "Memory Management Unit   Gate Leakage = " << mmu->rt_power.readOp.gate_leakage  << " W" << endl;
29210152Satgutier@umich.edu//		cout << indent_str_next << "Execution Unit   Peak Dynamic = " << exu->rt_power.readOp.dynamic*clockRate  << " W" << endl;
29310152Satgutier@umich.edu//		cout << indent_str_next << "Execution Unit   Subthreshold Leakage = " << exu->rt_power.readOp.leakage  << " W" << endl;
29410152Satgutier@umich.edu//		cout << indent_str_next << "Execution Unit   Gate Leakage = " << exu->rt_power.readOp.gate_leakage  << " W" << endl;
29510152Satgutier@umich.edu        }
29610152Satgutier@umich.edu}
29710152Satgutier@umich.edu
29810152Satgutier@umich.eduvoid NoC::set_noc_param()
29910152Satgutier@umich.edu{
30010152Satgutier@umich.edu
30110152Satgutier@umich.edu        nocdynp.type            = XML->sys.NoC[ithNoC].type;
30210152Satgutier@umich.edu        nocdynp.clockRate       =XML->sys.NoC[ithNoC].clockrate;
30310152Satgutier@umich.edu        nocdynp.clockRate       *= 1e6;
30410152Satgutier@umich.edu        nocdynp.executionTime   = XML->sys.total_cycles/(XML->sys.target_core_clockrate*1e6);
30510152Satgutier@umich.edu
30610152Satgutier@umich.edu        nocdynp.flit_size     = XML->sys.NoC[ithNoC].flit_bits;
30710152Satgutier@umich.edu        if (nocdynp.type)
30810152Satgutier@umich.edu        {
30910152Satgutier@umich.edu                nocdynp.input_ports   = XML->sys.NoC[ithNoC].input_ports;
31010152Satgutier@umich.edu                nocdynp.output_ports  = XML->sys.NoC[ithNoC].output_ports;//later minus 1
31110152Satgutier@umich.edu                nocdynp.min_ports     = min(nocdynp.input_ports,nocdynp.output_ports);
31210152Satgutier@umich.edu                nocdynp.global_linked_ports = (nocdynp.input_ports-1) + (nocdynp.output_ports-1);
31310152Satgutier@umich.edu                /*
31410152Satgutier@umich.edu                 * 	Except local i/o ports, all ports needs links( global_linked_ports);
31510152Satgutier@umich.edu                 *  However only min_ports can be fully active simultaneously
31610152Satgutier@umich.edu                 *  since the fewer number of ports (input or output ) is the bottleneck.
31710152Satgutier@umich.edu                 */
31810152Satgutier@umich.edu        }
31910152Satgutier@umich.edu        else
32010152Satgutier@umich.edu        {
32110152Satgutier@umich.edu                nocdynp.input_ports   = 1;
32210152Satgutier@umich.edu                nocdynp.output_ports  = 1;
32310152Satgutier@umich.edu                nocdynp.min_ports     = min(nocdynp.input_ports,nocdynp.output_ports);
32410152Satgutier@umich.edu                nocdynp.global_linked_ports = 1;
32510152Satgutier@umich.edu        }
32610152Satgutier@umich.edu
32710152Satgutier@umich.edu        nocdynp.virtual_channel_per_port     = XML->sys.NoC[ithNoC].virtual_channel_per_port;
32810152Satgutier@umich.edu        nocdynp.input_buffer_entries_per_vc  = XML->sys.NoC[ithNoC].input_buffer_entries_per_vc;
32910152Satgutier@umich.edu
33010152Satgutier@umich.edu        nocdynp.horizontal_nodes  = XML->sys.NoC[ithNoC].horizontal_nodes;
33110152Satgutier@umich.edu        nocdynp.vertical_nodes    = XML->sys.NoC[ithNoC].vertical_nodes;
33210152Satgutier@umich.edu        nocdynp.total_nodes       = nocdynp.horizontal_nodes*nocdynp.vertical_nodes;
33310152Satgutier@umich.edu        nocdynp.duty_cycle        = XML->sys.NoC[ithNoC].duty_cycle;
33410152Satgutier@umich.edu        nocdynp.has_global_link   = XML->sys.NoC[ithNoC].has_global_link;
33510152Satgutier@umich.edu        nocdynp.link_throughput   = XML->sys.NoC[ithNoC].link_throughput;
33610152Satgutier@umich.edu        nocdynp.link_latency      = XML->sys.NoC[ithNoC].link_latency;
33710152Satgutier@umich.edu        nocdynp.chip_coverage     = XML->sys.NoC[ithNoC].chip_coverage;
33810152Satgutier@umich.edu        nocdynp.route_over_perc   = XML->sys.NoC[ithNoC].route_over_perc;
33910152Satgutier@umich.edu
34010152Satgutier@umich.edu        assert (nocdynp.chip_coverage <=1);
34110152Satgutier@umich.edu        assert (nocdynp.route_over_perc <=1);
34210152Satgutier@umich.edu
34310152Satgutier@umich.edu        if (nocdynp.type)
34410152Satgutier@umich.edu                name = "NOC";
34510152Satgutier@umich.edu        else
34610152Satgutier@umich.edu                name = "BUSES";
34710152Satgutier@umich.edu
34810152Satgutier@umich.edu}
34910152Satgutier@umich.edu
35010152Satgutier@umich.edu
35110152Satgutier@umich.eduNoC ::~NoC(){
35210152Satgutier@umich.edu
35310152Satgutier@umich.edu        if(router) 	               {delete router; router = 0;}
35410152Satgutier@umich.edu        if(link_bus) 	           {delete link_bus; link_bus = 0;}
35510152Satgutier@umich.edu}
356