MUX2.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/std_cells/MUX2.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
4110447Snilay@cs.wisc.edu    MUX2::MUX2(const String& instance_name_, const TechModel* tech_model_)
4210447Snilay@cs.wisc.edu        : StdCell(instance_name_, tech_model_)
4310447Snilay@cs.wisc.edu    {
4410447Snilay@cs.wisc.edu        initProperties();
4510447Snilay@cs.wisc.edu    }
4610447Snilay@cs.wisc.edu
4710447Snilay@cs.wisc.edu    MUX2::~MUX2()
4810447Snilay@cs.wisc.edu    {}
4910447Snilay@cs.wisc.edu
5010447Snilay@cs.wisc.edu    void MUX2::initProperties()
5110447Snilay@cs.wisc.edu    {
5210447Snilay@cs.wisc.edu        return;
5310447Snilay@cs.wisc.edu    }
5410447Snilay@cs.wisc.edu
5510447Snilay@cs.wisc.edu    void MUX2::constructModel()
5610447Snilay@cs.wisc.edu    {
5710447Snilay@cs.wisc.edu        // All constructModel should do is create Area/NDDPower/Energy Results as
5810447Snilay@cs.wisc.edu        // well as instantiate any sub-instances using only the hard parameters
5910447Snilay@cs.wisc.edu
6010447Snilay@cs.wisc.edu        createInputPort("A");
6110447Snilay@cs.wisc.edu        createInputPort("B");
6210447Snilay@cs.wisc.edu        createInputPort("S0");
6310447Snilay@cs.wisc.edu        createOutputPort("Y");
6410447Snilay@cs.wisc.edu
6510447Snilay@cs.wisc.edu        createLoad("A_Cap");
6610447Snilay@cs.wisc.edu        createLoad("B_Cap");
6710447Snilay@cs.wisc.edu        createLoad("S0_Cap");
6810447Snilay@cs.wisc.edu        createDelay("A_to_Y_delay");
6910447Snilay@cs.wisc.edu        createDelay("B_to_Y_delay");
7010447Snilay@cs.wisc.edu        createDelay("S0_to_Y_delay");
7110447Snilay@cs.wisc.edu        createDriver("Y_Ron", true);
7210447Snilay@cs.wisc.edu
7310447Snilay@cs.wisc.edu        ElectricalLoad* a_cap = getLoad("A_Cap");
7410447Snilay@cs.wisc.edu        ElectricalLoad* b_cap = getLoad("B_Cap");
7510447Snilay@cs.wisc.edu        ElectricalLoad* s0_cap = getLoad("S0_Cap");
7610447Snilay@cs.wisc.edu        ElectricalDelay* a_to_y_delay = getDelay("A_to_Y_delay");
7710447Snilay@cs.wisc.edu        ElectricalDelay* b_to_y_delay = getDelay("B_to_Y_delay");
7810447Snilay@cs.wisc.edu        ElectricalDelay* s0_to_y_delay = getDelay("S0_to_Y_delay");
7910447Snilay@cs.wisc.edu        ElectricalDriver* y_ron = getDriver("Y_Ron");
8010447Snilay@cs.wisc.edu
8110447Snilay@cs.wisc.edu        getNet("A")->addDownstreamNode(a_cap);
8210447Snilay@cs.wisc.edu        getNet("B")->addDownstreamNode(b_cap);
8310447Snilay@cs.wisc.edu        getNet("S0")->addDownstreamNode(s0_cap);
8410447Snilay@cs.wisc.edu        a_cap->addDownstreamNode(a_to_y_delay);
8510447Snilay@cs.wisc.edu        b_cap->addDownstreamNode(b_to_y_delay);
8610447Snilay@cs.wisc.edu        s0_cap->addDownstreamNode(s0_to_y_delay);
8710447Snilay@cs.wisc.edu        a_to_y_delay->addDownstreamNode(y_ron);
8810447Snilay@cs.wisc.edu        b_to_y_delay->addDownstreamNode(y_ron);
8910447Snilay@cs.wisc.edu        s0_to_y_delay->addDownstreamNode(y_ron);
9010447Snilay@cs.wisc.edu        y_ron->addDownstreamNode(getNet("Y"));
9110447Snilay@cs.wisc.edu
9210447Snilay@cs.wisc.edu        // Create Area result
9310447Snilay@cs.wisc.edu        createElectricalAtomicResults();
9410447Snilay@cs.wisc.edu        getEventInfo("Idle")->setStaticTransitionInfos();
9510447Snilay@cs.wisc.edu        // Create MUX2 Event Energy Result
9610447Snilay@cs.wisc.edu        createElectricalEventAtomicResult("MUX2");
9710447Snilay@cs.wisc.edu
9810447Snilay@cs.wisc.edu
9910447Snilay@cs.wisc.edu        return;
10010447Snilay@cs.wisc.edu    }
10110447Snilay@cs.wisc.edu
10210447Snilay@cs.wisc.edu    void MUX2::updateModel()
10310447Snilay@cs.wisc.edu    {
10410447Snilay@cs.wisc.edu        // Get parameters
10510447Snilay@cs.wisc.edu        double drive_strength = getDrivingStrength();
10610447Snilay@cs.wisc.edu        Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache();
10710447Snilay@cs.wisc.edu
10810447Snilay@cs.wisc.edu        // Standard cell cache string
10910447Snilay@cs.wisc.edu        String cell_name = "MUX2_X" + (String) drive_strength;
11010447Snilay@cs.wisc.edu
11110447Snilay@cs.wisc.edu        // Get timing parameters
11210447Snilay@cs.wisc.edu        getLoad("A_Cap")->setLoadCap(cache->get(cell_name + "->Cap->A"));
11310447Snilay@cs.wisc.edu        getLoad("B_Cap")->setLoadCap(cache->get(cell_name + "->Cap->B"));
11410447Snilay@cs.wisc.edu        getLoad("S0_Cap")->setLoadCap(cache->get(cell_name + "->Cap->S0"));
11510447Snilay@cs.wisc.edu
11610447Snilay@cs.wisc.edu        getDelay("A_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->A_to_Y"));
11710447Snilay@cs.wisc.edu        getDelay("B_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->B_to_Y"));
11810447Snilay@cs.wisc.edu        getDelay("S0_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->S0_to_Y"));
11910447Snilay@cs.wisc.edu
12010447Snilay@cs.wisc.edu        getDriver("Y_Ron")->setOutputRes(cache->get(cell_name + "->DriveRes->Y"));
12110447Snilay@cs.wisc.edu
12210447Snilay@cs.wisc.edu        // Set the cell area
12310447Snilay@cs.wisc.edu        getAreaResult("Active")->setValue(cache->get(cell_name + "->ActiveArea"));
12410447Snilay@cs.wisc.edu        getAreaResult("Metal1Wire")->setValue(cache->get(cell_name + "->ActiveArea"));
12510447Snilay@cs.wisc.edu
12610447Snilay@cs.wisc.edu        return;
12710447Snilay@cs.wisc.edu    }
12810447Snilay@cs.wisc.edu
12910447Snilay@cs.wisc.edu    void MUX2::evaluateModel()
13010447Snilay@cs.wisc.edu    {
13110447Snilay@cs.wisc.edu        return;
13210447Snilay@cs.wisc.edu    }
13310447Snilay@cs.wisc.edu
13410447Snilay@cs.wisc.edu    void MUX2::useModel()
13510447Snilay@cs.wisc.edu    {
13610447Snilay@cs.wisc.edu        // Get parameters
13710447Snilay@cs.wisc.edu        double drive_strength = getDrivingStrength();
13810447Snilay@cs.wisc.edu        Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache();
13910447Snilay@cs.wisc.edu
14010447Snilay@cs.wisc.edu        // Standard cell cache string
14110447Snilay@cs.wisc.edu        String cell_name = "MUX2_X" + (String) drive_strength;
14210447Snilay@cs.wisc.edu
14310447Snilay@cs.wisc.edu        // Propagate the transition and get the 0->1 transition count
14410447Snilay@cs.wisc.edu        propagateTransitionInfo();
14510447Snilay@cs.wisc.edu        double P_A = getInputPort("A")->getTransitionInfo().getProbability1();
14610447Snilay@cs.wisc.edu        double P_B = getInputPort("B")->getTransitionInfo().getProbability1();
14710447Snilay@cs.wisc.edu        double P_S0 = getInputPort("S0")->getTransitionInfo().getProbability1();
14810447Snilay@cs.wisc.edu        double S0_num_trans_01 = getInputPort("S0")->getTransitionInfo().getNumberTransitions01();
14910447Snilay@cs.wisc.edu        double Y_num_trans_01 = getOutputPort("Y")->getTransitionInfo().getNumberTransitions01();
15010447Snilay@cs.wisc.edu
15110447Snilay@cs.wisc.edu        // Calculate leakage
15210447Snilay@cs.wisc.edu        double leakage = 0;
15310447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!A!B!S0") * (1 - P_A) * (1 - P_B) * (1 - P_S0);
15410447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!A!BS0") * (1 - P_A) * (1 - P_B) * P_S0;
15510447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!AB!S0") * (1 - P_A) * P_B * (1 - P_S0);
15610447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->!ABS0") * (1 - P_A) * P_B * P_S0;
15710447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->A!B!S0") * P_A * (1 - P_B) * (1 - P_S0);
15810447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->A!BS0") * P_A * (1 - P_B) * P_S0;
15910447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->AB!S0") * P_A * P_B * (1 - P_S0);
16010447Snilay@cs.wisc.edu        leakage += cache->get(cell_name + "->Leakage->ABS0") * P_A * P_B * P_S0;
16110447Snilay@cs.wisc.edu        getNddPowerResult("Leakage")->setValue(leakage);
16210447Snilay@cs.wisc.edu
16310447Snilay@cs.wisc.edu        // Get VDD
16410447Snilay@cs.wisc.edu        double vdd = getTechModel()->get("Vdd");
16510447Snilay@cs.wisc.edu
16610447Snilay@cs.wisc.edu        // Get capacitances
16710447Snilay@cs.wisc.edu        double s0_b_cap = cache->get(cell_name + "->Cap->S0_b");
16810447Snilay@cs.wisc.edu        double y_bar_cap = cache->get(cell_name + "->Cap->Y_b");
16910447Snilay@cs.wisc.edu        double y_cap = cache->get(cell_name + "->Cap->Y");
17010447Snilay@cs.wisc.edu        double y_load_cap = getNet("Y")->getTotalDownstreamCap();
17110447Snilay@cs.wisc.edu        // Create mux2 event energy
17210447Snilay@cs.wisc.edu        double mux2_event_energy = 0.0;
17310447Snilay@cs.wisc.edu        mux2_event_energy += (s0_b_cap) * S0_num_trans_01;
17410447Snilay@cs.wisc.edu        mux2_event_energy += (y_bar_cap + y_cap + y_load_cap) * Y_num_trans_01;
17510447Snilay@cs.wisc.edu        mux2_event_energy *= vdd * vdd;
17610447Snilay@cs.wisc.edu        getEventResult("MUX2")->setValue(mux2_event_energy);
17710447Snilay@cs.wisc.edu
17810447Snilay@cs.wisc.edu        return;
17910447Snilay@cs.wisc.edu    }
18010447Snilay@cs.wisc.edu
18110447Snilay@cs.wisc.edu    void MUX2::propagateTransitionInfo()
18210447Snilay@cs.wisc.edu    {
18310447Snilay@cs.wisc.edu        // Get input signal transition info
18410447Snilay@cs.wisc.edu        const TransitionInfo& trans_A = getInputPort("A")->getTransitionInfo();
18510447Snilay@cs.wisc.edu        const TransitionInfo& trans_B = getInputPort("B")->getTransitionInfo();
18610447Snilay@cs.wisc.edu        const TransitionInfo& trans_S0 = getInputPort("S0")->getTransitionInfo();
18710447Snilay@cs.wisc.edu
18810447Snilay@cs.wisc.edu        // Scale all transition information to the highest freq multiplier
18910447Snilay@cs.wisc.edu        double max_freq_mult = max(max(trans_A.getFrequencyMultiplier(), trans_B.getFrequencyMultiplier()), trans_S0.getFrequencyMultiplier());
19010447Snilay@cs.wisc.edu        const TransitionInfo& scaled_trans_A = trans_A.scaleFrequencyMultiplier(max_freq_mult);
19110447Snilay@cs.wisc.edu        const TransitionInfo& scaled_trans_B = trans_B.scaleFrequencyMultiplier(max_freq_mult);
19210447Snilay@cs.wisc.edu        const TransitionInfo& scaled_trans_S0 = trans_S0.scaleFrequencyMultiplier(max_freq_mult);
19310447Snilay@cs.wisc.edu
19410447Snilay@cs.wisc.edu        // Compute the probability of each transition on a given cycle
19510447Snilay@cs.wisc.edu        double A_prob_00 = scaled_trans_A.getNumberTransitions00() / max_freq_mult;
19610447Snilay@cs.wisc.edu        double A_prob_01 = scaled_trans_A.getNumberTransitions01() / max_freq_mult;
19710447Snilay@cs.wisc.edu        double A_prob_10 = A_prob_01;
19810447Snilay@cs.wisc.edu        double A_prob_11 = scaled_trans_A.getNumberTransitions11() / max_freq_mult;
19910447Snilay@cs.wisc.edu        double B_prob_00 = scaled_trans_B.getNumberTransitions00() / max_freq_mult;
20010447Snilay@cs.wisc.edu        double B_prob_01 = scaled_trans_B.getNumberTransitions01() / max_freq_mult;
20110447Snilay@cs.wisc.edu        double B_prob_10 = B_prob_01;
20210447Snilay@cs.wisc.edu        double B_prob_11 = scaled_trans_B.getNumberTransitions11() / max_freq_mult;
20310447Snilay@cs.wisc.edu        double S0_prob_00 = scaled_trans_S0.getNumberTransitions00() / max_freq_mult;
20410447Snilay@cs.wisc.edu        double S0_prob_01 = scaled_trans_S0.getNumberTransitions01() / max_freq_mult;
20510447Snilay@cs.wisc.edu        double S0_prob_10 = S0_prob_01;
20610447Snilay@cs.wisc.edu        double S0_prob_11 = scaled_trans_S0.getNumberTransitions11() / max_freq_mult;
20710447Snilay@cs.wisc.edu
20810447Snilay@cs.wisc.edu        // Compute output probabilities
20910447Snilay@cs.wisc.edu        double Y_prob_00 = S0_prob_00 * A_prob_00 +
21010447Snilay@cs.wisc.edu                            S0_prob_01 * (A_prob_00 + A_prob_01) * (B_prob_00 + B_prob_10) +
21110447Snilay@cs.wisc.edu                            S0_prob_10 * (A_prob_00 + A_prob_10) * (B_prob_00 + B_prob_01) +
21210447Snilay@cs.wisc.edu                            S0_prob_11 * B_prob_00;
21310447Snilay@cs.wisc.edu        double Y_prob_01 = S0_prob_00 * A_prob_01 +
21410447Snilay@cs.wisc.edu                            S0_prob_01 * (A_prob_00 + A_prob_01) * (B_prob_01 + B_prob_11) +
21510447Snilay@cs.wisc.edu                            S0_prob_10 * (A_prob_01 + A_prob_11) * (B_prob_00 + B_prob_01) +
21610447Snilay@cs.wisc.edu                            S0_prob_11 * B_prob_01;
21710447Snilay@cs.wisc.edu        double Y_prob_11 = S0_prob_00 * A_prob_11 +
21810447Snilay@cs.wisc.edu                            S0_prob_01 * (A_prob_10 + A_prob_11) * (B_prob_01 + B_prob_11) +
21910447Snilay@cs.wisc.edu                            S0_prob_10 * (A_prob_01 + A_prob_11) * (B_prob_10 + B_prob_11) +
22010447Snilay@cs.wisc.edu                            S0_prob_11 * B_prob_11;
22110447Snilay@cs.wisc.edu
22210447Snilay@cs.wisc.edu        // Check that probabilities add up to 1.0 with some finite tolerance
22310447Snilay@cs.wisc.edu        ASSERT(LibUtil::Math::isEqual((Y_prob_00 + Y_prob_01 + Y_prob_01 + Y_prob_11), 1.0),
22410447Snilay@cs.wisc.edu            "[Error] " + getInstanceName() +  "Output transition probabilities must add up to 1 (" +
22510447Snilay@cs.wisc.edu            (String) Y_prob_00 + ", " + (String) Y_prob_01 + ", " + (String) Y_prob_11 + ")!");
22610447Snilay@cs.wisc.edu
22710447Snilay@cs.wisc.edu        // Turn probability of transitions per cycle into number of transitions per time unit
22810447Snilay@cs.wisc.edu        TransitionInfo trans_Y(Y_prob_00 * max_freq_mult, Y_prob_01 * max_freq_mult, Y_prob_11 * max_freq_mult);
22910447Snilay@cs.wisc.edu        getOutputPort("Y")->setTransitionInfo(trans_Y);
23010447Snilay@cs.wisc.edu
23110447Snilay@cs.wisc.edu        return;
23210447Snilay@cs.wisc.edu    }
23310447Snilay@cs.wisc.edu
23410447Snilay@cs.wisc.edu    // Creates the standard cell, characterizes and abstracts away the details
23510447Snilay@cs.wisc.edu    void MUX2::cacheStdCell(StdCellLib* cell_lib_, double drive_strength_)
23610447Snilay@cs.wisc.edu    {
23710447Snilay@cs.wisc.edu        // Get parameters
23810447Snilay@cs.wisc.edu        double gate_pitch = cell_lib_->getTechModel()->get("Gate->PitchContacted");
23910447Snilay@cs.wisc.edu        Map<double>* cache = cell_lib_->getStdCellCache();
24010447Snilay@cs.wisc.edu
24110447Snilay@cs.wisc.edu        // Standard cell cache string
24210447Snilay@cs.wisc.edu        String cell_name = "MUX2_X" + (String) drive_strength_;
24310447Snilay@cs.wisc.edu
24410447Snilay@cs.wisc.edu        Log::printLine("=== " + cell_name + " ===");
24510447Snilay@cs.wisc.edu
24610447Snilay@cs.wisc.edu        // Now actually build the full standard cell model
24710447Snilay@cs.wisc.edu        createInputPort("A");
24810447Snilay@cs.wisc.edu        createInputPort("B");
24910447Snilay@cs.wisc.edu        createInputPort("S0");
25010447Snilay@cs.wisc.edu        createOutputPort("Y");
25110447Snilay@cs.wisc.edu
25210447Snilay@cs.wisc.edu        createNet("S0_b");
25310447Snilay@cs.wisc.edu        createNet("Y_b");
25410447Snilay@cs.wisc.edu
25510447Snilay@cs.wisc.edu        // Adds macros
25610447Snilay@cs.wisc.edu        CellMacros::addInverter(this, "INV1", false, true, "S0", "S0_b");
25710447Snilay@cs.wisc.edu        CellMacros::addInverter(this, "INV2", false, true, "Y_b", "Y");
25810447Snilay@cs.wisc.edu        CellMacros::addTristate(this, "INVZ1", true, true, true, true, "A", "S0_b", "S0", "Y_b");
25910447Snilay@cs.wisc.edu        CellMacros::addTristate(this, "INVZ2", true, true, true, true, "B", "S0", "S0_b", "Y_b");
26010447Snilay@cs.wisc.edu
26110447Snilay@cs.wisc.edu        // I have no idea how to size each of the parts haha
26210447Snilay@cs.wisc.edu        CellMacros::updateInverter(this, "INV1", drive_strength_ * 0.250);
26310447Snilay@cs.wisc.edu        CellMacros::updateInverter(this, "INV2", drive_strength_ * 1.000);
26410447Snilay@cs.wisc.edu        CellMacros::updateTristate(this, "INVZ1", drive_strength_ * 0.500);
26510447Snilay@cs.wisc.edu        CellMacros::updateTristate(this, "INVZ2", drive_strength_ * 0.500);
26610447Snilay@cs.wisc.edu
26710447Snilay@cs.wisc.edu        // Cache area result
26810447Snilay@cs.wisc.edu        double area = 0.0;
26910447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * 1;
27010447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV1_GatePitches").toDouble();
27110447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INV2_GatePitches").toDouble();
27210447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INVZ1_GatePitches").toDouble();
27310447Snilay@cs.wisc.edu        area += gate_pitch * getTotalHeight() * getGenProperties()->get("INVZ2_GatePitches").toDouble();
27410447Snilay@cs.wisc.edu        cache->set(cell_name + "->ActiveArea", area);
27510447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->ActiveArea=" + (String) area);
27610447Snilay@cs.wisc.edu
27710447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
27810447Snilay@cs.wisc.edu        // Cache Leakage Power (for every single signal combination)
27910447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
28010447Snilay@cs.wisc.edu        double leakage_000 = 0;          //!A, !B, !S0
28110447Snilay@cs.wisc.edu        double leakage_001 = 0;          //!A, !B, S0
28210447Snilay@cs.wisc.edu        double leakage_010 = 0;          //!A, B, !S0
28310447Snilay@cs.wisc.edu        double leakage_011 = 0;          //!A, B, S0
28410447Snilay@cs.wisc.edu        double leakage_100 = 0;          //A, !B, !S0
28510447Snilay@cs.wisc.edu        double leakage_101 = 0;          //A, !B, S0
28610447Snilay@cs.wisc.edu        double leakage_110 = 0;          //A, B, !S0
28710447Snilay@cs.wisc.edu        double leakage_111 = 0;          //A, B, S0
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_1").toDouble();
29210447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INVZ1_LeakagePower_100_1").toDouble();
29310447Snilay@cs.wisc.edu        leakage_000 += getGenProperties()->get("INVZ2_LeakagePower_010_1").toDouble();
29410447Snilay@cs.wisc.edu
29510447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
29610447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
29710447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INVZ1_LeakagePower_010_1").toDouble();
29810447Snilay@cs.wisc.edu        leakage_001 += getGenProperties()->get("INVZ2_LeakagePower_100_1").toDouble();
29910447Snilay@cs.wisc.edu
30010447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
30110447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
30210447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INVZ1_LeakagePower_100_1").toDouble();
30310447Snilay@cs.wisc.edu        leakage_010 += getGenProperties()->get("INVZ2_LeakagePower_011_1").toDouble();
30410447Snilay@cs.wisc.edu
30510447Snilay@cs.wisc.edu        leakage_011 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
30610447Snilay@cs.wisc.edu        leakage_011 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
30710447Snilay@cs.wisc.edu        leakage_011 += getGenProperties()->get("INVZ1_LeakagePower_010_0").toDouble();
30810447Snilay@cs.wisc.edu        leakage_011 += getGenProperties()->get("INVZ2_LeakagePower_101_0").toDouble();
30910447Snilay@cs.wisc.edu
31010447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INV1_LeakagePower_0").toDouble();
31110447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
31210447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INVZ1_LeakagePower_101_0").toDouble();
31310447Snilay@cs.wisc.edu        leakage_100 += getGenProperties()->get("INVZ2_LeakagePower_010_0").toDouble();
31410447Snilay@cs.wisc.edu
31510447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
31610447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INV2_LeakagePower_0").toDouble();
31710447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INVZ1_LeakagePower_011_1").toDouble();
31810447Snilay@cs.wisc.edu        leakage_101 += getGenProperties()->get("INVZ2_LeakagePower_100_1").toDouble();
31910447Snilay@cs.wisc.edu
32010447Snilay@cs.wisc.edu        leakage_110 += getGenProperties()->get("INV1_LeakagePower_1").toDouble();
32110447Snilay@cs.wisc.edu        leakage_110 += getGenProperties()->get("INV2_LeakagePower_1").toDouble();
32210447Snilay@cs.wisc.edu        leakage_110 += getGenProperties()->get("INVZ1_LeakagePower_101_0").toDouble();
32310447Snilay@cs.wisc.edu        leakage_110 += getGenProperties()->get("INVZ2_LeakagePower_011_0").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("INVZ1_LeakagePower_011_0").toDouble();
32810447Snilay@cs.wisc.edu        leakage_111 += getGenProperties()->get("INVZ2_LeakagePower_101_0").toDouble();
32910447Snilay@cs.wisc.edu
33010447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!A!B!S0", leakage_000);
33110447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!A!BS0", leakage_001);
33210447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!AB!S0", leakage_010);
33310447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->!ABS0", leakage_011);
33410447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->A!B!S0", leakage_100);
33510447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->A!BS0", leakage_101);
33610447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->AB!S0", leakage_110);
33710447Snilay@cs.wisc.edu        cache->set(cell_name + "->Leakage->ABS0", leakage_111);
33810447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!A!B!S0=" + (String) leakage_000);
33910447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!A!BS0=" + (String) leakage_001);
34010447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!AB!S0=" + (String) leakage_010);
34110447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->!ABS0=" + (String) leakage_011);
34210447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->A!B!S0=" + (String) leakage_100);
34310447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->A!BS0=" + (String) leakage_101);
34410447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->AB!S0=" + (String) leakage_110);
34510447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Leakage->ABS0=" + (String) leakage_111);
34610447Snilay@cs.wisc.edu
34710447Snilay@cs.wisc.edu        // Cache event energy results
34810447Snilay@cs.wisc.edu        /*
34910447Snilay@cs.wisc.edu        double event_a_flip = 0.0;
35010447Snilay@cs.wisc.edu        event_a_flip += getGenProperties()->get("INVZ1_A_Flip").toDouble();
35110447Snilay@cs.wisc.edu        cache->set(cell_name + "->Event_A_Flip", event_a_flip);
35210447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Event_A_Flip=" + (String) event_a_flip);
35310447Snilay@cs.wisc.edu
35410447Snilay@cs.wisc.edu        double event_b_flip = 0.0;
35510447Snilay@cs.wisc.edu        event_b_flip += getGenProperties()->get("INVZ1_A_Flip").toDouble();
35610447Snilay@cs.wisc.edu        cache->set(cell_name + "->Event_B_Flip", event_b_flip);
35710447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Event_B_Flip=" + (String) event_b_flip);
35810447Snilay@cs.wisc.edu
35910447Snilay@cs.wisc.edu        double event_s0_flip = 0.0;
36010447Snilay@cs.wisc.edu        event_s0_flip += getGenProperties()->get("INV1_A_Flip").toDouble();
36110447Snilay@cs.wisc.edu        event_s0_flip += getGenProperties()->get("INV1_ZN_Flip").toDouble();
36210447Snilay@cs.wisc.edu        event_s0_flip += getGenProperties()->get("INVZ1_OE_Flip").toDouble() + getGenProperties()->get("INVZ1_OEN_Flip").toDouble();
36310447Snilay@cs.wisc.edu        event_s0_flip += getGenProperties()->get("INVZ2_OE_Flip").toDouble() + getGenProperties()->get("INVZ2_OEN_Flip").toDouble();
36410447Snilay@cs.wisc.edu        cache->set(cell_name + "->Event_S0_Flip", event_s0_flip);
36510447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Event_S0_Flip=" + (String) event_s0_flip);
36610447Snilay@cs.wisc.edu
36710447Snilay@cs.wisc.edu        double event_y_flip = 0.0;
36810447Snilay@cs.wisc.edu        event_y_flip += getGenProperties()->get("INVZ1_ZN_Flip").toDouble();
36910447Snilay@cs.wisc.edu        event_y_flip += getGenProperties()->get("INVZ2_ZN_Flip").toDouble();
37010447Snilay@cs.wisc.edu        event_y_flip += getGenProperties()->get("INV2_A_Flip").toDouble();
37110447Snilay@cs.wisc.edu        event_y_flip += getGenProperties()->get("INV2_ZN_Flip").toDouble();
37210447Snilay@cs.wisc.edu        cache->set(cell_name + "->Event_Y_Flip", event_y_flip);
37310447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Event_Y_Flip=" + (String) event_y_flip);
37410447Snilay@cs.wisc.edu
37510447Snilay@cs.wisc.edu        double a_cap = getLoad("INVZ1_CgA")->getLoadCap();
37610447Snilay@cs.wisc.edu        double b_cap = getLoad("INVZ2_CgA")->getLoadCap();
37710447Snilay@cs.wisc.edu        double s0_cap = getLoad("INV1_CgA")->getLoadCap() + getLoad("INVZ1_CgOEN")->getLoadCap() + getLoad("INVZ2_CgOE")->getLoadCap();
37810447Snilay@cs.wisc.edu        double y_ron = getDriver("INV2_RonZN")->getOutputRes();
37910447Snilay@cs.wisc.edu        */
38010447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
38110447Snilay@cs.wisc.edu
38210447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
38310447Snilay@cs.wisc.edu        // Get Node capacitances
38410447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
38510447Snilay@cs.wisc.edu        double a_cap = getNet("A")->getTotalDownstreamCap();
38610447Snilay@cs.wisc.edu        double b_cap = getNet("B")->getTotalDownstreamCap();
38710447Snilay@cs.wisc.edu        double s0_cap = getNet("S0")->getTotalDownstreamCap();
38810447Snilay@cs.wisc.edu        double s0_b_cap = getNet("S0_b")->getTotalDownstreamCap();
38910447Snilay@cs.wisc.edu        double y_b_cap = getNet("Y_b")->getTotalDownstreamCap();
39010447Snilay@cs.wisc.edu        double y_cap = getNet("Y")->getTotalDownstreamCap();
39110447Snilay@cs.wisc.edu
39210447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->A", a_cap);
39310447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->B", b_cap);
39410447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->S0", s0_cap);
39510447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->S0_b", s0_b_cap);
39610447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->Y_b", y_b_cap);
39710447Snilay@cs.wisc.edu        cache->set(cell_name + "->Cap->Y", y_cap);
39810447Snilay@cs.wisc.edu
39910447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->A=" + (String) a_cap);
40010447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->B=" + (String) b_cap);
40110447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->S0=" + (String) s0_cap);
40210447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->S0_b=" + (String) s0_b_cap);
40310447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->Y_b=" + (String) y_b_cap);
40410447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Cap->Y=" + (String) y_cap);
40510447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
40610447Snilay@cs.wisc.edu
40710447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
40810447Snilay@cs.wisc.edu        // Build Internal Delay Model
40910447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
41010447Snilay@cs.wisc.edu        // Build abstracted timing model
41110447Snilay@cs.wisc.edu        double y_ron = getDriver("INV2_RonZN")->getOutputRes();
41210447Snilay@cs.wisc.edu
41310447Snilay@cs.wisc.edu        double a_to_y_delay = 0.0;
41410447Snilay@cs.wisc.edu        a_to_y_delay += getDriver("INVZ1_RonZN")->calculateDelay();
41510447Snilay@cs.wisc.edu        a_to_y_delay += getDriver("INV2_RonZN")->calculateDelay();
41610447Snilay@cs.wisc.edu
41710447Snilay@cs.wisc.edu        double b_to_y_delay = 0.0;
41810447Snilay@cs.wisc.edu        b_to_y_delay += getDriver("INVZ1_RonZN")->calculateDelay();
41910447Snilay@cs.wisc.edu        b_to_y_delay += getDriver("INV2_RonZN")->calculateDelay();
42010447Snilay@cs.wisc.edu
42110447Snilay@cs.wisc.edu        double s0_to_y_delay = 0.0;
42210447Snilay@cs.wisc.edu        s0_to_y_delay += getDriver("INV1_RonZN")->calculateDelay();
42310447Snilay@cs.wisc.edu        s0_to_y_delay += max(getDriver("INVZ1_RonZN")->calculateDelay(), getDriver("INVZ1_RonZN")->calculateDelay());
42410447Snilay@cs.wisc.edu        s0_to_y_delay += getDriver("INV2_RonZN")->calculateDelay();
42510447Snilay@cs.wisc.edu
42610447Snilay@cs.wisc.edu        cache->set(cell_name + "->DriveRes->Y", y_ron);
42710447Snilay@cs.wisc.edu        cache->set(cell_name + "->Delay->A_to_Y", a_to_y_delay);
42810447Snilay@cs.wisc.edu        cache->set(cell_name + "->Delay->B_to_Y", b_to_y_delay);
42910447Snilay@cs.wisc.edu        cache->set(cell_name + "->Delay->S0_to_Y", s0_to_y_delay);
43010447Snilay@cs.wisc.edu
43110447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->DriveRes->Y=" + (String) y_ron);
43210447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Delay->A_to_Y=" + (String) a_to_y_delay);
43310447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Delay->B_to_Y=" + (String) b_to_y_delay);
43410447Snilay@cs.wisc.edu        Log::printLine(cell_name + "->Delay->S0_to_Y=" + (String) s0_to_y_delay);
43510447Snilay@cs.wisc.edu        // --------------------------------------------------------------------
43610447Snilay@cs.wisc.edu
43710447Snilay@cs.wisc.edu        return;
43810447Snilay@cs.wisc.edu    }
43910447Snilay@cs.wisc.edu
44010447Snilay@cs.wisc.edu} // namespace DSENT
44110447Snilay@cs.wisc.edu
442