summaryrefslogtreecommitdiff
path: root/hdl/pll.sv
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-02-27 17:21:05 -0800
committerJulian Blake Kongslie2022-02-27 17:21:05 -0800
commit0553c4839c06011bd044f69b4913e5c793fdd2ec (patch)
treed11e69863532621fe1fa55cc7e8aa2a8cfa3b727 /hdl/pll.sv
downloadmultipdp8-0553c4839c06011bd044f69b4913e5c793fdd2ec.tar.xz
Initial commit.
Diffstat (limited to '')
-rw-r--r--hdl/pll.sv126
1 files changed, 126 insertions, 0 deletions
diff --git a/hdl/pll.sv b/hdl/pll.sv
new file mode 100644
index 0000000..d348b7c
--- /dev/null
+++ b/hdl/pll.sv
@@ -0,0 +1,126 @@
1module pll
2 #( MULTIPLY_BY = 1
3 , DIVIDE_BY = 1
4 , NATIVE_PERIOD_PICOSECONDS = 20_000
5 )
6 ( input bit native_clk
7 , input bit reset_n
8
9 , output bit target_clk
10 , output bit reset
11 );
12
13enum
14 { NOT_LOCKED
15 , RESET_CYCLE
16 , READY
17 } state = state.first;
18
19bit locked;
20
21`ifndef SYNTHESIS
22
23assign target_clk = native_clk;
24assign locked = 1;
25
26`else
27
28altpll
29 #( .clk0_divide_by(DIVIDE_BY)
30 , .clk0_multiply_by(MULTIPLY_BY)
31 , .inclk0_input_frequency(NATIVE_PERIOD_PICOSECONDS)
32 , .intended_device_family("Cyclone 10 LP")
33 , .operation_mode("NORMAL")
34 , .port_activeclock("PORT_UNUSED")
35 , .port_areset("PORT_USED")
36 , .port_clkbad0("PORT_UNUSED")
37 , .port_clkbad1("PORT_UNUSED")
38 , .port_clkloss("PORT_UNUSED")
39 , .port_clkswitch("PORT_UNUSED")
40 , .port_configupdate("PORT_UNUSED")
41 , .port_fbin("PORT_UNUSED")
42 , .port_inclk0("PORT_USED")
43 , .port_inclk1("PORT_UNUSED")
44 , .port_locked("PORT_USED")
45 , .port_pfdena("PORT_UNUSED")
46 , .port_phasecounterselect("PORT_UNUSED")
47 , .port_phasedone("PORT_UNUSED")
48 , .port_phasestep("PORT_UNUSED")
49 , .port_phaseupdown("PORT_UNUSED")
50 , .port_pllena("PORT_UNUSED")
51 , .port_scanaclr("PORT_UNUSED")
52 , .port_scanclk("PORT_UNUSED")
53 , .port_scanclkena("PORT_UNUSED")
54 , .port_scandata("PORT_UNUSED")
55 , .port_scandataout("PORT_UNUSED")
56 , .port_scandone("PORT_UNUSED")
57 , .port_scanread("PORT_UNUSED")
58 , .port_scanwrite("PORT_UNUSED")
59 , .port_clk0("PORT_USED")
60 , .port_clk1("PORT_UNUSED")
61 , .port_clk2("PORT_UNUSED")
62 , .port_clk3("PORT_UNUSED")
63 , .port_clk4("PORT_UNUSED")
64 , .port_clk5("PORT_UNUSED")
65 , .port_clkena0("PORT_UNUSED")
66 , .port_clkena1("PORT_UNUSED")
67 , .port_clkena2("PORT_UNUSED")
68 , .port_clkena3("PORT_UNUSED")
69 , .port_clkena4("PORT_UNUSED")
70 , .port_clkena5("PORT_UNUSED")
71 , .port_extclk0("PORT_UNUSED")
72 , .port_extclk1("PORT_UNUSED")
73 , .port_extclk2("PORT_UNUSED")
74 , .port_extclk3("PORT_UNUSED")
75 , .self_reset_on_loss_lock("ON")
76 , .width_clock(5)
77 ) pll
78 ( .areset(!reset_n)
79 , .inclk(native_clk)
80 , .clk(target_clk)
81 , .locked(locked)
82 , .activeclock()
83 , .clkbad()
84 , .clkena({6{1'b1}})
85 , .clkloss()
86 , .clkswitch(1'b0)
87 , .configupdate(1'b0)
88 , .extclkena({4{1'b1}})
89 , .fbin(1'b1)
90 , .fbmimicbidir()
91 , .fbout()
92 , .fref()
93 , .icdrclk()
94 , .pfdena(1'b1)
95 , .phasecounterselect({4{1'b1}})
96 , .phasedone()
97 , .phasestep(1'b1)
98 , .phaseupdown(1'b1)
99 , .pllena(1'b1)
100 , .scanaclr(1'b0)
101 , .scanclk(1'b0)
102 , .scanclkena(1'b1)
103 , .scandata(1'b0)
104 , .scandataout()
105 , .scandone()
106 , .scanread(1'b0)
107 , .scanwrite(1'b0)
108 , .sclkout0()
109 , .sclkout1()
110 , .vcooverrange()
111 , .vcounderrange()
112 );
113
114`endif
115
116always_ff @(posedge target_clk) begin
117 if (!reset_n || !locked) begin
118 state = state.first;
119 end else if (state != state.last) begin
120 state = state.next;
121 end
122
123 reset = !(state == state.last);
124end
125
126endmodule