Subversion Repositories ngs

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 lvd 1
// part of NeoGS project (c) 2007-2008 NedoPC
2
//
3
 
4
 
5
module resetter(
6
 
7
        clk,
8
 
9
        rst_in1_n,
10
        rst_in2_n,
11
 
12
        rst_out_n );
13
 
14
parameter RST_CNT_SIZE = 3;
15
 
16
 
17
        input clk;
18
 
19
        input rst_in1_n; // input of external asynchronous reset 1
20
        input rst_in2_n; // input of external asynchronous reset 2
21
 
22
        output reg rst_out_n; // output of end-synchronized reset (beginning is asynchronous to clock)
23
 
24
 
25
 
26
        reg [RST_CNT_SIZE:0] rst_cnt; // one bit more for counter stopping
27
 
28
        reg rst1_n,rst2_n;
29
 
30
        wire resets_n;
31
 
32
 
33
        assign resets_n = rst_in1_n & rst_in2_n;
34
 
35
        always @(posedge clk, negedge resets_n)
36
        if( !resets_n ) // external asynchronous reset
37
        begin
38
                rst_cnt <= 0;
39
 
40
                rst1_n <= 1'b0;
41
                rst2_n <= 1'b0; // sync in reset end
42
 
43
                rst_out_n <= 1'b0; // this zeroing also happens after FPGA configuration, so also power-up reset happens
44
        end
45
        else // clocking
46
        begin
47
                rst1_n <= 1'b1;
48
                rst2_n <= rst1_n;
49
 
50
                if( rst2_n && !rst_cnt[RST_CNT_SIZE] )
51
                begin
52
                        rst_cnt <= rst_cnt + 1;
53
                end
54
 
55
                rst_out_n <= rst_cnt[RST_CNT_SIZE];
56
        end
57
 
58
 
59
endmodule
60