not used, superceeded by numparam code
This commit is contained in:
parent
d399ba5ecd
commit
ba9d4554e5
|
|
@ -1,17 +0,0 @@
|
||||||
2000-10-10 Arno W. Peters <A.W.Peters@ieee.org>
|
|
||||||
|
|
||||||
* mslib, spiceprm: Michael Widlok released new version of his
|
|
||||||
programs.
|
|
||||||
|
|
||||||
2000-03-22 Paolo Nenzi <p.nenzi@ieee.org>
|
|
||||||
|
|
||||||
* mslib: Major update. M. Widlok sent the new version of it's
|
|
||||||
programs.
|
|
||||||
|
|
||||||
* spiceprm: Major update. See above line.
|
|
||||||
|
|
||||||
1999-09-14 Arno W. Peters <A.W.Peters@ieee.org>
|
|
||||||
|
|
||||||
* mslib: Added.
|
|
||||||
|
|
||||||
* spiceprm: Added.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
Mslib is free for everyone who think that it might by useful for
|
|
||||||
him. If someone makes it better please e-mail me.
|
|
||||||
|
|
||||||
Michael Widlok
|
|
||||||
widlok@uci.agh.edu.pl
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
/*
|
|
||||||
* MW. Include for spice
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ngspice_DATADEF_H
|
|
||||||
#define ngspice_DATADEF_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Program defaults
|
|
||||||
*
|
|
||||||
* *Directory for input file and input libraries
|
|
||||||
*/
|
|
||||||
#define DECKPATH "./"
|
|
||||||
#define LIBPATH "/usr/local/lib/"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Name for output library file
|
|
||||||
*/
|
|
||||||
#define TMPLIBNAME ".lib" /*
|
|
||||||
* * * * actual name is "deck.TMPLIBNAME"
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Command for libraries, subckts and models declaration
|
|
||||||
*/
|
|
||||||
#define LIBINVL "*LIB"
|
|
||||||
#define SUBINVL "*SUB"
|
|
||||||
#define MODINVL "*MOD"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Keywords for subckt start, end and model
|
|
||||||
*/
|
|
||||||
#define SUBLINE ".SUBCKT"
|
|
||||||
#define SUBEND ".ENDS"
|
|
||||||
#define MODLINE ".MODEL"
|
|
||||||
#define MODEND
|
|
||||||
|
|
||||||
#define LIBMESSAGE "* MW Library include for Spice"
|
|
||||||
|
|
||||||
#define BSIZE 255
|
|
||||||
#define MODDLINE 1
|
|
||||||
#define SUBDLINE 4
|
|
||||||
#define LIBDLINE 8
|
|
||||||
#define SUBLLINE 16
|
|
||||||
#define MODLLINE 32
|
|
||||||
#define ENDSLLINE 64
|
|
||||||
#define CONTLLINE 128
|
|
||||||
#define NORMLINE 0
|
|
||||||
#define WRITESUB 0xffff
|
|
||||||
#define WRITEMOD 0x1111
|
|
||||||
#define NOWRITE 0x0
|
|
||||||
#define FAILED 0xffffff
|
|
||||||
#define SUCCESS 0
|
|
||||||
|
|
||||||
#define IS_LIB 0x1
|
|
||||||
#define LIB_OPEN 0x2
|
|
||||||
|
|
||||||
#define IS_MOD 0x10
|
|
||||||
#define IS_SUB 0x100
|
|
||||||
#define FINDED 0x400
|
|
||||||
#define DUPLICATE 0x800
|
|
||||||
|
|
||||||
#define DECK_OPEN 0x20000
|
|
||||||
#define TLIB_OPEN 0x100000
|
|
||||||
|
|
||||||
#define NAMEVALID 0xfff
|
|
||||||
#define NAMENOTV 0x0
|
|
||||||
|
|
||||||
struct LSData
|
|
||||||
{
|
|
||||||
char name[BSIZE];
|
|
||||||
FILE *filedes;
|
|
||||||
int flag;
|
|
||||||
struct LSData *prevLS;
|
|
||||||
struct LSData *nextLS;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LSData *LSinsert(struct LSData *LS, struct LSData *where);
|
|
||||||
struct LSData *LSclear(struct LSData *LS);
|
|
||||||
struct LSData *Backfree(struct LSData *LS);
|
|
||||||
int readdeck(FILE * tdeck, struct LSData *lib, \
|
|
||||||
struct LSData *sub, struct LSData *mod);
|
|
||||||
int readlib(struct LSData *lib, FILE * tlib, \
|
|
||||||
struct LSData *firstSUB, struct LSData *firstMOD);
|
|
||||||
int checkname(struct LSData *smp, char *name);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
* MW. Include for spice - LSData functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "datadef.h"
|
|
||||||
|
|
||||||
char *Message = "Michael Widlok, all rights reserved \n"
|
|
||||||
"mslib - MW include for Spice models/subckts\n";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add or cretate new LS structure just after where pointer
|
|
||||||
*/
|
|
||||||
struct LSData *
|
|
||||||
LSinsert(struct LSData *LS, struct LSData *where)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!(LS))
|
|
||||||
{
|
|
||||||
LS = (struct LSData *) malloc(sizeof(struct LSData));
|
|
||||||
|
|
||||||
if (!(LS))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "LSinsert: Can't allocate LSData srtucture.\n");
|
|
||||||
exit(FAILED);
|
|
||||||
}
|
|
||||||
LS->filedes = NULL;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If where is given we must set nextLS and prevLS correctly
|
|
||||||
*/
|
|
||||||
if (where)
|
|
||||||
{
|
|
||||||
LS->prevLS = where;
|
|
||||||
if (LS->nextLS = where->nextLS)
|
|
||||||
where->nextLS->prevLS = LS;
|
|
||||||
where->nextLS = LS;
|
|
||||||
} else
|
|
||||||
LS->nextLS = LS->prevLS = NULL;
|
|
||||||
return LS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear all LS list from end. This also closes opened files
|
|
||||||
*/
|
|
||||||
struct LSData *
|
|
||||||
LSclear(struct LSData *LS)
|
|
||||||
{
|
|
||||||
while (LS->nextLS)
|
|
||||||
LS = LS->nextLS;
|
|
||||||
return Backfree(LS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used by LSclear
|
|
||||||
*/
|
|
||||||
struct LSData *
|
|
||||||
Backfree(struct LSData *LS)
|
|
||||||
{
|
|
||||||
if (LS->filedes)
|
|
||||||
fclose(LS->filedes);
|
|
||||||
return (LS->prevLS) ? Backfree(LS->prevLS) : free(LS), LS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if sub/mod name should by included
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
checkname(struct LSData *smp, char *name)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (!(strcmp(smp->name, name)))
|
|
||||||
{
|
|
||||||
if (smp->flag != FINDED)
|
|
||||||
{
|
|
||||||
smp->flag = FINDED;
|
|
||||||
return NAMEVALID;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
smp->flag = DUPLICATE;
|
|
||||||
return NAMEVALID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
smp = smp->nextLS;
|
|
||||||
}
|
|
||||||
while (smp);
|
|
||||||
return NAMENOTV;
|
|
||||||
}
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
/*
|
|
||||||
* MW. Include for spice
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "datadef.h"
|
|
||||||
|
|
||||||
static int whatdline(char *tbuf, char *firstname);
|
|
||||||
static int whatlline(char *tbuf, char *name);
|
|
||||||
|
|
||||||
extern int bsizer;
|
|
||||||
extern char buf[BSIZE];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read deck and search for *MOD, *LIB, *SUB commands
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
readdeck(FILE * tdeck, struct LSData *lib, \
|
|
||||||
struct LSData *sub, struct LSData *mod)
|
|
||||||
{
|
|
||||||
char firstname[BSIZE];
|
|
||||||
char *names, *smlp;
|
|
||||||
struct LSData *which;
|
|
||||||
|
|
||||||
while (fgets(buf, bsizer, tdeck))
|
|
||||||
{
|
|
||||||
|
|
||||||
smlp = buf;
|
|
||||||
/*
|
|
||||||
* Ignore control chars at the end of line
|
|
||||||
*/
|
|
||||||
do
|
|
||||||
{
|
|
||||||
smlp++;
|
|
||||||
}
|
|
||||||
while ((!(iscntrl(*smlp))) && (*smlp != '\0'));
|
|
||||||
*smlp = '\0';
|
|
||||||
|
|
||||||
switch (whatdline(buf, firstname))
|
|
||||||
{
|
|
||||||
|
|
||||||
case LIBDLINE:
|
|
||||||
lib->flag = IS_LIB;
|
|
||||||
which = lib;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SUBDLINE:
|
|
||||||
sub->flag = IS_SUB;
|
|
||||||
which = sub;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MODDLINE:
|
|
||||||
mod->flag = IS_MOD;
|
|
||||||
which = mod;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
which = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we finded something
|
|
||||||
*/
|
|
||||||
if (which)
|
|
||||||
{
|
|
||||||
names = buf;
|
|
||||||
strsep(&names, " ");
|
|
||||||
|
|
||||||
while (smlp = strsep(&names, " "))
|
|
||||||
{
|
|
||||||
if (*smlp)
|
|
||||||
{
|
|
||||||
which = LSinsert(NULL, which);
|
|
||||||
strcpy(which->name, smlp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ((lib->flag != IS_LIB) && (mod->flag != IS_MOD) \
|
|
||||||
&&(sub->flag != IS_SUB)) ? FAILED : SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read library and write specififed models/subckts to tmplib
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
readlib(struct LSData *lib, FILE * tlib, \
|
|
||||||
struct LSData *sub, struct LSData *mod)
|
|
||||||
{
|
|
||||||
|
|
||||||
char name[BSIZE];
|
|
||||||
int numi, wflag, nextsub;
|
|
||||||
|
|
||||||
numi = 0;
|
|
||||||
wflag = NOWRITE;
|
|
||||||
nextsub = 0;
|
|
||||||
|
|
||||||
while (fgets(buf, bsizer, lib->filedes))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Now we must check what line is it and if it should be written to tmplib
|
|
||||||
*/
|
|
||||||
switch (whatlline(buf, name))
|
|
||||||
{
|
|
||||||
|
|
||||||
case (MODLLINE):
|
|
||||||
if (wflag == WRITESUB)
|
|
||||||
fputs(buf, tlib);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if (mod)
|
|
||||||
{
|
|
||||||
if (checkname(mod, name))
|
|
||||||
{
|
|
||||||
wflag = WRITEMOD;
|
|
||||||
numi++;
|
|
||||||
fprintf(tlib, "* Model: %s, from: %s.\n", \
|
|
||||||
name, lib->name);
|
|
||||||
fputs(buf, tlib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (SUBLLINE):
|
|
||||||
if (sub)
|
|
||||||
{
|
|
||||||
if (wflag==WRITESUB)
|
|
||||||
{
|
|
||||||
/* subckt inside subckt
|
|
||||||
not so funny */
|
|
||||||
nextsub++;
|
|
||||||
fputs(buf, tlib);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkname(sub, name))
|
|
||||||
{
|
|
||||||
wflag = WRITESUB;
|
|
||||||
numi++;
|
|
||||||
fprintf(tlib, "* Subckt: %s, from: %s.\n", \
|
|
||||||
name, lib->name);
|
|
||||||
fputs(buf, tlib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (NORMLINE):
|
|
||||||
if (wflag == WRITEMOD)
|
|
||||||
{
|
|
||||||
wflag = NOWRITE;
|
|
||||||
fputs("\n* End Model.\n\n", tlib);
|
|
||||||
}
|
|
||||||
if (wflag == WRITESUB)
|
|
||||||
fputs(buf, tlib);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (ENDSLLINE):
|
|
||||||
if (nextsub)
|
|
||||||
{
|
|
||||||
nextsub--;
|
|
||||||
fputs(buf, tlib);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (wflag == WRITESUB)
|
|
||||||
{
|
|
||||||
fprintf(tlib, "%s\n* End Subckt\n\n", buf);
|
|
||||||
}
|
|
||||||
wflag = NOWRITE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case (CONTLLINE):
|
|
||||||
if (wflag != NOWRITE)
|
|
||||||
fputs(buf, tlib);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return numi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check what line in deck it is
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
whatdline(char *tbuf, char *firstname)
|
|
||||||
{
|
|
||||||
if (sscanf(tbuf, "*LIB %s", firstname) == 1)
|
|
||||||
return LIBDLINE;
|
|
||||||
if (sscanf(tbuf, "*SUB %s", firstname) == 1)
|
|
||||||
return SUBDLINE;
|
|
||||||
if (sscanf(tbuf, "*MOD %s", firstname) == 1)
|
|
||||||
return MODDLINE;
|
|
||||||
return NORMLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check what line it is. If we have model or subckt line we also read its name
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
whatlline(char *tbuf, char *name)
|
|
||||||
{
|
|
||||||
if (sscanf(tbuf, ".SUBCKT %s %*s", name) == 1)
|
|
||||||
return SUBLLINE;
|
|
||||||
if (sscanf(tbuf, ".MODEL %s %*s", name) == 1)
|
|
||||||
return MODLLINE;
|
|
||||||
if (sscanf(tbuf, ".ENDS%c", name) == 1)
|
|
||||||
return ENDSLLINE;
|
|
||||||
if (sscanf(tbuf, "+%s", name) == 1)
|
|
||||||
return CONTLLINE;
|
|
||||||
return NORMLINE;
|
|
||||||
}
|
|
||||||
|
|
@ -1,208 +0,0 @@
|
||||||
/*
|
|
||||||
* MW. Include - main functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "datadef.h"
|
|
||||||
|
|
||||||
struct LSData *firstLIB;
|
|
||||||
struct LSData *firstSUB;
|
|
||||||
struct LSData *firstMOD;
|
|
||||||
struct LSData *deck;
|
|
||||||
struct LSData *tmplib;
|
|
||||||
int bsize, bsizer;
|
|
||||||
char buf[BSIZE];
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize everything
|
|
||||||
*/
|
|
||||||
struct LSData *subp, *libp, *modp;
|
|
||||||
char tch[BSIZE];
|
|
||||||
int mswritten;
|
|
||||||
|
|
||||||
tmplib = LSinsert(NULL, NULL);
|
|
||||||
deck = LSinsert(NULL, NULL);
|
|
||||||
*tch = '\0';
|
|
||||||
mswritten = 0;
|
|
||||||
|
|
||||||
switch (argc)
|
|
||||||
{
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
strcpy(tmplib->name, argv[--argc]);
|
|
||||||
strcpy(tch, tmplib->name);
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
strcpy(deck->name, argv[--argc]);
|
|
||||||
if (!(*tch))
|
|
||||||
{
|
|
||||||
sprintf(tmplib->name, "%s%s", deck->name, TMPLIBNAME);
|
|
||||||
strcpy(tch, tmplib->name);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
fprintf(stdout, "Usage: mslib deck [tmplib]\n");
|
|
||||||
return FAILED;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr, "mslib: Incorrect parameters count.\n");
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open deck
|
|
||||||
*/
|
|
||||||
if (!(deck->filedes = fopen(deck->name, "r")))
|
|
||||||
{
|
|
||||||
sprintf(deck->name, "%s%s", DECKPATH, argv[1]);
|
|
||||||
sprintf(tmplib->name, "%s%s", DECKPATH, tch);
|
|
||||||
|
|
||||||
if (!(deck->filedes = fopen(deck->name, "r")))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "mslib: Can't open deck %s.\n", deck->name);
|
|
||||||
LSclear(deck);
|
|
||||||
LSclear(tmplib);
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bsizer = BSIZE;
|
|
||||||
bsize = bsizer--;
|
|
||||||
|
|
||||||
deck->flag = DECK_OPEN;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create tmplib and write first line to it
|
|
||||||
*/
|
|
||||||
if (!(tmplib->filedes = fopen(tmplib->name, "w")))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "mslib: Can't creat tmplib %s.\n", tmplib->name);
|
|
||||||
LSclear(tmplib);
|
|
||||||
LSclear(deck);
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
tmplib->flag = TLIB_OPEN;
|
|
||||||
fprintf(tmplib->filedes, "%s\n* Tmp library: %s,\n* For deck: %s.\n\n", \
|
|
||||||
LIBMESSAGE, tmplib->name, deck->name);
|
|
||||||
|
|
||||||
firstLIB = LSinsert(NULL, NULL);
|
|
||||||
firstSUB = LSinsert(NULL, NULL);
|
|
||||||
firstMOD = LSinsert(NULL, NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find commands in deck
|
|
||||||
*/
|
|
||||||
readdeck(deck->filedes, firstLIB, firstSUB, firstMOD);
|
|
||||||
|
|
||||||
if (firstLIB->flag = IS_LIB)
|
|
||||||
{
|
|
||||||
|
|
||||||
libp = firstLIB->nextLS;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (!(libp->filedes = fopen(libp->name, "r")))
|
|
||||||
{
|
|
||||||
strcpy(tch, libp->name);
|
|
||||||
sprintf(libp->name, "%s%s", LIBPATH, tch);
|
|
||||||
|
|
||||||
if (!(libp->filedes = fopen(libp->name, "r")))
|
|
||||||
{
|
|
||||||
libp->flag = FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Read libraries if everything is OK
|
|
||||||
*/
|
|
||||||
if (libp->flag != FAILED)
|
|
||||||
{
|
|
||||||
libp->flag = LIB_OPEN;
|
|
||||||
|
|
||||||
modp = (firstMOD->flag == IS_MOD) ? firstMOD->nextLS : NULL;
|
|
||||||
subp = (firstSUB->flag == IS_SUB) ? firstSUB->nextLS : NULL;
|
|
||||||
|
|
||||||
mswritten += readlib(libp, tmplib->filedes, subp, modp);
|
|
||||||
}
|
|
||||||
libp = libp->nextLS;
|
|
||||||
}
|
|
||||||
while (libp);
|
|
||||||
}
|
|
||||||
fprintf(stdout, "mslib: Written %d items to tmplib %s.\n", \
|
|
||||||
mswritten, tmplib->name);
|
|
||||||
|
|
||||||
if (libp = firstLIB->nextLS)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (libp->flag != LIB_OPEN)
|
|
||||||
fprintf(stderr, " Can't open lib %s.\n", libp->name);
|
|
||||||
libp = libp->nextLS;
|
|
||||||
}
|
|
||||||
while (libp);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Check is models or subckts were find and
|
|
||||||
* * are not duplicated
|
|
||||||
*/
|
|
||||||
if (modp = firstMOD->nextLS)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
switch (modp->flag)
|
|
||||||
{
|
|
||||||
case DUPLICATE:
|
|
||||||
fprintf(stderr, " Model duplicated %s.\n", \
|
|
||||||
modp->name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fprintf(stderr, " Can't find model %s.\n", \
|
|
||||||
modp->name);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FINDED:
|
|
||||||
}
|
|
||||||
|
|
||||||
modp = modp->nextLS;
|
|
||||||
}
|
|
||||||
while (modp);
|
|
||||||
}
|
|
||||||
if (subp = firstSUB->nextLS)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
switch (subp->flag)
|
|
||||||
{
|
|
||||||
case DUPLICATE:
|
|
||||||
fprintf(stderr, " Subckt duplicated %s.\n", \
|
|
||||||
subp->name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fprintf(stderr, " Can't find subckt %s.\n", \
|
|
||||||
subp->name);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FINDED:
|
|
||||||
}
|
|
||||||
subp = subp->nextLS;
|
|
||||||
}
|
|
||||||
while (subp);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Clear all data and close files
|
|
||||||
*/
|
|
||||||
|
|
||||||
LSclear(tmplib);
|
|
||||||
LSclear(deck);
|
|
||||||
LSclear(firstLIB);
|
|
||||||
LSclear(firstSUB);
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#set -x -v
|
|
||||||
|
|
||||||
# MW. Lib search / show program
|
|
||||||
|
|
||||||
# usage liblook libname [text_to_find] [l_before] [l_after]
|
|
||||||
|
|
||||||
LIBPATH=/usr/local/lib
|
|
||||||
|
|
||||||
function trapper()
|
|
||||||
{
|
|
||||||
echo User break!
|
|
||||||
echo Exiting . . .
|
|
||||||
unset LIBPATH
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
trap trapper SIGINT SIGQUIT
|
|
||||||
|
|
||||||
function operror()
|
|
||||||
{
|
|
||||||
echo Incorrect parameters: $*, $#
|
|
||||||
echo Usage: liblook libname [text_to_find] [l_before] [l_after]
|
|
||||||
unset LIBPATH
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function showlib()
|
|
||||||
{
|
|
||||||
if test -f $LIBPATH/$1; then
|
|
||||||
less $LIBPATH/$1; exit 0; fi
|
|
||||||
|
|
||||||
if test -f [C./$1; then
|
|
||||||
less ./$1; exit 0; fi
|
|
||||||
|
|
||||||
echo Searching $1 in ~/ . . .
|
|
||||||
less $(find ~/ -name $1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function searchlib()
|
|
||||||
{
|
|
||||||
if test -f $LIBPATH/$1; then
|
|
||||||
echo File: $1; echo;
|
|
||||||
grep -B"$3" -A"$4" --ignore-case -e "$2" $LIBPATH/$1;
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
if test -f ./$1; then
|
|
||||||
echo File: $1; echo;
|
|
||||||
grep -B"$3" -A"$4" --ignore-case -e "$2" ./$1;
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
#if *.lib or sth like this
|
|
||||||
|
|
||||||
echo Searching $1 in ~/ . . .;echo;
|
|
||||||
if (grep -B"$3" -A"$4" --ignore-case -e "$2" $(find ~/ -name $1)); then
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
echo Searching $1 in $LIBPATH;echo;
|
|
||||||
if (grep -B"$3" -A"$4" --ignore-case -e "$2" $(find $LIBPATH -name $1)); then
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Main body
|
|
||||||
if test $# -lt 1 -o $# -gt 4; then operror $*; fi
|
|
||||||
|
|
||||||
case $# in
|
|
||||||
1) showlib $*;;
|
|
||||||
2) searchlib $1 $2 2 2;;
|
|
||||||
3) searchlib $1 $2 $3 2;;
|
|
||||||
4) searchlib $1 $2 $3 $4;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unset LIBPATH
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#set -x -v
|
|
||||||
|
|
||||||
# MW. Lip / Param parsing program for spice
|
|
||||||
|
|
||||||
# -n normal, -f full (keep everything), -r replace original file
|
|
||||||
# -e new addition start with editor, then like normal
|
|
||||||
|
|
||||||
export TMPLP=/tmp/LibPrm.$$-
|
|
||||||
|
|
||||||
function trapper()
|
|
||||||
{
|
|
||||||
echo User break!
|
|
||||||
echo Exiting . . .
|
|
||||||
rm -f -v ${TMPLP}*
|
|
||||||
unset TMPLP
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
trap trapper SIGINT SIGQUIT
|
|
||||||
|
|
||||||
function operror()
|
|
||||||
{
|
|
||||||
echo Incorrect parameters: $*, $#
|
|
||||||
unset TMPLP
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function repnormpl()
|
|
||||||
{
|
|
||||||
mslib $1 ${TMPLP}1
|
|
||||||
sed -n -e 'p' -e "1r ${TMPLP}1" $1 >${TMPLP}2
|
|
||||||
spiceprm ${TMPLP}2 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
function keepall()
|
|
||||||
{
|
|
||||||
mslib $1
|
|
||||||
sed -n -e 'p' -e "1r $1.lib" $1 >${TMPLP}2
|
|
||||||
spiceprm ${TMPLP}2 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
function withedit()
|
|
||||||
{
|
|
||||||
joe $1
|
|
||||||
mslib $1 ${TMPLP}1
|
|
||||||
sed -n -e 'p' -e "1r ${TMPLP}1" $1 >${TMPLP}2
|
|
||||||
spiceprm ${TMPLP}2 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Main body
|
|
||||||
if test $# -lt 2 -o $# -gt 3; then operror $*; fi
|
|
||||||
if !(test -f $2); then operror $*; fi
|
|
||||||
|
|
||||||
case $1$# in
|
|
||||||
-r3) operror $*;;
|
|
||||||
-n2) repnormpl $2 ${2%.cir}.ckt;;
|
|
||||||
-n3) repnormpl $2 $3;;
|
|
||||||
-r2) repnormpl $2 $2;;
|
|
||||||
-f2) keepall $2 ${2%.cir}.ckt;;
|
|
||||||
-f3) keepall $2 $3;;
|
|
||||||
-e2) withedit $2 ${2%.cir}.ckt;;
|
|
||||||
-e3) withedit $2 $3;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
rm -f ${TMPLP}*
|
|
||||||
unset TMPLP
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
So, this is my idea of using parametrized subckts with spice3f4.
|
|
||||||
|
|
||||||
First I create an input file like foo.cir and I include commands for
|
|
||||||
mslib (*MOD, *SUB, *LIB) in it. Then I run "libprm -n foo.cir". Libprm then
|
|
||||||
runs mslib first to get all models and subckts form given libraries and then
|
|
||||||
runs spiceprm to evaluate all used parameters.
|
|
||||||
This works quite right for me, and I hope that You will find my idea
|
|
||||||
useful. Spiceprm is not my program (I get it from Internet), but I think
|
|
||||||
that it will better to enclose all used programs in this packet. Spiceprm
|
|
||||||
has it's own directory with very good readme and examples. If You want to
|
|
||||||
find out more about libprm or mslib look for the source code. These are rather
|
|
||||||
short and easy programs - they are all that I could write in quite short
|
|
||||||
time.
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
# MW. Include libs for Spice
|
|
||||||
CFLAGS= -O2 -s
|
|
||||||
LDFLAGS= -s
|
|
||||||
|
|
||||||
OBJS= inc_main.o inc_inp.o inc_LSD.o
|
|
||||||
HDRS= datadef.h
|
|
||||||
SRCC= inc_main.c inc_inp.c inc_LSD.c
|
|
||||||
|
|
||||||
mslib: $(OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(OBJS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) $(OBJS) mslib
|
|
||||||
|
|
||||||
$(OBJS): $(HDRS)
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
Mslib can create a small tmp library which can be .include to spice deck or
|
|
||||||
used as tmp file with libprm.
|
|
||||||
You invoke it like this: mslib deck_name [tmp_lib_name]. If second argument
|
|
||||||
is not given mslib uses deck_name.lib. Mslib then reads deck and looks for
|
|
||||||
special commands in it. This commands are:
|
|
||||||
|
|
||||||
*SUB name1 name2 ... - what subckts are used
|
|
||||||
*MOD name1 name2 ... - what models are used
|
|
||||||
*LIB name1 name2 ... - what libraries should be searched
|
|
||||||
|
|
||||||
You can give full path for libraries or just the name. Mslib tries to
|
|
||||||
find them in current directory and then in directory specified in datadef.h
|
|
||||||
file. There are also some other default options defined there. Check them
|
|
||||||
After all a tmp. library for the deck is created. It consist only the models
|
|
||||||
and subckts that were specified in *MOD and *SUB commands.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This is all.
|
|
||||||
Mslib is _NOT_ a good program. It should automatically recognize what models
|
|
||||||
or subckts were used and it should be written with flex or bison. Now it
|
|
||||||
just indicates what is my level of programming in C.
|
|
||||||
There are some options that You can set for mslib in datadef.h. I tried to
|
|
||||||
document all of them there, so when want to know more look to the sources.
|
|
||||||
|
|
||||||
And one more thing. There is a perl program "spiceprm" that lets You use
|
|
||||||
parameters in subckts. Many Intusoft's libraries use this feature. To use
|
|
||||||
parameters I have written a small shell script "libprm". This program
|
|
||||||
automatic runs spiceprm and mslib on Your's deck to give a working spice
|
|
||||||
input file. To see how this all works please read "libprm_readme" and
|
|
||||||
spiceprm readme.
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
These scripts are free for everyone who think that they might by useful for
|
|
||||||
him. If someone makes them better please e-mail me.
|
|
||||||
|
|
||||||
Michael Widlok
|
|
||||||
widlok@uci.agh.edu.pl
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#set -x -v
|
|
||||||
|
|
||||||
# MW. Lib search / show program
|
|
||||||
|
|
||||||
# usage liblook libname [text_to_find] [l_before] [l_after]
|
|
||||||
|
|
||||||
LIBPATH=/usr/local/lib
|
|
||||||
|
|
||||||
function trapper()
|
|
||||||
{
|
|
||||||
echo User break!
|
|
||||||
echo Exiting . . .
|
|
||||||
unset LIBPATH
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
trap trapper SIGINT SIGQUIT
|
|
||||||
|
|
||||||
function operror()
|
|
||||||
{
|
|
||||||
echo Incorrect parameters: $*, $#
|
|
||||||
echo Usage: liblook libname [text_to_find] [l_before] [l_after]
|
|
||||||
unset LIBPATH
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function showlib()
|
|
||||||
{
|
|
||||||
if test -f $LIBPATH/$1; then
|
|
||||||
less $LIBPATH/$1; exit 0; fi
|
|
||||||
|
|
||||||
if test -f [C./$1; then
|
|
||||||
less ./$1; exit 0; fi
|
|
||||||
|
|
||||||
echo Searching $1 in ~/ . . .
|
|
||||||
less $(find ~/ -name $1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function searchlib()
|
|
||||||
{
|
|
||||||
if test -f $LIBPATH/$1; then
|
|
||||||
echo File: $LIBNMAE; echo;
|
|
||||||
grep -B"$3" -A"$4" --ignore-case -e "$2" $LIBPATH/$LIBNAME1;
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
if test -f ./$1; then
|
|
||||||
echo File: $1; echo;
|
|
||||||
grep -B"$3" -A"$4" --ignore-case -e "$2" ./$1;
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
#if *.lib or sth like this
|
|
||||||
|
|
||||||
echo Searching $1 in ~/ . . .;echo;
|
|
||||||
if (grep -B"$3" -A"$4" --ignore-case -e "$2" $(find ~/ -name $1)); then
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
echo Searching $1 in $LIBPATH;echo;
|
|
||||||
if (grep -B"$3" -A"$4" --ignore-case -e "$2" $(find $LIBPATH -name $1)); then
|
|
||||||
echo; exit 0; fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Main body
|
|
||||||
if test $# -lt 1 -o $# -gt 4; then operror $*; fi
|
|
||||||
|
|
||||||
case $# in
|
|
||||||
1) showlib $*;;
|
|
||||||
2) searchlib $1 $2 2 2;;
|
|
||||||
3) searchlib $1 $2 $3 2;;
|
|
||||||
4) searchlib $1 $2 $3 $4;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unset LIBPATH
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
Liblook is a script that can show specified model or sub-circuit entry in
|
|
||||||
spice library. Common use look like this:
|
|
||||||
|
|
||||||
liblook lib_name [text_to_find] [lines_before] [lines_after]
|
|
||||||
|
|
||||||
lines_before and lines_after are used when you want to specify how many lines
|
|
||||||
you want to see before or after given text. Look to he source for more
|
|
||||||
details.
|
|
||||||
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#set -x -v
|
|
||||||
|
|
||||||
# MW. Lip / Param parsing program for spice
|
|
||||||
|
|
||||||
# -n normal, -f full (keep everything), -r replace original file
|
|
||||||
|
|
||||||
export TMPLP=/tmp/LibPrm.$$-
|
|
||||||
|
|
||||||
function trapper()
|
|
||||||
{
|
|
||||||
echo User break!
|
|
||||||
echo Exiting . . .
|
|
||||||
rm -f -v ${TMPLP}*
|
|
||||||
unset TMPLP
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
trap trapper SIGINT SIGQUIT
|
|
||||||
|
|
||||||
function operror()
|
|
||||||
{
|
|
||||||
echo Incorrect parameters: $*, $#
|
|
||||||
unset TMPLP
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function repnormpl()
|
|
||||||
{
|
|
||||||
mslib $1 ${TMPLP}1
|
|
||||||
sed -n -e 'p' -e "1r ${TMPLP}1" $1 >${TMPLP}2
|
|
||||||
spiceprm ${TMPLP}2 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
function keepall()
|
|
||||||
{
|
|
||||||
mslib $1
|
|
||||||
sed -n -e 'p' -e "1r $1.lib" $1 >${TMPLP}2
|
|
||||||
spiceprm ${TMPLP}2 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Main body
|
|
||||||
if test $# -lt 2 -o $# -gt 3; then operror $*; fi
|
|
||||||
|
|
||||||
case $1$# in
|
|
||||||
-r3) operror $*;;
|
|
||||||
-n2) repnormpl $2 ${2%.cir}.ckt;;
|
|
||||||
-n3) repnormpl $2 $3;;
|
|
||||||
-r2) repnormpl $2 $2;;
|
|
||||||
-f2) keepall $2 ${2%.cir}.ckt;;
|
|
||||||
-f3) keepall $2 $3;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
rm -f ${TMPLP}*
|
|
||||||
unset TMPLP
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
So, this is my idea of using parametrized subckts with spice.
|
|
||||||
|
|
||||||
First I create an input file like foo.cir and I include commands for
|
|
||||||
mslib (*MOD, *SUB, *LIB) in it. Then I run "libprm -n foo.cir". Libprm then
|
|
||||||
runs mslib first to get all models and subckts form given libraries and then
|
|
||||||
runs spiceprm to evaluate all used parameters.
|
|
||||||
This works quite right for me, and I hope that You will find my idea
|
|
||||||
useful. Spiceprm is not my program (I get it from Internet), but I think
|
|
||||||
that it will better to enclose all used programs in this packet. Spiceprm
|
|
||||||
has it's own directory with very good readme and examples. If You want to
|
|
||||||
find out more about libprm or mslib look for the source code. These are rather
|
|
||||||
short and easy programs - they are all that I could write in quite short
|
|
||||||
time.
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
-------------------------------
|
|
||||||
MW. 01-10-2000
|
|
||||||
Bugs Fixes -
|
|
||||||
-----------
|
|
||||||
.subckt inside another parametrized .subckt works right now.
|
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Version 0.11 January 2, 1996
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
No new features.
|
|
||||||
|
|
||||||
Bug Fixes -
|
|
||||||
-----------
|
|
||||||
|
|
||||||
1. Duplicate name clash problem with parameterized subckt calls from
|
|
||||||
within a .subckt....ends block.
|
|
||||||
|
|
||||||
2. Writing continuation lines to the output file occaisionally choked.
|
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Version 0.10 October 10, 1996
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Original release.
|
|
||||||
|
|
@ -1,339 +0,0 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 2, June 1991
|
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
|
||||||
675 Mass Ave, Cambridge, MA 02139, USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
License is intended to guarantee your freedom to share and change free
|
|
||||||
software--to make sure the software is free for all its users. This
|
|
||||||
General Public License applies to most of the Free Software
|
|
||||||
Foundation's software and to any other program whose authors commit to
|
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
|
||||||
the GNU Library General Public License instead.) You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
this service if you wish), that you receive source code or can get it
|
|
||||||
if you want it, that you can change the software or use pieces of it
|
|
||||||
in new free programs; and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
|
||||||
These restrictions translate to certain responsibilities for you if you
|
|
||||||
distribute copies of the software, or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must give the recipients all the rights that
|
|
||||||
you have. You must make sure that they, too, receive or can get the
|
|
||||||
source code. And you must show them these terms so they know their
|
|
||||||
rights.
|
|
||||||
|
|
||||||
We protect your rights with two steps: (1) copyright the software, and
|
|
||||||
(2) offer you this license which gives you legal permission to copy,
|
|
||||||
distribute and/or modify the software.
|
|
||||||
|
|
||||||
Also, for each author's protection and ours, we want to make certain
|
|
||||||
that everyone understands that there is no warranty for this free
|
|
||||||
software. If the software is modified by someone else and passed on, we
|
|
||||||
want its recipients to know that what they have is not the original, so
|
|
||||||
that any problems introduced by others will not reflect on the original
|
|
||||||
authors' reputations.
|
|
||||||
|
|
||||||
Finally, any free program is threatened constantly by software
|
|
||||||
patents. We wish to avoid the danger that redistributors of a free
|
|
||||||
program will individually obtain patent licenses, in effect making the
|
|
||||||
program proprietary. To prevent this, we have made it clear that any
|
|
||||||
patent must be licensed for everyone's free use or not licensed at all.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
|
||||||
under the terms of this General Public License. The "Program", below,
|
|
||||||
refers to any such program or work, and a "work based on the Program"
|
|
||||||
means either the Program or any derivative work under copyright law:
|
|
||||||
that is to say, a work containing the Program or a portion of it,
|
|
||||||
either verbatim or with modifications and/or translated into another
|
|
||||||
language. (Hereinafter, translation is included without limitation in
|
|
||||||
the term "modification".) Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running the Program is not restricted, and the output from the Program
|
|
||||||
is covered only if its contents constitute a work based on the
|
|
||||||
Program (independent of having been made by running the Program).
|
|
||||||
Whether that is true depends on what the Program does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Program's
|
|
||||||
source code as you receive it, in any medium, provided that you
|
|
||||||
conspicuously and appropriately publish on each copy an appropriate
|
|
||||||
copyright notice and disclaimer of warranty; keep intact all the
|
|
||||||
notices that refer to this License and to the absence of any warranty;
|
|
||||||
and give any other recipients of the Program a copy of this License
|
|
||||||
along with the Program.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy, and
|
|
||||||
you may at your option offer warranty protection in exchange for a fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Program or any portion
|
|
||||||
of it, thus forming a work based on the Program, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) You must cause the modified files to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
b) You must cause any work that you distribute or publish, that in
|
|
||||||
whole or in part contains or is derived from the Program or any
|
|
||||||
part thereof, to be licensed as a whole at no charge to all third
|
|
||||||
parties under the terms of this License.
|
|
||||||
|
|
||||||
c) If the modified program normally reads commands interactively
|
|
||||||
when run, you must cause it, when started running for such
|
|
||||||
interactive use in the most ordinary way, to print or display an
|
|
||||||
announcement including an appropriate copyright notice and a
|
|
||||||
notice that there is no warranty (or else, saying that you provide
|
|
||||||
a warranty) and that users may redistribute the program under
|
|
||||||
these conditions, and telling the user how to view a copy of this
|
|
||||||
License. (Exception: if the Program itself is interactive but
|
|
||||||
does not normally print such an announcement, your work based on
|
|
||||||
the Program is not required to print an announcement.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Program,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Program, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Program.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Program
|
|
||||||
with the Program (or with a work based on the Program) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may copy and distribute the Program (or a work based on it,
|
|
||||||
under Section 2) in object code or executable form under the terms of
|
|
||||||
Sections 1 and 2 above provided that you also do one of the following:
|
|
||||||
|
|
||||||
a) Accompany it with the complete corresponding machine-readable
|
|
||||||
source code, which must be distributed under the terms of Sections
|
|
||||||
1 and 2 above on a medium customarily used for software interchange; or,
|
|
||||||
|
|
||||||
b) Accompany it with a written offer, valid for at least three
|
|
||||||
years, to give any third party, for a charge no more than your
|
|
||||||
cost of physically performing source distribution, a complete
|
|
||||||
machine-readable copy of the corresponding source code, to be
|
|
||||||
distributed under the terms of Sections 1 and 2 above on a medium
|
|
||||||
customarily used for software interchange; or,
|
|
||||||
|
|
||||||
c) Accompany it with the information you received as to the offer
|
|
||||||
to distribute corresponding source code. (This alternative is
|
|
||||||
allowed only for noncommercial distribution and only if you
|
|
||||||
received the program in object code or executable form with such
|
|
||||||
an offer, in accord with Subsection b above.)
|
|
||||||
|
|
||||||
The source code for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For an executable work, complete source
|
|
||||||
code means all the source code for all modules it contains, plus any
|
|
||||||
associated interface definition files, plus the scripts used to
|
|
||||||
control compilation and installation of the executable. However, as a
|
|
||||||
special exception, the source code distributed need not include
|
|
||||||
anything that is normally distributed (in either source or binary
|
|
||||||
form) with the major components (compiler, kernel, and so on) of the
|
|
||||||
operating system on which the executable runs, unless that component
|
|
||||||
itself accompanies the executable.
|
|
||||||
|
|
||||||
If distribution of executable or object code is made by offering
|
|
||||||
access to copy from a designated place, then offering equivalent
|
|
||||||
access to copy the source code from the same place counts as
|
|
||||||
distribution of the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
|
||||||
except as expressly provided under this License. Any attempt
|
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
|
||||||
void, and will automatically terminate your rights under this License.
|
|
||||||
However, parties who have received copies, or rights, from you under
|
|
||||||
this License will not have their licenses terminated so long as such
|
|
||||||
parties remain in full compliance.
|
|
||||||
|
|
||||||
5. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Program or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Program (or any work based on the
|
|
||||||
Program), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Program or works based on it.
|
|
||||||
|
|
||||||
6. Each time you redistribute the Program (or any work based on the
|
|
||||||
Program), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute or modify the Program subject to
|
|
||||||
these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
this License.
|
|
||||||
|
|
||||||
7. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Program at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Program by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Program.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under
|
|
||||||
any particular circumstance, the balance of the section is intended to
|
|
||||||
apply and the section as a whole is intended to apply in other
|
|
||||||
circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system, which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Program under this License
|
|
||||||
may add an explicit geographical distribution limitation excluding
|
|
||||||
those countries, so that distribution is permitted only in or among
|
|
||||||
countries not thus excluded. In such case, this License incorporates
|
|
||||||
the limitation as if written in the body of this License.
|
|
||||||
|
|
||||||
9. The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
|
||||||
specifies a version number of this License which applies to it and "any
|
|
||||||
later version", you have the option of following the terms and conditions
|
|
||||||
either of that version or of any later version published by the Free
|
|
||||||
Software Foundation. If the Program does not specify a version number of
|
|
||||||
this License, you may choose any version ever published by the Free Software
|
|
||||||
Foundation.
|
|
||||||
|
|
||||||
10. If you wish to incorporate parts of the Program into other free
|
|
||||||
programs whose distribution conditions are different, write to the author
|
|
||||||
to ask for permission. For software which is copyrighted by the Free
|
|
||||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
|
||||||
make exceptions for this. Our decision will be guided by the two goals
|
|
||||||
of preserving the free status of all derivatives of our free software and
|
|
||||||
of promoting the sharing and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
|
||||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
||||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
|
||||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
|
||||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
|
||||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
|
||||||
REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
|
||||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
|
||||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
|
||||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
|
||||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) 19yy <name of author>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program is interactive, make it output a short notice like this
|
|
||||||
when it starts in an interactive mode:
|
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, the commands you use may
|
|
||||||
be called something other than `show w' and `show c'; they could even be
|
|
||||||
mouse-clicks or menu items--whatever suits your program.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
|
||||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1989
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
This General Public License does not permit incorporating your program into
|
|
||||||
proprietary programs. If your program is a subroutine library, you may
|
|
||||||
consider it more useful to permit linking proprietary applications with the
|
|
||||||
library. If this is what you want to do, use the GNU Library General
|
|
||||||
Public License instead of this License.
|
|
||||||
|
|
@ -1,176 +0,0 @@
|
||||||
****************************************************************
|
|
||||||
* Pi attenuator pad.
|
|
||||||
* Parameters: R0 = impedance
|
|
||||||
* DB = attenuation in dB (positive)
|
|
||||||
.SUBCKT PIPAD 1 2 { R0 DB }
|
|
||||||
R1 1 0 {R0*(1+2/(10**(DB/20)-1))}
|
|
||||||
R2 1 2 {(R0/2)*(10**(DB/20)-10**(DB/-20))}
|
|
||||||
R3 2 0 {R0*(1+2/(10**(DB/20)-1))}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* PCB Via inductance + extra L.
|
|
||||||
* H = substrate height in inches
|
|
||||||
* D = via diameter in inches
|
|
||||||
* L = extra inductance in henries.
|
|
||||||
.SUBCKT VIA 1 2 { H D L }
|
|
||||||
LV 1 2 {L+
|
|
||||||
+ 5.08E-9*H*(log((2+sqrt(4+D*D/(H*H)))*H/D)+
|
|
||||||
+ .75*(D/H-sqrt(4+D*D/(H*H))))}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Voltage-controlled oscillator.
|
|
||||||
* Parameters: F = frequency @ Vc = 0 in Hz
|
|
||||||
* KV = tuning sensitivity in Hz/volt
|
|
||||||
* A = peak output amplitude
|
|
||||||
* RO = output port resistance
|
|
||||||
* Connections: Vc Out
|
|
||||||
.SUBCKT VCO 20 2 { F KV A RO }
|
|
||||||
RIN1 20 0 1E12
|
|
||||||
VSW 30 0 DC 0 PULSE 0 1
|
|
||||||
RSW 30 0 1E12
|
|
||||||
BIN 3 0 V=(V(20)+{F/KV})*V(30)
|
|
||||||
R3 3 0 1E6
|
|
||||||
GSIN 2 0 22 0 {1/RO}
|
|
||||||
RSIN 2 0 {RO}
|
|
||||||
B1 1 0 I=-(V(22)*V(3))
|
|
||||||
B2 22 0 I=V(1)*V(3)
|
|
||||||
R2 1 0 1E9
|
|
||||||
I1 0 1 PULSE {1E-9*A} 0
|
|
||||||
C2 1 0 {.159154943/KV}
|
|
||||||
C1 22 0 {.159154943/KV}
|
|
||||||
R1 22 0 1E9
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Ideal Frequency converter.
|
|
||||||
* Parameters: F = Oscillator frequency
|
|
||||||
* RI = input port resistance
|
|
||||||
* RO = output port resistance
|
|
||||||
* Connections: In Out
|
|
||||||
.SUBCKT FCNVT 1 2 { F RI RO }
|
|
||||||
RIN 1 0 {RI}
|
|
||||||
VLO 3 0 DC 0 SIN 0 1 {F}
|
|
||||||
RLO 3 0 1E12
|
|
||||||
BMIX 0 2 I=(V(1)*V(3))/{RO}
|
|
||||||
RO 2 0 {RO}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Sine wave RF power source.
|
|
||||||
* Parameters: F = Frequency
|
|
||||||
* R = Output resistance
|
|
||||||
* P = Power in dBm
|
|
||||||
* V = DC (EMF)
|
|
||||||
.SUBCKT RFGEN 1 2 { F R P V }
|
|
||||||
* + -
|
|
||||||
Is 2 1 DC {V/R} SIN {V/R} {sqrt((10**(P/10))/(125*R))} {F}
|
|
||||||
Ro 1 2 {R}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Sine wave 2-tone RF power source.
|
|
||||||
* Parameters: F1 = 1st tone frequency
|
|
||||||
* F2 = 2nd tone frequency
|
|
||||||
* R = output resistance
|
|
||||||
* P = power per tone in dBm
|
|
||||||
* V = DC (EMF)
|
|
||||||
.SUBCKT 2TGEN 1 2 { F1 F2 R P V }
|
|
||||||
* + -
|
|
||||||
I1 2 1 DC {V/R} SIN {V/R} {sqrt((10**(P/10))/(125*R))} {F1}
|
|
||||||
I2 2 1 DC 0 SIN 0 {sqrt((10**(P/10))/(125*R))} {F2}
|
|
||||||
Ro 1 2 {R}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Transmission lines
|
|
||||||
* All ports must have external connections.
|
|
||||||
* Parameters: Z0 = impedance
|
|
||||||
* L = length in inches
|
|
||||||
* VP = velocity-of-propagation rel. to air
|
|
||||||
* Connections: 1+ 1- 2+ 2-
|
|
||||||
.SUBCKT TXL 1 2 3 4 { Z0 L VP }
|
|
||||||
T1 1 2 3 4 Z0={Z0} TD={L/(1.180315E10*VP)}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Lossy transmission line.
|
|
||||||
* All ports must have external connections.
|
|
||||||
* Parameters: Z0 = impedance
|
|
||||||
* L = length in inches
|
|
||||||
* VP = velocity-of-propagation rel. to air
|
|
||||||
* A = loss in dB/inch
|
|
||||||
* Connections: 1+ 1- 2+ 2-
|
|
||||||
.SUBCKT LTXL 1 2 3 4 { Z0 L VP A }
|
|
||||||
O1 1 2 3 4 LOSSY
|
|
||||||
.MODEL LOSSY LTRA LEN={L}
|
|
||||||
+ R={5.848492e-3*A*Z0}
|
|
||||||
+ L={Z0/(1.180315E10*VP)}
|
|
||||||
+ C={1/(1.180315E10*VP*Z0)}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* 2 coupled transmission lines
|
|
||||||
* All ports must have external connections.
|
|
||||||
* Parameters: Z0E = even-mode impedance
|
|
||||||
* Z0O = odd-mode impedance
|
|
||||||
* L = length in inches
|
|
||||||
* VP = velocity-of-propagation rel. to air
|
|
||||||
* Connections: 1+ 1- 2+ 2- { Z0E Z0O L VP }
|
|
||||||
.SUBCKT CPL2 1 2 3 4
|
|
||||||
T1 1 0 3 0 Z0={Z0E} TD={L/(1.180315E10*VP)}
|
|
||||||
T2 1 2 3 4 Z0={2*Z0E*Z0O/(Z0E-Z0O)} TD={L/(1.180315E10*VP)}
|
|
||||||
T3 2 0 4 0 Z0={Z0E} TD={L/(1.180315E10*VP)}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Generic Bipolar OpAmp - linear model
|
|
||||||
* Parameters: G = open-loop gain in dB
|
|
||||||
* FT = unity gain frequency in Hz
|
|
||||||
* IOS = input offset current in amps
|
|
||||||
* VOS = input offset voltage
|
|
||||||
* IB = input bias current in amps
|
|
||||||
.SUBCKT BIPOPA 2 3 6 7 4 { G FT IOS VOS IB }
|
|
||||||
* - In + Out Vcc Vee
|
|
||||||
RP 4 7 10K
|
|
||||||
RXX 4 0 10MEG
|
|
||||||
IBP 3 0 {IB-IOS}
|
|
||||||
RIP 3 0 10MEG
|
|
||||||
CIP 3 0 1.4PF
|
|
||||||
IBN 2 0 {IB}
|
|
||||||
RIN 2 0 10MEG
|
|
||||||
CIN 2 0 1.4PF
|
|
||||||
VOFST 2 10 {VOS}
|
|
||||||
RID 10 3 200K
|
|
||||||
EA 11 0 10 3 1
|
|
||||||
R1 11 12 5K
|
|
||||||
R2 12 13 50K
|
|
||||||
C1 12 0 {13E-6/FT}
|
|
||||||
GA 0 14 0 13 {0.0135*(10**(G/20))}
|
|
||||||
C2 13 14 {2.7E-6/FT}
|
|
||||||
RO 14 0 75
|
|
||||||
L 14 6 {30/FT}
|
|
||||||
RL 14 6 1000
|
|
||||||
CL 6 0 3PF
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
* Generic FET OpAmp - linear model
|
|
||||||
* Parameters: G = open-loop gain in dB
|
|
||||||
* FT = unity gain frequency in Hz
|
|
||||||
* VOS = input offset voltage
|
|
||||||
.SUBCKT FETOPA 2 3 6 7 4 { G FT VOS }
|
|
||||||
* - In + Out Vcc Vee
|
|
||||||
RP 4 7 6K
|
|
||||||
RXX 4 0 10MEG
|
|
||||||
IBP 3 0 33E-12
|
|
||||||
RIP 3 0 1E12
|
|
||||||
CIP 3 0 3PF
|
|
||||||
IBN 2 0 30E-12
|
|
||||||
RIN 2 0 1E12
|
|
||||||
CIN 2 0 3PF
|
|
||||||
VOFST 2 10 {VOS}
|
|
||||||
RID 10 3 1E12
|
|
||||||
EA 11 0 10 3 1
|
|
||||||
R1 11 12 5K
|
|
||||||
R2 12 13 50K
|
|
||||||
C1 12 0 {24E-6/FT}
|
|
||||||
GA 0 14 0 13 {0.0135*(10**(G/20))}
|
|
||||||
C2 13 14 {2.33E-6/FT}
|
|
||||||
RO 14 0 75
|
|
||||||
L 14 6 {4E-6/FT}
|
|
||||||
RL 14 6 100
|
|
||||||
CL 6 0 3PF
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
|
|
@ -1,216 +0,0 @@
|
||||||
------------------------------------------------------------------------
|
|
||||||
SPICEPRM - A Spice preprocessor for parameterized subcircuits (v 0.11)
|
|
||||||
Copyright (C) 1996 Andrew J. Borsa <andy@moose.mv.com>
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Spiceprm was written in the course of moving my engineering activities
|
|
||||||
to the Linux operating system. My previous MSDOS spice package
|
|
||||||
permitted passing parameters to subcircuits. The raw Berkely Spice
|
|
||||||
doesn't. Anyone used to this feature knows the frustration of trying
|
|
||||||
to use a simulator without it. This script is the result of my
|
|
||||||
desperation. It translates a circuit file containing parameterized
|
|
||||||
subcircuits with math expressions into another circuit file meeting raw
|
|
||||||
spice requirements. You then run spice on the translated output file.
|
|
||||||
|
|
||||||
This is an alpha version. It probably has some bugs I haven't caught.
|
|
||||||
But I have used it in a work environment enough to feel comfortable
|
|
||||||
about releasing it for comments and improvement suggestions.
|
|
||||||
|
|
||||||
|
|
||||||
What's So Great About Subcircuits With Parameters?
|
|
||||||
--------------------------------------------------
|
|
||||||
1. You can generalize a model once and then use it without having to
|
|
||||||
recalculate values of it's internal elements every time.
|
|
||||||
|
|
||||||
2. Many electronic devices can be modelled by using mathematical
|
|
||||||
expressions. The independent variables can be passed to the model as
|
|
||||||
parameters, evaluated in equations, and used to set the behavior of a
|
|
||||||
particular model instance.
|
|
||||||
|
|
||||||
3. They save mucho time and minimize human calculation error.
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
1. Copy the executable script to an accessible directory. I keep mine
|
|
||||||
in $HOME/bin so it's on my path.
|
|
||||||
|
|
||||||
2. Modify the top line if necessary to reflect the path to your Perl
|
|
||||||
interpreter.
|
|
||||||
For ex., #! /usr/bin/perl may have to become #! /usr/local/bin/perl or
|
|
||||||
wherever the perl binary is located.
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
spiceprm infile [outfile]
|
|
||||||
|
|
||||||
infile: Circuit file name containing parameterized subcircuits.
|
|
||||||
outfile: Transformed file meeting raw spice netlist conventions.
|
|
||||||
Optional. If not given, output is produced on standard
|
|
||||||
output (stdout).
|
|
||||||
|
|
||||||
My file name convention: infile = *.cir, outfile = *.ckt
|
|
||||||
|
|
||||||
infile == outfile isn't permitted for a coupla good reasons, the
|
|
||||||
best being you don't want to trash your original source.
|
|
||||||
|
|
||||||
Now source outfile from spice.
|
|
||||||
|
|
||||||
I always check the output from a new infile just to make sure. This
|
|
||||||
version only checks for a few obvious errors, so scanning outfile for
|
|
||||||
reasonable looking values and netlist correctness is wise. Note that
|
|
||||||
comment and blank lines are discarded in outfile and alphabetic
|
|
||||||
characters are transformed to lower case.
|
|
||||||
|
|
||||||
|
|
||||||
Parameterized Subcircuit Netlist Convention
|
|
||||||
-------------------------------------------
|
|
||||||
Calling a parameterized subcircuit works similarly to a normal spice call
|
|
||||||
except for the addition of a {} delimited list of parameter value
|
|
||||||
assignments -
|
|
||||||
|
|
||||||
Xname n1 n2 n3 ... ni subname {p1 = val1 ... pj = valj}
|
|
||||||
p1 thru pj are the parameter assignments to be passed to the
|
|
||||||
subcircuit.
|
|
||||||
val is any valid spice value.
|
|
||||||
{} (braces) must enclose the parameter assignment sequence.
|
|
||||||
|
|
||||||
After running the preprocessor on this file, each call in the netlist
|
|
||||||
will be replaced by the following -
|
|
||||||
|
|
||||||
Xname n1 n2 n3 ... ni subname#k
|
|
||||||
*{p1 = val1 ... pj = valj}
|
|
||||||
where k is a digit or digits representing a subcircuit with that
|
|
||||||
specific set of parameter substitutions. k will be incremented for
|
|
||||||
each unique set of parameters and matched by a new .subckt listing
|
|
||||||
named subname#k as follows -
|
|
||||||
|
|
||||||
.subckt subname#k n1 n2 n3 ... ni
|
|
||||||
... listing with parameters substituted and equations evaluated
|
|
||||||
.ends
|
|
||||||
|
|
||||||
|
|
||||||
Creating Parameterized Subcircuits
|
|
||||||
----------------------------------
|
|
||||||
Below is a simple example. See the EXAMPLES file for a number of
|
|
||||||
illustrative and useful models for Spice3.
|
|
||||||
|
|
||||||
This model creates an RF power source specified using the natural
|
|
||||||
output power units of dBm (dB referenced to 1 milliwatt). Note that
|
|
||||||
the model parameters must be declared on the ".subckt" definition line
|
|
||||||
inside curly braces {}.
|
|
||||||
****************************************************************
|
|
||||||
* Sine wave RF power source.
|
|
||||||
* Parameters: F = Frequency
|
|
||||||
* R = Output resistance
|
|
||||||
* P = Power in dBm
|
|
||||||
* V = DC (EMF)
|
|
||||||
.SUBCKT RFGEN 1 2 {F R P V}
|
|
||||||
* + -
|
|
||||||
Is 2 1 DC {V/R} SIN {V/R} {sqrt((10**(P/10))/(125*R))} {F}
|
|
||||||
Ro 1 2 {R}
|
|
||||||
.ENDS
|
|
||||||
****************************************************************
|
|
||||||
Note that independent current source Is has it's literal spice
|
|
||||||
parameters replaced by equations that calculate the required values
|
|
||||||
from the passed parameters. Each equation must be enclosed by {} to
|
|
||||||
inform the preprocessor that a substitution and calculation must be
|
|
||||||
performed for whatever appears between the braces.
|
|
||||||
|
|
||||||
Equations may span multiple lines by using the spice line continuation
|
|
||||||
symbol "+" as the first character of the following line.
|
|
||||||
|
|
||||||
.MODEL statements inside subcircuits may also use passed parameters.
|
|
||||||
In fact, anything between {} inside a subcircuit will be evaluated and
|
|
||||||
replaced with a result.
|
|
||||||
|
|
||||||
Be careful in situations like the following:
|
|
||||||
Bx 3 0 v = {v(1)*sgn(v(2))*frick/frack} WRONG!!!
|
|
||||||
|
|
||||||
The Spice3 nonlinear source element "B" also accepts equations
|
|
||||||
describing it's output dependency on functions of circuit voltages
|
|
||||||
and currents. If "frick" and "frack" are parameters, you must
|
|
||||||
separate them from the element's equation as follows -
|
|
||||||
Bx 3 0 v = v(1)*sgn(v(2))*{frick/frack}
|
|
||||||
|
|
||||||
Just remember that preprocessor equations and spice functions must
|
|
||||||
never meld.
|
|
||||||
|
|
||||||
The parameter substitution first replaces all parameters between any {}
|
|
||||||
with their numerical values and then uses Perl's eval() function to
|
|
||||||
produce a final numerical value. Theoretically at least, you could
|
|
||||||
execute a Perl program within those braces. I haven't explored this
|
|
||||||
yet so feel free. Realize though, that whatever's inside the braces
|
|
||||||
gets a ";" appended at the end to make a valid Perl statement from the
|
|
||||||
usual equation. Also, Perl's block delimiters are braces, so extra
|
|
||||||
one's could confuse the current parsing which is simply oriented to
|
|
||||||
equations. Ah well.
|
|
||||||
|
|
||||||
|
|
||||||
Known Bugs, Anomalies, and Perl Gotcha's
|
|
||||||
----------------------------------------
|
|
||||||
1. Minimal error checking! Be forewarned!
|
|
||||||
|
|
||||||
2. Don't use ".ends subckt_name" with parameters. Use ".ends" only.
|
|
||||||
The preprocessor modifies subckt_name to subckt_name#k.
|
|
||||||
|
|
||||||
3. Spice unit representations like "k", "meg", etc, are not recognized
|
|
||||||
inside the {} equation sections of .subckt listings. They may,
|
|
||||||
however, be used in the parameter assignment section of a .subckt call.
|
|
||||||
|
|
||||||
4. "-" as part of .subckt name doesn't work but "_" does. Stick to
|
|
||||||
alphanumeric names with optional underscore characters.
|
|
||||||
|
|
||||||
5. Equations must use Perl math operators and functions.
|
|
||||||
The following lists operator differences I'm aware of -
|
|
||||||
|
|
||||||
Exponentiation - Perl : **
|
|
||||||
Spice3 : ^
|
|
||||||
|
|
||||||
Logical AND, OR - Perl : &&, ||
|
|
||||||
Spice3 : &, |
|
|
||||||
|
|
||||||
Equality, Inequality - Perl : ==, !=
|
|
||||||
Spice3 : =, <>
|
|
||||||
|
|
||||||
These operators are the same for Perl and Spice3 -
|
|
||||||
+ - * / % ! < > <= >=
|
|
||||||
|
|
||||||
These operators are unique to Perl -
|
|
||||||
& | ^ ~ : bitwise AND, OR, exclusive OR, complement
|
|
||||||
|
|
||||||
Perl math functions -
|
|
||||||
abs(EXPR) : absolute value of EXPR
|
|
||||||
atan2(Y,X) : arctangent of Y/X in the range of -pi to +pi
|
|
||||||
cos(EXPR) : cosine of EXPR in radians
|
|
||||||
exp(EXPR) : e raised to EXPR
|
|
||||||
int(EXPR) : integer portion of EXPR
|
|
||||||
log(EXPR) : natural logarithm (base e) of EXPR
|
|
||||||
rand[(EXPR)]: returns a random fractional number between 0 and the
|
|
||||||
value of EXPR. If EXPR is omitted, returns a value
|
|
||||||
between 0 and 1.
|
|
||||||
sin(EXPR) : sine of EXPR in radians
|
|
||||||
sqrt(EXPR) : square root of EXPR
|
|
||||||
|
|
||||||
|
|
||||||
Finally, if you could make use of a language allowing you to do neat
|
|
||||||
things like this with minimal pain, give Perl a try. It's naturally
|
|
||||||
suited for text processing and transformation tasks like pre and post
|
|
||||||
processors, along with any math manipulation required.
|
|
||||||
|
|
@ -1,305 +0,0 @@
|
||||||
#!/usr/bin/env perl
|
|
||||||
# spiceprm
|
|
||||||
# Pass parameters to spice subcircuits.
|
|
||||||
# Usage: spiceprm infile [outfile]
|
|
||||||
# infile and outfile must be different.
|
|
||||||
# Output written to STDOUT if outfile not given.
|
|
||||||
|
|
||||||
$BANNER = "Spiceprm version 0.11, Copyright (C) 1996 Andrew J. Borsa";
|
|
||||||
|
|
||||||
# NOTES:
|
|
||||||
# 1. Units not recognized inside .subckt {} expressions.
|
|
||||||
# 2. Perl exponent operator: "**", Spice exp op: "^".
|
|
||||||
# 3. "-" as part of subckt name doesn't work but "_" does.
|
|
||||||
|
|
||||||
# Netlist convention
|
|
||||||
# Xname n1 n2 n3 ... ni subname {p1 = val1 ... pj = valj}
|
|
||||||
# p1 thru pj are the parameters to be passed to the subcircuit.
|
|
||||||
# val is any valid spice value.
|
|
||||||
#
|
|
||||||
# .subckt name n1 n2 ... ni {p1 p2 ... pj}
|
|
||||||
# parameter expressions must be enclosed in {}.
|
|
||||||
|
|
||||||
# After substitution -
|
|
||||||
# Xname n1 n2 n3 ... ni subname#k
|
|
||||||
# *{p1 = val1 ... pj = valj}
|
|
||||||
# .subckt subname#k n1 n2 n3 ... ni
|
|
||||||
# ... listing with parameters substituted
|
|
||||||
# .ends
|
|
||||||
|
|
||||||
# %subckt: key = subname
|
|
||||||
# value = startline, endline, listing(.subckt ... .ends)
|
|
||||||
# Only for .subckts with parameters.
|
|
||||||
# %subprm: key = subname
|
|
||||||
# value = parameter name list
|
|
||||||
# %subcall: key = Xname[#subname0#subname1...]
|
|
||||||
# value = subname#k
|
|
||||||
# NOTE: IF Xname is called from within a .subckt, it will have calling
|
|
||||||
# .subckt names appended, delimited by #'s.
|
|
||||||
# %sub: key = subname#k
|
|
||||||
# value = p1 val1 ... pj valj, where val is a pure
|
|
||||||
# numeric with no units.
|
|
||||||
|
|
||||||
$MAXLEN = 70; # Max output file line length.
|
|
||||||
$DMAXLEN = 10; # Amount to increment if necessary.
|
|
||||||
$linenum = 0;
|
|
||||||
|
|
||||||
%units = ('f','1e-15','p','1e-12','n','1e-9','u','1e-6','mil','25.4e-6',
|
|
||||||
'm','1e-3','k','1e3','meg','1e6','g','1e9','t','1e12');
|
|
||||||
|
|
||||||
$* = 1; # Pattern match with multi-line strings.
|
|
||||||
|
|
||||||
($infile, $outfile) = @ARGV;
|
|
||||||
print "\n$BANNER\ninfile: $infile\noutfile: $outfile\n\n";
|
|
||||||
$#ARGV && ($infile eq $outfile)
|
|
||||||
&& die "Input and Output filenames must be different\n";
|
|
||||||
open(INFILE, $infile) || die "Can't open source file: $infile\n";
|
|
||||||
$hasprm = $depth = 0;
|
|
||||||
&prm_scan;
|
|
||||||
close(INFILE);
|
|
||||||
|
|
||||||
open(INFILE, $infile) || die "Can't open source file: $infile\n";
|
|
||||||
unlink $outfile if $#ARGV;
|
|
||||||
open(OUTFILE, $#ARGV ? ">$outfile" : ">-")
|
|
||||||
|| die "Can't open output file: $outfile\n";
|
|
||||||
$depth = 0;
|
|
||||||
&prm_wr;
|
|
||||||
close(INFILE);
|
|
||||||
close(OUTFILE);
|
|
||||||
|
|
||||||
# Get a line from the input file, combining any continuation lines into
|
|
||||||
# one long line. Skip comment and blank lines.
|
|
||||||
sub prm_getline {
|
|
||||||
local($line);
|
|
||||||
|
|
||||||
chop($line = defined($nxtline) ? $nxtline : <INFILE>);
|
|
||||||
$linenum = $.;
|
|
||||||
while ($nxtline = <INFILE>) {
|
|
||||||
if ($line =~ /^\*|^\s/) { $line = ''; }
|
|
||||||
if ($line eq '' || $nxtline =~ s/^(\+)/ /) {
|
|
||||||
chop($nxtline);
|
|
||||||
$line .= $nxtline;
|
|
||||||
}
|
|
||||||
else { last; }
|
|
||||||
}
|
|
||||||
$line;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Scan the input file looking for subcircuit calls with parameter list and
|
|
||||||
# any subcircuits with defined parameters.
|
|
||||||
sub prm_scan {
|
|
||||||
local(@w, @tmp, @list);
|
|
||||||
local($xnm, $subnm, $i, $max, $m, $s, $n, $tmp, $start);
|
|
||||||
local($sublist) = '';
|
|
||||||
|
|
||||||
PRM_SCAN: while ($_ = &prm_getline) {
|
|
||||||
# skip .control - .endc blocks
|
|
||||||
if (/^\.control/i) {
|
|
||||||
while ($_ = &prm_getline) { next PRM_SCAN if (/^\.endc/i); }
|
|
||||||
}
|
|
||||||
tr/A-Z/a-z/;
|
|
||||||
PRM_TST: {
|
|
||||||
if (/^x/ && s/(\{([^\}]+)\})//) {
|
|
||||||
@w = split(' ');
|
|
||||||
@tmp = @w[0 .. $#w-1];
|
|
||||||
$xnm = $w[0] . $sublist; $subnm = $w[$#w];
|
|
||||||
$_ = $2; $i = 0;
|
|
||||||
while (/(\w+)\s*\=\s*([+-]?\d*(\.\d*)?([Ee][+-]?\d+)?)([a-z]\w*)?/) {
|
|
||||||
# 1 2 3 4 5
|
|
||||||
$prmval{$1} = $2*($5 ? &unit2mult($5) : 1);
|
|
||||||
$_ = $';
|
|
||||||
$i += 2;
|
|
||||||
}
|
|
||||||
$max = -1; $m = '';
|
|
||||||
CHKDUP: foreach $s (keys %sub) {
|
|
||||||
$s =~ /(\w+)\#(\d+)/;
|
|
||||||
if ($subnm eq $1) {
|
|
||||||
if ($max < $2) { $max = $2; }
|
|
||||||
$n = (@w = split(' ', $sub{$s}));
|
|
||||||
if ($n == $i) {
|
|
||||||
for ($i = 0; $i < $n; $i += 2) {
|
|
||||||
last if $w[$i+1] ne $prmval{$w[$i]};
|
|
||||||
}
|
|
||||||
if ($i >= $n) {
|
|
||||||
$m = 1;
|
|
||||||
$subcall{$xnm} = $s;
|
|
||||||
last CHKDUP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($m eq '') {
|
|
||||||
foreach $n (keys %prmval) {
|
|
||||||
$m = join(' ', $m, $n, $prmval{$n});
|
|
||||||
}
|
|
||||||
$sub{($s = join('', $subnm, '#', $max+1))} = $m;
|
|
||||||
$subcall{$xnm} = $s;
|
|
||||||
}
|
|
||||||
push(@list, join(' ', @tmp, $subcall{$xnm})) if $depth;
|
|
||||||
undef %prmval;
|
|
||||||
last PRM_TST;
|
|
||||||
}
|
|
||||||
if (/^\.subckt\s+(\w+)/) {
|
|
||||||
$depth++; $tmp = $1;
|
|
||||||
$sublist .= '#' . $1;
|
|
||||||
if (s/(\{([^\}]+)\})//) {
|
|
||||||
if ($hasprm) {
|
|
||||||
print "Line $linenum: ",
|
|
||||||
"Nested parameterized subckt definitions not permitted\n\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$hasprm = 1; $start = $.;
|
|
||||||
$subprm{$psubnm = $tmp} = $2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
push(@list, $_); # With {} parameter defs removed.
|
|
||||||
last PRM_TST;
|
|
||||||
}
|
|
||||||
if (/^\.ends/) {
|
|
||||||
$sublist =~ s/(\#\w+)$//;
|
|
||||||
if (--$depth == 0) {
|
|
||||||
if ($hasprm) {
|
|
||||||
$subckt{$psubnm} = join("\n",join(' ',$start,$.),@list,$_);
|
|
||||||
}
|
|
||||||
$hasprm = 0;
|
|
||||||
undef @list; $sublist = '';
|
|
||||||
last PRM_TST;
|
|
||||||
}
|
|
||||||
# MW. 'last PRM_TST' should be inside 'if' loop to allow nestle subckts.
|
|
||||||
}
|
|
||||||
if ($depth) {
|
|
||||||
push(@list, $_);
|
|
||||||
last PRM_TST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Write the output file.
|
|
||||||
sub prm_wr {
|
|
||||||
local(@w, @pnms, @list, @line);
|
|
||||||
local($xnm, $subnm, $n, $m, $i, $s);
|
|
||||||
local($sublist) = '';
|
|
||||||
|
|
||||||
PRMWR_SCAN: while ($_ = &prm_getline) {
|
|
||||||
# write .control - .endc blocks
|
|
||||||
if (/^\.control/i) {
|
|
||||||
print OUTFILE "$_\n";
|
|
||||||
while ($_ = &prm_getline) {
|
|
||||||
prm_wrline($_);
|
|
||||||
next PRMWR_SCAN if (/^\.endc/i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tr/A-Z/a-z/;
|
|
||||||
if (/^x/ && s/(\{([^\}]+)\})//) {
|
|
||||||
@w = split(' '); $subnm = pop(@w);
|
|
||||||
$xnm = $w[0] . $sublist;
|
|
||||||
prm_wrline(join(' ', @w, $subcall{$xnm}));
|
|
||||||
print OUTFILE "* $1\n";
|
|
||||||
if (!defined($subprm{$subnm})) {
|
|
||||||
print "Line $linenum: Subckt \"$subnm\" has no defined parameters\n\n";
|
|
||||||
next PRMWR_SCAN;
|
|
||||||
}
|
|
||||||
$n = @pnms = sort(split(' ', $subprm{$subnm}));
|
|
||||||
$m = (@w = split(' ', $sub{$subcall{$xnm}}));
|
|
||||||
if ($n == $m/2) {
|
|
||||||
for ($i = 0, undef(@list); $i < $m; $i += 2) {
|
|
||||||
push(@list, $w[$i]);
|
|
||||||
}
|
|
||||||
for ($i = 0, @w = sort(@list); $i < $n; ++$i) {
|
|
||||||
if ($pnms[$i] ne $w[$i]) {
|
|
||||||
print "Line $linenum: ",
|
|
||||||
"Undefined parameter \"$w[$i]\"",
|
|
||||||
"in subckt \"$subnm\" call\n\n";
|
|
||||||
next PRMWR_SCAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print "Line $linenum: ",
|
|
||||||
"Incorrect number of parameters in subckt \"$subnm\" call\n\n";
|
|
||||||
}
|
|
||||||
next PRMWR_SCAN;
|
|
||||||
}
|
|
||||||
if (/^\.subckt\s+(\w+)/) {
|
|
||||||
if ($s = $subckt{$1}) {
|
|
||||||
$s =~ /\d+\s+(\d+)/;
|
|
||||||
$n = $1;
|
|
||||||
&prm_getline until $. == $n;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$depth++; $sublist .= '#' . $1;
|
|
||||||
prm_wrline($_);
|
|
||||||
}
|
|
||||||
next PRMWR_SCAN;
|
|
||||||
}
|
|
||||||
if (/^\.end\b/) {
|
|
||||||
foreach $s (keys %sub) {
|
|
||||||
($subnm = $s) =~ s/\#\d+//;
|
|
||||||
@line = split(/\n/, $subckt{$subnm});
|
|
||||||
shift(@line);
|
|
||||||
$line[0] =~ s/$subnm/$s/;
|
|
||||||
%prmval = split(' ', $sub{$s});
|
|
||||||
foreach (@line) {
|
|
||||||
s/\{([^\}]+)\}/&prm_eval($1, %prmval)/eg;
|
|
||||||
prm_wrline($_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print OUTFILE ".end\n";
|
|
||||||
last PRMWR_SCAN;
|
|
||||||
}
|
|
||||||
if (/^\.ends/) {
|
|
||||||
if (--$depth == 0) { $sublist = ''; }
|
|
||||||
else { $sublist =~ s/(\#\w+)$//; }
|
|
||||||
}
|
|
||||||
prm_wrline($_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Translate a possible unit into a multiplier factor.
|
|
||||||
# Parameter is the unit letter string assumed lower case.
|
|
||||||
sub unit2mult {
|
|
||||||
local($u) = shift;
|
|
||||||
|
|
||||||
$u = ($u =~ /^(mil|meg)/ ? $1 : substr($u, 0, 1));
|
|
||||||
$u = defined($units{$u}) ? $units{$u} : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Evaluate a parameter expression.
|
|
||||||
# Arguments: expression, parameter & value assoc. array.
|
|
||||||
sub prm_eval {
|
|
||||||
local($x,%prm) = @_;
|
|
||||||
|
|
||||||
foreach $key (keys %prm) {
|
|
||||||
$x =~ s/\b$key\b/$prm{$key}/eg;
|
|
||||||
}
|
|
||||||
eval($x . ';');
|
|
||||||
}
|
|
||||||
|
|
||||||
# Write an output file line with a max length. The line is split on
|
|
||||||
# whitespace or '=' at a point less than or equal to the max length
|
|
||||||
# and output as a spice continuation line.
|
|
||||||
# If a splitting delimiter is not found within $MAXLEN, then allowable
|
|
||||||
# length is increased, potentially up to the actual line length.
|
|
||||||
# NOTE: outputs '\n'.
|
|
||||||
# $MAXLEN sets the max value, $DMAXLEN the increment.
|
|
||||||
# File handle = OUTFILE.
|
|
||||||
sub prm_wrline {
|
|
||||||
local($line) = shift;
|
|
||||||
local($max, $s, $m);
|
|
||||||
|
|
||||||
$max = $MAXLEN;
|
|
||||||
until ($line eq '') {
|
|
||||||
if (length($line) > $max) {
|
|
||||||
$m = substr($line, 0, $max);
|
|
||||||
if ($m =~ /((\s|\=)[^(\s|\=)]*)$/) {
|
|
||||||
$s = $` . $2;
|
|
||||||
$line = '+' . substr($line, length($s));
|
|
||||||
}
|
|
||||||
else { $max += $DMAXLEN; next; }
|
|
||||||
}
|
|
||||||
else { $s = $line; $line = ''; }
|
|
||||||
print OUTFILE "$s\n";
|
|
||||||
$max = $MAXLEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
Begin3
|
|
||||||
Title: spiceprm-0.11.tar.gz
|
|
||||||
Version: 0.11
|
|
||||||
Entered-date: 02JAN97
|
|
||||||
Description: A Perl script preprocessor adding parameterized
|
|
||||||
subcircuit capability to the Berkeley Spice circuit
|
|
||||||
simulator. Should also work with any spice lacking
|
|
||||||
this feature.
|
|
||||||
Keywords: spice cad simulation preprocessor perl script
|
|
||||||
Author: andy@moose.mv.com (Andy Borsa)
|
|
||||||
Maintained-by:
|
|
||||||
Primary-site: sunsite.unc.edu /pub/Linux/apps/circuits
|
|
||||||
15.6kB spiceprm-0.11.tar.gz
|
|
||||||
Alternate-site:
|
|
||||||
Original-site:
|
|
||||||
Platforms: Linux or most any unix, Perl 4 or greater.
|
|
||||||
Tested with Linux and Perl 5.
|
|
||||||
Copying-policy: GNU General Public License. See file COPYING.
|
|
||||||
End
|
|
||||||
Loading…
Reference in New Issue