module vco(in,out); input in; output out; voltage in,out; // SJM added voltage vin; parameter real f0 = 1.0M from (0:inf), // center frequency kf = 100K, // frequency coefficient Hz/V lockrange = 3, // lockrange according input voltage vin_offset = 0, // input dc offset, e.g. V(in)=vin_offs et -> f0 vout_offset = 0, // output dc offset vout_mag = 1, // output magnitude phi0 = 0; // dc phase, given in radian real w; analog begin vin = V(in) - vin_offset; if (vin > lockrange) vin = lockrange; else if (vin < -lockrange) vin = -lockrange; w = `M_TWO_PI * (f0 + kf*vin); V(out) <+ vout_offset + vout_mag*sin(w*$realtime + phi0); end endmodule