util

virtual class util

virtual Provides several utility functions.

See Also

putil

Summary
utilvirtual Provides several utility functions.
Functions
num_oct_digitsstatic Returns the number of octal digits required to represent the specified binary digits.
num_dec_digitsstatic Returns the number of decimal digits required to represent the specified binary digits.
num_hex_digitsstatic Returns the number of hexadecimal digits required to represent the specified binary digits.

Functions

num_oct_digits

static function int unsigned num_oct_digits(int unsigned num_bin_digits)

static Returns the number of octal digits required to represent the specified binary digits.

Argument

num_bin_digitsThe number of binary digits.

Returns

The number of octal digits required to represent num_bin_digits.

Example

assert( util::num_oct_digits( 3 ) == 1 ); //  3'b111 -> 1'o7
assert( util::num_oct_digits( 4 ) == 2 ); // 4'b1111 -> 2'o17

num_dec_digits

static function int unsigned num_dec_digits(int unsigned num_bin_digits)

static Returns the number of decimal digits required to represent the specified binary digits.

Argument

num_bin_digitsThe number of binary digits.

Returns

The number of decimal digits required to represent num_bin_digits.

Example

assert( util::num_dec_digits( 3 ) == 1 ); //  3'b111 -> 1'd7
assert( util::num_dec_digits( 4 ) == 2 ); // 4'b1111 -> 2'd15

num_hex_digits

static function int unsigned num_hex_digits(int unsigned num_bin_digits)

static Returns the number of hexadecimal digits required to represent the specified binary digits.

Argument

num_bin_digitsThe number of binary digits.

Returns

The number of hexadecimal digits required to represent num_bin_digits.

Example

assert( util::num_hex_digits( 3 ) == 1 ); //  3'b111 -> 1'h7
assert( util::num_hex_digits( 4 ) == 1 ); // 4'b1111 -> 1'hF
virtual class util
virtual Provides several utility functions.
static function int unsigned num_oct_digits(int unsigned num_bin_digits)
static Returns the number of octal digits required to represent the specified binary digits.
static function int unsigned num_dec_digits(int unsigned num_bin_digits)
static Returns the number of decimal digits required to represent the specified binary digits.
static function int unsigned num_hex_digits(int unsigned num_bin_digits)
static Returns the number of hexadecimal digits required to represent the specified binary digits.
virtual class putil #(type T =  int)
virtual Provides a parameterized utility function.