CMosBWellDifImpl.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, September 10, 1983 9:34 pm
last edited Christian Jacobi, March 25, 1986 2:20:13 pm PST
DIRECTORY
CD,
CDBasics,
CDRects,
CDIO,
CDLRUCache,
CDOrient,
CMosB,
Rope,
TokenIO;
CMosBWellDifImpl:
CEDAR
PROGRAM
IMPORTS CD, CDBasics, CDIO, CDLRUCache, CDRects, CDOrient, CMosB, TokenIO =
BEGIN
lambda: CD.Number = CMosB.lambda;
wellSurround: CD.Number = CMosB.wellSurround;
wpdifClass:
CD.ObjectClass =
CD.RegisterObjectClass[$C2PDifRect, [
drawMe: DrawWellPDiffRect,
interestRect: InsideWellDiffRect,
showMeSelected: ShowSelectedWellDiffRect,
internalRead: ReadWellDif,
internalWrite: WriteWellDif,
wireTyped: TRUE,
description: "w-pdif",
technology: CMosB.cmosB
]];
wndifClass:
CD.ObjectClass =
CD.RegisterObjectClass[$C2NDifRect, [
drawMe: DrawWellNDiffRect,
interestRect: InsideWellDiffRect,
showMeSelected: ShowSelectedWellDiffRect,
internalRead: ReadWellDif,
internalWrite: WriteWellDif,
wireTyped: TRUE,
description: "w-ndif",
technology: CMosB.cmosB
]];
cache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 30, newProc: NewWellDif];
dummySpecific:
REF WellRectRep =
NEW[WellRectRep];
WellRectRep: TYPE = RECORD [i: INT𡤀];
NewWellDif:
PROC []
RETURNS [
CD.Object] =
BEGIN
ob: CD.Object ← NEW[CD.ObjectRep ← [class: wpdifClass]];
ob.specificRef ← dummySpecific;
RETURN [ob]
END;
WriteWellDif:
CD.InternalWriteProc
-- PROC [me: Object] -- =
BEGIN
TokenIO.WriteInt[me.size.x-2*wellSurround];
TokenIO.WriteInt[me.size.y-2*wellSurround];
CDIO.WriteLayer[me.layer];
END;
ReadWellDif:
CD.InternalReadProc
--PROC [] RETURNS [Object]-- =
BEGIN
x: INT = TokenIO.ReadInt[];
y: INT = TokenIO.ReadInt[];
l: CD.Layer = CDIO.ReadLayer[];
ob: CD.Object = CreateWellDiffRect[[x, y], l];
RETURN [ob]
END;
InsideWellDiffRect:
PROC [ob:
CD.Object]
RETURNS [
CD.Rect] =
BEGIN
RETURN [CDBasics.Extend[CDBasics.RectAt[[0, 0], ob.size], -wellSurround]]
END;
ShowSelectedWellDiffRect:
PROC [inst:
CD.Instance, pos:
CD.Position,
orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
pr.drawOutLine[CDBasics.Extend[CDOrient.RectAt[pos, inst.ob.size, orient], -(wellSurround)], CD.selectionLayer, pr]
END;
CreateWellDiffRect:
PROC [size:
CD.Position, l:
CD.Layer]
RETURNS [
CD.Object] =
BEGIN
ob: CD.Object = cache.UnusedOrNew[];
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;
RETURN [cache.ReplaceByAequivalent[ob]]
END;
DrawWellPDiffRect:
PROC [inst:
CD.Instance, pos:
CD.Position, orient:
CD.Orientation,
pr: CD.DrawRef] =
BEGIN
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];
END;
DrawWellNDiffRect:
PROC [inst:
CD.Instance, pos:
CD.Position, orient:
CD.Orientation,
pr: CD.DrawRef] =
BEGIN
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];
END;
CDRects.UseAsCreateRect[CMosB.wpdif, CreateWellDiffRect, wpdifClass];
CDRects.UseAsCreateRect[CMosB.wndif, CreateWellDiffRect, wndifClass];
END.