HAL  v4.5.0-232-g8053ac4b3
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::Parameter Struct Reference

#include <hal_core/netlist/parameter.h>

Collaboration diagram for hal::Parameter:
Collaboration graph

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)
 

Detailed Description

A typed, named parameter declaration.

Definition at line 43 of file parameter.h.

Member Enumeration Documentation

◆ Type

enum hal::Parameter::Type
strong

Type tag for typed parameters across the netlist.

Enumerator
Boolean 

A logical boolean (true or false).

BitVector 

A multi-bit unsigned integer value (2-state).

LogicVector 

A multi-bit 9-state logic vector; each bit may be 0, 1, X, Z, U, L, H, W, or -.

Integer 

A signed 64-bit integer in decimal.

String 

An arbitrary string.

Float 

A double-precision floating-point number.

Time 

A time value with a unit suffix (fs, ps, ns, us, ms, s, min, h).

Enum 

A finite, ordered set of named values; encoded as an integer index.

Definition at line 48 of file parameter.h.

Constructor & Destructor Documentation

◆ Parameter()

hal::Parameter::Parameter ( )
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().

Member Function Documentation

◆ BitVector()

Result< Parameter > hal::Parameter::BitVector ( const std::string &  name,
u16  size,
const std::string &  default_value 
)
static

Construct a bit-vector parameter. Values use the prefixes 0b / 0o / 0x.

Parameters
[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().

◆ Boolean()

Result< Parameter > hal::Parameter::Boolean ( const std::string &  name,
const std::string &  default_value 
)
static

Construct a boolean parameter. Accepts only the value strings "true" and "false".

Parameters
[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().

◆ encode_as_int()

Result< u64 > hal::Parameter::encode_as_int ( const std::string &  value) const

Convert a string value to its canonical integer encoding for this parameter.

Per-type rules:

  • Boolean: returns 0 for false, 1 for true.
  • BitVector: parses the value (0b, 0o, 0x).
  • Integer: returns the bit-pattern of the signed value reinterpreted as u64.
  • LogicVector, String, Float, Time: no canonical integer encoding; returns an error.
  • Enum: returns the index of the value in the declared value list.
Parameters
[in]value- The string value to encode.
Returns
OK() and the integer encoding on success, an error otherwise.

Definition at line 603 of file parameter.cpp.

References BitVector, Boolean, Enum, ERR, ERR_APPEND, Float, Integer, LogicVector, OK, String, Time, and type.

◆ Enum()

Result< Parameter > hal::Parameter::Enum ( const std::string &  name,
const std::vector< std::string > &  values,
const std::string &  default_value 
)
static

Construct an enum parameter. size is auto-computed as ceil(log2(values.size())).

Parameters
[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().

◆ Float()

Result< Parameter > hal::Parameter::Float ( const std::string &  name,
const std::string &  default_value 
)
static

Construct a floating-point parameter. Values are parsed via std::stod.

Parameters
[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().

◆ get_default_value()

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.

Returns
The default value string.

Definition at line 309 of file parameter.cpp.

Referenced by hal::parameter_init(), and hal::ParameterTableModel::updateData().

◆ get_enum_values()

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.

Returns
The enum value list.

Definition at line 314 of file parameter.cpp.

Referenced by hal::parameter_init(), and hal::ParameterTableModel::updateData().

◆ get_name()

const std::string & hal::Parameter::get_name ( ) const

◆ get_size()

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.

Returns
The bit-width.

Definition at line 304 of file parameter.cpp.

Referenced by hal::parameter_init(), and hal::ParameterTableModel::updateData().

◆ get_type()

Parameter::Type hal::Parameter::get_type ( ) const

Get the data type of the parameter.

Returns
The parameter type.

Definition at line 299 of file parameter.cpp.

References type.

Referenced by hal::parameter_init(), hal::DataContainer::set_parameter(), and hal::ParameterTableModel::updateData().

◆ Integer()

Result< Parameter > hal::Parameter::Integer ( const std::string &  name,
const std::string &  default_value 
)
static

Construct a signed-integer parameter. Values are parsed in base 10 and must fit in i64.

Parameters
[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().

◆ LogicVector()

Result< Parameter > hal::Parameter::LogicVector ( const std::string &  name,
u16  size,
const std::string &  default_value 
)
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).

Parameters
[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().

◆ operator!=()

bool hal::Parameter::operator!= ( const Parameter &  other) const

Definition at line 665 of file parameter.cpp.

◆ operator==()

bool hal::Parameter::operator== ( const Parameter &  other) const

Definition at line 660 of file parameter.cpp.

References type.

◆ String()

Result< Parameter > hal::Parameter::String ( const std::string &  name,
const std::string &  default_value 
)
static

Construct a string parameter. Any value (including the empty string) is accepted.

Parameters
[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().

◆ Time()

Result< Parameter > hal::Parameter::Time ( const std::string &  name,
const std::string &  default_value 
)
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.

Parameters
[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().

◆ validate()

bool hal::Parameter::validate ( const std::string &  value) const

Check whether a candidate value is valid for this parameter declaration.

Per-type rules:

  • Boolean: value must be true or false.
  • BitVector: parses as a non-negative integer (0b, 0o, 0x) that fits in size.
  • LogicVector: parses as a 4-state literal (0b, 0o, 0x) whose total bit-length fits in size.
  • Integer: parses as a signed decimal integer (fits in i64).
  • String: any value (including the empty string) is accepted.
  • Float: parses as a double via std::stod.
  • Time: matches <number><unit> with unit in {fs, ps, ns, us, ms, s, min, h}.
  • Enum: must equal one of the declared enum values.
Parameters
[in]value- The candidate value string.
Returns
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().


The documentation for this struct was generated from the following files: