CoreClassesImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Barth, October 2, 1985 11:28:58 am PDT
Spreitzer, October 3, 1985 5:16:15 pm PDT
Bertrand Serlet November 18, 1985 1:57:20 pm PST
DIRECTORY Core, CoreClasses, CoreOps, CoreProperties, IO, Rope;
CoreClassesImpl: CEDAR PROGRAM
IMPORTS CoreOps, CoreProperties, IO
EXPORTS CoreClasses =
BEGIN OPEN Core, CoreClasses;
Record
recordCellClass: PUBLIC CellClass ← NEW [CellClassRec ← [name: "Record", recast: NIL, properties: CoreProperties.Props[[CoreOps.printClassProcProp, NEW [CoreOps.PrintClassProc ← PropPrint]], [CoreOps.nameClassWireProcProp, NEW [CoreOps.NameWireProc ← FullNameInternalWire]]]]];
PropPrint: CoreOps.PrintClassProc = {
RecordPrint[NARROW [data], out];
};
instanceNameProp: PUBLIC ATOM ← CoreProperties.RegisterProperty[$CoreInstanceName, CoreProperties.Props[[CoreProperties.propCopy, CoreProperties.PropDoCopy]]];
RecordPrint: PUBLIC PROC [recordCellType: RecordCellType, out: STREAM] = {
IO.PutRope[out, "\nInternal wire:"];
CoreOps.FullNameWireSequence[wireSeq: recordCellType.internal, name: NIL, prop: internalFullName];
CoreOps.PrintWireSequence[recordCellType.internal, out];
FOR instList: CellInstanceList ← recordCellType.instances, instList.rest UNTIL instList=NIL DO
firstActual: BOOLTRUE;
EachWirePair: CoreOps.EachWirePairProc = {
internalName: ROPENARROW [CoreProperties.GetWireProp[from: actualWire, prop: internalFullName]];
subWires ← internalName = NIL;
IF internalName#NIL THEN {
IF NOT firstActual THEN out.PutChar[',];
firstActual ← FALSE;
out.PutF[" %g: %g", IO.rope[NARROW [CoreProperties.GetWireProp[from: publicWire, prop: CoreOps.publicFullName]]], IO.rope[internalName]];
};
};
IO.PutF[out, "\nCellInstance, type: %g", IO.rope[CoreOps.GetCellTypeName[instList.first.type]]];
IO.PutRope[out, "\n Actual wire: "];
CoreOps.FullNameWireSequence[instList.first.type.public];
IF CoreOps.VisitBinding[instList.first.actual, instList.first.type.public, EachWirePair] THEN out.PutF["*** Actual and Public do not conform\n"];
CoreProperties.PrintProperties[props: instList.first.properties, out: out, depth: 1];
ENDLOOP;
};
CorrespondingActual: PUBLIC PROC [instance: CellInstance, public: Wire] RETURNS [actual: Wire ← NIL] = {
EachWirePair: CoreOps.EachWirePairProc = {
IF publicWire=public THEN {actual ← actualWire; quit ← TRUE};
};
[] ← CoreOps.VisitBinding[instance.actual, instance.type.public, EachWirePair];
};
Bound: PUBLIC PROC [instance1, instance2: CellInstance, public1, public2: Wire] RETURNS [b: BOOL] = {
actual1: Wire ← CorrespondingActual[instance1, public1];
actual2: Wire ← CorrespondingActual[instance2, public2];
IF actual1=NIL OR actual2=NIL THEN ERROR; -- RETURN [FALSE]
b ← actual1=actual2;
};
internalFullName: PUBLIC ATOM ← CoreProperties.RegisterProperty[$CoreInternalWireFullName, CoreProperties.Props[[CoreProperties.propPrint, CoreProperties.PropDontPrint]]];
FullNameInternalWire: CoreOps.NameWireProc = {
rct: RecordCellType ← NARROW [data];
CoreOps.FullNameWireSequence[wireSeq: rct.internal, prop: internalFullName];
};
Transistor
transistorCellClass: PUBLIC CellClass ← NEW [CellClassRec ← [name: "Transistor", recast: NIL]];
TransistorCreate: PUBLIC PROC [args: TransistorRec] RETURNS [cellType: CellType] = {
tranNames: ARRAY TransistorType OF ROPE ← ["nE", "pE", "nD"];
tranPublic: WireSequence ← CoreOps.WiresToWireSequence[LIST[
CoreOps.CreateAtomWire[name: "gate"],
CoreOps.CreateAtomWire[name: "ch1"],
CoreOps.CreateAtomWire[name: "ch2"]
CoreOps.CreateAtomWire[name: IF args.type=pE THEN "Vdd" ELSE "Gnd"]
]];
cellType ← CoreOps.CreateCellType[
class: transistorCellClass,
public: tranPublic,
data: NEW [TransistorRec ← args]];
};
Identity
identityCellClass: PUBLIC CellClass ← NEW [CellClassRec ← [name: "Identity", recast: IdentityRecast, properties: CoreProperties.Props[[CoreOps.printClassProcProp, NEW [CoreOps.PrintClassProc ← IdentityPrint]]]]];
Identity: PUBLIC PROC [cellType: CellType, name: ROPE, props: Properties ← NIL] RETURNS [identity: CellType] = {
identity ← CoreOps.CreateCellType[
class: identityCellClass,
public: CoreOps.CopyWireSequence[cellType.public],
data: cellType,
name: name,
props: props];
};
IdentityRecast: RecastProc = {new ← NARROW [new.data]};
IdentityPrint: CoreOps.PrintClassProc = {
ct: CellType ← NARROW [data];
out.PutF["\nIdentity of %g", IO.rope[CoreOps.GetCellTypeName[ct]]];
};
Unspecified
unspecifiedCellClass: PUBLIC CellClass ← NEW [CellClassRec ← [name: "Unspecified"]];
END.