Implemented an additional setback value for "lef write -hide <value>"

that produces a result that looks like "lef write -hide" in the middle
but "lef write" around the edge.  Can be useful for catching all the
detail around the edges but obscuring/simplifying the bulk of the cell
interior.
This commit is contained in:
Tim Edwards 2020-09-14 15:54:38 -04:00
parent a52590a10e
commit c3e8ed545d
2 changed files with 143 additions and 14 deletions

View File

@ -22,6 +22,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include "windows/windows.h"
#include "dbwind/dbwind.h"
#include "utils/main.h"
#include "utils/utils.h"
#include "textio/txcommands.h"
#include "commands/commands.h"
@ -83,9 +84,9 @@ CmdLef(w, cmd)
* will be output along with the
* lef macro.
*/
bool lefHide = FALSE; /* If TRUE, hide all details of
* the macro other than pin area
* immediately surrounding labels.
int lefHide = -1; /* If >= 0, hide all details of the macro
* other than pin area surrounding labels,
* with the indicated setback distance.
*/
bool lefTopLayer = False; /* If TRUE, only output the topmost
* layer used by a pin, and make
@ -106,11 +107,13 @@ CmdLef(w, cmd)
"read [filename] read a LEF file filename[.lef]\n"
" read [filename] -import read a LEF file; import cells from .mag files",
"write [filename] [-tech] write LEF for current cell\n"
" write [filename] -hide hide all details other than ports",
" write [filename] -hide hide all details other than ports\n",
" write [filename] -hide <d> hide details in area set back distance <d>",
"writeall write all cells including the top-level cell\n"
" writeall -notop write all children of the top-level cell\n"
" writeall -all recurse on all subcells of the top-level cell\n",
" writeall -hide hide all details other than ports",
" writeall -hide hide all details other than ports\n",
" writeall -hide [dist] hide details in area set back distance dist",
"help print this help information",
NULL
};
@ -211,7 +214,16 @@ CmdLef(w, cmd)
else if (!strncmp(cmd->tx_argv[i], "-tech", 5))
lefTech = TRUE;
else if (!strncmp(cmd->tx_argv[i], "-hide", 5))
lefHide = TRUE;
{
lefHide = 0;
if ((i < (cmd->tx_argc - 1)) &&
StrIsNumeric(cmd->tx_argv[i + 1]))
{
lefHide = cmdParseCoord(w, cmd->tx_argv[i + 1],
FALSE, TRUE);
i++;
}
}
else if (!strncmp(cmd->tx_argv[i], "-toplayer", 9))
lefTopLayer = TRUE;
else if (!strncmp(cmd->tx_argv[i], "-all", 4))
@ -248,7 +260,17 @@ CmdLef(w, cmd)
else if (!strncmp(cmd->tx_argv[i], "-hide", 5))
{
if (is_lef)
lefHide = TRUE;
{
lefHide = 0;
if ((i < (cmd->tx_argc - 1)) &&
StrIsNumeric(cmd->tx_argv[i + 1]))
{
lefHide = cmdParseCoord(w, cmd->tx_argv[i + 1],
FALSE, TRUE);
cargs--;
i++;
}
}
else
TxPrintf("The \"-hide\" option is only for lef write\n");
}

View File

@ -1095,11 +1095,11 @@ LefWritePinHeader(f, lab)
*/
void
lefWriteMacro(def, f, scale, hide, toplayer)
lefWriteMacro(def, f, scale, setback, toplayer)
CellDef *def; /* Def for which to generate LEF output */
FILE *f; /* Output to this file */
float scale; /* Output distance units conversion factor */
bool hide; /* If TRUE, hide all detail except pins */
int setback; /* If >= 0, hide all detail except pins inside setback */
bool toplayer; /* If TRUE, only output topmost layer of pins */
{
bool propfound, ispwrrail;
@ -1275,6 +1275,14 @@ lefWriteMacro(def, f, scale, hide, toplayer)
&boundary.r_ybot, &boundary.r_xtop, &boundary.r_ytop);
}
/* Check if (boundry less setback) is degenerate. If so, then */
/* there is no effect of the "-hide" option. */
if (setback > 0)
{
if ((boundary.r_xtop - boundary.r_xbot) < (2 * setback)) setback = -1;
if ((boundary.r_ytop - boundary.r_ybot) < (2 * setback)) setback = -1;
}
/* Write position and size information */
/* Note: Using "0.0 - X" prevents fprintf from generating "negative */
/* zeros" in the output. */
@ -1399,7 +1407,7 @@ lefWriteMacro(def, f, scale, hide, toplayer)
scx.scx_area = labr;
SelectClear();
if (hide)
if (setback == 0)
{
Rect carea;
labelLinkedList *newlll;
@ -1423,6 +1431,18 @@ lefWriteMacro(def, f, scale, hide, toplayer)
newlll->lll_next = lll;
lll = newlll;
}
else if (setback > 0)
{
Rect carea;
/* For -hide with setback, select the entire net and then */
/* remove the part inside the setback area. Note that this */
/* does not check if this causes the label to disappear. */
SelectNet(&scx, lab->lab_type, 0, NULL, FALSE);
GEO_EXPAND(&boundary, -setback, &carea);
SelRemoveArea(&carea, &DBAllButSpaceAndDRCBits);
}
else
SelectNet(&scx, lab->lab_type, 0, NULL, FALSE);
@ -1578,7 +1598,7 @@ lefWriteMacro(def, f, scale, hide, toplayer)
/* Restrict to routing planes only */
if (hide)
if (setback >= 0)
{
/* If details of the cell are to be hidden, then first paint */
/* all route layers with an obstruction rectangle the size of */
@ -1598,6 +1618,7 @@ lefWriteMacro(def, f, scale, hide, toplayer)
for (ttype = TT_TECHDEPBASE; ttype < DBNumTypes; ttype++)
if (TTMaskHasType(&lmask, ttype))
{
Rect r;
layerBound.r_xbot = layerBound.r_xtop = 0;
for (pNum = PL_TECHDEPBASE; pNum < DBNumPlanes; pNum++)
if (TTMaskHasType(&DBPlaneTypes[pNum], ttype))
@ -1607,6 +1628,10 @@ lefWriteMacro(def, f, scale, hide, toplayer)
lefGetBound, (ClientData)(&layerBound));
}
/* Clip layerBound to setback boundary */
GEO_EXPAND(&boundary, -setback, &r);
GeoClip(&layerBound, &r);
DBPaint(lc.lefYank, &layerBound, ttype);
}
@ -1630,6 +1655,43 @@ lefWriteMacro(def, f, scale, hide, toplayer)
DBErase(lc.lefYank, &thislll->lll_area, lab->lab_type);
freeMagic(thislll);
}
if (setback > 0)
{
/* For -hide with setback, yank everything in the area outside */
/* the setback. */
for (pNum = PL_TECHDEPBASE; pNum < DBNumPlanes; pNum++)
{
Rect r;
lc.pNum = pNum;
r = def->cd_bbox;
r.r_ytop = boundary.r_ybot + setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankGeometry, (ClientData) &lc);
r = def->cd_bbox;
r.r_ybot = boundary.r_ytop - setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankGeometry, (ClientData) &lc);
r = def->cd_bbox;
r.r_ybot = boundary.r_ybot + setback;
r.r_ytop = boundary.r_ytop - setback;
r.r_xtop = boundary.r_xbot + setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankGeometry, (ClientData) &lc);
r = def->cd_bbox;
r.r_ybot = boundary.r_ybot + setback;
r.r_ytop = boundary.r_ytop - setback;
r.r_xbot = boundary.r_xtop - setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankGeometry, (ClientData) &lc);
}
}
}
else
{
@ -1652,7 +1714,7 @@ lefWriteMacro(def, f, scale, hide, toplayer)
lefWriteGeometry, (ClientData) &lc);
/* Additional yank & write for contacts (although ignore contacts for -hide) */
if (!hide)
if (setback < 0)
{
lc.lefMode = LEF_MODE_OBS_CONTACT;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
@ -1663,6 +1725,51 @@ lefWriteMacro(def, f, scale, hide, toplayer)
lefWriteGeometry, (ClientData) &lc);
lc.lefMode = LEF_MODE_OBSTRUCT;
}
else if (setback > 0)
{
Rect r;
/* Apply only to area outside setback. */
lc.lefMode = LEF_MODE_OBS_CONTACT;
r = def->cd_bbox;
r.r_ytop = boundary.r_ybot + setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankContacts, (ClientData) &lc);
DBSrPaintArea((Tile *)NULL, lc.lefYank->cd_planes[pNum],
&r, &lc.rmask, lefWriteGeometry, (ClientData) &lc);
r = def->cd_bbox;
r.r_ybot = boundary.r_ytop - setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankContacts, (ClientData) &lc);
DBSrPaintArea((Tile *)NULL, lc.lefYank->cd_planes[pNum],
&r, &lc.rmask, lefWriteGeometry, (ClientData) &lc);
r = def->cd_bbox;
r.r_ybot = boundary.r_ybot + setback;
r.r_ytop = boundary.r_ytop - setback;
r.r_xtop = boundary.r_xbot + setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankContacts, (ClientData) &lc);
DBSrPaintArea((Tile *)NULL, lc.lefYank->cd_planes[pNum],
&r, &lc.rmask, lefWriteGeometry, (ClientData) &lc);
r = def->cd_bbox;
r.r_ybot = boundary.r_ybot + setback;
r.r_ytop = boundary.r_ytop - setback;
r.r_xbot = boundary.r_xtop - setback;
DBSrPaintArea((Tile *)NULL, lefFlatDef->cd_planes[pNum],
&r, &DBAllButSpaceAndDRCBits,
lefYankContacts, (ClientData) &lc);
DBSrPaintArea((Tile *)NULL, lc.lefYank->cd_planes[pNum],
&r, &lc.rmask, lefWriteGeometry, (ClientData) &lc);
lc.lefMode = LEF_MODE_OBSTRUCT;
}
}
if (lc.numWrites > 0)
@ -1843,7 +1950,7 @@ LefWriteAll(rootUse, writeTopCell, lefTech, lefHide, lefTopLayer, recurse)
CellUse *rootUse;
bool writeTopCell;
bool lefTech;
bool lefHide;
int lefHide;
bool lefTopLayer;
bool recurse;
{
@ -1979,7 +2086,7 @@ LefWriteCell(def, outName, isRoot, lefTech, lefHide, lefTopLayer)
char *outName; /* Name of output file, or NULL. */
bool isRoot; /* Is this the root cell? */
bool lefTech; /* Output layer information if TRUE */
bool lefHide; /* Hide detail other than pins if TRUE */
int lefHide; /* Hide detail other than pins if >= 0 */
bool lefTopLayer; /* Use only topmost layer of pin if TRUE */
{
char *filename;