Sisyph.mesa
Copyright Ó 1985, 1986, 1987 by Xerox Corporation. All rights reserved.
Created by Sindhu and Serlet, November 26, 1985 1:02:25 am PDT
Pradeep Sindhu November 15, 1986 11:24:25 pm PST
Barth, January 13, 1986 3:31:45 pm PST
Bertrand Serlet September 21, 1987 11:55:51 am PDT
DIRECTORY CD, Core, IO, Sinix USING [Mode], SymTab USING [Ref];
Sisyph: CEDAR DEFINITIONS = BEGIN
Types
Context: TYPE = SymTab.Ref; -- maps variable names to TVs
CellType: TYPE = Core.CellType;
Properties: TYPE = Core.Properties;
Wire: TYPE = Core.Wire;
Wires: TYPE = Core.Wires;
WireSeq: TYPE = Core.WireSeq;
ROPE: TYPE = Core.ROPE;
ROPES: TYPE = LIST OF ROPE;
Extraction
expressionsProp:
ATOM;
Property on CD objects and CD instances that holds Sisyph expressions.
corePropsRope:
ROPE;
name of Sisyph variable that represents a list of properties to be put on a CellType or Wire.
coreInstPropsRope:
ROPE;
name of Sisyph variable that represents a list of properties to be put on a CellType instance.
parmNamesProp:
ATOM;
property on icon that contains the names of the icon's parameters. A NIL value => any variable is potentially a parameter; a list with a rope="0" as its first element => 0 parameters.
defaultGlobalNames: ROPES;
mode: Sinix.Mode;
mode record for Sinix.Extract or SinixOps.ExtractCDInstance.
ES, ExtractSchematicByName: PROC [name: ROPE, cx: Context] RETURNS [CellType];
Context Handling Procedures
Create:
PROC [design:
CD.Design, previousCx: Context ←
NIL]
RETURNS [cx: Context];
Creates or copies to a new context (with globalNames initialized to defaultGlobalNames), and evaluates all design satellites in that context.
Copy:
PROC [oldCx: Context]
RETURNS [cx: Context];
Creates a new context and copies oldCx to it.
TVs are copied.
Store:
PROC [cx: Context, var:
ROPE, value:
REF ←
NIL];
Stores value into var in cx; if var didn't exist it is created; a NIL value removes var from cx.
Insert:
PROC [cx: Context, var:
ROPE, value:
REF ←
NIL];
Stores value into var in cx only if var didn't exist
FetchInt:
PROC [cx: Context, var:
ROPE]
RETURNS [found:
BOOL, value:
INT];
Fetches an integer in cx. NATs are OK, and converted to INTs.
FetchAtom:
PROC [cx: Context, var:
ROPE]
RETURNS [found:
BOOL, value:
ATOM];
Fetches an atom in cx.
FetchRope:
PROC [cx: Context, var:
ROPE]
RETURNS [found:
BOOL, value:
ROPE];
Fetches a rope in cx.
EvalExpr:
PROC [cx: Context, var, expr:
ROPE, checkDefined:
BOOL ←
TRUE];
Computes the value of expr, and stores it in var.
If checkDefined, var must have been declared before (e.g. using Store)
Might raise InterpreterError.
AddProp:
PROC [cx: Context, key:
ATOM, expr:
ROPE, inst:
BOOL];
Evaluates expr, that must yield a REF, and adds the result in the context variable corePropsRope or coreInstPropsRope, depending ob inst.
Expressions yielding a non-REF TV (such as an INT) a REFized, to allow satellites like: "Value: 2".
GetDesign:
PROC [cx: Context]
RETURNS [
CD.Design];
Returns the current design
GetGlobalNames:
PROC [cx: Context]
RETURNS [
ROPES];
Returns the current list of global names
GetCDObj:
PROC [cx: Context]
RETURNS [
CD.Object];
Returns the current object being extracted
Conveniences
EqualRopes:
PROC [ropes1, ropes2:
ROPES]
RETURNS [
BOOL];
Equality of the 2 sets of ROPES.
Cons:
PROC [r:
ROPE, lor:
ROPES]
RETURNS [
ROPES];
This function is useful to add a global variables to the global variables of a context.
For example to have the global names be Vdd, Gnd, and Clock, just add as object satellite to the design: globalNames ← Cons["Clock", globalNames].
This function is necessary because CONS ["Clock", globalNames] would produce a LORA and not a LOR.
List:
PROC [r1, r2, r3, r4, r5, r6:
ROPE ←
NIL]
RETURNS [lor:
ROPES];
This function is useful to set the global variables of a context.
For example to have the global names be Vdd, Gnd, and Clock, just add as object satellite to the design: globalNames ← List["Vdd", "Gnd", "Clock"].
This function is necessary because LIST ["Vdd", "Gnd", "Clock"] would produce a LORA and not a LOR.
Exceptions
GlobalNonAtomic:
SIGNAL [record: CellType, name:
ROPE, wire: Wire];
InterpreterError: SIGNAL [cx: Context, var, expr, errorRope: ROPE];
Private Utilities for implementors of Extract Procs
GetCoreProps:
PRIVATE
PROC [cx: Context]
RETURNS [Core.Properties];
GetCoreInstProps:
PRIVATE
PROC [cx: Context]
RETURNS [Core.Properties];
ParseRope:
PRIVATE PROC [rope:
ROPE]
RETURNS [tokenKind:
IO.TokenKind, token, rest:
ROPE];
IsParsedID:
PRIVATE PROC [tokenKind:
IO.TokenKind, token, id:
ROPE]
RETURNS [
BOOL];
IsParsedChar:
PRIVATE PROC [tokenKind:
IO.TokenKind, token:
ROPE, char:
CHAR]
RETURNS [
BOOL];
EvaluateParameters:
PRIVATE
PROC [userData:
REF, obj:
CD.Object, properties:
CD.PropList]
RETURNS [cx: Context];
The order of evaluation is:
(1) expressions specified in expressionsProp property of object;
(2) arguments specified in satellites of object
(3) arguments specified in expressionsProp property of instance;
(4) arguments specified in satellites of instance.
Thus instance satellites take precedence over instance property exprs, which take precedence over object satellites, which take precedence over object property exprs. The evaluation is performed in two passes: the second pass handles result expressions while the first pass handles all others. When evaluating satellite exprs, an expression containing "←" is evaluated, an expression containing a ":" is assumed to be a property, an expression containing "~" is evaluated as a declaration, while all other expressions are assumed to be names.
EvalToRef:
PRIVATE
PROC [cx: Context, expr:
ROPE]
RETURNS [result:
REF];
Computes the value of expr and returns the corresponding REF.
Might call InterpreterError.
Expressions yielding a non-REF TV (such as an INT) a REFized, to allow satellites like: "Value: 2".
ProcessGlobalNames:
PRIVATE
PROC [record: CellType, cx: Context];
Modifies in place record to fuse global wires.
Modification in place is always dangerous, so avoid using this function ...
END.