Added an "off-grid geometry" check, in two versions. The simple

one is an "off_grid" DRC type, which can be used to check geometry
that is below the manufacturing grid.  Normally magic prevents the
grid from being subdivided below the manufacturing grid, but this
limit can be removed and replaced by DRC checks to check for such
errors in a GDS file of unknown origin.  The second version looks
for interactions between subcells that end up with intersections
of non-manhattan geometry landing on points that are not on the
database internal grid.  Such errors cannot be seen by magic's DRC
engine by definition, and so must be detected while flattening
geometry for the DRC checks.
This commit is contained in:
Tim Edwards
2021-02-04 17:35:43 -05:00
parent 2a1494e4d1
commit e53a23de59
9 changed files with 329 additions and 67 deletions
+73 -15
View File
@@ -48,7 +48,7 @@ static PaintResultType (*dbCurPaintTbl)[NT][NT] = DBPaintResultTbl;
* such as the design-rule checker that need to use, for example,
* DBPaintPlaneMark instead of the standard version.
*/
static void (*dbCurPaintPlane)() = DBPaintPlaneWrapper;
static int (*dbCurPaintPlane)() = DBPaintPlaneWrapper;
/* Structure passed to DBTreeSrTiles() */
struct copyAllArg
@@ -56,6 +56,7 @@ struct copyAllArg
TileTypeBitMask *caa_mask; /* Mask of tile types to be copied */
Rect caa_rect; /* Clipping rect in target coords */
CellUse *caa_targetUse; /* Use to which tiles are copied */
void (*caa_func)(); /* Callback function for off-grid points */
Rect *caa_bbox; /* Bbox of material copied (in
* targetUse coords). Used only when
* copying cells.
@@ -96,7 +97,7 @@ struct copyLabelArg
* ----------------------------------------------------------------------------
*/
void
int
DBPaintPlaneWrapper(def, pNum, type, area, undo)
CellDef *def;
int pNum;
@@ -106,12 +107,14 @@ DBPaintPlaneWrapper(def, pNum, type, area, undo)
{
TileType loctype = type & TT_LEFTMASK;
Rect expand;
int result;
undo->pu_pNum = pNum;
DBNMPaintPlane(def->cd_planes[pNum], type, area,
result = DBNMPaintPlane(def->cd_planes[pNum], type, area,
dbCurPaintTbl[pNum][loctype], undo);
GEO_EXPAND(area, 1, &expand);
DBMergeNMTiles(def->cd_planes[pNum], &expand, undo);
return result;
}
/*
@@ -126,7 +129,7 @@ DBPaintPlaneWrapper(def, pNum, type, area, undo)
* ----------------------------------------------------------------------------
*/
void
int
DBPaintPlaneMark(def, pNum, type, area, undo)
CellDef *def;
int pNum;
@@ -137,7 +140,7 @@ DBPaintPlaneMark(def, pNum, type, area, undo)
TileType loctype = type & TT_LEFTMASK;
undo->pu_pNum = pNum;
DBNMPaintPlane0(def->cd_planes[pNum], type, area,
return DBNMPaintPlane0(def->cd_planes[pNum], type, area,
dbCurPaintTbl[pNum][loctype], undo, (unsigned char)PAINT_MARK);
}
@@ -147,7 +150,7 @@ DBPaintPlaneMark(def, pNum, type, area, undo)
* ----------------------------------------------------------------------------
*/
void
int
DBPaintPlaneXor(def, pNum, type, area, undo)
CellDef *def;
int pNum;
@@ -158,7 +161,7 @@ DBPaintPlaneXor(def, pNum, type, area, undo)
TileType loctype = type & TT_LEFTMASK;
undo->pu_pNum = pNum;
DBNMPaintPlane0(def->cd_planes[pNum], type, area,
return DBNMPaintPlane0(def->cd_planes[pNum], type, area,
dbCurPaintTbl[pNum][loctype], undo, (unsigned char)PAINT_XOR);
}
@@ -175,7 +178,7 @@ DBPaintPlaneXor(def, pNum, type, area, undo)
* ----------------------------------------------------------------------------
*/
void
int
DBPaintPlaneActive(def, pNum, type, area, undo)
CellDef *def;
int pNum;
@@ -200,11 +203,13 @@ DBPaintPlaneActive(def, pNum, type, area, undo)
DBPaintPlaneWrapper(def, pNum, t | (type &
(TT_SIDE | TT_DIRECTION | TT_DIAGONAL)),
area, undo);
return;
return 0;
}
}
if (TTMaskHasType(&DBActiveLayerBits, loctype))
DBPaintPlaneWrapper(def, pNum, type, area, undo);
return DBPaintPlaneWrapper(def, pNum, type, area, undo);
else
return 0;
}
/*
@@ -241,6 +246,7 @@ DBCellCopyManhattanPaint(scx, mask, xMask, targetUse)
arg.caa_mask = mask;
arg.caa_targetUse = targetUse;
arg.caa_func = NULL;
GEOTRANSRECT(&scx->scx_trans, &scx->scx_area, &arg.caa_rect);
(void) DBTreeSrTiles(scx, mask, xMask, dbCopyManhattanPaint, (ClientData) &arg);
@@ -281,6 +287,52 @@ DBCellCopyAllPaint(scx, mask, xMask, targetUse)
arg.caa_mask = mask;
arg.caa_targetUse = targetUse;
arg.caa_func = NULL;
GEOTRANSRECT(&scx->scx_trans, &scx->scx_area, &arg.caa_rect);
/* Add any stacking types for the search (but not to mask passed as arg!) */
locMask = *mask;
DBMaskAddStacking(&locMask);
DBTreeSrTiles(scx, &locMask, xMask, dbCopyAllPaint, (ClientData) &arg);
}
/*
*-----------------------------------------------------------------------------
*
* DBCellCheckCopyAllPaint --
*
* Copy paint from the tree rooted at scx->scx_use to the paint planes
* of targetUse, transforming according to the transform in scx.
* Only the types specified by typeMask are copied.
*
* Results:
* None.
*
* Side effects:
* Updates the paint planes in targetUse.
*
*-----------------------------------------------------------------------------
*/
void
DBCellCheckCopyAllPaint(scx, mask, xMask, targetUse, func)
SearchContext *scx; /* Describes root cell to search, area to
* copy, transform from root cell to coords
* of targetUse.
*/
TileTypeBitMask *mask; /* Types of tiles to be yanked/stuffed */
int xMask; /* Expansion state mask to be used in search */
CellUse *targetUse; /* Cell into which material is to be stuffed */
void (*func)(); /* Function to call on tile split error */
{
TileTypeBitMask locMask;
struct copyAllArg arg;
int dbCopyAllPaint();
arg.caa_mask = mask;
arg.caa_targetUse = targetUse;
arg.caa_func = func;
GEOTRANSRECT(&scx->scx_trans, &scx->scx_area, &arg.caa_rect);
/* Add any stacking types for the search (but not to mask passed as arg!) */
@@ -441,7 +493,7 @@ DBCellCopyPaint(scx, mask, xMask, targetUse)
for (pNum = PL_PAINTBASE; pNum < DBNumPlanes; pNum++)
if (PlaneMaskHasPlane(planeMask, pNum))
{
cxp.tc_plane = pNum; /* not used? */
cxp.tc_plane = pNum;
(void) DBSrPaintArea((Tile *) NULL,
scx->scx_use->cu_def->cd_planes[pNum], &scx->scx_area,
mask, dbCopyAllPaint, (ClientData) &cxp);
@@ -590,6 +642,7 @@ dbCopyAllPaint(tile, cxp)
CellDef *def;
TileType type = TiGetTypeExact(tile);
int pNum = cxp->tc_plane;
int result;
TileTypeBitMask *typeMask;
/*
@@ -752,7 +805,12 @@ topbottom:
splitdone:
(*dbCurPaintPlane)(def, pNum, dinfo | type, &targetRect, &ui);
result = (*dbCurPaintPlane)(def, pNum, dinfo | type, &targetRect, &ui);
if ((result != 0) && (arg->caa_func != NULL))
{
/* result == 1 used exclusively for DRC off-grid error flagging */
DRCOffGridError(&targetRect);
}
return (0);
}
@@ -1013,11 +1071,11 @@ DBNewPaintTable(newTable))[NT][NT]
* ----------------------------------------------------------------------------
*/
VoidProc
IntProc
DBNewPaintPlane(newProc)
void (*newProc)(); /* Address of new procedure */
int (*newProc)(); /* Address of new procedure */
{
void (*oldProc)() = dbCurPaintPlane;
int (*oldProc)() = dbCurPaintPlane;
dbCurPaintPlane = newProc;
return (oldProc);
}
+23 -18
View File
@@ -215,7 +215,7 @@ dbJoinUndo(tile, splitx, undo)
* 'undo' can be NULL.
*
* Results:
* None.
* Always return 0.
*
* Side effects:
* Modifies the database plane that contains the given tile.
@@ -236,7 +236,7 @@ dbJoinUndo(tile, splitx, undo)
* ----------------------------------------------------------------------------
*/
void
int
DBPaintPlane0(plane, area, resultTbl, undo, method)
Plane *plane; /* Plane whose paint is to be modified */
Rect *area; /* Area to be changed */
@@ -262,7 +262,7 @@ DBPaintPlane0(plane, area, resultTbl, undo, method)
bool haschanged;
if (area->r_xtop <= area->r_xbot || area->r_ytop <= area->r_ybot)
return;
return 0;
/*
* The following is a modified version of the area enumeration
@@ -697,6 +697,7 @@ enum2:
done2:
plane->pl_hint = tile;
return 0;
}
/*
@@ -1442,7 +1443,7 @@ typedef struct
* paint quadrangular (clipped triangle) areas.
*
* Results:
* None.
* 0 on success, 1 on error splitting a non-manhattan tile
*
* Side Effects:
* Plane is painted with a diagonal. The plane may be hacked up
@@ -1452,7 +1453,7 @@ typedef struct
* ----------------------------------------------------------------------------
*/
void
int
DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
Plane *plane; /* Plane whose paint is to be modified */
TileType exacttype; /* diagonal info for tile to be changed */
@@ -1478,6 +1479,7 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
int xc, yc, width, height;
dlong xref, yref; /* xref, yref can easily exceed 32 bits */
int resstate;
int result = 0;
if (exacttype & TT_DIAGONAL)
{
@@ -1532,7 +1534,7 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
if (resultTbl[oldType] == oldType)
{
freeMagic((char *) lr);
return;
return 0;
}
}
@@ -1544,7 +1546,7 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
if (newType == oldType)
{
freeMagic((char *) lr);
return;
return 0;
}
/* Watch for the worst-case scenario of attempting to */
@@ -1560,9 +1562,9 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
{
if ((width == 1) || (height == 1))
{
DBPaintPlane(plane, &(lr->r_r), resultTbl, undo);
result = DBPaintPlane(plane, &(lr->r_r), resultTbl, undo);
freeMagic((char *) lr);
return;
return 1; /* Flag the error by returning 1 */
}
/* lr->r_r is drawn & quartered */
@@ -1605,7 +1607,7 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
if (newType & TT_DIAGONAL)
{
DBPaintPlane(plane, &(lr->r_r), DBSpecialPaintTbl,
result = DBPaintPlane(plane, &(lr->r_r), DBSpecialPaintTbl,
(PaintUndoInfo *)NULL);
tile = plane->pl_hint;
GOTOPOINT(tile, &(lr->r_r.r_ll));
@@ -1620,14 +1622,14 @@ DBNMPaintPlane0(plane, exacttype, area, resultTbl, undo, method)
{
PaintResultType tempTbl;
tempTbl = newType;
DBPaintPlane0(plane, &(lr->r_r), &tempTbl, undo, method);
result = DBPaintPlane0(plane, &(lr->r_r), &tempTbl,
undo, method);
}
else
DBPaintPlane(plane, &(lr->r_r), resultTbl, undo);
result = DBPaintPlane(plane, &(lr->r_r), resultTbl, undo);
freeMagic((char *) lr);
/* goto nmmerge; */
return;
return result;
}
}
@@ -1755,11 +1757,12 @@ paintrect:
if (resstate == RES_DIAG)
{
/* Recursive call to self on sub-area */
DBNMPaintPlane0(plane, exacttype, &(lr->r_r), resultTbl, undo, method);
result |= DBNMPaintPlane0(plane, exacttype, &(lr->r_r), resultTbl,
undo, method);
}
else if ((resstate == RES_LEFT && !dinfo.side) ||
(resstate == RES_RIGHT && dinfo.side)) {
DBPaintPlane(plane, &(lr->r_r), resultTbl, undo);
result |= DBPaintPlane(plane, &(lr->r_r), resultTbl, undo);
}
/* else: Rectangle does not contain type and should be ignored. */
nextrect:
@@ -1774,8 +1777,10 @@ nextrect:
}
}
else
DBPaintPlane0(plane, area, resultTbl, undo, (method == PAINT_MARK) ?
result = DBPaintPlane0(plane, area, resultTbl, undo, (method == PAINT_MARK) ?
method : PAINT_NORMAL);
return result;
}
/*
@@ -2547,7 +2552,7 @@ dbMergeType(tile, newType, plane, mergeFlags, undo, client)
* ----------------------------------------------------------------------------
*/
void
int
DBPaintPlaneVert(plane, area, resultTbl, undo)
Plane *plane; /* Plane whose paint is to be modified */
Rect *area; /* Area to be changed */
+11 -10
View File
@@ -696,13 +696,13 @@ typedef struct
extern void DBPaint();
extern void DBErase();
extern int DBSrPaintArea();
extern void DBPaintPlane0();
extern void DBPaintPlaneActive();
extern void DBPaintPlaneWrapper();
extern void DBPaintPlaneMark();
extern void DBPaintPlaneXor();
extern void DBPaintPlaneByProc();
extern void DBPaintPlaneMergeOnce();
extern int DBPaintPlane0();
extern int DBPaintPlaneActive();
extern int DBPaintPlaneWrapper();
extern int DBPaintPlaneMark();
extern int DBPaintPlaneXor();
extern int DBPaintPlaneByProc();
extern int DBPaintPlaneMergeOnce();
extern void DBPaintMask();
extern void DBEraseMask();
extern void DBClearPaintPlane();
@@ -712,7 +712,7 @@ extern void DBUnlockContact();
#define DBPaintPlane(a, b, c, d) DBPaintPlane0(a, b, c, d, PAINT_NORMAL)
#define DBMergeNMTiles(a, b, c) DBMergeNMTiles0(a, b, c, FALSE)
extern void DBNMPaintPlane0();
extern int DBNMPaintPlane0();
#define DBNMPaintPlane(a, b, c, d, e) DBNMPaintPlane0(a, b, c, d, e, PAINT_NORMAL)
/* I/O */
@@ -816,6 +816,7 @@ extern char *DBPrintUseId();
/* Massive copying */
extern void DBCellCopyPaint();
extern void DBCellCopyAllPaint();
extern void DBCellCheckCopyAllPaint();
extern void DBCellCopyLabels();
extern void DBCellCopyAllLabels();
extern void DBCellCopyCells();
@@ -845,8 +846,8 @@ extern void DBEnumerateTypes();
extern Plane *DBNewPlane();
extern PaintResultType (*DBNewPaintTable())[TT_MAXTYPES][TT_MAXTYPES];
typedef void (*VoidProc)();
VoidProc DBNewPaintPlane();
typedef int (*IntProc)();
IntProc DBNewPaintPlane();
/* Diagnostic */
extern void DBTechPrintTypes();