SURF  1.0
WatchDogRst.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : WatchDogRst.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-06-17
5 -- Last update: 2014-06-17
6 -------------------------------------------------------------------------------
7 -- Description: Watch Dog Reset module
8 -------------------------------------------------------------------------------
9 -- This file is part of 'SLAC Firmware Standard Library'.
10 -- It is subject to the license terms in the LICENSE.txt file found in the
11 -- top-level directory of this distribution and at:
12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
13 -- No part of 'SLAC Firmware Standard Library', including this file,
14 -- may be copied, modified, propagated, or distributed except according to
15 -- the terms contained in the LICENSE.txt file.
16 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.std_logic_unsigned.all;
21 use ieee.std_logic_arith.all;
22 
23 use work.StdRtlPkg.all;
24 
25 --! @see entity
26  --! @ingroup base_general
27 entity WatchDogRst is
28  generic (
29  TPD_G : time := 1 ns;
30  IN_POLARITY_G : sl := '1';
31  OUT_POLARITY_G : sl := '1';
32  USE_DSP48_G : string := "no";
33  DURATION_G : natural range 0 to ((2**31)-1) := 156250000);
34  port (
35  clk : in sl;
36  monIn : in sl;
37  rstOut : out sl);
38 end WatchDogRst;
39 
40 architecture rtl of WatchDogRst is
41 
42  signal rst : sl := not(OUT_POLARITY_G);
43  signal monInput : sl;
44 
45  signal cnt : natural range 0 to DURATION_G := 0;
46 
47  attribute use_dsp48 : string;
48  attribute use_dsp48 of cnt : signal is USE_DSP48_G;
49 
50 begin
51 
52  -- USE_DSP48_G check
53  assert ((USE_DSP48_G = "yes") or (USE_DSP48_G = "no") or (USE_DSP48_G = "auto") or (USE_DSP48_G = "automax"))
54  report "USE_DSP48_G must be either yes, no, auto, or automax"
55  severity failure;
56 
57  Synchronizer_Inst : entity work.Synchronizer
58  generic map (
59  TPD_G => TPD_G)
60  port map (
61  clk => clk,
62  dataIn => monIn,
63  dataOut => monInput);
64 
65  process (clk)
66  begin
67  if rising_edge(clk) then
68  -- Reset the flag
69  rst <= not(OUT_POLARITY_G) after TPD_G;
70  -- Check the monitoring input
71  if monInput = IN_POLARITY_G then
72  -- Reset the counter
73  cnt <= 0 after TPD_G;
74  else
75  -- Increment the counter
76  cnt <= cnt + 1 after TPD_G;
77  -- Check the counter value
78  if cnt = DURATION_G then
79  -- Reset the counter
80  cnt <= 0 after TPD_G;
81  -- Set the flag
82  rst <= OUT_POLARITY_G after TPD_G;
83  end if;
84  end if;
85  end if;
86  end process;
87 
88  rstOut <= rst;
89 
90 end rtl;
_library_ ieeeieee
Definition: TextUtilPkg.vhd:18
out rstOutsl
Definition: WatchDogRst.vhd:37
TPD_Gtime := 1 ns
Definition: WatchDogRst.vhd:29
std_logic sl
Definition: StdRtlPkg.vhd:28
DURATION_Gnatural range 0 to (( 2** 31)- 1):= 156250000
Definition: WatchDogRst.vhd:33
USE_DSP48_Gstring := "no"
Definition: WatchDogRst.vhd:32
IN_POLARITY_Gsl := '1'
Definition: WatchDogRst.vhd:30
out dataOutsl
TPD_Gtime := 1 ns
OUT_POLARITY_Gsl := '1'
Definition: WatchDogRst.vhd:31