From 6bae7c25c43e65bdb01688db642b21a61733fb86 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 25 Mar 2020 09:29:16 -0400 Subject: [PATCH] Enhanced the "lef write -hide" command option to check for metal wide spacing rules; should result in LEF views that can import back into magic without DRC errors. --- drc/DRCtech.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ lef/lefWrite.c | 22 ++++++++++++++----- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/drc/DRCtech.c b/drc/DRCtech.c index 19a906dc..8cde7197 100644 --- a/drc/DRCtech.c +++ b/drc/DRCtech.c @@ -4031,3 +4031,62 @@ DRCGetDefaultLayerSurround(ttype1, ttype2) } return layerSurround; } + +/* + *----------------------------------------------------------------------------- + * DRCGetDefaultLayerWideSpacing --- + * + * Determine a default layer-to-self wide-layer spacing rule from + * the DRC width rules of a layer. + * + * Results: + * The minimum spacing between the specified magic layer type and + * itself, where one of the shapes has width greater than "twidth". + * The result value is in magic internal units. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +int +DRCGetDefaultWideLayerSpacing(ttype, twidth) + TileType ttype; + int twidth; +{ + int routeSpacing = 0; + DRCCookie *cptr; + TileTypeBitMask *set; + bool widerule = FALSE; + + for (cptr = DRCCurStyle->DRCRulesTbl[ttype][TT_SPACE]; cptr != (DRCCookie *) NULL; + cptr = cptr->drcc_next) + { + if (cptr->drcc_flags & DRC_TRIGGER) /* Widespacing rule */ + { + widerule = TRUE; + if (cptr->drcc_dist > twidth) /* Check against rule width */ + return routeSpacing; + } + if (widerule && ((cptr->drcc_flags & DRC_REVERSE) == 0)) /* FORWARD only */ + { + set = &cptr->drcc_mask; + if (!TTMaskHasType(set, ttype)) + if (PlaneMaskHasPlane(DBTypePlaneMaskTbl[ttype], cptr->drcc_plane) && + (cptr->drcc_dist == cptr->drcc_cdist)) + { + routeSpacing = cptr->drcc_dist; + /* Diagnostic */ + /* + TxPrintf("DRC: Layer %s has wide spacing %d to layer %s width %d\n", + DBTypeLongNameTbl[ttype1], routeSpacing, + DBTypeLongNameTbl[ttype2], twidth); + */ + } + } + if (!(cptr->drcc_flags & DRC_TRIGGER)) widerule = FALSE; + } + return routeSpacing; +} + diff --git a/lef/lefWrite.c b/lef/lefWrite.c index 4391d727..93fe30de 100644 --- a/lef/lefWrite.c +++ b/lef/lefWrite.c @@ -1103,15 +1103,25 @@ lefWriteMacro(def, f, scale, hide) for (thislll = lll; thislll; thislll = thislll->lll_next) { - int lspace; + int lspacex, lspacey, lwidth; lab = thislll->lll_label; - lspace = DRCGetDefaultLayerSpacing(lab->lab_type, lab->lab_type); - thislll->lll_area.r_xbot -= lspace; - thislll->lll_area.r_ybot -= lspace; - thislll->lll_area.r_xtop += lspace; - thislll->lll_area.r_ytop += lspace; + /* Look for wide spacing rules. If there are no wide spacing */ + /* rules, then fall back on the default spacing rule. */ + lwidth = thislll->lll_area.r_xtop - thislll->lll_area.r_xbot; + lspacex = DRCGetDefaultWideLayerSpacing(lab->lab_type, lwidth); + if (lspacex == 0) + lspacex = DRCGetDefaultLayerSpacing(lab->lab_type, lab->lab_type); + lwidth = thislll->lll_area.r_ytop - thislll->lll_area.r_ybot; + lspacey = DRCGetDefaultWideLayerSpacing(lab->lab_type, lwidth); + if (lspacey == 0) + lspacey = DRCGetDefaultLayerSpacing(lab->lab_type, lab->lab_type); + + thislll->lll_area.r_xbot -= lspacex; + thislll->lll_area.r_ybot -= lspacey; + thislll->lll_area.r_xtop += lspacex; + thislll->lll_area.r_ytop += lspacey; DBErase(lc.lefYank, &thislll->lll_area, lab->lab_type); freeMagic(thislll);