CMosWellDifImpl.mesa (part of ChipNDale)
Copyright © 1983, 1985 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:03:11 pm PDT
DIRECTORY
CD,
CDBasics,
CDBasicsInline,
CDRects,
CDIO,
CMos,
Rope,
TokenIO;
CMosWellDifImpl: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDBasicsInline, CDIO, CDRects, CMos, TokenIO
SHARES CDRects =
BEGIN
wellSurround: CD.Number = CMos.wellSurround;
wpdifClass: CD.ObjectClass = CD.RegisterObjectClass[$CMosPDifRect, [
drawMe: DrawWellPDiffRect,
interestRect: InsideWellDiffRect,
showMeSelected: ShowSelectedWellDiffRect,
internalRead: CDRects.bareRectClass.internalRead,
internalWrite: WriteWellDif,
wireTyped: TRUE,
description: "w-pdif",
technology: CMos.cmos
]];
wndifClass: CD.ObjectClass = CD.RegisterObjectClass[$CMosNDifRect, [
drawMe: DrawWellNDiffRect,
interestRect: InsideWellDiffRect,
showMeSelected: ShowSelectedWellDiffRect,
internalRead: CDRects.bareRectClass.internalRead,
internalWrite: WriteWellDif,
wireTyped: TRUE,
description: "w-ndif",
technology: CMos.cmos
]];
dummySpecific: REF WellRectRep = NEW[WellRectRep];
WellRectRep: TYPE = RECORD [i: INT𡤀];
NewWellDif: PROC [] RETURNS [CD.Object] = {
ob: CD.Object ← NEW[CD.ObjectRep ← [class: wpdifClass]];
ob.specific ← dummySpecific;
RETURN [ob]
};
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: CD.DrawProc = {
pr.drawOutLine[pr, CDBasics.Extend[CDBasics.MapRect[ob.bbox, trans], -(wellSurround)], CD.selectionLayer]
};
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=CMos.wpdif THEN ob.class ← wpdifClass
ELSE IF l=CMos.wndif THEN ob.class ← wndifClass
ELSE { --actally error, but try to correct
IF l=CMos.ndif THEN {l ← CMos.wndif; ob.class ← wndifClass}
ELSE IF l=CMos.pdif THEN {l ← CMos.wpdif; ob.class ← wpdifClass}
ELSE ERROR
};
ob.bbox ← [x1: -wellSurround, y1: -wellSurround, x2: size.x+wellSurround, y2: size.y+wellSurround];
ob.layer ← l;
};
DrawWellPDiffRect: CD.DrawProc = {
r: CD.Rect = CDBasicsInline.MapRect[ob.bbox, trans];
pr.drawRect[pr, CDBasics.Extend[r, -wellSurround], CMos.pdif];
pr.drawRect[pr, r, CMos.nwell];
};
DrawWellNDiffRect: CD.DrawProc = {
r: CD.Rect = CDBasicsInline.MapRect[ob.bbox, trans];
pr.drawRect[pr, CDBasics.Extend[r, -wellSurround], CMos.ndif];
pr.drawRect[pr, r, CMos.pwell];
};
CDRects.UseAsCreateRect[CMos.wpdif, CreateWellDiffRect, wpdifClass];
CDRects.UseAsCreateRect[CMos.wndif, CreateWellDiffRect, wndifClass];
END.