summaryrefslogtreecommitdiff
path: root/hdl
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-04-15 16:39:58 -0700
committerJulian Blake Kongslie2021-04-15 16:39:58 -0700
commitabd9703a1b96225db0d7317bf8833467150bae26 (patch)
tree1cafad36a4e4773b32fa38e6ca16fa0ca37dcbd1 /hdl
parentFix timing declarations for PLL in Quartus assignments. (diff)
downloadnoncpu-abd9703a1b96225db0d7317bf8833467150bae26.tar.xz
Change synthesis of PLL wrapper to avoid latch logic.pre-dp-8
Diffstat (limited to '')
-rw-r--r--hdl/clock.sv48
-rw-r--r--hdl/top.sv4
2 files changed, 20 insertions, 32 deletions
diff --git a/hdl/clock.sv b/hdl/clock.sv
index b33645b..0a6633d 100644
--- a/hdl/clock.sv
+++ b/hdl/clock.sv
@@ -1,8 +1,8 @@
1`include "util.svh" 1`include "util.svh"
2 2
3module clock 3module clock
4 #( DIVIDE_BY = 1 4 #( MULTIPLY_BY = 1
5 , MULTIPLY_BY = 1 5 , DIVIDE_BY = 1
6 , NATIVE_PERIOD_PICOSECONDS = 20_000 6 , NATIVE_PERIOD_PICOSECONDS = 20_000
7 ) 7 )
8 ( input bit native_clk 8 ( input bit native_clk
@@ -13,30 +13,26 @@ module clock
13 ); 13 );
14 14
15enum 15enum
16 { AWAIT_LOCKED 16 { NOT_LOCKED
17 , AWAIT_LOW 17 , RESET_CYCLE
18 , AWAIT_HIGH
19 , AWAIT_LOW_2
20 , READY 18 , READY
21 } state = state.first; 19 } state = state.first;
22 20
23bit locked; 21bit locked;
24 22
25`ifdef SYNTHESIS 23`ifndef SYNTHESIS
24
25assign target_clk = native_clk;
26assign locked = 1;
27
28`else
26 29
27altpll 30altpll
28 #( .bandwidth_type("AUTO") 31 #( .clk0_divide_by(DIVIDE_BY)
29 , .clk0_divide_by(DIVIDE_BY)
30 , .clk0_duty_cycle(50)
31 , .clk0_multiply_by(MULTIPLY_BY) 32 , .clk0_multiply_by(MULTIPLY_BY)
32 , .clk0_phase_shift(0)
33 , .compensate_clock("CLK0")
34 , .inclk0_input_frequency(NATIVE_PERIOD_PICOSECONDS) 33 , .inclk0_input_frequency(NATIVE_PERIOD_PICOSECONDS)
35 , .intended_device_family("Cyclone 10 LP") 34 , .intended_device_family("Cyclone 10 LP")
36 , .lpm_hint("CBX_MODULE_PREFIX=clock")
37 , .lpm_type("altpll")
38 , .operation_mode("NORMAL") 35 , .operation_mode("NORMAL")
39 , .pll_type("AUTO")
40 , .port_activeclock("PORT_UNUSED") 36 , .port_activeclock("PORT_UNUSED")
41 , .port_areset("PORT_USED") 37 , .port_areset("PORT_USED")
42 , .port_clkbad0("PORT_UNUSED") 38 , .port_clkbad0("PORT_UNUSED")
@@ -119,22 +115,14 @@ altpll
119 115
120`endif 116`endif
121 117
122always_latch begin 118always_ff @(posedge target_clk) begin
123 `ifndef SYNTHESIS 119 if (!reset_n || !locked) begin
124 target_clk = native_clk; 120 state = state.first;
125 locked = 1; 121 end else if (state != state.last) begin
126 `endif 122 state = state.next;
127 123 end
128 if (!reset_n || !locked) state = AWAIT_LOCKED;
129
130 case (state)
131 AWAIT_LOCKED: if (locked) state = AWAIT_LOW;
132 AWAIT_LOW: if (!target_clk) state = AWAIT_HIGH;
133 AWAIT_HIGH: if (target_clk) state = AWAIT_LOW_2;
134 AWAIT_LOW_2: if (!target_clk) state = READY;
135 endcase
136 124
137 reset = !(state == READY); 125 reset = !(state == state.last);
138end 126end
139 127
140endmodule 128endmodule
diff --git a/hdl/top.sv b/hdl/top.sv
index 46620cb..0aebd77 100644
--- a/hdl/top.sv
+++ b/hdl/top.sv
@@ -12,8 +12,8 @@ bit clk;
12bit reset; 12bit reset;
13 13
14clock 14clock
15 #( .DIVIDE_BY(10) 15 #( .MULTIPLY_BY(9)
16 , .MULTIPLY_BY(9) 16 , .DIVIDE_BY(10)
17 ) pll 17 ) pll
18 ( .native_clk(native_clk) 18 ( .native_clk(native_clk)
19 , .reset_n(reset_n) 19 , .reset_n(reset_n)