<> <> <> <> <<>> 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 = { <> 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}; <<>> <> 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 [ visited: BOOL _ FALSE, 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: TYPE = REF nameBlk; nameBlk: TYPE = RECORD [ visited: BOOL _ FALSE, nextName, srchLink: namePtr _ NIL, name: Rope.ROPE _ NIL, expExpr: expressionPtr _ NIL, realCopy: realThingPtr _ NIL, details: REF ANY _ NIL]; -- cf. the following 8 REF types RefNodeRec: TYPE = REF NodeRec; NodeRec: TYPE = RECORD []; RefBranchRec: TYPE = REF BranchRec; BranchRec: TYPE = RECORD [ visited: BOOL _ FALSE, branchType: elements _ nullElement, posNode, negNode, controller: namePtr _ NIL, modelIndex: NAT _ 0, valExpr: expressionPtr _ NIL]; RefCircuitRec: TYPE = REF CircuitRec; CircuitRec: TYPE = RECORD [ visited: BOOL _ FALSE, 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 [ visited: BOOL _ FALSE, default: BOOL _ FALSE, dfltValue: REAL _ 0.0, nextParm: namePtr _ NIL]; RefCktInstRec: TYPE = REF CktInstance; CktInstance: TYPE = RECORD [ visited: BOOL _ FALSE, of: namePtr _ NIL, connections: conLinkPtr _ NIL, actualParms: expressionPtr _ NIL]; RefModelRec: TYPE = REF ModelRec; ModelRec: TYPE = RECORD [ visited: BOOL _ FALSE, modelProc: model _ NIL, modelResults: argList _ NIL, modelArgs: argNames _ NIL, modelArgVec, modelOldArgVec: argList _ NIL, modelParms: expressionPtr _ NIL, data: REF ANY _ NIL]; RefFunctionRec: TYPE = REF FunctionRec; FunctionRec: TYPE = RECORD [ visited: BOOL _ FALSE, functionProc: function _ NIL, funcArgs: argNames _ NIL, funcArgVec: argList _ NIL, funcParms: expressionPtr _ NIL, branch: namePtr _ NIL, data: REF ANY _ NIL]; <<>> <> nodePtr: TYPE = REF node; node: TYPE = RECORD [ visited: BOOL _ FALSE, 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: BOOL _ FALSE]; <<>> <> elements: TYPE = {resistor, capacitor, inductor, vSource, iSource, nullElement}; branchPtr: TYPE = REF branch; branch: TYPE = RECORD [ visited: BOOL _ FALSE, 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 ANY _ NIL]; -- cf. the following 5 REF types. RefR: TYPE = REF ResistorBody; ResistorBody: TYPE = RECORD []; RefC: TYPE = REF CapacitorBody; CapacitorBody: TYPE = RECORD [ visited: BOOL _ FALSE, 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 [ visited: BOOL _ FALSE, nextInductor: branchPtr _ NIL, iHist: history _ []]; RefV: TYPE = REF VSourceBody; VSourceBody: TYPE = RECORD [ visited: BOOL _ FALSE, nextvSource: branchPtr _ NIL, vsCurrent: REAL _ 0.0, oldCurrent: REAL _ 0.0]; RefI: TYPE = REF ISourceBody; ISourceBody: TYPE = RECORD [ visited: BOOL _ FALSE, nextiSource: branchPtr _ NIL]; <> realThings: TYPE = {realNode, realBranch, realParm, realModel, unReal}; realThingPtr: TYPE = REF realThing; realThing: TYPE = RECORD [ visited: BOOL _ FALSE, nextThing: realThingPtr _ NIL, newLevel: BOOL _ TRUE, thing: REF ANY _ NIL]; -- cf. the following 5 REF types RefRealNode: TYPE = REF RealNode; RealNode: TYPE = RECORD [ visited: BOOL _ FALSE, rn: nodePtr _ NIL]; RefRealBranch: TYPE = REF RealBranch; RealBranch: TYPE = RECORD [ visited: BOOL _ FALSE, rb: branchPtr _ NIL]; RefRealParm: TYPE = REF RealParm; RealParm: TYPE = RECORD [ visited: BOOL _ FALSE, rp: REAL _ 0.0]; RefRealModel: TYPE = REF RealModel; RealModel: TYPE = RECORD [ visited: BOOL _ FALSE, rm: modFuncPtr _ NIL]; RefUnReal: TYPE = REF UnReal; UnReal: TYPE = RECORD []; <> branchLinkPtr: TYPE = REF branchLink; branchLink: TYPE = RECORD [ visited: BOOL _ FALSE, nextLink: branchLinkPtr _ NIL, branch: branchPtr _ NIL, otherNode: nodePtr _ NIL, pos: BOOL _ FALSE]; conLinkPtr: TYPE = REF conLink; conLink: TYPE = RECORD [ visited: BOOL _ FALSE, nextLink: conLinkPtr _ NIL, namedNode: namePtr _ NIL]; instTreePtr: TYPE = REF instTreeNode; instTreeNode: TYPE = RECORD [ visited: BOOL _ FALSE, father, brothers, sons: instTreePtr _ NIL, instance: namePtr _ NIL, nodes: nodePtr _ NIL, branches: branchPtr _ NIL]; <<>> <> modFuncPtr: TYPE = REF modFuncBlk; modFuncBlk: TYPE = RECORD [ visited: BOOL _ FALSE, nextMFPtr: modFuncPtr _ NIL, arguments: argNodes _ NIL, argVector, parmVector: argList _ NIL, actualParms: expressionPtr _ NIL, data: REF ANY _ NIL, -- for use by the model or function code body: REF ANY _ NIL]; -- cf. the following two. RefFuncBody: TYPE = REF FunctionBody; FunctionBody: TYPE = RECORD [ visited: BOOL _ FALSE, functionProc: function _ NIL, branch: branchPtr _ NIL]; RefModBody: TYPE = REF ModelBody; ModelBody: TYPE = RECORD [ visited: BOOL _ FALSE, modelProc: model _ NIL, modelResults: argList _ NIL, modelName: namePtr _ NIL, oldArgVector: argList _ NIL, modelBranches: modBrPtr _ NIL]; <<>> <> <<>> modBrPtr: TYPE = REF modelBranch; modelBranch: TYPE = RECORD [ visited: BOOL _ FALSE, nextBranch: modBrPtr, b: branchPtr]; <<>> <> <<>> ModelTable: TYPE = LIST OF REF ModelTableBlk; ModelTableBlk: TYPE = RECORD [ name: Rope.ROPE, proc: model, numArgs, numParms, numResults: NAT, data: REF ANY _ NIL]; FuncTable: TYPE = LIST OF REF FuncTableBlk; FuncTableBlk: TYPE = RECORD [ name: Rope.ROPE, proc: function, numArgs, numParms: NAT, data: REF ANY _ NIL]; <> <<>> hashModulus: INT = 253; HashKey: TYPE = [0..hashModulus); ModelArgHash: TYPE = ARRAY HashKey OF LIST OF REF ANY _ ALL[NIL]; <<>> <> argList: TYPE = REF ValueSeq; ValueSeq: TYPE = RECORD [ visited: BOOL _ FALSE, handle: Handle _ NIL, modFunc: modFuncPtr _ NIL, value: SEQUENCE size: NAT OF REAL]; argNames: TYPE = REF namePtrSeq; namePtrSeq: TYPE = RECORD [ visited: BOOL _ FALSE, names: SEQUENCE size: NAT OF namePtr]; argNodes: TYPE = REF nodePtrSeq; nodePtrSeq: TYPE = RECORD [ visited: BOOL _ FALSE, nodes: SEQUENCE size: NAT OF nodePtr]; <> model: TYPE = PROC[args, oldArgs, parms, results: argList]; function: TYPE = PROC[t: REAL, args, parms: argList] RETURNS [v: REAL]; <> 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.TS _ NIL, msgStream: IO.STREAM _ NIL, showDetailsButton, echoInputButton: Buttons.Button _ NIL, showTimeStep, echoInput: BOOL _ TRUE, stage: Stages _ idle, checkProcess, simulation: PROCESS _ NIL, checkPointCV: CONDITION, height: NAT _ 0, vars: REF Variables _ NIL]; Variables: TYPE = RECORD [ simTime: BasicTime.GMT _ BasicTime.nullGMT, runState: NAT[0..4) _ 0, forcedDump: BOOL _ FALSE, lastTime: REAL _ 0.0, checkPointInterval: REAL _ 60.0, <<>> <> fileStack: REF fileStackSeq _ NIL, fileNameStack: REF fileNameStackSeq _ NIL, fileStackTop: NAT _ 0, line: REF TEXT _ NIL, value: REAL _ 0.0, item: itemType _ nullItem, newString: REF TEXT _ NIL, char: CHAR _ Ascii.SP, cptr: NAT _ 0, -- pointer to "char" in "line" genSymCtr: LONG CARDINAL _ 10000, <<>> <> gndNodeName, undefNode, cktRoot, currentCkt: namePtr _ NIL, <<>> <> treeRoot: instTreePtr _ NIL, unusedNodes: nodePtr _ NIL, nodeCount, branchCount, modelCount, funcCount: LONG CARDINAL _ 0, modelArgs: REF ModelArgHash _ NIL, 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, <<>> <> errCount, warnCount: NAT _ 0, triedOnce: BOOL _ FALSE, inStream, thymeDotErrors: IO.STREAM _ NIL, topOfMsgStream: INT _ 0, <<>> <> type: {real, name} _ real, <> numPrints: NAT _ 0, prints: REF PrintSeq _ NIL, numPlots: NAT _ 0, plots: REF PlotSeq _ NIL, <<>> <> intNodeList: nodePtr _ NIL, intNodeModFunc, otherModFunc: modFuncPtr _ NIL, worstNode: nodePtr _ NIL, curLog: NAT _ 0, worstNodeLog: REF WorstNodeLog _ NIL, lastRetreatCause: Rope.ROPE_ NIL, icsSet, checkPoint, canned: BOOL _ FALSE, 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, ignorDvDtBelow: REAL _ 1.0e-9, -- if |dvdt| < this number then set it to 0.0. Temp fix to avoid being trapped into buggy floating point software too frequently. 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, showRetreat: BOOL _ FALSE, <<>> checkPointCV: CONDITION ]; <<>> <> argumentPtr: TYPE = REF argument; argument: TYPE = RECORD [ visited: BOOL _ FALSE, node: nodePtr _ NIL, branch: branchPtr _ NIL, getComVal, dvdt, current: BOOL _ FALSE]; fileStackSeq: TYPE = RECORD [f: SEQUENCE numFiles: NAT OF IO.STREAM]; fileNameStackSeq: TYPE = RECORD [f: SEQUENCE numFiles: NAT OF Rope.ROPE]; 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 [ visited: BOOL _ FALSE, 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.STREAM _ NIL]; printBlkPtr: TYPE = REF printBlk; printBlk: TYPE = RECORD [ visited: BOOL _ FALSE, nextBlk: printBlkPtr _ NIL, relativeTo: REAL _ 0, arg: argumentPtr _ NIL]; <> maxLog: NAT = 16; WorstNodeLog: TYPE = RECORD [SEQUENCE size: NAT OF WorstNodeRec]; WorstNodeRec: TYPE = RECORD [ visited: BOOL _ FALSE, node: nodePtr _ NIL, t, v, dvdt: REAL _ 0]; maxCountsPerStep: INT = 1000000000; <<>> <> ErrorSignal: SIGNAL[error: NAT, s: Rope.ROPE]; Retreat: SIGNAL[cause: Rope.ROPE]; Failure: SIGNAL[errorNum: NAT]; Aborted: SIGNAL; -- spGlobalsImpl <<>> <> <> version: Rope.ROPE; refNodeRec: READONLY RefNodeRec; refConRec: READONLY RefConRec; refR: READONLY RefR; refUnReal: READONLY RefUnReal; modelTable: ModelTable; functionTable: FuncTable; <<>> <> <<>> <> 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.STREAM _ NIL]; 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]; <<>> <> error: PROC[handle: Handle, err: NAT, skip, warning: BOOL _ FALSE]; 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]; <<>> <> 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]; <<>> <> 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]; <> 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: BOOL _ TRUE] RETURNS [Rope.ROPE]; getParmValue: PROC[handle: Handle, nPtr: namePtr] RETURNS [REAL]; putParmValue: PROC[handle: Handle, nPtr: namePtr, val: REAL]; <<>> <> topoAnalysis: PROC[handle: Handle]; <<>> <> runIt: PROC[handle: Handle] RETURNS [REAL]; setICs: PROC[handle: Handle]; <<>> <> 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]; <<>> <> EnterModels: PROC[entry: ModelTableBlk]; EnterFunctions: PROC[entry: FuncTableBlk]; findModel: PROC[name: Rope.ROPE] RETURNS [REF ModelTableBlk]; findFunction: PROC[name: Rope.ROPE] RETURNS [REF FuncTableBlk]; 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]; EchoInput: PROC[handle: Handle] RETURNS [BOOL]; StopIt: PROC[handle: Handle]; DumpIt: PROC[handle: Handle]; ToggleShowDetails: PROC[handle: Handle]; ToggleEchoInput: PROC[handle: Handle]; NormalRun: PROC[handle: Handle, background, fork: BOOL _ TRUE]; BatchRun: PROC[handle: Handle, inputFile: Rope.ROPE _ NIL]; NextStage: PROC[handle: Handle]; <<>> <> MakeThymeViewers: PROC[wDir: Rope.ROPE _ NIL] RETURNS [handle: spGlobals.Handle _ NIL]; SetCursor: PROC[handle: Handle]; AdvanceStage: PROC[handle: Handle]; <<>> <> CleanUp: PROC[handle: Handle]; <<>> <> 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. McCreight, April 1, 1985 4:17:09 pm PST, added: 1. "data" fields in ModelRec and FunctionRec, modFuncBlk, ModelTableBlk, and FuncTableBlk; 2. hashModulus, HashKey, and ModelArgHash; 3. the handle and modFunc fields in ValueSeq; 4. modelArgs. Chen, May 10, 1985 12:45:56 pm PDT, added ignorDvDtBelow to avoid concurrency problem using floating point software. Chen, July 22, 1985 8:01:41 pm PDT, => Cedar6.0.