Merged pull request #35 from Jan Belohoubek

This commit is contained in:
Tim Edwards 2021-02-17 21:08:10 -05:00
parent aa88c69636
commit 15fe4d2d29
2 changed files with 29 additions and 45 deletions

View File

@ -500,7 +500,7 @@ spcdevHierVisit(hc, dev, scale)
EFNode *subnode, *snode, *dnode, *subnodeFlat = NULL; EFNode *subnode, *snode, *dnode, *subnodeFlat = NULL;
int l, w, i, parmval; int l, w, i, parmval;
Rect r; Rect r;
bool subAP = FALSE, hierS, hierD, extHierSDAttr(), swapped = FALSE; bool subAP = FALSE, hierS, hierD, extHierSDAttr();
float sdM; float sdM;
char devchar; char devchar;
bool has_model = TRUE; bool has_model = TRUE;
@ -522,6 +522,8 @@ spcdevHierVisit(hc, dev, scale)
source = drain = &dev->dev_terms[1]; source = drain = &dev->dev_terms[1];
if (dev->dev_nterm >= 3) if (dev->dev_nterm >= 3)
{ {
drain = &dev->dev_terms[2];
/* If any terminal is marked with attribute "D" or "S" */ /* If any terminal is marked with attribute "D" or "S" */
/* (label "D$" or "S$" at poly-diffusion interface), */ /* (label "D$" or "S$" at poly-diffusion interface), */
/* then force order of source and drain accordingly. */ /* then force order of source and drain accordingly. */
@ -531,11 +533,8 @@ spcdevHierVisit(hc, dev, scale)
(dev->dev_terms[2].dterm_attrs && (dev->dev_terms[2].dterm_attrs &&
!strcmp(dev->dev_terms[2].dterm_attrs, "S"))) !strcmp(dev->dev_terms[2].dterm_attrs, "S")))
{ {
swapDrainSource(dev, &source, &drain); swapDrainSource(dev);
swapped = TRUE;
} }
else
drain = &dev->dev_terms[2];
} }
else if (dev->dev_nterm == 1) // Is a device with one terminal an error? else if (dev->dev_nterm == 1) // Is a device with one terminal an error?
source = drain = &dev->dev_terms[0]; source = drain = &dev->dev_terms[0];
@ -1023,10 +1022,6 @@ spcdevHierVisit(hc, dev, scale)
break; break;
} }
fprintf(esSpiceF, "\n"); fprintf(esSpiceF, "\n");
/* If S/D parameters were swapped, then put them back */
if (swapped) swapDrainSource(dev, NULL, NULL);
return 0; return 0;
} }

View File

@ -2219,47 +2219,39 @@ getCurDevMult()
/* /*
*-----------------------------------------------------------------------------
* swapDrainSource * swapDrainSource
* *
* Swap drain and source ordering and the related stuff * Swap drain and source ordering and the related stuff
* including the drain/source area parameters * including the drain/source area parameters
* *
* This is typycally called if any terminal is marked with attribute "D" or "S" * This is typically called if any terminal is marked with attribute "D" or "S"
* (label "D$" or "S$" at poly-diffusion interface), * (label "D$" or "S$" at poly-diffusion interface),
* then swap order of source and drain compared to the default ordering. * then swap order of source and drain compared to the default ordering.
*
* Note:
* Before calling this function, ensure that dev->dev_nterm >= 3
* *
* Results:
* None
*
* Side effects:
* Soure (dev->dev_terms[1]) and drain (dev->dev_terms[2]) terminals
* are swapped.
*
*-----------------------------------------------------------------------------
*/ */
void void
swapDrainSource(dev, source, drain) swapDrainSource(dev)
Dev *dev; Dev *dev;
DevTerm **source, **drain;
{ {
DevParam *plist; DevTerm tmpTerm;
/* swap drain/source ordering */
if (drain) *drain = &dev->dev_terms[1];
if (source) *source = &dev->dev_terms[2];
/* Swap drain/source-related parameters. Note that the parameter */
/* *definitions* are swapped, so if this is done, it must be */
/* reverted before the next device is processed. */
plist = efGetDeviceParams(EFDevTypes[dev->dev_type]); /* swap original terminals */
while (plist != NULL) memcpy(&tmpTerm, &(dev->dev_terms[1]), sizeof(DevTerm));
{ memcpy(&(dev->dev_terms[1]), &(dev->dev_terms[2]), sizeof(DevTerm));
// Diagnostic memcpy(&(dev->dev_terms[2]), &tmpTerm, sizeof(DevTerm));
// TxPrintf(" * param: %s; type: %c%c\n", plist->parm_name, plist->parm_type[0], plist->parm_type[1]);
/* Swap drain/source parameters only */
if (!(strcmp(plist->parm_type, "a1")) || !(strcmp(plist->parm_type, "p1")))
plist->parm_type[1] = '0' + 2;
else if (!(strcmp(plist->parm_type, "a2")) || !(strcmp(plist->parm_type, "p2")))
plist->parm_type[1] = '0' + 1;
/* move pointer */
plist = plist->parm_next;
}
} }
@ -2309,7 +2301,7 @@ spcdevVisit(dev, hc, scale, trans)
DevTerm *gate, *source, *drain; DevTerm *gate, *source, *drain;
EFNode *subnode, *snode, *dnode, *subnodeFlat = NULL; EFNode *subnode, *snode, *dnode, *subnodeFlat = NULL;
int l, w, i, parmval; int l, w, i, parmval;
bool subAP= FALSE, hierS, hierD, extHierSDAttr(), swapped = FALSE ; bool subAP= FALSE, hierS, hierD, extHierSDAttr();
float sdM; float sdM;
char name[12], devchar; char name[12], devchar;
bool has_model = TRUE; bool has_model = TRUE;
@ -2331,8 +2323,11 @@ spcdevVisit(dev, hc, scale, trans)
gate = &dev->dev_terms[0]; gate = &dev->dev_terms[0];
if (dev->dev_nterm >= 2) if (dev->dev_nterm >= 2)
source = drain = &dev->dev_terms[1]; source = drain = &dev->dev_terms[1];
if (dev->dev_nterm >= 3) if (dev->dev_nterm >= 3)
{ {
drain = &dev->dev_terms[2];
/* If any terminal is marked with attribute "D" or "S" */ /* If any terminal is marked with attribute "D" or "S" */
/* (label "D$" or "S$" at poly-diffusion interface), */ /* (label "D$" or "S$" at poly-diffusion interface), */
/* then force order of source and drain accordingly. */ /* then force order of source and drain accordingly. */
@ -2342,11 +2337,8 @@ spcdevVisit(dev, hc, scale, trans)
(dev->dev_terms[2].dterm_attrs && (dev->dev_terms[2].dterm_attrs &&
!strcmp(dev->dev_terms[2].dterm_attrs, "S"))) !strcmp(dev->dev_terms[2].dterm_attrs, "S")))
{ {
swapDrainSource(dev, &source, &drain); swapDrainSource(dev);
swapped = True;
} }
else
drain = &dev->dev_terms[2];
} }
subnode = dev->dev_subsnode; subnode = dev->dev_subsnode;
@ -2852,9 +2844,6 @@ spcdevVisit(dev, hc, scale, trans)
} }
fprintf(esSpiceF, "\n"); fprintf(esSpiceF, "\n");
/* If S/D parameters on a subcircuit were swapped, put them back */
if (swapped) swapDrainSource(dev, NULL, NULL);
return 0; return 0;
} }