CoreClassesImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Barth, October 2, 1985 11:28:58 am PDT
Spreitzer, December 1, 1985 7:01:10 pm PST
Bertrand Serlet December 3, 1985 1:28:33 am PST
Pradeep Sindhu December 4, 1985 11:59:23 am 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];
};
CreateRecordCell: PUBLIC PROC [public: Wire, internal: Wire, instances: LIST OF CellInstance, name: ROPENIL, props: Properties ← NIL] RETURNS [recordCell: CellType] = {
data: RecordCellType;
size: NAT ← 0;
FOR list: LIST OF CellInstance ← instances, list.rest WHILE list#NIL DO
size ← size+1;
ENDLOOP;
data ← NEW [RecordCellTypeRec[size]];
size ← 0;
FOR list: LIST OF CellInstance ← instances, list.rest WHILE list#NIL DO
data[size] ← list.first; size ← size+1;
IF ~CoreOps.Conform[list.first.actual, list.first.type.public] THEN ERROR;
ENDLOOP;
data.internal ← internal;
recordCell ← CoreOps.CreateCellType[recordCellClass, public, data, name, props];
};
GetCellInstanceName: PUBLIC PROC [instance: CellInstance] RETURNS [name: ROPENIL] = {
name ← NARROW [CoreProperties.GetCellInstanceProp[instance, CoreOps.nameProp]];
};
RecordPrint: PUBLIC PROC [recordCellType: RecordCellType, out: STREAM] = {
IO.PutRope[out, "\nInternal wire:"];
CoreOps.FullNameWire[wire: recordCellType.internal, name: NIL, prop: internalFullName];
CoreOps.PrintWire[recordCellType.internal, out];
IO.PutF[out, "\n%g instances", IO.int[recordCellType.size]];
FOR i: NAT IN [0 .. recordCellType.size) DO
firstActual: BOOLTRUE;
instanceName: ROPE ← GetCellInstanceName[recordCellType.instances[i]];
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]];
};
};
IF instanceName = NIL THEN instanceName ← "<no name>";
IO.PutF[out,
"\nCellInstance %g: %g",
[rope[instanceName]],
[rope[CoreOps.GetCellTypeName[recordCellType.instances[i].type]]]
];
IO.PutRope[out, "\n Actual wire: "];
CoreOps.FullNameWire[recordCellType.instances[i].type.public];
IF CoreOps.VisitBinding[recordCellType.instances[i].actual, recordCellType.instances[i].type.public, EachWirePair] THEN out.PutF["*** Actual and Public do not conform\n"];
CoreProperties.PrintProperties[props: recordCellType.instances[i].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];
};
internalFullName: PUBLIC ATOM ← CoreProperties.RegisterProperty[$CoreInternalWireFullName, CoreProperties.Props[[CoreProperties.propPrint, CoreProperties.PropDontPrint]]];
FullNameInternalWire: CoreOps.NameWireProc = {
rct: RecordCellType ← NARROW [data];
CoreOps.FullNameWire[wire: rct.internal, prop: internalFullName];
};
Transistor
transistorCellClass: PUBLIC CellClass ← NEW [CellClassRec ← [name: "Transistor", recast: NIL]];
CreateTransistor: PUBLIC PROC [args: TransistorRec] RETURNS [cellType: CellType] = {
tranNames: ARRAY TransistorType OF ROPE ← ["nE", "pE", "nD"];
tranPublic: Wire ← CoreOps.WiresToWire[LIST[
CoreOps.CreateWire[name: "gate"],
CoreOps.CreateWire[name: "ch1"],
CoreOps.CreateWire[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]]]]];
CreateIdentity: PUBLIC PROC [cellType: CellType, name: ROPE, props: Properties ← NIL] RETURNS [identity: CellType] = {
identity ← CoreOps.CreateCellType[
class: identityCellClass,
public: CoreOps.CopyWire[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.