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

Back to eFEX documentation
cntr_generic.vhd
Go to the documentation of this file.
1 
10 
11 library IEEE;
12 use IEEE.STD_LOGIC_1164.ALL;
13 USE ieee.std_logic_arith.all;
14 
16 entity cntr_generic is
17  generic (
18  width : integer := 32;
19  WRAPAROUND : boolean := True
20  );
21  Port (
23  CE : in STD_LOGIC;
25  CLK : in STD_LOGIC;
27  RST : in STD_LOGIC;
29  Q : out STD_LOGIC_VECTOR (width-1 downto 0)
30  );
31 end cntr_generic;
32 
34 architecture Behavioral of cntr_generic is
35 
36 begin
37 process (CLK)
38  variable temp : unsigned (width-1 downto 0);
39  constant maxval: unsigned (width-1 downto 0) := (Others => '1');
40  begin
41  if CLK'event AND CLK = '1' then
42  if RST = '1' then -- this is a synchronous reset
43  temp := (others => '0'); -- set counter to offset value given.
44  else
45  if (CE = '1') and (WRAPAROUND or (temp /= maxval)) then
46  temp := temp + 1; -- else increment the value by one
47  end if;
48  end if;
49  end if;
50  Q <= std_logic_vector(temp) ; -- push out new value
51  end process;
52 
53 end Behavioral;
Generic Counter for process FPGA.
Generic Counter for process FPGA.
in CLK STD_LOGIC
Clock signal input.
in CE STD_LOGIC
Enable signal input.
out Q STD_LOGIC_VECTOR( width- 1 downto 0)
Counter Output signal.
in RST STD_LOGIC
Reset signal input.