OnionCore.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet, February 10, 1986 9:30:28 pm PST
Bertrand Serlet, April 24, 1986 12:43:07 pm PST
Onion is a smill and (relatively) efficient PadRing router implemented from a paper by Smith, Saxe, Newkirk and Mathews (Stanford; CH1813-5, 1982 IEEE). This method is called Loop Routing Scheme (LRS).
DIRECTORY
CD, CMosB, HashTable, OnionCoreArc, Rope;
OnionCore: CEDAR DEFINITIONS IMPORTS CMosB =
BEGIN
Useful types
ROPE: TYPE = Rope.ROPE;
Side: TYPE = OnionCoreArc.Side;
Arc: TYPE = OnionCoreArc.Arc;
Seg: TYPE = OnionCoreArc.Seg;
Nets
Net: TYPE = REF NetRec;
NetRec: TYPE = RECORD [
name: ROPE,          -- must be filled by the user
width: INT ← 0,         -- 0 default means minimum size
routeEveryOuterSeg: BOOLTRUE,   -- FALSE if there is redundancy in outer pins
facing: BOOLFALSE,       -- already facing
chosen: BOOLFALSE,       -- chosen for being routed
eval: INT ← 0,          -- evaluation function
arc: Arc ← NIL,         -- arc used by this net
innerSegs, outerSegs, newInnerSegs: LIST OF Seg ← NIL  -- pins of the net, position is relative to the [0, 0] of the interest rect of the outer. newInnerPins is used internally (pins for the next iteration)
];
Onion ringing
IncludeInOuter: PROC [outer: CD.Object, nets: HashTable.Table, innerPos: CD.Position, innerSize, outerSize: CD.Position, radialLayer: CD.Layer ← CMosB.met, ringLayer: CD.Layer ← CMosB.met2] RETURNS [done: BOOL];
Nets is an association REF -> Net (REF can conveniently be a Core.Wire or a ROPE)
Just adds the onion rings in outer
The only fields that should be filled in nets are name, width, routeEveryOuterSeg, innerSegs and outerSegs. The nets table is modified in place, so watch out!
Center: PROC [inner, outer: CD.Object] RETURNS [innerPos: CD.Position];
Returns the innerPos needed for centering the inner in the outer. Usually that is what users want before refining by hand.
END.