arbiter.cc revision 10152
1/***************************************************************************** 2 * McPAT/CACTI 3 * SOFTWARE LICENSE AGREEMENT 4 * Copyright 2012 Hewlett-Packard Development Company, L.P. 5 * All Rights Reserved 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer; 11 * redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution; 14 * neither the name of the copyright holders nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 29 * 30 ***************************************************************************/ 31 32#include "arbiter.h" 33 34Arbiter::Arbiter( 35 double n_req, 36 double flit_size_, 37 double output_len, 38 TechnologyParameter::DeviceType *dt 39 ):R(n_req), flit_size(flit_size_), 40 o_len (output_len), deviceType(dt) 41{ 42 min_w_pmos = deviceType->n_to_p_eff_curr_drv_ratio*g_tp.min_w_nmos_; 43 Vdd = dt->Vdd; 44 double technology = g_ip->F_sz_um; 45 NTn1 = 13.5*technology/2; 46 PTn1 = 76*technology/2; 47 NTn2 = 13.5*technology/2; 48 PTn2 = 76*technology/2; 49 NTi = 12.5*technology/2; 50 PTi = 25*technology/2; 51 NTtr = 10*technology/2; /*Transmission gate's nmos tr. length*/ 52 PTtr = 20*technology/2; /* pmos tr. length*/ 53} 54 55Arbiter::~Arbiter(){} 56 57double 58Arbiter::arb_req() { 59 double temp = ((R-1)*(2*gate_C(NTn1, 0)+gate_C(PTn1, 0)) + 2*gate_C(NTn2, 0) + 60 gate_C(PTn2, 0) + gate_C(NTi, 0) + gate_C(PTi, 0) + 61 drain_C_(NTi, 0, 1, 1, g_tp.cell_h_def) + drain_C_(PTi, 1, 1, 1, g_tp.cell_h_def)); 62 return temp; 63} 64 65double 66Arbiter::arb_pri() { 67 double temp = 2*(2*gate_C(NTn1, 0)+gate_C(PTn1, 0)); /* switching capacitance 68 of flip-flop is ignored */ 69 return temp; 70} 71 72 73double 74Arbiter::arb_grant() { 75 double temp = drain_C_(NTn1, 0, 1, 1, g_tp.cell_h_def)*2 + drain_C_(PTn1, 1, 1, 1, g_tp.cell_h_def) + crossbar_ctrline(); 76 return temp; 77} 78 79double 80Arbiter::arb_int() { 81 double temp = (drain_C_(NTn1, 0, 1, 1, g_tp.cell_h_def)*2 + drain_C_(PTn1, 1, 1, 1, g_tp.cell_h_def) + 82 2*gate_C(NTn2, 0) + gate_C(PTn2, 0)); 83 return temp; 84} 85 86void 87Arbiter::compute_power() { 88 power.readOp.dynamic = (R*arb_req()*Vdd*Vdd/2 + R*arb_pri()*Vdd*Vdd/2 + 89 arb_grant()*Vdd*Vdd + arb_int()*0.5*Vdd*Vdd); 90 double nor1_leak = cmos_Isub_leakage(g_tp.min_w_nmos_*NTn1*2, min_w_pmos * PTn1*2, 2, nor); 91 double nor2_leak = cmos_Isub_leakage(g_tp.min_w_nmos_*NTn2*R, min_w_pmos * PTn2*R, 2, nor); 92 double not_leak = cmos_Isub_leakage(g_tp.min_w_nmos_*NTi, min_w_pmos * PTi, 1, inv); 93 double nor1_leak_gate = cmos_Ig_leakage(g_tp.min_w_nmos_*NTn1*2, min_w_pmos * PTn1*2, 2, nor); 94 double nor2_leak_gate = cmos_Ig_leakage(g_tp.min_w_nmos_*NTn2*R, min_w_pmos * PTn2*R, 2, nor); 95 double not_leak_gate = cmos_Ig_leakage(g_tp.min_w_nmos_*NTi, min_w_pmos * PTi, 1, inv); 96 power.readOp.leakage = (nor1_leak + nor2_leak + not_leak)*Vdd; //FIXME include priority table leakage 97 power.readOp.gate_leakage = nor1_leak_gate*Vdd + nor2_leak_gate*Vdd + not_leak_gate*Vdd; 98} 99 100double //wire cap with triple spacing 101Arbiter::Cw3(double length) { 102 Wire wc(g_ip->wt, length, 1, 3, 3); 103 double temp = (wc.wire_cap(length,true)); 104 return temp; 105} 106 107double 108Arbiter::crossbar_ctrline() { 109 double temp = (Cw3(o_len * 1e-6 /* m */) + 110 drain_C_(NTi, 0, 1, 1, g_tp.cell_h_def) + drain_C_(PTi, 1, 1, 1, g_tp.cell_h_def) + 111 gate_C(NTi, 0) + gate_C(PTi, 0)); 112 return temp; 113} 114 115double 116Arbiter::transmission_buf_ctrcap() { 117 double temp = gate_C(NTtr, 0)+gate_C(PTtr, 0); 118 return temp; 119} 120 121 122void Arbiter::print_arbiter() 123{ 124 cout << "\nArbiter Stats (" << R << " input arbiter" << ")\n\n"; 125 cout << "Flit size : " << flit_size << " bits" << endl; 126 cout << "Dynamic Power : " << power.readOp.dynamic*1e9 << " (nJ)" << endl; 127 cout << "Leakage Power : " << power.readOp.leakage*1e3 << " (mW)" << endl; 128} 129 130 131