SortAndPrint:
PROC [table: SymTab.Ref, area:
INT] ~ {
WHILE SymTab.GetSize[table]>0
DO
-- the laziest way to sort a few entries
largest: ROPE;
value: REF;
maxSize: INT ← 0;
SelectLargestItem: SymTab.EachPairAction ~ {
item: SizeRef ← NARROW[val];
name: ROPE ← NARROW[key];
IF item.totalArea > maxSize THEN {largest ← key; maxSize ← item.totalArea};
};
PrintItem:
PROC [name:
ROPE, item: SizeRef] ~ {
TerminalIO.PutF["%g %g => %5.1f%% of total area.\n", IO.int[item.nb], IO.rope[name], IO.real[100*REAL[item.totalArea]/area]];
};
[] ← SymTab.Pairs[table, SelectLargestItem];
value ← SymTab.Fetch[table, largest].val;
PrintItem[NARROW[largest], NARROW[value]];
[] ← SymTab.Delete[table, largest];
ENDLOOP;
};
HistogramIntProp:
PROC [cell: CellType, proc: GetAreaProc, table: SymTab.Ref]
RETURNS [area, nbCells:
INT ← 0] ~ {
key: ROPE;
[area, key] ← proc[cell]; -- total area
IF area#0
THEN {
ref: REF;
item: SizeRef;
found: BOOL;
[found, ref] ← SymTab.Fetch[table, key];
IF found
THEN {
item ← NARROW[ref];
item.totalArea ← item.totalArea+area;
item.nb ← item.nb+1}
ELSE item ← NEW[SizeRec ← [totalArea: area, nb: 1]];
[] ← SymTab.Store[table, key, item];
RETURN[area, 1];
};
SELECT
TRUE
FROM
cell.class=CoreClasses.recordCellClass => {
rct: CoreClasses.RecordCellType ← NARROW[cell.data];
FOR i:
NAT
IN [0..rct.size)
DO
subSize, subNb: INT ← 0;
[subSize, subNb] ← HistogramIntProp[rct[i].type, proc, table];
area ← area+subSize;
nbCells ← nbCells+subNb;
ENDLOOP;
};
cell.class.recast=NIL => RETURN[0, 0]; -- all other atomic classes are ignored
ENDCASE => RETURN HistogramIntProp[CoreOps.Recast[cell], proc, table]; -- recast
};
ExtractAndMeasure:
PROC [comm: CDSequencer.Command] = {
Lists the celltypes recognized as macros from Logic, with their arguments.
root, cellType: CellType;
leafTable: SymTab.Ref ← SymTab.Create[]; -- "xnor2" -> [totalArea, nb]
area, nbCells: INT ← 0;
macroTable: SymTab.Ref ← SymTab.Create[]; -- "MuxDN n=3 b=8" -> [totalArea, nb]
[root: root, cell: cellType] ← SinixOps.SelectedCellType[comm.design, Sisyph.mode];
IF root=NIL THEN RETURN; -- Extraction ended in error, message already printed
-- Statistics on leaf cells
-- The area of a standard cell is stored under the property $CellArea on the cellType;
-- The area is expressed in square CD units; currently, divide by 64 to be in square microns
TerminalIO.PutF["\nEstimating size of %g (excluding the routing):\n", IO.rope[CoreOps.GetCellTypeName[cellType]]];
[area, nbCells] ← HistogramIntProp[cellType, Leaf, leafTable];
TerminalIO.PutF["\nThe cell has %g placable elements\n", IO.int[nbCells]];
TerminalIO.PutF["Size is %g sq microns = %g sq mm.\n", IO.int[area/64], IO.real[REAL[area]/64000000]];
SortAndPrint[leafTable, area];
-- Celltypes recognized as macros from Logic, with their arguments.
TerminalIO.PutF["\nStatistics on %g:\n", IO.rope[CoreOps.GetCellTypeName[cellType]]];
[area, nbCells] ← HistogramIntProp[cellType, Macro, macroTable];
SortAndPrint[macroTable, area];
};