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, October 16, 1985 12:15:45 pm PDT
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: REF CD.ObjectClass = CD.RegisterObjectClass[$C2PDifRect, CMosB.cmosB];
wndifClass: REF CD.ObjectClass = CD.RegisterObjectClass[$C2NDifRect, 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)], 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;
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[CMosB.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[CMosB.wndif, CreateWellDiffRect, wndifClass];
END;
Init[];
END.