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

Subversion Repositories watchdog

[/] [watchdog/] [tags/] [initial/] [rtl/] [verilog/] [watchdog.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 markom
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  WISHBONE rev.B2 compliant Watchdog timer                   ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Marko Mlinar                                       ////
7
////          markom@opencores.org                               ////
8
////                                                             ////
9
/////////////////////////////////////////////////////////////////////
10
////                                                             ////
11
//// Copyright (C) 2002 Marko Mlinar                             ////
12
////                    markom@opencores.org                     ////
13
////                                                             ////
14
//// This source file may be used and distributed without        ////
15
//// restriction provided that this copyright statement is not   ////
16
//// removed from the file and that any derivative work contains ////
17
//// the original copyright notice and the associated disclaimer.////
18
////                                                             ////
19
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
20
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
21
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
22
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
23
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
24
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
25
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
26
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
27
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
28
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
29
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
30
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
31
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
32
////                                                             ////
33
/////////////////////////////////////////////////////////////////////
34
 
35
/*
36
  Watchdog time functionality
37
  ===========================
38
 
39
  Watchdog timer has only one wishbone address, holding current counter
40
  value. Countdown timer decreases its contents by 1 each wishbone clock.
41
  When 0 is reached, interrupt is asserted. Interrupt is deasserted upon
42
  next read/write to watchdog timer register.
43
  If contents of the watchdog timer are -1 (e.g. 32'hffff_ffff), counter is
44
  stopped.
45
  Timer can start counting at wisbone reset, if `WDT_INITIAL != -1.
46
 
47
  For typical watchdog timer configuration wb_int_o signal should cause
48
  system reset.
49
*/
50
 
51
 
52
`include "timescale.v"
53
`include "watchdog_defines.v"
54
 
55
module watchdog(
56
        wb_clk_i, wb_rst_i, wb_dat_i, wb_dat_o,
57
        wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o,
58
        wb_int_o);
59
 
60
parameter Tp = 1;
61
 
62
// wishbone signals
63
input         wb_clk_i;     // master clock input
64
input         wb_rst_i;     // synchronous active high reset
65
input  [`WDT_WIDTH - 1:0] wb_dat_i;     // databus input
66
output [`WDT_WIDTH - 1:0] wb_dat_o;     // databus output
67
reg    [`WDT_WIDTH - 1:0] wb_dat_o;
68
input         wb_we_i;      // write enable input
69
input         wb_stb_i;     // stobe/core select signal
70
input         wb_cyc_i;     // valid bus cycle input
71
output        wb_ack_o;     // bus cycle acknowledge output
72
output        wb_int_o;     // interrupt request signal output
73
reg           wb_int_o;     // interrupt request signal output
74
 
75
reg           stb;
76
reg           we;
77
reg    [`WDT_WIDTH - 1:0] dat_ir;
78
 
79
assign        wb_ack_o = stb;
80
 
81
/* sample input signals */
82
always @(posedge wb_rst_i or posedge wb_clk_i)
83
  if (wb_rst_i) begin
84
    stb <= #Tp 1'b0;
85
    we <= #Tp 1'b0;
86
    dat_ir <= #Tp `WDT_WIDTH'h0;
87
  end else begin
88
    stb <= #Tp wb_stb_i && wb_cyc_i;
89
    we <= #Tp wb_we_i;
90
    dat_ir <= #Tp wb_dat_i;
91
  end
92
 
93
/* Counter */
94
always @(posedge wb_rst_i or posedge wb_clk_i)
95
  if (wb_rst_i) wb_dat_o <= #Tp `WDT_INITIAL;
96
  else if (stb && we) wb_dat_o <= #Tp dat_ir;
97
  else if (~&wb_dat_o) wb_dat_o <= #Tp wb_dat_o - `WDT_WIDTH'h1;
98
 
99
/* Interrupt */
100
always @(posedge wb_rst_i or posedge wb_clk_i)
101
  if (wb_rst_i) wb_int_o <= #Tp 1'b0;
102
  else if (stb) wb_int_o <= #Tp 1'b0;
103
  else if (~|wb_dat_o) wb_int_o <= #Tp 1'b1;
104
 
105
endmodule
106
 

powered by: WebSVN 2.1.0

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