CMosWellDifImpl.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, September 19, 1985 2:52:56 pm PDT
DIRECTORY
CD,
CDBasics,
CDRects,
CDIO,
CDLRUCache,
CDOrient,
CMos,
Rope,
TokenIO;
CMosWellDifImpl: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDIO, CDLRUCache, CDRects, CDOrient, CMos, TokenIO =
BEGIN
lambda: CD.Number = CMos.lambda;
wellSurround: CD.Number = CMos.wellSurround;
wpdifClass: REF CD.ObjectClass = CD.RegisterObjectClass[$CMosPDifRect, CMos.cmos];
wndifClass: REF CD.ObjectClass = CD.RegisterObjectClass[$CMosNDifRect, CMos.cmos];
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)], pr]
END;
CreateWellDiffRect: PROC [size: CD.Position, l: CD.Layer] RETURNS [CD.Object] =
BEGIN
ob: CD.Object = cache.UnusedOrNew[];
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.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, CMos.pdif, pr];
pr.drawRect[r, CMos.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, CMos.ndif, pr];
pr.drawRect[r, CMos.pwell, pr];
END;
Init: PROC [] =
BEGIN
--p-diffusion
wpdifClass.drawMe ← DrawWellPDiffRect;
wpdifClass.interestRect ← wpdifClass.oldInsideRect ← InsideWellDiffRect;
wpdifClass.showMeSelected ← ShowSelectedWellDiffRect;
wpdifClass.internalRead ← ReadWellDif;
wpdifClass.internalWrite ← WriteWellDif;
wpdifClass.wireTyped ← TRUE;
wpdifClass.description ← "w-pdif";
CDRects.UseAsCreateRect[CMos.wpdif, CreateWellDiffRect, wpdifClass];
--n-diffusion
wndifClass.drawMe ← DrawWellNDiffRect;
wndifClass.interestRect ← wpdifClass.oldInsideRect ← InsideWellDiffRect;
wndifClass.showMeSelected ← ShowSelectedWellDiffRect;
wndifClass.internalRead ← ReadWellDif;
wndifClass.internalWrite ← WriteWellDif;
wndifClass.wireTyped ← TRUE;
wndifClass.description ← "w-ndif";
CDRects.UseAsCreateRect[CMos.wndif, CreateWellDiffRect, wndifClass];
END;
Init[];
END.