CMosCMContactsImpl.mesa (part of ChipNDale)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
Christian Jacobi, June 24, 1983 5:03 pm
last edited Christian Jacobi, September 19, 1985 2:49:33 pm PDT
DIRECTORY
Atom,
CMosCMContacts,
CMosObjects,
CD,
CDBasics,
CDCallSpecific,
CDIO,
CDLRUCache,
CDOrient,
CDRects USING [CreateRect],
CDStretchyExtras,
CMos,
Rope,
TokenIO;
CMosCMContactsImpl: CEDAR PROGRAM
IMPORTS Atom, CD, CDBasics, CDCallSpecific, CDIO, CDLRUCache, CDOrient, CDStretchyExtras, CDRects, CMos, Rope, TokenIO, CMosObjects
EXPORTS CMosCMContacts =
BEGIN OPEN CMos;
lambda: CD.Number = CMos.lambda;
ContactType: TYPE = CMosCMContacts.ContactType;
ContactPtr: TYPE = CMosCMContacts.ContactPtr;
ContactRec: TYPE = CMosCMContacts.ContactRec;
undef: CD.Layer = CMosCMContacts.undef;
wellSurround: CD.Number = CMos.wellSurround;
difCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 5, aequivalenceProc: Aequivalent, newProc: NewCont];
polyCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 5, aequivalenceProc: Aequivalent, newProc: NewCont];
dsCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 5, aequivalenceProc: Aequivalent, newProc: NewCont];
butCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 5, aequivalenceProc: Aequivalent, newProc: NewCont];
burCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 5, aequivalenceProc: Aequivalent, newProc: NewCont];
mmCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 5, aequivalenceProc: Aequivalent, newProc: NewCont];
ToPosition: PROC [x: REF] RETURNS [class: CD.Position] =
--y field defaults to lambda, x field defaults to 0
--[0, 0] if not done
BEGIN
IF x=NIL THEN class ← [0, lambda]
ELSE WITH x SELECT FROM
rp: REF CD.Position => class ← rp^;
rn: REF CD.Number => class ← [0, rn^];
ENDCASE => class ← [0, 0];
END;
Aequivalent: PROC[mySpecific, other: REF ANY] RETURNS [BOOL] = {
WITH other SELECT FROM
p2: ContactPtr => RETURN [NARROW[mySpecific, ContactPtr]^=p2^];
ENDCASE => RETURN [FALSE]
};
NewCont: PROC [] RETURNS [CD.Object] = {
ob: CD.Object ← NEW[CD.ObjectRep];
ob.specificRef ← NEW[ContactRec];
RETURN [ob]
};
InsideRectWithSurround: PROC [ob: CD.Object] RETURNS [CD.Rect] =
BEGIN
RETURN [CDBasics.Extend[CDBasics.RectAt[[0, 0], ob.size], -wellSurround]]
END;
ShowSelectedWithSurround: 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;
MatchContact: PROC [me: CD.Object, r: CD.Rect, layer: CD.Layer, prim: BOOL, horz: BOOL] RETURNS [BOOL] =
BEGIN
-- Don't care about different diffusions and such
IF layer=me.layer THEN RETURN [TRUE]
ELSE {
cp: ContactPtr = NARROW[me.specificRef];
RETURN [
SELECT cp.typ FROM
burr => (layer=CMos.pol),
mDif => (layer=CMos.met),
difShort => FALSE,
butt => (layer=CMos.met OR layer=CMos.pol),
mPol => (layer=CMos.met),
mm2 => (layer=CMos.met2),
ENDCASE => FALSE
]
}
END;
-- Dif and Pol -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
pForDifPolCon: REF CD.ObjectClass = RegisterObjectClass[$CMosContactDifAndPol];
pForWellDifPolCon: REF CD.ObjectClass = RegisterObjectClass[$CMosContactWellDifAndPol];
difpolRimWidth: CD.Number = lambda;
CreateDifCon: PUBLIC PROC [l: CD.Number, difLev: CD.Layer] RETURNS [CD.Object] =
--connect diffusion with metal
BEGIN
cob: CD.Object ~ difCache.UnusedOrNew[];
cp: ContactPtr ~ NARROW[cob.specificRef];
IF difLev=undef THEN difLev←ndif;
IF l=butConSX THEN {
IF difLev=CMos.pdif THEN difLev ← CMos.wpdif;
IF difLev=CMos.pol THEN RETURN [CMosObjects.CreatePolyCon[]]
ELSE RETURN [CMosObjects.CreateDifCon[difLev]]
};
l ← MAX[l, butConSX];
cp.typ ← mDif;
cob.layer ← difLev;
IF difLev=CMos.pdif THEN {
cob.class ← pForWellDifPolCon;
cob.size ← [butConSX+2*wellSurround, l+2*wellSurround];
}
ELSE {
cob.class ← pForDifPolCon;
cob.size ← [butConSX, l];
};
RETURN [difCache.ReplaceByAequivalent[cob]]
END;
CreatePolyCon: PUBLIC PROC [l: CD.Number] RETURNS [CD.Object] =
--connect poly with metal
BEGIN
cob: CD.Object ~ polyCache.UnusedOrNew[];
cp: ContactPtr ~ NARROW[cob.specificRef];
IF l=butConSX THEN {
RETURN [CMosObjects.CreatePolyCon[]]
};
l ← MAX[l, butConSX];
cp.typ ← mPol;
cob.class ← pForDifPolCon;
cob.size ← [butConSX, l];
cob.layer ← pol;
RETURN [polyCache.ReplaceByAequivalent[cob]]
END;
LengthenPolyDif: CDCallSpecific.CallProc =
BEGIN
amount: CD.Position = ToPosition[x];
IF amount.y=0 OR amount.x#0 THEN done ← FALSE
ELSE {
new: CD.Object;
sur: INT = IF inst.ob.layer=CMos.pdif THEN 2*wellSurround ELSE 0;
cp: ContactPtr = NARROW[inst.ob.specificRef];
sz: CD.Position ← CDBasics.SubPoints[CDBasics.AddPoints[inst.ob.size, amount], [sur, sur]];
IF sz.x<=0 OR sz.y<=0 THEN {done ← FALSE; RETURN};
IF inst.ob.layer=pol THEN new ← CreatePolyCon[sz.y] ELSE new ← CreateDifCon[sz.y, inst.ob.layer];
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
repaintMe ← TRUE;
}
END;
DefaultenPolyDif: CDCallSpecific.CallProc =
BEGIN
new: CD.Object;
cp: ContactPtr = NARROW[inst.ob.specificRef];
IF inst.ob.layer=pol THEN new ← CreatePolyCon[4*lambda] ELSE new ← CreateDifCon[4*lambda, inst.ob.layer];
repaintMe ← TRUE;
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
END;
ReadDifPolCon: CD.InternalReadProc --PROC [] RETURNS [Object]-- =
BEGIN
lev: CD.Layer = CDIO.ReadLayer[];
IF lev=pol THEN RETURN [ CreatePolyCon[TokenIO.ReadInt[]] ]
ELSE RETURN [ CreateDifCon[TokenIO.ReadInt[], lev] ]
END;
WriteDifPolCon: CD.InternalWriteProc -- PROC [me: Object] -- =
BEGIN
sur: INT = IF me.layer=CMos.pdif THEN 2*wellSurround ELSE 0;
CDIO.WriteLayer[me.layer];
TokenIO.WriteInt[me.size.y-sur];
END;
DrawDifPolCon: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
r: CD.Rect = CDOrient.RectAt[pos, inst.ob.size, orient];
pr.drawRect[r, met, pr];
pr.drawRect[r, inst.ob.layer, pr];
pr.drawRect[CDBasics.Extend[r, -difpolRimWidth], cut, pr];
END;
DrawWellDifPolCon: 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, met, pr];
pr.drawRect[inr, inst.ob.layer, pr];
pr.drawRect[CDBasics.Extend[inr, -difpolRimWidth], cut, pr];
pr.drawRect[r, nwell, pr];
END;
-- DifShort -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
pForDifShorts: REF CD.ObjectClass = RegisterObjectClass[$CMosContactDifShort];
pForWellDifShorts: REF CD.ObjectClass = RegisterObjectClass[$CMosContactWellDifShort];
difShortRimWidth: CD.Number = lambda;
CreateDifShortCon: PUBLIC PROC [difLev: CD.Layer] RETURNS [CD.Object] =
BEGIN
IF difLev=CMos.pdif THEN difLev ← CMos.wpdif;
RETURN [CMosObjects.CreateDifShortCon[difLev]]
cob: CD.Object ~ dsCache.UnusedOrNew[];
cp: ContactPtr ~ NARROW[cob.specificRef];
IF difLev=undef THEN difLev ← ndif;
cp.typ ← difShort;
cob.layer ← difLev;
IF difLev=CMos.pdif THEN {
cob.class ← pForWellDifShorts;
cob.size ← [butConSX+2*wellSurround, 8*lambda+2*wellSurround]
}
ELSE IF difLev=CMos.ndif THEN {
cob.class ← pForDifShorts;
cob.size ← [butConSX, 8*lambda]
}
ELSE ERROR;
RETURN [dsCache.ReplaceByAequivalent[cob]]
END;
ReadDifShortCon: CD.InternalReadProc --PROC [] RETURNS [Object]-- =
BEGIN
RETURN [ CreateDifShortCon[CDIO.ReadLayer[]] ]
END;
WriteDifShortCon: CD.InternalWriteProc -- PROC [me: Object] -- =
BEGIN
CDIO.WriteLayer[me.layer];
END;
DrawDifShortContact: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
Draw: PROC[r: CD.Rect, l: CD.Layer] = INLINE
--uses outer stuff!!
BEGIN
pr.drawRect[
CDOrient.MapRect[
itemInCell: r,
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos],
l,
pr];
END;
r: CD.Rect = CDOrient.RectAt[[0, 0], inst.ob.size];
mr: CD.Rect = CDBasics.Extend[r, -difShortRimWidth];
h: CD.Number = (r.y2-r.y1)/2;
Draw[r, met];
Draw[[x1: r.x1, y1: r.y1, x2: r.x2, y2: r.y1+h], CMos.ndif];
Draw[[x1: r.x1, y1: r.y1+h, x2: r.x2, y2: r.y2], CMos.pwellCont];
Draw[[x1: mr.x1, x2: mr.x2, y1: mr.y1, y2: mr.y1+2*lambda], cut];
Draw[[x1: mr.x1, x2: mr.x2, y1: mr.y2-2*lambda, y2: mr.y2], cut];
END;
DrawWellDifShortContact: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
Draw: PROC[r: CD.Rect, l: CD.Layer] = INLINE
--uses outer stuff!!
BEGIN
pr.drawRect[
CDOrient.MapRect[
itemInCell: r,
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos],
l,
pr];
END;
r: CD.Rect = CDOrient.RectAt[[0, 0], inst.ob.size];
inr: CD.Rect = CDBasics.Extend[r, -wellSurround];
mr: CD.Rect = CDBasics.Extend[inr, -difShortRimWidth];
h: CD.Number = (inr.y2-inr.y1)/2;
Draw[inr, met];
Draw[[x1: inr.x1, y1: inr.y1, x2: inr.x2, y2: inr.y1+h], CMos.pdif];
Draw[[x1: inr.x1, y1: inr.y1+h, x2: inr.x2, y2: inr.y2], CMos.nwellCont];
Draw[[x1: mr.x1, x2: mr.x2, y1: mr.y1, y2: mr.y1+2*lambda], cut];
Draw[[x1: mr.x1, x2: mr.x2, y1: mr.y2-2*lambda, y2: mr.y2], cut];
Draw[[x1: r.x1, x2: r.x2, y1: r.y1, y2: r.y2-h], nwell];
END;
-- But -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
pForButContact: REF CD.ObjectClass = RegisterObjectClass[$CMosContactBut];
pForWellButContact: REF CD.ObjectClass = RegisterObjectClass[$CMosContactWellBut];
butContactPolyYS: CD.Number = 3*lambda;
butContactDiffY: CD.Number = butContactPolyYS-lambda;
butContactDiffYS: CD.Number = 4*lambda;
butConSX: CD.Number = 4*lambda;
butConSY: CD.Number = butContactDiffY+butContactDiffYS;
butContactRimWidth: CD.Number = lambda;
pButConInnerY: CD.Number = wellSurround-butContactDiffY;
pButConSX: CD.Number = butConSX+2*wellSurround;
pButConSY: CD.Number = pButConInnerY+butConSY+wellSurround;
pButConInner: CD.Rect = [
x1: wellSurround, x2: wellSurround+butConSX,
y1: pButConInnerY, y2: pButConInnerY+butConSY
];
CreateButCon: PUBLIC PROC [difLev: CD.Layer] RETURNS [CD.Object] =
--connects metal with poly and diffusion
BEGIN
IF difLev=CMos.pdif THEN difLev ← CMos.wpdif;
RETURN [CMosObjects.CreateButCon[difLev]]
cob: CD.Object ~ butCache.UnusedOrNew[];
cp: ContactPtr ~ NARROW[cob.specificRef];
cp.typ ← butt;
IF difLev=undef THEN difLev←ndif;
cob.layer ← difLev;
IF difLev=CMos.pdif THEN {
cob.class ← pForWellButContact;
cob.size ← [pButConSX, pButConSY];
}
ELSE {
cob.class ← pForButContact;
cob.size ← [butConSX, butConSY];
};
RETURN [butCache.ReplaceByAequivalent[cob]]
END;
ReadButCon: CD.InternalReadProc --PROC [] RETURNS [Object]-- =
BEGIN
RETURN [ CreateButCon[CDIO.ReadLayer[]] ]
END;
WriteButCon: CD.InternalWriteProc -- PROC [me: Object] -- =
BEGIN
CDIO.WriteLayer[me.layer];
END;
DrawButContact: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
Draw: PROC[r: CD.Rect, l: CD.Layer] = INLINE
--uses outer stuff!!
BEGIN
pr.drawRect[
CDOrient.MapRect[
itemInCell: r,
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos],
l,
pr];
END;
Draw[[0, 0, butConSX, butConSY], met];
Draw[[0, 0, butConSX, butContactPolyYS], pol];
Draw[[0, butContactDiffY, butConSX, butConSY], inst.ob.layer];
Draw[[butContactRimWidth, butContactRimWidth,
butConSX-butContactRimWidth, butConSY-butContactRimWidth], cut];
END;
DrawWellButContact: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
Draw: PROC[r: CD.Rect, l: CD.Layer] = INLINE
--uses outer stuff!!
BEGIN
pr.drawRect[
CDOrient.MapRect[
itemInCell: r,
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos],
l,
pr];
END;
inr: CD.Rect = [
x1: wellSurround, y1: pButConInnerY,
x2: wellSurround+butConSX, y2: pButConInnerY+butConSY
];
Draw[inr, met];
Draw[[x1: inr.x1, y1: inr.y1, x2: inr.x2, y2: inr.y1+butContactPolyYS], pol];
Draw[[x1: inr.x1, y1: inr.y1+butContactDiffY, x2: inr.x2, y2: inr.y2], inst.ob.layer];
Draw[[x1: 0, y1: 0, x2: pButConSX, y2: pButConSY], nwell];
Draw[CDBasics.Extend[inr, -butContactRimWidth], cut];
END;
PButInsideRectWithSurround: PROC [ob: CD.Object] RETURNS [CD.Rect] =
BEGIN
RETURN [pButConInner]
END;
PButShowSelectedWithSurround: PROC [inst: CD.Instance, pos: CD.Position,
orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
pr.drawOutLine[
CDOrient.MapRect[
itemInCell: pButConInner,
cellSize: [pButConSX, pButConSY],
cellInstOrient: orient,
cellInstPos: pos
],
pr]
END;
-- Bur -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
pForBurCon: REF CD.ObjectClass = RegisterObjectClass[$CMosBurContact];
pForWellBurCon: REF CD.ObjectClass = RegisterObjectClass[$CMosWellBurContact];
-- Buried contacts come in three flavours, Pol-Surround, Dif-Surround and Crossing. The buried contacts in chipndale are parameterized by lExt and wExt, their interpretation is as follows: Diff always extends 1l to the left, material above/below and to the right is determined by lExt and wExt respectively. 2l is the pivotal value, below 2l the material is Pol, at 2l or above the material is Diff. (Note: some combinations give Diff on all four sides, it is assumed that such combinations will not be created.)
CreateBurCon: PUBLIC PROC [w, l: CD.Number,
wex: CD.Number,
lex: CD.Number,
difLev: CD.Layer] RETURNS [CD.Object] =
-- connects diffusion with poly without accessing metal
BEGIN
-- copied from chipmonk without understanding
burAct: CD.Number = 2*lambda;
actWidth, xMargins: CD.Number;
cob: CD.Object ~ burCache.UnusedOrNew[];
cp: ContactPtr ~ NARROW[cob.specificRef];
IF difLev=undef THEN difLev←ndif;
wex ← MAX[0, wex];
lex ← MAX[0, lex];
xMargins ← burAct +
(IF wex< burAct THEN MAX[wex+lambda, burAct] ELSE wex);
actWidth ← MAX[2*lambda, w-xMargins];
w ← actWidth+xMargins;
l ← MAX[l,
(IF lex<burAct THEN MAX[lex+lambda, burAct] ELSE lex)*2+lambda*MAX[6*lambda/actWidth, 2]
];
cp.typ ← burr;
cp.wExt ← wex;
cp.lExt ← lex;
IF difLev=CMos.pdif THEN {
--some people told me that this can not be produced
cob.class ← pForWellBurCon;
cob.size ← [w+2*wellSurround, l+2*wellSurround];
RETURN[CDRects.CreateRect[[w, l], CD.highLightError]];
}
ELSE {
cob.class ← pForBurCon;
cob.size ← [w, l];
};
cob.layer ← difLev;
RETURN [burCache.ReplaceByAequivalent[cob]]
END;
ReadBurCon: CD.InternalReadProc --PROC [] RETURNS [Object]-- =
BEGIN
w: INT = TokenIO.ReadInt[];
l: INT = TokenIO.ReadInt[];
wex: INT = TokenIO.ReadInt[];
lex: INT = TokenIO.ReadInt[];
difLev: CD.Layer = CDIO.ReadLayer[];
RETURN [ CreateBurCon[w, l, wex, lex, difLev] ]
END;
WriteBurCon: CD.InternalWriteProc -- PROC [me: Object] -- =
BEGIN
cp: ContactPtr = NARROW[me.specificRef];
IF me.layer = CMos.pdif THEN {
TokenIO.WriteInt[me.size.x-2*wellSurround];
TokenIO.WriteInt[me.size.y-2*wellSurround];
}
ELSE {
TokenIO.WriteInt[me.size.x];
TokenIO.WriteInt[me.size.y];
};
TokenIO.WriteInt[cp.wExt];
TokenIO.WriteInt[cp.lExt];
CDIO.WriteLayer[me.layer];
END;
DrawBurrCon: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
Draw: PROC[r: CD.Rect, l: CD.Layer] = INLINE
--uses outer stuff!!
BEGIN
pr.drawRect[
CDOrient.MapRect[
itemInCell: r,
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos],
l,
pr];
END;
--copied from chipmonk without understanding
class: ContactPtr = NARROW[inst.ob.specificRef];
dBur: CD.Number = lambda/2;
burAct: CD.Number = lambda*2;
diffBur: CD.Position = [
x: IF class.wExt<burAct THEN MAX[class.wExt+lambda, burAct] ELSE class.wExt-lambda,
y: IF class.lExt<burAct THEN MAX[class.lExt+lambda, burAct] ELSE class.lExt-lambda
];
Draw[[dBur, dBur, inst.ob.size.x-dBur, inst.ob.size.y-dBur], bur];
Draw[[burAct, class.lExt, inst.ob.size.x-class.wExt, inst.ob.size.y-class.lExt], pol];
Draw[[lambda, diffBur.y, inst.ob.size.x-diffBur.x, inst.ob.size.y-diffBur.y], inst.ob.layer];
END;
LengthenBur: CDCallSpecific.CallProc =
BEGIN
amount: CD.Position = ToPosition[x];
IF amount.y=0 AND amount.x=0 THEN done ← FALSE
ELSE {
new: CD.Object;
sur: INT = IF inst.ob.layer=CMos.pdif THEN 2*wellSurround ELSE 0;
cp: ContactPtr ← NARROW[inst.ob.specificRef];
sz: CD.Position ← CDBasics.SubPoints[CDBasics.AddPoints[inst.ob.size, amount], [sur, sur]];
IF sz.x<=0 OR sz.y<=0 THEN {done ← FALSE; RETURN};
new ← CreateBurCon[w: sz.x, l: sz.y, wex: cp.wExt, lex: cp.lExt, difLev: inst.ob.layer];
repaintMe ← TRUE;
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
};
END;
ChangeExtensionBur: CDCallSpecific.CallProc =
BEGIN
amount: CD.Position = ToPosition[x];
IF amount.y=0 AND amount.x=0 THEN done ← FALSE
ELSE {
sur: INT = (IF inst.ob.layer=CMos.pdif THEN 2*wellSurround ELSE 0);
cp: ContactPtr = NARROW[inst.ob.specificRef];
new: CD.Object ← CreateBurCon[
w: inst.ob.size.x-sur+amount.x,
l: inst.ob.size.y-sur+amount.y,
wex: cp.wExt+amount.x,
lex: cp.lExt+amount.y,
difLev: inst.ob.layer
];
repaintMe ← TRUE;
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
}
END;
DefaultenBur: CDCallSpecific.CallProc =
BEGIN
sur: INT = IF inst.ob.layer=CMos.pdif THEN 2*wellSurround ELSE 0;
cp: ContactPtr = NARROW[inst.ob.specificRef];
new: CD.Object ← CreateBurCon[w: inst.ob.size.x-sur, l: 4*lambda, wex: cp.wExt, lex: cp.lExt, difLev: inst.ob.layer];
repaintMe ← TRUE;
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
END;
--Mm -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
pForVia: REF CD.ObjectClass = RegisterObjectClass[$CMosMmContact];
mmRimWidth: CD.Number = lambda;
cut2min: CD.Number = 3*lambda;
CreateMmCon: PUBLIC PROC [l: CD.Number,
wex: CD.Number,
lex: CD.Number] RETURNS [CD.Object] =
--ignores wex and lex in chipmonk, why???
--connects two layers of metal
BEGIN
cob: CD.Object ~ mmCache.UnusedOrNew[];
cp: ContactPtr ~ NARROW[cob.specificRef];
mins: CD.Number = cut2min+2*mmRimWidth;
oldMins: CD.Number = cut2min+2*--mmRimWidth--2*lambda;
l ← MAX[l, mins];
IF l=mins THEN RETURN [CMosObjects.CreateMmCon[]];
cp.typ ← mm2;
--cp.wExt ← ;
--cp.wExt ← ;
cob.class ← pForVia;
IF l<oldMins THEN --new technology; we use new technology only for small sizes--
cob.size ← [mins, l]
ELSE --old technology--
cob.size ← [oldMins, l];
cob.layer ← CMos.met;
RETURN [mmCache.ReplaceByAequivalent[cob]]
END;
LengthenVia: CDCallSpecific.CallProc =
BEGIN
amount: CD.Position = ToPosition[x];
IF amount.y=0 OR amount.x#0 THEN done ← FALSE
ELSE {
new: CD.Object;
cp: ContactPtr ← NARROW[inst.ob.specificRef];
sz: CD.Position ← CDBasics.AddPoints[inst.ob.size, amount];
IF sz.x<=0 OR sz.y<=0 THEN {done←FALSE; RETURN};
new ← CreateMmCon[l: sz.y, wex: cp.wExt, lex: cp.lExt];
repaintMe ← TRUE;
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
}
END;
DefaultenVia: CDCallSpecific.CallProc =
BEGIN
cp: ContactPtr ← NARROW[inst.ob.specificRef];
new: CD.Object ← CreateMmCon[l: 4*lambda, wex: cp.wExt, lex: cp.lExt];
repaintMe ← TRUE;
IF new#NIL THEN inst.ob ← new ELSE done ← FALSE;
END;
ReadVia: CD.InternalReadProc --PROC [] RETURNS [Object]-- =
BEGIN
RETURN [ CreateMmCon[TokenIO.ReadInt[], 0, 0] ]
END;
WriteVia: CD.InternalWriteProc -- PROC [me: Object] -- =
BEGIN
TokenIO.WriteInt[me.size.y];
END;
DrawVia: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
--does not read specificRef !!!!!!
BEGIN
mins: CD.Number = cut2min+2*mmRimWidth;
r: CD.Rect = CDOrient.RectAt[pos, inst.ob.size, orient];
pr.drawRect[r, met, pr];
pr.drawRect[r, met2, pr];
IF inst.ob.size.x>mins THEN --old technology--
pr.drawRect[CDBasics.Extend[r, -2*lambda --oldmmRimWidth-- ], cut2, pr]
ELSE --new technology--
pr.drawRect[CDBasics.Extend[r, -mmRimWidth], cut2, pr];
END;
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
DescribeLayer: PROC[l: CD.Layer] RETURNS [Rope.ROPE] =
{RETURN [Atom.GetPName[CD.LayerKey[l]]]};
Describe: PROC[me: CD.Object] RETURNS [Rope.ROPE] =
BEGIN
cp: ContactPtr = NARROW[me.specificRef];
RETURN [
SELECT cp.typ FROM
burr => Rope.Concat["buried contact ", DescribeLayer[me.layer]],
mDif => Rope.Concat[DescribeLayer[me.layer], " contact"],
difShort => Rope.Concat["dif - short contact ", DescribeLayer[me.layer]],
butt => Rope.Concat["butting contact ", DescribeLayer[me.layer]],
mPol => "contact poly",
mm2 => "via",
ENDCASE => "unknown contact"
]
END;
Init: PROC [] =
BEGIN
pForDifPolCon.drawMe ← pForDifPolCon.quickDrawMe ← DrawDifPolCon;
pForDifPolCon.internalRead ← ReadDifPolCon;
pForDifPolCon.internalWrite ← WriteDifPolCon;
pForDifPolCon.describe ← Describe;
CDStretchyExtras.InstallMatch[pForDifPolCon, MatchContact];
CDCallSpecific.Register[$Lengthen, pForDifPolCon, LengthenPolyDif];
CDCallSpecific.Register[$Default, pForDifPolCon, DefaultenPolyDif];
pForWellDifPolCon.drawMe ← pForWellDifPolCon.quickDrawMe ← DrawWellDifPolCon;
pForWellDifPolCon.interestRect ← pForWellDifPolCon.oldInsideRect ← InsideRectWithSurround;
pForWellDifPolCon.showMeSelected ← ShowSelectedWithSurround;
pForWellDifPolCon.internalRead ← ReadDifPolCon;
pForWellDifPolCon.internalWrite ← WriteDifPolCon;
pForWellDifPolCon.describe ← Describe;
CDStretchyExtras.InstallMatch[pForWellDifPolCon, MatchContact];
CDCallSpecific.Register[$Lengthen, pForWellDifPolCon, LengthenPolyDif];
CDCallSpecific.Register[$Default, pForWellDifPolCon, DefaultenPolyDif];
pForButContact.drawMe ← pForButContact.quickDrawMe ← DrawButContact;
pForButContact.internalRead ← ReadButCon;
pForButContact.internalWrite ← WriteButCon;
pForButContact.describe ← Describe;
CDStretchyExtras.InstallMatch[pForButContact, MatchContact];
pForWellButContact.drawMe ← pForWellButContact.quickDrawMe ← DrawWellButContact;
pForWellButContact.interestRect ← pForWellButContact.oldInsideRect ← PButInsideRectWithSurround;
pForWellButContact.showMeSelected ← PButShowSelectedWithSurround;
pForWellButContact.internalRead ← ReadButCon;
pForWellButContact.internalWrite ← WriteButCon;
pForWellButContact.describe ← Describe;
CDStretchyExtras.InstallMatch[pForWellButContact, MatchContact];
pForBurCon.drawMe ← pForBurCon.quickDrawMe ← DrawBurrCon;
pForBurCon.internalRead ← ReadBurCon;
pForBurCon.internalWrite ← WriteBurCon;
pForBurCon.describe ← Describe;
CDStretchyExtras.InstallMatch[pForBurCon, MatchContact];
CDCallSpecific.Register[$Lengthen, pForBurCon, LengthenBur];
CDCallSpecific.Register[$ChangeExt, pForBurCon, ChangeExtensionBur];
CDCallSpecific.Register[$Default, pForBurCon, DefaultenBur];
pForWellBurCon.drawMe ← pForWellBurCon.quickDrawMe ← DrawWellBurrCon;
pForWellBurCon.interestRect ← pForWellBurCon.oldInsideRect ← InsideRectWithSurround;
pForWellBurCon.internalRead ← ReadBurCon;
pForWellBurCon.internalWrite ← WriteBurCon;
pForWellBurCon.describe ← Describe;
CDStretchyExtras.InstallMatch[pForWellBurCon, MatchContact];
CDCallSpecific.Register[$Lengthen, pForWellBurCon, LengthenBur];
CDCallSpecific.Register[$ChangeExt, pForWellBurCon, ChangeExtensionBur];
CDCallSpecific.Register[$Default, pForWellBurCon, DefaultenBur];
pForVia.drawMe ← pForVia.quickDrawMe ← DrawVia;
pForVia.internalRead ← ReadVia;
pForVia.internalWrite ← WriteVia;
pForVia.describe ← Describe;
CDStretchyExtras.InstallMatch[pForVia, MatchContact];
CDCallSpecific.Register[$Lengthen, pForVia, LengthenVia]; --I'm not shure changing size is a good idea
CDCallSpecific.Register[$Default, pForVia, DefaultenVia];
pForDifShorts.drawMe ← pForDifShorts.quickDrawMe ← DrawDifShortContact;
pForDifShorts.internalRead ← ReadDifShortCon;
pForDifShorts.internalWrite ← WriteDifShortCon;
pForDifShorts.describe ← Describe;
CDStretchyExtras.InstallMatch[pForDifShorts, MatchContact];
pForWellDifShorts.drawMe ← pForWellDifShorts.quickDrawMe ← DrawWellDifShortContact;
pForWellDifShorts.interestRect ← pForWellDifShorts.oldInsideRect ← InsideRectWithSurround;
pForWellDifShorts.internalRead ← ReadDifShortCon;
pForWellDifShorts.internalWrite ← WriteDifShortCon;
pForWellDifShorts.describe ← Describe;
CDStretchyExtras.InstallMatch[pForWellDifShorts, MatchContact];
END;
Init[];
END.