Ophidian
 All Classes Namespaces Functions
rc_tree.h
1 /*
2  * Copyright 2016 Ophidian
3 Licensed to the Apache Software Foundation (ASF) under one
4 or more contributor license agreements. See the NOTICE file
5 distributed with this work for additional information
6 regarding copyright ownership. The ASF licenses this file
7 to you under the Apache License, Version 2.0 (the
8 "License"); you may not use this file except in compliance
9 with the License. You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0
12 
13 Unless required by applicable law or agreed to in writing,
14 software distributed under the License is distributed on an
15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations
18 under the License.
19  */
20 
21 #ifndef SRC_TIMING_RC_TREE_H_
22 #define SRC_TIMING_RC_TREE_H_
23 
24 #include <boost/units/systems/si.hpp>
25 #include <boost/units/io.hpp>
26 
27 #include <lemon/list_graph.h>
28 #include <lemon/maps.h>
29 
30 #include <unordered_map>
31 
32 namespace ophidian {
34 namespace interconnection {
35 
36 using namespace boost::units;
37 
40  std::vector< std::size_t > m_pred;
41  std::vector< quantity<si::resistance> > m_resistances;
42  std::vector< quantity<si::capacitance> > m_capacitances;
43  std::unordered_map<std::string, std::size_t> m_taps;
44 
45 public:
46  packed_rc_tree(std::size_t node_count=0);
47  virtual ~packed_rc_tree();
48  void pred(std::size_t i, std::size_t pred);
49  void capacitance(std::size_t i, quantity<si::capacitance> cap);
50  void resistance(std::size_t i, quantity<si::resistance> res);
51  std::size_t node_count() const {
52  return m_pred.size();
53  }
54  std::size_t pred(std::size_t i) const {
55  return m_pred[i];
56  }
57  quantity<si::resistance> resistance(std::size_t i) const {
58  return m_resistances[i];
59  }
60  quantity<si::capacitance> capacitance(std::size_t i) const {
61  return m_capacitances[i];
62  }
63 
64  std::size_t tap(const std::string & name) const {
65  return m_taps.at(name);
66  }
67 
68 
69  void tap(const std::string & name, std::size_t value);
70 
71 
72 };
73 
75 
78 class rc_tree {
79 public:
80  using graph_t =lemon::ListGraph;
81 private:
82  graph_t m_graph;
83  graph_t::NodeMap<std::string> m_names;
84  graph_t::NodeMap<quantity<si::capacitance> > m_capacitances;
85  graph_t::EdgeMap<quantity<si::resistance> > m_resistances;
86  quantity<si::capacitance> m_lumped_capacitance;
87  std::vector< graph_t::Node > m_taps;
88 
89  std::unordered_map<std::string, lemon::ListGraph::Node> m_name2node;
90 public:
91  using capacitor_id = lemon::ListGraph::Node;
92  using resistor_id = lemon::ListGraph::Edge;
93  using resistor_it = lemon::ListGraph::IncEdgeIt;
94 
98  rc_tree();
102  rc_tree(const rc_tree& other);
108  rc_tree& operator=(const rc_tree& other);
110  virtual ~rc_tree();
116  quantity<si::capacitance> lumped() const {
117  return m_lumped_capacitance;
118  }
120  void tap_insert(capacitor_id cap);
121 
123 
128  capacitor_id capacitor_insert(std::string name);
129 
131 
136  std::string capacitor_name(capacitor_id u) const {
137  return m_names[u];
138  }
139 
141 
145  std::size_t capacitor_count() const {
146  return static_cast<std::size_t>(lemon::countNodes(m_graph));
147  }
148 
149  resistor_id resistor_insert(capacitor_id u, capacitor_id v,
150  quantity<si::resistance> res);
151 
152  void capacitance(capacitor_id u, quantity<si::capacitance> cap);
153 
154  capacitor_id capacitor_by_name(std::string name) const {
155  return m_name2node.at(name);
156  }
157  quantity<si::capacitance> capacitance(capacitor_id u) const {
158  return m_capacitances[u];
159  }
160 
161  quantity<si::resistance> resistance(resistor_id uv) const {
162  return m_resistances[uv];
163  }
164 
165  resistor_it capacitor_resistors(capacitor_id u) const {
166  return resistor_it(m_graph, u);
167  }
168 
169  capacitor_id other_capacitor(resistor_id res, capacitor_id cap) const {
170  return m_graph.oppositeNode(cap, res);
171  }
172 
173 
174  static resistor_it invalid() {
175  return lemon::INVALID;
176  }
177 
178  const graph_t & graph() const {
179  return m_graph;
180  }
181 
182  packed_rc_tree pack(capacitor_id source) const;
183 
184 };
185 
186 
187 
188 } /* namespace timing */
189 } /* namespace ophidian */
190 
191 #endif /* SRC_TIMING_RC_TREE_H_ */
std::size_t capacitor_count() const
Number of Capacitors.
Definition: rc_tree.h:145
Packed RC Tree Class.
Definition: rc_tree.h:39
quantity< si::capacitance > lumped() const
Returns the sum of the capacitance of all capacitors in the RC Tree.
Definition: rc_tree.h:116
RC Tree Class.
Definition: rc_tree.h:78
std::string capacitor_name(capacitor_id u) const
Return capacitor's name.
Definition: rc_tree.h:136