JasmineModelImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by Neil Gunther, June 19, 1986 2:42:55 pm PDT
Last Edited by: Neil Gunther June 26, 1986 7:57:49 pm PDT
DIRECTORY
Core,
CoreClasses,
CStitching,
IO,
Jasmine,
JasmineModel,
Real,
SymTab,
TerminalIO;
JasmineModelImpl: CEDAR PROGRAM
IMPORTS CStitching, IO, Real, SymTab, TerminalIO
EXPORTS JasmineModel
= BEGIN
OPEN Jasmine, Real;
Volts: TYPE = REAL;
kOhm: TYPE = REAL;
pF: TYPE = REAL;
mA: TYPE = REAL;
uH: TYPE = REAL;
resolution: INT ← 4;
CreateModel: PUBLIC PROC [tesselation: CStitching.Tesselation] RETURNS [model: SymTab.Ref] = {
InsertMacro: CStitching.TileProc
--PROC [tile: Tile, data: REF]-- = {
AspectRatio: PROC RETURNS [ar: AspectType] = {
-- Rect: TYPE = RECORD [x1, y1, x2, y2: INT];
ar ← SELECT TRUE FROM
(r.x2-r.x1)>(r.y2-r.y1) => horiz,
(r.x2-r.x1)<(r.y2-r.y1) => vert,
ENDCASE => square;
};
Branching: PROC RETURNS [branch: BranchType] = {
tWest, tEast, tSouth, tNorth: CStitching.Tile;
N, S, E, W: INT ← 0;
tEast ← CStitching.NE[tile];
IF tEast.value#NIL THEN E ← 1;
TRUSTED {tSouth ← LOOPHOLE[tile.wS]};
IF tSouth.value#NIL THEN S ← 1;
tWest ← CStitching.SW[tile];
IF tWest.value#NIL THEN W ← 1;
TRUSTED {tNorth ← LOOPHOLE[tile.eN]};
IF tNorth.value#NIL THEN N ← 1;
SELECT (N+S+E+W) FROM
4 => branch ← fourWay;
3 => SELECT TRUE FROM
N+(E+W)=3 => branch ← inverseT;
N+(E+S)=3 => branch ← rightT;
N+(W+S)=3 => branch ← leftT;
S+(E+W)=3 => branch ← T;
ENDCASE => NULL;
2 => SELECT TRUE FROM
N+S=2 => branch ← straight;
N+E=2 => branch ← L;
N+W=2 => branch ← reverseL;
S+E=2 => branch ← inverseL;
S+W=2 => branch ← inverseRevL;
ENDCASE => NULL;
1 => branch ← straight;
ENDCASE => NULL;
};
ContactResistance: PROC [] RETURNS [R: kOhm] = {
R ← SELECT tileData.object FROM
nDifCont => 30*1E-3,
pDifCont => 120*1E-3,
polyCont => 25*1E-3,
ENDCASE --Via-- => 1E-3;
};
WireResistance: PROC [] RETURNS [R: kOhm] = {
Squares: PROC [CStitching.Rect] RETURNS [sqrs: REAL] = {
length ← (r.x2-r.x1); width ← (r.y2-r.y1);
IF length > width THEN sqrs ← Real.Float[length]/width
ELSE sqrs ← Real.Float[width]/length;
};
Reference: QuickAndDirty
m1Resistivity: REAL ← 0.065;
m2Resistivity: REAL ← 0.042;
polyResistivity: REAL ← 3.5;
nDifResistivity: REAL ← 35;
pDifResistivity: REAL ← 120;
R ← SELECT tileData.object FROM
m1Wire => Squares[r]*m1Resistivity*1E-3,
m2Wire => Squares[r]*m2Resistivity*1E-3,
polyWire => Squares[r]*polyResistivity*1E-3,
nDifWire => Squares[r]*nDifResistivity*1E-3,
ENDCASE => Squares[r]*pDifResistivity*1E-3;
};
WireInductance: PROC [] RETURNS [L: uH] = {
};
WireCapacitance: PROC [] RETURNS [C: pF ← 0.1] = {
Compute Thyme Stray
(Area is additive; Perimeter is compounded)
jasmineMacro.wireArea ← length*width;
jasmineMacro.wirePerimeter ← 2*length+2*width;
};
TransistorParameters: PROC [] = {
tranData: CoreClasses.Transistor ←NARROW[tileData.data];
jasmineMacro.xtorType ← SELECT tileData.object FROM
nTran, nTranL => nE,
pTran, pTranL => pE,
ENDCASE => ERROR;
jasmineMacro.xtorLength ← tranData.length;
jasmineMacro.xtorWidth ← tranData.width;
};
tileData: JasmineObjectInLayer ← NARROW[tile.value];
jasmineMacro: JasmineMacro ← NEW[JasmineMacroRec];
r: CStitching.Rect ← CStitching.Area[tile];
symbol: Core.ROPE;
length, width: INT;
jasmineMacro.macroType ← tileData.object;
SELECT tileData.object FROM
m1Wire, m2Wire, nDifWire, pDifWire, polyWire => {
jasmineMacro.wireAspect ← AspectRatio[];
jasmineMacro.resistance ← WireResistance[];
jasmineMacro.inductance ← WireInductance[];
jasmineMacro.capacitance ← WireCapacitance[];
jasmineMacro.branch ← Branching[];
};
nDifCont, pDifCont, polyCont, Via => {
jasmineMacro.resistance ← ContactResistance[];
jasmineMacro.branch ← Branching[];
};
nTran, nTranL, pTran, pTranL => {TransistorParameters[];};
ENDCASE => NULL;
symbol ← MapConvert[jasmineMacro.JMapLoc ← ScaleMap[tile]];
[] ← SymTab.Store[x: model, key: symbol, val: jasmineMacro];
}; --InsertMacro
model ← SymTab.Create[];
CStitching.EnumerateArea[plane: tesselation, rect: CStitching.all, eachTile: InsertMacro];
}; --CreateModel
MapConvert: PUBLIC PROC [jml: JasmineModel.JasmineModelLocation] RETURNS [sym: Core.ROPE] = {
sym ← IO.PutFR["[%g, %g]", IO.int[jml.row], IO.int[jml.col]];
};
ScaleMap: PROC [tile: CStitching.Tile] RETURNS [loc: JasmineModel.JasmineModelLocation] = {
lambda: INT ← 8;
x, y, scale: INT ← 0;
r: CStitching.Rect ← CStitching.Area[tile];
IF resolution<1 THEN resolution𡤁
scale ← resolution*lambda;
x ← Round[Float[r.x1+(r.x2-r.x1)/2]/scale];
y ← Round[Float[r.y1+(r.y2-r.y1)/2]/scale];
IF x<1 THEN x𡤁 IF y<1 THEN y𡤁
IF x>INT.LAST THEN x←INT.LAST; IF y>INT.LAST THEN y←INT.LAST;
loc ← [x, y];
};
PrintModel: PROC [model: SymTab.Ref] = {
PrintMacro: PROC = {
FOR i: INT IN [0..model.size] DO
searchLocation.row ← i;
FOR j: INT IN [0..model.size] DO
searchLocation.col ← j;
[thereIs, val] ← SymTab.Fetch[model, MapConvert[searchLocation]];
IF thereIs THEN {
macro: JasmineMacro ← NARROW[val];
TerminalIO.WriteRope["\nMacro: "];
TerminalIO.WriteRope[MapConvert[macro.JMapLoc]];
SELECT macro.macroType FROM
m1Wire, m2Wire, nDifWire, pDifWire, polyWire => {
IF macro.wireAspect=vert THEN TerminalIO.WriteRope[" | "]
ELSE TerminalIO.WriteRope[" -- "];
TerminalIO.WriteF[" %g K ", IO.real[macro.resistance]];
};
nDifCont, pDifCont, polyCont, Via => {
SELECT macro.branch FROM
leftT => TerminalIO.WriteRope[" --| "];
rightT=> TerminalIO.WriteRope[" |-- "];
inverseT=> TerminalIO.WriteRope[" —L "];
T=> TerminalIO.WriteRope[" T "];
L => TerminalIO.WriteRope[" L "];
reverseL => TerminalIO.WriteRope[" ←L "];
inverseL => TerminalIO.WriteRope[" F "];
inverseRevL => TerminalIO.WriteRope[" 𡤏 "];
straight => TerminalIO.WriteRope[" * "];
fourWay=> TerminalIO.WriteRope[" + "];
ENDCASE => NULL;
TerminalIO.WriteF[" %g K ", IO.real[macro.resistance]];
};
nTran, nTranL, pTran, pTranL => TerminalIO.WriteRope[" -[ "];
ENDCASE => NULL;
macroCount ← macroCount.SUCC;
};
ENDLOOP;
ENDLOOP;
};
val: REF ANY;
thereIs: BOOL;
macroCount: INT ← 0;
searchLocation: JasmineModel.JasmineModelLocation;
PrintMacro[];
TerminalIO.WriteF["\nTotal: %g, Scale: %g lambda\n\n", IO.int[macroCount], IO.int[resolution]];
}; --PrintModel
END.