]> git.ozlabs.org Git - minimigmac.git/blob - fpga/fpga_clocks_dll.v
Initial commit
[minimigmac.git] / fpga / fpga_clocks_dll.v
1 module clockgen
2 (
3         input   mclk,           /* 4.433619 Mhz input */
4         output  sysclk16,       /* System clock outputs */
5         output  sysclk33,       /* System clock outputs */
6         output  pixclk      /* Pixel clock */
7 );
8         wire    pll_mclk;
9         wire    pll_c33;
10         wire    pll_c25;
11         wire    dll_c33;        
12         wire    dll_c16;      
13
14         IBUFG mclk_buf( .I(mclk), .O(pll_mclk));
15
16         /* Generate 33.25 for the DLL cpu*/
17         DCM #
18         (
19                 .CLKDV_DIVIDE(2.0), // Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,
20                                     // 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
21                 .CLKFX_DIVIDE(2),   // Can be any integer from 1 to 32
22                 .CLKFX_MULTIPLY(15), // Can be any integer from 2 to 32
23                 .CLKIN_DIVIDE_BY_2("FALSE"), // TRUE/FALSE to enable CLKIN divide by two feature
24                 .CLKIN_PERIOD(225.0),  // Specify period of input clock
25                 .CLKOUT_PHASE_SHIFT("NONE"), // Specify phase shift of NONE, FIXED or VARIABLE
26                 .CLK_FEEDBACK("NONE"),  // Specify clock feedback of NONE, 1X or 2X
27                 .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"), // SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or an integer from 0 to 15
28                 .DFS_FREQUENCY_MODE("LOW"),  // HIGH or LOW frequency mode for frequency synthesis
29                 .DLL_FREQUENCY_MODE("LOW"),  // HIGH or LOW frequency mode for DLL
30                 .DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, TRUE or FALSE
31                 .FACTORY_JF(16'hC080),   // FACTORY JF values
32                 .PHASE_SHIFT(0),     // Amount of fixed phase shift from -255 to 255
33                 .STARTUP_WAIT("FALSE")   // Delay configuration DONE until DCM LOCK, TRUE/FALSE
34         )
35         pllmain
36         (
37                 .CLKFX(pll_c33),   // DCM CLK synthesis out (M/D)
38                 .CLKIN(pll_mclk)   // Clock input (from IBUFG, BUFG or DCM)
39         );
40
41         /* Generate a rough 25.1Mhz for the video */
42         DCM #
43         (
44                 .CLKDV_DIVIDE(3.0), // Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,
45                                     // 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
46                 .CLKFX_DIVIDE(3),   // Can be any integer from 1 to 32
47                 .CLKFX_MULTIPLY(17), // Can be any integer from 2 to 32
48                 .CLKIN_DIVIDE_BY_2("FALSE"), // TRUE/FALSE to enable CLKIN divide by two feature
49                 .CLKIN_PERIOD(225.0),  // Specify period of input clock
50                 .CLKOUT_PHASE_SHIFT("NONE"), // Specify phase shift of NONE, FIXED or VARIABLE
51                 .CLK_FEEDBACK("NONE"),  // Specify clock feedback of NONE, 1X or 2X
52                 .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"), // SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or an integer from 0 to 15
53                 .DFS_FREQUENCY_MODE("LOW"),  // HIGH or LOW frequency mode for frequency synthesis
54                 .DLL_FREQUENCY_MODE("LOW"),  // HIGH or LOW frequency mode for DLL
55                 .DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, TRUE or FALSE
56                 .FACTORY_JF(16'hC080),   // FACTORY JF values
57                 .PHASE_SHIFT(0),     // Amount of fixed phase shift from -255 to 255
58                 .STARTUP_WAIT("FALSE")   // Delay configuration DONE until DCM LOCK, TRUE/FALSE
59         )
60         pllpix
61         (
62                 .CLKFX(pll_c25),   // DCM CLK synthesis out (M/D)
63                 .CLKIN(pll_mclk)   // Clock input (from IBUFG, BUFG or DCM)
64         );
65         
66         /* DLL that 33.25Mhz input and generate the 16.6 from it. Note: The Xilinx tools don't
67          * seem to like when you do that ;-) Looks like we should really have put a faster
68          * crystal on the board
69          */
70         DCM #
71         (
72                 .CLKDV_DIVIDE(2.0), // Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,
73                                     // 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0
74                 .CLKFX_DIVIDE(2),   // Can be any integer from 1 to 32
75                 .CLKFX_MULTIPLY(2), // Can be any integer from 2 to 32
76                 .CLKIN_DIVIDE_BY_2("FALSE"), // TRUE/FALSE to enable CLKIN divide by two feature
77                 .CLKIN_PERIOD(30.0),  // Specify period of input clock
78                 .CLKOUT_PHASE_SHIFT("NONE"), // Specify phase shift of NONE, FIXED or VARIABLE
79                 .CLK_FEEDBACK("1X"),  // Specify clock feedback of NONE, 1X or 2X
80                 .DESKEW_ADJUST("SYSTEM_SYNCHRONOUS"), // SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or an integer from 0 to 15
81                 .DFS_FREQUENCY_MODE("LOW"),  // HIGH or LOW frequency mode for frequency synthesis
82                 .DLL_FREQUENCY_MODE("LOW"),  // HIGH or LOW frequency mode for DLL
83                 .DUTY_CYCLE_CORRECTION("TRUE"), // Duty cycle correction, TRUE or FALSE
84                 .FACTORY_JF(16'hC080),   // FACTORY JF values
85                 .PHASE_SHIFT(0),     // Amount of fixed phase shift from -255 to 255
86                 .STARTUP_WAIT("FALSE")   // Delay configuration DONE until DCM LOCK, TRUE/FALSE
87         )
88         dll
89         (
90                 .CLKIN(pll_c33),        // Clock input (from IBUFG, BUFG or DCM)
91                 .CLK0(dll_c33),         // 0 degree DCM CLK output
92                 .CLKDV(dll_c16),        // Divided DCM CLK out (CLKDV_DIVIDE)
93                 .CLKFB(sysclk33)        // DCM clock feedback
94         );
95
96         /* Global clock buffers */
97         BUFG clk33_buf( .I(dll_c33),    .O(sysclk33));
98         BUFG clk16_buf( .I(dll_c16),    .O(sysclk16));
99         
100         /* Temporarily assign pixclock to 33Mhz, will fix later */
101         BUFG pixclk_buf( .I(pll_c25),   .O(pixclk));
102 endmodule // clocks