In: INT; -- ports
nIn: INT;
nMin: INT;
design: CD.Design ← PW.OpenDesign["Arbiter24"];
cx: Sisyph.Context ← Sisyph.Create[design];
peType ← Sisyph.ExtractSchematicByName[name: "PE-8-3.icon", cx: cx];
In ← CoreOps.GetWireIndex[peType.public, "In"];
nIn ← CoreOps.GetWireIndex[peType.public, "nIn"];
nMin ← CoreOps.GetWireIndex[peType.public, "nMin"];
[] ← Rosemary.SetFixedWire[CoreCreate.FindWire[peType.public, "Vdd"], H];
[] ← Rosemary.SetFixedWire[CoreCreate.FindWire[peType.public, "Gnd"], L];
FOR i:
INT
IN [0..nInputs)
DO
[] ← Ports.InitPort[wire: peType.public[In][i], levelType: c];
[] ← Ports.InitTesterDrive[wire: peType.public[In][i], initDrive: force];
[] ← Ports.InitPort[wire: peType.public[nIn][i], levelType: c];
[] ← Ports.InitTesterDrive[wire: peType.public[nIn][i], initDrive: force];
ENDLOOP;
[] ← Ports.InitPort[wire: peType.public[nMin], levelType: c, initDrive: force];
[] ← Ports.InitTesterDrive[wire: peType.public[nMin], initDrive: expect];
ioPort ← Ports.CreatePort[peType.public];
simulation ← Rosemary.InstantiateCellType[cellType: peType, testPort: ioPort];
tester ← RosemaryUser.TestProcedureViewer[cellType: peType, testButtons: LIST["PERandomTest"], name: "Priority Encoder Test", -- displayWires: RosemaryUser.DisplayPortLeafWires[peType], -- cutSet: CoreFlat.CreateCutSet[labels: LIST[Logic.logicCutSet, Logic.macroCutSet]]];
};
PERandomTestProc:
PROC [cellType: Core.CellType, p: Ports.Port,
Eval:
PROC [memory:
BOOL ←
TRUE]]
-- RosemaryUser.TestProc -- = {
In: INT = CoreOps.GetWireIndex[cellType.public, "In"]; -- ports
nIn: INT = CoreOps.GetWireIndex[cellType.public, "nIn"];
nMin: INT = CoreOps.GetWireIndex[cellType.public, "nMin"];
iterations ← 0;
DO
min: NAT = rs.ChooseInt[0, range-1];
where: NAT = rs.ChooseInt[0, nInputs-1];
inputs: ARRAY [0..nInputs) OF INT;
iterations ← iterations+1;
FOR i:
INT
IN [0..nInputs)
DO
inputs[i] ← (IF i = where THEN min ELSE rs.ChooseInt[min, range-1]);
p[In][i].c ← inputs[i];
p[nIn][i].c ← range-1-inputs[i];
ENDLOOP;
p[nMin].c ← range-1-min;
Eval[];
ENDLOOP;
};