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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [ml501/] [rtl/] [verilog/] [clkgen/] [clkgen.v] - Blame information for rev 435

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

Line No. Rev Author Line
1 412 julius
/*
2
 *
3
 * Clock, reset generation unit for ML501 board
4
 *
5
 * Implements clock generation according to design defines
6
 *
7
 */
8
//////////////////////////////////////////////////////////////////////
9
////                                                              ////
10
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG           ////
11
////                                                              ////
12
//// This source file may be used and distributed without         ////
13
//// restriction provided that this copyright statement is not    ////
14
//// removed from the file and that any derivative work contains  ////
15
//// the original copyright notice and the associated disclaimer. ////
16
////                                                              ////
17
//// This source file is free software; you can redistribute it   ////
18
//// and/or modify it under the terms of the GNU Lesser General   ////
19
//// Public License as published by the Free Software Foundation; ////
20
//// either version 2.1 of the License, or (at your option) any   ////
21
//// later version.                                               ////
22
////                                                              ////
23
//// This source is distributed in the hope that it will be       ////
24
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
25
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
26
//// PURPOSE.  See the GNU Lesser General Public License for more ////
27
//// details.                                                     ////
28
////                                                              ////
29
//// You should have received a copy of the GNU Lesser General    ////
30
//// Public License along with this source; if not, download it   ////
31
//// from http://www.opencores.org/lgpl.shtml                     ////
32
////                                                              ////
33
//////////////////////////////////////////////////////////////////////
34
 
35
`include "orpsoc-defines.v"
36
`include "synthesis-defines.v"
37
 
38
module clkgen
39
  (
40
   // Main clocks in, depending on board
41
   sys_clk_in_p, sys_clk_in_n,
42
 
43
   // Wishbone clock and reset out  
44
   wb_clk_o,
45
   wb_rst_o,
46
 
47
   // JTAG clock
48
`ifdef JTAG_DEBUG
49
   tck_pad_i,
50
   dbg_tck_o,
51
`endif
52
   // Main memory clocks
53
`ifdef XILINX_DDR2
54
   ddr2_if_clk_o,
55
   ddr2_if_rst_o,
56
   clk200_o,
57
`endif
58
 
59
   // Asynchronous, active low reset in
60
   rst_n_pad_i
61
 
62
   );
63
 
64
   input  sys_clk_in_p,sys_clk_in_n;
65
 
66
   output wb_rst_o;
67
   output wb_clk_o;
68
 
69
`ifdef JTAG_DEBUG
70
   input  tck_pad_i;
71
   output dbg_tck_o;
72
`endif
73
 
74
`ifdef XILINX_DDR2
75
   output ddr2_if_clk_o;
76
   output ddr2_if_rst_o;
77
   output clk200_o;
78
`endif
79
 
80
   // Asynchronous, active low reset (pushbutton, typically)
81
   input  rst_n_pad_i;
82
 
83
   // First, deal with the asychronous reset
84
   wire   async_rst;
85
   wire   async_rst_n;
86
 
87
   // Xilinx synthesis tools appear cluey enough to instantiate buffers when and
88
   // where they're needed, so we do simple assigns for this tech.
89
   assign async_rst_n = rst_n_pad_i;
90
 
91
   // Everyone likes active-high reset signals...
92
   assign async_rst = ~async_rst_n;
93
 
94
 
95
`ifdef JTAG_DEBUG
96
   assign dbg_tck_o = tck_pad_i;
97
`endif
98
 
99
   //
100
   // Declare synchronous reset wires here
101
   //
102
 
103
   // An active-low synchronous reset signal (usually a PLL lock signal)
104
   wire   sync_rst_n;
105
 
106
   // An active-low synchronous reset from ethernet PLL
107
   wire   sync_eth_rst_n;
108
 
109
 
110
   wire       sys_clk_in_200;
111
   /* DCM0 wires */
