[source]

Package utils

For detailed documentation see below.

Constants

Name

Value

Description

SIMULATION

Distinguishes simulation from synthesis deferred constant declaration

C_BCD_MINUS

"1010"

C_BCD_OFF

"1011"

Types

Name

Description

T_BOOLVEC
  • Vectors of primitive standard types +++++++++++++++++++++++++++++++++++++

T_INTVEC
T_NATVEC
T_POSVEC
T_REALVEC
T_INT_8
  • Integer subranges sometimes useful for speeding up simulation ++++++++++

T_INT_16
T_UINT_8
T_UINT_16
T_IPSTYLE
  • Enums ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Intellectual Property (IP) type

T_BIT_ORDER

Bit order

T_BYTE_ORDER

Byte order (Endian)

T_POLARITY

Active logic level

T_CLOCK_EDGE

active clock edge

T_ROUNDING_STYLE

rounding style

T_BCD

define a new unrelated type T_BCD for arithmetic QUESTION: extract to an own BCD package? => overloaded operators for +/-/=/... and conversion functions

T_BCD_VECTOR

Functions

virtual function T_BIT_ORDER "not" ( T_BIT_ORDER left ) [source]
virtual function T_BYTE_ORDER "not" ( T_BYTE_ORDER left ) [source]
virtual function T_POLARITY "not" ( T_POLARITY left ) [source]
virtual function T_CLOCK_EDGE "not" ( T_CLOCK_EDGE left ) [source]
virtual function bit "xor" ( T_POLARITY left, bit right ) [source]
virtual function bit_vector "xor" ( T_POLARITY left, bit_vector right ) [source]
virtual function STD_LOGIC "xor" ( T_POLARITY left, std_logic right ) [source]
virtual function STD_LOGIC_VECTOR "xor" ( T_POLARITY left, std_logic_vector right ) [source]
virtual function bit "xor" ( bit left, T_POLARITY right ) [source]
virtual function bit_vector "xor" ( bit_vector left, T_POLARITY right ) [source]
virtual function STD_LOGIC "xor" ( std_logic left, T_POLARITY right ) [source]
virtual function STD_LOGIC_VECTOR "xor" ( std_logic_vector left, T_POLARITY right ) [source]
virtual function bit "xnor" ( T_POLARITY left, bit right ) [source]
virtual function bit_vector "xnor" ( T_POLARITY left, bit_vector right ) [source]
virtual function STD_LOGIC "xnor" ( T_POLARITY left, std_logic right ) [source]
virtual function STD_LOGIC_VECTOR "xnor" ( T_POLARITY left, std_logic_vector right ) [source]
virtual function bit "xnor" ( bit left, T_POLARITY right ) [source]
virtual function bit_vector "xnor" ( bit_vector left, T_POLARITY right ) [source]
virtual function STD_LOGIC "xnor" ( std_logic left, T_POLARITY right ) [source]
virtual function STD_LOGIC_VECTOR "xnor" ( std_logic_vector left, T_POLARITY right ) [source]
virtual function natural div_ceil ( natural a, positive b ) [source]
  • Division ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Calculates: ceil(a / b)

virtual function boolean is_pow2 ( natural int ) [source]
  • Power +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

is input a power of 2?

virtual function positive ceil_pow2 ( natural int ) [source]

round to next power of 2

virtual function natural floor_pow2 ( natural int ) [source]

round to previous power of 2

virtual function natural log2ceil ( positive arg ) [source]
  • Logarithm ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Calculates: ceil(ld(arg))

virtual function positive log2ceilnz ( positive arg ) [source]

Calculates: max(1, ceil(ld(arg)))

virtual function natural log10ceil ( positive arg ) [source]

Calculates: ceil(lg(arg))

virtual function positive log10ceilnz ( positive arg ) [source]

Calculates: max(1, ceil(lg(arg)))

virtual function boolean ite ( boolean cond, boolean value1, boolean value2 ) [source]
  • if-then-else (ite) +++++++++++++++++++++++++++++++++++++++++++++++++++++

