hdlypes¶
VHDL Types for C++ and Python.
-
class
hdltypes
::
Bit
¶ Bit value type
Implementation of a bit value. Supports the values
0
and1
. Values of this type are immutable. Supports (de)serialization, comparison, and logic operations: “and”, “or”, “xor”, and inversion.Public Types
Public Functions
-
explicit constexpr
Bit
(value_type value) noexcept¶ Create a Bit given a value_type value.
Note that this function is noexcept, there is no checking on passed values. This is justified because it is difficult to break, except on purpose; while allowing us additional performance.
-
constexpr value_type
value
() const noexcept¶ Obtain the value_type value.
-
constexpr Bit
to_bit
(bool b) noexcept¶ Converts bool values
false
andtrue
to Bit0
and1
, respectively.
-
template<typename
IntType
, typename std::enable_if<is_integer_type<IntType>::value, int>::type = 0>
constexpr Bitto_bit
(const IntType &i)¶ Converts integer values
0
and1
into Bit0
and1
, respectively.
-
template<typename
CharType
, typename std::enable_if<is_char_type<CharType>::value, int>::type = 0>
constexpr Bitto_bit
(const CharType &c)¶ Converts character values into Logic. See table below for more details.
'0' => _0 '1' => _1
-
constexpr Bit
operator&
(Bit a, Bit b) noexcept¶ Logical “and” operation. Returns
1
if both arguments are1
.
-
constexpr Bit
operator|
(Bit a, Bit b) noexcept¶ Logical “or” operation. Returns
1
if either arguments are1
.
-
constexpr Bit
operator^
(Bit a, Bit b) noexcept¶ Logical “xor” operation. Returns
1
if arguments aren’t equivalent.
-
constexpr Bit
operator~
(Bit a) noexcept¶ Logical inversion operation. Returns
1
if given0
, and vice versa.
-
template<typename
IntType
= int>
constexpr IntTypeto_int
(Bit a) noexcept¶ Converts a Bit
0
or1
to the integer0
or1
, respectively.
-
explicit constexpr
-
class
hdltypes
::
Logic
¶ Logic value type
This effectively models VHDL’s std_ulogic type. See value_type for details on the values of this type.
This type supports logical operations “and”, “or”, “xor”, and inversion. Can be converted “from” and “to” int or bool representations of Logic values. Supports serialization and deserialization as well.
Like VHDL: weak value when operated on become strong (due to implicit buffering) operations on non-0/1 values yield “unknowns” operations involving unassigned result in unassigned results
Public Types
-
enum
value_type
¶ Representation of acceptable values of a Logic.
Naming and ordering are public information and must be controlled.
Values:
-
enumerator
U
¶ Unassigned. Represents the container holding a value of this type did not take on an actual value.
-
enumerator
X
¶ Unknown. Typically a result of doing operations on non-0/1 values.
-
enumerator
_0
¶ 0
-
enumerator
_1
¶ 1
-
enumerator
Z
¶ High Impedance. Useful for modeling pull-ups and pull-downs.
-
enumerator
W
¶ Weak Unknown. Like X, but the value is weak.
-
enumerator
L
¶ Weak 0. Like 0, but the value is weak.
-
enumerator
H
¶ Weak 1. Like 1, but the value is weak.
-
enumerator
DC
¶ Don’t Care. Like X, but explicit rather than accidental.
-
enumerator
Public Functions
-
explicit constexpr
Logic
(value_type value) noexcept¶ Create a Logic given a value_type value.
Note that this function is noexcept, there is no checking on passed values. This is justified because it is difficult to break, except on purpose; while allowing us additional performance.
-
constexpr value_type
value
() const noexcept¶ Obtain the value_type value.
-
constexpr Logic
to_logic
(bool b) noexcept¶ Converts bool values
false
andtrue
to Logic0
and1
, respectively.
-
template<typename
IntType
, typename std::enable_if<is_integer_type<IntType>::value, int>::type = 0>
constexpr Logicto_logic
(const IntType &i)¶ Converts integer values
0
and1
into Logic0
and1
, respectively.
-
template<typename
CharType
, typename std::enable_if<is_char_type<CharType>::value, int>::type = 0>
constexpr Logicto_logic
(const CharType &c)¶ Converts character values into Logic. See table below for more details.
'U' 'u' => U 'X' 'x' => X '0' => _0 '1' => _1 'Z' 'z' => Z 'W' 'w' => W 'L' 'l' => L 'H' 'h' => H '-' => DC
-
constexpr Logic
operator&
(Logic a, Logic b) noexcept¶ Logical “and” operation. See implementation for details.
-
constexpr Logic &
operator&=
(Logic &a, Logic b) noexcept¶ Inplace version of the logical “and” operation.
-
constexpr Logic
operator|
(Logic a, Logic b) noexcept¶ Logical “or” operation. See implementation for details.
-
constexpr Logic &
operator|=
(Logic &a, Logic b) noexcept¶ Inplace version of the logical “or” operation.
-
constexpr Logic
operator^
(Logic a, Logic b) noexcept¶ Logical “xor” operation. See implementation for details.
-
constexpr Logic &
operator^=
(Logic &a, Logic b) noexcept¶ Inplace version of the logical “xor” operation.
-
constexpr Logic
operator~
(Logic a) noexcept¶ Logical inversion operation. See implementation for details.
-
constexpr Logic &
inplace_invert
(Logic &a) noexcept¶ Inplace version of the logical “invert” operation.
-
template<typename
IntType
= int>
constexpr IntTypeto_int
(Logic a)¶ Converts a Logic
0
/L
or1
/H
to the integer0
or1
, respectively.
-
constexpr bool
to_bool
(Logic a)¶ Converts a Logic
0
/L
or1
/H
to the integerfalse
ortrue
, respectively.
-
enum