HAL  v4.5.0-232-g8053ac4b3
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
parameter.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"
31 
32 #include <map>
33 #include <string>
34 #include <vector>
35 
36 namespace hal
37 {
44  {
48  enum class Type
49  {
51  Boolean,
53  BitVector,
55  LogicVector,
57  Integer,
59  String,
61  Float,
63  Time,
65  Enum,
66  };
67 
71  explicit Parameter();
72 
78  const std::string& get_name() const;
79 
85  Type get_type() const;
86 
94  u16 get_size() const;
95 
102  const std::string& get_default_value() const;
103 
110  const std::vector<std::string>& get_enum_values() const;
111 
118  static Result<Parameter> Boolean(const std::string& name, const std::string& default_value);
119 
128  static Result<Parameter> BitVector(const std::string& name, u16 size, const std::string& default_value);
129 
141  static Result<Parameter> LogicVector(const std::string& name, u16 size, const std::string& default_value);
142 
149  static Result<Parameter> Integer(const std::string& name, const std::string& default_value);
150 
157  static Result<Parameter> String(const std::string& name, const std::string& default_value);
158 
165  static Result<Parameter> Float(const std::string& name, const std::string& default_value);
166 
175  static Result<Parameter> Time(const std::string& name, const std::string& default_value);
176 
184  static Result<Parameter> Enum(const std::string& name, const std::vector<std::string>& values, const std::string& default_value);
185 
202  bool validate(const std::string& value) const;
203 
217  Result<u64> encode_as_int(const std::string& value) const;
218 
219  bool operator==(const Parameter& other) const;
220  bool operator!=(const Parameter& other) const;
221 
222  private:
223  std::string name;
224  Type type;
225  u16 size = 0;
226  std::string default_value = "";
227  std::vector<std::string> enum_values = {};
228  };
229 
230  template<>
231  std::map<Parameter::Type, std::string> EnumStrings<Parameter::Type>::data;
232 } // namespace hal
#define NETLIST_API
Definition: arch_linux.h:30
u32 size
uint16_t u16
Definition: defines.h:40
Definition: defines.h:45
PinType type
std::string name