Ophidian
 All Classes Namespaces Functions
timingdriven_placement.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 OPHIDIAN_TIMING_DRIVEN_PLACEMENT_TIMING_DRIVEN_PLACEMENT_H
22 #define OPHIDIAN_TIMING_DRIVEN_PLACEMENT_TIMING_DRIVEN_PLACEMENT_H
23 
24 
25 
26 #include "../timing/generic_sta.h"
27 #include "../timing/ceff.h"
28 #include "../placement/placement.h"
29 #include "floorplan.h"
30 #include "../timing/endpoints.h"
31 #include "flute_rc_tree_estimation.h"
32 
33 #include "../timing/static_timing_analysis.h"
34 
35 namespace ophidian {
36 namespace timingdriven_placement {
37 
38 template <class IteratorType>
39 struct bounds {
40  const IteratorType m_begin;
41  const IteratorType m_end;
42 
43  const IteratorType begin() const {
44  return m_begin;
45  }
46 
47  const IteratorType end() const {
48  return m_end;
49  }
50 };
51 
52 
53 using Cell = entity_system::entity;
54 using Pin = entity_system::entity;
55 using StandardCellPin = entity_system::entity;
56 using StandardCell = entity_system::entity;
57 using Net = entity_system::entity;
58 using Point = geometry::point<double>;
59 using Geometry = geometry::multi_polygon< geometry::polygon<Point> >;
60 using CapacitanceType = boost::units::quantity< boost::units::si::capacitance > ;
61 using NetIterator = entity_system::entities_storage::const_iterator;
62 using CellIterator = entity_system::entities_storage::const_iterator;
63 using PinIterator = entity_system::entities_storage::const_iterator;
64 
65 
67  std::vector<Cell> cells;
68  std::vector<Geometry> geometries;
69  cells_geometries(std::size_t size) : cells(size), geometries(size) {cells.resize(0); geometries.resize(0);}
70 };
71 
72 
73 
75 {
76 
77 
79  netlist::netlist m_netlist{&m_std_cells};
80  floorplan::floorplan m_floorplan;
81  placement::library m_placement_lib{&m_std_cells};
82  placement::placement m_placement{&m_netlist, &m_placement_lib};
85  flute_rc_tree_creator m_flute;
86  std::set<Net> m_dirty_nets;
87 
88  // timing info is initialized in a lazy fashion >>
89  const std::string m_dot_lib_late;
90  const std::string m_dot_lib_early;
91  timing::graph m_timing_graph;
92  std::unique_ptr<timing::library_timing_arcs> m_tarcs;
93  std::unique_ptr<timing::library> m_lib_late;
94  std::unique_ptr<timing::library> m_lib_early;
95  std::unique_ptr<timing::static_timing_analysis> m_sta;
96  // <<
97 
98  void make_cell_nets_dirty(Cell cell);
99  void update_dirty_rc_trees();
100 public:
101  timingdriven_placement(const std::string & dot_verilog_file, const std::string & dot_def_file, const std::string & dot_lef_file, const std::string m_dot_lib_late, const std::string m_dot_lib_early, double clock_in_ps);
102  virtual ~timingdriven_placement();
103 
104 
105 
106  // NETLIST
107  // cell
109 
111  Cell cell_find(std::string name) const {
112  return m_netlist.cell_find(name);
113  }
114 
116 
118  std::string cell_name(Cell c) const {
119  return m_netlist.cell_name(c);
120  }
121 
122  std::size_t cell_lookup(Cell c) const {
123  return m_netlist.cell_system().lookup(c);
124  }
125 
126  const std::vector<Pin> & cell_pins(Cell c) const {
127  return m_netlist.cell_pins(c);
128  }
129 
131 
135  return {m_netlist.cell_system().begin(), m_netlist.cell_system().end()};
136  }
137 
138  // net
140 
144  Net net_find(std::string name) const {
145  return m_netlist.net_by_name(name);
146  }
147 
149 
151  std::string net_name(Net n) const {
152  return m_netlist.net_name(n);
153  }
154 
156 
158  const std::vector<Pin> & net_pins(Net net) const {
159  return m_netlist.net_pins(net);
160  }
161 
162  entity_system::entity_index net_lookup(Net net) const {
163  return m_netlist.net_system().lookup(net);
164  }
165 
166  void net_register_property(entity_system::property & p);
167 
169 
173  return {m_netlist.net_system().begin(), m_netlist.net_system().end()};
174  }
175 
176  // pin
178 
180  std::string pin_name(Pin pin) const {
181  return m_netlist.pin_name(pin);
182  }
183 
185 
187  Net pin_net(Pin pin) const {
188  return m_netlist.pin_net(pin);
189  }
190 
191  std::size_t pin_lookup(Pin pin) const {
192  return m_netlist.pin_system().lookup(pin);
193  }
194 
195  Cell pin_owner(Pin pin) const {
196  return m_netlist.pin_owner(pin);
197  }
198 
200 
204  return {m_netlist.pin_system().begin(), m_netlist.pin_system().end()};
205  }
206 
207 
208  // PLACEMENT
210 
212  void place_cell(Cell cell, Point destination);
214 
216  Point cell_position(Cell cell) const {
217  return m_placement.cell_position(cell);
218  }
220 
224  Geometry cell_geometry(Cell cell) const {
225  return m_placement.cell_geometry(cell);
226  }
227 
228  Point pin_position(Pin pin) const {
229  return m_placement.pin_position(pin);
230  }
231 
232 
233 
234  // TIMING
236 
238  void update_timing();
239 
240  timing::TimeType late_wns() const {
241  return m_sta->late_wns();
242  }
243  timing::TimeType early_wns() const{
244  return m_sta->early_wns();
245  }
246  timing::TimeType late_tns() const {
247  return m_sta->late_tns();
248  }
249  timing::TimeType early_tns() const{
250  return m_sta->early_tns();
251  }
252  timing::TimeType early_rise_slack(Pin p) const {
253  return m_sta->early_rise_slack(p);
254  }
255  timing::TimeType early_fall_slack(Pin p) const {
256  return m_sta->early_fall_slack(p);
257  }
258  timing::TimeType late_rise_slack(Pin p) const {
259  return m_sta->late_rise_slack(p);
260  }
261  timing::TimeType late_fall_slack(Pin p) const {
262  return m_sta->late_fall_slack(p);
263  }
264  timing::TimeType early_rise_arrival(Pin p) const {
265  return m_sta->early_rise_arrival(p);
266  }
267  timing::TimeType early_fall_arrival(Pin p) const {
268  return m_sta->early_fall_arrival(p);
269  }
270  timing::TimeType late_rise_arrival(Pin p) const {
271  return m_sta->late_rise_arrival(p);
272  }
273  timing::TimeType late_fall_arrival(Pin p) const {
274  return m_sta->late_fall_arrival(p);
275  }
276  timing::TimeType early_rise_slew(Pin p) const {
277  return m_sta->early_rise_slew(p);
278  }
279  timing::TimeType early_fall_slew(Pin p) const {
280  return m_sta->early_fall_slew(p);
281  }
282  timing::TimeType late_rise_slew(Pin p) const {
283  return m_sta->late_rise_slew(p);
284  }
285  timing::TimeType late_fall_slew(Pin p) const {
286  return m_sta->late_fall_slew(p);
287  }
288  const timing::endpoints & timing_endpoints() const {
289  return m_sta->timing_endpoints();
290  }
291 };
292 
293 }
294 }
295 
296 #endif // OPHIDIAN_TIMING_DRIVEN_PLACEMENT_TIMING_DRIVEN_PLACEMENT_H
const entity_system::entity_system & net_system() const
Net system getter.
Definition: netlist.h:359
const entity_system::entity_system & pin_system() const
Pin system getter.
Definition: netlist.h:284
Definition: timingdriven_placement.h:39
bounds< NetIterator > nets() const
Gets the nets.
Definition: timingdriven_placement.h:172
geometry::multi_polygon< geometry::polygon< geometry::point< double > > > cell_geometry(entity_system::entity cell) const
Cell geometry getter.
Definition: placement.h:54
Net net_find(std::string name) const
Finds a Net by its name.
Definition: timingdriven_placement.h:144
Definition: timingdriven_placement.h:74
Net pin_net(Pin pin) const
Gets the net of a pin.
Definition: timingdriven_placement.h:187
const std::vector< entity_system::entity > & cell_pins(entity_system::entity cell) const
Cell pins getter.
Definition: netlist.h:162
Point cell_position(Cell cell) const
Gets the cell's position.
Definition: timingdriven_placement.h:216
entity_system::entity pin_owner(entity_system::entity pin) const
Pin owner getter.
Definition: netlist.h:249
Definition: timingdriven_placement.h:66
Definition: design_constraints.h:63
bounds< PinIterator > pins() const
Gets the pins.
Definition: timingdriven_placement.h:203
std::string cell_name(entity_system::entity cell) const
Cell name getter.
Definition: netlist.h:153
geometry::point< double > pin_position(entity_system::entity pin) const
Pin position getter.
Definition: placement.h:101
Definition: graph.h:44
entity_system::entity pin_net(entity_system::entity pin) const
Pin net getter.
Definition: netlist.h:258
void place_cell(Cell cell, Point destination)
Places a cell in a position.
Definition: timingdriven_placement.cpp:181
void update_timing()
Updates the timing information.
Definition: timingdriven_placement.cpp:190
Geometry cell_geometry(Cell cell) const
Gets the cell's geometry.
Definition: timingdriven_placement.h:224
entities_storage::const_iterator begin() const
Begin iterator.
Definition: entity_system.h:97
Netlist class.
Definition: netlist.h:41
Placement class.
Definition: placement.h:35
Property class.
Definition: property.h:33
entities_storage::const_iterator end() const
End iterator.
Definition: entity_system.h:104
std::string net_name(Net n) const
Gets the name of a net.
Definition: timingdriven_placement.h:151
const entity_system::entity_system & cell_system() const
Cell system getter.
Definition: netlist.h:195
std::string pin_name(entity_system::entity pin) const
Pin name getter.
Definition: netlist.h:230
Placement library class.
Definition: library.h:42
std::string net_name(entity_system::entity net) const
Net name getter.
Definition: netlist.h:332
Definition: flute_rc_tree_estimation.h:37
std::string cell_name(Cell c) const
Gets the name of a cell.
Definition: timingdriven_placement.h:118
const std::vector< Pin > & net_pins(Net net) const
Gets the pin of a net.
Definition: timingdriven_placement.h:158
entity_system::entity net_by_name(std::string name) const
Finds net.
Definition: netlist.h:368
std::string pin_name(Pin pin) const
Gets the name of a pin.
Definition: timingdriven_placement.h:180
const std::vector< entity_system::entity > & net_pins(entity_system::entity net) const
Net pins getter.
Definition: netlist.h:341
void cell_position(entity_system::entity cell, geometry::point< double > position)
Places a cell.
Definition: placement.cpp:33
bounds< CellIterator > cells() const
Gets the cells.
Definition: timingdriven_placement.h:134
entity_system::entity cell_find(std::string name) const
Finds cell.
Definition: netlist.cpp:62
Cell cell_find(std::string name) const
Finds a Cell by its name.
Definition: timingdriven_placement.h:111
Floorplan class.
Definition: floorplan.h:37
Standard cell class.
Definition: standard_cells.h:37
entity_index lookup(entity e) const
Gets the index of an entity.
Definition: entity_system.h:149