diff --git a/ext2sim/ext2sim.c b/ext2sim/ext2sim.c index 7034cc71..35b28c05 100644 --- a/ext2sim/ext2sim.c +++ b/ext2sim/ext2sim.c @@ -92,10 +92,11 @@ FILE *esLabF = NULL; static unsigned short esFormat = MIT ; struct { - short resClassSource ; /* the resistance class of the source of the dev */ - short resClassDrain ; /* the resistance class of the drain of the dev */ - short resClassSub ; /* the resistance class of the substrate of the dev */ - char *defSubs ; /* the default substrate node */ + short resClassSource ; /* The resistance class of the source of the dev */ + short resClassDrain ; /* The resistance class of the drain of the dev */ + short resClassSub ; /* The resistance class of the substrate of the dev */ + TileType devType ; /* Magic tile type of the device */ + char *defSubs ; /* The default substrate node */ } fetInfo[MAXDEVTYPES]; typedef struct { @@ -266,6 +267,7 @@ CmdExtToSim(w, cmd) short s_rclass, d_rclass, sub_rclass; char *devname; char *subname; + TileType devtype; int idx; static EFCapValue LocCapThreshold = 2; @@ -576,6 +578,7 @@ runexttosim: fetInfo[i].resClassDrain = NO_RESCLASS; fetInfo[i].resClassSub = NO_RESCLASS; fetInfo[i].defSubs = NULL; + fetInfo[i].devType = TT_SPACE; } /* Get fetInfo information from the current extraction style */ @@ -583,7 +586,8 @@ runexttosim: /* command) */ idx = 0; - while (ExtGetDevInfo(idx++, &devname, &s_rclass, &d_rclass, &sub_rclass, &subname)) + while (ExtGetDevInfo(idx++, &devname, &devtype, &s_rclass, &d_rclass, + &sub_rclass, &subname)) { if (idx == MAXDEVTYPES) { @@ -598,6 +602,7 @@ runexttosim: fetInfo[i].resClassDrain = d_rclass; fetInfo[i].resClassSub = sub_rclass; fetInfo[i].defSubs = subname; + fetInfo[i].devType = devtype; } } @@ -676,6 +681,7 @@ main(argc, argv) fetInfo[i].resClassDrain = NO_RESCLASS; fetInfo[i].resClassSub = NO_RESCLASS; fetInfo[i].defSubs = NULL; + fetInfo[i].devType = TT_SPACE; } i = efBuildAddStr(EFDevTypes, &EFDevNumTypes, MAXDEVTYPES, "nfet"); fetInfo[i].resClassSource = fetInfo[i].resClassDrain = 0 ; @@ -895,6 +901,7 @@ simmainArgs(pargc, pargv) fetInfo[ndx].resClassDrain = rClass; fetInfo[ndx].resClassSub = rClassSub; fetInfo[ndx].defSubs = (char *) mallocMagic((unsigned) (strlen(subsNode)+1)); + fetInfo[ndx].devType = TT_SPACE; strcpy(fetInfo[ndx].defSubs,subsNode); TxError("Info: fet %s(%d) sdRclass=%d subRclass=%d dSub=%s\n", cp, ndx, fetInfo[ndx].resClassSD, fetInfo[ndx].resClassSub, @@ -1047,6 +1054,41 @@ simdevVisit(dev, hc, scale, trans) case DEV_CAPREV: fprintf(esSimF, "c"); /* sim format extension */ break; + case DEV_FET: + case DEV_MOSFET: + case DEV_ASYMMETRIC: + case DEV_MSUBCKT: + /* The sim file format only understands "n" and "p" for FETs. */ + /* The extraction method says nothing about which is which. */ + /* The EFDevTypes[] should ideally start with "n" or "p". If */ + /* it doesn't, then dev->dev_type should. If neither does, */ + /* then use EFDevTypes[] but flag an error. */ + + if (EFDevTypes[dev->dev_type][0] == 'n' || + EFDevTypes[dev->dev_type][0] == 'p') + { + fprintf(esSimF, "%c", EFDevTypes[dev->dev_type][0]); + } + else + { + TileType ttype = fetInfo[dev->dev_type].devType; + + if (DBTypeLongNameTbl[ttype][0] == 'n' || + DBTypeLongNameTbl[ttype][0] == 'p') + { + fprintf(esSimF, "%c", DBTypeLongNameTbl[ttype][0]); + } + else + { + TxError("Error: MOSFET device type \"%s\" does not start with " + "\"n\" or \"p\" as required for the .sim format\n", + EFDevTypes[dev->dev_type]); + + /* Default to "n" */ + fprintf(esSimF, "n"); + } + } + break; default: fprintf(esSimF, "%c", EFDevTypes[dev->dev_type][0]); break; diff --git a/ext2spice/ext2spice.c b/ext2spice/ext2spice.c index 0a402d7b..5abbfe43 100644 --- a/ext2spice/ext2spice.c +++ b/ext2spice/ext2spice.c @@ -242,6 +242,7 @@ CmdExtToSpice(w, cmd) short s_rclass, d_rclass, sub_rclass; char *devname; char *subname; + TileType devtype; int idx, idx2; globalList *glist = NULL; @@ -739,7 +740,8 @@ runexttospice: /* command) */ idx = 0; - while (ExtGetDevInfo(idx++, &devname, &s_rclass, &d_rclass, &sub_rclass, &subname)) + while (ExtGetDevInfo(idx++, &devname, &devtype, &s_rclass, &d_rclass, + &sub_rclass, &subname)) { if (idx == MAXDEVTYPES) { diff --git a/extract/ExtTech.c b/extract/ExtTech.c index c0b2da44..4f6bdb59 100644 --- a/extract/ExtTech.c +++ b/extract/ExtTech.c @@ -304,9 +304,11 @@ ExtCompareStyle(stylename) */ bool -ExtGetDevInfo(idx, devnameptr, s_rclassptr, d_rclassptr, sub_rclassptr, subnameptr) +ExtGetDevInfo(idx, devnameptr, devtypeptr, s_rclassptr, d_rclassptr, + sub_rclassptr, subnameptr) int idx; - char **devnameptr; + char **devnameptr; /* Name of extracted device model */ + TileType *devtypeptr; /* Magic tile type of device */ short *s_rclassptr; /* Source (1st terminal) type only */ short *d_rclassptr; /* Drain (2nd terminal) type only */ short *sub_rclassptr; @@ -354,6 +356,7 @@ ExtGetDevInfo(idx, devnameptr, s_rclassptr, d_rclassptr, sub_rclassptr, subnamep *devnameptr = locdname; *subnameptr = devptr->exts_deviceSubstrateName; + *devtypeptr = t; tmask = &devptr->exts_deviceSDTypes[0]; *s_rclassptr = (short)(-1); /* NO_RESCLASS */