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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc/] [boards/] [xsa-xst-3/] [src/] [clk_rst/] [clk_rst.v] - Blame information for rev 288

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 127 hellwig
//
2 224 hellwig
// clk_rst.v -- clock and reset generator
3 127 hellwig
//
4
 
5
 
6 224 hellwig
module clk_rst(clk_in, reset_inout_n,
7
               sdram_clk, sdram_fb,
8
               clk, clk_ok, reset);
9 27 hellwig
    input clk_in;
10
    inout reset_inout_n;
11
    output sdram_clk;
12
    input sdram_fb;
13
    output clk;
14
    output clk_ok;
15
    output reset;
16
 
17
  wire clk_in_buf;
18
  wire int_clk;
19
  wire int_locked;
20
  wire ext_rst_n;
21
  wire ext_fb;
22
  wire ext_locked;
23
 
24
  reg reset_p_n;
25
  reg reset_s_n;
26
  reg [23:0] reset_counter;
27
  wire reset_counting;
28
 
29 127 hellwig
  //------------------------------------------------------------
30 27 hellwig
 
31 127 hellwig
  IBUFG clk_in_buffer(
32
    .I(clk_in),
33
    .O(clk_in_buf)
34
  );
35 27 hellwig
 
36 127 hellwig
  DCM int_dcm(
37 27 hellwig
    .CLKIN(clk_in_buf),
38
    .CLKFB(clk),
39
    .RST(1'b0),
40
    .CLK0(int_clk),
41
    .LOCKED(int_locked)
42
  );
43
 
44 127 hellwig
  BUFG int_clk_buffer(
45
    .I(int_clk),
46
    .O(clk)
47
  );
48 27 hellwig
 
49 127 hellwig
  //------------------------------------------------------------
50 27 hellwig
 
51
  SRL16 ext_dll_rst_gen(
52
    .CLK(clk_in_buf),
53
    .D(int_locked),
54
    .Q(ext_rst_n),
55
    .A0(1'b1),
56
    .A1(1'b1),
57
    .A2(1'b1),
58
    .A3(1'b1)
59
  );
60
 
61
  defparam ext_dll_rst_gen.INIT = 16'h0000;
62
 
63 127 hellwig
  //------------------------------------------------------------
64 27 hellwig
 
65 127 hellwig
  IBUFG ext_fb_buffer(
66
    .I(sdram_fb),
67
    .O(ext_fb)
68
  );
69 27 hellwig
 
70 127 hellwig
  DCM ext_dcm(
71 27 hellwig
    .CLKIN(clk_in_buf),
72
    .CLKFB(ext_fb),
73
    .RST(~ext_rst_n),
74
    .CLK0(sdram_clk),
75
    .LOCKED(ext_locked)
76
  );
77
 
78
  assign clk_ok = int_locked & ext_locked;
79
 
80 127 hellwig
  //------------------------------------------------------------
81 27 hellwig
 
82
  assign reset_counting = (reset_counter == 24'hFFFFFF) ? 0 : 1;
83
  assign reset_inout_n = (reset_counter[23] == 0) ? 1'b0 : 1'bz;
84
 
85
  always @(posedge clk_in_buf) begin
86
    reset_p_n <= reset_inout_n;
87
    reset_s_n <= reset_p_n;
88 129 hellwig
    if (reset_counting == 1) begin
89
      reset_counter <= reset_counter + 1;
90 27 hellwig
    end else begin
91 129 hellwig
      if (~reset_s_n | ~clk_ok) begin
92
        reset_counter <= 24'h000000;
93 27 hellwig
      end
94
    end
95
  end
96
 
97
  assign reset = reset_counting;
98
 
99
endmodule

powered by: WebSVN 2.1.0

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