From f15ea2a135622ffa13f666589ae131430d4eacbd Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 19 Dec 2019 10:33:22 -0500 Subject: [PATCH] Modified "lef writeall" to only generate output for the set of subcells that are direct children of the top level cell. The "-all" option was added to enable the previous behavior, although its usefulness is doubtful. --- calma/CalmaWrite.c | 2 +- lef/lefCmd.c | 12 ++++++++++-- lef/lefWrite.c | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index 0480238f..a08899fa 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -1024,7 +1024,7 @@ calmaOutFunc(def, f, cliprect) ((lab->lab_flags & PORT_NUM_MASK) == i)) { calmaWriteLabelFunc(lab, type, f); - break; + /* break; */ /* Do not limit to unique labels! */ } } } diff --git a/lef/lefCmd.c b/lef/lefCmd.c index 546988db..0322467a 100644 --- a/lef/lefCmd.c +++ b/lef/lefCmd.c @@ -87,6 +87,11 @@ CmdLef(w, cmd) * the macro other than pin area * immediately surrounding labels. */ + bool recurse = FALSE; /* If TRUE, recurse on all subcells + * during "writeall". By default, + * only the immediate children of the + * top level cell are output. + */ static char *cmdLefOption[] = { @@ -95,7 +100,8 @@ CmdLef(w, cmd) "write [filename] [-tech] write LEF for current cell\n" " write [filename] -hide hide all details other than ports", "writeall write all cells including the top-level cell\n" - " writeall -notop write all subcells of the top-level cell", + " writeall -notop write all children of the top-level cell\n" + " writeall -all recurse on all subcells of the top-level cell", "help print this help information", NULL }; @@ -184,11 +190,13 @@ CmdLef(w, cmd) lefTopCell = FALSE; else if (!strncmp(cmd->tx_argv[i], "-tech", 5)) lefTech = TRUE; + else if (!strncmp(cmd->tx_argv[i], "-all", 4)) + recurse = TRUE; else goto wrongNumArgs; } else goto wrongNumArgs; } - LefWriteAll(selectedUse, lefTopCell, lefTech); + LefWriteAll(selectedUse, lefTopCell, lefTech, recurse); } break; case LEF_WRITE: diff --git a/lef/lefWrite.c b/lef/lefWrite.c index 8c3f7530..2984a2fb 100644 --- a/lef/lefWrite.c +++ b/lef/lefWrite.c @@ -1133,10 +1133,11 @@ lefWriteMacro(def, f, scale, hide) */ void -LefWriteAll(rootUse, writeTopCell, lefTech) +LefWriteAll(rootUse, writeTopCell, lefTech, recurse) CellUse *rootUse; bool writeTopCell; bool lefTech; + bool recurse; { CellDef *def, *rootdef; FILE *f; @@ -1155,8 +1156,12 @@ LefWriteAll(rootUse, writeTopCell, lefTech) (void) DBCellSrDefs(0, lefDefInitFunc, (ClientData) 0); /* Recursively visit all defs in the tree and push on stack */ + /* If "recurse" is false, then only the children of the root use */ + /* are pushed (this is the default behavior). */ lefDefStack = StackNew(100); - (void) lefDefPushFunc(rootUse); + if (writeTopCell) + lefDefPushFunc(rootUse, (bool *)NULL); + DBCellEnum(rootUse->cu_def, lefDefPushFunc, (ClientData)&recurse); /* Open the file for output */ @@ -1185,8 +1190,7 @@ LefWriteAll(rootUse, writeTopCell, lefTech) { def->cd_client = (ClientData) 0; if (!SigInterruptPending) - if ((writeTopCell == TRUE) || (def != rootdef)) - lefWriteMacro(def, f, scale); + lefWriteMacro(def, f, scale); } /* End the LEF file */ @@ -1217,8 +1221,9 @@ lefDefInitFunc(def) */ int -lefDefPushFunc(use) +lefDefPushFunc(use, recurse) CellUse *use; + bool *recurse; { CellDef *def = use->cu_def; @@ -1227,7 +1232,8 @@ lefDefPushFunc(use) def->cd_client = (ClientData) 1; StackPush((ClientData) def, lefDefStack); - (void) DBCellEnum(def, lefDefPushFunc, (ClientData) 0); + if (recurse && (*recurse)) + (void) DBCellEnum(def, lefDefPushFunc, (ClientData)recurse); return (0); }