From eecdc3c6421d42a031e98023567a0f3694ba47f4 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sat, 15 Oct 2022 11:33:59 -0400 Subject: [PATCH] Added a "flatten -doproperty" command option that allows selective flattening based on cells which have a property "flatten". Also: Modified the DEF read and write to convert DIEAREA into a FIXED_BBOX property. This solves issues with placing of components from DEF, when those components may not have have come from place & route and may not have P&R bounding boxes. Also: Fixed the documentation for the "dump" command, which was missing the optional orientation in the description. --- VERSION | 2 +- commands/CmdFI.c | 7 +++++-- database/DBcellsubr.c | 12 ++++++++++++ database/database.h.in | 1 + doc/html/dump.html | 12 ++++++++---- doc/html/flatten.html | 9 +++++++-- lef/defRead.c | 10 ++++++++++ lef/defWrite.c | 39 +++++++++++++++++++++++++++++++++------ 8 files changed, 77 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index c2e2d718..6e70b3e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.329 +8.3.330 diff --git a/commands/CmdFI.c b/commands/CmdFI.c index d856dbd2..0c8a2093 100644 --- a/commands/CmdFI.c +++ b/commands/CmdFI.c @@ -2004,7 +2004,10 @@ CmdFlatten(w, cmd) toplabels = (invert) ? FALSE : TRUE; break; case 'p': - doports = (invert) ? FALSE : TRUE; + if (!strncmp(cmd->tx_argv[i] + 3, "prop", 4)) + xMask = (invert) ? CU_DESCEND_ALL : CU_DESCEND_PROP_FLAT; + else + doports = (invert) ? FALSE : TRUE; break; case 's': xMask = (invert) ? CU_DESCEND_NO_SUBCKT : CU_DESCEND_ALL; @@ -2014,7 +2017,7 @@ CmdFlatten(w, cmd) break; default: TxError("options are: -nolabels, -nosubcircuits, -noports, " - "-novendor, -dotoplabels, -dobox\n"); + "-novendor, -dotoplabels, -doproperty, -dobox\n"); break; } } diff --git a/database/DBcellsubr.c b/database/DBcellsubr.c index d9e6ee8c..b9c60b47 100644 --- a/database/DBcellsubr.c +++ b/database/DBcellsubr.c @@ -64,6 +64,8 @@ DBDescendSubcell(use, xMask) CellUse *use; unsigned int xMask; { + bool propfound; + /* Check single bit (window ID) or zero */ if (((xMask - 1) & xMask) == 0) return ((use->cu_expandMask & xMask) == xMask); @@ -91,6 +93,16 @@ DBDescendSubcell(use, xMask) case CU_DESCEND_NO_VENDOR: return (use->cu_def->cd_flags & CDVENDORGDS) ? FALSE : TRUE; + case CU_DESCEND_PROP_FLAT: + if (use->cu_expandMask == CU_DESCEND_SPECIAL) + return TRUE; + else + { + /* Descend only into cells marked with property "flatten" */ + DBPropGet(use->cu_def, "flatten", &propfound); + return (propfound) ? TRUE : FALSE; + } + case CU_DESCEND_NONE: return FALSE; } diff --git a/database/database.h.in b/database/database.h.in index c011daad..2c622916 100644 --- a/database/database.h.in +++ b/database/database.h.in @@ -559,6 +559,7 @@ typedef struct celluse #define CU_DESCEND_NO_VENDOR 0x0006 /* Descend no vendor-GDS subcells */ #define CU_DESCEND_NO_LOCK 0x0007 /* Descend unlocked subcells only */ #define CU_DESCEND_NONE 0x0009 /* Descend no subcells */ +#define CU_DESCEND_PROP_FLAT 0x000a /* Descend by property string "flatten" */ /* * Declare tile type structure for non-manhattan geometry diff --git a/doc/html/dump.html b/doc/html/dump.html index 2a25e854..052b407b 100644 --- a/doc/html/dump.html +++ b/doc/html/dump.html @@ -25,16 +25,20 @@ Copy contents of the indicated cell into the current edit cell.

Usage:

- dump cell [child child_refpoint] + dump cell [orientation] + [child child_refpoint] [parent parent_refpoint]

