HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
base_pin.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include "hal_core/defines.h"
33 
34 #include <string>
35 
36 namespace hal
37 {
46  template<class T>
47  class BasePin
48  {
49  public:
50  virtual ~BasePin() = default;
51 
58  bool operator==(const BasePin& other) const
59  {
60  return m_id == other.get_id() && m_name == other.get_name() && m_direction == other.get_direction() && m_type == other.get_type()
61  && m_group.first->get_name() == other.get_group().first->get_name() && m_group.second == other.get_group().second;
62  }
63 
70  bool operator!=(const BasePin& other) const
71  {
72  return !operator==(other);
73  }
74 
80  ssize_t get_hash() const
81  {
82  return (uintptr_t)this;
83  }
84 
90  u32 get_id() const
91  {
92  return m_id;
93  }
94 
100  void set_name(const std::string& name)
101  {
102  m_name = name;
103  }
104 
110  const std::string& get_name() const
111  {
112  return m_name;
113  }
114 
121  {
123  }
124 
131  {
132  return m_direction;
133  }
134 
141  {
142  m_type = type;
143  }
144 
151  {
152  return m_type;
153  }
154 
160  const std::pair<PinGroup<T>*, i32>& get_group() const
161  {
162  return m_group;
163  }
164 
165  private:
166  friend PinGroup<T>;
167 
168  BasePin(const BasePin&) = delete;
169  BasePin(BasePin&&) = delete;
170  BasePin& operator=(const BasePin&) = delete;
171  BasePin& operator=(BasePin&&) = delete;
172 
173  protected:
175  std::string m_name;
178  std::pair<PinGroup<T>*, i32> m_group = {nullptr, 0};
179 
189  {
190  }
191  };
192 } // namespace hal
void set_name(const std::string &name)
Definition: base_pin.h:100
BasePin(const u32 id, const std::string &name, PinDirection direction, PinType type=PinType::none)
Definition: base_pin.h:188
const std::string & get_name() const
Definition: base_pin.h:110
virtual ~BasePin()=default
void set_type(PinType type)
Definition: base_pin.h:140
u32 get_id() const
Definition: base_pin.h:90
bool operator==(const BasePin &other) const
Definition: base_pin.h:58
PinType get_type() const
Definition: base_pin.h:150
PinType m_type
Definition: base_pin.h:177
void set_direction(PinDirection direction)
Definition: base_pin.h:120
ssize_t get_hash() const
Definition: base_pin.h:80
const std::pair< PinGroup< T > *, i32 > & get_group() const
Definition: base_pin.h:160
PinDirection get_direction() const
Definition: base_pin.h:130
std::pair< PinGroup< T > *, i32 > m_group
Definition: base_pin.h:178
std::string m_name
Definition: base_pin.h:175
PinDirection m_direction
Definition: base_pin.h:176
bool operator!=(const BasePin &other) const
Definition: base_pin.h:70
uint32_t u32
Definition: defines.h:41
int32_t i32
Definition: defines.h:36
Definition: defines.h:45
PinDirection
Definition: pin_direction.h:36
PinType
Definition: pin_type.h:36
PinType type
PinDirection direction
std::string name
i32 id