INV.cc revision 10447
110447Snilay@cs.wisc.edu#include "model/std_cells/INV.h" 210447Snilay@cs.wisc.edu 310447Snilay@cs.wisc.edu#include <cmath> 410447Snilay@cs.wisc.edu 510447Snilay@cs.wisc.edu#include "model/PortInfo.h" 610447Snilay@cs.wisc.edu#include "model/TransitionInfo.h" 710447Snilay@cs.wisc.edu#include "model/EventInfo.h" 810447Snilay@cs.wisc.edu#include "model/std_cells/CellMacros.h" 910447Snilay@cs.wisc.edu#include "model/std_cells/StdCellLib.h" 1010447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalNet.h" 1110447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalDriver.h" 1210447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalLoad.h" 1310447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalDelay.h" 1410447Snilay@cs.wisc.edu 1510447Snilay@cs.wisc.edunamespace DSENT 1610447Snilay@cs.wisc.edu{ 1710447Snilay@cs.wisc.edu using std::ceil; 1810447Snilay@cs.wisc.edu using std::max; 1910447Snilay@cs.wisc.edu 2010447Snilay@cs.wisc.edu INV::INV(const String& instance_name_, const TechModel* tech_model_) 2110447Snilay@cs.wisc.edu : StdCell(instance_name_, tech_model_) 2210447Snilay@cs.wisc.edu { 2310447Snilay@cs.wisc.edu initProperties(); 2410447Snilay@cs.wisc.edu } 2510447Snilay@cs.wisc.edu 2610447Snilay@cs.wisc.edu INV::~INV() 2710447Snilay@cs.wisc.edu {} 2810447Snilay@cs.wisc.edu 2910447Snilay@cs.wisc.edu void INV::initProperties() 3010447Snilay@cs.wisc.edu { 3110447Snilay@cs.wisc.edu return; 3210447Snilay@cs.wisc.edu } 3310447Snilay@cs.wisc.edu 3410447Snilay@cs.wisc.edu void INV::constructModel() 3510447Snilay@cs.wisc.edu { 3610447Snilay@cs.wisc.edu // All constructModel should do is create Area/NDDPower/Energy Results as 3710447Snilay@cs.wisc.edu // well as instantiate any sub-instances using only the hard parameters 3810447Snilay@cs.wisc.edu 3910447Snilay@cs.wisc.edu // Build Electrical Connectivity 4010447Snilay@cs.wisc.edu createInputPort("A"); 4110447Snilay@cs.wisc.edu createOutputPort("Y"); 4210447Snilay@cs.wisc.edu 4310447Snilay@cs.wisc.edu createLoad("A_Cap"); 4410447Snilay@cs.wisc.edu createDelay("A_to_Y_delay"); 4510447Snilay@cs.wisc.edu createDriver("Y_Ron", true); 4610447Snilay@cs.wisc.edu 4710447Snilay@cs.wisc.edu ElectricalLoad* a_cap = getLoad("A_Cap"); 4810447Snilay@cs.wisc.edu ElectricalDelay* a_to_y_delay = getDelay("A_to_Y_delay"); 4910447Snilay@cs.wisc.edu ElectricalDriver* y_ron = getDriver("Y_Ron"); 5010447Snilay@cs.wisc.edu 5110447Snilay@cs.wisc.edu getNet("A")->addDownstreamNode(a_cap); 5210447Snilay@cs.wisc.edu a_cap->addDownstreamNode(a_to_y_delay); 5310447Snilay@cs.wisc.edu a_to_y_delay->addDownstreamNode(y_ron); 5410447Snilay@cs.wisc.edu y_ron->addDownstreamNode(getNet("Y")); 5510447Snilay@cs.wisc.edu 5610447Snilay@cs.wisc.edu // Create Area result 5710447Snilay@cs.wisc.edu // Create NDD Power result 5810447Snilay@cs.wisc.edu createElectricalAtomicResults(); 5910447Snilay@cs.wisc.edu // Create INV Event Energy Result 6010447Snilay@cs.wisc.edu createElectricalEventAtomicResult("INV"); 6110447Snilay@cs.wisc.edu 6210447Snilay@cs.wisc.edu getEventInfo("Idle")->setStaticTransitionInfos(); 6310447Snilay@cs.wisc.edu 6410447Snilay@cs.wisc.edu return; 6510447Snilay@cs.wisc.edu } 6610447Snilay@cs.wisc.edu 6710447Snilay@cs.wisc.edu void INV::updateModel() 6810447Snilay@cs.wisc.edu { 6910447Snilay@cs.wisc.edu // All updateModel should do is calculate numbers for the Area/NDDPower/Energy 7010447Snilay@cs.wisc.edu // Results as anything else that needs to be done using either soft or hard parameters 7110447Snilay@cs.wisc.edu 7210447Snilay@cs.wisc.edu // Get parameters 7310447Snilay@cs.wisc.edu double drive_strength = getDrivingStrength(); 7410447Snilay@cs.wisc.edu Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache(); 7510447Snilay@cs.wisc.edu 7610447Snilay@cs.wisc.edu // Standard cell cache string 7710447Snilay@cs.wisc.edu String cell_name = "INV_X" + (String) drive_strength; 7810447Snilay@cs.wisc.edu 7910447Snilay@cs.wisc.edu // Get timing parameters 8010447Snilay@cs.wisc.edu getLoad("A_Cap")->setLoadCap(cache->get(cell_name + "->Cap->A")); 8110447Snilay@cs.wisc.edu getDriver("Y_Ron")->setOutputRes(cache->get(cell_name + "->DriveRes->Y")); 8210447Snilay@cs.wisc.edu getDelay("A_to_Y_delay")->setDelay(cache->get(cell_name + "->Delay->A_to_Y")); 8310447Snilay@cs.wisc.edu 8410447Snilay@cs.wisc.edu // Set the cell area 8510447Snilay@cs.wisc.edu getAreaResult("Active")->setValue(cache->get(cell_name + "->Area->Active")); 8610447Snilay@cs.wisc.edu getAreaResult("Metal1Wire")->setValue(cache->get(cell_name + "->Area->Metal1Wire")); 8710447Snilay@cs.wisc.edu 8810447Snilay@cs.wisc.edu return; 8910447Snilay@cs.wisc.edu } 9010447Snilay@cs.wisc.edu 9110447Snilay@cs.wisc.edu void INV::evaluateModel() 9210447Snilay@cs.wisc.edu { 9310447Snilay@cs.wisc.edu return; 9410447Snilay@cs.wisc.edu } 9510447Snilay@cs.wisc.edu 9610447Snilay@cs.wisc.edu void INV::useModel() 9710447Snilay@cs.wisc.edu { 9810447Snilay@cs.wisc.edu // Get parameters 9910447Snilay@cs.wisc.edu double drive_strength = getDrivingStrength(); 10010447Snilay@cs.wisc.edu Map<double>* cache = getTechModel()->getStdCellLib()->getStdCellCache(); 10110447Snilay@cs.wisc.edu 10210447Snilay@cs.wisc.edu // Standard cell cache string 10310447Snilay@cs.wisc.edu String cell_name = "INV_X" + (String) drive_strength; 10410447Snilay@cs.wisc.edu 10510447Snilay@cs.wisc.edu // Propagate the transition info and get the 0->1 transtion count 10610447Snilay@cs.wisc.edu propagateTransitionInfo(); 10710447Snilay@cs.wisc.edu double P_A = getInputPort("A")->getTransitionInfo().getProbability1(); 10810447Snilay@cs.wisc.edu double Y_num_trans_01 = getOutputPort("Y")->getTransitionInfo().getNumberTransitions01(); 10910447Snilay@cs.wisc.edu 11010447Snilay@cs.wisc.edu // Calculate leakage 11110447Snilay@cs.wisc.edu double leakage = 0; 11210447Snilay@cs.wisc.edu leakage += cache->get(cell_name + "->Leakage->!A") * (1 - P_A); 11310447Snilay@cs.wisc.edu leakage += cache->get(cell_name + "->Leakage->A") * P_A; 11410447Snilay@cs.wisc.edu getNddPowerResult("Leakage")->setValue(leakage); 11510447Snilay@cs.wisc.edu 11610447Snilay@cs.wisc.edu // Get VDD 11710447Snilay@cs.wisc.edu double vdd = getTechModel()->get("Vdd"); 11810447Snilay@cs.wisc.edu 11910447Snilay@cs.wisc.edu // Get capacitances 12010447Snilay@cs.wisc.edu //double a_cap = cache->get(cell_name + "->Cap->A"); 12110447Snilay@cs.wisc.edu double y_cap = cache->get(cell_name + "->Cap->Y"); 12210447Snilay@cs.wisc.edu double y_load_cap = getNet("Y")->getTotalDownstreamCap(); 12310447Snilay@cs.wisc.edu 12410447Snilay@cs.wisc.edu // Calculate INV Event energy 12510447Snilay@cs.wisc.edu double energy_per_trans_01 = (y_cap + y_load_cap) * vdd * vdd; 12610447Snilay@cs.wisc.edu getEventResult("INV")->setValue(energy_per_trans_01 * Y_num_trans_01); 12710447Snilay@cs.wisc.edu return; 12810447Snilay@cs.wisc.edu } 12910447Snilay@cs.wisc.edu 13010447Snilay@cs.wisc.edu void INV::propagateTransitionInfo() 13110447Snilay@cs.wisc.edu { 13210447Snilay@cs.wisc.edu // Get input transition info 13310447Snilay@cs.wisc.edu const TransitionInfo& trans_A = getInputPort("A")->getTransitionInfo(); 13410447Snilay@cs.wisc.edu 13510447Snilay@cs.wisc.edu // Set output transition info 13610447Snilay@cs.wisc.edu double Y_num_trans_00 = trans_A.getNumberTransitions11(); 13710447Snilay@cs.wisc.edu double Y_num_trans_01 = trans_A.getNumberTransitions01(); 13810447Snilay@cs.wisc.edu double Y_num_trans_11 = trans_A.getNumberTransitions00(); 13910447Snilay@cs.wisc.edu 14010447Snilay@cs.wisc.edu TransitionInfo trans_Y(Y_num_trans_00, Y_num_trans_01, Y_num_trans_11); 14110447Snilay@cs.wisc.edu getOutputPort("Y")->setTransitionInfo(trans_Y); 14210447Snilay@cs.wisc.edu return; 14310447Snilay@cs.wisc.edu } 14410447Snilay@cs.wisc.edu 14510447Snilay@cs.wisc.edu // Creates the standard cell, characterizes and abstracts away the details 14610447Snilay@cs.wisc.edu void INV::cacheStdCell(StdCellLib* cell_lib_, double drive_strength_) 14710447Snilay@cs.wisc.edu { 14810447Snilay@cs.wisc.edu // Standard cell cache string 14910447Snilay@cs.wisc.edu String cell_name = "INV_X" + (String) drive_strength_; 15010447Snilay@cs.wisc.edu 15110447Snilay@cs.wisc.edu Log::printLine("=== " + cell_name + " ==="); 15210447Snilay@cs.wisc.edu 15310447Snilay@cs.wisc.edu // Get parameters 15410447Snilay@cs.wisc.edu double gate_pitch = cell_lib_->getTechModel()->get("Gate->PitchContacted"); 15510447Snilay@cs.wisc.edu Map<double>* cache = cell_lib_->getStdCellCache(); 15610447Snilay@cs.wisc.edu 15710447Snilay@cs.wisc.edu // Now actually build the full standard cell model 15810447Snilay@cs.wisc.edu // Create the two input ports 15910447Snilay@cs.wisc.edu createInputPort("A"); 16010447Snilay@cs.wisc.edu createOutputPort("Y"); 16110447Snilay@cs.wisc.edu 16210447Snilay@cs.wisc.edu // Adds macros 16310447Snilay@cs.wisc.edu CellMacros::addInverter(this, "INV", true, true, "A", "Y"); 16410447Snilay@cs.wisc.edu CellMacros::updateInverter(this, "INV", drive_strength_); 16510447Snilay@cs.wisc.edu 16610447Snilay@cs.wisc.edu // Cache area result 16710447Snilay@cs.wisc.edu double area = gate_pitch * getTotalHeight() * (1 + getGenProperties()->get("INV_GatePitches").toDouble()); 16810447Snilay@cs.wisc.edu cache->set(cell_name + "->Area->Active", area); 16910447Snilay@cs.wisc.edu cache->set(cell_name + "->Area->Metal1Wire", area); 17010447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Area->Active=" + (String) area); 17110447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Area->Metal1Wire=" + (String) area); 17210447Snilay@cs.wisc.edu 17310447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 17410447Snilay@cs.wisc.edu // Leakage Model Calculation 17510447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 17610447Snilay@cs.wisc.edu double leakage_a0 = getGenProperties()->get("INV_LeakagePower_0").toDouble(); 17710447Snilay@cs.wisc.edu double leakage_a1 = getGenProperties()->get("INV_LeakagePower_1").toDouble(); 17810447Snilay@cs.wisc.edu cache->set(cell_name + "->Leakage->!A", leakage_a0); 17910447Snilay@cs.wisc.edu cache->set(cell_name + "->Leakage->A", leakage_a1); 18010447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Leakage->!A=" + (String) leakage_a0); 18110447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Leakage->A=" + (String) leakage_a1); 18210447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 18310447Snilay@cs.wisc.edu 18410447Snilay@cs.wisc.edu /* 18510447Snilay@cs.wisc.edu // Cache event energy results 18610447Snilay@cs.wisc.edu double event_a_flip = getGenProperties()->get("INV_A_Flip").toDouble() + getGenProperties()->get("INV_ZN_Flip").toDouble(); 18710447Snilay@cs.wisc.edu cache->set(cell_name + "->Event_A_Flip", event_a_flip); 18810447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Event_A_Flip=" + (String) event_a_flip); 18910447Snilay@cs.wisc.edu */ 19010447Snilay@cs.wisc.edu 19110447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 19210447Snilay@cs.wisc.edu // Get Node Capacitances 19310447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 19410447Snilay@cs.wisc.edu double a_cap = getNet("A")->getTotalDownstreamCap(); 19510447Snilay@cs.wisc.edu double y_cap = getNet("Y")->getTotalDownstreamCap(); 19610447Snilay@cs.wisc.edu 19710447Snilay@cs.wisc.edu cache->set(cell_name + "->Cap->A", a_cap); 19810447Snilay@cs.wisc.edu cache->set(cell_name + "->Cap->Y", y_cap); 19910447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Cap->A=" + (String) a_cap); 20010447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Cap->Y=" + (String) y_cap); 20110447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 20210447Snilay@cs.wisc.edu 20310447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 20410447Snilay@cs.wisc.edu // Build Internal Delay Model 20510447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 20610447Snilay@cs.wisc.edu double y_ron = getDriver("INV_RonZN")->getOutputRes(); 20710447Snilay@cs.wisc.edu double a_to_y_delay = getDriver("INV_RonZN")->calculateDelay(); 20810447Snilay@cs.wisc.edu cache->set(cell_name + "->DriveRes->Y", y_ron); 20910447Snilay@cs.wisc.edu cache->set(cell_name + "->Delay->A_to_Y", a_to_y_delay); 21010447Snilay@cs.wisc.edu Log::printLine(cell_name + "->DriveRes->Y=" + (String) y_ron); 21110447Snilay@cs.wisc.edu Log::printLine(cell_name + "->Delay->A_to_Y=" + (String) a_to_y_delay); 21210447Snilay@cs.wisc.edu // -------------------------------------------------------------------- 21310447Snilay@cs.wisc.edu 21410447Snilay@cs.wisc.edu return; 21510447Snilay@cs.wisc.edu 21610447Snilay@cs.wisc.edu } 21710447Snilay@cs.wisc.edu 21810447Snilay@cs.wisc.edu} // namespace DSENT 21910447Snilay@cs.wisc.edu 220