HAL
physical_graph_layouter.cpp
Go to the documentation of this file.
2 
3 #include "gui/gui_globals.h"
4 
5 #include <limits>
6 #include <set>
7 
8 namespace hal
9 {
11  : GraphLayouter(context), mMinXDistance(std::numeric_limits<i32>::max()), mMinYDistance(std::numeric_limits<i32>::max())
12  {
13  }
14 
16  {
17  return "Physical Layouter";
18  }
19 
21  {
22  return "<p>PLACEHOLDER</p>";
23  }
24 
25  void PhysicalGraphLayouter::add(const QSet<u32> modules, const QSet<u32> gates, const QSet<u32> nets, PlacementHint placement)
26  {
27  Q_UNUSED(modules)
28  Q_UNUSED(gates)
29  Q_UNUSED(nets)
30  // TODO is it OK to ignore the placement hint in this layouter?
31  Q_UNUSED(placement)
32 
33  // DOES THE CORE GUARANTEE UNIQUE LOCATION DATA ???
34  // COLLAPSE / ALIGN
35 
36  std::set<i32> x_coordinates;
37  std::set<i32> y_coordinates;
38 
39  for (u32 id : gates)
40  {
41  Gate* g = gNetlist->get_gate_by_id(id);
42  assert(g);
43 
44  if (g->has_location())
45  {
46  x_coordinates.insert(g->get_location_x());
47  y_coordinates.insert(g->get_location_y());
48  }
49  }
50 
51  for (i32 x1 : x_coordinates)
52  for (i32 x2 : x_coordinates)
53  if (x1 != x2)
54  {
55  i32 x_distance = std::abs(x1 - x2);
56 
57  if (x_distance < mMinXDistance)
58  mMinXDistance = x_distance;
59  }
60 
61  for (i32 y1 : y_coordinates)
62  for (i32 y2 : y_coordinates)
63  if (y1 != y2)
64  {
65  i32 y_distance = std::abs(y1 - y2);
66 
67  if (y_distance < mMinYDistance)
68  mMinYDistance = y_distance;
69  }
70  }
71 
72  void PhysicalGraphLayouter::remove(const QSet<u32> modules, const QSet<u32> gates, const QSet<u32> nets)
73  {
74  Q_UNUSED(modules)
75  Q_UNUSED(gates)
76  Q_UNUSED(nets)
77 
78  for (u32 id : modules)
80 
81  for (u32 id : gates)
83  }
84 } // namespace hal
Definition: gate.h:58
Logical container for modules, gates, and nets.
Definition: graph_context.h:55
Base class for all specific layouters.
void removeNodeFromMaps(const Node &n)
Gate * get_gate_by_id(const u32 gate_id) const
Definition: netlist.cpp:193
The Node class object represents a module or a gate.
Definition: gui_def.h:61
@ Module
Definition: gui_def.h:63
@ Gate
Definition: gui_def.h:63
virtual void remove(const QSet< u32 > modules, const QSet< u32 > gates, const QSet< u32 > nets) override
virtual void add(const QSet< u32 > modules, const QSet< u32 > gates, const QSet< u32 > nets, PlacementHint placement) override
QString mDescription() const override
PhysicalGraphLayouter(GraphContext *context)
The PlacementHint class object provides hints for the layouter how new box objects are placed on a vi...
Definition: gui_def.h:196
int32_t i32
Definition: defines.h:36
Netlist * gNetlist
Definition: plugin_gui.cpp:80
quint32 u32