virtual function integer ite ( boolean cond, integer value1, integer value2 ) [source]
virtual function real ite ( boolean cond, REAL value1, REAL value2 ) [source]
virtual function STD_LOGIC ite ( boolean cond, std_logic value1, std_logic value2 ) [source]
virtual function STD_LOGIC_VECTOR ite ( boolean cond, std_logic_vector value1, std_logic_vector value2 ) [source]
virtual function bit_vector ite ( boolean cond, bit_vector value1, bit_vector value2 ) [source]
virtual function UNSIGNED ite ( boolean cond, unsigned value1, unsigned value2 ) [source]
virtual function SIGNED ite ( boolean cond, signed value1, signed value2 ) [source]
virtual function character ite ( boolean cond, character value1, character value2 ) [source]
virtual function string ite ( boolean cond, string value1, string value2 ) [source]
virtual function integer inc_if ( boolean cond, integer value, integer increment ) [source]

conditional increment / decrement

virtual function integer dec_if ( boolean cond, integer value, integer decrement ) [source]
virtual function integer imin ( integer arg1, integer arg2 ) [source]
  • Max / Min / Sum ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

virtual function integer imin ( T_INTVEC vec ) [source]

function rmin(arg1 : real; arg2 : real) return real; -- Calculates: min(arg1, arg2) for reals Calculates: min(vec) for a integer vector

virtual function natural imin ( T_NATVEC vec ) [source]

Calculates: min(vec) for a natural vector

virtual function positive imin ( T_POSVEC vec ) [source]

Calculates: min(vec) for a positive vector

virtual function real rmin ( T_REALVEC vec ) [source]

Calculates: min(vec) of real vector

virtual function integer imax ( integer arg1, integer arg2 ) [source]
virtual function integer imax ( T_INTVEC vec ) [source]

function rmax(arg1 : real; arg2 : real) return real; -- Calculates: max(arg1, arg2) for reals Calculates: max(vec) for a integer vector

virtual function natural imax ( T_NATVEC vec ) [source]

Calculates: max(vec) for a natural vector

virtual function positive imax ( T_POSVEC vec ) [source]

Calculates: max(vec) for a positive vector

virtual function real rmax ( T_REALVEC vec ) [source]

Calculates: max(vec) of real vector

virtual function natural isum ( T_NATVEC vec ) [source]

Calculates: sum(vec) for a natural vector

virtual function natural isum ( T_POSVEC vec ) [source]

Calculates: sum(vec) for a positive vector

virtual function integer isum ( T_INTVEC vec ) [source]

Calculates: sum(vec) of integer vector

virtual function real rsum ( T_REALVEC vec ) [source]

Calculates: sum(vec) of real vector

virtual function integer to_int ( boolean bool, integer zero, integer one ) [source]

to integer: to_int

virtual function integer to_int ( std_logic sl, integer zero, integer one ) [source]
virtual function STD_LOGIC to_sl ( boolean Value ) [source]

to std_logic: to_sl

virtual function STD_LOGIC to_sl ( character Value ) [source]
virtual function STD_LOGIC_VECTOR to_slv ( natural Value, positive Size ) [source]

to std_logic_vector: to_slv

virtual function T_BCD to_BCD ( integer Digit ) [source]
virtual function T_BCD to_BCD ( character Digit ) [source]
virtual function T_BCD to_BCD ( unsigned Digit ) [source]
virtual function T_BCD to_BCD ( std_logic_vector Digit ) [source]
virtual function T_BCD_VECTOR to_BCD_Vector ( integer Value, natural Size, T_BCD Fill ) [source]
virtual function T_BCD_VECTOR to_BCD_Vector ( string Value, natural Size, T_BCD Fill ) [source]
virtual function integer bound ( integer index, integer lowerBound, integer upperBound ) [source]

TODO: comment

virtual function integer to_index ( unsigned slv, natural max ) [source]
virtual function integer to_index ( std_logic_vector slv, natural max ) [source]
virtual function boolean is_sl ( character c ) [source]

is_*

virtual function STD_LOGIC slv_or ( std_logic_vector vec ) [source]

Aggregate functions

virtual function STD_LOGIC slv_nor ( std_logic_vector vec ) [source]
virtual function STD_LOGIC slv_and ( std_logic_vector vec ) [source]
virtual function STD_LOGIC slv_nand ( std_logic_vector vec ) [source]
virtual function STD_LOGIC slv_xor ( std_logic_vector vec ) [source]
virtual function STD_LOGIC_VECTOR reverse ( std_logic_vector vec ) [source]

Reverses the elements of the passed Vector.

@synthesis supported

