File: [Cherry]<Thyme>Cedar5.2>System>spGlobals.mesa
Last Edited by: SChen, September 18, 1984 1:01:33 pm PDT
DIRECTORY
Ascii USING [SP],
BasicTime USING [GMT, nullGMT],
Buttons USING [Button],
Containers USING [Container],
IO USING [STREAM],
Labels USING [Label],
Rope USING [ROPE],
Plot USING [PlotSpec],
TypeScript USING [TS],
ViewerClasses USING [Viewer];
spGlobals: CEDAR DEFINITIONS = {
types:
itemType: TYPE = {name, comma, semi, colon, rightB, leftB, equal, number, leftC, rightC, eof, leftArrow, slash, upArrow, atSign, vertical, star, plus, minus, leftP, rightP, backSlash, greater, less, pound, squiggle, amperesand, quote, string, implies, greatEqual, lessEqual, maximum, minimum, nullItem};
keys: TYPE = {nodeKey, resKey, capKey, indKey, vsKey, isKey, runKey, printKey, circuitKey, modelKey, plotKey, icKey, dumpKey, assertsKey, checkPointKey, libraryKey, nullKey};
expressionPtr
operators: TYPE = {load, neg, add, sub, mul, div, power, store, abs, exp, num, log, sqrt, not, grt, les, geq, leq, eq, neq, and, or, int, max, min, nullOpr};
expressionPtr: TYPE = REF expressionNode;
expressionNode: TYPE = RECORD [
next: expressionPtr ← NIL,
operands: SELECT operator: operators FROM
add, sub, mul, div, power, and, or, grt, les, geq, leq, eq, neq, max, min =>
[leftOp: expressionPtr ← NIL,
rightOp: expressionPtr ← NIL],
abs, exp, neg, log, sqrt, not, int =>
[unaryOp: expressionPtr ← NIL],
load, store =>
[var: namePtr ← NIL,
expr: expressionPtr ← NIL],
num =>
[v: REAL ← 0.0],
ENDCASE
];
namePtr
namePtr: TYPE = REF nameBlk;
nameBlk: TYPE = RECORD [
nextName,
srchLink: namePtr ← NIL,
name: Rope.ROPENIL,
expExpr: expressionPtr ← NIL,
realCopy: realThingPtr ← NIL,
details: REF ANYNIL]; -- cf. the following 8 REF types
RefNodeRec: TYPE = REF NodeRec;
NodeRec: TYPE = RECORD [];
RefBranchRec: TYPE = REF BranchRec;
BranchRec: TYPE = RECORD [
branchType: elements ← nullElement,
posNode,
negNode,
controller: namePtr ← NIL,
modelIndex: NAT ← 0,
valExpr: expressionPtr ← NIL];
RefCircuitRec: TYPE = REF CircuitRec;
CircuitRec: TYPE = RECORD [
names,
fakeNodes: namePtr ← NIL,
conCount: NAT ← 0,
parms,
father: namePtr ← NIL,
assertions: expressionPtr ← NIL];
RefConRec: TYPE = REF ConRec;
ConRec: TYPE = RECORD [];
RefParmRec: TYPE = REF ParmRec;
ParmRec: TYPE = RECORD [
default: BOOLFALSE,
dfltValue: REAL ← 0.0,
nextParm: namePtr ← NIL];
RefCktInstRec: TYPE = REF CktInstance;
CktInstance: TYPE = RECORD [
of: namePtr ← NIL,
connections: conLinkPtr ← NIL,
actualParms: expressionPtr ← NIL];
RefModelRec: TYPE = REF ModelRec;
ModelRec: TYPE = RECORD [
modelProc: model ← NIL,
modelResults: argList ← NIL,
modelArgs: argNames ← NIL,
modelArgVec,
modelOldArgVec: argList ← NIL,
modelParms: expressionPtr ← NIL];
RefFunctionRec: TYPE = REF FunctionRec;
FunctionRec: TYPE = RECORD [
functionProc: function ← NIL,
funcArgs: argNames ← NIL,
funcArgVec: argList ← NIL,
funcParms: expressionPtr ← NIL,
branch: namePtr ← NIL];
nodePtr
nodePtr: TYPE = REF node;
node: TYPE = RECORD [
nextNode: nodePtr ← NIL,
nodeName: namePtr ← NIL,
treeLevel: instTreePtr ← NIL,
brotherNodes: nodePtr ← NIL,
branches: branchLinkPtr ← NIL,
curPtr: branchPtr ← NIL, -- vSource ptr
nextIntNode: nodePtr ← NIL,
nHist: history ← [],
integrate,
marked,
converged: BOOLFALSE];
branchPtr
elements: TYPE = {resistor, capacitor, inductor, vSource, iSource, nullElement};
branchPtr: TYPE = REF branch;
branch: TYPE = RECORD [
branchName: namePtr ← NIL,
treeLevel: instTreePtr ← NIL,
brotherBranches: branchPtr ← NIL,
posNode,
negNode: nodePtr ← NIL,
comVal: REAL ← 0.0,
controller: modFuncPtr ← NIL,
modelIndex: NAT ← 0,
body: REF ANYNIL]; -- cf. the following 5 REF types.
RefR: TYPE = REF ResistorBody;
ResistorBody: TYPE = RECORD [];
RefC: TYPE = REF CapacitorBody;
CapacitorBody: TYPE = RECORD [nextCapacitor: branchPtr ← NIL];
history: TYPE = RECORD [y, oldy, sumk, oldf, f0, f1, f2, f3, f4: REAL ← 0.0];
RefL: TYPE = REF InductorBody;
InductorBody: TYPE = RECORD [
nextInductor: branchPtr ← NIL,
iHist: history ← []];
RefV: TYPE = REF VSourceBody;
VSourceBody: TYPE = RECORD [
nextvSource: branchPtr ← NIL,
vsCurrent: REAL ← 0.0,
oldCurrent: REAL ← 0.0];
RefI: TYPE = REF ISourceBody;
ISourceBody: TYPE = RECORD [nextiSource: branchPtr ← NIL];
realThingPtr
realThings: TYPE = {realNode, realBranch, realParm, realModel, unReal};
realThingPtr: TYPE = REF realThing;
realThing: TYPE = RECORD [
nextThing: realThingPtr ← NIL,
newLevel: BOOLTRUE,
thing: REF ANYNIL]; -- cf. the following 5 REF types
RefRealNode: TYPE = REF RealNode;
RealNode: TYPE = RECORD [rn: nodePtr ← NIL];
RefRealBranch: TYPE = REF RealBranch;
RealBranch: TYPE = RECORD [rb: branchPtr ← NIL];
RefRealParm: TYPE = REF RealParm;
RealParm: TYPE = RECORD [rp: REAL ← 0.0];
RefRealModel: TYPE = REF RealModel;
RealModel: TYPE = RECORD [rm: modFuncPtr ← NIL];
RefUnReal: TYPE = REF UnReal;
UnReal: TYPE = RECORD [];
branchLinkPtr, conLinkPtr, and instTreePtr
branchLinkPtr: TYPE = REF branchLink;
branchLink: TYPE = RECORD [
nextLink: branchLinkPtr ← NIL,
branch: branchPtr ← NIL,
otherNode: nodePtr ← NIL,
pos: BOOLFALSE];
conLinkPtr: TYPE = REF conLink;
conLink: TYPE = RECORD [
nextLink: conLinkPtr ← NIL,
namedNode: namePtr ← NIL];
instTreePtr: TYPE = REF instTreeNode;
instTreeNode: TYPE = RECORD [
father,
brothers,
sons: instTreePtr ← NIL,
instance: namePtr ← NIL,
nodes: nodePtr ← NIL,
branches: branchPtr ← NIL];
modelFuncPtr
modFuncPtr: TYPE = REF modFuncBlk;
modFuncBlk: TYPE = RECORD [
nextMFPtr: modFuncPtr ← NIL,
arguments: argNodes ← NIL,
argVector,
parmVector: argList ← NIL,
actualParms: expressionPtr ← NIL,
body: REF ANYNIL]; -- cf. the following two.
RefFuncBody: TYPE = REF FunctionBody;
FunctionBody: TYPE = RECORD [
functionProc: function ← NIL,
branch: branchPtr ← NIL];
RefModBody: TYPE = REF ModelBody;
ModelBody: TYPE = RECORD [
modelProc: model ← NIL,
modelResults: argList ← NIL,
modelName: namePtr ← NIL,
oldArgVector: argList ← NIL,
modelBranches: modBrPtr ← NIL];
modelBrPtr
modBrPtr: TYPE = REF modelBranch;
modelBranch: TYPE = RECORD [
nextBranch: modBrPtr,
b: branchPtr];
ModelTablePtr and FuncTablePtr
ModelTablePtr: TYPE = REF ModelTableBlk;
ModelTableBlk: TYPE = RECORD [
next: ModelTablePtr,
name: Rope.ROPE,
proc: model,
numArgs, numParms, numResults: NAT];
FuncTablePtr: TYPE = REF FuncTableBlk;
FuncTableBlk: TYPE = RECORD [
next: FuncTablePtr,
name: Rope.ROPE,
proc: function,
numArgs, numParms: NAT];
argList, argNames, argNodes
argList: TYPE = REF ValueSeq;
ValueSeq: TYPE = RECORD [value: SEQUENCE size: NAT OF REAL];
argNames: TYPE = REF namePtrSeq;
namePtrSeq: TYPE = RECORD [names: SEQUENCE size: NAT OF namePtr];
argNodes: TYPE = REF nodePtrSeq;
nodePtrSeq: TYPE = RECORD [nodes: SEQUENCE size: NAT OF nodePtr];
model and function
model: TYPE = PROC[args, oldArgs, parms, results: argList];
function: TYPE = PROC[t: REAL, args, parms: argList] RETURNS [v: REAL];
Stages, Handle, ThymeToolRec and Variables
Stages: TYPE = {idle, input, bomb, topo, run};
Handle: TYPE = REF ThymeToolRec;
ThymeToolRec: TYPE = RECORD [
outer: Containers.Container ← NIL,
wDir, input, progress: ViewerClasses.Viewer ← NIL,
output, time, step: Labels.Label ← NIL,
message: TypeScript.TSNIL,
msgStream: IO.STREAMNIL,
showDetailsButton: Buttons.Button ← NIL,
showTimeStep: BOOLTRUE,
stage: Stages ← idle,
checkProcess, simulation: PROCESSNIL,
checkPointCV: CONDITION,
height: NAT ← 0,
vars: REF Variables ← NIL];
Variables: TYPE = RECORD [
simTime: BasicTime.GMT ← BasicTime.nullGMT,
runState: NAT[0..4) ← 0,
forcedDump: BOOLFALSE,
lastTime: REAL ← 0.0,
checkPointInterval: REAL ← 60.0,
spGlobalsImpl
fileStack: REF fileStackSeq ← NIL,
fileStackTop: NAT ← 0,
line: REF TEXTNIL,
value: REAL ← 0.0,
item: itemType ← nullItem,
newString: REF TEXTNIL,
char: CHAR ← Ascii.SP,
cptr: NAT ← 0, -- pointer to "char" in "line"
genSymCtr: LONG CARDINAL ← 10000,
spInput
gndNodeName,
undefNode,
cktRoot,
currentCkt: namePtr ← NIL,
spBomb
treeRoot: instTreePtr ← NIL,
unusedNodes: nodePtr ← NIL,
nodeCount, branchCount, modelCount, funcCount: LONG CARDINAL ← 0,
n: nodePtr ← NIL, -- Real ones!!!
b: branchPtr ← NIL,
p: REAL ← 0.0,
m: modFuncPtr ← NIL,
gndNode,
nodeList: nodePtr ← NIL,
capacitorList,
inductorList,
vSourceList,
iSourceList: branchPtr ← NIL,
functionList: modFuncPtr ← NIL,
spErrors
errCount, warnCount: NAT ← 0,
triedOnce: BOOLFALSE,
inStream, thymeDotErrors: IO.STREAMNIL,
topOfMsgStream: INT ← 0,
spExpressions
type: {real, name} ← real,
spOutput
numPrints: NAT ← 0,
prints: REF PrintSeq ← NIL,
numPlots: NAT ← 0,
plots: REF PlotSeq ← NIL,
spSolve
intNodeList: nodePtr ← NIL,
intNodeModFunc,
otherModFunc: modFuncPtr ← NIL,
worstNode: nodePtr ← NIL,
curLog: NAT ← 0,
worstNodeLog: REF WorstNodeLog ← NIL,
icsSet, checkPoint, canned: BOOLFALSE,
numGoodSteps: LONG CARDINAL ← 0,
modelsSkipped: NAT ← 0,
dvdtTrunc, t, dT: REAL ← 0.0,
AMcount, goodNodeCount, numberOfSteps, highStepCount, lowStepCount: INT ← 0,
countsPerStep: INT ← 100000000,
Vmin: REAL ← -100.0,
Vmax: REAL ← 100.0,
dvdtmax: REAL ← 1.0e15,
dfltInts: NAT ← 200,
retRatio: REAL ← 0.5,
RKfac: REAL ← 1.0,
minRatio: REAL ← 0.8,
floor: REAL ← 0.01,
AMerr: REAL ← 0.01,
RKerr: REAL ← 0.01,
tBreak: REAL ← 0.0,
dvdtFac: REAL ← 5.0,
squish: REAL ← 0.2,
initStep: REAL ← 0.1,
tol: REAL ← 0.001,
intTol: REAL ← 0.001,
AMup: REAL ← 1.25,
AMdown: REAL ← 0.8,
printdT: REAL ← 0.0,
tMin: REAL ← 0.0,
tMax: REAL ← 0.0,
maxIter: INT ← 20,
AMiter: NAT ← 2,
AMdelay: NAT ← 5,
printIter, printStep, doRungeKutta, printAll: BOOLFALSE,
checkPointCV: CONDITION
];
misc types and constants
argumentPtr: TYPE = REF argument;
argument: TYPE = RECORD [
node: nodePtr ← NIL,
branch: branchPtr ← NIL,
getComVal,
dvdt,
current: BOOLFALSE];
fileStackSeq: TYPE = RECORD [f: SEQUENCE numFiles: NAT OF IO.STREAM];
maxInclude: NAT = 10;
maxPlots: NAT = 10;
maxPrints: NAT = 10;
PlotSeq: TYPE = RECORD [SEQUENCE size: NAT OF PlotRec];
PlotRec: TYPE = RECORD [
plotList: plotBlkPtr ← NIL,
plotTimeRelTo: REAL ← 0,
plotCount: NAT ← 0, -- # curves
plotViewer: ViewerClasses.Viewer ← NIL,
plotSpec: Plot.PlotSpec ← NIL];
plotBlkPtr: TYPE = REF plotBlk;
plotBlk: TYPE = RECORD [
nextBlk: plotBlkPtr ← NIL,
relativeTo: REAL ← 0,
arg: argumentPtr ← NIL];
PrintSeq: TYPE = RECORD [SEQUENCE size: NAT OF PrintRec];
PrintRec: TYPE = RECORD [
printList: printBlkPtr ← NIL,
printTimeRelTo: REAL ← 0.0,
printStream: IO.STREAMNIL];
printBlkPtr: TYPE = REF printBlk;
printBlk: TYPE = RECORD [
nextBlk: printBlkPtr ← NIL,
relativeTo: REAL ← 0,
arg: argumentPtr ← NIL];
spSolve
maxLog: NAT = 16;
WorstNodeLog: TYPE = RECORD [SEQUENCE size: NAT OF WorstNodeRec];
WorstNodeRec: TYPE = RECORD [node: nodePtr ← NIL, t, v, dvdt: REAL ← 0];
maxCountsPerStep: INT = 1000000000;
signals:
ErrorSignal: SIGNAL[error: NAT, s: Rope.ROPE];
Retreat: SIGNAL[cause: Rope.ROPE];
Failure: SIGNAL[errorNum: NAT];
Aborted: SIGNAL; -- spGlobalsImpl
global variables:
Initialized in ThymeViewers
version: Rope.ROPE;
refNodeRec: READONLY RefNodeRec;
refConRec: READONLY RefConRec;
refR: READONLY RefR;
refUnReal: READONLY RefUnReal;
modelTable: ModelTablePtr;
functionTable: FuncTablePtr;
procs:
Exported by spGlobalsImpl:
openInputFile: PROC[handle: Handle];
OutputFileRoot: PROC[handle: Handle] RETURNS [Rope.ROPE];
WorkingDirectory: PROC[handle: Handle] RETURNS [Rope.ROPE];
FlushCloseNil: PROC[stream: IO.STREAM] RETURNS [IO.STREAMNIL];
CloseNil: PROC[stream: IO.STREAM] RETURNS [IO.STREAMNIL];
MsgTextsWithLook: PROC[handle: Handle, text: Rope.ROPE, look: CHAR['a..'z]];
next: PROC[handle: Handle];
searchKey: PROC[handle: Handle] RETURNS [index: keys];
getSignedNumber: PROC[handle: Handle] RETURNS [n: REAL ← 1.0];
GetLineAndCptr: PROC[handle: Handle] RETURNS [Rope.ROPE, NAT];
Exported by spErrors:
error: PROC[handle: Handle, err: NAT, skip, warning: BOOLFALSE];
error2: PROC[handle: Handle, err: NAT, n: namePtr];
ErrorStrings: PROC[handle: Handle, err: NAT, s1, s2: Rope.ROPE];
ErrorAtNB: PROC[handle: Handle, err: NAT, n: nodePtr, b: branchPtr];
ErrWarnSummary: PROC[handle: Handle];
Exported by spExpressions:
expression: PROC[handle: Handle] RETURNS [e: expressionPtr];
assignExpr: PROC[handle: Handle, leftContext: namePtr] RETURNS [a: expressionPtr];
eval: PROC[handle: Handle, exp: expressionPtr] RETURNS [v: REAL];
Exported by spInput:
variable: PROC[handle: Handle, string: REF TEXT, context: namePtr] RETURNS [nPtr: namePtr ← NIL];
output: PROC[handle: Handle, ckt: namePtr, level: NAT];
defineCircuit: PROC[handle: Handle, ckt: namePtr, root: BOOL];
Exported by spBomb:
bomb: PROC[handle: Handle];
printHole: PROC[handle: Handle];
findNodeOrBranch: PROC[handle: Handle] RETURNS [n: nodePtr, b: branchPtr];
makeStringNB: PROC[handle: Handle, n: nodePtr, b: branchPtr, ok: BOOLTRUE] RETURNS [Rope.ROPE];
getParmValue: PROC[handle: Handle, nPtr: namePtr] RETURNS [REAL];
putParmValue: PROC[handle: Handle, nPtr: namePtr, val: REAL];
Exported by spAnalysis:
topoAnalysis: PROC[handle: Handle];
Exported by spSolve:
runIt: PROC[handle: Handle] RETURNS [REAL];
setICs: PROC[handle: Handle];
Exported by spOutput:
initPlot: PROC[handle: Handle, tMin, tMax: REAL];
plotFromList: PROC[handle: Handle, t: REAL];
makePlotList: PROC[handle: Handle];
initPrint: PROC[handle: Handle, time: BasicTime.GMT];
printFromList: PROC[handle: Handle, ni: INT, t: REAL, printStep: BOOL];
makePrintList: PROC[handle: Handle];
PutMsgLine: PROC[handle: Handle, s: Rope.ROPE];
dumpAll: PROC[handle: Handle, t: REAL];
Exported by spMain:
EnterModels: PROC[
name: Rope.ROPE,
proc: model,
numArgs,
numParms,
numResults: NAT];
EnterFunctions: PROC[
name: Rope.ROPE,
proc: function,
numArgs,
numParms: NAT];
findModel: PROC[name: Rope.ROPE] RETURNS [model, NAT, NAT, NAT];
findFunction: PROC[name: Rope.ROPE] RETURNS [function, NAT, NAT];
ResetCheckPoint: PROC[handle: Handle];
Canned: PROC[handle: Handle] RETURNS [BOOL];
ForcedDump: PROC[handle: Handle] RETURNS [BOOL];
CheckPoint: PROC[handle: Handle] RETURNS [BOOL];
ShowDetails: PROC[handle: Handle] RETURNS [BOOL];
StopIt: PROC[handle: Handle];
DumpIt: PROC[handle: Handle];
ToggleShowDetails: PROC[handle: Handle];
SimulateIt: PROC[handle: Handle];
NextStage: PROC[handle: Handle];
Exported by ThymeViewers:
SetCursor: PROC[handle: Handle, invert: BOOLFALSE];
AdvanceStage: PROC[handle: Handle];
Library Models and Functions:
spModels: PROGRAM;
Level2Model: PROGRAM;
spFunctions: PROGRAM;
}.
CHANGE LOG
Wilhelm, April 27, 1982 4:05 PM
Barth, 7-May-82 10:58:25 PDT
Chen, 4/19/83:- modified itemType, operators, and expressionNode to support Max and Min operations.
Chen, 2/12/84:- modified to support oldArgVector.
Chen, June 12, 1984 10:05:25 am PDT, Cedarized.