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/std_cells/LATQ.h"
2310447Snilay@cs.wisc.edu
2410447Snilay@cs.wisc.edu#include <cmath>
2510447Snilay@cs.wisc.edu
2610447Snilay@cs.wisc.edu#include "model/PortInfo.h"
2710447Snilay@cs.wisc.edu#include "model/TransitionInfo.h"
2810447Snilay@cs.wisc.edu#include "model/EventInfo.h"
2910447Snilay@cs.wisc.edu#include "model/std_cells/StdCellLib.h"
3010447Snilay@cs.wisc.edu#include "model/std_cells/CellMacros.h"
3110447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalNet.h"
3210447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalDriver.h"
3310447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalLoad.h"
3410447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalDelay.h"
3510447Snilay@cs.wisc.edu
3610447Snilay@cs.wisc.edunamespace DSENT
3710447Snilay@cs.wisc.edu{
3810447Snilay@cs.wisc.edu    using std::ceil;
3910447Snilay@cs.wisc.edu    using std::max;
4010447Snilay@cs.wisc.edu    using std::min;
4110447Snilay@cs.wisc.edu
4210447Snilay@cs.wisc.edu    LATQ::LATQ(const String& instance_name_, const TechModel* tech_model_)
4310447Snilay@cs.wisc.edu        : StdCell(instance_name_, tech_model_)
4410447Snilay@cs.wisc.edu    {
4510447Snilay@cs.wisc.edu        initProperties();
4610447Snilay@cs.wisc.edu    }
4710447Snilay@cs.wisc.edu
4810447Snilay@cs.wisc.edu    LATQ::~LATQ()
4910447Snilay@cs.wisc.edu    {}
5010447Snilay@cs.wisc.edu
5110447Snilay@cs.wisc.edu    void LATQ::initProperties()
5210447Snilay@cs.wisc.edu    {
5310447Snilay@cs.wisc.edu        return;
5410447Snilay@cs.wisc.edu    }
5510447Snilay@cs.wisc.edu
5610447Snilay@cs.wisc.edu    void LATQ::constructModel()
5710447Snilay@cs.wisc.edu    {
5810447Snilay@cs.wisc.edu        // All constructModel should do is create Area/NDDPower/Energy Results as
5910447Snilay@cs.wisc.edu        // well as instantiate any sub-instances using only the hard parameters
6010447Snilay@cs.wisc.edu
6110447Snilay@cs.wisc.edu        createInputPort("D");
6210447Snilay@cs.wisc.edu        createInputPort("G");
6310447Snilay@cs.wisc.edu        createOutputPort("Q");
6410447Snilay@cs.wisc.edu
6510447Snilay@cs.wisc.edu        createLoad("D_Cap");
6610447Snilay@cs.wisc.edu        createLoad("G_Cap");
6710447Snilay@cs.wisc.edu        createDelay("D_to_Q_delay");
6810447Snilay@cs.wisc.edu        createDelay("G_to_Q_delay");
6910447Snilay@cs.wisc.edu        createDriver("Q_Ron", true);
7010447Snilay@cs.wisc.edu
7110447Snilay@cs.wisc.edu        ElectricalLoad* d_cap = getLoad("D_Cap");
7210447Snilay@cs.wisc.edu        ElectricalLoad* g_cap = getLoad("G_Cap");
7310447Snilay@cs.wisc.edu        ElectricalDelay* d_to_q_delay = getDelay("D_to_Q_delay");
7410447Snilay@cs.wisc.edu        ElectricalDelay* g_to_q_delay = getDelay("G_to_Q_delay");
7510447Snilay@cs.wisc.edu        ElectricalDriver* q_ron = getDriver("Q_Ron");
7610447Snilay@cs.wisc.edu
7710447Snilay@cs.wisc.edu        getNet("D")->addDownstreamNode(d_cap);
7810447Snilay@cs.wisc.edu        getNet("G")->addDownstreamNode(g_cap);
7910447Snilay@cs.wisc.edu        d_cap->addDownstreamNode(d_to_q_delay);
8010447Snilay@cs.wisc.edu        g_cap->addDownstreamNode(g_to_q_delay);
8110447Snilay@cs.wisc.edu        g_to_q_delay->addDownstreamNode(q_ron);
8210447Snilay@cs.wisc.edu        q_ron->addDownstreamNode(getNet("Q"));
8310447Snilay@cs.wisc.edu
8410447Snilay@cs.wisc.edu        // Create Area result
8510447Snilay@cs.wisc.edu        // Create NDD Power result
8610447Snilay@cs.wisc.edu        createElectricalAtomicResults();
8710447Snilay@cs.wisc.edu        // Create G Event Energy Result
8810447Snilay@cs.wisc.edu        createElectricalEventAtomicResult("G");
8910447Snilay@cs.wisc.edu        // Create DFF Event Energy Result
9010447Snilay@cs.wisc.edu        createElectricalEventAtomicResult("LATD");
9110447Snilay@cs.wisc.edu        createElectricalEventAtomicResult("LATQ");
9210447Snilay@cs.wisc.edu        // Create Idle event for leakage
9310447Snilay@cs.wisc.edu        // G pin is assumed to be on all the time
9410447Snilay@cs.wisc.edu        //createElectricalEventAtomicResult("Idle");
9510447Snilay@cs.wisc.edu        getEventInfo("Idle")->setStaticTransitionInfos();
9610447Snilay@cs.wisc.edu        return;
9710447Snilay@cs.wisc.edu    }
9810447Snilay@cs.wisc.edu
9910447Snilay@cs.wisc.edu    void LATQ::updateModel()
10010447Snilay@cs.wisc.edu    {
10110447Snilay@cs.wisc.edu        // Get parameters
10210447Snilay@cs.wisc.edu        double drive_strength = getDrivingStrength();
10310447Snilay@cs.wisc.edu        Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache();
10410447Snilay@cs.wisc.edu
10510447Snilay@cs.wisc.edu        // Standard cell cache string
10610447Snilay@cs.wisc.edu        String cell_name = "LATQ_X" + (String) drive_strength;
10710447Snilay@cs.wisc.edu
10810447Snilay@cs.wisc.edu        // Get timing parameters
10910447Snilay@cs.wisc.edu        getLoad("D_Cap")->setLoadCap(cache->get(cell_name + "->Cap->D"));
11010447Snilay@cs.wisc.edu        getLoad("G_Cap")->setLoadCap(cache->get(cell_name + "->Cap->G"));
11110447Snilay@cs.wisc.edu        getDriver("Q_Ron")->setOutputRes(cache->get(cell_name + "->DriveRes->Q"));
11210447Snilay@cs.wisc.edu        getDelay("G_to_Q_delay")->setDelay(cache->get(cell_name + "->Delay->G_to_Q"));
11310447Snilay@cs.wisc.edu        getDelay("D_to_Q_delay")->setDelay(cache->get(cell_name + "->Delay->D_to_Q"));
11410447Snilay@cs.wisc.edu
11510447Snilay@cs.wisc.edu        // Set the cell area
11610447Snilay@cs.wisc.edu        getAreaResult("Active")->setValue(cache->get(cell_name + "->Area->Active"));
11710447Snilay@cs.wisc.edu        getAreaResult("Metal1Wire")->setValue(cache->get(cell_name + "->Area->Metal1Wire"));
11810447Snilay@cs.wisc.edu
11910447Snilay@cs.wisc.edu        return;
12010447Snilay@cs.wisc.edu    }
12110447Snilay@cs.wisc.edu
12210447Snilay@cs.wisc.edu    void LATQ::evaluateModel()
12310447Snilay@cs.wisc.edu    {
12410447Snilay@cs.wisc.edu        return;
12510447Snilay@cs.wisc.edu    }
12610447Snilay@cs.wisc.edu
12710447Snilay@cs.wisc.edu    void LATQ::useModel()
12810447Snilay@cs.wisc.edu    {
12910447Snilay@cs.wisc.edu        // Get parameters
13010447Snilay@cs.wisc.edu        double drive_strength = getDrivingStrength();
13110447Snilay@cs.wisc.edu        Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache();
13210447Snilay@cs.wisc.edu
13310447Snilay@cs.wisc.edu        // Standard cell cache string
13410447Snilay@cs.wisc.edu        String cell_name = "LATQ_X" + (String) drive_strength;
13510447Snilay@cs.wisc.edu
13610447Snilay@cs.wisc.edu        // Propagate the transition info and get P_D, P_M, and P_Q
13710447Snilay@cs.wisc.edu        propagateTransitionInfo();
13810447Snilay@cs.wisc.edu        double P_D = getInputPort("D")->getTransitionInfo().getProbability1();
13910447Snilay@cs.wisc.edu        double P_G = getInputPort("G")->getTransitionInfo().getProbability1();
14010447Snilay@cs.wisc.edu        double P_Q = getOutputPort("Q")->getTransitionInfo().getProbability1();
14110447Snilay@cs.wisc.edu        double G_num_trans_01 = getInputPort("G")->getTransitionInfo().getNumberTransitions01();
14210447Snilay@cs.wisc.edu        double D_num_trans_01 = getInputPort("D")->getTransitionInfo().getNumberTransitions01();
14310447Snilay@cs.wisc.edu        double Q_num_trans_01 = getOutputPort("Q")->getTransitionInfo().getNumberTransitions01();
14410447Snilay@cs.wisc.edu
14510447Snilay@cs.wisc.edu        // Calculate leakage
14610447Snilay@cs.wisc.edu        double leakage = 0;
14710447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!D!G!Q") * (1 - P_D) * (1 - P_G) * (1 - P_Q);
14810447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!D!GQ") * (1 - P_D) * (1 - P_G) * P_Q;
14910447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!DG!Q") * (1 - P_D) * P_G * (1 - P_Q);
15010447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->D!G!Q") * P_D * (1 - P_G) * (1 - P_Q);
15110447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->D!GQ") * P_D * (1 - P_G) * P_Q;
15210447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->DGQ") * P_D * P_G * P_Q;
15310447Snilay@cs.wisc.edu        getNddPowerResult("Leakage")->setValue(leakage);
15410447Snilay@cs.wisc.edu
15510447Snilay@cs.wisc.edu        // Get VDD
15610447Snilay@cs.wisc.edu        double vdd = getTechModel()->get("Vdd");
15710447Snilay@cs.wisc.edu
15810447Snilay@cs.wisc.edu        // Get capacitances
15910447Snilay@cs.wisc.edu        double g_b_cap = cache->get(cell_name + "->Cap->G_b");
16010447Snilay@cs.wisc.edu        double d_b_cap = cache->get(cell_name + "->Cap->D_b");
16110447Snilay@cs.wisc.edu        double q_i_cap = cache->get(cell_name + "->Cap->Q_i");
16210447Snilay@cs.wisc.edu        double q_b_cap = cache->get(cell_name + "->Cap->Q_b");
16310447Snilay@cs.wisc.edu        double q_cap = cache->get(cell_name + "->Cap->Q");
16410447Snilay@cs.wisc.edu        double q_load_cap = getNet("Q")->getTotalDownstreamCap();
16510447Snilay@cs.wisc.edu
16610447Snilay@cs.wisc.edu        // Calculate G Event energy
16710447Snilay@cs.wisc.edu        double g_event_energy = 0.0;
16810447Snilay@cs.wisc.edu        g_event_energy += (g_b_cap) * G_num_trans_01;
16910447Snilay@cs.wisc.edu        g_event_energy *= vdd * vdd;
17010447Snilay@cs.wisc.edu        getEventResult("G")->setValue(g_event_energy);
17110447Snilay@cs.wisc.edu        // Calculate LATD Event energy
17210447Snilay@cs.wisc.edu        double latd_event_energy = 0.0;
17310447Snilay@cs.wisc.edu        latd_event_energy += (d_b_cap) * D_num_trans_01;
17410447Snilay@cs.wisc.edu        latd_event_energy *= vdd * vdd;
17510447Snilay@cs.wisc.edu        getEventResult("LATD")->setValue(latd_event_energy);
17610447Snilay@cs.wisc.edu        // Calculate LATQ Event energy
17710447Snilay@cs.wisc.edu        double latq_event_energy = 0.0;
17810447Snilay@cs.wisc.edu        latq_event_energy += (q_i_cap + q_b_cap + q_cap + q_load_cap) * Q_num_trans_01;
17910447Snilay@cs.wisc.edu        latq_event_energy *= vdd * vdd;
18010447Snilay@cs.wisc.edu        getEventResult("LATQ")->setValue(latq_event_energy);
18110447Snilay@cs.wisc.edu
18210447Snilay@cs.wisc.edu        return;
18310447Snilay@cs.wisc.edu    }
18410447Snilay@cs.wisc.edu
18510447Snilay@cs.wisc.edu    void LATQ::propagateTransitionInfo()
18610447Snilay@cs.wisc.edu    {
18710447Snilay@cs.wisc.edu        const TransitionInfo& trans_G = getInputPort("G")->getTransitionInfo();
18810447Snilay@cs.wisc.edu        const TransitionInfo& trans_D = getInputPort("D")->getTransitionInfo();
18910447Snilay@cs.wisc.edu
19010447Snilay@cs.wisc.edu        double G_num_trans_01 = trans_G.getNumberTransitions01();
19110447Snilay@cs.wisc.edu        double G_num_trans_10 = G_num_trans_01;
19210447Snilay@cs.wisc.edu        double G_num_trans_00 = trans_G.getNumberTransitions00();
19310447Snilay@cs.wisc.edu        double D_freq_mult = trans_D.getFrequencyMultiplier();
19410447Snilay@cs.wisc.edu
19510447Snilay@cs.wisc.edu        // If the latch is sampling just as fast or faster than input data signal
19610447Snilay@cs.wisc.edu        // Then it can capture all transitions (though it should be normalized to clock)
19710447Snilay@cs.wisc.edu        if((G_num_trans_10 + G_num_trans_00) >= D_freq_mult)
19810447Snilay@cs.wisc.edu        {
19910447Snilay@cs.wisc.edu            const TransitionInfo& trans_Q = trans_D.scaleFrequencyMultiplier(G_num_trans_10 + G_num_trans_00);
20010447Snilay@cs.wisc.edu            getOutputPort("Q")->setTransitionInfo(trans_Q);
20110447Snilay@cs.wisc.edu        }
20210447Snilay@cs.wisc.edu        // If the latch is sampling slower than the input data signal, then input
20310447Snilay@cs.wisc.edu        // will look like they transition more
20410447Snilay@cs.wisc.edu        else
20510447Snilay@cs.wisc.edu        {
20610447Snilay@cs.wisc.edu            // Calculate scale ratio
20710447Snilay@cs.wisc.edu            double scale_ratio = (G_num_trans_10 + G_num_trans_00) / D_freq_mult;
20810447Snilay@cs.wisc.edu            // 00 and 11 transitions become fewer
20910447Snilay@cs.wisc.edu            double D_scaled_diff = 0.5 * (1 - scale_ratio) * (trans_D.getNumberTransitions00() + trans_D.getNumberTransitions11());
21010447Snilay@cs.wisc.edu            double D_scaled_num_trans_00 = trans_D.getNumberTransitions00() * scale_ratio;
21110447Snilay@cs.wisc.edu            double D_scaled_num_trans_11 = trans_D.getNumberTransitions11() * scale_ratio;
21210447Snilay@cs.wisc.edu            // 01 and 10 transitions become more frequent
21310447Snilay@cs.wisc.edu            double D_scaled_num_trans_10 = trans_D.getNumberTransitions01() + D_scaled_diff;
21410447Snilay@cs.wisc.edu
21510447Snilay@cs.wisc.edu            // Create final transition info, remembering to apply scaling ratio to normalize to G
21610447Snilay@cs.wisc.edu            const TransitionInfo trans_Q(   D_scaled_num_trans_00 * scale_ratio,
21710447Snilay@cs.wisc.edu                                            D_scaled_num_trans_10 * scale_ratio,
21810447Snilay@cs.wisc.edu                                            D_scaled_num_trans_11 * scale_ratio);
21910447Snilay@cs.wisc.edu            getOutputPort("Q")->setTransitionInfo(trans_Q);
22010447Snilay@cs.wisc.edu        }
22110447Snilay@cs.wisc.edu
22210447Snilay@cs.wisc.edu        return;
22310447Snilay@cs.wisc.edu    }
22410447Snilay@cs.wisc.edu
22510447Snilay@cs.wisc.edu    // Creates the standard cell, characterizes and abstracts away the details
22610447Snilay@cs.wisc.edu    void LATQ::cacheStdCell(StdCellLib* cell_lib_, double drive_strength_)
22710447Snilay@cs.wisc.edu    {
22810447Snilay@cs.wisc.edu        // Get parameters
22910447Snilay@cs.wisc.edu        double gate_pitch = cell_lib_->getTechModel()->get("Gate->PitchContacted");
23010447Snilay@cs.wisc.edu        Map<double>* cache = cell_lib_->getStdCellCache();
23110447Snilay@cs.wisc.edu
23210447Snilay@cs.wisc.edu        // Standard cell cache string
23310447Snilay@cs.wisc.edu        String cell_name = "LATQ_X" + (String) drive_strength_;
23410447Snilay@cs.wisc.edu
23510447Snilay@cs.wisc.edu        Log::printLine("=== " + cell_name + " ===");
23610447Snilay@cs.wisc.edu
23710447Snilay@cs.wisc.edu
23810447Snilay@cs.wisc.edu        // Now actually build the full standard cell model
23910447Snilay@cs.wisc.edu        createInputPort("D");
24010447Snilay@cs.wisc.edu        createInputPort("G");
24110447Snilay@cs.wisc.edu        createOutputPort("Q");
24210447Snilay@cs.wisc.edu
24310447Snilay@cs.wisc.edu        createNet("D_b");
24410447Snilay@cs.wisc.edu        createNet("Q_i");
24510447Snilay@cs.wisc.edu        createNet("Q_b");
24610447Snilay@cs.wisc.edu        createNet("G_b");
24710447Snilay@cs.wisc.edu
24810447Snilay@cs.wisc.edu        // Adds macros
24910447Snilay@cs.wisc.edu        CellMacros::addInverter(this, "INV1", false, true, "D", "D_b");
25010447Snilay@cs.wisc.edu        CellMacros::addInverter(this, "INV2", false, true, "Q_i", "Q_b");
25110447Snilay@cs.wisc.edu        CellMacros::addInverter(this, "INV3", false, true, "Q_b", "Q");
25210447Snilay@cs.wisc.edu        CellMacros::addInverter(this, "INV4", false, true, "G", "G_b");
25310447Snilay@cs.wisc.edu        CellMacros::addTristate(this, "INVZ1", false, true, false, false, "D_b", "G", "G_b", "Q_i");        //trace timing through A->ZN path only
25410447Snilay@cs.wisc.edu        CellMacros::addTristate(this, "INVZ2", false, false, false, false, "Q_b", "G_b", "G", "Q_i");       //don't trace timing through the feedback path
25510447Snilay@cs.wisc.edu
25610447Snilay@cs.wisc.edu        // Update macros
25710447Snilay@cs.wisc.edu        CellMacros::updateInverter(this, "INV1", drive_strength_ * 0.125);
25810447Snilay@cs.wisc.edu        CellMacros::updateInverter(this, "INV2", drive_strength_ * 0.5);
25910447Snilay@cs.wisc.edu        CellMacros::updateInverter(this, "INV3", drive_strength_ * 1.0);
26010447Snilay@cs.wisc.edu        CellMacros::updateInverter(this, "INV4", drive_strength_ * 0.125);
26110447Snilay@cs.wisc.edu        CellMacros::updateTristate(this, "INVZ1", drive_strength_ * 0.5);
26210447Snilay@cs.wisc.edu        CellMacros::updateTristate(this, "INVZ2", drive_strength_ * 0.0625);
26310447Snilay@cs.wisc.edu
26410447Snilay@cs.wisc.edu        // Cache area result
26510447Snilay@cs.wisc.edu        double area = 0.0;
26610447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * 1;
26710447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV1_GatePitches").toDouble();
26810447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV2_GatePitches").toDouble();
26910447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV3_GatePitches").toDouble();
27010447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV4_GatePitches").toDouble();
27110447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INVZ1_GatePitches").toDouble();
27210447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INVZ2_GatePitches").toDouble();
27310447Snilay@cs.wisc.edu        cache->set(cell_name + "->Area->Active", area);
27410447Snilay@cs.wisc.edu        cache->set(cell_name + "->Area->Metal1Wire", area);     //Cover-block m1 area
27510447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Area->Active=" + (String) area);
27610447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Area->Metal1Wire=" + (String) area);
27710447Snilay@cs.wisc.edu
27810447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
27910447Snilay@cs.wisc.edu        // Leakage Model Calculation
28010447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
28110447Snilay@cs.wisc.edu        // Cache leakage power results (for every single signal combination)
28210447Snilay@cs.wisc.edu        double leakage_000 = 0;         //!D, !G, !Q
28310447Snilay@cs.wisc.edu        double leakage_001 = 0;         //!D, !G, Q
28410447Snilay@cs.wisc.edu        double leakage_010 = 0;         //!D, G, !Q
28510447Snilay@cs.wisc.edu        double leakage_100 = 0;         //D, !G, !Q
28610447Snilay@cs.wisc.edu        double leakage_101 = 0;         //D, !G, Q
28710447Snilay@cs.wisc.edu        double leakage_111 = 0;         //D, G, Q
28810447Snilay@cs.wisc.edu
28910447Snilay@cs.wisc.edu        //This is so painful...
29010447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
29110447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
29210447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INV3_LeakagePower_1").toDouble();
29310447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INV4_LeakagePower_0").toDouble();
29410447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INVZ1_LeakagePower_011_0").toDouble();
29510447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INVZ2_LeakagePower_101_0").toDouble();
29610447Snilay@cs.wisc.edu
29710447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
29810447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
29910447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INV3_LeakagePower_0").toDouble();
30010447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INV4_LeakagePower_0").toDouble();
30110447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INVZ1_LeakagePower_011_1").toDouble();
30210447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INVZ2_LeakagePower_100_1").toDouble();
30310447Snilay@cs.wisc.edu
30410447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
30510447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
30610447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INV3_LeakagePower_1").toDouble();
30710447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INV4_LeakagePower_1").toDouble();
30810447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INVZ1_LeakagePower_101_0").toDouble();
30910447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INVZ2_LeakagePower_011_0").toDouble();
31010447Snilay@cs.wisc.edu
31110447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
31210447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
31310447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INV3_LeakagePower_1").toDouble();
31410447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INV4_LeakagePower_0").toDouble();
31510447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INVZ1_LeakagePower_010_0").toDouble();
31610447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INVZ2_LeakagePower_101_0").toDouble();
31710447Snilay@cs.wisc.edu
31810447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
31910447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
32010447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INV3_LeakagePower_0").toDouble();
32110447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INV4_LeakagePower_0").toDouble();
32210447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INVZ1_LeakagePower_010_1").toDouble();
32310447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INVZ2_LeakagePower_100_1").toDouble();
32410447Snilay@cs.wisc.edu
32510447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
32610447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
32710447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INV3_LeakagePower_0").toDouble();
32810447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INV4_LeakagePower_1").toDouble();
32910447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INVZ1_LeakagePower_100_1").toDouble();
33010447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INVZ2_LeakagePower_010_1").toDouble();
33110447Snilay@cs.wisc.edu
33210447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!D!G!Q", leakage_000);
33310447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!D!GQ", leakage_001);
33410447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!DG!Q", leakage_010);
33510447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->D!G!Q", leakage_100);
33610447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->D!GQ", leakage_101);
33710447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->DGQ", leakage_111);
33810447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!D!G!Q=" + (String) leakage_000);
33910447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!D!GQ=" + (String) leakage_001);
34010447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!DG!Q=" + (String) leakage_010);
34110447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->D!G!Q=" + (String) leakage_100);
34210447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->D!GQ=" + (String) leakage_101);
34310447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->DGQ=" + (String) leakage_111);
34410447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
34510447Snilay@cs.wisc.edu
34610447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
34710447Snilay@cs.wisc.edu        // Get Node Capacitances
34810447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
34910447Snilay@cs.wisc.edu        double d_cap = getNet("D")->getTotalDownstreamCap();
35010447Snilay@cs.wisc.edu        double d_b_cap = getNet("D_b")->getTotalDownstreamCap();
35110447Snilay@cs.wisc.edu        double q_i_cap = getNet("Q_i")->getTotalDownstreamCap();
35210447Snilay@cs.wisc.edu        double q_b_cap = getNet("Q_b")->getTotalDownstreamCap();
35310447Snilay@cs.wisc.edu        double q_cap = getNet("Q")->getTotalDownstreamCap();
35410447Snilay@cs.wisc.edu        double g_cap = getNet("G")->getTotalDownstreamCap();
35510447Snilay@cs.wisc.edu        double g_b_cap = getNet("G_b")->getTotalDownstreamCap();
35610447Snilay@cs.wisc.edu
35710447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->D", d_cap);
35810447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->D_b", d_b_cap);
35910447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->Q_i", q_i_cap);
36010447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->Q_b", q_b_cap);
36110447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->Q", q_cap);
36210447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->G", g_cap);
36310447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->G_b", g_b_cap);
36410447Snilay@cs.wisc.edu
36510447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->D=" + (String) d_cap);
36610447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->D_b=" + (String) d_b_cap);
36710447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->Q_i=" + (String) q_i_cap);
36810447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->Q_b=" + (String) q_b_cap);
36910447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->Q=" + (String) q_cap);
37010447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->G=" + (String) g_cap);
37110447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->G_b=" + (String) g_b_cap);
37210447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
37310447Snilay@cs.wisc.edu
37410447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
37510447Snilay@cs.wisc.edu        // Build Internal Delay Model
37610447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
37710447Snilay@cs.wisc.edu        double q_ron = getDriver("INV3_RonZN")->getOutputRes();
37810447Snilay@cs.wisc.edu
37910447Snilay@cs.wisc.edu        double d_to_q_delay = getDriver("INV1_RonZN")->calculateDelay() +
38010447Snilay@cs.wisc.edu                                getDriver("INVZ1_RonZN")->calculateDelay() +
38110447Snilay@cs.wisc.edu                                getDriver("INV2_RonZN")->calculateDelay() +
38210447Snilay@cs.wisc.edu                                getDriver("INV3_RonZN")->calculateDelay();
38310447Snilay@cs.wisc.edu        double g_to_q_delay = getDriver("INV4_RonZN")->calculateDelay() +
38410447Snilay@cs.wisc.edu                                getDriver("INVZ1_RonZN")->calculateDelay() +
38510447Snilay@cs.wisc.edu                                getDriver("INV2_RonZN")->calculateDelay() +
38610447Snilay@cs.wisc.edu                                getDriver("INV3_RonZN")->calculateDelay();
38710447Snilay@cs.wisc.edu
38810447Snilay@cs.wisc.edu        cache->set(cell_name + "->DriveRes->Q", q_ron);
38910447Snilay@cs.wisc.edu        cache->set(cell_name + "->Delay->D_to_Q", d_to_q_delay);
39010447Snilay@cs.wisc.edu        cache->set(cell_name + "->Delay->G_to_Q", g_to_q_delay);
39110447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->DriveRes->Q=" + (String) q_ron);
39210447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Delay->D_to_Q=" + (String) d_to_q_delay);
39310447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Delay->G_to_Q=" + (String) g_to_q_delay);
39410447Snilay@cs.wisc.edu
39510447Snilay@cs.wisc.edu        return;
39610447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
39710447Snilay@cs.wisc.edu
39810447Snilay@cs.wisc.edu    }
39910447Snilay@cs.wisc.edu
40010447Snilay@cs.wisc.edu} // namespace DSENT
40110447Snilay@cs.wisc.edu
402