Additional changes, almost all stylistic, to make the resis/ section

style conform to the rest of the database.  It is difficult to work
with code written in a sloppy, random style.
This commit is contained in:
Tim Edwards 2021-05-26 22:34:36 -04:00
parent 9aa39f820f
commit 7f11020ab4
11 changed files with 919 additions and 945 deletions

View File

@ -1 +1 @@
8.3.169 8.3.170

View File

@ -43,7 +43,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/ */
void void
ResSanityChecks(nodename,resistorList,nodeList,devlist) ResSanityChecks(nodename, resistorList, nodeList, devlist)
char *nodename; char *nodename;
resResistor *resistorList; resResistor *resistorList;
resNode *nodeList; resNode *nodeList;
@ -55,7 +55,7 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
resDevice *dev; resDevice *dev;
resElement *rcell; resElement *rcell;
static Stack *resSanityStack = NULL; static Stack *resSanityStack = NULL;
int reached,foundorigin; int reached, foundorigin;
if (resSanityStack == NULL) if (resSanityStack == NULL)
{ {
@ -72,13 +72,13 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
resistor->rr_status &= ~RES_REACHED_RESISTOR; resistor->rr_status &= ~RES_REACHED_RESISTOR;
} }
/* Check 1- Are the resistors and nodes all connected? */ /* Check: Are the resistors and nodes all connected? */
while (!StackEmpty(resSanityStack)) while (!StackEmpty(resSanityStack))
{ {
node = (resNode *)STACKPOP(resSanityStack); node = (resNode *)STACKPOP(resSanityStack);
if (node->rn_status & RES_REACHED_NODE) continue; if (node->rn_status & RES_REACHED_NODE) continue;
node->rn_status |= RES_REACHED_NODE; node->rn_status |= RES_REACHED_NODE;
for (rcell = node->rn_re; rcell != NULL; rcell=rcell->re_nextEl) for (rcell = node->rn_re; rcell != NULL; rcell = rcell->re_nextEl)
{ {
resistor = rcell->re_thisEl; resistor = rcell->re_thisEl;
if (resistor->rr_status & RES_REACHED_RESISTOR) continue; if (resistor->rr_status & RES_REACHED_RESISTOR) continue;
@ -86,16 +86,17 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
if (resistor->rr_connection1 != node && if (resistor->rr_connection1 != node &&
resistor->rr_connection2 != node) resistor->rr_connection2 != node)
{ {
TxError("Stray resElement pointer- node %s, pointer %d\n",nodename,rcell); TxError("Stray resElement pointer- node %s, pointer %d\n",
nodename, rcell);
continue; continue;
} }
if ((resistor->rr_connection1->rn_status & RES_REACHED_NODE) == 0) if ((resistor->rr_connection1->rn_status & RES_REACHED_NODE) == 0)
{ {
STACKPUSH((ClientData)resistor->rr_connection1,resSanityStack); STACKPUSH((ClientData)resistor->rr_connection1, resSanityStack);
} }
if ((resistor->rr_connection2->rn_status & RES_REACHED_NODE) == 0) if ((resistor->rr_connection2->rn_status & RES_REACHED_NODE) == 0)
{ {
STACKPUSH((ClientData)resistor->rr_connection2,resSanityStack); STACKPUSH((ClientData)resistor->rr_connection2, resSanityStack);
} }
} }
} }
@ -103,7 +104,7 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
{ {
if ((resistor->rr_status & RES_REACHED_RESISTOR) == 0) if ((resistor->rr_status & RES_REACHED_RESISTOR) == 0)
{ {
TxError("Unreached resistor in %s\n",nodename); TxError("Unreached resistor in %s\n", nodename);
} }
resistor->rr_status &= ~RES_REACHED_RESISTOR; resistor->rr_status &= ~RES_REACHED_RESISTOR;
} }
@ -113,14 +114,14 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
if (dev->rd_status & RES_DEV_PLUG) continue; if (dev->rd_status & RES_DEV_PLUG) continue;
reached = FALSE; reached = FALSE;
for (i=0;i != dev->rd_nterms;i++) for (i = 0; i != dev->rd_nterms; i++)
{ {
if (dev->rd_terminals[i] != NULL) if (dev->rd_terminals[i] != NULL)
{ {
reached = TRUE; reached = TRUE;
if ((dev->rd_terminals[i]->rn_status & RES_REACHED_NODE) == 0) if ((dev->rd_terminals[i]->rn_status & RES_REACHED_NODE) == 0)
{ {
TxError("Device node %d unreached in %s\n",i,nodename); TxError("Device node %d unreached in %s\n", i, nodename);
} }
} }
} }
@ -137,7 +138,8 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
{ {
if ((node->rn_status & RES_REACHED_NODE) == 0) if ((node->rn_status & RES_REACHED_NODE) == 0)
{ {
TxError("Unreached node in %s at %d, %d\n",nodename,node->rn_loc.p_x,node->rn_loc.p_y); TxError("Unreached node in %s at %d, %d\n", nodename,
node->rn_loc.p_x, node->rn_loc.p_y);
} }
node->rn_status &= ~RES_REACHED_NODE; node->rn_status &= ~RES_REACHED_NODE;
if (node->rn_why & RES_NODE_ORIGIN) if (node->rn_why & RES_NODE_ORIGIN)
@ -147,7 +149,7 @@ ResSanityChecks(nodename,resistorList,nodeList,devlist)
} }
if (foundorigin == 0) if (foundorigin == 0)
{ {
TxError("Starting node not found in %s\n",nodename); TxError("Starting node not found in %s\n", nodename);
} }
} }
#endif #endif

View File

