TransistorRoseDetails.mesa
Copyright © 1985 by Xerox Corporation. All rights reversed.
Barth, August 1, 1985 2:31:39 pm PDT
Spreitzer, October 1, 1985 6:54:39 pm PDT
DIRECTORY Core, CoreTransistor, GetMe, RoseBehavior, TransistorRoseDefs;
TransistorRoseDetails: CEDAR PROGRAM
IMPORTS GetMe, RoseBehavior, TransistorRoseDefs
=
BEGIN OPEN CoreTransistor, RoseBehavior, TransistorRoseDefs;
Conductance: TYPE = {Off, On, Indeterminate};
ComputeState: ARRAY TransistorType OF ARRAY Level OF Conductance = [
nE: [L: Off, H: On, X: Indeterminate],
pE: [L: On, H: Off, X: Indeterminate],
nD: ALL[On]
];
TransistorStateRef: TYPE = REF TransistorStateRec;
TransistorStateRec: TYPE = RECORD [
strength: Strength ← drive,
conductance: Conductance];
CreateState: PROC [argsAny: REF ANYNIL] RETURNS [stateAny: REF ANYNIL] = {
t: Transistor = NARROW[argsAny];
ts: TransistorStateRef ← NEW [TransistorStateRec ← [
conductance: Indeterminate
]];
stateAny ← ts;
};
EnumerateVicinity
: PROC [
argsAny, stateAny: REF ANY,
portPath: PortPath,
evenIfInput: BOOLFALSE,
consume: PROC [PortPath]
]
= {
state: TransistorStateRef = NARROW[stateAny];
NotOff: PROC RETURNS [no: BOOL] = INLINE {
no ← SELECT state.conductance FROM
On, Indeterminate => TRUE,
Off => FALSE,
ENDCASE => ERROR};
IF portPath = NIL OR portPath.rest # NIL THEN ERROR;
SELECT portPath.first FROM
Transistorgate.first => NULL;
Transistorch1.first => IF NotOff[] THEN consume[Transistorch2];
Transistorch2.first => IF NotOff[] THEN consume[Transistorch1];
Transistorback.first => NULL;
ENDCASE => ERROR;
};
ValsChanged: PROC [argsAny, switchAny, simpleAny, strengthAny, stateAny: REF ANY, perturb: PROC [portPath: PortPath]] = {
t: Transistor = NARROW[argsAny];
state: TransistorStateRef = NARROW[stateAny];
io: REF TransistorSwitch = NARROW[switchAny];
{OPEN t, state, io;
SELECT type FROM
nE, pE => {
new: Conductance ← ComputeState[type][gate.val];
IF new # conductance THEN {
conductance ← new;
perturb[Transistorch1];
perturb[Transistorch2];
}
};
nD => NULL;
ENDCASE => ERROR;
};
};
PropQ: PROC [argsAny, switchAny, simpleAny, strengthAny, stateAny: REF ANY, perturb: PROC [portPath: PortPath]] = {
t: Transistor = NARROW[argsAny];
state: TransistorStateRef = NARROW[stateAny];
io: REF TransistorSwitch = NARROW[switchAny];
{OPEN t, state, io;
cs: Strength = SELECT conductance FROM
On => strength,
Off, Indeterminate => none,
ENDCASE => ERROR;
IF cs > none THEN {
ch1.s[q] ← MAX[ch1.s[q], MIN[cs, ch2.s[q]]];
ch2.s[q] ← MAX[ch2.s[q], MIN[cs, ch1.s[q]]];
};
};
};
PropUD: PROC [argsAny, switchAny, simpleAny, strengthAny, stateAny: REF ANY, perturb: PROC [portPath: PortPath]] = {
t: Transistor = NARROW[argsAny];
state: TransistorStateRef = NARROW[stateAny];
io: REF TransistorSwitch = NARROW[switchAny];
{OPEN t, state, io;
cs: Strength = SELECT conductance FROM
On, Indeterminate => strength,
Off => none,
ENDCASE => ERROR;
IF cs > none THEN {
ch1.s[u] ← MAX[ch1.s[u], MIN[cs, ch2.s[u]]];
ch1.s[d] ← MAX[ch1.s[d], MIN[cs, ch2.s[d]]];
ch2.s[u] ← MAX[ch2.s[u], MIN[cs, ch1.s[u]]];
ch2.s[d] ← MAX[ch2.s[d], MIN[cs, ch1.s[d]]];
};
};
};
RegisterDetails[
behaviorClassName: "Transistor",
details: NEW [DetailsRec ← [
ValsChanged: ValsChanged,
PropQ: PropQ,
PropUD: PropUD,
EnumerateVicinity: EnumerateVicinity,
CreateState: CreateState
]],
versionStamp: GetMe.GetVersion[]
];
END.