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 290

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

powered by: WebSVN 2.1.0

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