Added command option "-annotate" for "def read" that allows nets

to be annotated from a DEF file.  This is particularly useful if
"def read" has been used without the "-labels" option, and the
labels are needed at some point.
This commit is contained in:
Tim Edwards 2022-03-30 13:02:12 -04:00
parent e675decfc0
commit cfb81101ec
3 changed files with 51 additions and 21 deletions

View File

@ -1573,11 +1573,12 @@ cmdIdFunc(selUse, use, transform, newId)
} }
TileType TileType
CmdFindNetProc(nodename, use, rect, warn_not_found) CmdFindNetProc(nodename, use, rect, warn_not_found, isvalid)
char *nodename; char *nodename;
CellUse *use; CellUse *use;
Rect *rect; Rect *rect;
bool warn_not_found; bool warn_not_found;
bool *isvalid;
{ {
char *s,*s2; char *s,*s2;
SearchContext scx, scx2; SearchContext scx, scx2;
@ -1722,10 +1723,12 @@ checklocal:
if (!usefound) if (!usefound)
TxError("Couldn't find use referenced in hierarchical name\n"); TxError("Couldn't find use referenced in hierarchical name\n");
} }
if (isvalid) *isvalid = FALSE;
return TT_SPACE; return TT_SPACE;
} }
} }
GeoTransRect(&trans, &localrect, rect); GeoTransRect(&trans, &localrect, rect);
if (isvalid) *isvalid = TRUE;
return ttype; return ttype;
} }
@ -1770,7 +1773,7 @@ CmdGoto(w, cmd)
Rect rect; Rect rect;
CellUse *use; CellUse *use;
int locargc; int locargc;
bool nocomplain = FALSE; bool nocomplain = FALSE, isvalid;
TileType ttype; TileType ttype;
windCheckOnlyWindow(&w, DBWclientID); windCheckOnlyWindow(&w, DBWclientID);
@ -1797,8 +1800,8 @@ CmdGoto(w, cmd)
/* CmdFindNetProc() does all the work */ /* CmdFindNetProc() does all the work */
use = (CellUse *)w->w_surfaceID; use = (CellUse *)w->w_surfaceID;
ttype = CmdFindNetProc(nodename, use, &rect, !nocomplain); ttype = CmdFindNetProc(nodename, use, &rect, !nocomplain, &isvalid);
if (ttype == TT_SPACE) return; if (isvalid == FALSE) return;
ToolMoveBox(TOOL_BL, &rect.r_ll, FALSE, use->cu_def); ToolMoveBox(TOOL_BL, &rect.r_ll, FALSE, use->cu_def);
ToolMoveCorner(TOOL_TR, &rect.r_ur, FALSE, use->cu_def); ToolMoveCorner(TOOL_TR, &rect.r_ur, FALSE, use->cu_def);

View File

