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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
`include "util.svh"
module clock
#( MULTIPLY_BY = 1
, DIVIDE_BY = 1
, NATIVE_PERIOD_PICOSECONDS = 20_000
)
( input bit native_clk
, input bit reset_n
, output bit target_clk
, output bit reset
);
enum
{ NOT_LOCKED
, RESET_CYCLE
, READY
} state = state.first;
bit locked;
`ifndef SYNTHESIS
assign target_clk = native_clk;
assign locked = 1;
`else
altpll
#( .clk0_divide_by(DIVIDE_BY)
, .clk0_multiply_by(MULTIPLY_BY)
, .inclk0_input_frequency(NATIVE_PERIOD_PICOSECONDS)
, .intended_device_family("Cyclone 10 LP")
, .operation_mode("NORMAL")
, .port_activeclock("PORT_UNUSED")
, .port_areset("PORT_USED")
, .port_clkbad0("PORT_UNUSED")
, .port_clkbad1("PORT_UNUSED")
, .port_clkloss("PORT_UNUSED")
, .port_clkswitch("PORT_UNUSED")
, .port_configupdate("PORT_UNUSED")
, .port_fbin("PORT_UNUSED")
, .port_inclk0("PORT_USED")
, .port_inclk1("PORT_UNUSED")
, .port_locked("PORT_USED")
, .port_pfdena("PORT_UNUSED")
, .port_phasecounterselect("PORT_UNUSED")
, .port_phasedone("PORT_UNUSED")
, .port_phasestep("PORT_UNUSED")
, .port_phaseupdown("PORT_UNUSED")
, .port_pllena("PORT_UNUSED")
, .port_scanaclr("PORT_UNUSED")
, .port_scanclk("PORT_UNUSED")
, .port_scanclkena("PORT_UNUSED")
, .port_scandata("PORT_UNUSED")
, .port_scandataout("PORT_UNUSED")
, .port_scandone("PORT_UNUSED")
, .port_scanread("PORT_UNUSED")
, .port_scanwrite("PORT_UNUSED")
, .port_clk0("PORT_USED")
, .port_clk1("PORT_UNUSED")
, .port_clk2("PORT_UNUSED")
, .port_clk3("PORT_UNUSED")
, .port_clk4("PORT_UNUSED")
, .port_clk5("PORT_UNUSED")
, .port_clkena0("PORT_UNUSED")
, .port_clkena1("PORT_UNUSED")
, .port_clkena2("PORT_UNUSED")
, .port_clkena3("PORT_UNUSED")
, .port_clkena4("PORT_UNUSED")
, .port_clkena5("PORT_UNUSED")
, .port_extclk0("PORT_UNUSED")
, .port_extclk1("PORT_UNUSED")
, .port_extclk2("PORT_UNUSED")
, .port_extclk3("PORT_UNUSED")
, .self_reset_on_loss_lock("ON")
, .width_clock(5)
) pll
( .areset(!reset_n)
, .inclk(native_clk)
, .clk(target_clk)
, .locked(locked)
, .activeclock()
, .clkbad()
, .clkena({6{1'b1}})
, .clkloss()
, .clkswitch(1'b0)
, .configupdate(1'b0)
, .extclkena({4{1'b1}})
, .fbin(1'b1)
, .fbmimicbidir()
, .fbout()
, .fref()
, .icdrclk()
, .pfdena(1'b1)
, .phasecounterselect({4{1'b1}})
, .phasedone()
, .phasestep(1'b1)
, .phaseupdown(1'b1)
, .pllena(1'b1)
, .scanaclr(1'b0)
, .scanclk(1'b0)
, .scanclkena(1'b1)
, .scandata(1'b0)
, .scandataout()
, .scandone()
, .scanread(1'b0)
, .scanwrite(1'b0)
, .sclkout0()
, .sclkout1()
, .vcooverrange()
, .vcounderrange()
);
`endif
always_ff @(posedge target_clk) begin
if (!reset_n || !locked) begin
state = state.first;
end else if (state != state.last) begin
state = state.next;
end
reset = !(state == state.last);
end
endmodule
|