uvm_bit_vector_utils#(T)

Provides utility functions for converting bit vectors to/from strings.

@uvm-contribFor potential contribution to a future 1800.2 standard
Summary
uvm_bit_vector_utils#(T)
Provides utility functions for converting bit vectors to/from strings.
Class Declaration
virtual class uvm_bit_vector_utils#(
    type  T  =  int
)
Methods
to_stringConverts a packed array value into a string.
from_stringConverts a string value into a packed array.

to_string

static function string to_string(
    value,   
    int  size,   
    uvm_radix_enum  radix  =  UVM_NORADIX,
    string  radix_str  =  ""
)

Converts a packed array value into a string.

The <size> argument is the number of bits in the vector to be converted, all bits beyond the size are ignored/masked out.  The <radix> argument controls the base of the conversion, e.g.  UVM_BIN for “%0b”.  The <radix_str> argument is prepended to the converted value, e.g.  “’b” for binary.  Note that the radix_str argument has no effect on the base of the conversion.

The return value is the converted string.

@uvm-contribFor potential contribution to a future 1800.2 standard

from_string

static function int from_string(
    input  string  val_str,
    output  val
)

Converts a string value into a packed array.

The string val_str is processed as

[sign][radix]value

Where `[sign]` is an optional sign character, either “+” or “-”, and `[radix]` is an optional radix specifier.

The following radix specifiers are supported

”’b”, “0b”: Binary “’o”: Octal “’d”: Decimal “’h”, “’x”, “0x”: Hexidecimal

If the optional radix is omitted, then the value shall be treated as decimal.

The val_str is treated as a 4-state value, the characters “X”, “x”, “Z”, “z”, and “?” are legal within the val_str string.  Additionally, the underscore character (“_”) is ignored.

@uvm-contribFor potential contribution to a future 1800.2 standard
virtual class uvm_bit_vector_utils#(
    type  T  =  int
)
Provides utility functions for converting bit vectors to/from strings.
static function string to_string(
    value,   
    int  size,   
    uvm_radix_enum  radix  =  UVM_NORADIX,
    string  radix_str  =  ""
)
Converts a packed array value into a string.
static function int from_string(
    input  string  val_str,
    output  val
)
Converts a string value into a packed array.