forked from uwsampl/verilator-unisims
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PLL_BASE.v
110 lines (101 loc) · 2.63 KB
/
PLL_BASE.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
module PLL_BASE
(
output CLKFBOUT,
output CLKOUT0,
output CLKOUT1,
output CLKOUT2,
output CLKOUT3,
output CLKOUT4,
output CLKOUT5,
output LOCKED,
input CLKFBIN,
input CLKIN,
input RST
);
parameter BANDWIDTH = "OPTIMIZED";
parameter integer CLKFBOUT_MULT = 1;
parameter real CLKFBOUT_PHASE = 0.0;
parameter real CLKIN_PERIOD = 0.000;
parameter integer CLKOUT0_DIVIDE = 1;
parameter real CLKOUT0_DUTY_CYCLE = 0.5;
parameter real CLKOUT0_PHASE = 0.0;
parameter integer CLKOUT1_DIVIDE = 1;
parameter real CLKOUT1_DUTY_CYCLE = 0.5;
parameter real CLKOUT1_PHASE = 0.0;
parameter integer CLKOUT2_DIVIDE = 1;
parameter real CLKOUT2_DUTY_CYCLE = 0.5;
parameter real CLKOUT2_PHASE = 0.0;
parameter integer CLKOUT3_DIVIDE = 1;
parameter real CLKOUT3_DUTY_CYCLE = 0.5;
parameter real CLKOUT3_PHASE = 0.0;
parameter integer CLKOUT4_DIVIDE = 1;
parameter real CLKOUT4_DUTY_CYCLE = 0.5;
parameter real CLKOUT4_PHASE = 0.0;
parameter integer CLKOUT5_DIVIDE = 1;
parameter real CLKOUT5_DUTY_CYCLE = 0.5;
parameter real CLKOUT5_PHASE = 0.0;
parameter CLK_FEEDBACK = "CLKFBOUT";
parameter COMPENSATION = "SYSTEM_SYNCHRONOUS";
parameter integer DIVCLK_DIVIDE = 1;
parameter real REF_JITTER = 0.100;
parameter RESET_ON_LOSS_OF_LOCK = "FALSE";
PLL_sim PLL_sim
(.input_clk(CLKIN),
.output_clk(CLKFBOUT),
.pll_mult(CLKFBOUT_MULT),
.pll_div(1),
.locked(LOCKED),
.debug(1'b0)
);
PLL_DIV #(.DIVIDE(CLKOUT0_DIVIDE)) pll_div0
(.clki(CLKFBOUT),
.rst(RST),
.clko(CLKOUT0));
PLL_DIV #(.DIVIDE(CLKOUT1_DIVIDE)) pll_div1
(.clki(CLKFBOUT),
.rst(RST),
.clko(CLKOUT1));
PLL_DIV #(.DIVIDE(CLKOUT2_DIVIDE)) pll_div2
(.clki(CLKFBOUT),
.rst(RST),
.clko(CLKOUT2));
PLL_DIV #(.DIVIDE(CLKOUT3_DIVIDE)) pll_div3
(.clki(CLKFBOUT),
.rst(RST),
.clko(CLKOUT3));
PLL_DIV #(.DIVIDE(CLKOUT4_DIVIDE)) pll_div4
(.clki(CLKFBOUT),
.rst(RST),
.clko(CLKOUT4));
PLL_DIV #(.DIVIDE(CLKOUT5_DIVIDE)) pll_div5
(.clki(CLKFBOUT),
.rst(RST),
.clko(CLKOUT5));
endmodule
module PLL_DIV
#(DIVIDE=1)
(input clki,
input rst,
output clko
);
reg [31:0] cnt;
wire [31:0] next_cnt = cnt + 1;
reg clkdiv;
assign clko = (DIVIDE == 1) ? clki : clkdiv;
always @(posedge clki or posedge rst) begin
if(rst) begin
cnt <= 0;
clkdiv <= 0;
end else begin
if(next_cnt >= DIVIDE) begin
clkdiv <= 0;
cnt <= 0;
end else begin
cnt <= cnt + 1;
if(next_cnt == DIVIDE/2) begin
clkdiv <= 1;
end
end
end
end
endmodule