Square:
PROC [name:
ATOM, upLeft, upRight, lowLeft, lowRight: AtomicTile]
RETURNS [cell:
CD.Object] = {
cell ← PW.CreateEmptyCell[];
[] ← PW.IncludeInCell[cell, masks[upLeft], [0, size.y]];
[] ← PW.IncludeInCell[cell, masks[upRight], size, 1];
[] ← PW.IncludeInCell[cell, masks[lowLeft], [0, 0], 5];
[] ← PW.IncludeInCell[cell, masks[lowRight], [size.x, 0], 4];
CDCells.SetInterestRect[cell, [0, 0, 2*size.x, 2*size.y]];
IncludePin[cell, "Input", CMosB.pol, [3*l, 0], [2*l, 2*size.y]];
IncludePin[cell, "Input", CMosB.met2, [2*l, 0], [4*l, 2*size.y]];
IncludePin[cell, "NotInput", CMosB.pol, [11*l, 0], [2*l, 2*size.y]];
IncludePin[cell, "NotInput", CMosB.met2, [10*l, 0], [4*l, 2*size.y]];
IncludePin[cell, "Gnd", CMosB.met, [0, 10*l], [2*size.x, 4*l]];
IncludePin[cell, "Plus", CMosB.met, [14*l, 18*l], [2*l, 4*l]];
IncludePin[cell, "Minus", CMosB.met, [14*l, 2*l], [2*l, 4*l]];
IF upLeft=trans
OR upRight=trans
THEN IncludePin[cell, "PlusLeft", CMosB.met, [0, 18*l], [2*l, 4*l]];
IF lowLeft=trans
OR lowRight=trans
THEN IncludePin[cell, "MinusLeft", CMosB.met, [0, 2*l], [2*l, 4*l]];
PW.RepositionCell[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]
]]];