`include "discipline.h"
`include "constants.h"

module vco(in, out);
input in; output out;
voltage in;
phase out;
parameter real gain = 1 from (0:inf); // transfer gain, Kvco (Hz/V)
parameter real n = 0 from [0:inf); // white output phase noise at 1 Hz (rad2/Hz)
parameter real fc = 0 from [0:inf); // flicker noise corner frequency (Hz)
analog begin
Theta(out) <+ 2*`M_PI*gain*idt(V(in));
Theta(out) <+ flicker_noise(n, 2, "wpn") + flicker_noise(n*fc, 3, "fpn");
end
endmodule