CountCapa:
PROC [wire: Core.Wire]
RETURNS [capa: pfs ← 0]~ {
AddValue:
PROC [ia: IndexArray, index:
INTEGER, value:
INT] ~ {
iseq: CARDINAL ← ABS[value MOD 8192]/8;
elem: BiINT ← [index: index, value: value];
ia[iseq] ← CONS[elem, ia[iseq]];
};
IndexOfVal:
PROC [ia: IndexArray, value:
INT]
RETURNS [index:
INTEGER] ~ {
iseq: CARDINAL ← ABS[value MOD 8192]/8;
FOR ib:
LIST
OF BiINT ← ia[iseq], ib.rest
DO
IF value = ib.first.value THEN RETURN[ib.first.index];
ENDLOOP;
};
AddInAxis:
PROC [axis: Axis, n:
INT] ~ {
ibuff: LIST OF INT;
IF axis.axisList=
NIL
THEN {
axis.axisList ← LIST[n];
axis.nStep ← 1;
RETURN
};
FOR i:
LIST
OF
INT ← axis.axisList, i.rest
WHILE i#
NIL
DO
IF i.first = n THEN RETURN;
IF i.first > n
THEN {
i.rest ← CONS[i.first, i.rest];
i.first ← n;
axis.nStep ← axis.nStep + 1;
RETURN;
};
ibuff ← i;
ENDLOOP;
ibuff.rest ← CONS[n, ibuff.rest];
axis.nStep ← axis.nStep + 1;
};
IndexInList:
PROC [list:
LIST
OF
INT, array: IndexArray, gridScale: GridScale] ~ {
index: INT ← 0;
prevNum: INT ← list.first;
AddValue[array, index, list.first];
FOR ilist:
LIST
OF
INT ← list.rest, ilist.rest
WHILE ilist#
NIL
DO
gridScale[index] ← ilist.first - prevNum;
index ← index + 1;
AddValue[array, index, ilist.first];
prevNum ← ilist.first;
ENDLOOP;
};
PackedBitMap:
PROC [eqp:
LIST
OF IntermediateRect, ix: IndexArray, iy: IndexArray, xAxis: Axis, yAxis: Axis]
RETURNS [capa: pfs ← 0] ~ {
Square: TYPE = PACKED ARRAY [0..myCDLayerLimit) OF BOOLEAN ;
Column: TYPE = RECORD [SEQUENCE cmax: INTEGER OF Square];
Row: TYPE = RECORD [SEQUENCE rmax: INTEGER OF REF Column];
BitMap: TYPE = REF Row;
truthTable: ARRAY [0..myCDLayerLimit) OF BOOLEAN ← ALL[FALSE];
xGridScale: GridScale ← NEW[GridScaleRep[xAxis.nStep]];
yGridScale: GridScale ← NEW[GridScaleRep[yAxis.nStep]];
bitMap: BitMap ← NEW[Row[xAxis.nStep]];
thisLayer: INTEGER;
IF eqp = NIL THEN RETURN[0];
FOR iRow:
INTEGER
IN [0..xAxis.nStep)
DO
bitMap[iRow] ← NEW[Column[yAxis.nStep]];
FOR iColumn:
INTEGER
IN [0..yAxis.nStep)
DO
bitMap[iRow][iColumn] ← ALL[FALSE];
ENDLOOP;
ENDLOOP;
IndexInList[xAxis.axisList, ix, xGridScale];
IndexInList[yAxis.axisList, iy, yGridScale];
FOR ecurrent:
LIST
OF IntermediateRect ← eqp, ecurrent.rest
WHILE ecurrent#
NIL
DO
thisLayer ← myCDLayerNumber[ecurrent.first.layer];
truthTable[thisLayer] ← TRUE;
FOR x:
INTEGER
IN [IndexOfVal[ix, ecurrent.first.rect.x1]..IndexOfVal[ix, ecurrent.first.rect.x2])
DO
FOR y:
INTEGER
IN [IndexOfVal[iy, ecurrent.first.rect.y1]..IndexOfVal[iy, ecurrent.first.rect.y2])
DO
bitMap[x][y][thisLayer] ← TRUE;
ENDLOOP;
ENDLOOP;
ENDLOOP;
FOR ilayer:
CD.Layer
IN [0..myCDLayerLimit)
DO
IF truthTable[ilayer]
THEN {
FOR x:
INTEGER
IN [0..xAxis.nStep)
DO
FOR y:
INTEGER
IN [0..yAxis.nStep)
DO
IF bitMap[x][y][ilayer]
THEN
capa ← capa + xGridScale[x]*yGridScale[y]*layerCapa[ilayer];
ENDLOOP;
ENDLOOP;
}
ENDLOOP;
};
IndexArray: TYPE = REF IndexArrayRep;
IndexArrayRep: TYPE = ARRAY CARDINAL [0..1024) OF ListInt;
ListInt: TYPE = LIST OF BiINT;
BiINT: TYPE = RECORD[index: INTEGER, value: INT];
IntermediateRect: TYPE = RECORD[rect: CD.Rect, layer: CD.Layer];
GridScale: TYPE = REF GridScaleRep;
GridScaleRep: TYPE = RECORD [SEQUENCE gmax: INTEGER OF INT];
GridStep: TYPE = CD.Number;
Axis: TYPE = REF AxisRep;
AxisRep: TYPE = RECORD [nStep: INTEGER ← 0, axisList: LIST OF GridStep ← NIL];
equipot: LIST OF IntermediateRect ← NIL;
iRect: IntermediateRect;
xAxis: Axis ← NEW[AxisRep];
yAxis: Axis ← NEW[AxisRep];
ix: IndexArray ← NEW[IndexArrayRep ← ALL[NIL]];
iy: IndexArray ← NEW[IndexArrayRep ← ALL[NIL]];
instances: LIST OF CD.Instance ← CoreGeometry.GetGeometry[tech.decoration ,wire];
IF instances = NIL THEN RETURN;
FOR iList:
LIST
OF
CD.Instance ← instances, iList.rest
WHILE iList#
NIL
DO
instance: CD.Instance ← iList.first;
SELECT
TRUE
FROM
instance.ob.class=CDRects.bareRectClass => {
rec: CD.Rect ← CDInstances.InstRectI[instance];
AddInAxis[xAxis, rec.x1];
AddInAxis[xAxis, rec.x2];
AddInAxis[yAxis, rec.y1];
AddInAxis[yAxis, rec.y2];
iRect ← [rect: rec, layer: instance.ob.layer];
equipot ← CONS[iRect, equipot];
};
CDSymbolicObjects.IsSymbolicOb[instance.ob] => NULL;
ENDCASE => {
FOR rList: CDAtomicObjects.DrawList ← CoreGeometry.FlattenAtomic[instance.ob], rList.rest
WHILE rList#
NIL
DO
AddInAxis[xAxis, rList.first.r.x1];
AddInAxis[xAxis, rList.first.r.x2];
AddInAxis[yAxis, rList.first.r.y1];
AddInAxis[yAxis, rList.first.r.y2];
iRect ← [rect: rList.first.r, layer: rList.first.lev];
equipot ← CONS[iRect, equipot];
ENDLOOP;
};
ENDLOOP;
capa ← PackedBitMap[equipot, ix, iy, xAxis, yAxis];
RETURN[capa];
}; -- CountCapa