where cell is the name of the cell whose contents are to be copied, and optional child_refpoint and parent_refpoint are coordinate pairs of x y values, - or keywords ll, lr, ul, or ur. The - syntax and use of the reference points is the same as for the - getcell command. + or keywords ll, lr, ul, or ur. + The optional orientation may be any valid orientation + (flip or rotation), such as h, v, 90, + 180, or 270. + The syntax and use of the orientation and reference points is the + same as for the getcell command.
diff --git a/doc/html/flatten.html b/doc/html/flatten.html index 5fedfb9e..6cd5639e 100644 --- a/doc/html/flatten.html +++ b/doc/html/flatten.html @@ -30,8 +30,8 @@ Flatten edit cell into the indicated destination cell. where cellname is the name of a cell definition to be created, and into which the flattened geometry will be placed. option may be one of -nolabels, -nosubcircuits, - or -noports, -novendor, -dotoplabels, and - -dobox. + or -noports, -novendor, -dotoplabels, + -doproperty, and -dobox. @@ -63,6 +63,11 @@ Flatten edit cell into the indicated destination cell.
This option tells magic to preserve in the flattened view only the labels that are in the top level cell. Labels in subcells will be ignored. +
-doproperty +
This option will only flatten subcells which are marked + with the property string "flatten". This is useful + for flattening an entire set of cells; for example, flattening + subcells with routing before creating a DEF file of a layout.
-dobox
When this option is specified, magic flattens only the area of the circuit that is inside the boundary of the cursor box. diff --git a/lef/defRead.c b/lef/defRead.c index c9e73fe7..da483427 100644 --- a/lef/defRead.c +++ b/lef/defRead.c @@ -2354,8 +2354,10 @@ DefRead(inName, dolabels, annotate, noblockage) FILE *f; char *filename; char *token; + char *bboxstr; int keyword, dscale, total; float oscale; + Rect *dierect; static char *sections[] = { "VERSION", @@ -2496,6 +2498,14 @@ DefRead(inName, dolabels, annotate, noblockage) LefEndStatement(f); break; case DEF_DIEAREA: + dierect = LefReadRect(f, 0, oscale); + bboxstr = mallocMagic(40); + sprintf(bboxstr, "%d %d %d %d", + dierect->r_xbot, + dierect->r_ybot, + dierect->r_xtop, + dierect->r_ytop); + DBPropPut(rootDef, "FIXED_BBOX", bboxstr); LefEndStatement(f); break; case DEF_PROPERTYDEFINITIONS: diff --git a/lef/defWrite.c b/lef/defWrite.c index 6a8584d7..bac0d9b3 100644 --- a/lef/defWrite.c +++ b/lef/defWrite.c @@ -102,6 +102,8 @@ defWriteHeader(def, f, oscale, units) int units; /* Units for UNITS; could be derived from oscale */ { TileType type; + char *propvalue; + bool propfound; TxPrintf("Diagnostic: Write DEF header for cell %s\n", def->cd_name); @@ -130,12 +132,37 @@ defWriteHeader(def, f, oscale, units) fprintf(f, " UNITS DISTANCE MICRONS %d ;\n", units); - /* Die area, taken from the cell def bounding box. */ - fprintf(f, " DIEAREA ( %.10g %.10g ) ( %.10g %.10g ) ;\n", - (float)def->cd_bbox.r_xbot * oscale, - (float)def->cd_bbox.r_ybot * oscale, - (float)def->cd_bbox.r_xtop * oscale, - (float)def->cd_bbox.r_ytop * oscale); + /* For DIEAREA, use the FIXED_BBOX property if present. Otherwise, */ + /* use the extents of geometry (CellDef bounding box) */ + + propvalue = (char *)DBPropGet(def, "FIXED_BBOX", &propfound); + if (propfound) + { + Rect bbox; + + /* Die area, taken from the declared FIXED_BBOX. */ + if (sscanf(propvalue, "%d %d %d %d", &bbox.r_xbot, &bbox.r_ybot, + &bbox.r_xtop, &bbox.r_ytop) == 4) + { + fprintf(f, " DIEAREA ( %.10g %.10g ) ( %.10g %.10g ) ;\n", + (float)bbox.r_xbot * oscale, + (float)bbox.r_ybot * oscale, + (float)bbox.r_xtop * oscale, + (float)bbox.r_ytop * oscale); + } + else + propfound = FALSE; + } + + if (!propfound) + { + /* Die area, taken from the cell def bounding box. */ + fprintf(f, " DIEAREA ( %.10g %.10g ) ( %.10g %.10g ) ;\n", + (float)def->cd_bbox.r_xbot * oscale, + (float)def->cd_bbox.r_ybot * oscale, + (float)def->cd_bbox.r_xtop * oscale, + (float)def->cd_bbox.r_ytop * oscale); + } fprintf(f, "\n"); }