Initial commit at Tue Apr 25 08:41:48 EDT 2017 by tim on stravinsky

This commit is contained in:
Tim Edwards
2017-04-25 08:41:48 -04:00
commit 231a299b16
1249 changed files with 520134 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
ext2spice.o: ext2spice.c ../tcltk/tclmagic.h ../utils/magic.h \
../utils/malloc.h ../utils/geometry.h ../utils/hash.h ../utils/dqueue.h \
../utils/utils.h ../tiles/tile.h ../database/database.h \
../windows/windows.h ../textio/textio.h ../dbwind/dbwind.h \
../commands/commands.h ../textio/txcommands.h ../extflat/extflat.h \
../extflat/EFint.h ../extract/extract.h ../utils/runstats.h \
../ext2spice/ext2spice.h
ext2hier.o: ext2hier.c ../tcltk/tclmagic.h ../utils/magic.h \
../utils/malloc.h ../utils/geometry.h ../utils/hash.h ../utils/dqueue.h \
../utils/utils.h ../tiles/tile.h ../database/database.h \
../windows/windows.h ../textio/textio.h ../dbwind/dbwind.h \
../commands/commands.h ../textio/txcommands.h ../extflat/extflat.h \
../extflat/EFint.h ../extract/extract.h ../utils/runstats.h \
../ext2spice/ext2spice.h
+44
View File
@@ -0,0 +1,44 @@
#
# rcsid "$Header: /usr/cvsroot/magic-8.0/ext2spice/Makefile,v 1.2 2010/08/10 00:18:45 tim Exp $"
#
MODULE = ext2spice
MAGICDIR = ..
SRCS = ext2spice.c ext2hier.c
EXTRA_LIBS = ${MAGICDIR}/extflat/libextflat.o ${MAGICDIR}/utils/libutils.a
include ${MAGICDIR}/defs.mak
LIBS += -lm ${LD_EXTRA_LIBS} ${SUB_EXTRA_LIBS}
CLEANS += exttospice${SHDLIB_EXT} spicewrap.o spicehier.o
main: ext2spice
tcl-main: exttospice${SHDLIB_EXT}
spicewrap.o: ext2spice.c ext2spice.h
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ext2spice.c -c -o spicewrap.o
spicehier.o: ext2hier.c ext2spice.h
${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ext2hier.c -c -o spicehier.o
exttospice${SHDLIB_EXT}: spicewrap.o spicehier.o ${MAGICDIR}/extflat/libextflat.o
@echo --- making exttospice Tcl library \(exttospice${SHDLIB_EXT}\)
${RM} exttospice${SHDLIB_EXT}
${CC} ${CFLAGS} ${CPPFLAGS} -o $@ ${LDDL_FLAGS} spicewrap.o spicehier.o \
${MAGICDIR}/extflat/libextflat.o ${LD_SHARED} -lc ${LIBS}
install: $(DESTDIR)${BINDIR}/${MODULE}${EXEEXT} $(DESTDIR)${BINDIR}/spice2sim
install-tcl: $(DESTDIR)${TCLDIR}/exttospice${SHDLIB_EXT} $(DESTDIR)${BINDIR}/spice2sim
$(DESTDIR)${TCLDIR}/exttospice${SHDLIB_EXT}: exttospice${SHDLIB_EXT}
${RM} $(DESTDIR)${TCLDIR}/exttospice${SHDLIB_EXT}
${CP} exttospice${SHDLIB_EXT} $(DESTDIR)${TCLDIR}/exttospice${SHDLIB_EXT}
$(DESTDIR)${BINDIR}/spice2sim: spice2sim
${RM} $(DESTDIR)${BINDIR}/spice2sim
${CP} spice2sim $(DESTDIR)${BINDIR}/spice2sim
include ${MAGICDIR}/rules.mak
+1830
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+205
View File
@@ -0,0 +1,205 @@
/*
* ext2spice.h --
* Definitions for ext2spice.c and ext2hier.c
*/
#ifndef _EXTTOSPICE_H
#define _EXTTOSPICE_H
/* cache list used to find parallel devs */
typedef struct _devMerge {
float l, w;
EFNode *g, *s, *d, *b;
Dev * dev;
int esFMIndex;
HierName *hierName;
struct _devMerge *next;
} devMerge;
/* Forward declarations */
#ifdef MAGIC_WRAPPER
void CmdExtToSpice();
#endif
extern int spcmainArgs();
extern int spccapVisit(), spcdevVisit(), spcnodeVisit(), subcktVisit();
extern int spcresistVisit(), devMergeVisit(), devDistJunctVisit();
extern int spcsubVisit();
extern int subcktUndef();
extern EFNode *spcdevSubstrate();
extern char *nodeSpiceName();
extern int nodeVisitDebug();
extern void topVisit();
extern int _ext2spice_start();
extern EFNode *spcdevHierSubstrate();
extern char *nodeSpiceHierName();
extern devMerge *mkDevMerge();
extern bool extHierSDAttr();
/* Options specific to ext2spice */
extern bool esDoExtResis;
extern bool esDoPorts;
extern bool esDoHierarchy;
extern bool esDoResistorTee;
extern int esDoSubckt;
extern bool esDevNodesOnly;
extern bool esNoAttrs;
extern bool esHierAP;
extern char spcesDefaultOut[FNSIZE];
extern int esCapAccuracy;
extern char esSpiceCapFormat[FNSIZE];
extern char *spcesOutName;
extern FILE *esSpiceF;
extern float esScale; /* negative if hspice the EFScale/100 otherwise */
extern unsigned short esFormat;
extern unsigned long initMask;
extern int esCapNum, esDevNum, esResNum, esDiodeNum;
extern int esNodeNum; /* just in case we're extracting spice2 */
extern int esSbckNum; /* used in hspice node name shortening */
extern int esNoModelType; /* index for device type "None" (model-less device) */
extern bool esMergeDevsA; /* aggressive merging of devs L1=L2 merge them */
extern bool esMergeDevsC; /* conservative merging of devs L1=L2 and W1=W2 */
/* used with the hspice multiplier */
extern bool esDistrJunct;
extern float *esFMult; /* the array itself */
extern int esFMIndex; /* current index to it */
extern int esFMSize; /* its current size (growable) */
extern int esSpiceDevsMerged;
extern devMerge *devMergeList;
/*
* The following hash table and associated functions are used only if
* the format is hspice, to keep the translation between the hierarchical
* prefix of a node and the x num that we use to output valid hspice
* which also are meaningful.
*/
extern HashTable subcktNameTable ; /* the hash table itself */
extern DQueue subcktNameQueue ; /* q used to print it sorted at the end*/
typedef struct {
short resClassSD ; /* the resistance class of the src/drn of the dev */
short resClassSub ; /* the resistance class of the substrate of the dev */
char *defSubs ; /* the default substrate node */
} fetInfoList;
extern fetInfoList esFetInfo[MAXDEVTYPES];
#define MAX_STR_SIZE (1<<11) /* 2K should be enough for keeping temp
names even of the most complicated design */
/* Node clients for figuring out areas and perimeters of sources and drains */
typedef struct {
long _duml:MAXDEVTYPES;
} _dum; /* if you get an error here you should change
the data structures and visitMask */
typedef union {
long visitMask; /* mask for normal visits */
float *widths; /* width used for distributing area perim */
} maskOrWidth ;
typedef struct {
char *spiceNodeName;
maskOrWidth m_w;
} nodeClient;
typedef struct {
HierName *lastPrefix;
maskOrWidth m_w;
} nodeClientHier;
#define NO_RESCLASS -1
#define markVisited(client, rclass) \
{ (client)->m_w.visitMask |= (1<<rclass); }
#define clearVisited(client) \
{ (client)->m_w.visitMask = (long)0; }
#define beenVisited(client, rclass) \
( (client)->m_w.visitMask & (1<<rclass))
/*
* Used to mark the nodes which are connected to devs. initMask is set to
* DEV_CONNECT_MASK only when we are in visitDevs
*/
#define DEV_CONNECT_MASK ((unsigned long)1<<(sizeof(long)*BITSPERCHAR-1))
#define initNodeClient(node) \
{ \
(node)->efnode_client = (ClientData) mallocMagic((unsigned) (sizeof(nodeClient))); \
(( nodeClient *)(node)->efnode_client)->spiceNodeName = NULL; \
(( nodeClient *)(node)->efnode_client)->m_w.visitMask = (unsigned long)initMask; \
}
#define initNodeClientHier(node) \
{ \
(node)->efnode_client = (ClientData) mallocMagic((unsigned)(sizeof(nodeClientHier))); \
((nodeClientHier *) (node)->efnode_client)->m_w.visitMask = (unsigned long) 0; \
}
/* attributes controlling the Area/Perimeter extraction of dev terminals */
#define ATTR_FLATAP "*[Ee][Xx][Tt]:[Aa][Pp][Ff]*"
#define ATTR_HIERAP "*[Ee][Xx][Tt]:[Aa][Pp][Hh]*"
#define ATTR_SUBSAP "*[Ee][Xx][Tt]:[Aa][Pp][Ss]*"
#define SPICE2 0
#define SPICE3 1
#define HSPICE 2
#define NGSPICE 3
#define AUTO 2 /* TRUE | FALSE | AUTO for esDoSubckt */
#define NOT_PARALLEL 0
#define PARALLEL 1
#define ANTIPARALLEL 2
/*
*---------------------------------------------------------
* Variables & macros used for merging parallel devs
* The merging of devs is based on the fact that spcdevVisit
* visits the devs in the same order all the time so the
* value of esFMult[i] keeps the multiplier for the ith dev
*---------------------------------------------------------
*/
#define DEV_KILLED ((float) -1.0)
#define FMULT_SIZE (1<<10)
#define devIsKilled(n) ( esFMult[(n)] <=(float)0.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
#define atoCap(s) ((EFCapValue)atof(s))
#endif
#endif /* _EXTTOSPICE_H */
+81
View File
@@ -0,0 +1,81 @@
#!/bin/awk -f
# convert an ext2spice produced file to a .sim file for debugging
#
BEGIN {
firstLine = 1 ; gotScale = 0; firstFet = 1;
scale = 100;
}
firstLine == 1 {
if ( firstLine ) {
style = $2 ; firstLine = 0;
if ( style != "HSPICE" && style != "SPICE2" && style != "SPICE3" ) {
print "weird spice style assuming SPICE3" | "cat 1>&2"
}
if ( style == "HSPICE" ) scale = -100;
}
}
$1 ~ /^\.opt/ && $2 ~ /^scale/ {
if ( style != "HSPICE" ) {
print "ERROR: scale found in a non HSPICE file\n" | "cat 1>&2"
exit;
}
l = length($2)-7;
scale = (substr($2, 7, l))*100;
}
$1 ~ /^[m|M]/ {
if ( firstFet ) {
firstFet = 0;
if ( style == "HSPICE" && scale < 0 ) {
print "ERROR: scale not fount in HSPICE file\n"| "cat 1>&2"
exit;
}
printf "| units: %d tech: spice2sim format: MIT\n", scale
scale = scale/100;
}
sl = $8; sw = $7;
ll = length(sl);
lw = length(sw);
if ( style != "HSPICE" ) {
if (substr(sw, lw, 1)!= "u" || substr(sl, ll, 1) != "u") {
print "ERROR: weird units in w/l of fet:\n", $0 | "cat 1>&2"
exit;
}
l = substr(sl, 3, ll-3);
w = substr(sw, 3, lw-3);
} else { # HSPICE
l = substr(sl, 3, ll-2);
w = substr(sw, 3, lw-2);
if ( NF == 9 ) { # get the mult
if ( substr($9, 1, 2) != "M=" ) {
printf "ERROR - weird multiplier : %s\n", $0;
} else w = w * (substr($9, 3, 100)+1.0-1.0);
}
}
printf "%s %s %s %s %.2f %.2f\n", substr($6,1,1), $3, $2, $4, l, w;
}
$1 ~ /^[c|C]/ {
if ( $4 ~ /[0-9]*fF/ )
printf "C %s %s %s\n", $2, $3, substr($4, 1, length($4)-2);
else
printf "ERROR - weird capacitor: %s\n", $0;
}
$1 ~ /^[R|R]/ {
if ( $4 ~ /^[0-9]*/ )
printf "r %s %s %s\n", $2, $3, $4;
else
printf "ERROR - weird resistor: %s\n", $0;
}
$1 ~ /^[q|Q]/ {
print "ERROR: found a bipolar in spice file" | "cat 1>&2"
}
$1 ~ /^[v|V]/ {
print "ERROR: found a voltage source in spice file" | "cat 1>&2"
}