virtual function bit_vector reverse ( bit_vector vec ) [source]
virtual function UNSIGNED reverse ( unsigned vec ) [source]
virtual function integer scale ( integer Value, integer Minimum, integer Maximum, T_ROUNDING_STYLE RoundingStyle ) [source]

scale a value into a range [Minimum, Maximum]

virtual function integer scale ( REAL Value, integer Minimum, integer Maximum, T_ROUNDING_STYLE RoundingStyle ) [source]
virtual function real scale ( REAL Value, REAL Minimum, REAL Maximum ) [source]
virtual function bit_vector resize ( bit_vector vec, natural length, bit fill ) [source]

Resizes the vector to the specified length. The adjustment is make on on the 'high end of the vector. The 'low index remains as in the argument. If the result vector is larger, the extension uses the provided fill value (default: '0'). Use the resize functions of the numeric_std package for value-preserving resizes of the signed and unsigned data types.

@synthesis supported

virtual function STD_LOGIC_VECTOR resize ( std_logic_vector vec, natural length, std_logic fill ) [source]
virtual function STD_LOGIC_VECTOR move ( std_logic_vector vec, integer ofs ) [source]

Shift the index range of a vector by the specified offset.

virtual function STD_LOGIC_VECTOR movez ( std_logic_vector vec ) [source]

Shift the index range of a vector making vec'low = 0.

virtual function STD_LOGIC_VECTOR ascend ( std_logic_vector vec ) [source]
virtual function STD_LOGIC_VECTOR descend ( std_logic_vector vec ) [source]
virtual function STD_LOGIC_VECTOR lssb ( std_logic_vector arg ) [source]

Least-Significant Set Bit (lssb): Computes a vector of the same length as the argument with at most one bit set at the rightmost '1' found in arg.

@synthesis supported

virtual function bit_vector lssb ( bit_vector arg ) [source]
virtual function integer lssb_idx ( std_logic_vector arg ) [source]

Returns the index of the least-significant set bit.

@synthesis supported

virtual function integer lssb_idx ( bit_vector arg ) [source]
virtual function STD_LOGIC_VECTOR mssb ( std_logic_vector arg ) [source]

Most-Significant Set Bit (mssb): computes a vector of the same length with at most one bit set at the leftmost '1' found in arg.

virtual function bit_vector mssb ( bit_vector arg ) [source]
virtual function integer mssb_idx ( std_logic_vector arg ) [source]
virtual function integer mssb_idx ( bit_vector arg ) [source]
virtual function STD_LOGIC_VECTOR swap ( std_logic_vector slv, positive Size ) [source]

Swap sub vectors in vector (endian reversal)

virtual function STD_LOGIC_VECTOR bit_swap ( std_logic_vector slv, positive Chunksize ) [source]

Swap the bits in a chunk

virtual function STD_LOGIC_VECTOR genmask_high ( natural Bits, positive MaskLength ) [source]

generate bit masks

virtual function STD_LOGIC_VECTOR genmask_low ( natural Bits, positive MaskLength ) [source]
virtual function STD_LOGIC_VECTOR genmask_alternate ( positive len, std_logic lsb ) [source]
virtual function UNSIGNED onehot2bin ( std_logic_vector onehot, integer empty_val ) [source]
One-Hot-Code to Binary-Code.

If a non-negative value empty_val is specified, its unsigned representation will be returned upon an all-zero input. As a consequence of specifying this value, no simulation warnings will be issued upon empty inputs. Alleged 1-hot-encoded inputs with more than one bit asserted will always raise a simulation warning.

virtual function STD_LOGIC_VECTOR gray2bin ( std_logic_vector gray_val ) [source]

Converts Gray-Code into Binary-Code.

@synthesis supported

virtual function UNSIGNED gray2bin ( std_logic_vector gray_val ) [source]
virtual function STD_LOGIC_VECTOR bin2onehot ( std_logic_vector value ) [source]

Binary-Code to One-Hot-Code

virtual function STD_LOGIC_VECTOR bin2onehot ( unsigned value ) [source]
virtual function STD_LOGIC_VECTOR bin2onecold ( std_logic_vector value ) [source]

Binary-Code to One-Cold-Code

virtual function STD_LOGIC_VECTOR bin2onecold ( unsigned value ) [source]
virtual function STD_LOGIC_VECTOR bin2gray ( std_logic_vector value ) [source]

Binary-Code to Gray-Code

virtual function STD_LOGIC_VECTOR bin2gray ( unsigned value ) [source]