SILICON
Loading...
Searching...
No Matches
SILICON::wireUtils Namespace Reference

Functions

bool busValueOverflowsWidth (const core::BusValue &value, std::size_t width)
 True when truncating to width would discard a non-low bit.
bool fitsUnsigned (const core::BusValue &value, std::size_t width)
 Tests whether an LSB-first value is representable as an unsigned value.
bool fitsSigned (const core::BusValue &value, std::size_t width)
 Tests whether an LSB-first two's-complement value fits a signed width.
BusValue normalizeBusValue (const core::BusValue &value, std::size_t width, core::State extension=core::State::LOW)
 Resize an LSB-first value to an exact bus width.
bool busWillChangeToValue (const core::Bus &bus, const core::BusValue &value)
 Checks whether assigning a binary value would change any driven bus wire.
bool isKnownBinary (core::State state)
 Tests whether a state is a concrete binary logic value.
bool mayBe (core::State actual, core::State expected)
 Tests whether an actual state could represent an expected binary state.
State normalizeBinaryOrUnknown (core::State state)
 Normalizes non-binary states for stored binary elements.

Function Documentation

◆ busValueOverflowsWidth()

bool busValueOverflowsWidth ( const BusValue & value,
const std::size_t width )
nodiscard

True when truncating to width would discard a non-low bit.

Definition at line 94 of file wire.cpp.

◆ busWillChangeToValue()

bool busWillChangeToValue ( const core::Bus & bus,
const core::BusValue & value )
nodiscard

Checks whether assigning a binary value would change any driven bus wire.

Parameters
busBus to compare against the requested value.
valueBinary value encoded least-significant bit first.
Returns
True when at least one existing wire would change state.

Definition at line 131 of file wire.cpp.

◆ fitsSigned()

bool fitsSigned ( const BusValue & value,
const std::size_t width )
nodiscard

Tests whether an LSB-first two's-complement value fits a signed width.

Definition at line 105 of file wire.cpp.

◆ fitsUnsigned()

bool fitsUnsigned ( const BusValue & value,
const std::size_t width )
nodiscard

Tests whether an LSB-first value is representable as an unsigned value.

Definition at line 97 of file wire.cpp.

◆ isKnownBinary()

bool isKnownBinary ( core::State state)
nodiscard

Tests whether a state is a concrete binary logic value.

Parameters
stateState to test.
Returns
True for LOW or HIGH, false for UNKNOWN or ERROR.

Definition at line 136 of file wire.cpp.

◆ mayBe()

bool mayBe ( core::State actual,
core::State expected )
nodiscard

Tests whether an actual state could represent an expected binary state.

Parameters
actualObserved state.
expectedExpected concrete state.
Returns
True when actual equals expected or actual is not a known binary state.

Definition at line 141 of file wire.cpp.

◆ normalizeBinaryOrUnknown()

core::State normalizeBinaryOrUnknown ( core::State state)
nodiscard

Normalizes non-binary states for stored binary elements.

Parameters
stateState to normalize.
Returns
LOW/HIGH unchanged, UNKNOWN for every other state.

Definition at line 146 of file wire.cpp.

◆ normalizeBusValue()

core::BusValue normalizeBusValue ( const core::BusValue & value,
std::size_t width,
core::State extension = core::State::LOW )
nodiscard

Resize an LSB-first value to an exact bus width.

Short values are extended with extension and long values retain their least significant bits.

Definition at line 121 of file wire.cpp.