Ophidian
 All Classes Namespaces Functions
library.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_LIBRARY_H_
22 #define SRC_TIMING_LIBRARY_H_
23 
24 #include "../standard_cell/standard_cells.h"
25 #include "../entity_system/vector_property.h"
26 
27 #include <boost/units/systems/si.hpp>
28 #include <boost/units/io.hpp>
29 
30 #include "library_timing_arcs.h"
31 #include <boost/optional.hpp>
32 
33 namespace ophidian {
34 namespace timing {
35 
36 enum class unateness {
37  NEGATIVE_UNATE, POSITIVE_UNATE, NON_UNATE
38 };
39 
40 enum class timing_arc_types {
41  COMBINATIONAL, SEQUENTIAL, RISING_EDGE
42 };
43 
44 class library {
45 public:
46  using CapacitanceType = boost::units::quantity<boost::units::si::capacitance>;
47  using SlewType = boost::units::quantity<boost::units::si::time>;
50 
51 private:
53  library_timing_arcs & m_tarcs;
54 
61 
62 
67  std::vector<TestLUT> m_tests;
68 
70 
71 public:
73  virtual ~library();
74  void pin_capacitance(entity_system::entity pin, boost::units::quantity<boost::units::si::capacitance> capacitance);
75 
76 
77  void setup_rise_create(entity_system::entity arc, const TestLUT & lut);
78  void hold_rise_create(entity_system::entity arc, const TestLUT & lut);
79 
80  const TestLUT& setup_rise(entity_system::entity arc) const {
81  assert(m_arc2setup_rise[m_tarcs.system().lookup(arc)]);
82  return m_tests[*m_arc2setup_rise[m_tarcs.system().lookup(arc)]];
83  }
84 
85  const TestLUT& hold_rise(entity_system::entity arc) const {
86  assert(m_arc2hold_rise[m_tarcs.system().lookup(arc)]);
87  return m_tests[*m_arc2hold_rise[m_tarcs.system().lookup(arc)]];
88  }
89 
90 
91  void setup_fall_create(entity_system::entity arc, const TestLUT & lut);
92  void hold_fall_create(entity_system::entity arc, const TestLUT & lut);
93 
94  const TestLUT& setup_fall(entity_system::entity arc) const {
95  assert(m_arc2setup_fall[m_tarcs.system().lookup(arc)]);
96  return m_tests[*m_arc2setup_fall[m_tarcs.system().lookup(arc)]];
97  }
98 
99  const TestLUT& hold_fall(entity_system::entity arc) const {
100  assert(m_arc2hold_fall[m_tarcs.system().lookup(arc)]);
101  return m_tests[*m_arc2hold_fall[m_tarcs.system().lookup(arc)]];
102  }
103 
104 
105  boost::units::quantity<boost::units::si::capacitance> pin_capacitance(entity_system::entity pin) const {
106  return m_pin_capacitance[m_std_cells.pin_system().lookup(pin)];
107  }
109  return m_std_cells;
110  }
111 
112  void pin_direction(entity_system::entity pin, standard_cell::pin_directions direction) {
113  return m_std_cells.pin_direction(pin, direction);
114  }
115 
116  standard_cell::pin_directions pin_direction(entity_system::entity pin) const {
117  return m_std_cells.pin_direction(pin);
118  }
119 
120  entity_system::entity timing_arc_from(entity_system::entity arc) const {
121  return m_tarcs.from(arc);
122  }
123 
124  entity_system::entity timing_arc_to(entity_system::entity arc) const {
125  return m_tarcs.to(arc);
126  }
127 
128  entity_system::entity timing_arc_create(entity_system::entity from, entity_system::entity to) {
129  return m_tarcs.create(from, to);
130  }
131 
132  const std::vector<entity_system::entity>& pin_timing_arcs(entity_system::entity pin) const {
133  return m_tarcs.pin_timing_arcs(pin);
134  }
135 
136  void timing_arc_rise_slew(entity_system::entity arc, const LUT & lut);
137  void timing_arc_fall_slew(entity_system::entity arc, const LUT & lut);
138  void timing_arc_rise_delay(entity_system::entity arc, const LUT & lut);
139  void timing_arc_fall_delay(entity_system::entity arc, const LUT & lut);
140 
141  const LUT & timing_arc_rise_slew(entity_system::entity arc) const {
142  return m_rise_slews[m_tarcs.system().lookup(arc)];
143  }
144  const LUT & timing_arc_fall_slew(entity_system::entity arc) const {
145  return m_fall_slews[m_tarcs.system().lookup(arc)];
146  }
147  const LUT & timing_arc_rise_delay(entity_system::entity arc) const {
148  return m_rise_delays[m_tarcs.system().lookup(arc)];
149  }
150  const LUT & timing_arc_fall_delay(entity_system::entity arc) const {
151  return m_fall_delays[m_tarcs.system().lookup(arc)];
152  }
153  entity_system::entity timing_arc(entity_system::entity from, entity_system::entity to) const {
154  return m_tarcs.get(from, to);
155  }
156 
157 
158  void timing_arc_timing_sense(entity_system::entity arc, unateness timing_sense);
159  unateness timing_arc_timing_sense(entity_system::entity arc) const {
160  return m_timing_senses[m_tarcs.system().lookup(arc)];
161  }
162 
163  void timing_arc_timing_type(entity_system::entity arc, timing_arc_types type);
164  timing_arc_types timing_arc_timing_type(entity_system::entity arc) const {
165  return m_timing_types[m_tarcs.system().lookup(arc)];
166  }
167 
168 
169  entity_system::entity cell_create(std::string name);
170  entity_system::entity pin_create(entity_system::entity cell, std::string name);
171 
172 
173  void cell_sequential(entity_system::entity cell, bool sequential);
174 
175  bool cell_sequential(entity_system::entity cell) const
176  {
177  return m_std_cells.cell_sequential(cell);
178  }
179  void pin_clock_input(entity_system::entity pin, bool clock_input);
180 
181  bool pin_clock_input(entity_system::entity pin) const {
182  return m_std_cells.pin_clock_input(pin);
183  }
184 };
185 
186 } /* namespace timing */
187 } /* namespace ophidian */
188 
189 #endif /* SRC_TIMING_LIBRARY_H_ */
const entity_system::entity_system & pin_system() const
Pin system getter.
Definition: standard_cells.h:179
Definition: library_timing_arcs.h:53
pin_directions pin_direction(entity_system::entity pin) const
Pin direction getter.
Definition: standard_cells.h:188
bool pin_clock_input(entity_system::entity pin) const
Pin clock input attribute getter.
Definition: standard_cells.h:197
Implementation of the vector property class.
Definition: vector_property.h:37
Definition: library.h:44
Definition: lookup_table.h:33
Standard cell class.
Definition: standard_cells.h:37
void cell_sequential(entity_system::entity cell, bool sequential)
Cell sequential attribute setter.
Definition: standard_cells.cpp:45
entity_index lookup(entity e) const
Gets the index of an entity.
Definition: entity_system.h:149