@ -65,7 +65,6 @@ int
dbcConnectFuncDCS(tile, cx) dbcConnectFuncDCS(tile, cx)
Tile *tile; Tile *tile;
TreeContext *cx; TreeContext *cx;
{ {
struct conSrArg2 *csa2; struct conSrArg2 *csa2;
Rect tileArea, *srArea, devArea, newarea; Rect tileArea, *srArea, devArea, newarea;
@ -85,39 +84,40 @@ dbcConnectFuncDCS(tile, cx)
TiToRect(tile, &tileArea); TiToRect(tile, &tileArea);
srArea = &scx->scx_area; srArea = &scx->scx_area;
if (((tileArea.r_xbot >= srArea->r_xtop-1) || if (((tileArea.r_xbot >= srArea->r_xtop - 1) ||
(tileArea.r_xtop <= srArea->r_xbot+1)) && (tileArea.r_xtop <= srArea->r_xbot + 1)) &&
((tileArea.r_ybot >= srArea->r_ytop-1) || ((tileArea.r_ybot >= srArea->r_ytop - 1) ||
(tileArea.r_ytop <= srArea->r_ybot+1))) (tileArea.r_ytop <= srArea->r_ybot + 1)))
return 0; return 0;
t1 = TiGetType(tile); t1 = TiGetType(tile);
if TTMaskHasType(&DiffTypeBitMask,t1) if TTMaskHasType(&DiffTypeBitMask, t1)
{ {
/* left */ /* left */
for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp=RT(tp)) for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp))
{ {
t2 = TiGetType(tp); t2 = TiGetType(tp);
devptr = ExtCurStyle->exts_device[t2]; devptr = ExtCurStyle->exts_device[t2];
if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask),t2) && if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) &&
TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),t1)) TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1))
{ {
TiToRect(tp, &devArea); TiToRect(tp, &devArea);
thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile)));
ResCalcPerimOverlap(thisDev,tp);
GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area); GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area);
thisDev->type = TiGetType(tp); thisDev->type = TiGetType(tp);
thisDev->nextDev = DevList; thisDev->nextDev = DevList;
DevList = thisDev; DevList = thisDev;
ResCalcPerimOverlap(thisDev, tp);
} }
} }
/*right*/
/* right */
for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp)) for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp))
{ {
t2 = TiGetType(tp); t2 = TiGetType(tp);
devptr = ExtCurStyle->exts_device[t2]; devptr = ExtCurStyle->exts_device[t2];
if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask),t2) && if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) &&
TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),t1)) TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1))
{ {
TiToRect(tp, &devArea); TiToRect(tp, &devArea);
thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile)));
@ -125,16 +125,17 @@ dbcConnectFuncDCS(tile, cx)
thisDev->type = TiGetType(tp); thisDev->type = TiGetType(tp);
thisDev->nextDev = DevList; thisDev->nextDev = DevList;
DevList = thisDev; DevList = thisDev;
ResCalcPerimOverlap(thisDev,tp); ResCalcPerimOverlap(thisDev, tp);
} }
} }
/*top*/
for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp=BL(tp)) /* top */
for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp))
{ {
t2 = TiGetType(tp); t2 = TiGetType(tp);
devptr = ExtCurStyle->exts_device[t2]; devptr = ExtCurStyle->exts_device[t2];
if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask),t2) && if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) &&
TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),t1)) TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1))
{ {
TiToRect(tp, &devArea); TiToRect(tp, &devArea);
thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile)));
@ -142,16 +143,17 @@ dbcConnectFuncDCS(tile, cx)
thisDev->type = TiGetType(tp); thisDev->type = TiGetType(tp);
thisDev->nextDev = DevList; thisDev->nextDev = DevList;
DevList = thisDev; DevList = thisDev;
ResCalcPerimOverlap(thisDev,tp); ResCalcPerimOverlap(thisDev, tp);
} }
} }
/*bottom */
for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp=TR(tp)) /* bottom */
for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp = TR(tp))
{ {
t2 = TiGetType(tp); t2 = TiGetType(tp);
devptr = ExtCurStyle->exts_device[t2]; devptr = ExtCurStyle->exts_device[t2];
if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask),t2) && if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) &&
TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),t1)) TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1))
{ {
TiToRect(tp, &devArea); TiToRect(tp, &devArea);
thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile)));
@ -159,11 +161,11 @@ dbcConnectFuncDCS(tile, cx)
thisDev->type = TiGetType(tp); thisDev->type = TiGetType(tp);
thisDev->nextDev = DevList; thisDev->nextDev = DevList;
DevList = thisDev; DevList = thisDev;
ResCalcPerimOverlap(thisDev,tp); ResCalcPerimOverlap(thisDev, tp);
} }
} }
} }
else if TTMaskHasType(&(ExtCurStyle->exts_deviceMask),t1) else if TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t1)
{ {
TiToRect(tile, &devArea); TiToRect(tile, &devArea);
thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile)));
@ -173,9 +175,10 @@ dbcConnectFuncDCS(tile, cx)
thisDev->nextDev = DevList; thisDev->nextDev = DevList;
DevList = thisDev; DevList = thisDev;
} }
/* in some cases (primarily bipolar technology), we'll want to extract /* in some cases (primarily bipolar technology), we'll want to extract
devices whose substrate terminals are part of the given region. * devices whose substrate terminals are part of the given region.
The following does that check. (10-11-88) * The following does that check. (10-11-88)
*/ */
#ifdef ARIEL #ifdef ARIEL
if (TTMaskHasType(&ResSubsTypeBitMask,t1) && (ResOptionsFlags & ResOpt_DoSubstrate)) if (TTMaskHasType(&ResSubsTypeBitMask,t1) && (ResOptionsFlags & ResOpt_DoSubstrate))
@ -186,9 +189,9 @@ dbcConnectFuncDCS(tile, cx)
{ {
if (TTMaskIntersect(&DBPlaneTypes[pNum], mask)) if (TTMaskIntersect(&DBPlaneTypes[pNum], mask))
{ {
(void)DBSrPaintArea((Tile *) NULL, DBSrPaintArea((Tile *) NULL,
scx->scx_use->cu_def->cd_planes[pNum], scx->scx_use->cu_def->cd_planes[pNum],
&tileArea,mask,resSubSearchFunc, (ClientData) cx); &tileArea, mask, resSubSearchFunc, (ClientData)cx);
} }
} }
} }
@ -248,7 +251,6 @@ dbcConnectFuncDCS(tile, cx)
DBTreeSrLabels(&scx2, connectMask, csa2->csa2_xMask, &tpath, DBTreeSrLabels(&scx2, connectMask, csa2->csa2_xMask, &tpath,
TF_LABEL_ATTACH, dbcConnectLabelFunc, TF_LABEL_ATTACH, dbcConnectLabelFunc,
(ClientData)csa2); (ClientData)csa2);
// DBCellCopyLabels(&scx2, connectMask, csa2->csa2_xMask, csa2->csa2_use, NULL);
/* Only extend those sides bordering the diagonal tile */ /* Only extend those sides bordering the diagonal tile */
@ -322,55 +324,43 @@ void
ResCalcPerimOverlap(dev, tile) ResCalcPerimOverlap(dev, tile)
ResDevTile *dev; ResDevTile *dev;
Tile *tile; Tile *tile;
{ {
Tile *tp; Tile *tp;
int t1; int t1;
int overlap; int overlap;
dev->perim = (TOP(tile)-BOTTOM(tile)-LEFT(tile)+RIGHT(tile))<<1; dev->perim = (TOP(tile) - BOTTOM(tile) - LEFT(tile) + RIGHT(tile)) << 1;
overlap =0; overlap =0;
t1 = TiGetType(tile); t1 = TiGetType(tile);
/* left */ /* left */
for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp=RT(tp)) for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp))
{ {
if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]),TiGetType(tp)) if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp))
{ overlap += MIN(TOP(tile), TOP(tp)) -
overlap += MIN(TOP(tile),TOP(tp))- MAX(BOTTOM(tile), BOTTOM(tp));
MAX(BOTTOM(tile),BOTTOM(tp));
} }
} /* right */
/*right*/
for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp)) for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp))
{ {
if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]),TiGetType(tp)) if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp))
{ overlap += MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp));
overlap += MIN(TOP(tile),TOP(tp))-
MAX(BOTTOM(tile),BOTTOM(tp));
} }
} /* top */
/*top*/ for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp))
for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp=BL(tp))
{ {
if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]),TiGetType(tp)) if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp))
{ overlap += MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp));
overlap += MIN(RIGHT(tile),RIGHT(tp))-
MAX(LEFT(tile),LEFT(tp));
} }
} /* bottom */
/*bottom */
for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp=TR(tp)) for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp=TR(tp))
{ {
if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]),TiGetType(tp)) if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp))
{ overlap += MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp));
overlap += MIN(RIGHT(tile),RIGHT(tp))-
MAX(LEFT(tile),LEFT(tp));
}
} }
dev->overlap = overlap; dev->overlap = overlap;
} }
@ -516,11 +506,9 @@ DBTreeCopyConnectDCS(scx, mask, xMask, connect, area, destUse)
*/ */
int int
resSubSearchFunc(tile,cx) resSubSearchFunc(tile, cx)
Tile *tile; Tile *tile;
TreeContext *cx; TreeContext *cx;
{ {
ResDevTile *thisDev; ResDevTile *thisDev;
Rect devArea; Rect devArea;
@ -528,18 +516,18 @@ resSubSearchFunc(tile,cx)
ExtDevice *devptr; ExtDevice *devptr;
/* Right now, we're only going to extract substrate terminals for /* Right now, we're only going to extract substrate terminals for
devices with only one diffusion terminal, principally bipolar * devices with only one diffusion terminal, principally bipolar
devices. * devices.
*/ */
devptr = ExtCurStyle->exts_device[t] devptr = ExtCurStyle->exts_device[t];
if (devptr->exts_deviceSDCount >1) return 0; if (devptr->exts_deviceSDCount > 1) return 0;
TiToRect(tile, &devArea); TiToRect(tile, &devArea);
thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile)));
GeoTransRect(&cx->tc_scx->scx_trans, &devArea, &thisDev->area); GeoTransRect(&cx->tc_scx->scx_trans, &devArea, &thisDev->area);
thisDev->type = t; thisDev->type = t;
thisDev->nextDev = DevList; thisDev->nextDev = DevList;
DevList = thisDev; DevList = thisDev;
ResCalcPerimOverlap(thisDev,tile); ResCalcPerimOverlap(thisDev, tile);
return 0; return 0;
} }

View File

@ -46,16 +46,15 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/ */
void void
ResPrintNodeList(fp,list) ResPrintNodeList(fp, list)
FILE *fp; FILE *fp;
resNode *list; resNode *list;
{ {
for (; list != NULL; list = list->rn_more) for (; list != NULL; list = list->rn_more)
{ {
fprintf(fp, "node %p: (%d %d) r= %d\n", fprintf(fp, "node %p: (%d %d) r= %d\n",
list,list->rn_loc.p_x,list->rn_loc.p_y,list->rn_noderes); list, list->rn_loc.p_x, list->rn_loc.p_y, list->rn_noderes);
} }
} }
@ -73,7 +72,7 @@ ResPrintNodeList(fp,list)
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
void void
ResPrintResistorList(fp,list) ResPrintResistorList(fp, list)
FILE *fp; FILE *fp;
resResistor *list; resResistor *list;
@ -112,7 +111,7 @@ ResPrintResistorList(fp,list)
*/ */
void void
ResPrintDeviceList(fp,list) ResPrintDeviceList(fp, list)
FILE *fp; FILE *fp;
resDevice *list; resDevice *list;

View File

