Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 1 | // Digital PLL (ring oscillator + controller) |
| 2 | // Technically this is a frequency locked loop, not a phase locked loop. |
| 3 | |
| 4 | `include "digital_pll_controller.v" |
| 5 | `include "ring_osc2x13.v" |
| 6 | |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 7 | module digital_pll( |
| 8 | `ifdef LVS |
| 9 | vdd, |
| 10 | vss, |
| 11 | `endif |
Tim Edwards | 3245e2f | 2020-10-10 14:02:11 -0400 | [diff] [blame] | 12 | resetb, enable, osc, clockp, div, dco, ext_trim); |
shalan | fd13eb5 | 2020-08-21 16:48:07 +0200 | [diff] [blame] | 13 | |
| 14 | `ifdef LVS |
| 15 | input vdd; |
| 16 | input vss; |
| 17 | `endif |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 18 | |
Tim Edwards | 3245e2f | 2020-10-10 14:02:11 -0400 | [diff] [blame] | 19 | input resetb; // Sense negative reset |
| 20 | input enable; // Enable PLL |
| 21 | input osc; // Input oscillator to match |
| 22 | input [4:0] div; // PLL feedback division ratio |
| 23 | input dco; // Run in DCO mode |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 24 | input [25:0] ext_trim; // External trim for DCO mode |
| 25 | |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 26 | output [1:0] clockp; // Two 90 degree clock phases |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 27 | |
Tim Edwards | 3245e2f | 2020-10-10 14:02:11 -0400 | [diff] [blame] | 28 | wire [25:0] itrim; // Internally generated trim bits |
| 29 | wire [25:0] otrim; // Trim bits applied to the ring oscillator |
| 30 | wire creset; // Controller reset |
| 31 | wire ireset; // Internal reset (external reset OR disable) |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 32 | |
Tim Edwards | 3245e2f | 2020-10-10 14:02:11 -0400 | [diff] [blame] | 33 | assign ireset = ~resetb | ~enable; |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 34 | |
| 35 | // In DCO mode: Hold controller in reset and apply external trim value |
Tim Edwards | 3245e2f | 2020-10-10 14:02:11 -0400 | [diff] [blame] | 36 | |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 37 | assign itrim = (dco == 1'b0) ? otrim : ext_trim; |
| 38 | assign creset = (dco == 1'b0) ? ireset : 1'b1; |
| 39 | |
| 40 | ring_osc2x13 ringosc ( |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 41 | .reset(ireset), |
| 42 | .trim(itrim), |
| 43 | .clockp(clockp) |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 44 | ); |
| 45 | |
| 46 | digital_pll_controller pll_control ( |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 47 | .reset(creset), |
| 48 | .clock(clockp[0]), |
| 49 | .osc(osc), |
| 50 | .div(div), |
| 51 | .trim(otrim) |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 52 | ); |
| 53 | |
Tim Edwards | cd64af5 | 2020-08-07 11:11:58 -0400 | [diff] [blame] | 54 | endmodule |