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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 568 julius
/*
2
 *
3
 * Clock, reset generation unit for s3adsp1800 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_i,
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
   clk133_o,
55
`endif
56
 
57
   // Asynchronous, active low reset in
58
   rst_n_pad_i
59
 
60
   );
61
 
62
   input  sys_clk_i;
63
 
64
   output wb_rst_o;
65
   output wb_clk_o;
66
 
67
`ifdef JTAG_DEBUG
68
   input  tck_pad_i;
69
   output dbg_tck_o;
70
`endif
71
 
72
`ifdef XILINX_DDR2
73
   output clk133_o;
74
`endif
75
 
76
   // Asynchronous, active low reset (pushbutton, typically)
77
   input  rst_n_pad_i;
78
 
79
   // First, deal with the asychronous reset
80
   wire   async_rst;
81
   wire   async_rst_n;
82
 
83
   // Xilinx synthesis tools appear cluey enough to instantiate buffers when and
84
   // where they're needed, so we do simple assigns for this tech.
85
   assign async_rst_n = rst_n_pad_i;
86
 
87
   // Everyone likes active-high reset signals...
88
   assign async_rst = ~async_rst_n;
89
 
90
 
91
`ifdef JTAG_DEBUG
92
   assign dbg_tck_o = tck_pad_i;
93
`endif
94
 
95
   //
96
   // Declare synchronous reset wires here
97
   //
98
 
99
   // An active-low synchronous reset signal (usually a PLL lock signal)
100
   wire   sync_rst_n;
101
 
102
   // An active-low synchronous reset from ethernet PLL
103
   wire   sync_eth_rst_n;
104
 
105
   // IBUF for sys_clk_i
106
   wire   sys_clk;
107
   IBUFG ibufg0
108
     (.I(sys_clk_i), .O(sys_clk));
109
 
110
 
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
 
118
   /* DCM providing main system/Wishbone clock */
119
   DCM_SP #( .CLK_FEEDBACK("1X"),
120
             // 125 / 5 = 25 MHz
121
             .CLKDV_DIVIDE(5),
122
             // 125 * 2/8 = 31.25Mhz
123
             .CLKFX_DIVIDE(8),
124
             .CLKFX_MULTIPLY(2),
125
             // Clkin = 125 Mhz
126
             .CLKIN_PERIOD(8.000),
127
             .CLKIN_DIVIDE_BY_2("FALSE"),
128
             .CLKOUT_PHASE_SHIFT("NONE"), .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"),
129
             .DFS_FREQUENCY_MODE("LOW"), .DLL_FREQUENCY_MODE("LOW"),
130
             .DUTY_CYCLE_CORRECTION("TRUE"), .FACTORY_JF(16'hC080),
131
             .PHASE_SHIFT(0), .STARTUP_WAIT("FALSE") )
132
   DCM_SP_INST
133
     (
134
      .CLKFB(dcm0_clk0),
135
      .CLKIN(sys_clk),
136
      .DSSEN(1'b0),
137
      .PSCLK(1'b0),
138
      .PSEN(1'b0),
139
      .PSINCDEC(1'b0),
140
      .RST(1'b0),
141
      .CLKDV(dcm0_clkdv_prebufg),
142
      .CLKFX(dcm0_clkfx_prebufg),
143
      .CLKFX180(),
144
      .CLK0(dcm0_clk0_prebufg),
145
      .CLK2X(),
146
      .CLK2X180(),
147
      .CLK90(),
148
      .CLK180(),
149
      .CLK270(),
150
      .LOCKED(dcm0_locked),
151
      .PSDONE(),
152
      .STATUS());
153
 
154
   BUFG dcm0_clk0_bufg
155
     (// Outputs
156
      .O                                 (dcm0_clk0),
157
      // Inputs
158
      .I                                 (dcm0_clk0_prebufg));
159
 
160
   BUFG dcm0_clkfx_bufg
161
     (// Outputs
162
      .O                                 (dcm0_clkfx),
163
      // Inputs
164
      .I                                 (dcm0_clkfx_prebufg));
165
 
166
   BUFG dcm0_clkdv_bufg
167
     (// Outputs
168
      .O                                 (dcm0_clkdv),
169
      // Inputs
170
      .I                                 (dcm0_clkdv_prebufg));
171
 
172
   assign wb_clk_o = dcm0_clkdv;
173
   assign sync_rst_n = dcm0_locked;
174
 
175
 `ifdef XILINX_DDR2
176
   assign clk133_o = dcm0_clk0; // 125 MHz for now
177
 `endif
178
 
179
   //
180
   // Reset generation
181
   //
182
   //
183
 
184
   // Reset generation for wishbone
185
   reg [15:0]       wb_rst_shr;
186
   always @(posedge wb_clk_o or posedge async_rst)
187
     if (async_rst)
188
       wb_rst_shr <= 16'hffff;
189
     else
190
       wb_rst_shr <= {wb_rst_shr[14:0], ~(sync_rst_n)};
191
 
192
   assign wb_rst_o = wb_rst_shr[15];
193
 
194
 
195
 `ifdef XILINX_DDR2
196
   /*
197
   // Reset generation for DDR2 controller
198
   reg [15:0]      ddr2_if_rst_shr;
199
   always @(posedge ddr2_if_clk_o or posedge async_rst)
200
     if (async_rst)
201
       ddr2_if_rst_shr <= 16'hffff;
202
     else
203
       ddr2_if_rst_shr <= {ddr2_if_rst_shr[14:0], ~(sync_rst_n)};
204
 
205
   assign ddr2_if_rst_o = ddr2_if_rst_shr[15];
206
    */
207
`endif
208
 
209
 
210
endmodule // clkgen

powered by: WebSVN 2.1.0

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