`include "disciplines.vams" `include "constants.vams" //-------------------------------------------------- // sinusoidal source //-------------------------------------------------- //From SMASH module VSIN(p, n); //modified by Daniel Anderson inout p, n; electrical p, n; //when paramaters are not passed these will be the default values used parameter real ampl = 1.0; //signal amplitude parameter real f = 1k; //signal freq parameter real offset = 0.0; //signal offset parameter real phi = 0.0; parameter real mag = 0.0; analog //M_PI term is pi as defined by constants.vams file V(p,n) <+ ampl * sin(2 * `M_PI * f * \$abstime + phi) + offset + ac_stim("ac", mag); //generates an ac stimulus based on given magnitude.; endmodule //-------------------------------------------------- // DC source //-------------------------------------------------- ////From Designer's Guide Community `timescale 1ns/1ps module VDC (p, n); inout p, n; electrical p, n; parameter real dc = 2.0; //fixed DC value analog V(p,n) <+ dc; endmodule //-------------------------------------------------- // AC source //-------------------------------------------------- //From Designer's Guide Community module VAC (p,n); inout p,n; electrical p, n; parameter real dc = 0; parameter real mag = 1; analog begin V(p,n) <+ dc + ac_stim("ac", mag); //generates an ac stimulus based on given magnitude. end endmodule //-------------------------------------------------- // PULSE source //-------------------------------------------------- //based on VAMS reference Guide; //written by Daniel Anderson module VPULSE (p,n); inout p,n; electrical p, n; //default parameter values; will be overwritten when values are passed through parameter real val0 = 0; //start value parameter real val1= 1; //end value parameter real td = 2n; //delay time parameter real rise = 100p; //rise time parameter real fall = 100p; //fall time parameter real width= 10n; //pusle width parameter real period = 20n; //period width parameter real cycles = 1e100; //number of cycles; must be greaer than 0 (integer only) parameter real mag = 1.0; real t,t0,t1,t2,t3,t4,Vout; real cnt = 0; analog begin t = \$abstime; //absolute time; real time in seconds during simulation t0 = td + cnt*period; //starting time t1 = rise+td+cnt*period; t2 = width+rise+td+cnt*period; t3 = fall+width+rise+td+cnt*period; t4 = td+(cnt+1)*period; if (t <= t0) Vout = val0; else if( (t0