HAL  v4.5.0-124-g47ab54673
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
bit_order.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 
31 #pragma once
32 
33 #include "hal_core/defines.h"
35 
36 #include <optional>
37 #include <vector>
38 
39 namespace hal
40 {
41  class Net;
42  class Module;
43  class ModulePin;
44 
45  namespace bitorder_propagation
46  {
52  using WordIndex = u32;
53 
61  class BitOrder
62  {
63  public:
74  BitOrder(Module* module, PinGroup<ModulePin>* pin_group, std::vector<std::pair<Net*, u32>> order);
75 
81  Module* get_module() const;
82 
89 
95  const std::vector<std::pair<Net*, u32>>& get_order() const;
96 
103  std::optional<u32> get_index(const Net* net) const;
104 
111  Net* get_net_at(u32 index) const;
112 
118  u32 get_size() const;
119 
125  bool is_continuous() const;
126 
127  bool operator==(const BitOrder& other) const;
128  bool operator!=(const BitOrder& other) const;
129 
130  private:
131  Module* m_module;
132  PinGroup<ModulePin>* m_pin_group;
133  std::vector<std::pair<Net*, u32>> m_order;
134  };
135 
144  {
145  public:
146  BitOrderResult() = default;
147 
153  explicit BitOrderResult(std::vector<BitOrder> bit_orders);
154 
160  void add(BitOrder bit_order);
161 
167  const std::vector<BitOrder>& get_bit_orders() const;
168 
176  const BitOrder* get(const Module* module, const PinGroup<ModulePin>* pin_group) const;
177 
185  bool contains(const Module* module, const PinGroup<ModulePin>* pin_group) const;
186 
192  u32 get_size() const;
193 
199  bool is_empty() const;
200 
201  std::vector<BitOrder>::const_iterator begin() const;
202  std::vector<BitOrder>::const_iterator end() const;
203 
204  private:
205  std::vector<BitOrder> m_bit_orders;
206  };
207  } // namespace bitorder_propagation
208 } // namespace hal
Definition: net.h:58
bool operator==(const BitOrder &other) const
Definition: bit_order.cpp:63
bool operator!=(const BitOrder &other) const
Definition: bit_order.cpp:68
Net * get_net_at(u32 index) const
Definition: bit_order.cpp:39
std::optional< u32 > get_index(const Net *net) const
Definition: bit_order.cpp:33
const std::vector< std::pair< Net *, u32 > > & get_order() const
Definition: bit_order.cpp:28
PinGroup< ModulePin > * get_pin_group() const
Definition: bit_order.cpp:23
BitOrder(Module *module, PinGroup< ModulePin > *pin_group, std::vector< std::pair< Net *, u32 >> order)
Definition: bit_order.cpp:12
bool contains(const Module *module, const PinGroup< ModulePin > *pin_group) const
Definition: bit_order.cpp:129
const BitOrder * get(const Module *module, const PinGroup< ModulePin > *pin_group) const
Definition: bit_order.cpp:116
std::vector< BitOrder >::const_iterator begin() const
Definition: bit_order.cpp:144
std::vector< BitOrder >::const_iterator end() const
Definition: bit_order.cpp:149
const std::vector< BitOrder > & get_bit_orders() const
Definition: bit_order.cpp:111
uint32_t u32
Definition: defines.h:41
const Module * module(const Gate *g, const NodeBoxes &boxes)
Definition: defines.h:45
Net * net