Fixed a long-standing error in which "ext2spice merge" fails when

used with "ext2spice hierarchy on" because the device index is not
reset between calls to output cells in the hierarchy, leading to
a mismatch of the index for all cells after the first one output.
This commit is contained in:
Tim Edwards 2019-10-23 09:33:37 -04:00
parent 77e8ff437b
commit 7a42b5b6ad
4 changed files with 64 additions and 26 deletions

View File

@ -621,8 +621,10 @@ CIFReadTechLine(sectionName, argc, argv)
if (argc >= 3) if (argc >= 3)
{ {
if(!strncmp(argv[argc - 1], "nanom", 5)) if (!strncmp(argv[argc - 1], "nanom", 5))
cifCurReadStyle->crs_multiplier = 10; cifCurReadStyle->crs_multiplier = 10;
else if (!strncmp(argv[argc - 1], "angstr", 6))
cifCurReadStyle->crs_multiplier = 100;
} }
if (cifCurReadStyle->crs_scaleFactor <= 0) if (cifCurReadStyle->crs_scaleFactor <= 0)

View File

@ -1883,6 +1883,9 @@ esHierVisit(hc, cdata)
EFHierVisitNodes(hcf, spcnodeHierVisit, (ClientData) NULL); EFHierVisitNodes(hcf, spcnodeHierVisit, (ClientData) NULL);
freeMagic(resstr); freeMagic(resstr);
} }
/* Reset device merge index for next cell */
if (esMergeDevsA || esMergeDevsC) esFMIndex = 0;
} }
if ((def != topdef) || (def->def_flags & DEF_SUBCIRCUIT) || (locDoSubckt == TRUE)) if ((def != topdef) || (def->def_flags & DEF_SUBCIRCUIT) || (locDoSubckt == TRUE))

View File

@ -264,7 +264,8 @@ CmdExtToSpice(w, cmd)
"extresist [on|off] incorporate information from extresist", "extresist [on|off] incorporate information from extresist",
"resistor tee [on|off] model resistor capacitance as a T-network", "resistor tee [on|off] model resistor capacitance as a T-network",
"scale [on|off] use .option card for scaling", "scale [on|off] use .option card for scaling",
"subcircuits [on|off] standard cells become subcircuit calls", "subcircuits [top|descend] [on|off|auto]\n"
" standard cells become subcircuit calls",
"hierarchy [on|off] output hierarchical spice for LVS", "hierarchy [on|off] output hierarchical spice for LVS",
"blackbox [on|off] output abstract views as black-box entries", "blackbox [on|off] output abstract views as black-box entries",
"renumber [on|off] on = number instances X1, X2, etc.\n" "renumber [on|off] on = number instances X1, X2, etc.\n"
@ -2095,6 +2096,56 @@ esOutputResistor(dev, hierName, scale, term1, term2, has_model, l, w, dscale)
} }
} }
/* Report if device at index n has been deleted due to merging */
bool
devIsKilled(n)
int n;
{
return (esFMult[(n)] <= (float)0.0) ? TRUE : FALSE;
}
/* Add a dev's multiplier to the table and grow it if necessary */
void
addDevMult(f)
float f;
{
int i;
float *op;
if (esFMult == NULL) {
esFMult = (float *) mallocMagic((unsigned) (esFMSize*sizeof(float)));
}
else if (esFMIndex >= esFMSize)
{
op = esFMult;
esFMSize *= 2;
esFMult = (float *)mallocMagic((unsigned)(esFMSize * sizeof(float)));
for (i = 0; i < esFMSize / 2; i++) esFMult[i] = op[i];
if (op) freeMagic(op);
}
esFMult[esFMIndex++] = f;
}
/* Set the multiplier value f of device at index i */
void
setDevMult(i, f)
int i;
float f;
{
esFMult[i] = f;
}
/* Get the multiplier value of the device at the current index esFMIndex */
float
getCurDevMult()
{
return (esFMult && (esFMIndex > 0)) ? esFMult[esFMIndex-1] : (float)1.0;
}
/* /*
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *

View File

@ -36,6 +36,11 @@ extern char *nodeSpiceHierName();
extern devMerge *mkDevMerge(); extern devMerge *mkDevMerge();
extern bool extHierSDAttr(); extern bool extHierSDAttr();
extern bool devIsKilled();
extern float getCurDevMult();
extern void addDevMult();
extern void setDevMult();
/* Options specific to ext2spice */ /* Options specific to ext2spice */
extern bool esDoExtResis; extern bool esDoExtResis;
extern bool esDoPorts; extern bool esDoPorts;
@ -166,7 +171,7 @@ typedef struct {
/* /*
*--------------------------------------------------------- *---------------------------------------------------------
* Variables & macros used for merging parallel devs * Variables used for merging parallel devs
* The merging of devs is based on the fact that spcdevVisit * The merging of devs is based on the fact that spcdevVisit
* visits the devs in the same order all the time so the * visits the devs in the same order all the time so the
* value of esFMult[i] keeps the multiplier for the ith dev * value of esFMult[i] keeps the multiplier for the ith dev
@ -174,31 +179,8 @@ typedef struct {
*/ */
#define DEV_KILLED ((float) -1.0) #define DEV_KILLED ((float) -1.0)
#define FMULT_SIZE (1<<10) #define FMULT_SIZE (1<<10)
#define devIsKilled(n) ( esFMult[(n)] <=(float)0.0 )
#define DEV_KILLED ((float) -1.0) #define DEV_KILLED ((float) -1.0)
/* macro to add a dev's multiplier to the table and grow it if necessary */
#define addDevMult(f) \
{ \
if ( esFMult == NULL ) { \
esFMult = (float *) mallocMagic((unsigned) (esFMSize*sizeof(float))); \
} else if ( esFMIndex >= esFMSize ) { \
int i; \
float *op = esFMult ; \
esFMult = (float *) mallocMagic((unsigned) ((esFMSize = esFMSize*2)*sizeof(float))); \
for ( i = 0 ; i < esFMSize/2 ; i++ ) esFMult[i] = op[i]; \
if (op) freeMagic(op); \
} \
esFMult[esFMIndex++] = (float)(f); \
}
#define setDevMult(i,f) { esFMult[(i)] = (float)(f); }
#define getCurDevMult() ((esFMult && (esFMIndex > 0)) ? esFMult[esFMIndex-1] : (float)1.0)
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
#define atoCap(s) ((EFCapValue)atof(s)) #define atoCap(s) ((EFCapValue)atof(s))
#endif #endif