1 |
62 |
rfajardo |
|
2 |
|
|
`include "minsoc_defines.v"
|
3 |
|
|
|
4 |
|
|
module xilinx_dcm(
|
5 |
|
|
clk_i,
|
6 |
|
|
clk_o
|
7 |
|
|
);
|
8 |
|
|
|
9 |
|
|
//
|
10 |
|
|
// Parameters
|
11 |
|
|
//
|
12 |
|
|
parameter divisor = 2;
|
13 |
|
|
|
14 |
|
|
input clk_i;
|
15 |
|
|
output clk_o;
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
`ifdef SPARTAN2
|
19 |
|
|
`define XILINX_DLL
|
20 |
|
|
`elsif VIRTEX
|
21 |
|
|
`define XILINX_DLL
|
22 |
|
|
`endif // !SPARTAN2/VIRTEX
|
23 |
|
|
|
24 |
|
|
`ifdef SPARTAN3
|
25 |
|
|
`define XILINX_DCM
|
26 |
|
|
`elsif VIRTEX2
|
27 |
|
|
`define XILINX_DCM
|
28 |
|
|
`endif // !SPARTAN3/VIRTEX2
|
29 |
|
|
|
30 |
|
|
`ifdef SPARTAN3E
|
31 |
|
|
`define XILINX_DCM_SP
|
32 |
|
|
`elsif SPARTAN3A
|
33 |
|
|
`define XILINX_DCM_SP
|
34 |
|
|
`endif // !SPARTAN3E/SPARTAN3A
|
35 |
|
|
|
36 |
|
|
`ifdef VIRTEX4
|
37 |
|
|
`define XILINX_DCM_ADV
|
38 |
|
|
`define XILINX_DCM_COMPONENT "VIRTEX4"
|
39 |
|
|
`elsif VIRTEX5
|
40 |
|
|
`define XILINX_DCM_ADV
|
41 |
|
|
`define XILINX_DCM_COMPONENT "VIRTEX5"
|
42 |
|
|
`endif // !VIRTEX4/VIRTEX5
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
wire CLKIN_IN;
|
46 |
|
|
wire CLKDV_OUT;
|
47 |
|
|
|
48 |
|
|
assign CLKIN_IN = clk_i;
|
49 |
|
|
assign clk_o = CLKDV_OUT;
|
50 |
|
|
|
51 |
|
|
wire CLKIN_IBUFG;
|
52 |
|
|
wire CLK0_BUF;
|
53 |
|
|
wire CLKFB_IN;
|
54 |
|
|
wire CLKDV_BUF;
|
55 |
|
|
|
56 |
|
|
IBUFG CLKIN_IBUFG_INST (
|
57 |
|
|
.I(CLKIN_IN),
|
58 |
|
|
.O(CLKIN_IBUFG)
|
59 |
|
|
);
|
60 |
|
|
|
61 |
|
|
BUFG CLK0_BUFG_INST (
|
62 |
|
|
.I(CLK0_BUF),
|
63 |
|
|
.O(CLKFB_IN)
|
64 |
|
|
);
|
65 |
|
|
|
66 |
|
|
BUFG CLKDV_BUFG_INST (
|
67 |
|
|
.I(CLKDV_BUF),
|
68 |
|
|
.O(CLKDV_OUT)
|
69 |
|
|
);
|
70 |
|
|
|
71 |
|
|
`ifdef XILINX_DLL
|
72 |
|
|
|
73 |
|
|
CLKDLL #(
|
74 |
|
|
.CLKDV_DIVIDE(divisor), // Divide by: 1.5,2.0,2.5,3.0,4.0,5.0,8.0 or 16.0
|
75 |
|
|
.DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, TRUE or FALSE
|
76 |
|
|
.FACTORY_JF(16'hC080), // FACTORY JF Values
|
77 |
|
|
.STARTUP_WAIT("FALSE") // Delay config DONE until DLL LOCK, TRUE/FALSE
|
78 |
|
|
) CLKDLL_inst (
|
79 |
|
|
.CLK0(CLK0_BUF), // 0 degree DLL CLK output
|
80 |
|
|
.CLK180(), // 180 degree DLL CLK output
|
81 |
|
|
.CLK270(), // 270 degree DLL CLK output
|
82 |
|
|
.CLK2X(), // 2X DLL CLK output
|
83 |
|
|
.CLK90(), // 90 degree DLL CLK output
|
84 |
|
|
.CLKDV(CLKDV_BUF), // Divided DLL CLK out (CLKDV_DIVIDE)
|
85 |
|
|
.LOCKED(), // DLL LOCK status output
|
86 |
|
|
.CLKFB(CLKFB_IN), // DLL clock feedback
|
87 |
|
|
.CLKIN(CLKIN_IBUFG), // Clock input (from IBUFG, BUFG or DLL)
|
88 |
|
|
.RST(1'b0) // DLL asynchronous reset input
|
89 |
|
|
);
|
90 |
|
|
|
91 |
|
|
`elsif XILINX_DCM
|
92 |
|
|
|
93 |
|
|
DCM #(
|
94 |
|
|
.SIM_MODE("SAFE"), // Simulation: "SAFE" vs. "FAST", see "Synthesis and Simulation Design Guide" for details
|
95 |
|
|
.CLKDV_DIVIDE(divisor), // Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5
|
96 |
|
|
// 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
|
97 |
|
|
.CLKFX_DIVIDE(1), // Can be any integer from 1 to 32
|
98 |
|
|
.CLKFX_MULTIPLY(4), // Can be any integer from 2 to 32
|
99 |
|
|
.CLKIN_DIVIDE_BY_2("FALSE"), // TRUE/FALSE to enable CLKIN divide by two feature
|
100 |
|
|
.CLKIN_PERIOD(0.0), // Specify period of input clock
|
101 |
|
|
.CLKOUT_PHASE_SHIFT("NONE"), // Specify phase shift of NONE, FIXED or VARIABLE
|
102 |
|
|
.CLK_FEEDBACK("1X"), // Specify clock feedback of NONE, 1X or 2X
|
103 |
|
|
.DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"), // SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or
|
104 |
|
|
// an integer from 0 to 15
|
105 |
|
|
.DFS_FREQUENCY_MODE("LOW"), // HIGH or LOW frequency mode for frequency synthesis
|
106 |
|
|
.DLL_FREQUENCY_MODE("LOW"), // HIGH or LOW frequency mode for DLL
|
107 |
|
|
.DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, TRUE or FALSE
|
108 |
|
|
.FACTORY_JF(16'hC080), // FACTORY JF values
|
109 |
|
|
.PHASE_SHIFT(0), // Amount of fixed phase shift from -255 to 255
|
110 |
|
|
.STARTUP_WAIT("FALSE") // Delay configuration DONE until DCM LOCK, TRUE/FALSE
|
111 |
|
|
) DCM_inst (
|
112 |
|
|
.CLK0(CLK0_BUF), // 0 degree DCM CLK output
|
113 |
|
|
.CLK180(), // 180 degree DCM CLK output
|
114 |
|
|
.CLK270(), // 270 degree DCM CLK output
|
115 |
|
|
.CLK2X(), // 2X DCM CLK output
|
116 |
|
|
.CLK2X180(), // 2X, 180 degree DCM CLK out
|
117 |
|
|
.CLK90(), // 90 degree DCM CLK output
|
118 |
|
|
.CLKDV(CLKDV_BUF), // Divided DCM CLK out (CLKDV_DIVIDE)
|
119 |
|
|
.CLKFX(), // DCM CLK synthesis out (M/D)
|
120 |
|
|
.CLKFX180(), // 180 degree CLK synthesis out
|
121 |
|
|
.LOCKED(), // DCM LOCK status output
|
122 |
|
|
.PSDONE(), // Dynamic phase adjust done output
|
123 |
|
|
.STATUS(), // 8-bit DCM status bits output
|
124 |
|
|
.CLKFB(CLKFB_IN), // DCM clock feedback
|
125 |
|
|
.CLKIN(CLKIN_IBUFG), // Clock input (from IBUFG, BUFG or DCM)
|
126 |
|
|
.PSCLK(1'b0), // Dynamic phase adjust clock input
|
127 |
|
|
.PSEN(1'b0), // Dynamic phase adjust enable input
|
128 |
|
|
.PSINCDEC(1'b0), // Dynamic phase adjust increment/decrement
|
129 |
|
|
.RST(1'b0) // DCM asynchronous reset input
|
130 |
|
|
);
|
131 |
|
|
|
132 |
|
|
`elsif XILINX_DCM_SP
|
133 |
|
|
|
134 |
|
|
DCM_SP #(
|
135 |
|
|
.CLKDV_DIVIDE(divisor), // Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5
|
136 |
|
|
// 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
|
137 |
|
|
.CLKFX_DIVIDE(1), // Can be any integer from 1 to 32
|
138 |
|
|
.CLKFX_MULTIPLY(4), // Can be any integer from 2 to 32
|
139 |
|
|
.CLKIN_DIVIDE_BY_2("FALSE"), // TRUE/FALSE to enable CLKIN divide by two feature
|
140 |
|
|
.CLKIN_PERIOD(0.0), // Specify period of input clock
|
141 |
|
|
.CLKOUT_PHASE_SHIFT("NONE"), // Specify phase shift of NONE, FIXED or VARIABLE
|
142 |
|
|
.CLK_FEEDBACK("1X"), // Specify clock feedback of NONE, 1X or 2X
|
143 |
|
|
.DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"), // SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or
|
144 |
|
|
// an integer from 0 to 15
|
145 |
|
|
.DLL_FREQUENCY_MODE("LOW"), // HIGH or LOW frequency mode for DLL
|
146 |
|
|
.DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, TRUE or FALSE
|
147 |
|
|
.PHASE_SHIFT(0), // Amount of fixed phase shift from -255 to 255
|
148 |
|
|
.STARTUP_WAIT("FALSE") // Delay configuration DONE until DCM LOCK, TRUE/FALSE
|
149 |
|
|
) DCM_SP_inst (
|
150 |
|
|
.CLK0(CLK0_BUF), // 0 degree DCM CLK output
|
151 |
|
|
.CLK180(), // 180 degree DCM CLK output
|
152 |
|
|
.CLK270(), // 270 degree DCM CLK output
|
153 |
|
|
.CLK2X(), // 2X DCM CLK output
|
154 |
|
|
.CLK2X180(), // 2X, 180 degree DCM CLK out
|
155 |
|
|
.CLK90(), // 90 degree DCM CLK output
|
156 |
|
|
.CLKDV(CLKDV_BUF), // Divided DCM CLK out (CLKDV_DIVIDE)
|
157 |
|
|
.CLKFX(), // DCM CLK synthesis out (M/D)
|
158 |
|
|
.CLKFX180(), // 180 degree CLK synthesis out
|
159 |
|
|
.LOCKED(), // DCM LOCK status output
|
160 |
|
|
.PSDONE(), // Dynamic phase adjust done output
|
161 |
|
|
.STATUS(), // 8-bit DCM status bits output
|
162 |
|
|
.CLKFB(CLKFB_IN), // DCM clock feedback
|
163 |
|
|
.CLKIN(CLKIN_IBUFG), // Clock input (from IBUFG, BUFG or DCM)
|
164 |
|
|
.PSCLK(1'b0), // Dynamic phase adjust clock input
|
165 |
|
|
.PSEN(1'b0), // Dynamic phase adjust enable input
|
166 |
|
|
.PSINCDEC(1'b0), // Dynamic phase adjust increment/decrement
|
167 |
|
|
.RST(1'b0) // DCM asynchronous reset input
|
168 |
|
|
);
|
169 |
|
|
|
170 |
|
|
`elsif XILINX_DCM_ADV
|
171 |
|
|
|
172 |
|
|
DCM_ADV #(
|
173 |
|
|
.CLKDV_DIVIDE(divisor), // Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5
|
174 |
|
|
// 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
|
175 |
|
|
.CLKFX_DIVIDE(1), // Can be any integer from 1 to 32
|
176 |
|
|
.CLKFX_MULTIPLY(4), // Can be any integer from 2 to 32
|
177 |
|
|
.CLKIN_DIVIDE_BY_2("FALSE"), // TRUE/FALSE to enable CLKIN divide by two feature
|
178 |
|
|
.CLKIN_PERIOD(10.0), // Specify period of input clock in ns from 1.25 to 1000.00
|
179 |
|
|
.CLKOUT_PHASE_SHIFT("NONE"), // Specify phase shift mode of NONE, FIXED,
|
180 |
|
|
// VARIABLE_POSITIVE, VARIABLE_CENTER or DIRECT
|
181 |
|
|
.CLK_FEEDBACK("1X"), // Specify clock feedback of NONE, 1X or 2X
|
182 |
|
|
.DCM_AUTOCALIBRATION("TRUE"), // DCM calibration circuitry "TRUE"/"FALSE"
|
183 |
|
|
.DCM_PERFORMANCE_MODE("MAX_SPEED"), // Can be MAX_SPEED or MAX_RANGE
|
184 |
|
|
.DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"), // SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or
|
185 |
|
|
// an integer from 0 to 15
|
186 |
|
|
.DFS_FREQUENCY_MODE("LOW"), // HIGH or LOW frequency mode for frequency synthesis
|
187 |
|
|
.DLL_FREQUENCY_MODE("LOW"), // LOW, HIGH, or HIGH_SER frequency mode for DLL
|
188 |
|
|
.DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, "TRUE"/"FALSE"
|
189 |
|
|
.FACTORY_JF(16'hf0f0), // FACTORY JF value suggested to be set to 16’hf0f0
|
190 |
|
|
.PHASE_SHIFT(0), // Amount of fixed phase shift from -255 to 1023
|
191 |
|
|
.SIM_DEVICE(`XILINX_DCM_COMPONENT), // Set target device, "VIRTEX4" or "VIRTEX5"
|
192 |
|
|
.STARTUP_WAIT("FALSE") // Delay configuration DONE until DCM LOCK, "TRUE"/"FALSE"
|
193 |
|
|
) DCM_ADV_inst (
|
194 |
|
|
.CLK0(CLK0_BUF), // 0 degree DCM CLK output
|
195 |
|
|
.CLK180(), // 180 degree DCM CLK output
|
196 |
|
|
.CLK270(), // 270 degree DCM CLK output
|
197 |
|
|
.CLK2X(), // 2X DCM CLK output
|
198 |
|
|
.CLK2X180(), // 2X, 180 degree DCM CLK out
|
199 |
|
|
.CLK90(), // 90 degree DCM CLK output
|
200 |
|
|
.CLKDV(CLKDV_BUF), // Divided DCM CLK out (CLKDV_DIVIDE)
|
201 |
|
|
.CLKFX(), // DCM CLK synthesis out (M/D)
|
202 |
|
|
.CLKFX180(), // 180 degree CLK synthesis out
|
203 |
|
|
.DO(), // 16-bit data output for Dynamic Reconfiguration Port (DRP)
|
204 |
|
|
.DRDY(), // Ready output signal from the DRP
|
205 |
|
|
.LOCKED(), // DCM LOCK status output
|
206 |
|
|
.PSDONE(), // Dynamic phase adjust done output
|
207 |
|
|
.CLKFB(CLKFB_IN), // DCM clock feedback
|
208 |
|
|
.CLKIN(CLKIN_IBUFG), // Clock input (from IBUFG, BUFG or DCM)
|
209 |
|
|
.DADDR(7'h00), // 7-bit address for the DRP
|
210 |
|
|
.DCLK(1'b0), // Clock for the DRP
|
211 |
|
|
.DEN(1'b0), // Enable input for the DRP
|
212 |
|
|
.DI(16'h0000), // 16-bit data input for the DRP
|
213 |
|
|
.DWE(1'b0), // Active high allows for writing configuration memory
|
214 |
|
|
.PSCLK(1'b0), // Dynamic phase adjust clock input
|
215 |
|
|
.PSEN(1'b0), // Dynamic phase adjust enable input
|
216 |
|
|
.PSINCDEC(1'b0), // Dynamic phase adjust increment/decrement
|
217 |
|
|
.RST(1'b0) // DCM asynchronous reset input
|
218 |
|
|
);
|
219 |
|
|
|
220 |
|
|
`endif // !XILINX_DLL/XILINX_DCM/XILINX_DCM_SP/XILINX_DCM_ADV
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
endmodule
|