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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 627 stekern
/*
2
 *
3
 * Clock, reset generation unit for Atlys 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,
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
   clk100_o,
57
`endif
58
 
59
   // Asynchronous, active low reset in
60
   rst_n_pad_i
61
 
62
   );
63
 
64
   input  sys_clk_in;
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 clk100_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
   wire       sys_clk_ibufg;
112
   /* DCM0 wires */
113
   wire            dcm0_clk0_prebufg, dcm0_clk0;
114
   wire            dcm0_clkfx_prebufg, dcm0_clkfx;
115
   wire            dcm0_clkdv_prebufg, dcm0_clkdv;
116
   wire            dcm0_clk2x_prebufg, dcm0_clk2x;
117
   wire            dcm0_locked;
118
 
119
`ifdef FPGA_BOARD_XILINX_ML501
120
   /* Dif. input buffer for 200MHz board clock, generate SE 200MHz */
121
   IBUFGDS_LVPECL_25 sys_clk_in_ibufds
122
     (
123
      .O(sys_clk_in_200),
124
      .I(sys_clk_in_p),
125
      .IB(sys_clk_in_n));
126
 
127
 
128
   /* DCM providing main system/Wishbone clock */
129
   DCM_BASE dcm0
130
     (
131
      // Outputs
132
      .CLK0                              (dcm0_clk0_prebufg),
133
      .CLK180                            (),
134
      .CLK270                            (),
135
      .CLK2X180                          (),
136
      .CLK2X                             (dcm0_clk2x_prebufg),
137
      .CLK90                             (),
138
      .CLKDV                             (dcm0_clkdv_prebufg),
139
      .CLKFX180                          (),
140
      .CLKFX                             (dcm0_clkfx_prebufg),
141
      .LOCKED                            (dcm0_locked),
142
      // Inputs
143
      .CLKFB                             (dcm0_clk0),
144
      .CLKIN                             (sys_clk_in_200),
145
      .RST                               (1'b0));
146
 
147
`endif
148
`ifdef FPGA_BOARD_XILINX_ATLYS
149
    IBUFG sys_clk_in_ibufg
150
   (
151
   .I  (sys_clk_in),
152
   .O  (sys_clk_ibufg)
153
   );
154
 
155
 
156
   /* DCM providing main system/Wishbone clock */
157
   DCM_SP dcm0
158
     (
159
      // Outputs
160
      .CLK0                              (dcm0_clk0_prebufg),
161
      .CLK180                            (),
162
      .CLK270                            (),
163
      .CLK2X180                          (),
164
      .CLK2X                             (dcm0_clk2x_prebufg),
165
      .CLK90                             (),
166
      .CLKDV                             (dcm0_clkdv_prebufg),
167
      .CLKFX180                          (),
168
      .CLKFX                             (dcm0_clkfx_prebufg),
169
      .LOCKED                            (dcm0_locked),
170
      // Inputs
171
      .CLKFB                             (dcm0_clk0),
172
      .CLKIN                             (sys_clk_ibufg),
173
      .PSEN                              (1'b0),
174
      .RST                               (1'b0));
175
`endif
176
 
177
   // Generate 266 MHz from CLKFX
178
   defparam    dcm0.CLKFX_MULTIPLY    = 8;
179
   defparam    dcm0.CLKFX_DIVIDE      = 3;
180
 
181
   // Generate 50 MHz from CLKDV
182
   defparam    dcm0.CLKDV_DIVIDE      = 2.0;
183
 
184
   BUFG dcm0_clk0_bufg
185
     (// Outputs
186
      .O                                 (dcm0_clk0),
187
      // Inputs
188
      .I                                 (dcm0_clk0_prebufg));
189
 
190
   BUFG dcm0_clk2x_bufg
191
     (// Outputs
192
      .O                                 (dcm0_clk2x),
193
      // Inputs
194
      .I                                 (dcm0_clk2x_prebufg));
195
 
196
   BUFG dcm0_clkfx_bufg
197
     (// Outputs
198
      .O                                 (dcm0_clkfx),
199
      // Inputs
200
      .I                                 (dcm0_clkfx_prebufg));
201
 
202
   BUFG dcm0_clkdv_bufg
203
     (// Outputs
204
      .O                                 (dcm0_clkdv),
205
      // Inputs
206
      .I                                 (dcm0_clkdv_prebufg));
207
 
208
   assign wb_clk_o = dcm0_clkdv;
209
   assign sync_rst_n = dcm0_locked;
210
 
211
 `ifdef XILINX_DDR2
212
   assign ddr2_if_clk_o = dcm0_clkfx; // 266MHz    
213
   assign clk100_o = dcm0_clk0; // 100MHz
214
 `endif
215
 
216
   //
217
   // Reset generation
218
   //
219
   //
220
 
221
   // Reset generation for wishbone
222
   reg [15:0]       wb_rst_shr;
223
   always @(posedge wb_clk_o or posedge async_rst)
224
     if (async_rst)
225
       wb_rst_shr <= 16'hffff;
226
     else
227
       wb_rst_shr <= {wb_rst_shr[14:0], ~(sync_rst_n)};
228
 
229
   assign wb_rst_o = wb_rst_shr[15];
230
 
231
 
232
`ifdef XILINX_DDR2
233
   // Reset generation for DDR2 controller
234
   reg [15:0]       ddr2_if_rst_shr;
235
   always @(posedge ddr2_if_clk_o or posedge async_rst)
236
     if (async_rst)
237
       ddr2_if_rst_shr <= 16'hffff;
238
     else
239
       ddr2_if_rst_shr <= {ddr2_if_rst_shr[14:0], ~(sync_rst_n)};
240
 
241
   assign ddr2_if_rst_o = ddr2_if_rst_shr[15];
242
`endif
243
 
244
 
245
endmodule // clkgen

powered by: WebSVN 2.1.0

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