From 93c4503fa89858fe0a40c5597fe594a067ed4737 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 21 Jan 2022 14:48:59 -0500 Subject: [PATCH] Refined the new "gds maskhints" command option for GDS input from yesterday's commit to allow the syntax "gds maskhints ", in which mask hints can be restricted to a specific list of layers rather than all layers which define mask hints in the cifoutput rule. --- calma/CalmaRdcl.c | 2 +- calma/calma.h | 2 +- cif/CIFrdcl.c | 6 +++++- cif/CIFrdtech.c | 19 +++++++++++-------- cif/cif.h | 1 + commands/CmdCD.c | 22 ++++++++++++++++++---- doc/html/gds.html | 6 ++++-- 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/calma/CalmaRdcl.c b/calma/CalmaRdcl.c index 4281f331..a6673f5e 100644 --- a/calma/CalmaRdcl.c +++ b/calma/CalmaRdcl.c @@ -50,7 +50,7 @@ int calmaNonManhattan; int CalmaFlattenLimit = 10; int NameConvertErrors = 0; bool CalmaRewound = FALSE; -bool CalmaMaskHints = FALSE; +TileTypeBitMask *CalmaMaskHints = NULL; extern HashTable calmaDefInitHash; diff --git a/calma/calma.h b/calma/calma.h index 8910cad6..91c0b8e5 100644 --- a/calma/calma.h +++ b/calma/calma.h @@ -34,7 +34,7 @@ extern bool CalmaAddendum; extern bool CalmaNoDuplicates; extern time_t *CalmaDateStamp; extern bool CalmaUnique; -extern bool CalmaMaskHints; +extern TileTypeBitMask *CalmaMaskHints; extern bool CalmaMergeTiles; extern bool CalmaFlattenArrays; extern bool CalmaNoDRCCheck; diff --git a/cif/CIFrdcl.c b/cif/CIFrdcl.c index 2986e1b7..1f8d337d 100644 --- a/cif/CIFrdcl.c +++ b/cif/CIFrdcl.c @@ -723,7 +723,7 @@ CIFPaintCurrent(filetype) /* plane for that layer, compare to the input plane, and create */ /* mask hint properties to make the output the same as the input. */ - if (CalmaMaskHints) + if ((CalmaMaskHints != NULL) && (!TTMaskIsZero(CalmaMaskHints))) { int j; CIFOp *op, newop, subop; @@ -737,6 +737,8 @@ CIFPaintCurrent(filetype) for (i = 0; i < cifNReadLayers; i++) { + if (!TTMaskHasType(CalmaMaskHints, i)) continue; + /* Does the input layer have a corresponding output layer? */ in_out_map[i] = -1; for (j = 0; j < CIFCurStyle->cs_nLayers; j++) @@ -787,6 +789,8 @@ CIFPaintCurrent(filetype) char locstr[512]; Plane *tempp; + if (!TTMaskHasType(CalmaMaskHints, i)) continue; + j = in_out_map[i]; if (j < 0) continue; diff --git a/cif/CIFrdtech.c b/cif/CIFrdtech.c index d6404d24..cbf37711 100644 --- a/cif/CIFrdtech.c +++ b/cif/CIFrdtech.c @@ -248,9 +248,10 @@ CIFCalmaLayerToCifLayer(layer, datatype, calmaStyle) */ void -CIFParseReadLayers(string, mask) +CIFParseReadLayers(string, mask, newok) char *string; /* Comma-separated list of CIF layers. */ TileTypeBitMask *mask; /* Where to store bit mask. */ + bool newok; /* If TRUE, create new layers if they don't exist */ { int i; char *p; @@ -265,10 +266,10 @@ CIFParseReadLayers(string, mask) if (p != NULL) *p = 0; - i = CIFReadNameToType(string, TRUE); + i = CIFReadNameToType(string, newok); if (i >= 0) TTMaskSetType(mask, i); - else + else if (newok) { HashEntry *he; TileTypeBitMask *amask; @@ -280,6 +281,8 @@ CIFParseReadLayers(string, mask) TTMaskSetMask(mask, amask); } } + else + TxError("Error: CIF layer \"%s\" is unknown.\n", string); if (p == NULL) break; *p = ','; @@ -743,7 +746,7 @@ CIFReadTechLine(sectionName, argc, argv) cifCurReadOp = (CIFOp *) mallocMagic(sizeof(CIFOp)); cifCurReadOp->co_opcode = CIFOP_OR; cifCurReadOp->co_client = (ClientData)NULL; - CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask); + CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask, TRUE); TTMaskZero(&cifCurReadOp->co_paintMask); cifCurReadOp->co_next = NULL; cifCurReadOp->co_distance = 0; @@ -793,7 +796,7 @@ CIFReadTechLine(sectionName, argc, argv) cifCurReadOp = (CIFOp *) mallocMagic(sizeof(CIFOp)); cifCurReadOp->co_opcode = CIFOP_OR; cifCurReadOp->co_client = (ClientData)NULL; - CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask); + CIFParseReadLayers(argv[2], &cifCurReadOp->co_cifMask, TRUE); TTMaskZero(&cifCurReadOp->co_paintMask); cifCurReadOp->co_next = NULL; cifCurReadOp->co_distance = 0; @@ -865,7 +868,7 @@ CIFReadTechLine(sectionName, argc, argv) else goto wrongNumArgs; } - CIFParseReadLayers(argv[1], &mask); + CIFParseReadLayers(argv[1], &mask, TRUE); for (i=0; ico_cifMask); + CIFParseReadLayers(argv[1], &newOp->co_cifMask, TRUE); break; case CIFOP_GROW: case CIFOP_GROW_G: diff --git a/cif/cif.h b/cif/cif.h index 304f3840..f6db0619 100644 --- a/cif/cif.h +++ b/cif/cif.h @@ -62,6 +62,7 @@ extern void CIFReadTechStyleInit(); extern void CIFReadTechInit(); extern bool CIFReadTechLine(); extern void CIFReadTechFinal(); +extern void CIFParseReadLayers(); /* Externally-visible procedures: */ diff --git a/commands/CmdCD.c b/commands/CmdCD.c index e4a057de..f2e47610 100644 --- a/commands/CmdCD.c +++ b/commands/CmdCD.c @@ -545,9 +545,12 @@ CmdCalma(w, cmd) if (cmd->tx_argc == 2) { #ifdef MAGIC_WRAPPER - Tcl_SetObjResult(magicinterp, Tcl_NewBooleanObj(CalmaMaskHints)); + if ((CalmaMaskHints != NULL) && !TTMaskIsZero(CalmaMaskHints)) + Tcl_SetObjResult(magicinterp, Tcl_NewBooleanObj(TRUE)); + else + Tcl_SetObjResult(magicinterp, Tcl_NewBooleanObj(FALSE)); #else - if (CalmaMaskHints) + if ((CalmaMaskHints != NULL) && !TTMaskIsZero(CalmaMaskHints)) TxPrintf("Mask hints generated from GDS input.\n"); else TxPrintf("No mask hints generated from GDS input.\n"); @@ -557,10 +560,21 @@ CmdCalma(w, cmd) else if (cmd->tx_argc != 3) goto wrongNumArgs; + if (CalmaMaskHints == NULL) + { + CalmaMaskHints = (TileTypeBitMask *)mallocMagic(sizeof(TileTypeBitMask)); + TTMaskZero(CalmaMaskHints); + } option = Lookup(cmd->tx_argv[2], cmdCalmaYesNo); if (option < 0) - goto wrongNumArgs; - CalmaMaskHints = (option < 4) ? FALSE : TRUE; + CIFParseReadLayers(cmd->tx_argv[2], CalmaMaskHints, FALSE); + else + { + if (option < 4) + TTMaskZero(CalmaMaskHints); + else + TTMaskSetMask(CalmaMaskHints, &DBAllTypeBits); + } return; case CALMA_MERGE: diff --git a/doc/html/gds.html b/doc/html/gds.html index a0412946..bfc7cdc0 100644 --- a/doc/html/gds.html +++ b/doc/html/gds.html @@ -105,7 +105,7 @@ Read GDSII input or generate GDSII output. Otherwise, the use of yes and no toggles the flattening behavior without affecting any value previously set by flatten number. -
maskhints [yes|no] +
maskhints [yes|no|layers]
When set to yes, then after reading each cell definition from the GDS file, magic will re-generate the GDS output data from its internal representation of the @@ -114,7 +114,9 @@ Read GDSII input or generate GDSII output. the cifoutput section for a GDS layer, magic will automatically generate the mask hint property for the cell such that writing GDS of the cell will produce exactly the - same mask data as was in the original GDS file. + same mask data as was in the original GDS file. Alternatively + to specifying "yes", a comma-separated list layers + of GDS layers to create mask hints for can be specified (default no).
noduplicates [yes|no]
When reading a GDS file, this option forces magic to ignore