// Copyright 2012 Accellera Systems Initiative // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at: // http://www.apache.org/licenses/LICENSE-2.0 // Voltage controlled sinus oscillator `include "disciplines.vams" `include "constants.vams" module vco(in, out); input in; output out; voltage in, out; parameter real f0 = 1.0M from (0:inf); // center frequency parameter real kf = 100K; // frequency coefficient Hz/V parameter real lockrange = 3; // lockrange according input voltage parameter real vin_offset = 0; // input dc offset, e.g. // V(in)=vin_offset -> f0 parameter real vout_offset = 0; // output dc offset parameter real vout_mag = 1; // output magnitude parameter real phi0 = 0; // dc phase, given in radian real vin; 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*$abstime + phi0); end endmodule