ElectricalTimingNode.cc (10447:a465576671d4) ElectricalTimingNode.cc (10448:bc1a3b7ab5ef)
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 */
1
21
22
2#include "model/timing_graph/ElectricalTimingNode.h"
3#include "model/timing_graph/ElectricalLoad.h"
4
5namespace DSENT
6{
7 // Set the optical node initial visited num
8 const int ElectricalTimingNode::TIMING_NODE_INIT_VISITED_NUM = 0;
9
10 ElectricalTimingNode::ElectricalTimingNode(const String& instance_name_, ElectricalModel* model_)
11 : m_instance_name_(instance_name_), m_model_(model_), m_false_path_(false), m_crit_path_(-1),
12 m_visited_num_(ElectricalTimingNode::TIMING_NODE_INIT_VISITED_NUM), m_delay_left_(0.0)
13 {
14 m_upstream_nodes_ = new vector<ElectricalTimingNode*>();
15 m_downstream_nodes_ = new vector<ElectricalTimingNode*>();
16 }
17
18 ElectricalTimingNode::~ElectricalTimingNode()
19 {
20 delete m_upstream_nodes_;
21 delete m_downstream_nodes_;
22 }
23
24 double ElectricalTimingNode::getMaxUpstreamRes() const
25 {
26 double max_res = 0.0;
27
28 for(unsigned int i = 0; i < m_upstream_nodes_->size(); ++i)
29 {
30 double res = m_upstream_nodes_->at(i)->getMaxUpstreamRes();
31 if(max_res < res)
32 {
33 max_res = res;
34 }
35 }
36 return max_res;
37 }
38
39 double ElectricalTimingNode::getTotalDownstreamCap() const
40 {
41 double cap_sum = 0;
42
43 for(unsigned int i = 0; i < m_downstream_nodes_->size(); ++i)
44 {
45 cap_sum += m_downstream_nodes_->at(i)->getTotalDownstreamCap();
46 }
47
48 return cap_sum;
49 }
50
51 vector<ElectricalTimingNode*>* ElectricalTimingNode::getUpstreamNodes() const
52 {
53 return m_upstream_nodes_;
54 }
55
56 vector<ElectricalTimingNode*>* ElectricalTimingNode::getDownstreamNodes() const
57 {
58 return m_downstream_nodes_;
59 }
60
61 const String& ElectricalTimingNode::getInstanceName() const
62 {
63 return m_instance_name_;
64 }
65
66 ElectricalModel* ElectricalTimingNode::getModel()
67 {
68 return m_model_;
69 }
70
71 bool ElectricalTimingNode::isDriver() const
72 {
73 return false;
74 }
75
76 bool ElectricalTimingNode::isNet() const
77 {
78 return false;
79 }
80
81 bool ElectricalTimingNode::isLoad() const
82 {
83 return false;
84 }
85
86
87 const ElectricalModel* ElectricalTimingNode::getModel() const
88 {
89 return (const ElectricalModel*) m_model_;
90 }
91
92 void ElectricalTimingNode::addDownstreamNode(ElectricalTimingNode* node_)
93 {
94 m_downstream_nodes_->push_back(node_);
95 node_->m_upstream_nodes_->push_back(this);
96 return;
97 }
98
99 void ElectricalTimingNode::setFalsePath(bool false_path_)
100 {
101 m_false_path_ = false_path_;
102 return;
103 }
104
105 bool ElectricalTimingNode::getFalsePath() const
106 {
107 return m_false_path_;
108 }
109
110
111 //-------------------------------------------------------------------------
112 // Functions for delay optimization
113 //-------------------------------------------------------------------------
114 // By default, electrical timing nodes cannot be sized up/down
115 bool ElectricalTimingNode::hasMaxDrivingStrength() const
116 {
117 return true;
118 }
119
120 bool ElectricalTimingNode::hasMinDrivingStrength() const
121 {
122 return true;
123 }
124
125 void ElectricalTimingNode::increaseDrivingStrength()
126 {
127 return;
128 }
129
130 void ElectricalTimingNode::decreaseDrivingStrength()
131 {
132 return;
133 }
134 //-------------------------------------------------------------------------
135
136 //-------------------------------------------------------------------------
137 // Node variables for critical path delay calculations
138 //-------------------------------------------------------------------------
139 void ElectricalTimingNode::setCritPath(int crit_path_)
140 {
141 m_crit_path_ = crit_path_;
142 return;
143 }
144
145 int ElectricalTimingNode::getCritPath() const
146 {
147 return m_crit_path_;
148 }
149
150 void ElectricalTimingNode::setVisitedNum(int visited_num_)
151 {
152 m_visited_num_ = visited_num_;
153 return;
154 }
155
156 int ElectricalTimingNode::getVisitedNum() const
157 {
158 return m_visited_num_;
159 }
160
161 void ElectricalTimingNode::setDelayLeft(double delay_left_)
162 {
163 m_delay_left_ = delay_left_;
164 }
165
166 double ElectricalTimingNode::getDelayLeft() const
167 {
168 return m_delay_left_;
169 }
170 //-------------------------------------------------------------------------
171
172} // namespace DSENT
173
174
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