Package utils
For detailed documentation see below.
Name |
Value |
Description |
---|---|---|
SIMULATION |
Distinguishes simulation from synthesis deferred constant declaration |
|
C_BCD_MINUS |
"1010" |
|
C_BCD_OFF |
"1011" |
Name |
Description |
---|---|
T_BOOLVEC |
|
T_INTVEC |
|
T_NATVEC |
|
T_POSVEC |
|
T_REALVEC |
|
T_INT_8 |
|
T_INT_16 |
|
T_UINT_8 |
|
T_UINT_16 |
|
T_IPSTYLE |
|
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
- "not"(T_BIT_ORDER left)
- Parameters:
left (T_BIT_ORDER)
- Return type:
- "not"(T_BYTE_ORDER left)
- Parameters:
left (T_BYTE_ORDER)
- Return type:
- "not"(T_POLARITY left)
- Parameters:
left (T_POLARITY)
- Return type:
- "not"(T_CLOCK_EDGE left)
- Parameters:
left (T_CLOCK_EDGE)
- Return type:
- "xor"(T_POLARITY left, bit right)
- Parameters:
left (T_POLARITY)
right (bit)
- "xor"(T_POLARITY left, bit_vector right)
- Parameters:
left (T_POLARITY)
right (bit_vector)
- "xor"(T_POLARITY left, std_logic right)
- Parameters:
left (T_POLARITY)
right (std_logic)
- "xor"(T_POLARITY left, std_logic_vector right)
- Parameters:
left (T_POLARITY)
right (std_logic_vector)
- "xor"(bit left, T_POLARITY right)
- Parameters:
left (bit)
right (T_POLARITY)
- "xor"(bit_vector left, T_POLARITY right)
- Parameters:
left (bit_vector)
right (T_POLARITY)
- "xor"(std_logic left, T_POLARITY right)
- Parameters:
left (std_logic)
right (T_POLARITY)
- "xor"(std_logic_vector left, T_POLARITY right)
- Parameters:
left (std_logic_vector)
right (T_POLARITY)
- "xnor"(T_POLARITY left, bit right)
- Parameters:
left (T_POLARITY)
right (bit)
- "xnor"(T_POLARITY left, bit_vector right)
- Parameters:
left (T_POLARITY)
right (bit_vector)
- "xnor"(T_POLARITY left, std_logic right)
- Parameters:
left (T_POLARITY)
right (std_logic)
- "xnor"(T_POLARITY left, std_logic_vector right)
- Parameters:
left (T_POLARITY)
right (std_logic_vector)
- "xnor"(bit left, T_POLARITY right)
- Parameters:
left (bit)
right (T_POLARITY)
- "xnor"(bit_vector left, T_POLARITY right)
- Parameters:
left (bit_vector)
right (T_POLARITY)
- "xnor"(std_logic left, T_POLARITY right)
- Parameters:
left (std_logic)
right (T_POLARITY)
- "xnor"(std_logic_vector left, T_POLARITY right)
- Parameters:
left (std_logic_vector)
right (T_POLARITY)
- div_ceil(natural a, positive b)
Division ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Calculates: ceil(a / b)
- Parameters:
a (natural)
b (positive)
- is_pow2(natural int)
Power +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
is input a power of 2?
- Parameters:
int (natural)
- ceil_pow2(natural int)
round to next power of 2
- Parameters:
int (natural)
- floor_pow2(natural int)
round to previous power of 2
- Parameters:
int (natural)
- log2ceil(positive arg)
Logarithm ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Calculates: ceil(ld(arg))
- Parameters:
arg (positive)
- log2ceilnz(positive arg)
Calculates: max(1, ceil(ld(arg)))
- Parameters:
arg (positive)
- log10ceil(positive arg)
Calculates: ceil(lg(arg))
- Parameters:
arg (positive)
- log10ceilnz(positive arg)
Calculates: max(1, ceil(lg(arg)))
- Parameters:
arg (positive)
- ite(boolean cond, boolean value1, boolean value2)
if-then-else (ite) +++++++++++++++++++++++++++++++++++++++++++++++++++++
- Parameters:
cond (boolean)
value1 (boolean)
value2 (boolean)
- ite(boolean cond, integer value1, integer value2)
- Parameters:
cond (boolean)
value1 (integer)
value2 (integer)
- ite(boolean cond, REAL value1, REAL value2)
- Parameters:
cond (boolean)
value1 (REAL)
value2 (REAL)
- ite(boolean cond, std_logic value1, std_logic value2)
- Parameters:
cond (boolean)
value1 (std_logic)
value2 (std_logic)
- ite(boolean cond, std_logic_vector value1, std_logic_vector value2)
- Parameters:
cond (boolean)
value1 (std_logic_vector)
value2 (std_logic_vector)
- ite(boolean cond, bit_vector value1, bit_vector value2)
- Parameters:
cond (boolean)
value1 (bit_vector)
value2 (bit_vector)
- ite(boolean cond, unsigned value1, unsigned value2)
- Parameters:
cond (boolean)
value1 (unsigned)
value2 (unsigned)
- ite(boolean cond, signed value1, signed value2)
- Parameters:
cond (boolean)
value1 (signed)
value2 (signed)
- ite(boolean cond, character value1, character value2)
- Parameters:
cond (boolean)
value1 (character)
value2 (character)
- ite(boolean cond, string value1, string value2)
- Parameters:
cond (boolean)
value1 (string)
value2 (string)
- inc_if(boolean cond, integer value, integer increment = 1)
conditional increment / decrement
- Parameters:
cond (boolean)
value (integer)
increment (integer)
- dec_if(boolean cond, integer value, integer decrement = 1)
- Parameters:
cond (boolean)
value (integer)
decrement (integer)
- imin(integer arg1, integer arg2)
Max / Min / Sum ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Parameters:
arg1 (integer)
arg2 (integer) -- Calculates: min(arg1, arg2) for integers
- imin(T_INTVEC vec)
function rmin(arg1 : real; arg2 : real) return real; -- Calculates: min(arg1, arg2) for reals Calculates: min(vec) for a integer vector
- Parameters:
vec (T_INTVEC)
- imin(T_NATVEC vec)
Calculates: min(vec) for a natural vector
- Parameters:
vec (T_NATVEC)
- imin(T_POSVEC vec)
Calculates: min(vec) for a positive vector
- Parameters:
vec (T_POSVEC)
- rmin(T_REALVEC vec)
Calculates: min(vec) of real vector
- Parameters:
vec (T_REALVEC)
- imax(integer arg1, integer arg2)
- Parameters:
arg1 (integer)
arg2 (integer) -- Calculates: max(arg1, arg2) for integers
- imax(T_INTVEC vec)
function rmax(arg1 : real; arg2 : real) return real; -- Calculates: max(arg1, arg2) for reals Calculates: max(vec) for a integer vector
- Parameters:
vec (T_INTVEC)
- imax(T_NATVEC vec)
Calculates: max(vec) for a natural vector
- Parameters:
vec (T_NATVEC)
- imax(T_POSVEC vec)
Calculates: max(vec) for a positive vector
- Parameters:
vec (T_POSVEC)
- rmax(T_REALVEC vec)
Calculates: max(vec) of real vector
- Parameters:
vec (T_REALVEC)
- isum(T_NATVEC vec)
Calculates: sum(vec) for a natural vector
- Parameters:
vec (T_NATVEC)
- isum(T_POSVEC vec)
Calculates: sum(vec) for a positive vector
- Parameters:
vec (T_POSVEC)
- isum(T_INTVEC vec)
Calculates: sum(vec) of integer vector
- Parameters:
vec (T_INTVEC)
- rsum(T_REALVEC vec)
Calculates: sum(vec) of real vector
- Parameters:
vec (T_REALVEC)
- to_int(boolean bool, integer zero = 0, integer one = 1)
to integer: to_int
- Parameters:
bool (boolean)
zero (integer)
one (integer)
- to_int(std_logic sl, integer zero = 0, integer one = 1)
- Parameters:
sl (std_logic)
zero (integer)
one (integer)
- to_sl(boolean Value)
to std_logic: to_sl
- Parameters:
Value (boolean)
- to_sl(character Value)
- Parameters:
Value (character)
- to_slv(natural Value, positive Size)
to std_logic_vector: to_slv
- Parameters:
Value (natural)
Size (positive) -- short for std_logic_vector(to_unsigned(Value, Size))
- to_BCD(integer Digit)
- Parameters:
Digit (integer)
- Return type:
- to_BCD(character Digit)
- Parameters:
Digit (character)
- Return type:
- to_BCD(unsigned Digit)
- Parameters:
Digit (unsigned)
- Return type:
- to_BCD(std_logic_vector Digit)
- Parameters:
Digit (std_logic_vector)
- Return type:
- to_BCD_Vector(integer Value, natural Size = 0, T_BCD Fill = x\"0\")
- Parameters:
Value (integer)
Size (natural)
Fill (T_BCD)
- Return type:
- to_BCD_Vector(string Value, natural Size = 0, T_BCD Fill = x\"0\")
- Parameters:
Value (string)
Size (natural)
Fill (T_BCD)
- Return type:
- bound(integer index, integer lowerBound, integer upperBound)
TODO: comment
- Parameters:
index (integer)
lowerBound (integer)
upperBound (integer)
- to_index(unsigned slv, natural max = 0)
- Parameters:
slv (unsigned)
max (natural)
- to_index(std_logic_vector slv, natural max = 0)
- Parameters:
slv (std_logic_vector)
max (natural)
- is_sl(character c)
is_*
- Parameters:
c (character)
- slv_or(std_logic_vector vec)
Aggregate functions
- Parameters:
vec (std_logic_vector)
- slv_nor(std_logic_vector vec)
- Parameters:
vec (std_logic_vector)
- slv_and(std_logic_vector vec)
- Parameters:
vec (std_logic_vector)
- slv_nand(std_logic_vector vec)
- Parameters:
vec (std_logic_vector)
- slv_xor(std_logic_vector vec)
- Parameters:
vec (std_logic_vector)
- reverse(std_logic_vector vec)
Reverses the elements of the passed Vector.
@synthesis supported
- Parameters:
vec (std_logic_vector)
- reverse(bit_vector vec)
- Parameters:
vec (bit_vector)
- reverse(unsigned vec)
- Parameters:
vec (unsigned)
- scale(integer Value, integer Minimum, integer Maximum, T_ROUNDING_STYLE RoundingStyle = ROUND\_TO\_NEAREST)
scale a value into a range [Minimum, Maximum]
- Parameters:
Value (integer)
Minimum (integer)
Maximum (integer)
RoundingStyle (T_ROUNDING_STYLE)
- scale(REAL Value, integer Minimum, integer Maximum, T_ROUNDING_STYLE RoundingStyle = ROUND\_TO\_NEAREST)
- Parameters:
Value (REAL)
Minimum (integer)
Maximum (integer)
RoundingStyle (T_ROUNDING_STYLE)
- scale(REAL Value, REAL Minimum, REAL Maximum)
- Parameters:
Value (REAL)
Minimum (REAL)
Maximum (REAL)
- resize(bit_vector vec, natural length, bit fill = \'0\')
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
- Parameters:
vec (bit_vector)
length (natural)
fill (bit)
- resize(std_logic_vector vec, natural length, std_logic fill = \'0\')
- Parameters:
vec (std_logic_vector)
length (natural)
fill (std_logic)
- move(std_logic_vector vec, integer ofs)
Shift the index range of a vector by the specified offset.
- Parameters:
vec (std_logic_vector)
ofs (integer)
- movez(std_logic_vector vec)
Shift the index range of a vector making vec'low = 0.
- Parameters:
vec (std_logic_vector)
- ascend(std_logic_vector vec)
- Parameters:
vec (std_logic_vector)
- descend(std_logic_vector vec)
- Parameters:
vec (std_logic_vector)
- lssb(std_logic_vector arg)
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
- Parameters:
arg (std_logic_vector)
- lssb(bit_vector arg)
- Parameters:
arg (bit_vector)
- lssb_idx(std_logic_vector arg)
Returns the index of the least-significant set bit.
@synthesis supported
- Parameters:
arg (std_logic_vector)
- lssb_idx(bit_vector arg)
- Parameters:
arg (bit_vector)
- mssb(std_logic_vector arg)
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.
- Parameters:
arg (std_logic_vector)
- mssb(bit_vector arg)
- Parameters:
arg (bit_vector)
- mssb_idx(std_logic_vector arg)
- Parameters:
arg (std_logic_vector)
- mssb_idx(bit_vector arg)
- Parameters:
arg (bit_vector)
- swap(std_logic_vector slv, positive Size)
Swap sub vectors in vector (endian reversal)
- Parameters:
slv (std_logic_vector)
Size (positive)
- bit_swap(std_logic_vector slv, positive Chunksize)
Swap the bits in a chunk
- Parameters:
slv (std_logic_vector)
Chunksize (positive)
- genmask_high(natural Bits, positive MaskLength)
generate bit masks
- Parameters:
Bits (natural)
MaskLength (positive)
- genmask_low(natural Bits, positive MaskLength)
- Parameters:
Bits (natural)
MaskLength (positive)
- genmask_alternate(positive len, std_logic lsb = \'0\')
- Parameters:
len (positive)
lsb (std_logic)
- onehot2bin(std_logic_vector onehot, integer empty_val = - 1)
Encodings
- 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.
- param std_logic_vector onehot:
- param integer empty_val:
- gray2bin(std_logic_vector gray_val)
Converts Gray-Code into Binary-Code.
@synthesis supported
- Parameters:
gray_val (std_logic_vector)
- gray2bin(std_logic_vector gray_val)
- Parameters:
gray_val (std_logic_vector)
- bin2onehot(std_logic_vector value)
Binary-Code to One-Hot-Code
- Parameters:
value (std_logic_vector)
- bin2onehot(unsigned value)
- Parameters:
value (unsigned)
- bin2onecold(std_logic_vector value)
Binary-Code to One-Cold-Code
- Parameters:
value (std_logic_vector)
- bin2onecold(unsigned value)
- Parameters:
value (unsigned)
- bin2gray(std_logic_vector value)
Binary-Code to Gray-Code
- Parameters:
value (std_logic_vector)
- bin2gray(unsigned value)
- Parameters:
value (unsigned)