IMPORTS CoreClasses, CoreCreate, CoreFlat, CoreOps, CoreProperties, GList, RefTab =
Create2Inverter:
PROC []
RETURNS [cellType: CellType] = {
In: Wire ← CoreOps.CreateWire[name: "In"];
Out: Wire ← CoreOps.CreateWire[name: "Out"];
Gnd: Wire ← CoreCreate.Seq[size:2, name: "Gnd"];
Vdd: Wire ← CoreCreate.Seq[size:2, name: "Vdd"];
Intern: Wire ← CoreOps.CreateWire[name: "Intern"];
inverter: CellType ← CreateInverter[];
first: CoreClasses.CellInstance ←
NEW [CoreClasses.CellInstanceRec ← [
actual: CoreOps.CreateWire[LIST [In, Intern, Gnd[0], Vdd[0]]],
type: inverter
]];
second: CoreClasses.CellInstance ←
NEW [CoreClasses.CellInstanceRec ← [
actual: CoreOps.CreateWire[LIST [Intern, Out, Gnd[1], Vdd[1]]],
type: inverter
]];
cellType ← CoreClasses.CreateRecordCell[
public: CoreOps.CreateWire[LIST [In, Out, Gnd, Vdd]],
internal: CoreOps.CreateWire[LIST [In, Out, Gnd, Vdd, Intern]],
instances: LIST [first, second],
name: "Inverter2"
];
};
CreateUnNamed2Inverter:
PROC []
RETURNS [cellType: CellType] = {
In: Wire ← CoreOps.CreateWire[];
Out: Wire ← CoreOps.CreateWire[];
Gnd: Wire ← CoreCreate.Seq[size:2];
Vdd: Wire ← CoreCreate.Seq[size:2];
Intern: Wire ← CoreOps.CreateWire[];
inverter: CellType ← CreateInverter[];
first: CoreClasses.CellInstance ←
NEW [CoreClasses.CellInstanceRec ← [
actual: CoreOps.CreateWire[LIST [In, Intern, Gnd[0], Vdd[0]]],
type: inverter
]];
second: CoreClasses.CellInstance ←
NEW [CoreClasses.CellInstanceRec ← [
actual: CoreOps.CreateWire[LIST [Intern, Out, Gnd[1], Vdd[1]]],
type: inverter
]];
cellType ← CoreClasses.CreateRecordCell[
public: CoreOps.CreateWire[LIST [In, Out, Gnd, Vdd]],
internal: CoreOps.CreateWire[LIST [In, Out, Gnd, Vdd, Intern]],
instances: LIST [first, second],
name: "Inverter2",
giveNames: TRUE
];
};
Test:
PROC [] = {
AllTheWay: FlattenCellTypeProc = {flatten ← cellType.class#CoreClasses.transistorCellClass};
cellType, ct, unspec: CellType;
data: CoreClasses.RecordCellType;
public, wire: Wire;
wires: Wires;
table: RefTab.Ref;
wirePath: ROPE;
flatWire: CoreFlat.FlatWireRec;
cellType ← CreateInverter[];
data ← NARROW [cellType.data];
IF CoreClasses.InstanceIndex[cellType, data[1]]#1 THEN ERROR;
cellType ← Create2Inverter[];
IF CoreClasses.InstanceIndex[cellType, data[1]]#-1 THEN ERROR;
cellType ← CreateInverters[6];
cellType ← CreateInvertersPlusOne[6];
cellType ← CreateUnNamed2Inverter[];
IF CoreOps.FindWire[cellType.public, "In"]=NIL THEN ERROR;
IF CoreOps.FindWire[cellType.public, "Out"]=NIL THEN ERROR;
IF CoreOps.FindWire[cellType.public, "Gnd"]#NIL THEN ERROR;
IF CoreOps.FindWire[cellType.public, "Vdd"]#NIL THEN ERROR;
IF CoreOps.FindWire[cellType.public, "Intern"]#NIL THEN ERROR;
wire ← cellType.public[2]; -- Gnd
wires ← LIST [wire];
IF NOT GList.EqLists[CoreOps.ParentWires[cellType.public, wire[0]], wires] THEN ERROR;
wires ← LIST [cellType.public];
IF NOT GList.EqLists[CoreOps.ParentWires[cellType.public, wire], wires] THEN ERROR;
IF NOT GList.EqLists[CoreOps.ParentWires[cellType.public, cellType.public], NIL] THEN ERROR;
IF cellType.public.size#CoreOps.CopyWire[cellType.public].size THEN ERROR;
Test for CoreFlat
cellType ← Create2Inverter[];
cellType ← Flatten[cellType, AllTheWay];
IF cellType.public.size#6 THEN ERROR;
data ← NARROW [cellType.data];
IF data.internal.size#7 THEN ERROR;
IF data.size#4 THEN ERROR;
cellType ← Create2Inverter[];
flatWire ← CoreFlat.ParseWirePath[cellType, "Intern"];
wirePath ← CoreFlat.WirePathRope[cellType, flatWire];
flatWire ← CoreFlat.ParseWirePath[cellType, "/0.actual.In"];
wirePath ← CoreFlat.WirePathRope[cellType, flatWire];
Test for CoreClasses.CreatePermutedRecordCell
cellType ← Create2Inverter[];
public ← CoreCreate.Wires[CoreCreate.Seq["Gnd", 2], "Out"]; -- no Vdd and In and Out collapsed
unspec ← CoreClasses.CreateUnspecified[public];
table ← RefTab.Create[];
[] ← RefTab.Store[table, CoreOps.FindWire[cellType.public, "Gnd"], CoreOps.FindWire[public, "Gnd"]];
[] ← RefTab.Store[table, CoreOps.FindWire[cellType.public, "In"], CoreOps.FindWire[public, "Out"]];
[] ← RefTab.Store[table, CoreOps.FindWire[cellType.public, "Out"], CoreOps.FindWire[public, "Out"]];
ct ← CoreClasses.CreatePermutedRecordCell[public, cellType, table];
Test for Properties inheritance
cellType ← Create2Inverter[];
IF CoreProperties.InheritCellTypeProp[cellType, $foo]#NIL THEN ERROR;
CoreProperties.PutCellTypeProp[cellType, $foo, $bar];
IF CoreProperties.InheritCellTypeProp[cellType, $foo]#$bar THEN ERROR;
CoreProperties.PutCellTypeProp[cellType, $foo, NIL];
CoreProperties.PutCellClassProp[cellType.class, $foo, $bar];
IF CoreProperties.InheritCellTypeProp[cellType, $foo]#$bar THEN ERROR;
CoreProperties.PutCellTypeProp[cellType, $foo, $zob];
IF CoreProperties.InheritCellTypeProp[cellType, $foo]#$zob THEN ERROR;
CoreProperties.PutCellTypeProp[cellType, $foo, NIL];
CoreProperties.PutCellClassProp[cellType.class, $foo, NIL];
IF CoreProperties.InheritCellTypeProp[cellType, $foo]#NIL THEN ERROR;
CoreProperties.PutWireProp[CoreOps.FindWire[cellType.public, "Gnd"], $bip, $bop];
IF CoreProperties.InheritPublicProp[cellType, CoreOps.FindWire[cellType.public, "Gnd"], $bip]#$bop THEN ERROR;
IF CoreProperties.InheritPublicProp[cellType, CoreOps.FindWire[cellType.public, "Gnd"], $burp]#NIL THEN ERROR;
};