-- WireLengthAnalysis.mesa
-- Last edited by McCreight, May 5, 1983 2:21 pm

DIRECTORY
 DoradoBoard,
IO USING [STREAM, Close, PutF, real, rope, CreateViewerStreams, SetIndex, PutChar],
PriorityQueue USING [Ref, SortPred, Create, Empty, Insert, Remove],
Real USING [Float, RoundLI, SqRt],
Rope USING [ROPE];

WireLengthAnalysis: --CEDAR-- PROGRAM
IMPORTS DoradoBoard, IO, PriorityQueue, Real
=

BEGIN OPEN DoradoBoard;

LengthRecRef: TYPE = REF LengthRec;
LengthRec: TYPE = RECORD[length: INT ← 0, canonPad: CARDINAL];

CompareLength: PriorityQueue.SortPred = TRUSTED
BEGIN
xl: LengthRecRef = NARROW[x];
yl: LengthRecRef = NARROW[y];
RETURN[xl.length>yl.length];
END;

IntSquare: PROC [x: INT] RETURNS [INT] = INLINE {RETURN[x*x]};

Distance: PROC [first, second: Point] RETURNS [distance: INT] =
INLINE {RETURN[IntSquare[second.x - first.x] + IntSquare[second.y - first.y]]};

Analyze: PROC [state: Board ← NIL] =
BEGIN
pq: PriorityQueue.Ref = PriorityQueue.Create[CompareLength];
s: IO.STREAMIO.CreateViewerStreams[name: "Net Length Analysis"].out;
IF state=NIL THEN state ← DoradoBoard.board;
FOR pad: CARDINAL IN [0..state.padCount) DO
netLength: LengthRecRef = NEW[LengthRec ← [canonPad: pad]];
IF state.pads[pad].segs#NIL THEN
BEGIN
segs: REF SegTab = state.pads[pad].segs;
s.PutChar['*];
FOR layer: WiringLayer IN WiringLayer DO
IF segs.l[layer]#0 THEN
BEGIN
segCount: CARDINAL;
state.asiFile.SetIndex[segs.l[layer]];
segCount ← GetCardinal[state];
   FOR i: CARDINAL IN [0 ..segCount) DO
    start: Point = GetPoint[state];
    end: Point = GetPoint[state];
    netLength.length ← netLength.length+Real.RoundLI[Real.SqRt[Distance[start, end]]];
    ENDLOOP;
END;
ENDLOOP;
pq.Insert[item: netLength];
END;
ENDLOOP;
-- empty out priority queue into text viewer
s.PutF["\n"];
WHILE NOT pq.Empty[] DO
netLength: LengthRecRef = NARROW[pq.Remove[]];
IF netLength.length>0 THEN
s.PutF[format: "%6g %s\n", v1: IO.real[Real.Float[netLength.length]/1000.],
v2: IO.rope[state.pads[netLength.canonPad].segs.sigName]];
ENDLOOP;

s.Close[];
END; -- of Analyze

END. -- of WireLengthAnalysis --


CHANGE LOG

Created by McCreight/Pier, May 5, 1983 11:48 am