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, 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], Gnd: [%g], AdrBit: AdrBit[start: 0, len: andDecoderBits], nAdrBit: nAdrBit[start: 0, len: andDecoderBits], nDecodeVdd: nDecode, nDecodeGnd: nDecode", 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, VddLeft: Vdd, Gnd: GndMiddle, TreeSelect: [AdrBit[addressDecoderBits-1], nAdrBit[addressDecoderBits-1]]"] ] ]; IF GetBool[context, $PWCore] THEN PWCore.SetAbutX[cellType: cellType]; IF GetBool[context, $Sinix] THEN [] _ Sinix.Extract[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, "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šžœžœ0˜PKšœ˜K˜—Jšœž™Jšœx™xKšœžœ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šžœžœ0˜PKšœ˜—J™Jšœ™šœžœS˜jšœ*˜*šœ˜Kšœ˜KšœC˜CKšœ2˜2—Kšžœžœ&˜GKšžœžœ0˜PKšœ˜K˜——Jšœ™šœžœO˜dšœ(˜(KšœT˜Tšœ˜Kšœ˜K˜Kšœ)˜)šœ žœ˜Kšœ˜Kšœ˜——Kšžœžœ/žœ˜WKšžœžœ0˜PKšœ˜K˜——Jšœ™šœ žœG˜Xšœ$˜$šœ˜Kšœ˜K˜Kšœ*˜*—Kšžœžœ+žœ$˜vKšžœžœ0˜PKšœ˜K˜——Jšœ"™"šœžœU˜mšœ+˜+šœ˜Kšœ˜KšœF˜FKšœ1˜1Kšœ˜—Kšžœžœ&˜GKšžœžœ0˜PKšœ˜K˜——Jšœ™šœžœQ˜gšœ)˜)KšœV˜Všœ˜Kšœ˜K˜Kšœ=˜=šœ žœ˜Kšœ,˜,Kšœ˜Kšœ,˜,Kšœ˜——Kšžœžœ/žœ˜WKšžœžœ0˜PKšœ˜K˜——Jšœ™šœžœI˜[šœ%˜%šœ˜Kšœ˜K˜Kšœ/˜/—Kšžœžœ+žœ$˜vKšžœžœ0˜PKšœ˜K˜——JšœW™WšœžœU˜mšœ+˜+šœ˜Kšœ˜KšœD˜DKšœ1˜1Kšœ ˜ —Kšžœžœ&˜GKšžœžœ0˜PKšœ˜K˜——JšœE™EšœžœQ˜gšœ)˜)KšœV˜VKšœ!˜!šœ˜Kšœ˜K˜Kšœ˜šœ žœ˜Kšœ=˜=Kšœ˜Kšœ=˜=Kšœ˜——Kšœžœ˜Kšžœžœ/žœ˜WKšžœžœ0˜PKšœ˜K˜——Jšœ?™?šœžœI˜[šœ%˜%šœ˜Kšœ˜Kšœ>˜>Kšœ ˜ Kšœ#˜#—Kšžœžœ+žœ$˜vKšžœžœ0˜PKšœ˜K˜——Jšœ3™3šœ žœE˜Ušœ#˜#šœžœ˜ Kšœ<˜