blob: 77cce426039ecf4deaf93f3667ff2dfe76b3f17e [file] [log] [blame]
Tim Edwardscd64af52020-08-07 11:11:58 -04001// 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
shalanfd13eb52020-08-21 16:48:07 +02007module digital_pll(
8`ifdef LVS
9 vdd,
10 vss,
11`endif
Tim Edwards3245e2f2020-10-10 14:02:11 -040012 resetb, enable, osc, clockp, div, dco, ext_trim);
shalanfd13eb52020-08-21 16:48:07 +020013
14`ifdef LVS
15 input vdd;
16 input vss;
17`endif
Tim Edwardscd64af52020-08-07 11:11:58 -040018
Tim Edwards3245e2f2020-10-10 14:02:11 -040019 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 Edwardscd64af52020-08-07 11:11:58 -040024 input [25:0] ext_trim; // External trim for DCO mode
25
Tim Edwardscd64af52020-08-07 11:11:58 -040026 output [1:0] clockp; // Two 90 degree clock phases
Tim Edwardscd64af52020-08-07 11:11:58 -040027
Tim Edwards3245e2f2020-10-10 14:02:11 -040028 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 Edwardscd64af52020-08-07 11:11:58 -040032
Tim Edwards3245e2f2020-10-10 14:02:11 -040033 assign ireset = ~resetb | ~enable;
Tim Edwardscd64af52020-08-07 11:11:58 -040034
35 // In DCO mode: Hold controller in reset and apply external trim value
Tim Edwards3245e2f2020-10-10 14:02:11 -040036
Tim Edwardscd64af52020-08-07 11:11:58 -040037 assign itrim = (dco == 1'b0) ? otrim : ext_trim;
38 assign creset = (dco == 1'b0) ? ireset : 1'b1;
39
40 ring_osc2x13 ringosc (
Tim Edwards04ba17f2020-10-02 22:27:50 -040041 .reset(ireset),
42 .trim(itrim),
43 .clockp(clockp)
Tim Edwardscd64af52020-08-07 11:11:58 -040044 );
45
46 digital_pll_controller pll_control (
Tim Edwards04ba17f2020-10-02 22:27:50 -040047 .reset(creset),
48 .clock(clockp[0]),
49 .osc(osc),
50 .div(div),
51 .trim(otrim)
Tim Edwardscd64af52020-08-07 11:11:58 -040052 );
53
Tim Edwardscd64af52020-08-07 11:11:58 -040054endmodule