@ -81,7 +81,7 @@ enumerate:
if (SigInterruptPending) if (SigInterruptPending)
return (1); return (1);
if ((tt=TiGetType(resSrTile)) != TT_SPACE) if ((tt = TiGetType(resSrTile)) != TT_SPACE)
{ {
resTopTile = RT(resSrTile); resTopTile = RT(resSrTile);
while (RIGHT(resTopTile) > LEFT(resSrTile)) while (RIGHT(resTopTile) > LEFT(resSrTile))
@ -90,11 +90,11 @@ enumerate:
if (ntt != tt) if (ntt != tt)
{ {
resTopTile=BL(resTopTile); resTopTile = BL(resTopTile);
continue; continue;
} }
/* ok, we may have found a concave corner */ /* ok, we may have found a concave corner */
ResCheckConcavity(resSrTile,resTopTile,tt); ResCheckConcavity(resSrTile, resTopTile, tt);
if (resTopTile == NULL) break; if (resTopTile == NULL) break;
if (BOTTOM(resTopTile) != TOP(resSrTile)) if (BOTTOM(resTopTile) != TOP(resSrTile))
{ {
@ -105,7 +105,6 @@ enumerate:
resTopTile=BL(resTopTile); resTopTile=BL(resTopTile);
} }
} }
} }
tpnew = TR(resSrTile); tpnew = TR(resSrTile);
@ -134,7 +133,8 @@ enumerate:
} }
/* At left edge -- walk down to next tile along the left edge */ /* At left edge -- walk down to next tile along the left edge */
for (resSrTile = LB(resSrTile); RIGHT(resSrTile) <= rect->r_xbot; resSrTile = TR(resSrTile)) for (resSrTile = LB(resSrTile); RIGHT(resSrTile) <= rect->r_xbot;
resSrTile = TR(resSrTile))
/* Nothing */; /* Nothing */;
} }
return (0); return (0);
@ -157,44 +157,48 @@ enumerate:
*/ */
void void
ResCheckConcavity(bot,top,tt) ResCheckConcavity(bot, top, tt)
Tile *bot,*top; Tile *bot, *top;
TileType tt; TileType tt;
{ {
Tile *tp; Tile *tp;
int xlen,ylen; int xlen, ylen;
/* corner #1: /* corner #1:
XXXXXXX * XXXXXXX
YYYYYYY * YYYYYYY
^--here * ^--here
*/ */
if (RIGHT(top) > RIGHT(bot) && TiGetType(TR(bot)) != tt) if (RIGHT(top) > RIGHT(bot) && TiGetType(TR(bot)) != tt)
{ {
int xpos = RIGHT(bot); int xpos = RIGHT(bot);
int ypos = BOTTOM(top); int ypos = BOTTOM(top);
xlen = xpos - resWalkleft(top,tt,xpos,ypos,NULL); xlen = xpos - resWalkleft(top, tt, xpos, ypos, NULL);
ylen = resWalkup(top,tt,xpos,ypos,NULL) - ypos; ylen = resWalkup(top, tt, xpos, ypos, NULL) - ypos;
if (xlen > ylen) if (xlen > ylen)
{ {
(void) resWalkup(top,tt,xpos,ypos,ResSplitX); (void) resWalkup(top, tt, xpos, ypos, ResSplitX);
} }
} }
if (resTopTile == NULL) return; if (resTopTile == NULL) return;
/* corner #2: /* corner #2:
v--here * v--here
XXXXXXX * XXXXXXX
YYYYYYY * YYYYYYY
*/ */
if (RIGHT(top) < RIGHT(bot)) if (RIGHT(top) < RIGHT(bot))
{ {
for (tp = TR(top);BOTTOM(tp) > BOTTOM(top);tp=LB(tp)); for (tp = TR(top); BOTTOM(tp) > BOTTOM(top); tp = LB(tp));
if (TiGetType(tp) != tt) if (TiGetType(tp) != tt)
{ {
int xpos = RIGHT(top); int xpos = RIGHT(top);
int ypos = BOTTOM(top); int ypos = BOTTOM(top);
xlen = xpos-resWalkleft(top,tt,xpos,ypos,NULL); xlen = xpos - resWalkleft(top, tt, xpos, ypos, NULL);
ylen = ypos-resWalkdown(bot,tt,xpos,ypos,NULL); ylen = ypos - resWalkdown(bot, tt, xpos, ypos, NULL);
if (xlen > ylen) if (xlen > ylen)
{ {
(void) resWalkdown(bot,tt,xpos,ypos,ResSplitX); (void) resWalkdown(bot,tt,xpos,ypos,ResSplitX);
@ -202,41 +206,45 @@ ResCheckConcavity(bot,top,tt)
} }
} }
if (resTopTile == NULL) return; if (resTopTile == NULL) return;
/* corner #3: /* corner #3:
XXXXXXX * XXXXXXX
YYYYYYY * YYYYYYY
^--here * ^--here
*/ */
if (LEFT(top) < LEFT(bot)) if (LEFT(top) < LEFT(bot))
{ {
for (tp = BL(bot);TOP(tp) < TOP(bot);tp=RT(tp)); for (tp = BL(bot); TOP(tp) < TOP(bot); tp = RT(tp));
if (TiGetType(tp) != tt) if (TiGetType(tp) != tt)
{ {
int xpos = LEFT(bot); int xpos = LEFT(bot);
int ypos = BOTTOM(top); int ypos = BOTTOM(top);
xlen = resWalkright(top,tt,xpos,ypos,NULL)- xpos; xlen = resWalkright(top, tt, xpos, ypos, NULL) - xpos;
ylen = resWalkup(top,tt,xpos,ypos,NULL) - ypos; ylen = resWalkup(top, tt, xpos, ypos, NULL) - ypos;
if (xlen > ylen) if (xlen > ylen)
{ {
(void) resWalkup(top,tt,xpos,ypos,ResSplitX); (void) resWalkup(top, tt, xpos, ypos, ResSplitX);
} }
} }
} }
if (resTopTile == NULL) return; if (resTopTile == NULL) return;
/* corner #4: /* corner #4:
v--here * v--here
XXXXXXX * XXXXXXX
YYYYYYY * YYYYYYY
*/ */
if (LEFT(top) > LEFT(bot) && TiGetType(BL(top)) != tt) if (LEFT(top) > LEFT(bot) && TiGetType(BL(top)) != tt)
{ {
int xpos = LEFT(top); int xpos = LEFT(top);
int ypos = BOTTOM(top); int ypos = BOTTOM(top);
xlen = resWalkright(top,tt,xpos,ypos,NULL)- xpos; xlen = resWalkright(top, tt, xpos, ypos, NULL) - xpos;
ylen = ypos-resWalkdown(bot,tt,xpos,ypos,NULL); ylen = ypos - resWalkdown(bot, tt, xpos, ypos, NULL);
if (xlen > ylen) if (xlen > ylen)
{ {
(void) resWalkdown(bot,tt,xpos,ypos,ResSplitX); (void) resWalkdown(bot, tt, xpos, ypos, ResSplitX);
} }
} }
} }
@ -259,7 +267,7 @@ ResCheckConcavity(bot,top,tt)
*/ */
int int
resWalkup(tile,tt,xpos,ypos,func) resWalkup(tile, tt, xpos, ypos, func)
Tile *tile; Tile *tile;
TileType tt; TileType tt;
int xpos,ypos; int xpos,ypos;
@ -275,8 +283,8 @@ resWalkup(tile,tt,xpos,ypos,func)
if (xpos == LEFT(tile)) if (xpos == LEFT(tile))
{ {
/* walk up left edge */ /* walk up left edge */
for (tp = BL(tile);TOP(tp) <= ypos;tp=RT(tp)); for (tp = BL(tile); TOP(tp) <= ypos; tp = RT(tp));
for (;BOTTOM(tp) < TOP(tile);tp=RT(tp)) for (; BOTTOM(tp) < TOP(tile); tp = RT(tp))
{ {
if (TiGetType(tp) != tt) return(BOTTOM(tp)); if (TiGetType(tp) != tt) return(BOTTOM(tp));
} }
@ -286,16 +294,16 @@ resWalkup(tile,tt,xpos,ypos,func)
if (func) tile = (*func)(tile,xpos); if (func) tile = (*func)(tile,xpos);
} }
pt.p_y = TOP(tile); pt.p_y = TOP(tile);
GOTOPOINT(tile,&pt); GOTOPOINT(tile, &pt);
} }
return(BOTTOM(tile)); return(BOTTOM(tile));
} }
int int
resWalkdown(tile,tt,xpos,ypos,func) resWalkdown(tile, tt, xpos, ypos, func)
Tile *tile; Tile *tile;
TileType tt; TileType tt;
int xpos,ypos; int xpos, ypos;
Tile * (*func)(); Tile * (*func)();
{ {
@ -310,7 +318,7 @@ resWalkdown(tile,tt,xpos,ypos,func)
{ {
/* walk up left edge */ /* walk up left edge */
endt = NULL; endt = NULL;
for (tp = BL(tile);BOTTOM(tp) < TOP(tile);tp=RT(tp)) for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp))
{ {
if (TiGetType(tp) != tt) if (TiGetType(tp) != tt)
{ {
@ -324,19 +332,19 @@ resWalkdown(tile,tt,xpos,ypos,func)
} }
else else
{ {
if (func) tile = (*func)(tile,xpos); if (func) tile = (*func)(tile, xpos);
} }
pt.p_y = BOTTOM(tile)-1; pt.p_y = BOTTOM(tile) - 1;
GOTOPOINT(tile,&pt); GOTOPOINT(tile, &pt);
} }
return(TOP(tile)); return(TOP(tile));
} }
int int
resWalkright(tile,tt,xpos,ypos,func) resWalkright(tile, tt, xpos, ypos, func)
Tile *tile; Tile *tile;
TileType tt; TileType tt;
int xpos,ypos; int xpos, ypos;
Tile * (*func)(); Tile * (*func)();
{ {
@ -349,27 +357,27 @@ resWalkright(tile,tt,xpos,ypos,func)
if (ypos == BOTTOM(tile)) if (ypos == BOTTOM(tile))
{ {
/* walk along bottom edge */ /* walk along bottom edge */
for (tp = LB(tile);LEFT(tp) < xpos;tp=TR(tp)); for (tp = LB(tile); LEFT(tp) < xpos; tp = TR(tp));
for (;LEFT(tp) < RIGHT(tile);tp=TR(tp)) for (; LEFT(tp) < RIGHT(tile); tp = TR(tp))
{ {
if (TiGetType(tp) != tt) return(LEFT(tp)); if (TiGetType(tp) != tt) return(LEFT(tp));
} }
} }
else else
{ {
if (func) tile = (*func)(tile,ypos); if (func) tile = (*func)(tile, ypos);
} }
pt.p_x = RIGHT(tile); pt.p_x = RIGHT(tile);
GOTOPOINT(tile,&pt); GOTOPOINT(tile, &pt);
} }
return(LEFT(tile)); return(LEFT(tile));
} }
int int
resWalkleft(tile,tt,xpos,ypos,func) resWalkleft(tile, tt, xpos, ypos, func)
Tile *tile; Tile *tile;
TileType tt; TileType tt;
int xpos,ypos; int xpos, ypos;
Tile * (*func)(); Tile * (*func)();
{ {
@ -384,7 +392,7 @@ resWalkleft(tile,tt,xpos,ypos,func)
{ {
/* walk along bottom edge */ /* walk along bottom edge */
endt = NULL; endt = NULL;
for (tp = LB(tile);LEFT(tp) < RIGHT(tile);tp=TR(tp)) for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp = TR(tp))
{ {
if (TiGetType(tp) != tt) if (TiGetType(tp) != tt)
{ {
@ -398,10 +406,10 @@ resWalkleft(tile,tt,xpos,ypos,func)
} }
else else
{ {
if (func) tile = (*func)(tile,ypos); if (func) tile = (*func)(tile, ypos);
} }
pt.p_x = LEFT(tile)-1; pt.p_x = LEFT(tile) - 1;
GOTOPOINT(tile,&pt); GOTOPOINT(tile, &pt);
} }
return(RIGHT(tile)); return(RIGHT(tile));
} }
@ -419,14 +427,15 @@ resWalkleft(tile,tt,xpos,ypos,func)
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
Tile * Tile *
ResSplitX(tile,x) ResSplitX(tile, x)
Tile *tile; Tile *tile;
int x; int x;
{ {
TileType tt = TiGetType(tile); TileType tt = TiGetType(tile);
Tile *tp = TiSplitX(tile,x); Tile *tp = TiSplitX(tile, x);
Tile *tp2; Tile *tp2;
TiSetBody(tp,tt); TiSetBody(tp,tt);
@ -437,13 +446,13 @@ ResSplitX(tile,x)
if (tp2 == resSrTile) if (tp2 == resSrTile)
{ {
if (resTopTile == tile) resTopTile = NULL; if (resTopTile == tile) resTopTile = NULL;
TiJoinY(tp2,tile,resFracPlane); TiJoinY(tp2, tile, resFracPlane);
tile = tp2; tile = tp2;
} }
else else
{ {
if (resTopTile == tp2) resTopTile = NULL; if (resTopTile == tp2) resTopTile = NULL;
TiJoinY(tile,tp2,resFracPlane); TiJoinY(tile, tp2, resFracPlane);
} }
} }
tp2 = LB(tile); tp2 = LB(tile);
@ -452,26 +461,26 @@ ResSplitX(tile,x)
if (tp2 == resSrTile) if (tp2 == resSrTile)
{ {
if (resTopTile == tile) resTopTile = NULL; if (resTopTile == tile) resTopTile = NULL;
TiJoinY(tp2,tile,resFracPlane); TiJoinY(tp2, tile, resFracPlane);
tile = tp2; tile = tp2;
} }
else else
{ {
if (resTopTile == tp2) resTopTile = NULL; if (resTopTile == tp2) resTopTile = NULL;
TiJoinY(tile,tp2,resFracPlane); TiJoinY(tile, tp2, resFracPlane);
} }
} }
/* do the same checks with the newly created tile */ /* do the same checks with the newly created tile */
tp2 = RT(tp); tp2 = RT(tp);
if (TiGetType(tp2) == tt && LEFT(tp2) == LEFT(tp) && RIGHT(tp2) == RIGHT(tp)) if (TiGetType(tp2) == tt && LEFT(tp2) == LEFT(tp) && RIGHT(tp2) == RIGHT(tp))
{ {
TiJoinY(tp2,tp,resFracPlane); TiJoinY(tp2, tp, resFracPlane);
tp = tp2; tp = tp2;
} }
tp2 = LB(tp); tp2 = LB(tp);
if (TiGetType(tp2) == tt && LEFT(tp2) == LEFT(tp) && RIGHT(tp2) == RIGHT(tp)) if (TiGetType(tp2) == tt && LEFT(tp2) == LEFT(tp) && RIGHT(tp2) == RIGHT(tp))
{ {
TiJoinY(tp2,tp,resFracPlane); TiJoinY(tp2, tp, resFracPlane);
} }
return tile; return tile;
} }

