<> <> <> <> DIRECTORY CD, CDBasics, CDRects, CDIO, CDOrient, CMosB, Rope, TokenIO; CMosBWellDifImpl: CEDAR PROGRAM IMPORTS CD, CDBasics, CDIO, CDRects, CDOrient, CMosB, TokenIO SHARES CDRects = BEGIN lambda: CD.Number = CMosB.lambda; wellSurround: CD.Number = CMosB.wellSurround; wpdifClass: CD.ObjectClass = CD.RegisterObjectClass[$C2PDifRect, [ drawMe: DrawWellPDiffRect, interestRect: InsideWellDiffRect, showMeSelected: ShowSelectedWellDiffRect, internalRead: CDRects.bareRectClass.internalRead, internalWrite: WriteWellDif, wireTyped: TRUE, description: "w-pdif", technology: CMosB.cmosB ]]; wndifClass: CD.ObjectClass = CD.RegisterObjectClass[$C2NDifRect, [ drawMe: DrawWellNDiffRect, interestRect: InsideWellDiffRect, showMeSelected: ShowSelectedWellDiffRect, internalRead: CDRects.bareRectClass.internalRead, internalWrite: WriteWellDif, wireTyped: TRUE, description: "w-ndif", technology: CMosB.cmosB ]]; dummySpecific: REF WellRectRep = NEW[WellRectRep]; WellRectRep: TYPE = RECORD [i: INT_0]; WriteWellDif: CD.InternalWriteProc -- PROC [me: Object] -- = { TokenIO.WriteInt[me.size.x-2*wellSurround]; TokenIO.WriteInt[me.size.y-2*wellSurround]; CDIO.WriteLayer[me.layer]; }; InsideWellDiffRect: PROC [ob: CD.Object] RETURNS [CD.Rect] = { RETURN [CDBasics.Extend[CDBasics.RectAt[[0, 0], ob.size], -wellSurround]] }; ShowSelectedWellDiffRect: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef] = { pr.drawOutLine[CDBasics.Extend[CDOrient.RectAt[pos, inst.ob.size, orient], -(wellSurround)], CD.selectionLayer, pr] }; CreateWellDiffRect: PROC [size: CD.Position, l: CD.Layer] RETURNS [ob: CD.Object] = { <<--we do not lru cache; CDRects caching is good enough>> ob _ NEW[CD.ObjectRep _ [class: wpdifClass, specificRef: dummySpecific]]; IF l=CMosB.wpdif THEN ob.class _ wpdifClass ELSE IF l=CMosB.wndif THEN ob.class _ wndifClass ELSE { --actally error, but try to correct IF l=CMosB.ndif THEN {l _ CMosB.wndif; ob.class _ wndifClass} ELSE IF l=CMosB.pdif THEN {l _ CMosB.wpdif; ob.class _ wpdifClass} ELSE ERROR }; ob.size _ CDBasics.AddSize[ [2*wellSurround, 2*wellSurround], CDBasics.MaxPoint[size, [1, 1]]]; ob.layer _ l; }; DrawWellPDiffRect: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef] = { r: CD.Rect = CDOrient.RectAt[pos, inst.ob.size, orient]; inr: CD.Rect = CDBasics.Extend[r, -wellSurround]; pr.drawRect[inr, CMosB.pdif, pr]; pr.drawRect[r, CMosB.nwell, pr]; }; DrawWellNDiffRect: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef] = { r: CD.Rect = CDOrient.RectAt[pos, inst.ob.size, orient]; inr: CD.Rect = CDBasics.Extend[r, -wellSurround]; pr.drawRect[inr, CMosB.ndif, pr]; pr.drawRect[r, CMosB.pwell, pr]; }; CDRects.UseAsCreateRect[CMosB.wpdif, CreateWellDiffRect, wpdifClass]; CDRects.UseAsCreateRect[CMosB.wndif, CreateWellDiffRect, wndifClass]; END.