module vco(in, out);
`define M_PI 3
parameter real amplitude =1.0, centre_frequency = 1K, gain = 1K ;
parameter integer steps_per_cycle=20;
localparam real omegac =2.0* `M_PI * centre_frequency, omega_gain =2.0* `M_PI * gain ;
electrical in, out ;
analog begin : main
real vin, instantaneousFreq ;
vin = V(in);
V(out)<+ amplitude*sin(idt(vin*omega_gain+omegac,0.0));// Use $bound_step system task to limit time step // This is to ensure that sine wave is rendered with // adequate detail.
instantaneousFreq = centre_frequency + gain * vin ;
$bound_step (1.0/ instantaneousFreq / steps_per_cycle);
end
endmodule