View File

@ -26,8 +26,6 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "textio/txcommands.h" #include "textio/txcommands.h"
#include "resis/resis.h" #include "resis/resis.h"
/* /*
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* *
@ -45,9 +43,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/ */
void void
ResNewSDDevice(tile,tp,xj,yj,direction,PendingList) ResNewSDDevice(tile, tp, xj, yj, direction, PendingList)
Tile *tile,*tp; Tile *tile, *tp;
int xj,yj,direction; int xj, yj, direction;
resNode **PendingList; resNode **PendingList;
{ {
resNode *resptr; resNode *resptr;
@ -90,11 +88,11 @@ ResNewSDDevice(tile,tp,xj,yj,direction,PendingList)
tcell = (tElement *) mallocMagic((unsigned)(sizeof(tElement))); tcell = (tElement *) mallocMagic((unsigned)(sizeof(tElement)));
tcell->te_nextt = NULL; tcell->te_nextt = NULL;
tcell->te_thist = j->deviceList; tcell->te_thist = j->deviceList;
InitializeNode(resptr,xj,yj,RES_NODE_DEVICE); InitializeNode(resptr, xj, yj, RES_NODE_DEVICE);
resptr->rn_te = tcell; resptr->rn_te = tcell;
ResAddToQueue(resptr,PendingList); ResAddToQueue(resptr, PendingList);
} }
NEWBREAK(resptr,tile,xj,yj,NULL); NEWBREAK(resptr, tile, xj, yj, NULL);
} }
/* /*
@ -114,7 +112,7 @@ ResNewSDDevice(tile,tp,xj,yj,direction,PendingList)
void void
ResProcessJunction(tile, tp, xj, yj, NodeList) ResProcessJunction(tile, tp, xj, yj, NodeList)
Tile *tile, *tp; Tile *tile, *tp;
int xj,yj; int xj, yj;
resNode **NodeList; resNode **NodeList;
{ {
ResJunction *junction; ResJunction *junction;
@ -135,9 +133,9 @@ ResProcessJunction(tile, tp, xj, yj, NodeList)
resptr->rn_te = (tElement *) NULL; resptr->rn_te = (tElement *) NULL;
junction = (ResJunction *) mallocMagic((unsigned)(sizeof(ResJunction))); junction = (ResJunction *) mallocMagic((unsigned)(sizeof(ResJunction)));
jcell = (jElement *) mallocMagic((unsigned)(sizeof(jElement))); jcell = (jElement *) mallocMagic((unsigned)(sizeof(jElement)));
InitializeNode(resptr,xj,yj,RES_NODE_JUNCTION); InitializeNode(resptr, xj, yj, RES_NODE_JUNCTION);
resptr->rn_je = jcell; resptr->rn_je = jcell;
ResAddToQueue(resptr,NodeList); ResAddToQueue(resptr, NodeList);
jcell->je_thisj = junction; jcell->je_thisj = junction;
jcell->je_nextj = NULL; jcell->je_nextj = NULL;
@ -152,10 +150,10 @@ ResProcessJunction(tile, tp, xj, yj, NodeList)
junction->rj_nextjunction[1] = j2->junctionList; junction->rj_nextjunction[1] = j2->junctionList;
j2->junctionList = junction; j2->junctionList = junction;
NEWBREAK(junction->rj_jnode,tile, NEWBREAK(junction->rj_jnode,tile, junction->rj_loc.p_x,
junction->rj_loc.p_x,junction->rj_loc.p_y,NULL); junction->rj_loc.p_y, NULL);
NEWBREAK(junction->rj_jnode,tp, NEWBREAK(junction->rj_jnode,tp, junction->rj_loc.p_x,
junction->rj_loc.p_x,junction->rj_loc.p_y,NULL); junction->rj_loc.p_y, NULL);
} }

View File

@ -574,18 +574,18 @@ ResProcessTiles(goodies, origin)
*/ */
bool bool
ResExtractNet(startlist, goodies, cellname) ResExtractNet(fix, goodies, cellname)
ResFixPoint *startlist; ResFixPoint *fix;
ResGlobalParams *goodies; ResGlobalParams *goodies;
char *cellname; char *cellname;
{ {
SearchContext scx; SearchContext scx;
int pNum; int pNum;
ResDevTile *DevTiles, *lasttile; ResDevTile *DevTiles;
TileTypeBitMask FirstTileMask; TileTypeBitMask FirstTileMask;
Point startpoint; Point startpoint;
ResFixPoint *fix;
static int first = 1; static int first = 1;
ResDevTile *newdevtiles, *tmp;
/* Make sure all global network variables are reset */ /* Make sure all global network variables are reset */
@ -601,7 +601,7 @@ ResExtractNet(startlist, goodies, cellname)
goodies->rg_maxres = 0; goodies->rg_maxres = 0;
goodies->rg_tilecount = 0; goodies->rg_tilecount = 0;
/*set up internal stuff if this is the first time through */ /* Set up internal stuff if this is the first time through */
if (first) if (first)
{ {
@ -640,10 +640,6 @@ ResExtractNet(startlist, goodies, cellname)
/* Copy Paint */ /* Copy Paint */
DevTiles = NULL; DevTiles = NULL;
lasttile = NULL;
for (fix = startlist; fix != NULL; fix = fix->fp_next)
{
ResDevTile *newdevtiles, *tmp;
#ifdef ARIEL #ifdef ARIEL
if ((ResOptionsFlags & ResOpt_Power) && if ((ResOptionsFlags & ResOpt_Power) &&
@ -663,20 +659,9 @@ ResExtractNet(startlist, goodies, cellname)
TTMaskZero(&FirstTileMask); TTMaskZero(&FirstTileMask);
TTMaskSetMask(&FirstTileMask, &DBConnectTbl[fix->fp_ttype]); TTMaskSetMask(&FirstTileMask, &DBConnectTbl[fix->fp_ttype]);
newdevtiles = DBTreeCopyConnectDCS(&scx, &FirstTileMask, 0, DevTiles = DBTreeCopyConnectDCS(&scx, &FirstTileMask, 0,
ResCopyMask, &TiPlaneRect, ResUse); ResCopyMask, &TiPlaneRect, ResUse);
for (tmp = newdevtiles; tmp && tmp->nextDev; tmp = tmp->nextDev);
if (newdevtiles)
{
if (DevTiles)
lasttile->nextDev = newdevtiles;
else
DevTiles = newdevtiles;
lasttile = tmp;
}
}
ExtResetTiles(scx.scx_use->cu_def, extUnInit); ExtResetTiles(scx.scx_use->cu_def, extUnInit);
/* Find all contacts in design and note their position */ /* Find all contacts in design and note their position */

View File

@ -53,9 +53,10 @@ extern ResSimNode *ResOriginalNodes; /*Linked List of Nodes */
int resNodeNum; int resNodeNum;
#ifdef LAPLACE #ifdef LAPLACE
int ResOptionsFlags = ResOpt_Simplify|ResOpt_Tdi|ResOpt_DoExtFile|ResOpt_CacheLaplace; int ResOptionsFlags = ResOpt_Simplify | ResOpt_Tdi | ResOpt_DoExtFile
| ResOpt_CacheLaplace;
#else #else
int ResOptionsFlags = ResOpt_Simplify|ResOpt_Tdi|ResOpt_DoExtFile; int ResOptionsFlags = ResOpt_Simplify | ResOpt_Tdi | ResOpt_DoExtFile;
#endif #endif
char *ResCurrentNode; char *ResCurrentNode;
@ -478,9 +479,10 @@ typedef enum {
gparams.rg_ttype = tt; gparams.rg_ttype = tt;
gparams.rg_status = DRIVEONLY; gparams.rg_status = DRIVEONLY;
oldoptions = ResOptionsFlags; oldoptions = ResOptionsFlags;
ResOptionsFlags = ResOpt_DoSubstrate|ResOpt_Signal|ResOpt_Box; ResOptionsFlags = ResOpt_DoSubstrate | ResOpt_Signal | ResOpt_Box;
#ifdef LAPLACE #ifdef LAPLACE
ResOptionsFlags |= (oldoptions & (ResOpt_CacheLaplace|ResOpt_DoLaplace)); ResOptionsFlags |= (oldoptions &
(ResOpt_CacheLaplace | ResOpt_DoLaplace));
LaplaceMatchCount = 0; LaplaceMatchCount = 0;
LaplaceMissCount = 0; LaplaceMissCount = 0;
#endif #endif
@ -488,13 +490,13 @@ typedef enum {
fp.fp_loc = rect.r_ll; fp.fp_loc = rect.r_ll;
fp.fp_next = NULL; fp.fp_next = NULL;
if (ResExtractNet(&fp, &gparams, NULL) != 0) return; if (ResExtractNet(&fp, &gparams, NULL) != 0) return;
ResPrintResistorList(stdout,ResResList); ResPrintResistorList(stdout, ResResList);
ResPrintDeviceList(stdout,ResRDevList); ResPrintDeviceList(stdout, ResRDevList);
#ifdef LAPLACE #ifdef LAPLACE
if (ResOptionsFlags & ResOpt_DoLaplace) if (ResOptionsFlags & ResOpt_DoLaplace)
{ {
TxPrintf("Laplace solved: %d matched %d\n", TxPrintf("Laplace solved: %d matched %d\n",
LaplaceMissCount,LaplaceMatchCount); LaplaceMissCount, LaplaceMatchCount);
} }
#endif #endif
@ -521,11 +523,11 @@ typedef enum {
return; return;
#endif #endif
case RES_AMBIG: case RES_AMBIG:
TxPrintf("Ambiguous option: %s\n",cmd->tx_argv[1]); TxPrintf("Ambiguous option: %s\n", cmd->tx_argv[1]);
TxFlushOut(); TxFlushOut();
return; return;
case RES_BAD: case RES_BAD:
TxPrintf("Unknown option: %s\n",cmd->tx_argv[1]); TxPrintf("Unknown option: %s\n", cmd->tx_argv[1]);
TxFlushOut(); TxFlushOut();
return; return;
default: default:
@ -610,8 +612,6 @@ resSubcircuitFunc(cellDef, rdata)
return 0; return 0;
} }
/* /*
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* *
@ -870,7 +870,7 @@ ResCheckSimNodes(celldef, resisdata)
} }
if (ResOptionsFlags & ResOpt_DoLumpFile) if (ResOptionsFlags & ResOpt_DoLumpFile)
{ {
ResLumpFile = PaOpen(outfile,"w",".res.lump",".",(char *) NULL, (char **) NULL); ResLumpFile = PaOpen(outfile, "w", ".res.lump", ".", (char *)NULL, (char **)NULL);
} }
else else
{ {
@ -879,7 +879,7 @@ ResCheckSimNodes(celldef, resisdata)
if (ResOptionsFlags & ResOpt_FastHenry) if (ResOptionsFlags & ResOpt_FastHenry)
{ {
char *geofilename; char *geofilename;
ResFHFile = PaOpen(outfile,"w",".fh",".",(char *) NULL, &geofilename); ResFHFile = PaOpen(outfile, "w", ".fh", ".", (char *)NULL, &geofilename);
TxPrintf("Writing FastHenry-format geometry file \"%s\"\n", geofilename); TxPrintf("Writing FastHenry-format geometry file \"%s\"\n", geofilename);
ResPortIndex = 0; ResPortIndex = 0;
} }
@ -1071,8 +1071,8 @@ ResCheckSimNodes(celldef, resisdata)
fp.fp_next = NULL; fp.fp_next = NULL;
if (ResExtractNet(&fp, &gparams, outfile) != 0) if (ResExtractNet(&fp, &gparams, outfile) != 0)
{ {
TxError("Error in extracting node %s\n",node->name); /* On error, don't output this net, but keep going */
// break; // Don't stop for one error. . . TxError("Error in extracting node %s\n", node->name);
} }
else else
{ {
@ -1091,7 +1091,7 @@ ResCheckSimNodes(celldef, resisdata)
} }
} }
#ifdef PARANOID #ifdef PARANOID
ResSanityChecks(node->name,ResResList,ResNodeList,ResDevList); ResSanityChecks(node->name, ResResList, ResNodeList, ResDevList);
#endif #endif
ResCleanUpEverything(); ResCleanUpEverything();
} }
@ -1104,7 +1104,7 @@ ResCheckSimNodes(celldef, resisdata)
if (ResOptionsFlags & ResOpt_DoExtFile) if (ResOptionsFlags & ResOpt_DoExtFile)
{ {
ResPrintExtDev(ResExtFile,ResRDevList); ResPrintExtDev(ResExtFile, ResRDevList);
} }
/* /*
@ -1427,9 +1427,10 @@ void
ResSortByGate(DevpointerList) ResSortByGate(DevpointerList)
devPtr **DevpointerList; devPtr **DevpointerList;
{ {
int changed=TRUE; int changed = TRUE;
int localchange=TRUE; int localchange = TRUE;
devPtr *working, *last=NULL, *current, *gatelist=NULL; devPtr *working, *current;
devPtr *last = NULL, *gatelist = NULL;
working = *DevpointerList; working = *DevpointerList;
while (working != NULL) while (working != NULL)
@ -1555,7 +1556,7 @@ ResWriteLumpFile(node)
{ {
lumpedres = gparams.rg_maxres; lumpedres = gparams.rg_maxres;
} }
fprintf(ResLumpFile,"R %s %d\n", node->name, lumpedres); fprintf(ResLumpFile, "R %s %d\n", node->name, lumpedres);
} }

View File

@ -63,13 +63,13 @@ ResFirst(tile, arg)
if (DBIsContact(t)) if (DBIsContact(t))
{ {
reg = (ResContactPoint *) mallocMagic((unsigned) (sizeof(ResContactPoint))); reg = (ResContactPoint *) mallocMagic((unsigned) (sizeof(ResContactPoint)));
reg->cp_center.p_x = (LEFT(tile)+RIGHT(tile))>>1; reg->cp_center.p_x = (LEFT(tile) + RIGHT(tile)) >> 1;
reg->cp_center.p_y = (TOP(tile)+BOTTOM(tile))>>1; reg->cp_center.p_y = (TOP(tile) + BOTTOM(tile)) >> 1;
reg->cp_status = FALSE; reg->cp_status = FALSE;
reg->cp_type = t; reg->cp_type = t;
reg->cp_width = RIGHT(tile)-LEFT(tile); reg->cp_width = RIGHT(tile) - LEFT(tile);
reg->cp_height = TOP(tile)-BOTTOM(tile); reg->cp_height = TOP(tile) - BOTTOM(tile);
for (i=0; i< LAYERS_PER_CONTACT; i++) for (i = 0; i < LAYERS_PER_CONTACT; i++)
{ {
reg->cp_tile[i] = (Tile *) NULL; reg->cp_tile[i] = (Tile *) NULL;
reg->cp_cnode[i] = (resNode *) NULL; reg->cp_cnode[i] = (resNode *) NULL;
@ -109,9 +109,9 @@ ResEach(tile, pNum, arg)
FindRegion *arg; FindRegion *arg;
{ {
if ( ((ResContactPoint *)(arg->fra_region))->cp_contactTile != tile) if (((ResContactPoint *)(arg->fra_region))->cp_contactTile != tile)
{ {
(void) ResFirst(tile, arg); ResFirst(tile, arg);
} }
return(0); return(0);
} }
@ -137,12 +137,11 @@ int
ResAddPlumbing(tile, arg) ResAddPlumbing(tile, arg)
Tile *tile; Tile *tile;
ClientData *arg; ClientData *arg;
{ {
tileJunk *Junk,*junk2; tileJunk *Junk, *junk2;
static Stack *resDevStack=NULL; static Stack *resDevStack = NULL;
TileType loctype, t1; TileType loctype, t1;
Tile *tp1,*tp2,*source; Tile *tp1, *tp2, *source;
resDevice *resDev; resDevice *resDev;
ExtDevice *devptr; ExtDevice *devptr;
@ -165,7 +164,7 @@ ResAddPlumbing(tile, arg)
/* Count SD terminals of the device */ /* Count SD terminals of the device */
nterms = 0; nterms = 0;
for (i = 0; ; i++) for (i = 0;; i++)
{ {
if (TTMaskIsZero(&(devptr->exts_deviceSDTypes[i]))) break; if (TTMaskIsZero(&(devptr->exts_deviceSDTypes[i]))) break;
nterms++; nterms++;
@ -181,7 +180,7 @@ ResAddPlumbing(tile, arg)
resDev = (resDevice *) mallocMagic((unsigned)(sizeof(resDevice))); resDev = (resDevice *) mallocMagic((unsigned)(sizeof(resDevice)));
resDev->rd_nterms = nterms; resDev->rd_nterms = nterms;
resDev->rd_terminals = (resNode **) mallocMagic(nterms * sizeof(resNode *)); resDev->rd_terminals = (resNode **) mallocMagic(nterms * sizeof(resNode *));
for (i=0; i != nterms;i++) for (i = 0; i != nterms; i++)
resDev->rd_terminals[i] = (resNode *) NULL; resDev->rd_terminals[i] = (resNode *) NULL;
resDev->rd_tile = tile; resDev->rd_tile = tile;
@ -205,7 +204,7 @@ ResAddPlumbing(tile, arg)
/* find diffusion (if present) to be source contact */ /* find diffusion (if present) to be source contact */
/* top */ /* top */
for (tp2= RT(tile); RIGHT(tp2) > LEFT(tile); tp2 = BL(tp2)) for (tp2 = RT(tile); RIGHT(tp2) > LEFT(tile); tp2 = BL(tp2))
{ {
if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),
TiGetBottomType(tp2)) TiGetBottomType(tp2))
@ -218,9 +217,9 @@ ResAddPlumbing(tile, arg)
} }
} }
/*bottom*/ /* bottom */
if (source == NULL) if (source == NULL)
for (tp2= LB(tile); LEFT(tp2) < RIGHT(tile); tp2 = TR(tp2)) for (tp2 = LB(tile); LEFT(tp2) < RIGHT(tile); tp2 = TR(tp2))
{ {
if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),
TiGetTopType(tp2)) TiGetTopType(tp2))
@ -233,9 +232,9 @@ ResAddPlumbing(tile, arg)
} }
} }
/*right*/ /* right */
if (source == NULL) if (source == NULL)
for (tp2= TR(tile); TOP(tp2) > BOTTOM(tile); tp2 = LB(tp2)) for (tp2 = TR(tile); TOP(tp2) > BOTTOM(tile); tp2 = LB(tp2))
{ {
if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),
TiGetLeftType(tp2)) TiGetLeftType(tp2))
@ -248,9 +247,9 @@ ResAddPlumbing(tile, arg)
} }
} }
/*left*/ /* left */
if (source == NULL) if (source == NULL)
for (tp2= BL(tile); BOTTOM(tp2) < TOP(tile); tp2 = RT(tp2)) for (tp2 = BL(tile); BOTTOM(tp2) < TOP(tile); tp2 = RT(tp2))
{ {
if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), if TTMaskHasType(&(devptr->exts_deviceSDTypes[0]),
TiGetRightType(tp2)) TiGetRightType(tp2))
@ -273,7 +272,7 @@ ResAddPlumbing(tile, arg)
if (source != (Tile *) NULL) if (source != (Tile *) NULL)
{ {
STACKPUSH((ClientData) (source),resDevStack); STACKPUSH((ClientData)source, resDevStack);
} }
while (!StackEmpty(resDevStack)) while (!StackEmpty(resDevStack))
{ {
@ -287,20 +286,20 @@ ResAddPlumbing(tile, arg)
t1 = TiGetTypeExact(tp1); t1 = TiGetTypeExact(tp1);
/* top */ /* top */
for (tp2= RT(tp1); RIGHT(tp2) > LEFT(tp1); tp2 = BL(tp2)) for (tp2 = RT(tp1); RIGHT(tp2) > LEFT(tp1); tp2 = BL(tp2))
{ {
if (TiGetBottomType(tp2) == t1) if (TiGetBottomType(tp2) == t1)
{ {
tileJunk *j= resAddField(tp2); tileJunk *j = resAddField(tp2);
if ((j->tj_status & RES_TILE_SD) ==0) if ((j->tj_status & RES_TILE_SD) ==0)
{ {
j->tj_status |= RES_TILE_SD; j->tj_status |= RES_TILE_SD;
STACKPUSH((ClientData)tp2,resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
/*bottom*/ /* bottom */
for (tp2= LB(tp1); LEFT(tp2) < RIGHT(tp1); tp2 = TR(tp2)) for (tp2 = LB(tp1); LEFT(tp2) < RIGHT(tp1); tp2 = TR(tp2))
{ {
if (TiGetTopType(tp2) == t1) if (TiGetTopType(tp2) == t1)
{ {
@ -308,12 +307,12 @@ ResAddPlumbing(tile, arg)
if ((j->tj_status & RES_TILE_SD) == 0) if ((j->tj_status & RES_TILE_SD) == 0)
{ {
j->tj_status |= RES_TILE_SD; j->tj_status |= RES_TILE_SD;
STACKPUSH((ClientData) (tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
/*right*/ /* right */
for (tp2= TR(tp1); TOP(tp2) > BOTTOM(tp1); tp2 = LB(tp2)) for (tp2 = TR(tp1); TOP(tp2) > BOTTOM(tp1); tp2 = LB(tp2))
{ {
if (TiGetLeftType(tp2) == t1) if (TiGetLeftType(tp2) == t1)
{ {
@ -321,12 +320,12 @@ ResAddPlumbing(tile, arg)
if ((j->tj_status & RES_TILE_SD) == 0) if ((j->tj_status & RES_TILE_SD) == 0)
{ {
j->tj_status |= RES_TILE_SD; j->tj_status |= RES_TILE_SD;
STACKPUSH((ClientData) (tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
/*left*/ /* left */
for (tp2= BL(tp1); BOTTOM(tp2) < TOP(tp1); tp2 = RT(tp2)) for (tp2 = BL(tp1); BOTTOM(tp2) < TOP(tp1); tp2 = RT(tp2))
{ {
if (TiGetRightType(tp2) == t1) if (TiGetRightType(tp2) == t1)
{ {
@ -334,7 +333,7 @@ ResAddPlumbing(tile, arg)
if ((j->tj_status & RES_TILE_SD) == 0) if ((j->tj_status & RES_TILE_SD) == 0)
{ {
j->tj_status |= RES_TILE_SD; j->tj_status |= RES_TILE_SD;
STACKPUSH((ClientData) (tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
@ -342,12 +341,12 @@ ResAddPlumbing(tile, arg)
/* find rest of device; search for source edges */ /* find rest of device; search for source edges */
STACKPUSH((ClientData) (tile), resDevStack); STACKPUSH((ClientData)tile, resDevStack);
while (!StackEmpty(resDevStack)) while (!StackEmpty(resDevStack))
{ {
tileJunk *j0; tileJunk *j0;
tp1= (Tile *) STACKPOP(resDevStack); tp1 = (Tile *) STACKPOP(resDevStack);
if (IsSplit(tp1)) if (IsSplit(tp1))
{ {
t1 = (SplitSide(tp1)) ? SplitRightType(tp1) : t1 = (SplitSide(tp1)) ? SplitRightType(tp1) :
@ -359,13 +358,13 @@ ResAddPlumbing(tile, arg)
devptr = ExtCurStyle->exts_device[t1]; devptr = ExtCurStyle->exts_device[t1];
j0 = (tileJunk *) tp1->ti_client; j0 = (tileJunk *) tp1->ti_client;
/* top */ /* top */
for (tp2= RT(tp1); RIGHT(tp2) > LEFT(tp1); tp2 = BL(tp2)) for (tp2 = RT(tp1); RIGHT(tp2) > LEFT(tp1); tp2 = BL(tp2))
{ {
if ((TiGetBottomType(tp2) == t1) && if ((TiGetBottomType(tp2) == t1) &&
(tp2->ti_client == (ClientData) CLIENTDEFAULT)) (tp2->ti_client == (ClientData) CLIENTDEFAULT))
{ {
Junk = resAddField(tp2); Junk = resAddField(tp2);
STACKPUSH((ClientData)(tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
Junk->deviceList = resDev; Junk->deviceList = resDev;
Junk->tj_status |= RES_TILE_DEV; Junk->tj_status |= RES_TILE_DEV;
@ -378,14 +377,14 @@ ResAddPlumbing(tile, arg)
j0->sourceEdge |= TOPEDGE; j0->sourceEdge |= TOPEDGE;
} }
} }
/*bottom*/ /* bottom */
for (tp2= LB(tp1); LEFT(tp2) < RIGHT(tp1); tp2 = TR(tp2)) for (tp2 = LB(tp1); LEFT(tp2) < RIGHT(tp1); tp2 = TR(tp2))
{ {
if ((TiGetTopType(tp2) == t1) && if ((TiGetTopType(tp2) == t1) &&
(tp2->ti_client == (ClientData) CLIENTDEFAULT)) (tp2->ti_client == (ClientData) CLIENTDEFAULT))
{ {
Junk = resAddField(tp2); Junk = resAddField(tp2);
STACKPUSH((ClientData)(tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
Junk->deviceList = resDev; Junk->deviceList = resDev;
Junk->tj_status |= RES_TILE_DEV; Junk->tj_status |= RES_TILE_DEV;
} }
@ -397,14 +396,14 @@ ResAddPlumbing(tile, arg)
j0->sourceEdge |= BOTTOMEDGE; j0->sourceEdge |= BOTTOMEDGE;
} }
} }
/*right*/ /* right */
for (tp2= TR(tp1); TOP(tp2) > BOTTOM(tp1); tp2 = LB(tp2)) for (tp2 = TR(tp1); TOP(tp2) > BOTTOM(tp1); tp2 = LB(tp2))
{ {
if ((TiGetLeftType(tp2) == t1) && if ((TiGetLeftType(tp2) == t1) &&
(tp2->ti_client == (ClientData) CLIENTDEFAULT)) (tp2->ti_client == (ClientData) CLIENTDEFAULT))
{ {
Junk = resAddField(tp2); Junk = resAddField(tp2);
STACKPUSH((ClientData)(tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
Junk->deviceList = resDev; Junk->deviceList = resDev;
Junk->tj_status |= RES_TILE_DEV; Junk->tj_status |= RES_TILE_DEV;
} }
@ -416,14 +415,14 @@ ResAddPlumbing(tile, arg)
j0->sourceEdge |= RIGHTEDGE; j0->sourceEdge |= RIGHTEDGE;
} }
} }
/*left*/ /* left */
for (tp2= BL(tp1); BOTTOM(tp2) < TOP(tp1); tp2 = RT(tp2)) for (tp2 = BL(tp1); BOTTOM(tp2) < TOP(tp1); tp2 = RT(tp2))
{ {
if ((TiGetRightType(tp2) == t1) && if ((TiGetRightType(tp2) == t1) &&
(tp2->ti_client == (ClientData) CLIENTDEFAULT)) (tp2->ti_client == (ClientData) CLIENTDEFAULT))
{ {
Junk = resAddField(tp2); Junk = resAddField(tp2);
STACKPUSH((ClientData)(tp2),resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
Junk->deviceList = resDev; Junk->deviceList = resDev;
Junk->tj_status |= RES_TILE_DEV; Junk->tj_status |= RES_TILE_DEV;
} }
@ -443,7 +442,7 @@ ResAddPlumbing(tile, arg)
{ {
tileJunk *j = (tileJunk *) source->ti_client; tileJunk *j = (tileJunk *) source->ti_client;
STACKPUSH((ClientData) (source),resDevStack); STACKPUSH((ClientData)source, resDevStack);
j->tj_status &= ~RES_TILE_SD; j->tj_status &= ~RES_TILE_SD;
} }
while (!StackEmpty(resDevStack)) while (!StackEmpty(resDevStack))
@ -458,7 +457,7 @@ ResAddPlumbing(tile, arg)
t1 = TiGetTypeExact(tp1); t1 = TiGetTypeExact(tp1);
/* top */ /* top */
for (tp2= RT(tp1); RIGHT(tp2) > LEFT(tp1); tp2 = BL(tp2)) for (tp2 = RT(tp1); RIGHT(tp2) > LEFT(tp1); tp2 = BL(tp2))
{ {
tileJunk *j2 = (tileJunk *) tp2->ti_client; tileJunk *j2 = (tileJunk *) tp2->ti_client;
if (TiGetBottomType(tp2) == t1) if (TiGetBottomType(tp2) == t1)
@ -466,12 +465,12 @@ ResAddPlumbing(tile, arg)
if (j2->tj_status & RES_TILE_SD) if (j2->tj_status & RES_TILE_SD)
{ {
j2->tj_status &= ~RES_TILE_SD; j2->tj_status &= ~RES_TILE_SD;
STACKPUSH((ClientData) tp2,resDevStack); STACKPUSH((ClientData)tp2 ,resDevStack);
} }
} }
} }
/*bottom*/ /* bottom */
for(tp2= LB(tp1); LEFT(tp2) < RIGHT(tp1); tp2 = TR(tp2)) for(tp2 = LB(tp1); LEFT(tp2) < RIGHT(tp1); tp2 = TR(tp2))
{ {
tileJunk *j2 = (tileJunk *) tp2->ti_client; tileJunk *j2 = (tileJunk *) tp2->ti_client;
if (TiGetTopType(tp2) == t1) if (TiGetTopType(tp2) == t1)
@ -479,12 +478,12 @@ ResAddPlumbing(tile, arg)
if (j2->tj_status & RES_TILE_SD) if (j2->tj_status & RES_TILE_SD)
{ {
j2->tj_status &= ~RES_TILE_SD; j2->tj_status &= ~RES_TILE_SD;
STACKPUSH((ClientData) tp2,resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
/*right*/ /* right */
for (tp2= TR(tp1); TOP(tp2) > BOTTOM(tp1); tp2 = LB(tp2)) for (tp2 = TR(tp1); TOP(tp2) > BOTTOM(tp1); tp2 = LB(tp2))
{ {
tileJunk *j2 = (tileJunk *) tp2->ti_client; tileJunk *j2 = (tileJunk *) tp2->ti_client;
if (TiGetLeftType(tp2) == t1) if (TiGetLeftType(tp2) == t1)
@ -492,12 +491,12 @@ ResAddPlumbing(tile, arg)
if (j2->tj_status & RES_TILE_SD) if (j2->tj_status & RES_TILE_SD)
{ {
j2->tj_status &= ~RES_TILE_SD; j2->tj_status &= ~RES_TILE_SD;
STACKPUSH((ClientData) tp2,resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
/*left*/ /* left */
for (tp2= BL(tp1); BOTTOM(tp2) < TOP(tp1); tp2 = RT(tp2)) for (tp2 = BL(tp1); BOTTOM(tp2) < TOP(tp1); tp2 = RT(tp2))
{ {
tileJunk *j2 = (tileJunk *) tp2->ti_client; tileJunk *j2 = (tileJunk *) tp2->ti_client;
if (TiGetRightType(tp2) == t1) if (TiGetRightType(tp2) == t1)
@ -505,7 +504,7 @@ ResAddPlumbing(tile, arg)
if (j2->tj_status & RES_TILE_SD) if (j2->tj_status & RES_TILE_SD)
{ {
j2->tj_status &= ~RES_TILE_SD; j2->tj_status &= ~RES_TILE_SD;
STACKPUSH((ClientData) tp2,resDevStack); STACKPUSH((ClientData)tp2, resDevStack);
} }
} }
} }
@ -627,7 +626,7 @@ ResPreProcessDevices(TileList, DeviceList, Def)
freeMagic((char *)oldTile); freeMagic((char *)oldTile);
} }
for(; DeviceList != NULL;DeviceList = DeviceList->rd_nextDev) for (; DeviceList != NULL;DeviceList = DeviceList->rd_nextDev)
{ {
int width = DeviceList->rd_perim; int width = DeviceList->rd_perim;
int length = DeviceList->rd_length; int length = DeviceList->rd_length;
@ -666,18 +665,17 @@ ResPreProcessDevices(TileList, DeviceList, Def)
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
void
ResAddToQueue(node,list)
resNode *node,**list;
{
void
ResAddToQueue(node, list)
resNode *node, **list;
{
node->rn_more = *list; node->rn_more = *list;
node->rn_less = NULL; node->rn_less = NULL;
if (*list) (*list)->rn_less = node; if (*list) (*list)->rn_less = node;
*list = node; *list = node;
} }
/* /*
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* *
@ -692,11 +690,9 @@ ResAddToQueue(node,list)
*/ */
void void
ResRemoveFromQueue(node,list) ResRemoveFromQueue(node, list)
resNode *node,**list; resNode *node, **list;
{ {
if (node->rn_less != NULL) if (node->rn_less != NULL)
{ {
node->rn_less->rn_more = node->rn_more; node->rn_less->rn_more = node->rn_more;
@ -719,13 +715,13 @@ ResRemoveFromQueue(node,list)
node->rn_more = NULL; node->rn_more = NULL;
node->rn_less = NULL; node->rn_less = NULL;
} }
tileJunk * tileJunk *
resAddField(tile) resAddField(tile)
Tile *tile; Tile *tile;
{ {
tileJunk *Junk; tileJunk *Junk;
if ((Junk=(tileJunk *)tile->ti_client) == (tileJunk *) CLIENTDEFAULT) if ((Junk = (tileJunk *)tile->ti_client) == (tileJunk *) CLIENTDEFAULT)
{ {
Junk = (tileJunk *) mallocMagic((unsigned) (sizeof(tileJunk))); Junk = (tileJunk *) mallocMagic((unsigned) (sizeof(tileJunk)));
ResJunkInit(Junk); ResJunkInit(Junk);

View File

@ -47,16 +47,15 @@ ResPrintNetwork(filename, reslist)
resResistor *reslist; resResistor *reslist;
{ {
char bigname[255],name1[255],name2[255]; char bigname[255], name1[255], name2[255];
FILE *fp; FILE *fp;
int i=1; int i = 1;
sprintf(bigname,"%s.%s",filename,"res"); sprintf(bigname, "%s.%s", filename, "res");
fp = fopen(bigname,"w"); fp = fopen(bigname, "w");
if (fp != NULL) if (fp != NULL)
{ {
for (;reslist;reslist=reslist->rr_nextResistor) for (; reslist; reslist = reslist->rr_nextResistor)
{ {
if (reslist->rr_connection1->rn_id == 0) if (reslist->rr_connection1->rn_id == 0)
{ {
@ -68,11 +67,11 @@ ResPrintNetwork(filename, reslist)
} }
if (reslist->rr_connection1->rn_why == RES_NODE_ORIGIN) if (reslist->rr_connection1->rn_why == RES_NODE_ORIGIN)
{ {
sprintf(name1,"gnd"); sprintf(name1, "gnd");
} }
else else
{ {
sprintf(name1,"n%d_%d_%d", sprintf(name1, "n%d_%d_%d",
reslist->rr_connection1->rn_id, reslist->rr_connection1->rn_id,
reslist->rr_connection1->rn_loc.p_x, reslist->rr_connection1->rn_loc.p_x,
reslist->rr_connection1->rn_loc.p_y); reslist->rr_connection1->rn_loc.p_y);
@ -83,20 +82,20 @@ ResPrintNetwork(filename, reslist)
} }
else else
{ {
sprintf(name2,"n%d_%d_%d", sprintf(name2, "n%d_%d_%d",
reslist->rr_connection2->rn_id, reslist->rr_connection2->rn_id,
reslist->rr_connection2->rn_loc.p_x, reslist->rr_connection2->rn_loc.p_x,
reslist->rr_connection2->rn_loc.p_y); reslist->rr_connection2->rn_loc.p_y);
} }
fprintf(fp,"r %s %s %f\n",name1,name2, fprintf(fp, "r %s %s %f\n", name1, name2,
(float)(reslist->rr_value)*MILLITOKILO); (float)(reslist->rr_value) * MILLITOKILO);
} }
} }
fclose(fp); fclose(fp);
} }
void void
ResPrintCurrents(filename,extension,node) ResPrintCurrents(filename, extension, node)
char *filename; char *filename;
float extension; float extension;
resNode *node; resNode *node;
@ -106,19 +105,18 @@ ResPrintCurrents(filename,extension,node)
FILE *fp; FILE *fp;
int resCurrentPrintFunc(); int resCurrentPrintFunc();
sprintf(bigname,"%s.%d",filename,abs((int)(extension))); sprintf(bigname, "%s.%d", filename, abs((int)(extension)));
fp = fopen(bigname,"w"); fp = fopen(bigname, "w");
if (fp != NULL) if (fp != NULL)
{ {
(void) ResTreeWalk(node,NULL,resCurrentPrintFunc, (void) ResTreeWalk(node, NULL, resCurrentPrintFunc,
RES_DO_FIRST,RES_NO_LOOP,RES_NO_FLAGS,fp); RES_DO_FIRST, RES_NO_LOOP, RES_NO_FLAGS, fp);
} }
fclose(fp); fclose(fp);
} }
/* /*
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* *
@ -130,17 +128,17 @@ ResPrintCurrents(filename,extension,node)
*/ */
void void
resCurrentPrintFunc(node,resistor,filename) resCurrentPrintFunc(node, resistor, filename)
resNode *node; resNode *node;
resResistor *resistor; resResistor *resistor;
FILE *filename; FILE *filename;
{ {
tElement *workingDev; tElement *workingDev;
float i_sum=0.0; float i_sum = 0.0;
for (workingDev = node->rn_te; workingDev != NULL; for (workingDev = node->rn_te; workingDev != NULL;
workingDev=workingDev->te_nextt) workingDev = workingDev->te_nextt)
{ {
if ((workingDev->te_thist->rd_status & RES_DEV_PLUG) || if ((workingDev->te_thist->rd_status & RES_DEV_PLUG) ||
workingDev->te_thist->rd_gate != node) workingDev->te_thist->rd_gate != node)
@ -150,16 +148,14 @@ resCurrentPrintFunc(node,resistor,filename)
{ {
if (node->rn_why == RES_NODE_ORIGIN) if (node->rn_why == RES_NODE_ORIGIN)
{ {
fprintf(filename,"i gnd %f\n",i_sum); fprintf(filename, "i gnd %f\n", i_sum);
} }
else else
{ {
fprintf(filename,"i n%d_%d %f\n",node->rn_loc.p_x, fprintf(filename, "i n%d_%d %f\n", node->rn_loc.p_x,
node->rn_loc.p_y,i_sum); node->rn_loc.p_y, i_sum);
} }
} }
} }
void void
@ -170,60 +166,60 @@ ResDeviceCounts()
resDevice *t; resDevice *t;
resResistor *r; resResistor *r;
for (n=ResNodeList,i=0;n!=NULL;n=n->rn_more,i++); for (n = ResNodeList, i = 0; n != NULL; n = n->rn_more, i++);
for (t=ResDevList,j=0;t!=NULL;t=t->rd_nextDev,j++); for (t = ResDevList, j = 0; t != NULL; t = t->rd_nextDev, j++);
for (r=ResResList,k=0;r!=NULL;r=r->rr_nextResistor,k++); for (r = ResResList, k = 0; r != NULL; r = r->rr_nextResistor, k++);
TxError("n=%d t=%d r=%d\n",i,j,k); TxError("n=%d t=%d r=%d\n", i, j, k);
TxFlushErr(); TxFlushErr();
} }
void void
ResWriteECLFile(filename,reslist,nodelist) ResWriteECLFile(filename, reslist, nodelist)
char *filename; char *filename;
resResistor *reslist; resResistor *reslist;
resNode *nodelist; resNode *nodelist;
{ {
char newname[100],*tmpname,*per; char newname[100], *tmpname, *per;
FILE *fp; FILE *fp;
int nodenum = 0; int nodenum = 0;
strcpy(newname,filename); strcpy(newname, filename);
if (per = strrchr(newname,'.')) *per = '\0'; if (per = strrchr(newname,'.')) *per = '\0';
strcat(newname,".res"); strcat(newname, ".res");
if ((fp = fopen(newname,"w")) == NULL) if ((fp = fopen(newname, "w")) == NULL)
{ {
TxError("Can't open %s\n",newname); TxError("Can't open %s\n", newname);
return; return;
} }
for (;nodelist;nodelist=nodelist->rn_more) for (; nodelist; nodelist = nodelist->rn_more)
{ {
if (nodelist->rn_name == NULL) if (nodelist->rn_name == NULL)
{ {
if (nodelist->rn_noderes == 0) if (nodelist->rn_noderes == 0)
{ {
strcpy(newname,"gnd"); strcpy(newname, "gnd");
} }
else else
{ {
(void)sprintf(newname,"n%d_%d_%d",nodelist->rn_loc.p_x, (void)sprintf(newname, "n%d_%d_%d", nodelist->rn_loc.p_x,
nodelist->rn_loc.p_y,nodenum++); nodelist->rn_loc.p_y, nodenum++);
} }
tmpname = (char *) mallocMagic((unsigned) (strlen(newname)+1)); tmpname = (char *)mallocMagic((unsigned) (strlen(newname) + 1));
strcpy(tmpname,newname); strcpy(tmpname, newname);
nodelist->rn_name = tmpname; nodelist->rn_name = tmpname;
} }
} }
for (;reslist;reslist = reslist->rr_nextResistor) for (; reslist; reslist = reslist->rr_nextResistor)
{ {
fprintf(fp, "r %s %s %f %s %d\n",
fprintf(fp,"r %s %s %f %s %d\n", reslist->rr_node[0]->rn_name,
reslist->rr_node[0]->rn_name,reslist->rr_node[1]->rn_name, reslist->rr_node[1]->rn_name,
/* /1000.0 gets ohms from milliohms */ /* /1000.0 gets ohms from milliohms */
(float)(reslist->rr_value)/1000.0, (float)(reslist->rr_value) / 1000.0,
DBTypeShortName(reslist->rr_tt),reslist->rr_csArea); DBTypeShortName(reslist->rr_tt), reslist->rr_csArea);
} }
fclose(fp); fclose(fp);
} }