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

Subversion Repositories mpeg2fpga

[/] [mpeg2fpga/] [trunk/] [rtl/] [mpeg2/] [reset.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kdv
/*
2
 * reset.v
3
 *
4
 * Copyright (c) 2007 Koen De Vleeschauwer.
5
 *
6
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
7
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
10
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16
 * SUCH DAMAGE.
17
 */
18
 
19
/*
20
 * Generate reset signals.
21
 *   Accepts an asynchronous reset signal, and generates reset signals in the clk, mem_clk and dot_clk domains
22
 *   which are at least three clock cycles long.
23
 *
24
 * Xilinx FIFO18/FIFO36 primitives:
25
 * "The reset signal must be high for at least three read clock and three write clock cycles."
26
 *
27
 */
28
 
29
`include "timescale.v"
30
 
31
module reset (clk, mem_clk, dot_clk, async_rst, watchdog_rst,
32
              clk_rst, mem_rst, dot_rst, hard_rst);
33
 
34
  input clk;                  /* decoder clock */
35
  input mem_clk;              /* memory clock */
36
  input dot_clk;              /* pixel clock */
37
  input async_rst;            /* global reset, asynchronous. */
38
  input watchdog_rst;         /* watchdog-generated reset, synchronous with clk. Goes low when watchdog timer expires. */
39
  output clk_rst;             /* global reset, synchronized to decoder clock. Goes low when "async_rst" or "watchdog_rst" goes low. */
40
  output mem_rst;             /* global reset, synchronized to memory clock. Goes low when "async_rst" or "watchdog_rst" goes low. */
41
  output dot_rst;             /* global reset, synchronized to pixel clock. Goes low when "async_rst" or "watchdog_rst" goes low. */
42
  output hard_rst;            /* "hard" reset signal. Goes low when "async_rst" input pin goes low. */
43
 
44
  /* synchronize async_rst and watchdog with clk */
45
 
46
  wire clk_rst_0;
47
  wire clk_watchdog_0;
48
 
49
  sync_reset clk_sreset_0 (
50
    .clk(clk),
51
    .asyncrst(async_rst),
52
    .syncrst(clk_rst_0)
53
    );
54
 
55
  sync_reset clk_swatchdog_0 (
56
    .clk(clk),
57
    .asyncrst(watchdog_rst),
58
    .syncrst(clk_watchdog_0)
59
    );
60
 
61
  /* combine async_rst and watchdog into a common reset signal */
62
  wire comm_rst = clk_rst_0 && clk_watchdog_0;
63
 
64
  /* synchronize common reset signal to the three system clocks */
65
  wire clk_rst_1;
66
  wire mem_rst_1;
67
  wire dot_rst_1;
68
 
69
  sync_reset clk_sreset_1 (
70
    .clk(clk),
71
    .asyncrst(comm_rst),
72
    .syncrst(clk_rst_1)
73
    );
74
 
75
  sync_reset mem_sreset_1 (
76
    .clk(mem_clk),
77
    .asyncrst(comm_rst),
78
    .syncrst(mem_rst_1)
79
    );
80
 
81
  sync_reset dot_sreset_1 (
82
    .clk(dot_clk),
83
    .asyncrst(comm_rst),
84
    .syncrst(dot_rst_1)
85
    );
86
 
87
  /*
88
   * combine all three resets - this produces a reset which is at least three clock cycles long in any clock domain
89
   */
90
 
91
  wire global_rst = clk_rst_1 && mem_rst_1 && dot_rst_1;
92
 
93
  /*
94
   * Now synchronize global reset back to the individual clocks
95
   */
96
 
97
  sync_reset clk_sreset_2 (
98
    .clk(clk),
99
    .asyncrst(global_rst),
100
    .syncrst(clk_rst)
101
    );
102
 
103
  sync_reset mem_sreset_2 (
104
    .clk(mem_clk),
105
    .asyncrst(global_rst),
106
    .syncrst(mem_rst)
107
    );
108
 
109
  sync_reset dot_sreset_2 (
110
    .clk(dot_clk),
111
    .asyncrst(global_rst),
112
    .syncrst(dot_rst)
113
    );
114
 
115
  /*
116
   * "Hard" reset signal. Goes low when the "rst" input pin goes low.
117
   * Use two synchronizers so delay from async_rst to hard_rst is the same as the delay from async_rst to clk_rst.
118
   */
119
 
120
  wire hard_rst_1;
121
 
122
  sync_reset hard_sreset_1 (
123
    .clk(clk),
124
    .asyncrst(clk_rst_0),
125
    .syncrst(hard_rst_1)
126
    );
127
 
128
  sync_reset hard_sreset_2 (
129
    .clk(clk),
130
    .asyncrst(hard_rst_1),
131
    .syncrst(hard_rst)
132
    );
133
 
134
endmodule
135
/* not truncated */
136
 

powered by: WebSVN 2.1.0

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