@ -74,7 +74,7 @@ enum def_netspecial_shape_keys {
DEF_SPECNET_SHAPE_DRCFILL}; DEF_SPECNET_SHAPE_DRCFILL};
char * char *
DefAddRoutes(rootDef, f, oscale, special, netname, ruleset, defLayerMap) DefAddRoutes(rootDef, f, oscale, special, netname, ruleset, defLayerMap, annotate)
CellDef *rootDef; /* Cell to paint */ CellDef *rootDef; /* Cell to paint */
FILE *f; /* Input file */ FILE *f; /* Input file */
float oscale; /* Scale factor between LEF and magic units */ float oscale; /* Scale factor between LEF and magic units */
@ -82,6 +82,7 @@ DefAddRoutes(rootDef, f, oscale, special, netname, ruleset, defLayerMap)
char *netname; /* Name of the net, if net is to be labeled */ char *netname; /* Name of the net, if net is to be labeled */
LefRules *ruleset; /* Non-default rule, or NULL */ LefRules *ruleset; /* Non-default rule, or NULL */
LefMapping *defLayerMap; /* magic-to-lef layer mapping array */ LefMapping *defLayerMap; /* magic-to-lef layer mapping array */
bool annotate; /* If TRUE, do not generate any geometry */
{ {
char *token; char *token;
LinkedRect *routeList, *newRoute = NULL, *routeTop = NULL; LinkedRect *routeList, *newRoute = NULL, *routeTop = NULL;
@ -674,7 +675,8 @@ endCoord:
while (routeTop != NULL) while (routeTop != NULL)
{ {
/* paint */ /* paint */
DBPaint(rootDef, &routeTop->r_r, routeTop->r_type); if (annotate == FALSE)
DBPaint(rootDef, &routeTop->r_r, routeTop->r_type);
/* label */ /* label */
if (labeled == FALSE) if (labeled == FALSE)
@ -927,13 +929,14 @@ enum def_netprop_keys {
}; };
void void
DefReadNets(f, rootDef, sname, oscale, special, dolabels, total) DefReadNets(f, rootDef, sname, oscale, special, dolabels, annotate, total)
FILE *f; FILE *f;
CellDef *rootDef; CellDef *rootDef;
char *sname; char *sname;
float oscale; float oscale;
bool special; /* True if this section is SPECIALNETS */ bool special; /* True if this section is SPECIALNETS */
bool dolabels; /* If true, create a label for each net */ bool dolabels; /* If true, create a label for each net */
bool annotate; /* If true, create labels, not geometry */
int total; int total;
{ {
char *token; char *token;
@ -1027,7 +1030,7 @@ DefReadNets(f, rootDef, sname, oscale, special, dolabels, total)
case DEF_NETPROP_COVER: case DEF_NETPROP_COVER:
case DEF_NETPROP_NOSHIELD: case DEF_NETPROP_NOSHIELD:
token = DefAddRoutes(rootDef, f, oscale, special, token = DefAddRoutes(rootDef, f, oscale, special,
netname, ruleset, defLayerMap); netname, ruleset, defLayerMap, annotate);
ruleset = NULL; ruleset = NULL;
break; break;
@ -2054,7 +2057,7 @@ DefReadComponents(f, rootDef, sname, oscale, total)
/* Don't process properties for cells we could not find */ /* Don't process properties for cells we could not find */
if ((defMacro == NULL) || ((defUse = DBCellNewUse(defMacro, usename)) if ((defMacro == NULL) || ((defUse = DBCellNewUse(defMacro, usename))
== NULL)) == NULL))
{ {
if (defMacro != NULL) LefEndStatement(f); if (defMacro != NULL) LefEndStatement(f);
break; break;
@ -2162,9 +2165,10 @@ enum def_sections {DEF_VERSION = 0, DEF_NAMESCASESENSITIVE,
DEF_NONDEFAULTRULES, DEF_END}; DEF_NONDEFAULTRULES, DEF_END};
void void
DefRead(inName, dolabels) DefRead(inName, dolabels, annotate)
char *inName; char *inName;
bool dolabels; bool dolabels;
bool annotate;
{ {
CellDef *rootDef; CellDef *rootDef;
FILE *f; FILE *f;
@ -2206,6 +2210,9 @@ DefRead(inName, dolabels)
NULL NULL
}; };
/* "annotate" implies "dolabels" whether set or not */
if (annotate) dolabels = TRUE;
/* Make sure we have a valid LefInfo hash table, even if it's empty */ /* Make sure we have a valid LefInfo hash table, even if it's empty */
if (LefInfo.ht_table == (HashEntry **) NULL) if (LefInfo.ht_table == (HashEntry **) NULL)
LefTechInit(); LefTechInit();
@ -2321,7 +2328,11 @@ DefRead(inName, dolabels)
token = LefNextToken(f, TRUE); token = LefNextToken(f, TRUE);
if (sscanf(token, "%d", &total) != 1) total = 0; if (sscanf(token, "%d", &total) != 1) total = 0;
LefEndStatement(f); LefEndStatement(f);
DefReadComponents(f, rootDef, sections[DEF_COMPONENTS], oscale, total); if (annotate)
LefSkipSection(f, sections[DEF_COMPONENTS]);
else
DefReadComponents(f, rootDef, sections[DEF_COMPONENTS],
oscale, total);
break; break;
case DEF_VIAS: case DEF_VIAS:
token = LefNextToken(f, TRUE); token = LefNextToken(f, TRUE);
@ -2333,7 +2344,10 @@ DefRead(inName, dolabels)
token = LefNextToken(f, TRUE); token = LefNextToken(f, TRUE);
if (sscanf(token, "%d", &total) != 1) total = 0; if (sscanf(token, "%d", &total) != 1) total = 0;
LefEndStatement(f); LefEndStatement(f);
DefReadPins(f, rootDef, sections[DEF_PINS], oscale, total); if (annotate)
LefSkipSection(f, sections[DEF_PINS]);
else
DefReadPins(f, rootDef, sections[DEF_PINS], oscale, total);
break; break;
case DEF_PINPROPERTIES: case DEF_PINPROPERTIES:
LefSkipSection(f, sections[DEF_PINPROPERTIES]); LefSkipSection(f, sections[DEF_PINPROPERTIES]);
@ -2343,14 +2357,14 @@ DefRead(inName, dolabels)
if (sscanf(token, "%d", &total) != 1) total = 0; if (sscanf(token, "%d", &total) != 1) total = 0;
LefEndStatement(f); LefEndStatement(f);
DefReadNets(f, rootDef, sections[DEF_SPECIALNETS], oscale, TRUE, DefReadNets(f, rootDef, sections[DEF_SPECIALNETS], oscale, TRUE,
dolabels, total); dolabels, annotate, total);
break; break;
case DEF_NETS: case DEF_NETS:
token = LefNextToken(f, TRUE); token = LefNextToken(f, TRUE);
if (sscanf(token, "%d", &total) != 1) total = 0; if (sscanf(token, "%d", &total) != 1) total = 0;
LefEndStatement(f); LefEndStatement(f);
DefReadNets(f, rootDef, sections[DEF_NETS], oscale, FALSE, DefReadNets(f, rootDef, sections[DEF_NETS], oscale, FALSE,
dolabels, total); dolabels, annotate, total);
break; break;
case DEF_NONDEFAULTRULES: case DEF_NONDEFAULTRULES:
token = LefNextToken(f, TRUE); token = LefNextToken(f, TRUE);
@ -2378,8 +2392,11 @@ DefRead(inName, dolabels)
token = LefNextToken(f, TRUE); token = LefNextToken(f, TRUE);
if (sscanf(token, "%d", &total) != 1) total = 0; if (sscanf(token, "%d", &total) != 1) total = 0;
LefEndStatement(f); LefEndStatement(f);
DefReadBlockages(f, rootDef, sections[DEF_BLOCKAGES], if (annotate)
oscale, total); LefSkipSection(f, sections[DEF_BLOCKAGES]);
else
DefReadBlockages(f, rootDef, sections[DEF_BLOCKAGES],
oscale, total);
break; break;
case DEF_END: case DEF_END:
if (!LefParseEndStatement(token, "DESIGN")) if (!LefParseEndStatement(token, "DESIGN"))

View File

@ -119,6 +119,10 @@ CmdLef(w, cmd)
* center of the first rectangle * center of the first rectangle
* found on that net. * found on that net.
*/ */
bool defAnnotate = FALSE; /* Indicates that no geometry should be
* created from any DEF files, which
* will be used for label annotation only.
*/
static char *cmdLefOption[] = static char *cmdLefOption[] =
{ {
"read [filename] read a LEF file filename[.lef]\n" "read [filename] read a LEF file filename[.lef]\n"
@ -139,9 +143,10 @@ CmdLef(w, cmd)
static char *cmdDefOption[] = static char *cmdDefOption[] =
{ {
"read [filename] read a DEF file filename[.def]", "read [filename] read a DEF file filename[.def]\n"
"write [cell] [-allspecial] write DEF for current or indicated cell\n" " read [filename] -labels read a DEF file with net labeling\n"
"write -labels label every net in NETS with the net name", " read [filename] -annotate read a DEF file for net annotation only",
"write [cell] [-allspecial] write DEF for current or indicated cell",
"writeall (use \"flatten -nosubckt\" + \"def" "writeall (use \"flatten -nosubckt\" + \"def"
" write\" instead)", " write\" instead)",
"help print this help information", "help print this help information",
@ -198,7 +203,12 @@ CmdLef(w, cmd)
if (!strncmp(cmd->tx_argv[i], "-import", 7)) if (!strncmp(cmd->tx_argv[i], "-import", 7))
lefImport = TRUE; lefImport = TRUE;
else if (!strncmp(cmd->tx_argv[i], "-anno", 5)) else if (!strncmp(cmd->tx_argv[i], "-anno", 5))
lefAnnotate = TRUE; {
if (is_lef)
lefAnnotate = TRUE;
else
defAnnotate = TRUE;
}
else if (!strncmp(cmd->tx_argv[i], "-label", 6)) else if (!strncmp(cmd->tx_argv[i], "-label", 6))
{ {
if (is_lef) if (is_lef)
@ -216,7 +226,7 @@ CmdLef(w, cmd)
if (is_lef) if (is_lef)
LefRead(namep, lefImport, lefAnnotate, lefDateStamp); LefRead(namep, lefImport, lefAnnotate, lefDateStamp);
else else
DefRead(namep, defLabelNets); DefRead(namep, defLabelNets, defAnnotate);
break; break;
case LEF_WRITEALL: case LEF_WRITEALL:
if (!is_lef) if (!is_lef)