diff --git a/lef/Depend b/lef/Depend index 9b997139..76825257 100644 --- a/lef/Depend +++ b/lef/Depend @@ -23,6 +23,6 @@ lefRead.o: lefRead.c ../tcltk/tclmagic.h ../utils/magic.h \ ../lef/lefInt.h defRead.o: defRead.c ../tcltk/tclmagic.h ../utils/magic.h \ ../utils/geometry.h ../tiles/tile.h ../utils/hash.h ../utils/undo.h \ - ../database/database.h ../windows/windows.h ../dbwind/dbwind.h \ - ../utils/malloc.h ../graphics/graphics.h ../utils/main.h ../cif/cif.h \ - ../lef/lefInt.h + ../utils/utils.h ../database/database.h ../windows/windows.h \ + ../dbwind/dbwind.h ../utils/malloc.h ../graphics/graphics.h \ + ../utils/main.h ../cif/cif.h ../lef/lefInt.h diff --git a/lef/defRead.c b/lef/defRead.c index 7091c1c9..a62a5099 100644 --- a/lef/defRead.c +++ b/lef/defRead.c @@ -26,6 +26,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include "tiles/tile.h" #include "utils/hash.h" #include "utils/undo.h" +#include "utils/utils.h" #include "database/database.h" #include "windows/windows.h" #include "dbwind/dbwind.h" @@ -73,11 +74,12 @@ enum def_netspecial_shape_keys { DEF_SPECNET_SHAPE_DRCFILL}; char * -DefAddRoutes(rootDef, f, oscale, special, defLayerMap) +DefAddRoutes(rootDef, f, oscale, special, netname, defLayerMap) CellDef *rootDef; /* Cell to paint */ FILE *f; /* Input file */ float oscale; /* Scale factor between LEF and magic units */ bool special; /* True if this section is SPECIALNETS */ + char *netname; /* Name of the net, if net is to be labeled */ LefMapping *defLayerMap; /* magic-to-lef layer mapping array */ { char *token; @@ -85,6 +87,7 @@ DefAddRoutes(rootDef, f, oscale, special, defLayerMap) Point refp; /* reference point */ bool valid = FALSE; /* is there a valid reference point? */ bool initial = TRUE; + bool labeled = TRUE; Rect locarea; int extend, lextend, hextend; float x, y, z, w; @@ -124,6 +127,8 @@ DefAddRoutes(rootDef, f, oscale, special, defLayerMap) NULL }; + if (netname != NULL) labeled = FALSE; + while (initial || (token = LefNextToken(f, TRUE)) != NULL) { /* Get next point, token "NEW", or via name */ @@ -605,6 +610,16 @@ endCoord: /* paint */ DBPaint(rootDef, &routeTop->r_r, routeTop->r_type); + /* label */ + if (labeled == FALSE) + { + Rect r; + r.r_xbot = r.r_xtop = (routeTop->r_r.r_xbot + routeTop->r_r.r_xtop) / 2; + r.r_ybot = r.r_ytop = (routeTop->r_r.r_ybot + routeTop->r_r.r_ytop) / 2; + DBPutLabel(rootDef, &r, GEO_CENTER, netname, routeTop->r_type, 0); + labeled = TRUE; + } + /* advance to next point and free record (1-delayed) */ freeMagic((char *)routeTop); routeTop = routeTop->r_next; @@ -636,15 +651,17 @@ enum def_netprop_keys { DEF_NETPROP_PROPERTY}; void -DefReadNets(f, rootDef, sname, oscale, special, total) +DefReadNets(f, rootDef, sname, oscale, special, dolabels, total) FILE *f; CellDef *rootDef; char *sname; float oscale; bool special; /* True if this section is SPECIALNETS */ + bool dolabels; /* If true, create a label for each net */ int total; { char *token; + char *netname = NULL; int keyword, subkey; int processed = 0; LefMapping *defLayerMap; @@ -684,8 +701,8 @@ DefReadNets(f, rootDef, sname, oscale, special, total) case DEF_NET_START: /* Get net name */ - /* Presently, we ignore net names completely. */ token = LefNextToken(f, TRUE); + if (dolabels) netname = StrDup((char **)NULL, token); /* Update the record of the number of nets processed */ /* and spit out a message for every 5% finished. */ @@ -725,10 +742,11 @@ DefReadNets(f, rootDef, sname, oscale, special, total) case DEF_NETPROP_FIXED: case DEF_NETPROP_COVER: token = DefAddRoutes(rootDef, f, oscale, special, - defLayerMap); + netname, defLayerMap); break; } } + if (dolabels) freeMagic(netname); break; case DEF_NET_END: @@ -1648,8 +1666,9 @@ enum def_sections {DEF_VERSION = 0, DEF_NAMESCASESENSITIVE, DEF_END}; void -DefRead(inName) +DefRead(inName, dolabels) char *inName; + bool dolabels; { CellDef *rootDef; FILE *f; @@ -1825,13 +1844,15 @@ DefRead(inName) token = LefNextToken(f, TRUE); if (sscanf(token, "%d", &total) != 1) total = 0; LefEndStatement(f); - DefReadNets(f, rootDef, sections[DEF_SPECIALNETS], oscale, TRUE, total); + DefReadNets(f, rootDef, sections[DEF_SPECIALNETS], oscale, TRUE, + dolabels, total); break; case DEF_NETS: token = LefNextToken(f, TRUE); if (sscanf(token, "%d", &total) != 1) total = 0; LefEndStatement(f); - DefReadNets(f, rootDef, sections[DEF_NETS], oscale, FALSE, total); + DefReadNets(f, rootDef, sections[DEF_NETS], oscale, FALSE, + dolabels, total); break; case DEF_IOTIMINGS: LefSkipSection(f, sections[DEF_IOTIMINGS]); diff --git a/lef/lefCmd.c b/lef/lefCmd.c index df80f310..b5ba0b12 100644 --- a/lef/lefCmd.c +++ b/lef/lefCmd.c @@ -92,6 +92,10 @@ CmdLef(w, cmd) * only the immediate children of the * top level cell are output. */ + bool defLabelNets = FALSE; /* If TRUE, attach a label to the + * center of the first rectangle + * found on that net. + */ static char *cmdLefOption[] = { @@ -101,7 +105,8 @@ CmdLef(w, cmd) " write [filename] -hide hide all details other than ports", "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", + " writeall -all recurse on all subcells of the top-level cell\n", + " writeall -hide hide all details other than ports", "help print this help information", NULL }; @@ -109,7 +114,8 @@ CmdLef(w, cmd) static char *cmdDefOption[] = { "read [filename] read a DEF file filename[.def]", - "write [cell] [-allspecial] write DEF for current or indicated cell", + "write [cell] [-allspecial] write DEF for current or indicated cell\n", + "write -labels label every net in NETS with the net name", "writeall (use \"flatten -nosubckt\" + \"def" " write\" instead)", "help print this help information", @@ -157,22 +163,32 @@ CmdLef(w, cmd) switch (option) { case LEF_READ: - if (cmd->tx_argc != 3) + if (cmd->tx_argc > 3) { - if (cmd->tx_argc == 4) + for (i = 3; i < cmd->tx_argc; i++) { - if (*(cmd->tx_argv[3]) == '-') - if (!strncmp(cmd->tx_argv[3], "-import", 7)) + if (*(cmd->tx_argv[i]) == '-') + { + if (!strncmp(cmd->tx_argv[i], "-import", 7)) lefImport = TRUE; + else if (!strncmp(cmd->tx_argv[i], "-label", 6)) + { + if (is_lef) + TxPrintf("The \"-labels\" option is only for def read\n"); + else + defLabelNets = TRUE; + } + } } - else - goto wrongNumArgs; } + else if (cmd->tx_argc < 3) + goto wrongNumArgs; + namep = cmd->tx_argv[2]; if (is_lef) LefRead(namep, lefImport); else - DefRead(namep); + DefRead(namep, defLabelNets); break; case LEF_WRITEALL: if (!is_lef) diff --git a/utils/main.c b/utils/main.c index 73eea16a..708f0354 100644 --- a/utils/main.c +++ b/utils/main.c @@ -1156,7 +1156,7 @@ mainInitFinal() LefRead(temporary->fn, FALSE); break; case FN_DEF_FILE: - DefRead(temporary->fn); + DefRead(temporary->fn, FALSE); break; #endif #ifdef MAGIC_WRAPPER