CreateInverter:
PROC
RETURNS [cellType: Core.CellType, In, Out, Bus, Gnd, Vdd: Core.Wire] = {
In ← CoreOps.CreateWire[name: "In"];
Out ← CoreOps.CreateWire[name: "Out"];
Bus ← CoreOps.CreateWires[name: "Bus", size: 3];
Gnd ← CoreOps.CreateWire[name: "Gnd"];
Vdd ← CoreOps.CreateWire[name: "Vdd"];
{
ntrans: CoreClasses.CellInstance ←
NEW [CoreClasses.CellInstanceRec ← [
actual: CoreOps.CreateWire[LIST [In, Out, Gnd]],
type: CoreClasses.CreateTransistor[nE]
]];
ptrans: CoreClasses.CellInstance ←
NEW [CoreClasses.CellInstanceRec ← [
actual: CoreOps.CreateWire[LIST [In, Out, Vdd, Vdd]],
type: CoreClasses.CreateTransistor[pE]
]];
FOR i:
NAT
IN [0..3)
DO
Bus[i] ← CoreOps.CreateWire[];
ENDLOOP;
cellType ← CoreClasses.CreateRecordCell[
public: CoreOps.CreateWire[LIST [In, Out, Bus, Gnd, Vdd]],
internal: CoreOps.CreateWire[LIST [In, Out, Bus, Gnd, Vdd]],
instances: LIST [ntrans, ptrans],
name: "Inverter"
];
};
};
CreateSequence:
PROC
RETURNS [sequence, recasted: Core.CellType ←
NIL] = {
inverter: Core.CellType;
In, Out, Bus, Gnd, Vdd: Core.Wire;
bindings: Sequence.WireBindings ← NIL;
operations: Sequence.Operations ← RefTab.Create[];
[inverter, In, Out, Bus, Gnd, Vdd] ← CreateInverter[];
bindings ← CONS[[In, Out], bindings];
[] ← RefTab.Store[operations, In, NEW[Sequence.OperationRec ← [expose: [FALSE, FALSE, FALSE, TRUE, FALSE]]]];
[] ← RefTab.Store[operations, Out, NEW[Sequence.OperationRec ← [expose: [FALSE, FALSE, FALSE, FALSE, TRUE]]]];
bindings ← CONS[[Bus, Bus], bindings];
[] ← RefTab.Store[operations, Bus, NEW[Sequence.OperationRec ← [expose: [FALSE, FALSE, TRUE, FALSE, FALSE]]]];
bindings ← CONS[[Gnd, Gnd], bindings];
[] ← RefTab.Store[operations, Gnd, NEW[Sequence.OperationRec ← [expose: [FALSE, FALSE, TRUE, FALSE, FALSE]]]];
bindings ← CONS[[Vdd, Vdd], bindings];
[] ← RefTab.Store[operations, Vdd, NEW[Sequence.OperationRec ← [expose: [FALSE, FALSE, TRUE, FALSE, FALSE]]]];
sequence ← Sequence.CreateSequence[inverter, 3, bindings, operations];
recasted ← sequence.class.recast[sequence];
CoreOps.Print[sequence];
CoreOps.Print[recasted];
};