|
HAL
v4.5.0-232-g8053ac4b3
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
#include <hal_core/netlist/parameter.h>

Public Types | |
| enum class | Type { Boolean , BitVector , LogicVector , Integer , String , Float , Time , Enum } |
Public Member Functions | |
| Parameter () | |
| const std::string & | get_name () const |
| Type | get_type () const |
| u16 | get_size () const |
| const std::string & | get_default_value () const |
| const std::vector< std::string > & | get_enum_values () const |
| bool | validate (const std::string &value) const |
| Result< u64 > | encode_as_int (const std::string &value) const |
| bool | operator== (const Parameter &other) const |
| bool | operator!= (const Parameter &other) const |
Static Public Member Functions | |
| static Result< Parameter > | Boolean (const std::string &name, const std::string &default_value) |
| static Result< Parameter > | BitVector (const std::string &name, u16 size, const std::string &default_value) |
| static Result< Parameter > | LogicVector (const std::string &name, u16 size, const std::string &default_value) |
| static Result< Parameter > | Integer (const std::string &name, const std::string &default_value) |
| static Result< Parameter > | String (const std::string &name, const std::string &default_value) |
| static Result< Parameter > | Float (const std::string &name, const std::string &default_value) |
| static Result< Parameter > | Time (const std::string &name, const std::string &default_value) |
| static Result< Parameter > | Enum (const std::string &name, const std::vector< std::string > &values, const std::string &default_value) |
A typed, named parameter declaration.
Definition at line 43 of file parameter.h.
|
strong |
Type tag for typed parameters across the netlist.
Definition at line 48 of file parameter.h.
|
explicit |
Constructs an empty / invalid Parameter.
Definition at line 290 of file parameter.cpp.
Referenced by BitVector(), Boolean(), Enum(), Float(), Integer(), LogicVector(), String(), and Time().
|
static |
Construct a bit-vector parameter. Values use the prefixes 0b / 0o / 0x.
| [in] | name | - Parameter name (must be non-empty). |
| [in] | size | - Bit-width (must be at least 1; up to 65535). |
| [in] | default_value | - Default value as a string. |
Definition at line 340 of file parameter.cpp.
References BitVector, ERR, name, OK, Parameter(), and size.
Referenced by hal::parameter_init().
|
static |
Construct a boolean parameter. Accepts only the value strings "true" and "false".
| [in] | name | - Parameter name (must be non-empty). |
| [in] | default_value | - Default value, either "true" or "false". |
Definition at line 319 of file parameter.cpp.
References Boolean, ERR, name, OK, and Parameter().
Referenced by hal::parameter_init().
Convert a string value to its canonical integer encoding for this parameter.
Per-type rules:
false, 1 for true.0b, 0o, 0x).u64.| [in] | value | - The string value to encode. |
Definition at line 603 of file parameter.cpp.
References BitVector, Boolean, Enum, ERR, ERR_APPEND, Float, Integer, LogicVector, OK, String, Time, and type.
|
static |
Construct an enum parameter. size is auto-computed as ceil(log2(values.size())).
| [in] | name | - Parameter name (must be non-empty). |
| [in] | values | - Ordered list of enum values (at least two, unique, non-empty). |
| [in] | default_value | - Default value, must equal one of values. |
Definition at line 469 of file parameter.cpp.
References Enum, ERR, name, OK, and Parameter().
Referenced by hal::parameter_init().
|
static |
Construct a floating-point parameter. Values are parsed via std::stod.
| [in] | name | - Parameter name (must be non-empty). |
| [in] | default_value | - Default value as a decimal float (e.g. 3.14, 1e-5). |
Definition at line 427 of file parameter.cpp.
References ERR, Float, name, OK, and Parameter().
Referenced by hal::parameter_init().
| const std::string & hal::Parameter::get_default_value | ( | ) | const |
Get the default value of the parameter as a string. An empty string signals "no default"; all other values satisfy the type's grammar.
Definition at line 309 of file parameter.cpp.
Referenced by hal::parameter_init(), and hal::ParameterTableModel::updateData().
| const std::vector< std::string > & hal::Parameter::get_enum_values | ( | ) | const |
Get the ordered list of named values for an Enum parameter. Always empty for every other type.
Definition at line 314 of file parameter.cpp.
Referenced by hal::parameter_init(), and hal::ParameterTableModel::updateData().
| const std::string & hal::Parameter::get_name | ( | ) | const |
Get the name of the parameter.
Definition at line 294 of file parameter.cpp.
Referenced by hal::GateType::add_parameter(), hal::DataContainer::get_parameter_value(), hal::DataContainer::has_parameter(), hal::parameter_init(), and hal::DataContainer::set_parameter().
| u16 hal::Parameter::get_size | ( | ) | const |
Get the bit-width of the parameter. Fixed at 1 for Boolean, 64 for Integer and Float, 0 for String and Time, ceil(log2(N)) for Enum with N values, and the declared width for BitVector / LogicVector.
Definition at line 304 of file parameter.cpp.
Referenced by hal::parameter_init(), and hal::ParameterTableModel::updateData().
| Parameter::Type hal::Parameter::get_type | ( | ) | const |
Get the data type of the parameter.
Definition at line 299 of file parameter.cpp.
References type.
Referenced by hal::parameter_init(), hal::DataContainer::set_parameter(), and hal::ParameterTableModel::updateData().
|
static |
Construct a signed-integer parameter. Values are parsed in base 10 and must fit in i64.
| [in] | name | - Parameter name (must be non-empty). |
| [in] | default_value | - Default value as a decimal string (optional leading +/-). |
Definition at line 390 of file parameter.cpp.
References ERR, Integer, name, OK, and Parameter().
Referenced by hal::parameter_init().
|
static |
Construct a 9-state logic-vector parameter. Values use the prefixes 0b / 0o / 0x, with any of the VHDL std_logic state characters (X, Z, U, L, H, W, -) appearing in place of digits (case-insensitive; for octal/hex, a state-character digit expands to 3/4 copies of that state).
| [in] | name | - Parameter name (must be non-empty). |
| [in] | size | - Bit-width (must be at least 1; up to 65535). |
| [in] | default_value | - Default value as a 9-state literal string (empty for "no default"). |
Definition at line 365 of file parameter.cpp.
References ERR, LogicVector, name, OK, Parameter(), and size.
Referenced by hal::parameter_init().
| bool hal::Parameter::operator!= | ( | const Parameter & | other | ) | const |
Definition at line 665 of file parameter.cpp.
| bool hal::Parameter::operator== | ( | const Parameter & | other | ) | const |
Definition at line 660 of file parameter.cpp.
References type.
|
static |
Construct a string parameter. Any value (including the empty string) is accepted.
| [in] | name | - Parameter name (must be non-empty). |
| [in] | default_value | - Default value. |
Definition at line 411 of file parameter.cpp.
References ERR, name, OK, Parameter(), and String.
Referenced by hal::parameter_init().
|
static |
Construct a time parameter. Values are of the form <number><unit> with the unit in {fs, ps, ns, us, ms, s, min, h}; the number is a non-negative decimal.
| [in] | name | - Parameter name (must be non-empty). |
| [in] | default_value | - Default value, e.g. 10ns. |
Definition at line 448 of file parameter.cpp.
References ERR, name, OK, Parameter(), and Time.
Referenced by hal::parameter_init().
| bool hal::Parameter::validate | ( | const std::string & | value | ) | const |
Check whether a candidate value is valid for this parameter declaration.
Per-type rules:
true or false.0b, 0o, 0x) that fits in size.0b, 0o, 0x) whose total bit-length fits in size.i64).double via std::stod.<number><unit> with unit in {fs, ps, ns, us, ms, s, min, h}.| [in] | value | - The candidate value string. |
true if the value is valid, false otherwise. Definition at line 505 of file parameter.cpp.
References BitVector, Boolean, Enum, Float, Integer, LogicVector, String, Time, and type.
Referenced by hal::parameter_init(), and hal::DataContainer::set_parameter().