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

Back to eFEX documentation
cntr_up_dn_generic.vhd
Go to the documentation of this file.
1 
11 
12 
13 library IEEE;
14 use IEEE.STD_LOGIC_1164.ALL;
15 USE ieee.std_logic_arith.all;
16 
19  generic (
20  width : integer := 16
21  );
22  Port (
24  CE : in STD_LOGIC;
26  CLK : in STD_LOGIC;
28  RST : in STD_LOGIC;
30  UP : in STD_LOGIC;
32  DOWN : in STD_LOGIC;
34  Q : out STD_LOGIC_VECTOR (width-1 downto 0)
35  );
37 
39 architecture Behavioral of cntr_up_dn_generic is
40 
41  signal temp : unsigned (width-1 downto 0) ;
42 
43 begin
44 process (CLK)
45  begin
46  if CLK'event AND CLK = '1' then
47  if RST = '1' then -- this is a synchronous reset
48  temp <= (others => '0'); -- set counter to offset value given.
49  else
50  if UP = '1' AND DOWN = '0'then
51  temp <= temp + 1; -- else increment the value by one
52  else
53  if UP = '0' AND DOWN = '1' then
54  if temp > 0 then -- if count > 0
55  temp <= temp - 1; -- else decrement the value by one
56  end if;
57  else
58  temp <= temp; -- do nothing
59  end if;
60  end if;
61  end if;
62  end if;
63  end process;
64  Q <= std_logic_vector(temp) ; -- push out new value
65 
66 end Behavioral;
in CLK STD_LOGIC
Clock signal input.
in DOWN STD_LOGIC
Count DOWN 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.
in UP STD_LOGIC
Count UP signal input.