<> <> <> <<>> <> <<>> DIRECTORY BitOps, Core, CoreClasses, CoreCreate, CoreGeometry, CoreOps, Logic, LogicUtils, Rope, Sinix, Sisyph, Static; IOBLogic: CEDAR PROGRAM IMPORTS BitOps, CoreCreate, CoreGeometry, CoreOps, Logic, LogicUtils, Sinix, Sisyph, Static SHARES Sisyph ~ BEGIN OPEN LogicUtils, CoreCreate; ROPE: TYPE ~ Rope.ROPE; <> <> <<>> OneShotName: ROPE = "OneShot"; OneShot: PROC [cx: Sisyph.Context, d: NAT] RETURNS [ct: CellType] = { oneShot1B: CellType = Sisyph.ES["oneShot1B.sch", cx]; -- schematic for small d insts: CoreClasses.CellInstances; tmp: Core.Wire; IF d=0 THEN LogicUtils.Error["Please provide the delay for the one-shot"]; insts _ LIST[ Instance[Logic.Nand[d], ["I", "nTmp"], ["X", "Output"]]]; tmp _ Seq["Tmp", d]; [] _ Static.UnconnectedOK[tmp[d-1]]; -- This is the only wire unused in the whole cell FOR i: NAT IN [0..d) DO insts _ CONS[ Instance[oneShot1B, ["D", IF i=0 THEN "Trigger" ELSE Index["Tmp", i-1]], ["Q", Index["Tmp", i]], ["nQ", Index["nTmp", i]]], insts]; ENDLOOP; ct _ Cell[ name: OneShotName, public: Wires["Trigger", "Output", "Vdd", "Gnd", "CK"], onlyInternal: Wires[Seq["nTmp", d], tmp], instances: insts]; }; <> <> <<>> Constant: Sinix.ExtractProc = { <> <> cx: Sisyph.Context = Sisyph.EvaluateParameters[userData, obj, properties]; iconCT: CellType = NARROW [Sinix.ExtractCell[obj, mode, NIL, cx].result]; gnd: Wire = CoreOps.CreateWire[name: "Gnd"]; vdd: Wire = CoreOps.CreateWire[name: "Vdd"]; output: Wire; b: NAT; v: INT; vCard: CARD; b _ Sisyph.FetchInt[cx, "b"].value; v _ Sisyph.FetchInt[cx, "v"].value; vCard _ LOOPHOLE[v]; IF b<=0 THEN LogicUtils.Error["Specify number of bits for Constant"]; output _ Seq[size: b]; IF b<=32 THEN FOR i: NAT IN [0..b) DO output[i] _ IF BitOps.EBFD[vCard, i, b] THEN vdd ELSE gnd; ENDLOOP ELSE { sign: Wire _ IF v<0 THEN vdd ELSE gnd; FOR i: NAT IN [0..b-32) DO output[i] _ sign; ENDLOOP; FOR i: NAT IN [b-32..b) DO output[i] _ IF BitOps.EBFD[vCard, i-b+32, 32] THEN vdd ELSE gnd; ENDLOOP; }; CoreGeometry.PutIndirectLazyPins[mode.decoration, output, CoreOps.FindWire[iconCT.public, "Output"]]; result _ Wires[output, gnd, vdd]; }; <> <> <> <> < Input[b], Output[b], Force (when TRUE, select the constant)>> <> <> <> <> <> <> <> <> <> <> <> <> <<["I[0]", "nnForce"], ["I[1]", input[i]], ["X", output[i]]],>> <> <> <> <> <> <> <> <> <<};>> END.