File: spFunctions.mesa
Copyright (C) 1985 by Xerox Corporation. All rights reserved.
Last Edited by:
Sweetsun Chen, July 22, 1985 8:04:13 pm PDT
DIRECTORY
Real USING [FixI, RealException],
spGlobals USING [EnterFunctions, Failure, function];
spFunctions: CEDAR PROGRAM
IMPORTS Real, spGlobals
EXPORTS spGlobals=
BEGIN
functionError: SIGNAL[s: STRING]= CODE;
SimpleFET: spGlobals.function= {
args indices
Vgate: NAT= 0;
Vsource: NAT= 1;
Vdrain: NAT= 2;
parms indices
Vt: NAT= 0;
Gain: NAT= 1;
Vds, Vgst: REAL;
Vds← args[Vdrain] - args[Vsource];
IF Vds >= 0 THEN {
Vgst← args[Vgate] - args[Vsource] - parms[Vt];
v←
IF Vgst > 0 THEN
IF Vds > Vgst THEN 0.5*parms[Gain]*Vgst*Vgst
ELSE parms[Gain]*(Vgst - 0.5*Vds)*Vds
ELSE 0.01*parms[Gain];
}
ELSE {
Vds← -Vds;
Vgst← args[Vgate] - args[Vdrain] - parms[Vt];
v←
IF Vgst > 0 THEN
IF Vds > Vgst THEN -0.5*parms[Gain]*Vgst*Vgst
ELSE -parms[Gain]*(Vgst - 0.5*Vds)*Vds
ELSE -0.01*parms[Gain];
};
}; -- SimpleFET
PulseGen: spGlobals.function= {
gives OffLevel if t<tDelay EMM May 3, 1985 3:30:49 pm PDT
parms indices
onLevel: NAT= 0;
offLevel: NAT= 1;
period: NAT= 2;
width: NAT= 3;
tRise: NAT= 4;
tFall: NAT= 5;
tDelay: NAT= 6;
time: REAL← t - parms[tDelay];
tRel: REALIF time <= 0.0 THEN parms[width] ELSE
time - Real.FixI[time/parms[period]
! Real.RealException=> spGlobals.Failure[750]]*parms[period];
v←
SELECT tRel FROM
>= parms[width] => parms[offLevel],
< parms[tRise] => parms[offLevel] + (parms[onLevel] - parms[offLevel])*tRel/parms[tRise],
<= parms[width] - parms[tFall] => parms[onLevel],
ENDCASE => parms[offLevel] + (parms[width] - tRel)*
(parms[onLevel] - parms[offLevel])/parms[tFall];
}; -- PulseGen
OneShotGen: spGlobals.function= {
onLevel: NAT= 0;
offLevel: NAT= 1;
width: NAT= 2;
tRise: NAT= 3;
tFall: NAT= 4;
tDelay: NAT= 5;
tRel: REAL← t - parms[tDelay];
v←
IF tRel < 0.0 OR tRel >= parms[width] THEN parms[offLevel]
ELSE
IF tRel < parms[tRise] THEN
parms[offLevel] + (parms[onLevel] - parms[offLevel])*tRel/parms[tRise]
ELSE
IF tRel <= parms[width] - parms[tFall] THEN parms[onLevel]
ELSE parms[offLevel] + (parms[width] - tRel)*
(parms[onLevel] - parms[offLevel])/parms[tFall];
}; -- OneShotGen
StepGen: spGlobals.function= {
onLevel: NAT= 0;
offLevel: NAT= 1;
tRise: NAT= 2;
tDelay: NAT= 3;
v←
IF t <= parms[tDelay] THEN parms[offLevel]
ELSE
IF t >= parms[tDelay] + parms[tRise] THEN parms[onLevel]
ELSE parms[offLevel] + (t - parms[tDelay])*
(parms[onLevel] - parms[offLevel])/parms[tRise];
}; -- StepGen
spGlobals.EnterFunctions[["OneShotGen", OneShotGen, 0, 6]];
spGlobals.EnterFunctions[["PulseGen", PulseGen, 0, 7]];
spGlobals.EnterFunctions[["SimpleFET", SimpleFET, 3, 2]];
spGlobals.EnterFunctions[["StepGen", StepGen, 0, 4]];
END.
CHANGE LOG
Wilhem, April 6, 1982 12:17 PM
Barth, 7-May-82 10:56:56 PDT
Chen, June 7, 1984 8:14:24 pm PDT, cedarized.
McCreight, May 3, 1985 3:30:57 pm PDT, modified PulseGen to give OffLevel if t<tDelay
Chen, July 22, 1985 8:02:42 pm PDT, => Cedar6.0.