OpenCores
URL https://opencores.org/ocsvn/mcip_open/mcip_open/trunk

Subversion Repositories mcip_open

[/] [mcip_open/] [trunk/] [Watchdog.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 mezzah
----------------------------------------------------------------------------------
2
-- Company:        Ferhat Abbas University - Algeria
3
-- Engineer:       Ibrahim MEZZAH
4
-- 
5
-- Create Date:    17:56:57 04/12/2012 
6
-- Design Name: 
7
-- Module Name:    Watchdog - Behavioral 
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
 
25
entity Watchdog is
26
         Generic(WDTPS : std_logic_vector(3 downto 0) := "0100"; -- Watchdog Timer Postscale Select bits
27
                                WDTEN : std_logic := '0'); -- Watchdog Timer enable bit
28
 
29
    Port ( nreset       : in std_logic;
30
           WDT_clock    : in std_logic;
31
           Q1           : in std_logic;
32
           Q4           : in std_logic;
33
           RE           : in std_logic;
34
           WE           : in std_logic;
35
           clrWDT       : in std_logic;
36
           Sleep                   : in std_logic;
37
           DATA         : inout std_logic_vector(7 downto 0);
38
           WDT_reset    : out std_logic;
39
           WDTwake_up   : out std_logic);
40
end Watchdog;
41
 
42
architecture Behavioral of Watchdog is
43
 
44
  signal data_write_0 : std_logic;
45
  signal data_read : std_logic_vector(7 downto 0);
46
 
47
  signal SWDTEN : std_logic;
48
 
49
  signal Reset : std_logic;
50
  signal Wake_up : std_logic;
51
 
52
  signal Sleep_state : std_logic;
53
 
54
  signal WDT_Posts_counter : std_logic_vector(conv_integer(WDTPS)+6 downto 0);
55
  signal Postscaler_output : std_logic;
56
 
57
begin
58
 
59
        data_read <= "0000000"&SWDTEN; -- WDTCON
60
        data_write_0 <= DATA(0);
61
 
62
        DATA <= data_read                                                        when RE = '1' and Q1 = '1' else
63
                          (others => 'Z');
64
 
65
        Postscaler_output <= WDT_Posts_counter(conv_integer(WDTPS)+6);
66
 
67
        WDTCON : process(nreset, Q4, WE, data_write_0)
68
        begin
69
                if nreset = '0' then
70
                                SWDTEN <= WDTEN;
71
                elsif Q4'event and Q4 = '1' then
72
                        if WE = '1' then
73
                                SWDTEN <= data_write_0;
74
                        else
75
                                SWDTEN <= SWDTEN;
76
                        end if;
77
                end if;
78
        end process;
79
 
80
        Counter : process(nreset, SWDTEN, Sleep, WDT_clock, clrWDT, Sleep_state)
81
        begin
82
          if nreset = '0' or SWDTEN = '0' or (Sleep = '1' and Sleep_state = '0') or clrWDT = '1' then
83
                        WDT_Posts_counter <= (others => '0');
84
          elsif WDT_clock'event and WDT_clock = '0' then
85
                        WDT_Posts_counter <= WDT_Posts_counter + "1";
86
          end if;
87
        end process;
88
 
89
        Sleep_control : process(nreset, Sleep, Q4)
90
        begin
91
          if nreset = '0' or Sleep = '0' then
92
                        Sleep_state <= '0';
93
          elsif Q4'event and Q4 = '0' then
94
                        Sleep_state <= '1';
95
          end if;
96
        end process;
97
 
98
        WakeUp : process(nreset, Postscaler_output, Sleep)
99
        begin
100
          if nreset = '0' or Sleep = '0' then
101
                        Wake_up <= '0';
102
          elsif Postscaler_output'event and Postscaler_output = '0' then
103
                        Wake_up <= '1';
104
          end if;
105
        end process;
106
 
107
        Reset_signal : process(nreset, Postscaler_output, Sleep)
108
        begin
109
          if nreset = '0' or Sleep = '1' then
110
                        Reset <= '0';
111
          elsif Postscaler_output'event and Postscaler_output = '0' then
112
                        Reset <= '1';
113
          end if;
114
        end process;
115
 
116
        WDT_reset <= Reset;
117
 
118
        WDTwake_up <= Wake_up;
119
 
120
 
121
end Behavioral;
122
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.