diff --git a/VERSION b/VERSION index fd696242..90d348e0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.174 +8.3.175 diff --git a/calma/CalmaRead.c b/calma/CalmaRead.c index 64139209..c9b300d2 100644 --- a/calma/CalmaRead.c +++ b/calma/CalmaRead.c @@ -46,6 +46,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include "textio/textio.h" #include "calma/calmaInt.h" #include "commands/commands.h" /* for CmdGetRootPoint */ +#include "utils/main.h" /* for EditCellUse */ #include "utils/undo.h" /* Globals for Calma reading */ @@ -167,7 +168,7 @@ CalmaReadFile(file, filename) if (EditCellUse == (CellUse *)NULL) { TxError("Cannot read GDS: There is no edit cell.\n"); - return + return; } /* We will use full cell names as keys in this hash table */ diff --git a/ext2sim/ext2sim.c b/ext2sim/ext2sim.c index 9ef866c8..507dd1ea 100644 --- a/ext2sim/ext2sim.c +++ b/ext2sim/ext2sim.c @@ -1206,9 +1206,6 @@ simdevVisit(dev, hc, scale, trans) /* Output length, width, and position as attributes */ fprintf(esSimF, " l=%g w=%g x=%g y=%g", l * scale, w * scale, r.r_xbot * scale, r.r_ybot * scale); - - /* Output tile type as an attribute for quick lookup by ResReadSim */ - fprintf(esSimF, " t=%d", fetInfo[dev->dev_type].devType); } else if ((dev->dev_class != DEV_DIODE) && (dev->dev_class != DEV_PDIODE) && (dev->dev_class != DEV_NDIODE)) { diff --git a/resis/Makefile b/resis/Makefile index 9cba56fd..18e0fe40 100644 --- a/resis/Makefile +++ b/resis/Makefile @@ -5,7 +5,7 @@ MODULE = resis MAGICDIR = .. SRCS = ResMain.c ResJunct.c ResMakeRes.c ResSimple.c ResPrint.c \ - ResReadSim.c ResConDCS.c ResRex.c ResBasic.c ResMerge.c ResChecks.c \ + ResReadSim.c ResRex.c ResBasic.c ResMerge.c ResChecks.c \ ResFract.c ResUtils.c ResDebug.c include ${MAGICDIR}/defs.mak diff --git a/resis/ResConDCS.c b/resis/ResConDCS.c deleted file mode 100644 index fb8c695f..00000000 --- a/resis/ResConDCS.c +++ /dev/null @@ -1,535 +0,0 @@ -/* ResConnectDCS.c -- - * - * This contains a slightly modified version of DBTreeCopyConnect. - */ - -#ifndef lint -static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/resis/ResConDCS.c,v 1.5 2010/06/24 12:37:56 tim Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include - -#include "utils/magic.h" -#include "utils/geometry.h" -#include "utils/geofast.h" -#include "tiles/tile.h" -#include "utils/hash.h" -#include "utils/stack.h" -#include "database/database.h" -#include "utils/malloc.h" -#include "textio/textio.h" -#include "extract/extract.h" -#include "extract/extractInt.h" -#include "utils/signals.h" -#include "windows/windows.h" -#include "dbwind/dbwind.h" -#include "utils/tech.h" -#include "textio/txcommands.h" -#include "resis/resis.h" - -extern int dbcUnconnectFunc(); -extern int dbcConnectLabelFunc(); -extern int dbcConnectFuncDCS(); -#ifdef ARIEL -extern int resSubSearchFunc(); -#endif - -static ResDevTile *DevList = NULL; -static TileTypeBitMask DiffTypeBitMask; -TileTypeBitMask ResSubsTypeBitMask; - -/* Forward declarations */ -extern void ResCalcPerimOverlap(); - -/* - * ---------------------------------------------------------------------------- - * - * dbcConnectFuncDCS -- the same as dbcConnectFunc, except that it does - * some extra searching around diffusion tiles looking for - * devices. - * - * Results: - * Always returns 0 to keep the search from aborting. - * - * Side effects: - * Adds a new record to the current check list. May also add new - * ResDevTile structures. - * - * ---------------------------------------------------------------------------- - */ - -int -dbcConnectFuncDCS(tile, cx) - Tile *tile; - TreeContext *cx; -{ - struct conSrArg2 *csa2; - Rect tileArea, *srArea, devArea, newarea; - ResDevTile *thisDev; - TileTypeBitMask notConnectMask, *connectMask; - Tile *tp; - TileType t2, t1, loctype, ctype; - TileType dinfo = 0; - SearchContext *scx = cx->tc_scx; - SearchContext scx2; - int i, pNum; - CellDef *def; - ExtDevice *devptr; - TerminalPath tpath; - char pathstring[FLATTERMSIZE]; - - TiToRect(tile, &tileArea); - srArea = &scx->scx_area; - - if (((tileArea.r_xbot >= srArea->r_xtop - 1) || - (tileArea.r_xtop <= srArea->r_xbot + 1)) && - ((tileArea.r_ybot >= srArea->r_ytop - 1) || - (tileArea.r_ytop <= srArea->r_ybot + 1))) - return 0; - - t1 = TiGetType(tile); - if TTMaskHasType(&DiffTypeBitMask, t1) - { - /* left */ - for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp)) - { - t2 = TiGetType(tp); - devptr = ExtCurStyle->exts_device[t2]; - if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) && - TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1)) - { - TiToRect(tp, &devArea); - thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); - GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area); - thisDev->type = TiGetType(tp); - thisDev->nextDev = DevList; - DevList = thisDev; - ResCalcPerimOverlap(thisDev, tp); - } - } - - /* right */ - for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp)) - { - t2 = TiGetType(tp); - devptr = ExtCurStyle->exts_device[t2]; - if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) && - TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1)) - { - TiToRect(tp, &devArea); - thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); - GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area); - thisDev->type = TiGetType(tp); - thisDev->nextDev = DevList; - DevList = thisDev; - ResCalcPerimOverlap(thisDev, tp); - } - } - - /* top */ - for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp)) - { - t2 = TiGetType(tp); - devptr = ExtCurStyle->exts_device[t2]; - if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) && - TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1)) - { - TiToRect(tp, &devArea); - thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); - GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area); - thisDev->type = TiGetType(tp); - thisDev->nextDev = DevList; - DevList = thisDev; - ResCalcPerimOverlap(thisDev, tp); - } - } - - /* bottom */ - for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp = TR(tp)) - { - t2 = TiGetType(tp); - devptr = ExtCurStyle->exts_device[t2]; - if (TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t2) && - TTMaskHasType(&(devptr->exts_deviceSDTypes[0]), t1)) - { - TiToRect(tp, &devArea); - thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); - GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area); - thisDev->type = TiGetType(tp); - thisDev->nextDev = DevList; - DevList = thisDev; - ResCalcPerimOverlap(thisDev, tp); - } - } - } - else if TTMaskHasType(&(ExtCurStyle->exts_deviceMask), t1) - { - TiToRect(tile, &devArea); - thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); - ResCalcPerimOverlap(thisDev,tile); - GeoTransRect(&scx->scx_trans, &devArea, &thisDev->area); - thisDev->type = TiGetType(tile); - thisDev->nextDev = DevList; - DevList = thisDev; - } - - /* in some cases (primarily bipolar technology), we'll want to extract - * devices whose substrate terminals are part of the given region. - * The following does that check. (10-11-88) - */ -#ifdef ARIEL - if (TTMaskHasType(&ResSubsTypeBitMask,t1) && (ResOptionsFlags & ResOpt_DoSubstrate)) - { - TileTypeBitMask *mask = &ExtCurStyle->exts_subsTransistorTypes[t1]; - - for (pNum = PL_TECHDEPBASE; pNum < DBNumPlanes; pNum++) - { - if (TTMaskIntersect(&DBPlaneTypes[pNum], mask)) - { - DBSrPaintArea((Tile *) NULL, - scx->scx_use->cu_def->cd_planes[pNum], - &tileArea, mask, resSubSearchFunc, (ClientData)cx); - } - } - } -#endif - GeoTransRect(&scx->scx_trans, &tileArea, &newarea); - - csa2 = (struct conSrArg2 *)cx->tc_filter->tf_arg; - GeoClip(&newarea, csa2->csa2_bounds); - if (GEO_RECTNULL(&newarea)) return 0; - - loctype = TiGetTypeExact(tile); - - /* Resolve geometric transformations on diagonally-split tiles */ - - if (IsSplit(tile)) - { - dinfo = DBTransformDiagonal(loctype, &scx->scx_trans); - loctype = (SplitSide(tile)) ? SplitRightType(tile) : SplitLeftType(tile); - } - - pNum = cx->tc_plane; - connectMask = &csa2->csa2_connect[loctype]; - - if (DBIsContact(loctype)) - { - /* The mask of contact types must include all stacked contacts */ - - TTMaskZero(¬ConnectMask); - TTMaskSetMask(¬ConnectMask, &DBNotConnectTbl[loctype]); - } - else - { - TTMaskCom2(¬ConnectMask, connectMask); - } - - def = csa2->csa2_use->cu_def; - - if (DBSrPaintNMArea((Tile *) NULL, def->cd_planes[pNum], - dinfo, &newarea, ¬ConnectMask, dbcUnconnectFunc, - (ClientData)NULL) == 0) - return 0; - - DBNMPaintPlane(def->cd_planes[pNum], dinfo, - &newarea, DBStdPaintTbl(loctype, pNum), - (PaintUndoInfo *) NULL); - - /* Check the source def for any labels belonging to this */ - /* tile area and plane, and add them to the destination */ - - scx2 = *csa2->csa2_topscx; - scx2.scx_area = newarea; - - pathstring[0] = '\0'; - tpath.tp_first = tpath.tp_next = pathstring; - tpath.tp_last = pathstring + FLATTERMSIZE; - - DBTreeSrLabels(&scx2, connectMask, csa2->csa2_xMask, &tpath, - TF_LABEL_ATTACH, dbcConnectLabelFunc, - (ClientData)csa2); - - /* Only extend those sides bordering the diagonal tile */ - - if (dinfo & TT_DIAGONAL) - { - if (dinfo & TT_SIDE) /* right */ - newarea.r_xtop += 1; - else /* left */ - newarea.r_xbot -= 1; - if (((dinfo & TT_SIDE) >> 1) - == (dinfo & TT_DIRECTION)) /* top */ - newarea.r_ytop += 1; - else /* bottom */ - newarea.r_ybot -= 1; - } - else - { - newarea.r_xbot -= 1; - newarea.r_ybot -= 1; - newarea.r_xtop += 1; - newarea.r_ytop += 1; - } - - /* Check if any of the last 5 entries has the same type and */ - /* area. If so, don't duplicate the existing entry. */ - /* (NOTE: Connect masks are all from the same table, so */ - /* they can be compared by address, no need for TTMaskEqual)*/ - - for (i = csa2->csa2_lasttop; (i >= 0) && (i > csa2->csa2_lasttop - 5); i--) - if (connectMask == csa2->csa2_list[i].connectMask) - if (GEO_SURROUND(&csa2->csa2_list[i].area, &newarea)) - return 0; - - /* Register the area and connection mask as needing to be processed */ - - if (++csa2->csa2_top == CSA2_LIST_SIZE) - { - /* Reached list size limit---need to enlarge the list */ - /* Double the size of the list every time we hit the limit */ - - conSrArea *newlist; - - newlist = (conSrArea *)mallocMagic(CSA2_LIST_SIZE * sizeof(conSrArea)); - StackPush((ClientData)csa2->csa2_list, csa2->csa2_stack); - csa2->csa2_list = newlist; - csa2->csa2_top = 0; - } - - csa2->csa2_list[csa2->csa2_top].area = newarea; - csa2->csa2_list[csa2->csa2_top].connectMask = connectMask; - csa2->csa2_list[csa2->csa2_top].dinfo = dinfo; - - return 0; -} - - -/* - *------------------------------------------------------------------------- - * - * ResCalcPerimOverlap-- - * - * Results: - * None. - * - * Side Effects: - * - *------------------------------------------------------------------------- - */ - -void -ResCalcPerimOverlap(dev, tile) - ResDevTile *dev; - Tile *tile; -{ - Tile *tp; - int t1; - int overlap; - - dev->perim = (TOP(tile) - BOTTOM(tile) - LEFT(tile) + RIGHT(tile)) << 1; - overlap =0; - - t1 = TiGetType(tile); - - /* left */ - for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp)) - { - if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp)) - overlap += MIN(TOP(tile), TOP(tp)) - - MAX(BOTTOM(tile), BOTTOM(tp)); - } - - /* right */ - for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp)) - { - if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp)) - overlap += MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp)); - } - - /* top */ - for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp)) - { - if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp)) - overlap += MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp)); - } - - /* bottom */ - for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp=TR(tp)) - { - if TTMaskHasType(&(ExtCurStyle->exts_nodeConn[t1]), TiGetType(tp)) - overlap += MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp)); - } - dev->overlap = overlap; -} - - -/* - * ---------------------------------------------------------------------------- - * - * DBTreeCopyConnectDCS -- - * - * Basically the same as DBTreeCopyConnect, except it calls - * dbcConnectFuncDCS. - * - * Results: - * Linked list of devices. - * - * Side effects: - * The contents of the result cell are modified. - * - * ---------------------------------------------------------------------------- - */ - -ResDevTile * -DBTreeCopyConnectDCS(scx, mask, xMask, connect, area, destUse) - SearchContext *scx; - TileTypeBitMask *mask; - int xMask; - TileTypeBitMask *connect; - Rect *area; - CellUse *destUse; - -{ - static int first = 1; - struct conSrArg2 csa2; - int dev, pNum; - char *dev_name; - TileTypeBitMask *newmask; - ResDevTile *CurrentT; - CellDef *def = destUse->cu_def; - TileType newtype; - ExtDevice *devptr; - - csa2.csa2_use = destUse; - csa2.csa2_xMask = xMask; - csa2.csa2_bounds = area; - csa2.csa2_connect = connect; - csa2.csa2_topscx = scx; - - csa2.csa2_list = (conSrArea *)mallocMagic(CSA2_LIST_SIZE * sizeof(conSrArea)); - csa2.csa2_top = -1; - csa2.csa2_lasttop = -1; - - csa2.csa2_stack = StackNew(100); - - if (first) - { - TTMaskZero(&DiffTypeBitMask); - TTMaskZero(&ResSubsTypeBitMask); - for (dev = TT_TECHDEPBASE; dev < TT_MAXTYPES; dev++) - { - devptr = ExtCurStyle->exts_device[dev]; - if ((devptr != NULL) && ((dev_name = devptr->exts_deviceName) != NULL) - && (strcmp(dev_name, "None"))) - { - TTMaskSetMask(&DiffTypeBitMask, - &(devptr->exts_deviceSDTypes[0])); - TTMaskSetMask(&ResSubsTypeBitMask, - &(devptr->exts_deviceSubstrateTypes)); - } - } - first = 0; - } - - DevList = NULL; - DBTreeSrTiles(scx, mask, xMask, dbcConnectFuncDCS, (ClientData) &csa2); - while (csa2.csa2_top >= 0) - { - newmask = csa2.csa2_list[csa2.csa2_top].connectMask; - scx->scx_area = csa2.csa2_list[csa2.csa2_top].area; - newtype = csa2.csa2_list[csa2.csa2_top].dinfo; - if (csa2.csa2_top == 0) - { - if (StackLook(csa2.csa2_stack) != (ClientData)NULL) - { - freeMagic(csa2.csa2_list); - csa2.csa2_list = (conSrArea *)StackPop(csa2.csa2_stack); - csa2.csa2_top = CSA2_LIST_SIZE - 1; - } - else - csa2.csa2_top--; - } - else - csa2.csa2_top--; - - csa2.csa2_lasttop = csa2.csa2_top; - - if (newtype & TT_DIAGONAL) - DBTreeSrNMTiles(scx, newtype, newmask, xMask, dbcConnectFuncDCS, - (ClientData) &csa2); - else - DBTreeSrTiles(scx, newmask, xMask, dbcConnectFuncDCS, (ClientData) &csa2); - } - freeMagic((char *)csa2.csa2_list); - StackFree(csa2.csa2_stack); - - for (CurrentT = DevList; CurrentT != NULL; CurrentT=CurrentT->nextDev) - { - TileType t = CurrentT->type; - TileType nt; - TileTypeBitMask *residues = DBResidueMask(t); - - for (nt = TT_TECHDEPBASE; nt < DBNumTypes; nt++) - { - if (TTMaskHasType(residues, nt)) - { - pNum = DBPlane(nt); - DBPaintPlane(def->cd_planes[pNum], &CurrentT->area, - DBStdPaintTbl(nt, pNum), (PaintUndoInfo *) NULL); - } - } - } - - DBReComputeBbox(def); - return(DevList); -} - - -#ifdef ARIEL -/* - *------------------------------------------------------------------------- - * - * resSubSearchFunc -- - * - * called when DBSrPaintArea finds a device within - * a substrate area. - * - * Results: - * Always return 0 to keep the search alive. - * - * Side Effects: - * - *------------------------------------------------------------------------- - */ - -int -resSubSearchFunc(tile, cx) - Tile *tile; - TreeContext *cx; -{ - ResDevTile *thisDev; - Rect devArea; - TileType t = TiGetType(tile); - ExtDevice *devptr; - - /* Right now, we're only going to extract substrate terminals for - * devices with only one diffusion terminal, principally bipolar - * devices. - */ - devptr = ExtCurStyle->exts_device[t]; - if (devptr->exts_deviceSDCount > 1) return 0; - TiToRect(tile, &devArea); - thisDev = (ResDevTile *) mallocMagic((unsigned)(sizeof(ResDevTile))); - GeoTransRect(&cx->tc_scx->scx_trans, &devArea, &thisDev->area); - thisDev->type = t; - thisDev->nextDev = DevList; - DevList = thisDev; - ResCalcPerimOverlap(thisDev, tile); - - return 0; -} - -#endif /* ARIEL */ diff --git a/resis/ResMain.c b/resis/ResMain.c index 2ceaefb6..f338d7fc 100644 --- a/resis/ResMain.c +++ b/resis/ResMain.c @@ -20,6 +20,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include "windows/windows.h" #include "dbwind/dbwind.h" #include "utils/tech.h" +#include "select/select.h" #include "textio/txcommands.h" #include "resis/resis.h" @@ -560,7 +561,103 @@ ResProcessTiles(goodies, origin) return(0); } -/*------------------------------------------------------------------------- +/* + *------------------------------------------------------------------------- + * + * ResCalcPerimOverlap --- + * + * Given a device tile, compute simple perimeter and overlap of the device + * by the net under consideration. + * + * Results: + * None. + * + * Side Effects: + * The ResDevTile structure is updated with the overlap and perimeter + * values. + * + *------------------------------------------------------------------------- + */ + +void +ResCalcPerimOverlap(tile, dev) + Tile *tile; + ResDevTile *dev; +{ + Tile *tp; + int t1; + int overlap; + TileTypeBitMask *omask; + + dev->perim = (TOP(tile) - BOTTOM(tile) - LEFT(tile) + RIGHT(tile)) << 1; + overlap = 0; + + t1 = TiGetType(tile); + omask = &(ExtCurStyle->exts_nodeConn[t1]); + + /* left */ + for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp)) + { + if TTMaskHasType(omask, TiGetType(tp)) + overlap += MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp)); + } + + /* right */ + for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp=LB(tp)) + { + if TTMaskHasType(omask, TiGetType(tp)) + overlap += MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp)); + } + + /* top */ + for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp)) + { + if TTMaskHasType(omask, TiGetType(tp)) + overlap += MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp)); + } + + /* bottom */ + for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp=TR(tp)) + { + if TTMaskHasType(omask, TiGetType(tp)) + overlap += MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp)); + } + dev->overlap = overlap; +} +/* + *------------------------------------------------------------------------- + * + * resMakeDevFunc -- + * + * Callback function from ResExtractNet. For each device in a node's + * device list pulled from the .sim file, find the tile corresponding + * to the device in the source tree, and fill out the complete device + * record (namely the full device area). + * + * Result: + * Return 1 to stop the search because the device has been found. + * + *------------------------------------------------------------------------- + */ + +int +resMakeDevFunc(tile, cx) + Tile *tile; + TreeContext *cx; +{ + ResDevTile *thisDev = (ResDevTile *)cx->tc_filter->tf_arg; + Rect devArea; + + TiToRect(tile, &devArea); + GeoTransRect(&cx->tc_scx->scx_trans, &devArea, &thisDev->area); + ResCalcPerimOverlap(tile, thisDev); + + return 1; +} + + +/* + *------------------------------------------------------------------------- * * ResExtractNet-- extracts the resistance net at the specified * rn_loc. If the resulting net is greater than the tolerance, @@ -574,18 +671,20 @@ ResProcessTiles(goodies, origin) */ bool -ResExtractNet(fix, goodies, cellname) - ResFixPoint *fix; +ResExtractNet(node, goodies, cellname) + ResSimNode *node; ResGlobalParams *goodies; char *cellname; { SearchContext scx; int pNum; - ResDevTile *DevTiles; TileTypeBitMask FirstTileMask; Point startpoint; static int first = 1; - ResDevTile *newdevtiles, *tmp; + ResDevTile *DevTiles, *thisDev; + ResFixPoint *fix; + devPtr *tptr; + int resMakeDevFunc(); /* Make sure all global network variables are reset */ @@ -638,29 +737,55 @@ ResExtractNet(fix, goodies, cellname) DBCellClearDef(ResUse->cu_def); - /* Copy Paint */ - DevTiles = NULL; - #ifdef ARIEL if ((ResOptionsFlags & ResOpt_Power) && - strcmp(fix->fp_name, goodies->rg_name) != 0) continue; + strcmp(node->name, goodies->rg_name) != 0) continue; #endif - scx.scx_area.r_ll.p_x = fix->fp_loc.p_x-2; - scx.scx_area.r_ll.p_y = fix->fp_loc.p_y-2; - scx.scx_area.r_ur.p_x = fix->fp_loc.p_x+2; - scx.scx_area.r_ur.p_y = fix->fp_loc.p_y+2; - startpoint = fix->fp_loc; + /* Copy Paint */ - /* Because fix->fp_ttype might come from a label with a sticky type + scx.scx_area.r_ll.p_x = node->location.p_x - 2; + scx.scx_area.r_ll.p_y = node->location.p_y - 2; + scx.scx_area.r_ur.p_x = node->location.p_x + 2; + scx.scx_area.r_ur.p_y = node->location.p_y + 2; + startpoint = node->location; + + /* Because node->type might come from a label with a sticky type * that does not correspond exactly to the layer underneath, include * all connecting types. */ TTMaskZero(&FirstTileMask); - TTMaskSetMask(&FirstTileMask, &DBConnectTbl[fix->fp_ttype]); + TTMaskSetMask(&FirstTileMask, &DBConnectTbl[node->type]); - DevTiles = DBTreeCopyConnectDCS(&scx, &FirstTileMask, 0, - ResCopyMask, &TiPlaneRect, ResUse); + /* DevTiles = DBTreeCopyConnectDCS(&scx, &FirstTileMask, 0, + ResCopyMask, &TiPlaneRect, ResUse); */ + DBTreeCopyConnect(&scx, &FirstTileMask, 0, ResCopyMask, &TiPlaneRect, + SEL_DO_LABELS, ResUse); + + /* Add devices to ResUse from list in node */ + DevTiles = NULL; + for (tptr = node->firstDev; tptr; tptr = tptr->nextDev) + { + TileTypeBitMask devMask; + + TTMaskSetOnlyType(&devMask, tptr->thisDev->rs_ttype); + thisDev = (ResDevTile *)mallocMagic(sizeof(ResDevTile)); + thisDev->devptr = tptr->thisDev->rs_devptr; + thisDev->type = tptr->thisDev->rs_ttype; + scx.scx_area.r_ll.p_x = tptr->thisDev->location.p_x; + scx.scx_area.r_ll.p_y = tptr->thisDev->location.p_y; + scx.scx_area.r_xtop = scx.scx_area.r_xbot + 1; + scx.scx_area.r_ytop = scx.scx_area.r_ybot + 1; + DBTreeSrTiles(&scx, &devMask, 0, resMakeDevFunc, (ClientData)thisDev); + thisDev->nextDev = DevTiles; + DevTiles = thisDev; + + /* Paint the type into ResUse */ + pNum = DBPlane(thisDev->type); + DBPaintPlane(ResUse->cu_def->cd_planes[pNum], &thisDev->area, + DBStdPaintTbl(thisDev->type, pNum), (PaintUndoInfo *)NULL); + } + DBReComputeBbox(ResUse->cu_def); ExtResetTiles(scx.scx_use->cu_def, extUnInit); diff --git a/resis/ResMerge.c b/resis/ResMerge.c index 4882dbde..4650d52e 100644 --- a/resis/ResMerge.c +++ b/resis/ResMerge.c @@ -13,6 +13,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include "database/database.h" #include "utils/malloc.h" #include "textio/textio.h" +#include "extract/extractInt.h" #include "resis/resis.h" TileTypeBitMask ResNoMergeMask[NT]; diff --git a/resis/ResReadSim.c b/resis/ResReadSim.c index a969404d..74ccd7e3 100644 --- a/resis/ResReadSim.c +++ b/resis/ResReadSim.c @@ -207,7 +207,7 @@ ResReadSim(simfile, fetproc, capproc, resproc, attrproc, mergeproc, subproc) devptr = ExtCurStyle->exts_device[fettype]; sheetr = (float)devptr->exts_linearResist; - result = (*fetproc)(line, sheetr, fettype); + result = (*fetproc)(line, sheetr, devptr); } if (result != 0) { @@ -374,6 +374,8 @@ ResSimSubckt(line) for (i = 1; line[i][0] != '\0'; i++); i--; + /* To do: Replace this search with a pre-prepared hash */ + /* table to key off of the device name. */ for (j = 0; j < EFDevNumTypes; j++) if (!strcmp(EFDevTypes[j], line[i])) break; @@ -402,33 +404,29 @@ ResSimSubckt(line) case 'y': device->location.p_y = (int)((float)atof(eqptr) / lambda); break; - case 't': - ttype = (int)(atoi(eqptr)); - break; } } } - /* This should not be needed, as ext2sim should encode device type */ - /* in the attributes list. */ - if (ttype == TT_SPACE) + if (j == EFDevNumTypes) { - if (j == EFDevNumTypes) - { - TxError("Failure to find device type %s\n", line[i]); - return 1; - } - ttype = extGetDevType(EFDevTypes[j]); + TxError("Failure to find device type %s\n", line[i]); + return 1; } + ttype = extGetDevType(EFDevTypes[j]); + /* Find the device record that corresponds to the device name */ + for (devptr = ExtCurStyle->exts_device[ttype]; devptr; devptr = devptr->exts_next) + if (!strcmp(devptr->exts_deviceName, EFDevTypes[j])) + break; + + device->rs_devptr = devptr; device->rs_ttype = ttype; if (lptr != NULL && wptr != NULL) { float rpersquare; - ExtDevice *devptr; - devptr = ExtCurStyle->exts_device[ttype]; rpersquare =(float)devptr->exts_linearResist; /* Subcircuit types may not have a length or width value, in which */ /* case it is zero. Don't induce a divide-by-zero error. */ @@ -454,8 +452,6 @@ ResSimSubckt(line) return rvalue; } - - /* *------------------------------------------------------------------------- * @@ -469,10 +465,10 @@ ResSimSubckt(line) */ int -ResSimDevice(line, rpersquare, ttype) +ResSimDevice(line, rpersquare, devptr) char line[][MAXTOKEN]; float rpersquare; - TileType ttype; + ExtDevice *devptr; { RDev *device; @@ -511,7 +507,7 @@ ResSimDevice(line, rpersquare, ttype) device->rs_gattr=RDEV_NOATTR; device->rs_sattr=RDEV_NOATTR; device->rs_dattr=RDEV_NOATTR; - device->rs_ttype = ttype; + device->rs_devptr = devptr; device->gate = device->source = device->drain = device->subs = NULL; diff --git a/resis/ResRex.c b/resis/ResRex.c index f2d99a51..64caa1a4 100644 --- a/resis/ResRex.c +++ b/resis/ResRex.c @@ -464,7 +464,7 @@ typedef enum { CellDef *def; Rect rect; int oldoptions; - ResFixPoint fp; + ResSimNode lnode; if (ToolGetBoxWindow((Rect *) NULL, (int *) NULL) == NULL) { @@ -486,10 +486,9 @@ typedef enum { LaplaceMatchCount = 0; LaplaceMissCount = 0; #endif - fp.fp_ttype = tt; - fp.fp_loc = rect.r_ll; - fp.fp_next = NULL; - if (ResExtractNet(&fp, &gparams, NULL) != 0) return; + lnode.location = rect.r_ll; + lnode.type = tt; + if (ResExtractNet(&lnode, &gparams, NULL) != 0) return; ResPrintResistorList(stdout, ResResList); ResPrintDeviceList(stdout, ResRDevList); #ifdef LAPLACE @@ -1066,10 +1065,7 @@ ResCheckSimNodes(celldef, resisdata) ResFixPoint fp; failed1++; - fp.fp_loc = node->location; - fp.fp_ttype = node->type; - fp.fp_next = NULL; - if (ResExtractNet(&fp, &gparams, outfile) != 0) + if (ResExtractNet(node, &gparams, outfile) != 0) { /* On error, don't output this net, but keep going */ TxError("Error in extracting node %s\n", node->name); diff --git a/resis/ResUtils.c b/resis/ResUtils.c index 778a9b9a..31e35201 100644 --- a/resis/ResUtils.c +++ b/resis/ResUtils.c @@ -545,7 +545,7 @@ ResRemovePlumbing(tile, arg) /* *------------------------------------------------------------------------- * - * ResPreprocessDevices-- Given a list of all the device tiles and + * ResPreProcessDevices-- Given a list of all the device tiles and * a list of all the devices, this procedure calculates the width and * length. The width is set equal to the sum of all edges that touch * diffusion divided by 2. The length is the remaining perimeter divided by @@ -603,8 +603,9 @@ ResPreProcessDevices(TileList, DeviceList, Def) tt = TiGetType(tile); tstruct = (tileJunk *) tile->ti_client; - if (!TTMaskHasType(&ExtCurStyle->exts_deviceMask, tt) || - tstruct->deviceList == NULL) + if ((tstruct == (tileJunk *)CLIENTDEFAULT) || + (tstruct->deviceList == NULL) || + !TTMaskHasType(&ExtCurStyle->exts_deviceMask, tt)) { TxError("Bad Device Location at %d,%d\n", TileList->area.r_ll.p_x, @@ -626,7 +627,7 @@ ResPreProcessDevices(TileList, DeviceList, Def) freeMagic((char *)oldTile); } - for (; DeviceList != NULL;DeviceList = DeviceList->rd_nextDev) + for (; DeviceList != NULL; DeviceList = DeviceList->rd_nextDev) { int width = DeviceList->rd_perim; int length = DeviceList->rd_length; diff --git a/resis/resis.h b/resis/resis.h index 9507df0f..1594346a 100644 --- a/resis/resis.h +++ b/resis/resis.h @@ -247,6 +247,7 @@ typedef struct resdevtile struct resdevtile *nextDev; Rect area; TileType type; + ExtDevice *devptr; int perim; int overlap; } ResDevTile; @@ -297,7 +298,8 @@ typedef struct rdev Point location; /* Location of lower left point of */ /* device. */ float resistance; /* "Resistance" of device. */ - int rs_ttype; /* device type */ + TileType rs_ttype; /* tile type for device */ + ExtDevice *rs_devptr; /* device extraction record */ char *rs_gattr; /* Gate attributes, if any */ char *rs_sattr; char *rs_dattr;