CoreHacks.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
written by Ch. Louis Monier October 25, 1988 2:25:01 pm PDT
DIRECTORY
CDCommandOps, CDSequencer, CoreCDUser, CoreClasses, CoreCreate, CoreOps, IO, TerminalIO;
CoreHacks: CEDAR PROGRAM    
IMPORTS
CDCommandOps, CoreOps, CoreCDUser, CoreClasses, IO, TerminalIO
= BEGIN OPEN CoreCreate;
Statistics
hackMenu: ATOM ← $SpecialMenu; -- where DAUserHacks commands are forcefully registered
Count: PROC [cellType: CellType] RETURNS [nb: INT ← 0] ~ {
data: CoreClasses.RecordCellType;
cellType ← CoreOps.ToBasic[cellType]; -- think about this!!!
SELECT cellType.class FROM
CoreClasses.recordCellClass => {
data ← NARROW[cellType.data];
FOR i: NAT IN [0..data.size) DO
nb ← nb+Count[data.instances[i].type];
ENDLOOP;
};
CoreClasses.transistorCellClass => RETURN [1];
ENDCASE => ERROR;
};
ExtractAndMeasure: PROC [comm: CDSequencer.Command] = {
Measure: CoreCDUser.EachRootCellTypeProc ~ {
TerminalIO.PutF["\nEstimating transistors count\n"];
TerminalIO.PutF["%g transistors\n", IO.int[Count[root]]];
};
[] ← CoreCDUser.EnumerateSelectedCellTypes[comm.design, Measure];
};
Init
CDCommandOps.RegisterWithMenu[hackMenu, "Count transistors", "Estimate number of transistors", $ExtractAndMeasure, ExtractAndMeasure];
END.