blob: 2f3fc2ad4d80b83a5060f7fc0697f44f9102ab27 [file] [log] [blame]
Matt Venn08cd6eb2020-11-16 12:01:14 +01001`default_nettype none
Tim Edwardscd64af52020-08-07 11:11:58 -04002// Digital PLL (ring oscillator + controller)
3// Technically this is a frequency locked loop, not a phase locked loop.
4
5`include "digital_pll_controller.v"
6`include "ring_osc2x13.v"
7
shalanfd13eb52020-08-21 16:48:07 +02008module digital_pll(
Manar61dce922020-11-10 19:26:28 +02009`ifdef USE_POWER_PINS
shalanfd13eb52020-08-21 16:48:07 +020010 vdd,
11 vss,
12`endif
Tim Edwards3245e2f2020-10-10 14:02:11 -040013 resetb, enable, osc, clockp, div, dco, ext_trim);
shalanfd13eb52020-08-21 16:48:07 +020014
Manar61dce922020-11-10 19:26:28 +020015`ifdef USE_POWER_PINS
shalanfd13eb52020-08-21 16:48:07 +020016 input vdd;
17 input vss;
18`endif
Tim Edwardscd64af52020-08-07 11:11:58 -040019
Tim Edwards3245e2f2020-10-10 14:02:11 -040020 input resetb; // Sense negative reset
21 input enable; // Enable PLL
22 input osc; // Input oscillator to match
23 input [4:0] div; // PLL feedback division ratio
24 input dco; // Run in DCO mode
Tim Edwardscd64af52020-08-07 11:11:58 -040025 input [25:0] ext_trim; // External trim for DCO mode
26
Tim Edwardscd64af52020-08-07 11:11:58 -040027 output [1:0] clockp; // Two 90 degree clock phases
Tim Edwardscd64af52020-08-07 11:11:58 -040028
Tim Edwards3245e2f2020-10-10 14:02:11 -040029 wire [25:0] itrim; // Internally generated trim bits
30 wire [25:0] otrim; // Trim bits applied to the ring oscillator
31 wire creset; // Controller reset
32 wire ireset; // Internal reset (external reset OR disable)
Tim Edwardscd64af52020-08-07 11:11:58 -040033
Tim Edwards3245e2f2020-10-10 14:02:11 -040034 assign ireset = ~resetb | ~enable;
Tim Edwardscd64af52020-08-07 11:11:58 -040035
36 // In DCO mode: Hold controller in reset and apply external trim value
Tim Edwards3245e2f2020-10-10 14:02:11 -040037
Tim Edwardscd64af52020-08-07 11:11:58 -040038 assign itrim = (dco == 1'b0) ? otrim : ext_trim;
39 assign creset = (dco == 1'b0) ? ireset : 1'b1;
40
41 ring_osc2x13 ringosc (
Tim Edwards04ba17f2020-10-02 22:27:50 -040042 .reset(ireset),
43 .trim(itrim),
44 .clockp(clockp)
Tim Edwardscd64af52020-08-07 11:11:58 -040045 );
46
47 digital_pll_controller pll_control (
Tim Edwards04ba17f2020-10-02 22:27:50 -040048 .reset(creset),
49 .clock(clockp[0]),
50 .osc(osc),
51 .div(div),
52 .trim(otrim)
Tim Edwardscd64af52020-08-07 11:11:58 -040053 );
54
Tim Edwardscd64af52020-08-07 11:11:58 -040055endmodule
Tim Edwards581068f2020-11-19 12:45:25 -050056`default_nettype wire