It is designed to allow you to test X recorders before placing them in the field to gather important data. With it you can identify potential problems before they occur, saving time and money.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter is
generic
(
data_width : positive := 32
);
port
(
clk : in std_logic;
rst_n : in std_logic;
start : in std_logic;
count : out std_logic_vector (data_width - 1 downto 0)
);
end counter;
architecture Behavioral of counter is
signal start_r,start_r2 : std_logic;
signal count_i : std_logic_vector (data_width - 1 downto 0);
begin
process (clk, rst_n)
begin
if (rising_edge(clk)) then
if(rst_n = '0') then
start_r <= '0';
start_r2 <= '0';
count_i <= (others => '0');
else
start_r <= start;
start_r2 <= start_r;
if(start_r = '1' and start_r2 = '0') then
count_i <= (others => '0');
elsif(start_r = '1') then
count_i <= count_i + '1';
end if;
end if;
end if;
end process;
count <= count_i;
end Behavioral;