File: [Cherry]<Thyme>Cedar5.2>System>spGlobals.mesa
Last Edited by: SChen, October 16, 1984 7:48:32 pm PDT
DIRECTORY
Ascii USING [SP],
IO USING [STREAM],
Rope USING [ROPE],
ThymeParser;
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 - describes how to calculate an expression as a collection of operators and operands.
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 - a list of things with names. This is the data structure used to store circuits in hierarchical form as they are read in. Everything starts with a single root nameBlk, for a circuit. It's "names" list stores its elements, which are other things that can have contents and so on.
namePtr: TYPE = REF nameBlk;
nameBlk: TYPE = RECORD [
nextName,
Appears to be used for two things: temporarily linking together a list of names that has been parsed by getNames but not yet by higher-level routines (e.g. create many nodes); and also to link together the connection names for a circuit definition.
srchLink: namePtr ← NIL,
Used to link together all of the namBlks defined in a given definition. Used for name searching to make sure there aren't duplicate names, and to find the element corresponding to a name.
name: Rope.ROPENIL,
expExpr: expressionPtr ← NIL,
Used for conditional expansion of circuit elements. If this expression evaluates to zero, then this element is ignored when the hierarchical circuit is flattened. This feature is used only for branches and circuit instances.
realCopy: realThingPtr ← NIL,
For formal parameters and connection nodes, this is used to keep track of the actual parameter or connection that is current. Since instances can be called recursively, this is a list of values that is pushed and popped as instances are entered or exited.
details: REF ANYNIL]; -- cf. the following 8 REF types
RefNodeRec: TYPE = REF NodeRec;
NodeRec: TYPE = RECORD [];
elements: TYPE = {resistor, capacitor, inductor, vSource, iSource, nullElement};
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,
A list of all the names defined within this circuit definition. Includes names of parameters, connection nodes, nodes, branches, subcircuit definitions, circuit instances, etc. etc. The elements of the list are linked together by their srchLinks, and the list is maintained with the most-recently-referenced entries nearest the front.
fakeNodes: namePtr ← NIL,
A list of all of the formal node parameters for this circuit (i.e. its connections to the outside world. The elements of the list are linked by their nextName pointers.
conCount: NAT ← 0,
The number of node parameters for this circuit definition.
parms,
A list of all the formal non-node parameters (things after the "|" in the parameter list). The entries in this list are linked together by the nextParm pointers in their ParmRec details.
father: namePtr ← NIL,
Pointer to the circuit definition containing this circuit definition.
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,
attributes: attPtr ← 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];
conLinkPtr - Used to keep track of all the formal connections for a circuit.
conLinkPtr: TYPE = REF conLink;
conLink: TYPE = RECORD [
nextLink: conLinkPtr ← NIL,
namedNode: namePtr ← NIL];
attPtr - Used to keep track of all the attributes of a transistor.
attPtr: TYPE = REF attribute;
attribute: TYPE = RECORD [
name: Rope.ROPE,
value: Rope.ROPE,
next: attPtr];
realThingPtr - As the tree is being traversed and flattened, this things point to the real values of parameters and nodes. "UnReal" means there's no value for the thing (I think).
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: Rope.ROPENIL];
For nodes, the "real thing" is just the node's name, in a complete hierarchical form.
RefRealParm: TYPE = REF RealParm;
RealParm: TYPE = RECORD [rp: REAL ← 0.0];
RefUnReal: TYPE = REF UnReal;
UnReal: TYPE = RECORD [];
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];
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 [
msgStream: IO.STREAMNIL,
stage: Stages ← idle,
checkProcess, simulation: PROCESSNIL,
checkPointCV: CONDITION,
height: NAT ← 0,
vars: REF Variables ← NIL];
Variables: TYPE = RECORD [
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,
canned: BOOLFALSE,
stopValue: REF BOOLNIL,
spInput
gndNodeName,
undefNode,
cktRoot,
currentCkt: namePtr ← NIL,
spBomb
nodeCount, resCount, capCount, fetCount, modelCount, funcCount: LONG CARDINAL ← 0,
n: Rope.ROPENIL, -- Real ones!!!
p: REAL ← 0.0,
resProc: ThymeParser.ResistorProc,
capProc: ThymeParser.CapacitorProc,
fetProc: ThymeParser.TransistorProc,
attProc: ThymeParser.AttributeProc,
nodeProc: ThymeParser.NodeProc,
clientData: REF ANY,
fetTable: ThymeParser.TypeList,
pathName: Rope.ROPE,
-- Stores cumulative path (list of names, separated by slashes) from root to current cell. Used by Crystal to assign unique names to each node.
curCkt: namePtr,
-- Current circuit being exploded.
spErrors
errCount, warnCount: NAT ← 0,
triedOnce: BOOLFALSE,
inStream, thymeDotErrors: IO.STREAMNIL,
topOfMsgStream: INT ← 0,
spExpressions
type: {real, name} ← real,
checkPointCV: CONDITION
];
misc types and constants
fileStackSeq: TYPE = RECORD [f: SEQUENCE numFiles: NAT OF IO.STREAM];
maxInclude: NAT = 10;
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;
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];
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];
getParmValue: PROC[handle: Handle, nPtr: namePtr] RETURNS [REAL];
putParmValue: PROC[handle: Handle, nPtr: namePtr, val: REAL];
;
PutMsgLine: PROC[handle: Handle, s: Rope.ROPE];
dumpAll: PROC[handle: Handle, t: REAL];
Exported by spMain:
Canned: PROC[handle: Handle] RETURNS [BOOL];
StopIt: PROC[handle: Handle];
NextStage: PROC[handle: Handle];
findFunction: PROC[name: Rope.ROPE]
RETURNS[function, NAT, NAT];
findModel: PROC[name: Rope.ROPE] RETURNS[model, NAT, NAT, NAT];
EnterModels: PROC[name: Rope.ROPE, proc: model, numArgs, numParms, numResults: NAT];
EnterFunctions: PROC[name: Rope.ROPE, proc: function, numArgs, numParms: NAT];
}.
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.