Ophidian
All Classes Namespaces Functions
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 SRC_PLACEMENT_PLACEMENT_H_
22 #define SRC_PLACEMENT_PLACEMENT_H_
23 
24 #include "../netlist/netlist.h"
25 #include "library.h"
26 #include "cells.h"
27 
28 namespace ophidian {
30 namespace placement {
32 
35 class placement {
36  netlist::netlist * m_netlist;
37  library * m_library;
38  cells m_cells;
39 public:
41 
47  virtual ~placement();
49 
54  geometry::multi_polygon<geometry::polygon<geometry::point<double> > > cell_geometry(
55  entity_system::entity cell) const {
56  auto position = cell_position(cell);
57  auto lib_geometry = m_library->geometry(m_netlist->cell_std_cell(cell));
58  geometry::multi_polygon<geometry::polygon<geometry::point<double> > > translated;
59  geometry::translate(lib_geometry, position, translated);
60  return translated;
61  }
63 
68  void cell_position(entity_system::entity cell,
69  geometry::point<double> position);
71 
76  geometry::point<double> cell_position(entity_system::entity cell) const {
77  return m_cells.position(cell);
78  }
79  void cell_fixed(entity_system::entity cell, bool fixed);
80  bool cell_fixed(entity_system::entity cell) const {
81  return m_cells.fixed(cell);
82  }
83  geometry::point<double> cell_dimensions(entity_system::entity cell) const {
84  auto geometry = cell_geometry(cell);
85  geometry::box<geometry::point<double>> cell_box;
86  boost::geometry::envelope(geometry, cell_box);
87  geometry::point<double> dimensions(cell_box.max_corner().x() - cell_box.min_corner().x(), cell_box.max_corner().y() - cell_box.min_corner().y());
88  return dimensions;
89  }
90 
91  entity_system::entity cell_create(std::string name, std::string type);
92 
93  const cells & cell_properties() { return m_cells; };
94 
96 
101  geometry::point<double> pin_position(entity_system::entity pin) const {
102  entity_system::entity owner = m_netlist->pin_owner(pin);
103  entity_system::entity std_cell_pin = m_netlist->pin_std_cell(pin);
104 
105  geometry::point<double> position = m_library->pin_offset(std_cell_pin);
106  if(!(owner == entity_system::invalid_entity))
107  {
108  auto owner_position = m_cells.position(owner);
109  position.x( position.x() + owner_position.x() );
110  position.y( position.y() + owner_position.y() );
111  }
112  return position;
113  }
114 
116 
121  void pad_position(entity_system::entity pad, geometry::point<double> position);
122 
123 
125 
129  const netlist::netlist& netlist() const
130  {
131  return *m_netlist;
132  }
133 
135 
139  const library& lib() const {
140  return *m_library;
141  }
142 };
143 
144 } /* namespace placement */
145 } /* namespace ophidian */
146 
147 #endif /* SRC_PLACEMENT_PLACEMENT_H_ */
geometry::point< double > cell_position(entity_system::entity cell) const
Cell position getter.
Definition: placement.h:76
const netlist::netlist & netlist() const
Netlist getter.
Definition: placement.h:129
Definition: cells.h:33
geometry::multi_polygon< geometry::polygon< geometry::point< double > > > cell_geometry(entity_system::entity cell) const
Cell geometry getter.
Definition: placement.h:54
multipolygon geometry(entity_system::entity cell) const
Cell geometry getter.
Definition: library.h:69
entity_system::entity pin_owner(entity_system::entity pin) const
Pin owner getter.
Definition: netlist.h:249
entity_system::entity cell_std_cell(entity_system::entity cell) const
Cell type getter.
Definition: netlist.h:171
geometry::point< double > pin_position(entity_system::entity pin) const
Pin position getter.
Definition: placement.h:101
void pin_offset(entity_system::entity pin, point offset)
Pin offset setter.
Definition: library.cpp:47
void pad_position(entity_system::entity pad, geometry::point< double > position)
Places a pad.
Definition: placement.cpp:42
Netlist class.
Definition: netlist.h:41
Placement class.
Definition: placement.h:35
const library & lib() const
Placement library getter.
Definition: placement.h:139
placement(netlist::netlist *netlist, library *lib)
Constructor.
Definition: placement.cpp:26
entity_system::entity pin_std_cell(entity_system::entity pin) const
Pin type getter.
Definition: netlist.h:267
Placement library class.
Definition: library.h:42
void cell_position(entity_system::entity cell, geometry::point< double > position)
Places a cell.
Definition: placement.cpp:33