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, March 25, 1986 4:31:40 pm PST
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:
CD.ObjectClass =
CD.RegisterObjectClass[$CMosPDifRect, [
drawMe: DrawWellPDiffRect,
interestRect: InsideWellDiffRect,
showMeSelected: ShowSelectedWellDiffRect,
internalRead: ReadWellDif,
internalWrite: WriteWellDif,
wireTyped: TRUE,
description: "w-pdif",
technology: CMos.cmos
]];
wndifClass:
CD.ObjectClass =
CD.RegisterObjectClass[$CMosNDifRect, [
drawMe: DrawWellNDiffRect,
interestRect: InsideWellDiffRect,
showMeSelected: ShowSelectedWellDiffRect,
internalRead: ReadWellDif,
internalWrite: WriteWellDif,
wireTyped: TRUE,
description: "w-ndif",
technology: 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)], CD.selectionLayer, 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;
CDRects.UseAsCreateRect[CMos.wpdif, CreateWellDiffRect, wpdifClass];
CDRects.UseAsCreateRect[CMos.wndif, CreateWellDiffRect, wndifClass];
END.