DIRECTORY CD, CDBasics, CDCells, CDCommandOps, CDDirectory, CDRects, CDOps, CDSequencer, IO, TerminalIO; CountsImpl: CEDAR PROGRAM IMPORTS CD, CDCells, CDCommandOps, CDDirectory, CDOps, CDRects, IO, TerminalIO SHARES CDCells, CDRects = BEGIN ToCell: PROC [obj: CD.Object, comm: CDSequencer.Command] RETURNS [cell: CD.Object] ~ { ob: CD.Object _ obj; IF obj.class.composed THEN { WHILE ob#NIL AND ~CDCells.IsCell[ob] DO ob _ CDDirectory.ExpandRecursed[ob, comm.design, comm.design]; IF ob=obj THEN ob _ NIL; --to exit loop ENDLOOP; }; cell _ ob}; CountWithEnum: PROC [instance: CD.Instance, comm: CDSequencer.Command] ~ { rectangles, wellRectangles, atomicObjects: INT _ 0; EachInst: CDCells.InstEnumerator ~ { CountRects[inst.ob] }; CountRects: PROC [obj: CD.Object] ~ { class: CD.ObjectClass _ obj.class; IF class = CDRects.bareRectClass THEN rectangles _ rectangles + 1 ELSE IF class = CDRects.wellRectClass THEN wellRectangles _ wellRectangles + 1 ELSE IF class.atomicOb THEN atomicObjects _ atomicObjects + 1 ELSE IF class.composed THEN [] _ CDCells.EnumerateInstances[ToCell[obj, comm], EachInst]; }; CountRects[instance.ob]; TerminalIO.PutF1["well rectangles = %g\n", IO.int[wellRectangles]]; TerminalIO.PutF1["rectangles = %g\n", IO.int[rectangles]]; TerminalIO.PutF1["atomic objects (transistors or vias) = %g\n", IO.int[atomicObjects]]; }; CountCommWithEnum: PROC [comm: CDSequencer.Command] = { instance: CD.Instance _ CDOps.TheInstance[comm.design, "count rectangles using enumeration\n"]; IF instance#NIL THEN { CountWithEnum[instance, comm]; TerminalIO.PutRope["--done\n"] }; }; MyDrawChild: CD.DrawProc = { objectCount _ objectCount+1; CD.DrawOb[ob: ob, trans: trans, pr: pr, readOnlyInstProps: readOnlyInstProps]; }; MyDrawRect: CD.DrawRectProc = { rectangleCount _ rectangleCount+1; }; rectangleCount, objectCount: INT; CountWithDraw: PROC [instance: CD.Instance, comm: CDSequencer.Command] ~ { myDrawRef: CD.DrawRef _ CD.CreateDrawRef[[ interestClip: CDBasics.universe, drawChild: MyDrawChild, drawRect: MyDrawRect, design: comm.design ]]; rectangleCount _ objectCount _ 0; CD.DrawOb[myDrawRef, instance.ob, instance.trans, instance.properties]; myDrawRef _ NIL; TerminalIO.PutF1["objects = %g\n", IO.int[objectCount]]; TerminalIO.PutF1["rectangles = %g\n", IO.int[rectangleCount]]; }; CountCommWithDraw: PROC [comm: CDSequencer.Command] = { instance: CD.Instance _ CDOps.TheInstance[comm.design, "count rectangles using draw mechanism\n"]; IF instance#NIL THEN { CountWithDraw[instance, comm]; TerminalIO.PutRope["--done\n"] }; }; CountCommProtected: PROC [comm: CDSequencer.Command] = { [] _ CDCommandOps.DoWithResource[CountCommWithDraw, comm, $myDrawRef]; }; CDCommandOps.RegisterWithMenu[menu: $ProgramMenu, entry: "count rectangles (enum)", proc: CountCommWithEnum, key: $CDCountRectanglesWithEnum]; CDCommandOps.RegisterWithMenu[menu: $ProgramMenu, entry: "count rectangles (draw)", proc: CountCommProtected, key: $CDCountRectanglesWithDraw]; END. β CountsImpl.mesa (a ChipNDale module) Copyright Σ 1989 by Xerox Corporation. All rights reserved. Created by Preas May 19, 1989 5:08:19 pm PDT if object is composed, convert to a cell, else return object -- PROC [inst: CD.Instance] RETURNS [quit: BOOL_FALSE]; PROC [pr: CD.DrawRef, ob: CD.Object, trans: CD.Transformation_[], readOnlyInstProps: CD.PropList_NIL]; PROC [pr: CD.DrawRef, r: CD.Rect, l: CD.Layer]; Count rectangles and objects using ChnpnDale's draw mechnism ΚΕ™codešœ&™&Kšœ<™˜>KšœœœΟc˜'Kšœ˜—Kšœ˜—K˜ K˜—šž œœ œ)˜JKšœ+œ˜3K˜šžœ˜$KšŸ7™7Kšœ˜Kšœ˜K˜—šž œœœ ˜%Kšœœ˜"Kšœœ˜AKšœœœ$˜NKšœœœ!˜=šœœ˜Kšœ=˜=—K˜K˜—Kšœ˜Kšœ+œ˜CKšœ&œ˜:Kšœ@œ˜WK˜K˜—šžœœ ˜7Kšœ œS˜_šœ œœ˜Kšœ˜K˜K˜—K˜K˜—šΠbn œœ ˜Kšœf™fKšœ˜KšœM˜OKšœ˜K˜—š  œœ˜Kšœ/™/Kšœ"˜"Kšœ˜K˜—šœœ˜!K˜—šž œœ œ)˜JKšœ<™K˜K˜—šžœœ ˜7Kšœ œV˜bšœ œœ˜Kšœ˜K˜K˜—K˜K˜—šžœœ ˜8KšœF˜FKšœ˜K˜—KšœŽ˜ŽKšœ˜Kšœ˜K˜J˜—…— Ά]