eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
counter.vhd
Go to the documentation of this file.
1 
8 library IEEE;
9 use IEEE.STD_LOGIC_1164.all;
10 use IEEE.NUMERIC_STD.all;
12 entity counter is
13  generic (DEPTH : integer := 16);
14  port (
16  clk : in std_logic;
18  enable1 : in std_logic;
20  enable2 : in std_logic := '1';
22  count : out std_logic_vector (DEPTH - 1 downto 0);
24  saturated : out std_logic;
26  reset : in std_logic
27  );
28 
29 end counter;
31 architecture Behavioral of counter is
32  signal cntr : unsigned (DEPTH-1 downto 0);
33  signal enable2_i, enable1_i, RESET_i : std_logic; -- added by ST to remove timing error 18.03.2020
34  constant ones : unsigned(DEPTH-1 downto 0) := (others => '1');
35 begin
36  process(clk)
37  begin
38  if clk' event and clk = '1' then
39  enable2_i <= enable2;
40  RESET_i <= RESET;
41  enable1_i <= enable1;
42  if RESET_i = '1' then
43  cntr <= (others => '0');
44  saturated <= '0';
45  elsif (enable1_i = '1' and enable2_i = '1') then
46  if cntr = ones then
47  cntr <= cntr;
48  saturated <= '1';
49  else
50  cntr <= cntr + 1;
51  saturated <= '0';
52  end if;
53  else
54  cntr <= cntr;
56  end if;
57  end if;
58  end process;
59 
60  count <= std_logic_vector(cntr);
61 
62 end Behavioral;
Counter with double enable.
Definition: counter.vhd:31
Counter with double enable.
Definition: counter.vhd:12
in reset std_logic
reset
Definition: counter.vhd:27
in enable1 std_logic
enable 1
Definition: counter.vhd:18
in clk std_logic
clock
Definition: counter.vhd:16
out count std_logic_vector( DEPTH- 1 downto 0)
counter value
Definition: counter.vhd:22
in enable2 std_logic := '1'
enable 2
Definition: counter.vhd:20
out saturated std_logic
counter value
Definition: counter.vhd:24