ElectricalDriver.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 2310447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalDriver.h" 2410447Snilay@cs.wisc.edu#include "model/timing_graph/ElectricalNet.h" 2510447Snilay@cs.wisc.edu#include "model/ElectricalModel.h" 2610447Snilay@cs.wisc.edu 2710447Snilay@cs.wisc.edunamespace DSENT 2810447Snilay@cs.wisc.edu{ 2910447Snilay@cs.wisc.edu ElectricalDriver::ElectricalDriver(const String& instance_name_, ElectricalModel* model_, bool sizable_) 3010447Snilay@cs.wisc.edu : ElectricalTimingNode(instance_name_, model_), m_output_res_(0.0), m_sizable_(sizable_) 3110447Snilay@cs.wisc.edu { 3210447Snilay@cs.wisc.edu 3310447Snilay@cs.wisc.edu } 3410447Snilay@cs.wisc.edu 3510447Snilay@cs.wisc.edu ElectricalDriver::~ElectricalDriver() 3610447Snilay@cs.wisc.edu { 3710447Snilay@cs.wisc.edu 3810447Snilay@cs.wisc.edu } 3910447Snilay@cs.wisc.edu 4010447Snilay@cs.wisc.edu void ElectricalDriver::setOutputRes(double output_res_) 4110447Snilay@cs.wisc.edu { 4210447Snilay@cs.wisc.edu m_output_res_ = output_res_; 4310447Snilay@cs.wisc.edu return; 4410447Snilay@cs.wisc.edu } 4510447Snilay@cs.wisc.edu 4610447Snilay@cs.wisc.edu double ElectricalDriver::getOutputRes() const 4710447Snilay@cs.wisc.edu { 4810447Snilay@cs.wisc.edu return m_output_res_; 4910447Snilay@cs.wisc.edu } 5010447Snilay@cs.wisc.edu 5110447Snilay@cs.wisc.edu double ElectricalDriver::calculateDelay() const 5210447Snilay@cs.wisc.edu { 5310447Snilay@cs.wisc.edu return 0.693 * m_output_res_ * getTotalDownstreamCap(); 5410447Snilay@cs.wisc.edu } 5510447Snilay@cs.wisc.edu 5610447Snilay@cs.wisc.edu double ElectricalDriver::calculateTransition() const 5710447Snilay@cs.wisc.edu { 5810447Snilay@cs.wisc.edu return 1.386 * getMaxUpstreamRes() * getTotalDownstreamCap(); 5910447Snilay@cs.wisc.edu } 6010447Snilay@cs.wisc.edu 6110447Snilay@cs.wisc.edu double ElectricalDriver::getMaxUpstreamRes() const 6210447Snilay@cs.wisc.edu { 6310447Snilay@cs.wisc.edu return m_output_res_; 6410447Snilay@cs.wisc.edu } 6510447Snilay@cs.wisc.edu 6610447Snilay@cs.wisc.edu bool ElectricalDriver::isSizable() const 6710447Snilay@cs.wisc.edu { 6810447Snilay@cs.wisc.edu return m_sizable_; 6910447Snilay@cs.wisc.edu } 7010447Snilay@cs.wisc.edu 7110447Snilay@cs.wisc.edu bool ElectricalDriver::hasMaxDrivingStrength() const 7210447Snilay@cs.wisc.edu { 7310447Snilay@cs.wisc.edu if (!isSizable()) 7410447Snilay@cs.wisc.edu { 7510447Snilay@cs.wisc.edu return true; 7610447Snilay@cs.wisc.edu } 7710447Snilay@cs.wisc.edu return (getModel() == NULL) || (getModel()->hasMaxDrivingStrength()); 7810447Snilay@cs.wisc.edu } 7910447Snilay@cs.wisc.edu 8010447Snilay@cs.wisc.edu bool ElectricalDriver::hasMinDrivingStrength() const 8110447Snilay@cs.wisc.edu { 8210447Snilay@cs.wisc.edu if (!isSizable()) 8310447Snilay@cs.wisc.edu { 8410447Snilay@cs.wisc.edu return true; 8510447Snilay@cs.wisc.edu } 8610447Snilay@cs.wisc.edu return (getModel() == NULL) || (getModel()->hasMinDrivingStrength()); 8710447Snilay@cs.wisc.edu } 8810447Snilay@cs.wisc.edu 8910447Snilay@cs.wisc.edu void ElectricalDriver::increaseDrivingStrength() 9010447Snilay@cs.wisc.edu { 9110447Snilay@cs.wisc.edu ASSERT(isSizable(), "[Error] " + getInstanceName() + 9210447Snilay@cs.wisc.edu " -> Attempted to size up unsizable driver!"); 9310447Snilay@cs.wisc.edu if(!hasMaxDrivingStrength()) 9410447Snilay@cs.wisc.edu { 9510447Snilay@cs.wisc.edu getModel()->increaseDrivingStrength(); 9610447Snilay@cs.wisc.edu } 9710447Snilay@cs.wisc.edu return; 9810447Snilay@cs.wisc.edu } 9910447Snilay@cs.wisc.edu 10010447Snilay@cs.wisc.edu void ElectricalDriver::decreaseDrivingStrength() 10110447Snilay@cs.wisc.edu { 10210447Snilay@cs.wisc.edu ASSERT(isSizable(), "[Error] " + getInstanceName() + 10310447Snilay@cs.wisc.edu " -> Attempted to size down unsizable driver!"); 10410447Snilay@cs.wisc.edu if(!hasMinDrivingStrength()) 10510447Snilay@cs.wisc.edu { 10610447Snilay@cs.wisc.edu getModel()->decreaseDrivingStrength(); 10710447Snilay@cs.wisc.edu } 10810447Snilay@cs.wisc.edu return; 10910447Snilay@cs.wisc.edu } 11010447Snilay@cs.wisc.edu 11110447Snilay@cs.wisc.edu bool ElectricalDriver::isDriver() const 11210447Snilay@cs.wisc.edu { 11310447Snilay@cs.wisc.edu return true; 11410447Snilay@cs.wisc.edu } 11510447Snilay@cs.wisc.edu} // namespace DSENT 11610447Snilay@cs.wisc.edu 117