112
   wire            dcm0_clk0_prebufg, dcm0_clk0;
113
   wire            dcm0_clkfx_prebufg, dcm0_clkfx;
114
   wire            dcm0_clkdv_prebufg, dcm0_clkdv;
115
   wire            dcm0_locked;
116
 
117
   /* Dif. input buffer for 200MHz board clock, generate SE 200MHz */
118
   IBUFGDS_LVPECL_25 sys_clk_in_ibufds
119
     (
120
      .O(sys_clk_in_200),
121
      .I(sys_clk_in_p),
122
      .IB(sys_clk_in_n));
123
 
124
   /* DCM providing main system/Wishbone clock */
125
   DCM_BASE dcm0
126
     (
127
      // Outputs
128
      .CLK0                              (dcm0_clk0_prebufg),
129
      .CLK180                            (),
130
      .CLK270                            (),
131
      .CLK2X180                          (),
132
      .CLK2X                             (),
133
      .CLK90                             (),
134
      .CLKDV                             (dcm0_clkdv_prebufg),
135
      .CLKFX180                          (),
136
      .CLKFX                             (dcm0_clkfx_prebufg),
137
      .LOCKED                            (dcm0_locked),
138
      // Inputs
139
      .CLKFB                             (dcm0_clk0),
140
      .CLKIN                             (sys_clk_in_200),
141
      .RST                               (1'b0));
142
 
143
   // Generate 266 MHz from CLKFX
144
   defparam    dcm0.CLKFX_MULTIPLY    = 4;
145
   defparam    dcm0.CLKFX_DIVIDE      = 3;
146
 
147
   // Generate 50 MHz from CLKDV
148
   defparam    dcm0.CLKDV_DIVIDE      = 4.0;
149
 
150
   BUFG dcm0_clk0_bufg
151
     (// Outputs
152
      .O                                 (dcm0_clk0),
153
      // Inputs
154
      .I                                 (dcm0_clk0_prebufg));
155
 
156
   BUFG dcm0_clkfx_bufg
157
     (// Outputs
158
      .O                                 (dcm0_clkfx),
159
      // Inputs
160
      .I                                 (dcm0_clkfx_prebufg));
161
 
162
   BUFG dcm0_clkdv_bufg
163
     (// Outputs
164
      .O                                 (dcm0_clkdv),
165
      // Inputs
166
      .I                                 (dcm0_clkdv_prebufg));
167
 
168
   assign wb_clk_o = dcm0_clkdv;
169
   assign sync_rst_n = dcm0_locked;
170
 
171
 `ifdef XILINX_DDR2
172
   assign ddr2_if_clk_o = dcm0_clkfx; // 266MHz    
173
   assign clk200_o = dcm0_clk0; // 200MHz
174
 `endif
175
 
176
   //
177
   // Reset generation
178
   //
179
   //
180
 
181
   // Reset generation for wishbone
182
   reg [15:0]       wb_rst_shr;
183
   always @(posedge wb_clk_o or posedge async_rst)
184
     if (async_rst)
185
       wb_rst_shr <= 16'hffff;
186
     else
187
       wb_rst_shr <= {wb_rst_shr[14:0], ~(sync_rst_n)};
188
 
189
   assign wb_rst_o = wb_rst_shr[15];
190
 
191
 
192
`ifdef XILINX_DDR2
193
   // Reset generation for DDR2 controller
194
   reg [15:0]       ddr2_if_rst_shr;
195
   always @(posedge ddr2_if_clk_o or posedge async_rst)
196
     if (async_rst)
197
       ddr2_if_rst_shr <= 16'hffff;
198
     else
199
       ddr2_if_rst_shr <= {ddr2_if_rst_shr[14:0], ~(sync_rst_n)};
200
 
201
   assign ddr2_if_rst_o = ddr2_if_rst_shr[15];
202
`endif
203
 
204
 
205
endmodule // clkgen

powered by: WebSVN 2.1.0

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