RosemaryUser.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Barth, December 17, 1987 4:22:58 pm PST
Bertrand Serlet October 17, 1986 10:03:12 pm PDT
Last Edited by: Gasbarro October 14, 1987 10:26:38 am PDT
Jean-Marc Frailong December 24, 1987 5:49:23 pm PST
DIRECTORY Buttons, ChoiceButtons, Core, CoreFlat, RefTab, IO, PlotGraph, Ports, Rosemary, ViewerClasses;
RosemaryUser: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Core.ROPE;
Client Controlled Simulations
NOTE: The procedures in this section are low-level procedures for clients who do not wish to use the Tester abstraction. Reading the implementation of the tester abstraction may help the foolhardy.
DisplayViewer: PROC [simulation: Rosemary.Simulation, cellType: Core.CellType, name: ROPENIL, displayWires: CoreFlat.FlatWires ← NIL, graphWires: CoreFlat.FlatWires ← NIL] RETURNS [handle: RoseDisplay];
LogSettle: PROC [handle: RoseDisplay, time: INT, memory: BOOLTRUE];
Same as Rosemary.Settle but pays attention to the log button and records changes.
UpdateDisplay: PROC [handle: RoseDisplay];
InitializeDeltas: PROC [handle: RoseDisplay];
Resets the initial state of all the wires to the current state.
RecordDelta: PROC [handle: RoseDisplay, wire: Rosemary.RoseWire, time: INT];
Must be called from a Rosemary.UpdateProc if plotting is to be used.
DeltaFinished: PROC [handle: RoseDisplay, time: INT];
Says that data is valid up to time.
RecordStateSample: PROC [handle: RoseDisplay, roseInstance: Rosemary.RoseCellInstance, value: Ports.LevelSequence, time: INT];
To be called by Rosemary.InitProc procedures when the state is initialized and Rosemary.EvalProc procedures whenever the state changes. The implementation, not the client, is responsible for saving only the last sample for a given Eval call. The level sequence is owned by the client.
Test Procedure Simulations
TestProcedureViewer: PROC [cellType: Core.CellType, testButtons: LIST OF ROPE, name: ROPENIL, displayWires: CoreFlat.FlatWires ← NIL, graphWires: CoreFlat.FlatWires ← NIL, cutSet: CoreFlat.CutSet ← NIL, historySize: NAT ← 0, steady: BOOLFALSE, recordDeltas: BOOLTRUE] RETURNS [tester: Tester];
Create the tester and its viewer. When the viewer is destroyed, all associated viewers and data structures will also be destroyed.
StartTest: PROC [tester: Tester];
SetProceedUntil: PROC [tester: Tester, count: INT];
RegisterTestProc: PROC [name: ROPE, proc: TestProc];
TestProc: TYPE = PROC [simulation: Rosemary.Simulation, cellType: Core.CellType, p: Ports.Port, Eval: TestEvalProc];
TestEvalProc: TYPE = PROC [memory: BOOLTRUE, clockEval: BOOLFALSE, checkPorts: BOOLTRUE];
Wire Display and Access
RoseDisplayFor: PROC [cellType: Core.CellType] RETURNS [RoseDisplay];
Recover the RoseDisplay structure associated to a celltype
DisplayPortLeafWires: PROC [root: Core.CellType, flatCell: CoreFlat.FlatCellTypeRec ← CoreFlat.rootCellType] RETURNS [displayWires: CoreFlat.FlatWires];
AddWireToPlot: PROC [handle: RoseDisplay, wire: CoreFlat.FlatWire] RETURNS [msg: ROPENIL];
RemoveWireFromPlot: PROC [handle: RoseDisplay, wire: CoreFlat.FlatWire] RETURNS [found: BOOLFALSE];
WireTimeValue: PROC [handle: RoseDisplay, flatWire: CoreFlat.FlatWire, time: INT] RETURNS [value: Ports.LevelSequence];
Gets the value of the wire. May raise Rosemary.NotInstantiated. Will return NIL if information is not available.
State Display and Access
AddStateToPlot: PROC [handle: RoseDisplay, flatCell: CoreFlat.FlatCellType, data: REF ANY NIL] RETURNS [msg: ROPENIL];
Adds the state vector of the specified flatCell to the plot. Implementation calls stateToRope found by CoreProperties.InheritCellTypeProp for each displayed state or calls Ports.LSToRope if not found.
RemoveStateFromPlot: PROC [handle: RoseDisplay, flatCell: CoreFlat.FlatCellType, data: REF ANY NIL] RETURNS [found: BOOLFALSE];
stateToMaxCharsProcProp: ATOM; -- $RoseStateToMaxCharsProc
Put this on the cell type or cell class.
StateToMaxCharsProc: TYPE = PROC [stateAny: REF ANY, data: REF ANYNIL] RETURNS [maxChars: NAT ← 0];
Sets the maximum number of characters that will be returned by the StateToRopeProc
stateToRopeProcProp: ATOM; -- $RoseStateToRopeProc
Put this on the cell type or cell class to provide coercion from level sequence to rope.
StateToRopeProc: TYPE = PROC [stateAny: REF ANY, value: Ports.LevelSequence, data: REF ANY NIL] RETURNS [rope: ROPE];
The level sequence is owned by the implementation. The client should not alter the contents nor should it retain the ref with the expectation that the value will not change.
StateTimeValue: PROC [handle: RoseDisplay, flatCell: CoreFlat.FlatCellType, time: INT] RETURNS [value: Ports.LevelSequence];
Gets the value of the cell state encoded as an LS. May raise Rosemary.NotInstantiated. Will return NIL if information is not available.
Odds and ends
CheckCoverage: PROC [handle: RoseDisplay] RETURNS [ok: BOOL];
Returns TRUE iff all nodes in the simulation reach the H and L levels. Nodes that do not are printed on the simulation log.
Data Structures
Not intended to be understood by clients.
Tester: TYPE = REF TesterRec;
TesterRec: TYPE = RECORD [
intermediatePort: Ports.Port ← NIL,
runState: ViewerClasses.Viewer ← NIL,
evalsSinceStart: ViewerClasses.Viewer ← NIL,
evalSinceStartCount: INT,
proceedUntil: ViewerClasses.Viewer ← NIL,
evalUntil: INT,
historyTrigger: ViewerClasses.Viewer ← NIL,
historyTriggerCount: INT,
currentStatePoint: NAT ← 0,
displayedStatePoint: NAT ← 0,
validStates: NAT ← 0,
historySize: NAT ← 0,
testVectorBuffer: Rosemary.PortSequence ← NIL,
proceed: CONDITION,
testStarted: BOOLFALSE,
waiting: BOOLFALSE,
abort: BOOLFALSE,
interrupt: BOOLFALSE,
singleEval: BOOLFALSE,
testButtonList: LIST OF Buttons.Button,
currentTestProc: ROPENIL,
display: RoseDisplay ← NIL,
steadyInit: BOOLTRUE];
timeBlock: NAT = 4096;
TimeSteps: TYPE ~ REF TimeStepsRep; -- keeps time->mossim step relation
TimeStepsRep: TYPE ~ ARRAY [0..timeBlock) OF INT;
RoseDisplay: TYPE = REF RoseDisplayRec;
RoseDisplayRec: TYPE = RECORD [
name: ROPENIL,
cellType: Core.CellType,
simulation: Rosemary.Simulation,
displayWires: LIST OF ChoiceButtons.PromptDataRef ← NIL,
tsin: IO.STREAMNIL,
tsout: IO.STREAMNIL,
path: ViewerClasses.Viewer ← NIL,
currentWire: ViewerClasses.Viewer ← NIL,
plot: PlotGraph.Plot ← NIL,
ps: IO.STREAMNIL,
psLock: BOOLFALSE,
psWait: CONDITION,
lastValidTime: INT ← -1,
wDir: REF ANYNIL,
traceChanges: BOOLFALSE,
recordDeltas: BOOLTRUE, -- data must be logged on backing file
recordSteps: BOOLFALSE, -- if recordDeltas, log at MosSim step granularity
plotStyle: {allSteps, waveSteps, noSteps} ← noSteps, -- should MosSim steps appear on plot
cutSet: CoreFlat.CutSet ← NIL,
wBuff: REF TEXTNIL, -- output logging speedup
filePos: INT ← 0, -- logical position in backing file
timeSteps: ARRAY [0..1024) OF TimeSteps ← ALL[NIL]];
END.