LogicValue class abstract
An immutable 4-value representation of an arbitrary number of bits.
Each bit of LogicValue can be represented as a LogicValue
of 0
, 1
, x
(contention), or z
(floating).
LogicValue is unsigned.
- Implemented types
- Annotations
Properties
- bit → LogicValue
-
The current active value of this, if it has width 1, as a LogicValue.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isFloating → bool
-
True iff all bits are
z
.no setter - isValid → bool
-
True iff all bits are
0
or1
, not a singlex
orz
.no setter - isZero → bool
-
Returns true if this value is
0
.no setter - length → int
-
The number of bits in this
LogicValue
.no setter - reversed → LogicValue
-
Returns a new LogicValue with the order of all bits in the reverse order
of this LogicValue
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → int
-
The number of bits in this
LogicValue
.final
Methods
-
abs(
) → LogicValue - Calculates the absolute value, assuming that the number is a two's complement.
-
and(
) → LogicValue - Unary AND operation.
-
clog2(
) → LogicValue - Ceil of log base 2 operation.
-
compareTo(
Object other) → int -
Compares this to
other
.override -
eq(
dynamic other) → LogicValue - Equal-to operation.
-
equalsWithDontCare(
LogicValue other) → bool -
Checks if
this
is equal toother
, except ignoring bits of which are not valid. -
extend(
int newWidth, LogicValue fill) → LogicValue -
Returns a new LogicValue with width
newWidth
where the most significant bits for indices beyond the original width are set tofill
. -
getRange(
int startIndex, [int? endIndex]) → LogicValue -
Returns a subset LogicValue. It is inclusive of
startIndex
, exclusive ofendIndex
. -
neq(
dynamic other) → LogicValue - Not equal-to operation.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
or(
) → LogicValue - Unary OR operation.
-
pow(
dynamic exponent) → LogicValue - Power operation.
-
replicate(
int multiplier) → LogicValue -
Returns new LogicValue replicated
multiplier
times. -
signExtend(
int newWidth) → LogicValue -
Returns a new LogicValue with width
newWidth
where new bits added are sign bits as the most significant bits. The sign is determined using two's complement, so it takes the most significant bit of the original value and extends with that. -
slice(
int endIndex, int startIndex) → LogicValue -
Accesses a subset of this LogicValue from
startIndex
toendIndex
, both inclusive. -
toBigInt(
) → BigInt - Converts valid a LogicValue to an int.
-
toBool(
) → bool - Converts a valid logical value to a boolean.
-
toInt(
) → int - Converts valid a LogicValue to an int.
-
toList(
) → List< LogicValue> - Returns a this LogicValue as a List<LogicValue> where every element is 1 bit.
-
toRadixString(
{int radix = 2, int chunkSize = 4, String sepChar = '_'}) → String -
Return the radix encoding of the current LogicValue as a sequence
of radix characters prefixed by the length and encoding format.
Output format is:
<len>'<format><encoded-value>
. -
toString(
{bool includeWidth = true}) → String -
Converts this LogicValue to a binary String, including a decorator at
the front in SystemVerilog style.
override
-
triState(
LogicValue other) → LogicValue -
Bitwise tristate merge of this value with
other
. -
withSet(
int startIndex, LogicValue update) → LogicValue -
Returns a copy of this LogicValue with the bits starting from
startIndex
up untilstartIndex
+update
.width
set toupdate
instead of their original value. -
xor(
) → LogicValue - Unary XOR operation.
-
zeroExtend(
int newWidth) → LogicValue -
Returns a new LogicValue with width
newWidth
where new bits added are zeros as the most significant bits.
Operators
-
operator %(
dynamic other) → LogicValue - Modulo operation.
-
operator &(
LogicValue other) → LogicValue - Bitwise AND operation.
-
operator *(
dynamic other) → LogicValue - Multiplication operation.
-
operator +(
dynamic other) → LogicValue - Addition operation.
-
operator -(
dynamic other) → LogicValue - Subtraction operation.
-
operator /(
dynamic other) → LogicValue - Division operation.
-
operator <(
dynamic other) → LogicValue - Less-than operation.
-
operator <<(
dynamic shamt) → LogicValue - Logical left-shift operation.
-
operator <=(
dynamic other) → LogicValue - Less-than-or-equal operation.
-
operator ==(
Object other) → bool -
Returns true iff the width and all bits of
this
are equal toother
.override -
operator >(
dynamic other) → LogicValue - Greater-than operation.
-
operator >=(
dynamic other) → LogicValue - Greater-than-or-equal operation.
-
operator >>(
dynamic shamt) → LogicValue - Arithmetic right-shift operation.
-
operator >>>(
dynamic shamt) → LogicValue - Logical right-shift operation.
-
operator [](
int index) → LogicValue -
Returns the
i
th bit of this LogicValue -
operator ^(
LogicValue other) → LogicValue - Bitwise XOR operation.
-
operator |(
LogicValue other) → LogicValue - Bitwise OR operation.
-
operator ~(
) → LogicValue - Returns a new LogicValue with every bit inverted.
Static Methods
-
filled(
int width, LogicValue fill) → LogicValue -
Constructs a LogicValue with the
width
number of bits, where every bit has the same value offill
. -
from(
Iterable< LogicValue> it) → LogicValue -
Constructs a LogicValue from
it
. -
fromBigInt(
BigInt value, int width) → LogicValue -
Converts
BigInt
value
to a valid LogicValue withwidth
number of bits. -
fromBool(
bool value) → LogicValue -
Converts
bool
value
to a valid LogicValue with 1 bits either one or zero. -
fromInt(
int value, int width) → LogicValue -
Converts
int
value
to a valid LogicValue withwidth
number of bits. -
fromString(
String stringRepresentation) → LogicValue - Converts a binary String representation of a LogicValue into a LogicValue.
-
isNegedge(
LogicValue previousValue, LogicValue newValue, {bool ignoreInvalid = false}) → bool - Returns true iff the transition represents a negative edge.
-
isPosedge(
LogicValue previousValue, LogicValue newValue, {bool ignoreInvalid = false}) → bool - Returns true iff the transition represents a positive edge.
-
of(
dynamic val, {bool fill = false, int? width}) → LogicValue -
Constructs a LogicValue from
val
which could be of a variety of types. -
ofBigInt(
BigInt value, int width) → LogicValue -
Converts
BigInt
value
to a valid LogicValue withwidth
number of bits. -
ofBool(
bool value) → LogicValue -
Converts
bool
value
to a valid LogicValue with 1 bits either one or zero. -
ofInferWidth(
dynamic val) → LogicValue -
Creates a LogicValue of
val
using of, but attempts to infer the width that would fitval
automatically. -
ofInt(
int value, int width) → LogicValue -
Converts
int
value
to a valid LogicValue withwidth
number of bits. -
ofIterable(
Iterable< LogicValue> it) → LogicValue -
Constructs a LogicValue from
it
. -
ofRadixString(
String valueString, {String sepChar = '_'}) → LogicValue - Create a LogicValue from a length/radix-encoded string of the following format:
-
ofString(
String stringRepresentation) → LogicValue - Converts a binary String representation of a LogicValue into a LogicValue.
Constants
- empty → const LogicValue
- A zero-width value.
- one → const LogicValue
-
Logical value of
1
. - radixStringChars → const String
- Legal characters in a radixString representation.
- x → const LogicValue
-
Logical value of
x
. - z → const LogicValue
-
Logical value of
z
. - zero → const LogicValue
-
Logical value of
0
.