From 982bb8aa63e678f484d45f7a336e31995659754f Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 25 Jul 2019 10:20:24 -0400 Subject: [PATCH 1/2] Changed a recent commit which removed brackets from instance names while reading DEF. To preserve names as much as possible, such names are now kept. To avoid problems, EFbuild.c and ext2hier behavior has been changed to only parse entries in a .ext file as instance arrays if the array notation follows the specific syntax of [ax:bx:cx][ay:by:cy], letting all other uses of brackets pass through unaffected. --- ext2spice/ext2hier.c | 53 +++++++++++++++++++++++++++++++++----------- extflat/EFbuild.c | 24 +++++++++++++++----- lef/defRead.c | 26 +++++++++++++--------- 3 files changed, 74 insertions(+), 29 deletions(-) diff --git a/ext2spice/ext2hier.c b/ext2spice/ext2hier.c index e5686cbf..93236df8 100644 --- a/ext2spice/ext2hier.c +++ b/ext2spice/ext2hier.c @@ -1572,14 +1572,29 @@ esMakePorts(hc, cdata) while (tptr != NULL) { + int idum[6]; + bool is_array; + /* Ignore array information for the purpose of tracing */ - /* the cell definition hierarchy. */ + /* the cell definition hierarchy. Complementary to the */ + /* method used in EFbuild.c, only consider uses of */ + /* brackets that conform to the [ax:bx:cx][ay:by:cy] */ + /* notation. */ aptr = strchr(portname, '['); - if ((aptr == NULL) || (aptr > tptr)) - *tptr = '\0'; - else + if (aptr && (aptr < tptr) && + (sscanf(aptr, "[%d:%d:%d][%d:%d:%d]", + &idum[0], &idum[1], &idum[2], + &idum[3], &idum[4], &idum[5]) == 6)) + { + is_array = TRUE; *aptr = '\0'; + } + else + { + is_array = FALSE; + *tptr = '\0'; + } // Find the cell for the instance portdef = NULL; @@ -1589,10 +1604,10 @@ esMakePorts(hc, cdata) use = (Use *)HashGetValue(he); portdef = use->use_def; } - if ((aptr == NULL) || (aptr > tptr)) - *tptr = '/'; - else + if (is_array) *aptr = '['; + else + *tptr = '/'; portname = tptr + 1; // Find the net of portname in the subcell and @@ -1651,14 +1666,26 @@ esMakePorts(hc, cdata) while (tptr != NULL) { + int idum[6]; + bool is_array; + /* Ignore array information for the purpose of tracing */ /* the cell definition hierarchy. */ aptr = strchr(portname, '['); - if ((aptr == NULL) || (aptr > tptr)) - *tptr = '\0'; - else + if (aptr && (aptr < tptr) && + (sscanf(aptr, "[%d:%d:%d][%d:%d:%d]", + &idum[0], &idum[1], &idum[2], + &idum[3], &idum[4], &idum[5]) == 6)) + { *aptr = '\0'; + is_array = TRUE; + } + else + { + *tptr = '\0'; + is_array = FALSE; + } // Find the cell for the instance portdef = NULL; @@ -1668,10 +1695,10 @@ esMakePorts(hc, cdata) use = (Use *)HashGetValue(he); portdef = use->use_def; } - if ((aptr == NULL) || (aptr > tptr)) - *tptr = '/'; - else + if (is_array) *aptr = '['; + else + *tptr = '/'; portname = tptr + 1; // Find the net of portname in the subcell and diff --git a/extflat/EFbuild.c b/extflat/EFbuild.c index 684168f1..3d56225f 100644 --- a/extflat/EFbuild.c +++ b/extflat/EFbuild.c @@ -1123,12 +1123,26 @@ efBuildUse(def, subDefName, subUseId, ta, tb, tc, td, te, tf) } else { - *cp = '\0'; - newuse->use_id = StrDup((char **) NULL, subUseId); - *cp = '['; - (void) sscanf(cp, "[%d:%d:%d][%d:%d:%d]", + /* Note: Preserve any use of brackets as-is other than the */ + /* standard magic array notation below. This allows, for */ + /* example, verilog instance arrays read from DEF files to */ + /* be passed through correctly. */ + + if ((sscanf(cp, "[%d:%d:%d][%d:%d:%d]", &newuse->use_xlo, &newuse->use_xhi, &newuse->use_xsep, - &newuse->use_ylo, &newuse->use_yhi, &newuse->use_ysep); + &newuse->use_ylo, &newuse->use_yhi, &newuse->use_ysep)) == 6) + { + *cp = '\0'; + newuse->use_id = StrDup((char **) NULL, subUseId); + *cp = '['; + } + else + { + newuse->use_id = StrDup((char **) NULL, subUseId); + newuse->use_xlo = newuse->use_xhi = 0; + newuse->use_ylo = newuse->use_yhi = 0; + newuse->use_xsep = newuse->use_ysep = 0; + } } he = HashFind(&def->def_uses, newuse->use_id); diff --git a/lef/defRead.c b/lef/defRead.c index afe49a2a..d4a1377f 100644 --- a/lef/defRead.c +++ b/lef/defRead.c @@ -1450,18 +1450,22 @@ DefReadComponents(f, rootDef, sname, oscale, total) /* Does use name contain brackets? If so, this can */ /* interfere with magic's use of arrays. */ + /* NOTE: This has been commented out. I think */ + /* the only confusion is in ext2spice and can be */ + /* avoided by allowing any bracket notation in an */ + /* instance name other than that used by the .ext */ + /* file for dealing with arrays, which uses the */ + /* specific syntax [xlo:xsep:xhi][ylo:ysep:yhi] and */ + /* is easy enough to distinguish. */ - /* NOTE: It is not clear that this needs to be */ - /* done during DEF read. The only confusion comes */ - /* from the arrays being parsed by ExtFlat when */ - /* doing ext2spice. */ - - dptr = strchr(usename, '['); - if (dptr != NULL) { - *dptr = '_'; - dptr = strchr(dptr + 1, ']'); - if (dptr != NULL) *dptr = '_'; - } + /* + dptr = strchr(usename, '['); + if (dptr != NULL) { + *dptr = '_'; + dptr = strchr(dptr + 1, ']'); + if (dptr != NULL) *dptr = '_'; + } + */ token = LefNextToken(f, TRUE); From 8562812fff467a1c50341185b6f56d4162023c29 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 25 Jul 2019 16:29:12 -0400 Subject: [PATCH 2/2] Corrected CalmaError() to CalmaReadError() in cif/CIFrdcl.c. Thanks to Toby Schaffer for the bug report and patch! --- cif/CIFrdcl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cif/CIFrdcl.c b/cif/CIFrdcl.c index 2157b15a..23321977 100644 --- a/cif/CIFrdcl.c +++ b/cif/CIFrdcl.c @@ -752,7 +752,7 @@ cifMakeBoundaryFunc(tile, clientdata) CIFReadError("Warning: Cell %s boundary was redefined.\n", cifReadCellDef->cd_name); else - CalmaError("Warning: Cell %s boundary was redefined.\n", + CalmaReadError("Warning: Cell %s boundary was redefined.\n", cifReadCellDef->cd_name); } }