bit_ops¶
Description¶
This package provides components that count the number of set bits in a vector. Multiple implementations are available with different performance characteristics.
Example usage¶
signal value : unsigned(11 downto 0);
signal ones_count : unsigned(bit_size(value'length)-1 downto 0);
-- Basic combinational circuit:
basic: count_ones
port map (
Value => value,
Ones_count => ones_count
);
-- Chunked combinational circuit:
basic: count_ones_chunked
generic map (
TABLE_BITS => 4 -- Constant table with 16 entries
)
port map (
Value => value,
Ones_count => ones_count
);
-- Chunked sequential circuit:
basic: count_ones_chunked
generic map (
TABLE_BITS => 4 -- Constant table with 16 entries
)
port map (
Clock => clock,
Reset => reset,
Start => start,
Busy => busy,
Done => done,
Value => value,
Ones_count => ones_count
);
Components¶
count_ones¶
-
bit_ops.
count_ones
¶ Count the number of set bits in a vector.
Port: - Value (in unsigned) – Vector to count set bits
- Ones_count (out unsigned) – Number of set bits in
Value
count_ones_chunked¶
-
bit_ops.
count_ones_chunked
¶ Count the number of set bits in a vector with a reduced constant table.
Generics: - TABLE_BITS (positive) – Number of bits for constant table
Port: - Value (in unsigned) – Vector to count set bits
- Ones_count (out unsigned) – Number of set bits in
Value
count_ones_sequential¶
-
bit_ops.
count_ones_sequential
¶ Count the number of set bits in a vector with a reduced constant table.
Generics: - TABLE_BITS (positive) – Number of bits for constant table
- RESET_ACTIVE_LEVEL (std_ulogic) – Asynch. reset control level
Port: - Clock (in std_ulogic) – System clock
- Reset (in std_ulogic) – Asynchronous reset
- Start (in std_ulogic) – Start counting
- Busy (out std_ulogic) – Count is in progress
- Done (out std_ulogic) – Count is done
- Value (in unsigned) – Vector to count set bits
- Ones_count (out unsigned) – Number of set bits in
Value