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, August 16, 1986 6:09:08 pm PDT
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𡤀];
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.