Implemented glob-style matching for label selection. Introduces

an optional extra argument to the "select" command that can be used
to select labels by glob-style matching;  e.g., "select area labels
VSS*" or "select less area labels *_1".  This will help in managing
labels after flattening a standard cell design;  e.g., by using
"select less area labels */VDD".
This commit is contained in:
Tim Edwards
2021-10-09 13:44:04 -04:00
parent 537b1f057d
commit 2f7813094b
10 changed files with 273 additions and 40 deletions
+68
View File
@@ -27,6 +27,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "utils/malloc.h"
#include "tiles/tile.h"
#include "utils/hash.h"
#include "utils/utils.h"
#include "database/database.h"
#include "database/databaseInt.h"
#include "textio/textio.h"
@@ -83,6 +84,9 @@ struct copyLabelArg
* to be filled in with total area of
* all labels copied.
*/
char *cla_glob; /* If non-NULL, used for glob-style
* matching of labels during copy.
*/
};
/*
@@ -595,6 +599,7 @@ DBCellCopyAllLabels(scx, mask, xMask, targetUse, pArea)
arg.cla_targetUse = targetUse;
arg.cla_bbox = pArea;
arg.cla_glob = NULL;
if (pArea != NULL)
{
pArea->r_xbot = 0;
@@ -619,6 +624,9 @@ dbCopyAllLabels(scx, lab, tpath, arg)
CellDef *def;
def = arg->cla_targetUse->cu_def;
if (arg->cla_glob != NULL)
if (!Match(arg->cla_glob, lab->lab_text))
return 0;
if (!GEO_LABEL_IN_AREA(&lab->lab_rect, &(scx->scx_area))) return 0;
GeoTransRect(&scx->scx_trans, &lab->lab_rect, &labTargetRect);
targetPos = GeoTransPos(&scx->scx_trans, lab->lab_just);
@@ -648,6 +656,66 @@ dbCopyAllLabels(scx, lab, tpath, arg)
return 0;
}
/*
*-----------------------------------------------------------------------------
*
* DBCellCopyGlobLabels --
*
* Copy labels from the tree rooted at scx->scx_use to targetUse,
* transforming according to the transform in scx. Only labels
* attached to layers of the types specified by mask and which
* match the string "globmatch" by glob-style matching are copied.
* The area to be copied is determined by GEO_LABEL_IN_AREA.
*
* Results:
* None.
*
* Side effects:
* Copies labels to targetUse, clipping against scx->scx_area.
* If pArea is given, store in it the bounding box of all the
* labels copied.
*
*-----------------------------------------------------------------------------
*/
void
DBCellCopyGlobLabels(scx, mask, xMask, targetUse, pArea, globmatch)
SearchContext *scx; /* Describes root cell to search, area to
* copy, transform from root cell to coords
* of targetUse.
*/
TileTypeBitMask *mask; /* Only labels of these types are copied */
int xMask; /* Expansion state mask to be used in search */
CellUse *targetUse; /* Cell into which labels are to be stuffed */
Rect *pArea; /* If non-NULL, points to a box that will be
* filled in with bbox (in targetUse coords)
* of all labels copied. Will be degenerate
* if nothing was copied.
*/
char *globmatch; /* If non-NULL, only labels matching this
* string by glob-style matching are copied.
*/
{
int dbCopyAllLabels();
struct copyLabelArg arg;
/* DBTeeSrLabels finds all the labels that we want plus some more.
* We'll filter out the ones that we don't need.
*/
arg.cla_targetUse = targetUse;
arg.cla_bbox = pArea;
arg.cla_glob = globmatch;
if (pArea != NULL)
{
pArea->r_xbot = 0;
pArea->r_xtop = -1;
}
(void) DBTreeSrLabels(scx, mask, xMask, (TerminalPath *) 0,
TF_LABEL_ATTACH, dbCopyAllLabels,
(ClientData) &arg);
}
/*
*-----------------------------------------------------------------------------
*
+43 -3
View File
@@ -228,7 +228,7 @@ DBPutFontLabel(cellDef, rect, font, size, rot, offset, align, text, type, flags)
/*
* ----------------------------------------------------------------------------
*
* DBEraseLabel --
* DBEraseGlobLabel --
*
* Delete labels attached to tiles of the indicated types that
* are in the given area (as determined by the macro GEO_LABEL_IN_AREA).
@@ -250,13 +250,13 @@ DBPutFontLabel(cellDef, rect, font, size, rot, offset, align, text, type, flags)
* still enough material to keep them around. The rect pointed to
* by areaReturn is filled with the area affected by removing the
* label, for purposes of redrawing the necessary portions of the
* screen.
* screen.
*
* ----------------------------------------------------------------------------
*/
bool
DBEraseLabel(cellDef, area, mask, areaReturn)
DBEraseGlobLabel(cellDef, area, mask, areaReturn, globmatch)
CellDef *cellDef; /* Cell being modified */
Rect *area; /* Area from which labels are to be erased.
* This may be a point; any labels touching
@@ -266,6 +266,9 @@ DBEraseLabel(cellDef, area, mask, areaReturn)
* be erased.
*/
Rect *areaReturn; /* Expand this with label bounding box */
char *globmatch; /* If non-NULL, do glob-style matching of
* any label against this string.
*/
{
Label *lab, *labPrev;
bool erasedAny = FALSE;
@@ -289,6 +292,10 @@ DBEraseLabel(cellDef, area, mask, areaReturn)
if (DBConnectsTo(newType, lab->lab_type)) goto nextLab;
}
}
if (globmatch != NULL)
{
if (!Match(globmatch, lab->lab_text)) goto nextLab;
}
DBWLabelChanged(cellDef, lab, DBW_ALLWINDOWS);
if (labPrev == NULL)
@@ -319,6 +326,39 @@ DBEraseLabel(cellDef, area, mask, areaReturn)
&& (r1)->r_xtop == (r2)->r_xtop \
&& (r1)->r_ytop == (r2)->r_ytop)
/*
* ----------------------------------------------------------------------------
*
* DBEraseLabel ---
*
* Wrapper around DBEraseGlobLabel() with globmatch set to NULL so
* that labels are erased verbatim rather that being matched against
* a glob-style string.
*
* Results:
* Passes back the result of DBEraseGlobLabel()
*
* Side effects:
* See DBEraseGlobLabel()
*
* ----------------------------------------------------------------------------
*/
bool
DBEraseLabel(cellDef, area, mask, areaReturn)
CellDef *cellDef; /* Cell being modified */
Rect *area; /* Area from which labels are to be erased.
* This may be a point; any labels touching
* or overlapping it are erased.
*/
TileTypeBitMask *mask; /* Mask of types from which labels are to
* be erased.
*/
Rect *areaReturn; /* Expand this with label bounding box */
{
return DBEraseGlobLabel(cellDef, area, mask, areaReturn, NULL);
}
/*
* ----------------------------------------------------------------------------
*
+2
View File
@@ -783,6 +783,7 @@ extern void DBPathSubstitute();
extern Label *DBPutLabel();
extern Label *DBPutFontLabel();
extern void DBFontLabelSetBBox();
extern bool DBEraseGlobLabel();
extern bool DBEraseLabel();
extern void DBEraseLabelAll();
extern void DBEraseLabelsByContent();
@@ -875,6 +876,7 @@ extern void DBCellCopyAllPaint();
extern void DBCellCheckCopyAllPaint();
extern void DBCellCopyLabels();
extern void DBCellCopyAllLabels();
extern void DBCellCopyGlobLabels();
extern void DBCellCopyCells();
extern void DBCellCopyAllCells();
extern Plane *DBCellGenerateSubstrate();