1 //---------------------------------------------------------------------
2 // FPGA MOONCRESTA CLOCK GEN
6 // Copyright(c) 2004 Katsumi Degawa , All rights reserved
10 // This program is freeware for non-commercial use.
11 // An author does no guarantee about this program.
12 // You can use this under your own risk.
14 //---------------------------------------------------------------------
32 // 2/3 clock divider(duty 33%)
33 reg [1:0] clk_ff1,clk_ff2;
34 //I_CLK 1010101010101010101
35 //c_ff10 0011110011110011110
36 //c_ff11 0011000011000011000
37 //c_ff20 0000110000110000110
38 //c_ff21 0110000110000110000
39 //O_12M 0000110110110110110
40 always @(posedge I_CLK_18M)
42 clk_ff1[0] <= ~clk_ff1[0] | clk_ff1[1];
43 clk_ff1[1] <= ~clk_ff1[0] & ~clk_ff1[1];
44 clk_ff2[0] <= clk_ff1[0] & clk_ff1[1];
46 always @(negedge I_CLK_18M)
47 clk_ff2[1] <= ~clk_ff1[0] & ~clk_ff1[1];
49 // 2/3 clock (duty 66%)
50 assign O_CLK_12M = clk_ff2[0]| clk_ff2[1];
52 // 1/3 clock divider (duty 50%)
54 always @(posedge O_CLK_12M)
59 assign O_CLK_06M = CLK_6M;
60 assign O_CLK_06Mn = CLK_6Mn;