Square:
PROC [name:
ATOM, upLeft, upRight, lowLeft, lowRight: AtomicTile]
RETURNS [cell:
CD.Object] = {
IncludeMask:
PROC [mask:
CD.Object, pos:
CD.Position, orient:
CD.Orientation] = {
instances ← CONS [CDInstances.NewInst[mask, [CDBasics.SubPoints[pos, CDBasics.BaseOfRect[CDBasics.MapRect[CD.InterestRect[mask], [[0, 0], orient]]]], orient]], instances];
};
IncludePin:
PROC [name:
ROPE, layer:
CD.Layer, pos:
CD.Position, size:
CD.Position] = {
inst: CD.Instance = CDInstances.NewInst[CDRects.CreateRect[size, layer], [pos]];
instances ← CONS [inst, instances];
CDProperties.PutInstanceProp[inst, $SignalName, name];
};
instances: CD.InstanceList ← NIL;
IncludeMask[masks[upLeft], [0, size.y], original];
IncludeMask[masks[upRight], size, mirrorX];
IncludeMask[masks[lowLeft], [0, 0], rotate180X];
IncludeMask[masks[lowRight], [size.x, 0], rotate180];
IncludePin["Input", CMosB.pol, [3*l, 0], [2*l, 2*size.y]];
IncludePin["Input", CMosB.met2, [2*l, 0], [4*l, 2*size.y]];
IncludePin["NotInput", CMosB.pol, [11*l, 0], [2*l, 2*size.y]];
IncludePin["NotInput", CMosB.met2, [10*l, 0], [4*l, 2*size.y]];
IncludePin["Gnd", CMosB.met, [0, 10*l], [2*size.x, 4*l]];
IncludePin["Plus", CMosB.met, [14*l, 19*l], [2*l, 3*l]];
IncludePin["Minus", CMosB.met, [14*l, 2*l], [2*l, 3*l]];
IF upLeft=trans
OR upRight=trans
THEN IncludePin["PlusLeft", CMosB.met, [0, 19*l], [2*l, 3*l]];
IF lowLeft=trans
OR lowRight=trans
THEN IncludePin["MinusLeft", CMosB.met, [0, 2*l], [2*l, 3*l]];
cell ← PW.CreateCell[instances, [0, 0, 2*size.x, 2*size.y]];
cell ← PW.Flatten[cell];
[] ← CDDirectory.Include[design, cell, IO.PutFR["%g.mask", IO.atom[name]]];
CoreOps.Print[Sinix.Extract[cell, PWCore.extractMode].result, TerminalIO.TOS[]];
};
RETURN [
PW.AbutListX[
LIST [
Square[$Case11, gnd, gnd, nope, nope],
Square[$Case00, nope, nope, gnd, gnd],
Square[$Case10, gnd, nope, nope, gnd],
Square[$Case01, nope, gnd, gnd, nope],
Square[$Case1X, gnd, nope, nope, trans],
Square[$Case0X, nope, trans, gnd, nope],
Square[$CaseX1, nope, gnd, trans, nope],
Square[$CaseX0, trans, nope, nope, gnd],
Square[$CaseXX, nope, nope, nope, nope],
Square[$CaseTX, trans, nope, trans, nope],
Square[$CaseXT, nope, trans, nope, trans]
]]];