AggerCounterRoseDetails.mesa
Copyright © 1985 by Xerox Corporation. All rights reversed.
Spreitzer, October 22, 1985 6:42:10 pm PDT
DIRECTORY BasicTime, BitTwiddling, Core, CoreProperties, GetMe, IO, Rope, RoseBehavior, AggerCounterRoseDefs;
AggerCounterRoseDetails: CEDAR PROGRAM
IMPORTS GetMe, RoseBehavior
=
BEGIN OPEN RoseBehavior, AggerCounterRoseDefs;
CounterState: TYPE = REF CounterStatePrivate;
CounterStatePrivate: TYPE = RECORD [
val: PACKED SEQUENCE length: NAT OF RECORD [cur, next: BOOL]];
EvalCounter
: PROC [
argsAny, switchAny, simpleAny, strengthAny, stateAny: REF ANY,
perturb: PROC [portPath: PortPath]
]
= {
io: REF AggerCounterSimple = NARROW[simpleAny];
drive: REF AggerCounterDrive = NARROW[strengthAny];
state: CounterState = NARROW[stateAny];
drive.clocks.phA ← drive.clocks.phB ← drive.load ← drive.io.in ← none;
drive.io.out ← IF io.clocks.phB THEN drive ELSE none;
IF io.clocks.phA THEN {
do: {Flip, Copy} ← Flip;
FOR i: NAT DECREASING IN [0 .. state.length) DO
IF do = Flip THEN {
IF (state[i].next ← NOT state[i].cur) THEN do ← Copy
}
ELSE state[i].next ← state[i].cur;
ENDLOOP;
};
IF io.load THEN FOR i: NAT IN [0 .. state.length) DO state[i].next ← io.io.in[i] ENDLOOP;
IF io.clocks.phB THEN FOR i: NAT IN [0 .. state.length) DO
io.io.out[i] ← state[i].cur ← state[i].next;
ENDLOOP;
};
CreateCounterState: PROC [argsAny: REF ANYNIL] RETURNS [stateAny: REF ANYNIL] = {
rw: REF INT = NARROW[argsAny];
stateAny ← NEW [CounterStatePrivate[rw^]];
};
RegisterDetails[
"AggerCounter",
NEW [DetailsRec ← [EvalSimple: EvalCounter, CreateState: CreateCounterState]],
GetMe.GetVersion[]
];
END.