Ophidian
 All Classes Namespaces Functions
library_timing_arcs.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_TIMING_ARCS_H_
22 #define SRC_TIMING_LIBRARY_TIMING_ARCS_H_
23 
24 #include "../entity_system/entity_system.h"
25 #include "../standard_cell/standard_cells.h"
26 #include "lookup_table.h"
27 #include <unordered_map>
28 
29 namespace ophidian {
30 namespace timing {
31 
32 
33 // Only for pairs of std::hash-able types for simplicity.
34 // You can of course template this struct to allow other hash functions
35 //struct pair_hash {
36 // template <class T1, class T2>
37 // std::size_t operator () (const std::pair<T1,T2> &p) const {
38 // auto h1 = std::hash<T1>{}(p.first);
39 // auto h2 = std::hash<T2>{}(p.second);
40 
41 // // Mainly for demonstration purposes, i.e. works but is overly simple
42 // // In the real world, use sth. like boost.hash_combine
43 // return h1 ^ h2;
44 // }
45 //};
46 
48  std::size_t operator () (const std::pair<entity_system::entity,entity_system::entity> &p) const {
49  return std::hash<uint32_t>{}(p.first) ^ std::hash<uint32_t>{}(p.second);
50  }
51 };
52 
54 public:
55 private:
56  standard_cell::standard_cells & m_std_cells;
57 
61 
62  // // std_cell properties
64 
65 
66  std::unordered_map< std::pair< entity_system::entity, entity_system::entity >, entity_system::entity,pair_entity_hash > m_pinpair2arc;
67 public:
69  virtual ~library_timing_arcs();
70  entity_system::entity create(entity_system::entity from, entity_system::entity to);
71  entity_system::entity get(entity_system::entity from, entity_system::entity to) const;
72 
73  entity_system::entity from(entity_system::entity arc) const {
74  return m_from[m_system.lookup(arc)];
75  }
76  entity_system::entity to(entity_system::entity arc) const {
77  return m_to[m_system.lookup(arc)];
78  }
79 
80  std::size_t size() const {
81  return m_system.size();
82  }
83 
84  const entity_system::entity_system & system() const {
85  return m_system;
86  }
87 
88  const std::vector<entity_system::entity> & pin_timing_arcs(entity_system::entity pin) const {
89  return m_pin_timing_arcs[m_std_cells.pin_system().lookup(pin)];
90  }
91 
92  void register_property(entity_system::property* property);
93 
94 };
95 
96 } /* namespace timing */
97 } /* namespace ophidian */
98 
99 #endif /* SRC_TIMING_LIBRARY_TIMING_ARCS_H_ */
const entity_system::entity_system & pin_system() const
Pin system getter.
Definition: standard_cells.h:179
Definition: library_timing_arcs.h:53
Definition: library_timing_arcs.h:47
Property class.
Definition: property.h:33
entity_system class.
Definition: entity_system.h:40
std::size_t size() const
Returns the size of the system.
Definition: entity_system.h:82
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