CMosBWellDifImpl.mesa (part of ChipNDale)
Copyright © 1983, 1985, 1986 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, September 10, 1983 9:34 pm
Last Edited by: Christian Jacobi, October 17, 1986 2:00:20 pm PDT
DIRECTORY
CD,
CDBasics,
CDBasicsInline,
CDRects,
CDIO,
CMosB,
Rope,
TokenIO;
CMosBWellDifImpl: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDBasicsInline, CDIO, CDRects, CMosB, TokenIO
SHARES CDRects =
BEGIN
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𡤀];
WriteWellDif: CD.InternalWriteProc = {
sz: CD.Position ← CDBasics.SizeOfRect[ob.bbox];
TokenIO.WriteInt[h, sz.x-2*wellSurround];
TokenIO.WriteInt[h, sz.y-2*wellSurround];
CDIO.WriteLayer[h, ob.layer];
};
InsideWellDiffRect: PROC [ob: CD.Object] RETURNS [CD.Rect] = {
RETURN [CDBasics.Extend[ob.bbox, -wellSurround]]
};
ShowSelectedWellDiffRect: PROC [inst: CD.Instance, trans: CD.Transformation, pr: CD.DrawRef] = {
pr.drawOutLine[CDBasics.Extend[CDBasics.MapRect[inst.ob.bbox, trans], -(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
size ← CDBasics.MaxPoint[size, [1, 1]];
ob ← NEW[CD.ObjectRep ← [class: wpdifClass, specific: 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.bbox ← [x1: -wellSurround, y1: -wellSurround, x2: size.x+wellSurround, y2: size.y+wellSurround];
ob.layer ← l;
};
DrawWellPDiffRect: PROC [inst: CD.Instance, trans: CD.Transformation, pr: CD.DrawRef] = {
r: CD.Rect = CDBasicsInline.MapRect[inst.ob.bbox, trans];
pr.drawRect[CDBasics.Extend[r, -wellSurround], CMosB.pdif, pr];
pr.drawRect[r, CMosB.nwell, pr];
};
DrawWellNDiffRect: PROC [inst: CD.Instance, trans: CD.Transformation, pr: CD.DrawRef] = {
r: CD.Rect = CDBasicsInline.MapRect[inst.ob.bbox, trans];
pr.drawRect[CDBasics.Extend[r, -wellSurround], CMosB.ndif, pr];
pr.drawRect[r, CMosB.pwell, pr];
};
CDRects.UseAsCreateRect[CMosB.wpdif, CreateWellDiffRect, wpdifClass];
CDRects.UseAsCreateRect[CMosB.wndif, CreateWellDiffRect, wndifClass];
END.