<> <> <> <<>> <> <<>> DIRECTORY CD, CDCommandOps, CDOps, CDSequencer, CoreClasses, CoreOps, IO, Sinix, SinixOps, TerminalIO, TransCount; TransCountImpl: CEDAR PROGRAM IMPORTS CDCommandOps, CDOps, CoreClasses, CoreOps, IO, SinixOps, TerminalIO EXPORTS TransCount = BEGIN OPEN TransCount; <> ExtractAndCount: PROC[command: CDSequencer.Command] = { <> count: INT _ 0; design: CD.Design _ command.design; mode: Sinix.Mode _ SinixOps.GetExtractMode[tech: design.technology]; FOR insts: CD.InstanceList _ CDOps.InstList[design: design], insts.rest UNTIL insts = NIL DO IF insts.first.selected THEN { ref: REF _ SinixOps.ExtractCDInstance[instance: insts.first, design: design, mode: mode].result; IF ISTYPE[ref, CellType] THEN count _ count + TransistorCount[cell: NARROW[ref]] } ENDLOOP; TerminalIO.PutF1[format: "There are %g transistors in the selected objects.\n", value: IO.int[count]] }; <
> TransistorCount: PUBLIC PROC [cell: CellType] RETURNS [INT _ 0] = { <> SELECT cell.class FROM CoreClasses.transistorCellClass => RETURN [1]; CoreClasses.unspecifiedCellClass => RETURN; CoreClasses.recordCellClass => { count: INT _ 0; instances: CoreClasses.RecordCellType _ NARROW[cell.data]; FOR i: INT IN [0..instances.size) DO count _ count + TransistorCount[cell: instances[i].type] ENDLOOP; RETURN [count] } ENDCASE => RETURN[TransistorCount[cell: CoreOps.Recast[me: cell]]]; }; <> CDCommandOps.RegisterWithMenu[ menu: $OtherProgramMenu, entry: "Extract and Count Transistors", doc: "counts the number of transistors in selected object(s)", proc: ExtractAndCount, key: $ExtractAndCount]; END.