ROD firmware  1.0.5
ATLAS l1-calo - ROD_eFEX and ROD_jFEX firmware for the L1Calo ROD board

Back to ROD documentation
watchdog.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 20.08.2021 14:53:17
6 -- Design Name:
7 -- Module Name: watchdog - RTL
8 -- Project Name:
9 -- Target Devices:
10 -- Tool Versions:
11 -- Description:
12 --
13 -- Dependencies:
14 --
15 -- Revision:
16 -- Revision 0.01 - File Created
17 -- Additional Comments:
18 --
19 ----------------------------------------------------------------------------------
20 library IEEE;
21 use IEEE.STD_LOGIC_1164.ALL;
22 use IEEE.STD_LOGIC_UNSIGNED.ALL;
23 
24 -- Uncomment the following library declaration if using
25 -- arithmetic functions with Signed or Unsigned values
26 --use IEEE.NUMERIC_STD.ALL;
27 
28 -- Uncomment the following library declaration if instantiating
29 -- any Xilinx leaf cells in this code.
30 --library UNISIM;
31 --use UNISIM.VComponents.all;
32 
33 entity watchdog is
34  generic (
35  overflow_clock_count : std_logic_vector(7 downto 0) := x"0f";
36  counter_width : integer := 19;
37  msb : integer := (counter_width - 1);
38  lsb : integer := (counter_width - 16)
39  );
40  Port ( pp_clock : in STD_LOGIC;
41  reset_in : in STD_LOGIC;
42  wdog_disable : in STD_LOGIC;
43  wdog_pet : in STD_LOGIC;
44  wdog_threshold : in STD_LOGIC_VECTOR (15 downto 0);
45  wdog_overflow : out STD_LOGIC);
46 end watchdog;
47 
48 architecture RTL of watchdog is
49 
50 signal wd_counter : std_logic_vector(msb downto 0) := (others => '0');
51 signal overflow_i : std_logic := '0';
52 signal output_timer : std_logic_vector(7 downto 0) := x"00";
53 signal wdog_overflow_i : std_logic;
54 
55 begin
56 
57 process (pp_clock) begin
58  if rising_edge (pp_clock) then
59  if (reset_in = '1') or (overflow_i = '1') or (wdog_pet = '1') or (wdog_disable = '1') then
60  wd_counter <= (others => '0');
61  else wd_counter <= wd_counter + '1';
62  end if;
63  end if;
64 end process;
65 
66 process (pp_clock) begin
67  if rising_edge (pp_clock) then
68  if wd_counter(msb downto lsb) = wdog_threshold then
69  overflow_i <= '1';
70  else
71  overflow_i <= '0';
72  end if;
73  end if;
74 end process;
75 
76 --wdog_overflow <= overflow_i;
77 process (pp_clock) begin
78  if rising_edge (pp_clock) then
79 -- if (reset_in = '1' or wdog_disable = '1') then
80  if (wdog_disable = '1') then
81  output_timer <= x"00";
82  elsif (overflow_i = '1') then
83  output_timer <= overflow_clock_count;
84  elsif (output_timer /= x"00") then
85  output_timer <= (output_timer - '1');
86  else
87  output_timer <= x"00";
88  end if;
89  end if;
90  end process;
91 
92 wdog_overflow_i <= OR (output_timer);
93 wdog_overflow <= wdog_overflow_i;
94 end RTL;
95 
96