CoreCompose.mesa 
Copyright © 1985 by Xerox Corporation. All rights reserved.
Barth, October 15, 1985 3:40:50 pm PDT
Bertrand Serlet November 8, 1985 10:16:53 pm PST
Louis Monier October 29, 1985 7:23:24 pm PST
DIRECTORY Core, CoreClasses, SymTab;
CoreCompose: CEDAR DEFINITIONS = BEGIN
Common Types and Errors
ROPE: TYPE = Core.ROPE;
CellType: TYPE = Core.CellType;
WireSequence: TYPE = Core.WireSequence;
TransistorType: TYPE = CoreClasses.TransistorType;
InstanceList: TYPE = LIST OF InstanceRec;
InstanceRec: TYPE = RECORD[
actual: ROPE,  -- need a parser to turn it into actual wires
type: CellType];
-- A Context is a stack of properties
Context: TYPE = REF ContextRec;
CContext: TYPE = Context;
ContextRec: TYPE = RECORD [ -- we'll make it opaque later!
stack: Stack ← NIL,-- stack of pairs [atom, ref]; order matters
tab: SymTab.Ref ← NIL];
Stack: TYPE = PropertyLiterals;
PropertyLiteral: TYPE = RECORD[key: ATOM, val: REF];
PropertyLiterals: TYPE = LIST OF PropertyLiteral;
Context
GetRef: PROC [context: Context, prop: ATOM] RETURNS [REF];
GetAtom: PROC [context: Context, prop: ATOM] RETURNS [ATOM];
GetRope: PROC [context: Context, prop: ATOM] RETURNS [ROPE];
GetInt: PROC [context: Context, prop: ATOM] RETURNS [INT];
GetReal: PROC [context: Context, prop: ATOM] RETURNS [REAL];
GetBool: PROC [context: Context, prop: ATOM] RETURNS [BOOL];
PushRef: PROC [context: Context, prop: ATOM, val: REF];
PushAtom: PROC [context: Context, prop: ATOM, val: ATOM];
PushRope: PROC [context: Context, prop: ATOM, val: ROPE];
PushInt: PROC [context: Context, prop: ATOM, val: INT];
PushReal: PROC [context: Context, prop: ATOM, val: REAL];
PushBool: PROC [context: Context, prop: ATOM, val: BOOL];
RegisterRefProperty: PROC [prop: ATOM];
RegisterAtomProperty: PROC [prop: ATOM];
RegisterRopeProperty: PROC [prop: ATOM];
RegisterIntProperty: PROC [prop: ATOM];
RegisterRealProperty: PROC [prop: ATOM];
RegisterBoolProperty: PROC [prop: ATOM];
CreateContext: PROC [init: Context ← NIL, props: PropertyLiterals ← NIL] RETURNS [Context];
MarkContext: PROC [context: Context, mark: ATOM];
PopContext: PROC [context: Context, mark: ATOM];
Structure
StructureProc: TYPE = PROC [context: Context] RETURNS [cellType: CellType];
Given a context compute the implementation.
RegisterStructureProc: PROC [name: ROPE, proc: StructureProc] RETURNS [ROPE];
Returns name argument as result.
CreateStructure: PROC [name: ROPE, context: Context] RETURNS [CellType];
IsRegistered: PROC [name: ROPE] RETURNS [BOOL];
Cells
CreateTransistor: PROC [name: ROPENIL, type: TransistorType ← nE, length: NAT ← 2, width: NAT ← 4] RETURNS [cellType: CellType];
CreateRecordCell: PROC [name: ROPE, public: WireSequence, onlyInternal: WireSequence ← NIL, instances: InstanceList ← NIL, context: Context] RETURNS [cellType: CellType];
CreateSequenceCell: PROC [name: ROPE, baseCell: CellType, count: NAT, sequencePorts: ROPENIL] RETURNS [cellType: CellType];
Wires
-- Uses the parser
CreateWires: PROC [context: Context, rope: ROPE] RETURNS [wire: WireSequence];
END.
Theory
This interface provides some procedures useful for assembling elementary Core object into more complex ones. It also provides for user comfort a number of short cuts which increase the readability of Core-producing code. What follows is the grammar of the language used inside ropes that define wire (public or internal) and actual (binding).
publicOrInternal←"
M[
Data[seq:32][a, b[seq:2]],     -- seq of record
Other[seq:32],       -- seq of unnamed atomic
Cmd[enum:Dragon.MBusCommands],  -- enumerated type
Hold],       -- atomic
Vdd,       -- atomic
Input[x, y]"     -- record of two atomic
actual ← "
a:M.Data[3].b[0],      -- bunch of subfield and subrange chasing
b:M.Data[start:1, len:7],     -- subrange
c:[M.Hold, M.Cmd]"     -- composed wire (not implemented yet)
publicOrInternal ::= composition ,..
composition ::= name ( [ sequence ] )* ?( [ publicOrInternal ] ) | name [ enumType ]
sequence ::= seq: exp
enumType ::= enum: enumeratedTypeName -- whatever the interpreter will buy
binding ::= name : actual ,..
actual ::= name ( selector )* ?( [ start: exp, len: exp ] ) | [ actual ,.. ]
selector ::= .name | [ exp ]
name ::= a valid Cedar identifier
exp ::= a valid expression evaluating to an integer
Notes:
Semantic of ENUM?
Do we want to sequence an enumerated type?