DIRECTORY Basics, CD, CDPinObjects, Core, CoreClasses, CoreCompose, CoreFlatten, CoreOps, CoreProperties, IO, PW, PWCore, PWPins, Rope, Rosemary, Sinix; CrossRAMDecoder: CEDAR PROGRAM IMPORTS Basics, CDPinObjects, CoreCompose, CoreFlatten, CoreProperties, IO, PW, PWCore, PWPins, Rope, Rosemary, Sinix = BEGIN OPEN CoreCompose; Wire: TYPE = Core.Wire; Decoder: ROPE = RegisterStructureProc[name: "Decoder", proc: CreateDecoder]; CreateDecoder: StructureProc = { rowQuads: INT _ GetInt[context, $rowQuads]; rowPairs: INT _ 2*rowQuads; nRopesVdd: ROPE _ "Vdd"; nRopesGnd: ROPE _ "Gnd"; FOR row: INT IN (0 .. rowPairs) DO nRopesVdd _ Rope.Cat[nRopesVdd, ", Vdd"]; ENDLOOP; FOR row: INT IN (0 .. rowPairs) DO nRopesGnd _ Rope.Cat[nRopesGnd, ", Gnd"]; ENDLOOP; RegisterIntProperty[prop: $andDecoderBits]; RegisterIntProperty[prop: $rowPairs]; PushInt[context: context, prop: $andDecoderBits, val: GetInt[context, $addressDecoderBits]-1]; PushInt[context: context, prop: $rowPairs, val: rowPairs]; cellType _ CreateRecordCell[ name: Decoder, context: context, public: CreateWires[context, "Vdd, Gnd, VddLeft, VddMiddle, VddRight, GndLeft, GndMiddle, AccessB, AdrBit[seq: addressDecoderBits], nAdrBit[seq: addressDecoderBits], Word[seq: 4*rowQuads]"], onlyInternal: CreateWires[context, "nDecode[seq: 2*rowQuads]"], instances: LIST [ [type: CreateStructure[name: "DecoderLeftColumn", context: context]], [type: CreateStructure[name: "DecoderAndPlane", context: context], actual: IO.PutFR["Vdd: [%g], VddWell1: [%g], VddWell2: [%g], Gnd: [%g], AdrBit: AdrBit[start: 0, len: andDecoderBits], nAdrBit: nAdrBit[start: 0, len: andDecoderBits]", IO.rope[nRopesVdd], IO.rope[nRopesVdd], IO.rope[nRopesVdd], IO.rope[nRopesGnd]]], [type: CreateStructure[name: "DecoderRightColumn", context: context], actual: IO.PutFR["Vdd: [%g]", IO.rope[nRopesVdd]]], [type: CreateStructure[name: "DecoderLogicColumn", context: context], actual: "Vdd: VddMiddle, Gnd: GndMiddle, TreeSelect: [AdrBit[addressDecoderBits-1], nAdrBit[addressDecoderBits-1]]"] ] ]; IF GetBool[context, $PWCore] THEN PWCore.SetAbutX[cellType: cellType]; IF GetBool[context, $Sinix] THEN [] _ Sinix.ExtractObj[PWCore.GetLayout[cellType]]; }; DecoderRow: ROPE = RegisterStructureProc[name: "DecoderRow", proc: CreateDecoderRow]; CreateDecoderRow: StructureProc = { andDecoderBits: INT _ GetInt[context, $andDecoderBits]; row: INT _ GetInt[context, $row]; design: CD.Design _ NARROW[GetRef[context, $sourceCDDesign]]; dec0: PW.Object _ PW.Get[design, "DecoderZero"]; dec1: PW.Object _ PW.Get[design, "DecoderOne"]; DecoderSelect: PW.XYFunction ={ RenameEach: PWPins.ChangePinProc = { name: ROPE _ CDPinObjects.GetName[oldPin]; SELECT TRUE FROM Rope.Equal[name, "nDecodeGnd"] OR Rope.Equal[name, "nDecodeVdd"] OR Rope.Equal[name, "VddWell2"] OR Rope.Equal[name, "VddWell1"] OR Rope.Equal[name, "Vdd"] OR Rope.Equal[name, "Gnd"] => newPin _ PWPins.CopyInstance[oldPin]; Rope.Equal[name, "AdrBit"] OR Rope.Equal[name, "nAdrBit"] => { newPin _ PWPins.CopyInstance[oldPin]; CDPinObjects.SetName[newPin, Rope.Cat[name, "[", IO.PutR[IO.int[x]], "]"]]; }; ENDCASE => ERROR; }; oddBit: BOOL _ PW.XthBitOfN[x, row]; resultingOb _ IF oddBit THEN dec1 ELSE dec0; resultingOb _ PWPins.ChangePins[NIL, resultingOb, RenameEach]; }; actual: ROPE _ "Input: ["; FOR bit: INT IN [0 .. andDecoderBits) DO actual _ Rope.Cat[actual, IO.PutFR["%gAdrBit[%g]", IO.rope[IF Basics.BITAND[Basics.BITSHIFT[row, bit-andDecoderBits+1], 1]#0 THEN NIL ELSE "n"], IO.int[bit]]]; IF bitKšœ%˜%Kšœ1žœžœ˜KK˜—Kšžœžœ˜—K˜—Kšœžœžœ˜$Kšœžœžœžœ˜,Kšœ žœ˜>Kšœ˜—Kšœžœ˜šžœžœžœž˜(Kšœžœžœžœžœžœ"žœžœžœžœ ˜ŸKšžœžœ!˜=Kšžœ˜—šœ˜Kšœ˜K˜Kšœ˜šœ žœ˜Kšœ3™3šœ8˜8Kšœ5˜5—Kšœ6™6šœ8˜8Kšœ3˜3—Kšœ˜—Kšœ˜—Kšžœžœ>žœžœ&˜˜Kšžœžœ3˜SKšœ˜K˜—Jšœž™Jšœ\™\KšœžœO˜dšœ(˜(Kšœ žœ˜+Kšœžœ$˜7Kšœžœ˜Kšœ ˜ KšœW˜WKšœ3˜3Kšœ6˜6š žœžœžœžœΟcΠbc ˜/Kšœ0˜0šœ žœ˜šœ žœˆžœžœ žœ žœ žœ žœ žœ ˜ιKšœ>˜>—Kšœ ˜ —Kšžœ˜—šœ˜Kšœ˜K˜šœ˜Kšœ―˜―—Kšœ˜—Kšžœžœ/žœ˜XKšžœžœ3˜SKšœ˜—J™Jšœ™šœžœS˜jšœ*˜*šœ˜Kšœ˜KšœC˜CKšœ2˜2—Kšžœžœ&˜GKšžœžœ3˜SKšœ˜K˜——Jšœ™šœžœO˜dšœ(˜(KšœT˜Tšœ˜Kšœ˜K˜Kšœ)˜)šœ žœ˜Kšœ˜Kšœ˜——Kšžœžœ/žœ˜WKšžœžœ3˜SKšœ˜K˜——Jšœ™šœ žœG˜Xšœ$˜$šœ˜Kšœ˜K˜Kšœ*˜*—Kšžœžœ+žœ$˜vKšžœžœ3˜SKšœ˜K˜——Jšœ"™"šœžœU˜mšœ+˜+šœ˜Kšœ˜KšœF˜FKšœ1˜1Kšœ˜—Kšžœžœ&˜GKšžœžœ3˜SKšœ˜K˜——Jšœ™šœžœQ˜gšœ)˜)KšœV˜Všœ˜Kšœ˜K˜Kšœ=˜=šœ žœ˜Kšœ,˜,Kšœ˜Kšœ,˜,Kšœ˜——Kšžœžœ/žœ˜WKšžœžœ3˜SKšœ˜K˜——Jšœ™šœžœI˜[šœ%˜%šœ˜Kšœ˜K˜Kšœ/˜/—Kšžœžœ+žœ$˜vKšžœžœ3˜SKšœ˜K˜——JšœW™WšœžœU˜mšœ+˜+šœ˜Kšœ˜KšœD˜DKšœ1˜1Kšœ ˜ —Kšžœžœ&˜GKšžœžœ3˜SKšœ˜K˜——JšœE™EšœžœQ˜gšœ)˜)KšœV˜VKšœ!˜!šœ˜Kšœ˜K˜Kšœ˜šœ žœ˜Kšœ=˜=Kšœ˜Kšœ=˜=Kšœ˜——Kšœžœ˜Kšžœžœ/žœ˜WKšžœžœ3˜SKšœ˜K˜——Jšœ?™?šœžœI˜[šœ%˜%šœ˜Kšœ˜Kšœ>˜>Kšœ ˜ Kšœ#˜#—Kšžœžœ+žœ$˜vKšžœžœ3˜SKšœ˜K˜——Jšœ3™3šœ žœE˜Ušœ#˜#šœžœ˜ Kšœ<˜