TransCountImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Bruce Wagar, August 18, 1987 11:19:48 pm PDT
Implementation of the transistor count program.
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
Command Proc
ExtractAndCount:
PROC[command: CDSequencer.Command] = {
Extracts selected object(s) and counts the number of transistors in them.
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]]
};
Main Routine
TransistorCount:
PUBLIC
PROC [cell: CellType]
RETURNS [
INT ← 0] = {
Performs a depth-first recursive count of the number of transistors in cell.
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]]];
};
Initialization
CDCommandOps.RegisterWithMenu[
menu: $OtherProgramMenu,
entry: "Extract and Count Transistors",
doc: "counts the number of transistors in selected object(s)",
proc: ExtractAndCount,
key: $ExtractAndCount];
END.