1/* Copyright (c) 2012 Massachusetts Institute of Technology 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to deal 5 * in the Software without restriction, including without limitation the rights 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 * copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 * THE SOFTWARE. 20 */ 21 22 23#include "model/timing_graph/ElectricalTimingNode.h" 24#include "model/timing_graph/ElectricalLoad.h" 25 26namespace DSENT 27{ 28 // Set the optical node initial visited num 29 const int ElectricalTimingNode::TIMING_NODE_INIT_VISITED_NUM = 0; 30 31 ElectricalTimingNode::ElectricalTimingNode(const String& instance_name_, ElectricalModel* model_) 32 : m_instance_name_(instance_name_), m_model_(model_), m_false_path_(false), m_crit_path_(-1), 33 m_visited_num_(ElectricalTimingNode::TIMING_NODE_INIT_VISITED_NUM), m_delay_left_(0.0) 34 { 35 m_upstream_nodes_ = new vector<ElectricalTimingNode*>(); 36 m_downstream_nodes_ = new vector<ElectricalTimingNode*>(); 37 } 38 39 ElectricalTimingNode::~ElectricalTimingNode() 40 { 41 delete m_upstream_nodes_; 42 delete m_downstream_nodes_; 43 } 44 45 double ElectricalTimingNode::getMaxUpstreamRes() const 46 { 47 double max_res = 0.0; 48 49 for(unsigned int i = 0; i < m_upstream_nodes_->size(); ++i) 50 { 51 double res = m_upstream_nodes_->at(i)->getMaxUpstreamRes(); 52 if(max_res < res) 53 { 54 max_res = res; 55 } 56 } 57 return max_res; 58 } 59 60 double ElectricalTimingNode::getTotalDownstreamCap() const 61 { 62 double cap_sum = 0; 63 64 for(unsigned int i = 0; i < m_downstream_nodes_->size(); ++i) 65 { 66 cap_sum += m_downstream_nodes_->at(i)->getTotalDownstreamCap(); 67 } 68 69 return cap_sum; 70 } 71 72 vector<ElectricalTimingNode*>* ElectricalTimingNode::getUpstreamNodes() const 73 { 74 return m_upstream_nodes_; 75 } 76 77 vector<ElectricalTimingNode*>* ElectricalTimingNode::getDownstreamNodes() const 78 { 79 return m_downstream_nodes_; 80 } 81 82 const String& ElectricalTimingNode::getInstanceName() const 83 { 84 return m_instance_name_; 85 } 86 87 ElectricalModel* ElectricalTimingNode::getModel() 88 { 89 return m_model_; 90 } 91 92 bool ElectricalTimingNode::isDriver() const 93 { 94 return false; 95 } 96 97 bool ElectricalTimingNode::isNet() const 98 { 99 return false; 100 } 101 102 bool ElectricalTimingNode::isLoad() const 103 { 104 return false; 105 } 106 107 108 const ElectricalModel* ElectricalTimingNode::getModel() const 109 { 110 return (const ElectricalModel*) m_model_; 111 } 112 113 void ElectricalTimingNode::addDownstreamNode(ElectricalTimingNode* node_) 114 { 115 m_downstream_nodes_->push_back(node_); 116 node_->m_upstream_nodes_->push_back(this); 117 return; 118 } 119 120 void ElectricalTimingNode::setFalsePath(bool false_path_) 121 { 122 m_false_path_ = false_path_; 123 return; 124 } 125 126 bool ElectricalTimingNode::getFalsePath() const 127 { 128 return m_false_path_; 129 } 130 131 132 //------------------------------------------------------------------------- 133 // Functions for delay optimization 134 //------------------------------------------------------------------------- 135 // By default, electrical timing nodes cannot be sized up/down 136 bool ElectricalTimingNode::hasMaxDrivingStrength() const 137 { 138 return true; 139 } 140 141 bool ElectricalTimingNode::hasMinDrivingStrength() const 142 { 143 return true; 144 } 145 146 void ElectricalTimingNode::increaseDrivingStrength() 147 { 148 return; 149 } 150 151 void ElectricalTimingNode::decreaseDrivingStrength() 152 { 153 return; 154 } 155 //------------------------------------------------------------------------- 156 157 //------------------------------------------------------------------------- 158 // Node variables for critical path delay calculations 159 //------------------------------------------------------------------------- 160 void ElectricalTimingNode::setCritPath(int crit_path_) 161 { 162 m_crit_path_ = crit_path_; 163 return; 164 } 165 166 int ElectricalTimingNode::getCritPath() const 167 { 168 return m_crit_path_; 169 } 170 171 void ElectricalTimingNode::setVisitedNum(int visited_num_) 172 { 173 m_visited_num_ = visited_num_; 174 return; 175 } 176 177 int ElectricalTimingNode::getVisitedNum() const 178 { 179 return m_visited_num_; 180 } 181 182 void ElectricalTimingNode::setDelayLeft(double delay_left_) 183 { 184 m_delay_left_ = delay_left_; 185 } 186 187 double ElectricalTimingNode::getDelayLeft() const 188 { 189 return m_delay_left_; 190 } 191 //------------------------------------------------------------------------- 192 193} // namespace DSENT 194 195 196