ElectricalTimingNode.cc revision 10448:bc1a3b7ab5ef
12817Sksewell@umich.edu/* Copyright (c) 2012 Massachusetts Institute of Technology
22817Sksewell@umich.edu *
32817Sksewell@umich.edu * Permission is hereby granted, free of charge, to any person obtaining a copy
42817Sksewell@umich.edu * of this software and associated documentation files (the "Software"), to deal
52817Sksewell@umich.edu * in the Software without restriction, including without limitation the rights
62817Sksewell@umich.edu * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
72817Sksewell@umich.edu * copies of the Software, and to permit persons to whom the Software is
82817Sksewell@umich.edu * furnished to do so, subject to the following conditions:
92817Sksewell@umich.edu *
102817Sksewell@umich.edu * The above copyright notice and this permission notice shall be included in
112817Sksewell@umich.edu * all copies or substantial portions of the Software.
122817Sksewell@umich.edu *
132817Sksewell@umich.edu * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
142817Sksewell@umich.edu * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152817Sksewell@umich.edu * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
162817Sksewell@umich.edu * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
172817Sksewell@umich.edu * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
182817Sksewell@umich.edu * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
192817Sksewell@umich.edu * THE SOFTWARE.
202817Sksewell@umich.edu */
212817Sksewell@umich.edu
222817Sksewell@umich.edu
232817Sksewell@umich.edu#include "model/timing_graph/ElectricalTimingNode.h"
242817Sksewell@umich.edu#include "model/timing_graph/ElectricalLoad.h"
252817Sksewell@umich.edu
262817Sksewell@umich.edunamespace DSENT
272817Sksewell@umich.edu{
282817Sksewell@umich.edu    // Set the optical node initial visited num
294202Sbinkertn@umich.edu    const int ElectricalTimingNode::TIMING_NODE_INIT_VISITED_NUM = 0;
302817Sksewell@umich.edu
312817Sksewell@umich.edu    ElectricalTimingNode::ElectricalTimingNode(const String& instance_name_, ElectricalModel* model_)
322817Sksewell@umich.edu        : m_instance_name_(instance_name_), m_model_(model_), m_false_path_(false), m_crit_path_(-1),
334202Sbinkertn@umich.edu        m_visited_num_(ElectricalTimingNode::TIMING_NODE_INIT_VISITED_NUM), m_delay_left_(0.0)
342817Sksewell@umich.edu    {
355192Ssaidi@eecs.umich.edu        m_upstream_nodes_ = new vector<ElectricalTimingNode*>();
368335Snate@binkert.org        m_downstream_nodes_ = new vector<ElectricalTimingNode*>();
378335Snate@binkert.org    }
388335Snate@binkert.org
395192Ssaidi@eecs.umich.edu    ElectricalTimingNode::~ElectricalTimingNode()
404202Sbinkertn@umich.edu    {
414486Sbinkertn@umich.edu        delete m_upstream_nodes_;
424486Sbinkertn@umich.edu        delete m_downstream_nodes_;
434486Sbinkertn@umich.edu    }
444486Sbinkertn@umich.edu
454202Sbinkertn@umich.edu    double ElectricalTimingNode::getMaxUpstreamRes() const
464202Sbinkertn@umich.edu    {
474202Sbinkertn@umich.edu        double max_res = 0.0;
489341SAndreas.Sandberg@arm.com
494202Sbinkertn@umich.edu        for(unsigned int i = 0; i < m_upstream_nodes_->size(); ++i)
505597Sgblack@eecs.umich.edu        {
514202Sbinkertn@umich.edu            double res = m_upstream_nodes_->at(i)->getMaxUpstreamRes();
524202Sbinkertn@umich.edu            if(max_res < res)
534202Sbinkertn@umich.edu            {
544202Sbinkertn@umich.edu                max_res = res;
554202Sbinkertn@umich.edu            }
564202Sbinkertn@umich.edu        }
574202Sbinkertn@umich.edu        return max_res;
584202Sbinkertn@umich.edu    }
599919Ssteve.reinhardt@amd.com
604202Sbinkertn@umich.edu    double ElectricalTimingNode::getTotalDownstreamCap() const
614202Sbinkertn@umich.edu    {
624202Sbinkertn@umich.edu        double cap_sum = 0;
634202Sbinkertn@umich.edu
644202Sbinkertn@umich.edu        for(unsigned int i = 0; i < m_downstream_nodes_->size(); ++i)
655597Sgblack@eecs.umich.edu        {
662817Sksewell@umich.edu            cap_sum += m_downstream_nodes_->at(i)->getTotalDownstreamCap();
678335Snate@binkert.org        }
688335Snate@binkert.org
698335Snate@binkert.org        return cap_sum;
708335Snate@binkert.org    }
718335Snate@binkert.org
728335Snate@binkert.org    vector<ElectricalTimingNode*>* ElectricalTimingNode::getUpstreamNodes() const
738335Snate@binkert.org    {
748335Snate@binkert.org        return m_upstream_nodes_;
758335Snate@binkert.org    }
765192Ssaidi@eecs.umich.edu
775192Ssaidi@eecs.umich.edu    vector<ElectricalTimingNode*>* ElectricalTimingNode::getDownstreamNodes() const
785192Ssaidi@eecs.umich.edu    {
795192Ssaidi@eecs.umich.edu        return m_downstream_nodes_;
805192Ssaidi@eecs.umich.edu    }
818887Sgeoffrey.blake@arm.com
829340SAndreas.Sandberg@arm.com    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