DIRECTORY CDTexts, CDOps, CDRects, CDCells, CDGenerate, CD, CDDirectory, CDSatellites, IO, Rope, TerminalIO; ArbPEGen: CEDAR PROGRAM IMPORTS CDOps, CDTexts, CDRects, CDCells, CDGenerate, CD, CDSatellites, IO, Rope, TerminalIO = BEGIN tech: CD.Technology _ CD.FetchTechnology[$cmosB]; comment: CD.Layer _ CD.FetchLayer[t: tech, uniqueKey: $comment]; font: CDTexts.CDFont _ CDTexts.MakeFont[name: "Xerox/TiogaFonts/Helvetica8", scale: 2]; lambda: INT _ tech.lambda; cellSizeY: INT _ 8*13*lambda; PETerms: CDGenerate.GeneratorProc = BEGIN Trit: TYPE = {zero, one, x}; nBits: [1..4] = TerminalIO.RequestInt["How many bits wide? [1..4] "]; Pattern: TYPE = ARRAY [0..4) OF Trit; yBase: INT _ 0; outGates: ARRAY BOOL -- isSome -- OF Rope.ROPE _ ["and8cw", "or8aw"]; inGates: ARRAY BOOL -- isSome -- OF ARRAY [1..4] OF Rope.ROPE _ [ ["*pass", "Logic.nand2.icon", "Logic.nand3.icon", "Logic.nand4.icon"], ["*pass", "Logic.nor2P.icon", "Logic.nor3P.icon", "Logic.nor4P.icon"]]; gateInpPos: ARRAY [1..4] OF RECORD [base, delta: INT] _ [[6,0], [4, 4], [2,4], [2,3]]; XOR: PROC [ a, b: BOOL ] RETURNS [ c: BOOL] = { c _ (a AND NOT b) OR (b AND NOT a); }; AddToTermCell: PROC [pattern: Pattern] = BEGIN mainGate, inGate, ioWire, text: CD.Object; tInst, wInst: CD.Instance; isSome: BOOL; sCnt: NAT _ 0; gateName: Rope.ROPE _ NIL; FOR i: NAT IN [0..nBits) DO IF pattern[i] # x THEN { sCnt _ sCnt+1; isSome _ pattern[i] = zero; }; ENDLOOP; ioWire _ CDRects.CreateRect[size: [x: 19*lambda, y: lambda/2], l: comment]; mainGate _ CDGenerate.FetchNCall[directory, design, outGates[isSome]]; [] _ CDCells.IncludeOb[mode: dontResize, cell: ob, ob: mainGate, trans: CDOps.FitObjectI[mainGate, [x: (19+16)*lambda, y: yBase+6*lambda]]]; wInst _ CDCells.IncludeOb[mode: dontResize, cell: ob, ob: ioWire, trans: [[x: (19+16+40)*lambda, y: yBase+90*lambda]]].newInst; text _ CDTexts.Create[ text: IO.PutFR["%s%s", IO.rope[IF isSome THEN "Some" ELSE "No"], IO.rope[PatternToRope[pattern]]], font: font, layer: comment, flip: TRUE]; tInst _ CDCells.IncludeOb[mode: dontResize, cell: ob, ob: text, trans: CDOps.FitObjectI[text, [x: (19+16+40+3)*lambda, y: yBase+90*lambda]]].newInst; CDSatellites.Associate[wInst, tInst]; gateName _ inGates[isSome][sCnt]; inGate _ CDGenerate.FetchNCall[IF gateName.Fetch[0]='* THEN directory ELSE imports, design, IF gateName.Fetch[0]='* THEN gateName.Substr[1] ELSE gateName]; FOR input: NAT IN [0..8) DO gateInput: NAT _ 0; yPos: INT _ yBase+input*13*lambda; [] _ CDCells.IncludeOb[mode: dontResize, cell: ob, ob: inGate, trans: CDOps.FitObjectI[inGate, [x: 19*lambda, y: yPos]]]; FOR bit: NAT IN [0..nBits) DO IF pattern[bit] # x THEN { inWireY: INT _ yPos+(gateInpPos[sCnt].base+gateInput*gateInpPos[sCnt].delta)*lambda; wInst _ CDCells.IncludeOb[mode: dontResize, cell: ob, ob: ioWire, trans: CDOps.FitObjectI[ioWire, [x: 0, y: inWireY]]].newInst; text _ CDTexts.Create[ text: IO.PutFR["%sIn[%d][%d]", IO.rope[IF XOR[sCnt=1, XOR[isSome, (pattern[bit] = one)]] THEN "" ELSE "n"], IO.int[input], IO.int[bit]], font: font, layer: comment, flip: TRUE]; tInst _ CDCells.IncludeOb[mode: dontResize, cell: ob, ob: text, trans: CDOps.FitObjectI[text, [x: 0, y: inWireY]]].newInst; CDSatellites.Associate[wInst, tInst]; gateInput _ gateInput+1; }; ENDLOOP; ENDLOOP; yBase _ yBase+cellSizeY; END; PatternToRope: PROC [p: Pattern] RETURNS [r: Rope.ROPE] = BEGIN r _ NIL; FOR i: NAT IN [0..nBits) DO r _ r.Cat[(SELECT p[i] FROM zero => "0", one => "1", x => "x", ENDCASE => ERROR)]; ENDLOOP; END; p: Pattern; twoToThe: ARRAY [0..5) OF INT _ [1, 2, 4, 8, 16]; IF design.technology#tech THEN ERROR; ob _ CDCells.CreateEmptyCell[]; FOR ls: NAT IN [0..nBits) DO -- position of last significant digit (0 or 1) delta: NAT = twoToThe[(nBits-1)-ls]; FOR i: NAT _ 0, i+delta WHILE i+delta < twoToThe[nBits] DO FOR j: NAT IN [0..nBits) DO p[j] _ (SELECT (i/twoToThe[nBits-1-j]) MOD 2 FROM 0 => IF j <= ls THEN zero ELSE x, 1 => IF j = ls THEN one ELSE x, ENDCASE => ERROR); ENDLOOP; AddToTermCell[p]; ENDLOOP; ENDLOOP; [] _ CDCells.ResizeCell[design, ob]; END; table: CDGenerate.Context _ CDGenerate.AssertContext["USER"]; directory: CDGenerate.Context _ CDGenerate.AssertContext["DIRECTORY"]; imports: CDGenerate.Context _ CDGenerate.AssertContext["IMPORT"]; [] _ table.Register["PETerms", PETerms]; END. 8ArbPEGen.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. E. McCreight, February 11, 1987 5:15:01 pm PST Last edited by: Christian Jacobi, January 9, 1987 5:08:31 pm PST .. if sCnt=1 then optimize out a level of inverting gate The useful patterns are Some{0|x}*0{x}* No{0|x}*0{0|x}*1{x}* Êq˜šœ ™ Icodešœ Ïmœ1™Jšœžœ˜#——šÏnœžœž˜šžœ/žœ˜9Jšœ"˜"—Jšœ˜—Jšž˜Jšœžœžœ˜1Jšœ žœ žœ*˜@J˜WJšœžœ˜Jšœ žœ˜J˜šŸœ˜#Jšž˜Jšœžœ˜JšœE˜EJšœ žœžœžœ˜%Jšœžœ˜Jš œ žœžœÏc œžœžœ˜Ešœ žœžœ  œžœžœžœžœ˜AJšœŽ˜Ž—š œ žœžœžœžœ˜7J˜—J˜š žœžœ žœžœžœ˜/Jš œžœžœžœžœžœ˜#Jšœ˜J˜—šŸ œžœ˜(Jšž˜Jšœ žœ˜*Jšœžœ ˜Jšœžœ˜ Jšœžœ˜Jšœžœžœ˜J˜šžœžœžœ ž˜šžœžœ˜J˜J˜J˜—Jšžœ˜J˜—J˜KJ˜šœF˜FJšœ8™8—JšœŒ˜ŒJšœ˜šœ˜Jšœžœ˜Jš žœžœžœžœžœ˜KJšœ"žœ˜(—Jšœ•˜•Jšœ%˜%J˜Jšœ!˜!Jš œžœžœ žœžœžœžœ ˜›šžœžœžœž˜Jšœ žœ˜Jšœžœ˜"Jšœy˜yšžœžœžœ ž˜šžœžœ˜Jšœ žœH˜TJšœ˜šœ˜Jšœžœ˜Jšžœžœžœ žœ žœžœžœ žœ ˜iJšœ"žœ˜(—Jšœ{˜{Jšœ%˜%Jšœ˜Jšœ˜—Jšžœ˜—Jšžœ˜—J˜Jšœ˜Jšžœ˜J˜—šŸ œžœžœ žœ˜9Jšž˜Jšœžœ˜šžœžœžœ ž˜šœ žœž˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšžœžœ˜—Jšžœ˜—Jšžœ˜J˜—J˜ Jšœ žœžœžœ˜1J˜šœ™Jšœ™Jšœ™J™—Jšžœžœžœ˜%J˜J˜š žœžœžœ žœ .˜KJšœžœ˜$šžœžœžœž˜:šžœžœžœ ž˜šœžœžœž˜1Jšœžœ žœžœ˜!Jšœžœžœžœ˜Jšžœžœ˜—Jšžœ˜Jšœ˜—Jšžœ˜—Jšžœ˜—Jšœ$˜$Jšžœ˜J˜—Jšœ=˜=JšœF˜FJšœA˜AJ˜(Jšžœ˜—…—Ò{