This package contains miscellaneous bit mangling, err, manipulation functions:
function bit_reverse
(A : in std_ulogic_vector)
return std_ulogic_vector;
reverses the bits in A. Example:
bit_reverse("1101000") => "0001011"
The result type is std_ulogic_vector(A'length-1 downto 0).
function bit_extract
(A : in std_ulogic_vector;
N : in positive;
O : in natural := 0)
return std_ulogic_vector;
extracts every N'th bit from A, starting with bit O (counted from the right). Example:
bit_extract("100100", 3, 2) => "11"
The result type is std_ulogic_vector(X-1 downto 0)
where X := (A'length + N - O - 1) / N.
function bit_duplicate
(A : in std_ulogic_vector;
N : in positive)
return std_ulogic_vector;
duplicates A bitwise, N times. Example:
bit_duplicate("101", 3) => "111000111"
The result type is std_ulogic_vector(N*A'length-1 downto 0).
function vector_duplicate
(A : in std_ulogic_vector;
N : in positive)
return std_ulogic_vector;
duplicates A as a whole, N times. Example:
vector_duplicate("101", 3) => "101101101"
The result type is std_ulogic_vector(N*A'length-1 downto 0).
function cascade_and
(A : in std_ulogic_vector)
return std_ulogic_vector;
function cascade_or
(A : in std_ulogic_vector)
return std_ulogic_vector;
perform AND and OR cascading operations, from right to left.
The actual implementation is more efficient, however :-) Example:
The result type is std_ulogic_vector(A'length-1 downto 0).
perform the AND, OR and XOR operations,
respectively, over all bits of A.
The result type is std_ulogic.
perform the left/right shift operations.
Shifted-in bits will have the value
of C. Note that the N
operand is not restricted
to A'length. That is, if N >= A'length,
all result bits will equal C.
The result type is std_ulogic_vector(A'length-1 downto 0).
is equivalent to lshift(A, N, '0').
is equivalent to lshift(A, N, A(A'right)).
is equivalent to rshift(A, N, '0').
is equivalent to rshift(A, N, A(A'left)).
rotate A left and right, respectively,
by N mod A'length bits.
The result type is std_ulogic_vector(A'length-1 downto 0).
cascade_and("01100111") => "00000111"
cascade_or("01100111") => "01111111"
function reduce_and
(A : in std_ulogic_vector)
return std_ulogic;
function reduce_xor
(A : in std_ulogic_vector)
return std_ulogic;
function reduce_or
(A : in std_ulogic_vector)
return std_ulogic;
function lshift
(A : in std_ulogic_vector;
N : in natural;
C : in std_ulogic)
return std_ulogic_vector;
function rshift
(A : in std_ulogic_vector;
N : in natural;
C : in std_ulogic)
return std_ulogic_vector;
function lshift
(A : in std_ulogic_vector;
N : in natural)
return std_ulogic_vector;
function lshifta
(A : in std_ulogic_vector;
N : in natural)
return std_ulogic_vector;
function rshift
(A : in std_ulogic_vector;
N : in natural)
return std_ulogic_vector;
function rshifta
(A : in std_ulogic_vector;
N : in natural)
return std_ulogic_vector;
function lrotate
(A : in std_ulogic_vector;
N : in natural)
return std_ulogic_vector;
function rrotate
(A : in std_ulogic_vector;
N : in natural)
return std_ulogic_vector;