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;
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:
ROPE ←
NIL, displayWires: CoreFlat.FlatWires ←
NIL, graphWires: CoreFlat.FlatWires ←
NIL]
RETURNS [handle: RoseDisplay];
LogSettle:
PROC [handle: RoseDisplay, time:
INT, memory:
BOOL ←
TRUE];
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:
ROPE ←
NIL, displayWires: CoreFlat.FlatWires ←
NIL, graphWires: CoreFlat.FlatWires ←
NIL, cutSet: CoreFlat.CutSet ←
NIL, historySize:
NAT ← 0, steady:
BOOL ←
FALSE, recordDeltas:
BOOL ←
TRUE]
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 [cellType: Core.CellType, p: Ports.Port, Eval: TestEvalProc];
TestEvalProc: TYPE = PROC [memory: BOOL ← TRUE, clockEval: BOOL ← FALSE, checkPorts: BOOL ← TRUE];
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:
ROPE ←
NIL];
RemoveWireFromPlot:
PROC [handle: RoseDisplay, wire: CoreFlat.FlatWire]
RETURNS [found:
BOOL ←
FALSE];
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:
ROPE ←
NIL];
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:
BOOL ←
FALSE];
stateToMaxCharsProcProp:
ATOM;
-- $RoseStateToMaxCharsProc
Put this on the cell type or cell class.
StateToMaxCharsProc:
TYPE =
PROC [stateAny:
REF
ANY, data:
REF
ANY ←
NIL]
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.
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: BOOL ← FALSE,
waiting: BOOL ← FALSE,
abort: BOOL ← FALSE,
interrupt: BOOL ← FALSE,
singleEval: BOOL ← FALSE,
testButtonList: LIST OF Buttons.Button,
currentTestProc: ROPE ← NIL,
display: RoseDisplay ← NIL,
steadyInit: BOOL ← TRUE];
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: ROPE ← NIL,
cellType: Core.CellType,
simulation: Rosemary.Simulation,
displayWires: LIST OF ChoiceButtons.PromptDataRef ← NIL,
tsin: IO.STREAM ← NIL,
tsout: IO.STREAM ← NIL,
path: ViewerClasses.Viewer ← NIL,
currentWire: ViewerClasses.Viewer ← NIL,
plot: PlotGraph.Plot ← NIL,
ps: IO.STREAM ← NIL,
psLock: BOOL ← FALSE,
psWait: CONDITION,
lastValidTime: INT ← -1,
wDir: REF ANY ← NIL,
traceChanges: BOOL ← FALSE,
recordDeltas: BOOL ← TRUE, -- data must be logged on backing file
recordSteps: BOOL ← FALSE, -- if recordDeltas, log at MosSim step granularity
plotStyle: {allSteps, waveSteps, noSteps} ← noSteps, -- should MosSim steps appear on plot
cutSet: CoreFlat.CutSet ← NIL,
wBuff: REF TEXT ← NIL, -- output logging speedup
filePos: INT ← 0, -- logical position in backing file
timeSteps: ARRAY [0..1024) OF TimeSteps ← ALL[NIL]];