diff options
| author | Julian Blake Kongslie | 2021-04-15 16:39:58 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2021-04-15 16:39:58 -0700 |
| commit | abd9703a1b96225db0d7317bf8833467150bae26 (patch) | |
| tree | 1cafad36a4e4773b32fa38e6ca16fa0ca37dcbd1 /hdl | |
| parent | Fix timing declarations for PLL in Quartus assignments. (diff) | |
| download | noncpu-pre-dp-8.tar.xz | |
Change synthesis of PLL wrapper to avoid latch logic.pre-dp-8
Diffstat (limited to '')
| -rw-r--r-- | hdl/clock.sv | 48 | ||||
| -rw-r--r-- | hdl/top.sv | 4 |
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 | ||
| 3 | module clock | 3 | module 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 | ||
| 15 | enum | 15 | enum |
| 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 | ||
| 23 | bit locked; | 21 | bit locked; |
| 24 | 22 | ||
| 25 | `ifdef SYNTHESIS | 23 | `ifndef SYNTHESIS |
| 24 | |||
| 25 | assign target_clk = native_clk; | ||
| 26 | assign locked = 1; | ||
| 27 | |||
| 28 | `else | ||
| 26 | 29 | ||
| 27 | altpll | 30 | altpll |
| 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 | ||
| 122 | always_latch begin | 118 | always_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); |
| 138 | end | 126 | end |
| 139 | 127 | ||
| 140 | endmodule | 128 | endmodule |
| @@ -12,8 +12,8 @@ bit clk; | |||
| 12 | bit reset; | 12 | bit reset; |
| 13 | 13 | ||
| 14 | clock | 14 | clock |
| 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) |
