Counter#
Translation Stage: low level ir to vhdl
The plugin provides a counter implemented in vhdl.
Interface
entity counter is
generic (
MAX_VALUE : natural -- <1>
);
port (
clk : in std_logic;
rst : in std_logic; -- <2>
enable : in std_logic := '0'; -- <3>
d_out : out std_logic_vector(clog2(MAX_VALUE+1) - 1 downto 0) := (others => '0') -- <4>
);
end entity;
The maximum value of the counter. After reaching this value, the counter will reset to 0 when reaching the end of the process (ie. on the next change of
clk
).Holding the reset signal will reset the counter to 0.
The counter will increment on each rising edge of the clock signal while the enable signal is high.
The output of the counter as a
std_logic_vector
. Useto_unsigned(0, d_out'length)
to turn this into an unsigned number again.