From d7ad0ee10cae5ba8dec22d98bf8d9d002e18afb5 Mon Sep 17 00:00:00 2001 From: arno Date: Sat, 17 Jun 2000 22:54:26 +0000 Subject: [PATCH] * AUTHORS TODO: Small updates. * src/devices/dev.c src/devices/dev.h: Small updates. * src/devices/README: Short description of the purpose of the devices directory. * src/analysis/cktaccpt.c src/analysis/cktcrte.c src/analysis/cktinit.c: Moved these files into src/devices. * src/analysis/dctran.c: Updates to ease the move. * src/analysis/Makefile.am src/devices/Makefile.am: Updates * src/Makefile.am: Library loading reordered. * src/main.c: Small updates. * src/devices/devsup/devsup.c: Moved this file into src/devices. * src/devices/devsup/.cvsignore src/devices/devsup/Makefile.am: Superfluous files, removed * configure.in: Removed src/devices/devsup/Makefile. --- AUTHORS | 1 + TODO | 20 +++--- configure.in | 1 - src/Makefile.am | 3 +- src/analysis/Makefile.am | 3 - src/analysis/cktcrte.c | 47 -------------- src/analysis/cktinit.c | 62 ------------------ src/analysis/dctran.c | 14 ++-- src/main.c | 18 +++--- src/spicelib/devices/Makefile.am | 10 ++- src/spicelib/devices/README | 3 + .../devices/cktaccept.c} | 32 +++++----- src/spicelib/devices/cktaccept.h | 6 ++ src/spicelib/devices/cktcrte.c | 53 +++++++++++++++ src/spicelib/devices/cktinit.c | 64 +++++++++++++++++++ src/spicelib/devices/dev.c | 10 ++- src/spicelib/devices/dev.h | 3 +- src/spicelib/devices/{devsup => }/devsup.c | 0 src/spicelib/devices/devsup/.cvsignore | 6 -- src/spicelib/devices/devsup/Makefile.am | 10 --- 20 files changed, 187 insertions(+), 179 deletions(-) delete mode 100644 src/analysis/cktcrte.c delete mode 100644 src/analysis/cktinit.c create mode 100644 src/spicelib/devices/README rename src/{analysis/cktaccpt.c => spicelib/devices/cktaccept.c} (52%) create mode 100644 src/spicelib/devices/cktaccept.h create mode 100644 src/spicelib/devices/cktcrte.c create mode 100644 src/spicelib/devices/cktinit.c rename src/spicelib/devices/{devsup => }/devsup.c (100%) delete mode 100644 src/spicelib/devices/devsup/.cvsignore delete mode 100644 src/spicelib/devices/devsup/Makefile.am diff --git a/AUTHORS b/AUTHORS index 2ba8c2a41..952fc6ea0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -17,6 +17,7 @@ Min-Chie Jeng Kenneth H. Keller Mathew Lew Weidong Liu +Richard D. McRoberts Gary W. Ng Hong June Park Thomas L. Quarles diff --git a/TODO b/TODO index 1cdb597db..ceb9ef581 100644 --- a/TODO +++ b/TODO @@ -6,9 +6,9 @@ Standards conformance --------------------- Add proper copyright headers to every source, header, documentation -and other files +and other files. -Fix all compiler warnings +Fix all compiler warnings. Remove smktemp() in favor of tmpfile() or other ANSI C equivalent; Note: different symantics! @@ -20,8 +20,8 @@ available. Usability issues ------------------ -Plug all memory leaks (use debauch from -http://quorum.tamu.edu/jon/gnu/ to find them) +Plug all memory leaks; use debauch (http://quorum.tamu.edu/jon/gnu/) +or another memory checker to find them. Either get help program functioning again; OR interface to webbrowser, info reader and get rid of all help-related code. Option 2 is the @@ -31,15 +31,17 @@ most appealing. Refactorings ------------ -Make devices dynamically loadable (perhaps use framework from glib) +Make devices dynamically loadable (perhaps use framework from glib). -Separate out circuit builder from the analysis code and put it in a -separate src/builder directory +Separate out circuit builder from the analysis code and put it in the +devices directory (rename devices directory to simbuilder at some +point). [PARTIAL] -Separate ngspice and nutmeg; i.e., no more SIMULATOR define +Separate ngspice and nutmeg; i.e., no more SIMULATOR define. Dispose +of nutmeg all together once the devices are plugins. Integrate bsim3, bsim3v1, bsim3v2 to use a single codebase instead of -three only slighty differing implementations +three only slighty differing implementations. Separate frontend commands from supporting code. Command files start with com_*. [PARTIAL] diff --git a/configure.in b/configure.in index 6ec9a2309..a55a67fba 100644 --- a/configure.in +++ b/configure.in @@ -212,7 +212,6 @@ src/devices/cap/Makefile \ src/devices/cccs/Makefile \ src/devices/ccvs/Makefile \ src/devices/csw/Makefile \ -src/devices/devsup/Makefile \ src/devices/dio/Makefile \ src/devices/ind/Makefile \ src/devices/isrc/Makefile \ diff --git a/src/Makefile.am b/src/Makefile.am index 93cf48eff..05b82f754 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,6 @@ DYNAMIC_DEVICELIBS = \ devices/ccvs/libccvs.la \ devices/ccvs/libccvs.la \ devices/csw/libcsw.la \ - devices/devsup/libdevsup.la \ devices/dio/libdio.la \ devices/ind/libind.la \ devices/isrc/libisrc.la \ @@ -57,9 +56,9 @@ ngspice_LDADD = \ spice.o \ frontend/libfte.a \ frontend/plotting/libplotting.a \ - devices/libdev.a \ $(DYNAMIC_DEVICELIBS) \ analysis/libckt.a \ + devices/libdev.a \ parser/libparser.a \ hlp/libhlp.a \ circuit/libinp.a \ diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am index 104e57ae6..31b2f4a8d 100644 --- a/src/analysis/Makefile.am +++ b/src/analysis/Makefile.am @@ -6,7 +6,6 @@ libckt_a_SOURCES = \ acan.c \ acaskq.c \ acsetp.c \ - cktaccpt.c \ cktacct.c \ cktacdum.c \ cktask.c \ @@ -15,7 +14,6 @@ libckt_a_SOURCES = \ cktbindn.c \ cktbkdum.c \ cktclrbk.c \ - cktcrte.c \ cktdelt.c \ cktdest.c \ cktdisto.c \ @@ -33,7 +31,6 @@ libckt_a_SOURCES = \ cktgrnd.c \ ckti2nod.c \ cktic.c \ - cktinit.c \ cktlnkeq.c \ cktload.c \ cktmapn.c \ diff --git a/src/analysis/cktcrte.c b/src/analysis/cktcrte.c deleted file mode 100644 index d1cbb034e..000000000 --- a/src/analysis/cktcrte.c +++ /dev/null @@ -1,47 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTcrtElement(ckt,type,inModPtr,inInstPtr,name,subname) - * Create a device of the specified type, with the given name, using - * the specified model in the named circuit. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - - -/*ARGSUSED*/ -int -CKTcrtElt(void *ckt, void *inModPtr, void **inInstPtr, IFuid name) -{ - GENinstance *instPtr = NULL; - GENmodel *modPtr=(GENmodel*)inModPtr; - extern SPICEdev *DEVices[]; - int error; - int type; - - if((GENmodel *)modPtr==(GENmodel*)NULL) return(E_NOMOD); - type = ((GENmodel*)modPtr)->GENmodType; - error =CKTfndDev(ckt,&type,(void**)&instPtr,name,inModPtr,(char *)NULL ); - if (error== OK) { - if(inInstPtr) *inInstPtr=(void *)instPtr; - return(E_EXISTS); - } else if (error != E_NODEV) return(error); - instPtr = (GENinstance *)MALLOC(*DEVices[type]->DEVinstSize); - if(instPtr == (GENinstance *)NULL) return(E_NOMEM); - instPtr->GENname = name; - instPtr->GENmodPtr = modPtr; - instPtr->GENnextInstance = modPtr->GENinstances; - modPtr->GENinstances = instPtr; - if(inInstPtr != NULL) *inInstPtr = (void *)instPtr; - return(OK); -} diff --git a/src/analysis/cktinit.c b/src/analysis/cktinit.c deleted file mode 100644 index d23cb37bd..000000000 --- a/src/analysis/cktinit.c +++ /dev/null @@ -1,62 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cktdefs.h" -#include "const.h" -#include "sperror.h" - - -int -CKTinit(void **ckt) - /* new circuit to create */ -{ - int i; - CKTcircuit *sckt; - - sckt = (CKTcircuit *)( *ckt = (char *)MALLOC(sizeof(CKTcircuit)) ); - if(sckt == NULL) return(E_NOMEM); - for (i=0;iCKThead[i] = (GENmodel *) NULL; - } - (sckt)->CKTmaxEqNum = 1; - (sckt)->CKTnodes = (CKTnode *)NULL; - (sckt)->CKTlastNode = (CKTnode *)NULL; - sckt->CKTmatrix = NULL; - - (sckt)->CKTgmin = 1e-12; - (sckt)->CKTabstol = 1e-12; - (sckt)->CKTreltol = 1e-3; - (sckt)->CKTchgtol = 1e-14; - (sckt)->CKTvoltTol = 1e-6; - (sckt)->CKTtrtol = 7; - (sckt)->CKTbypass = 1; - (sckt)->CKTisSetup = 0; - (sckt)->CKTtranMaxIter = 10; - (sckt)->CKTdcMaxIter = 100; - (sckt)->CKTdcTrcvMaxIter = 50; - (sckt)->CKTintegrateMethod = TRAPEZOIDAL; - (sckt)->CKTorder = 1; - (sckt)->CKTmaxOrder = 2; - (sckt)->CKTpivotAbsTol = 1e-13; - (sckt)->CKTpivotRelTol = 1e-3; - (sckt)->CKTtemp = 300.15; - (sckt)->CKTnomTemp = 300.15; - (sckt)->CKTdefaultMosL = 1e-4; - (sckt)->CKTdefaultMosW = 1e-4; - (sckt)->CKTdefaultMosAD = 0; - (sckt)->CKTdefaultMosAS = 0; - (sckt)->CKTsrcFact=1; - (sckt)->CKTdiagGmin=0; - (sckt)->CKTstat = (STATistics *)MALLOC(sizeof(STATistics)); - (sckt)->CKTtroubleNode = 0; - (sckt)->CKTtroubleElt = NULL; - (sckt)->CKTtimePoints = NULL; - if( (sckt)->CKTstat == (STATistics *)NULL) return(E_NOMEM); - - return(OK); -} diff --git a/src/analysis/dctran.c b/src/analysis/dctran.c index 04e99cafd..e4176cfcb 100644 --- a/src/analysis/dctran.c +++ b/src/analysis/dctran.c @@ -6,15 +6,15 @@ Author: 1985 Thomas L. Quarles /* subroutine to do DC TRANSIENT analysis --- ONLY, unlike spice2 routine with the same name! */ -#include "ngspice.h" -#include -#include "trandefs.h" -#include "cktdefs.h" -#include "sperror.h" +#include +#include +#include +#include +#include int -DCtran(CKTcircuit *ckt, int restart) -/* restart: forced restart flag */ +DCtran(CKTcircuit *ckt, + int restart) /* forced restart flag */ { int i; double olddelta; diff --git a/src/main.c b/src/main.c index 137ea78eb..4da189c3e 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,8 @@ Author: 1985 Wayne A. Christopher The main routine for ngspice */ +#include + #include #include #include @@ -14,16 +16,12 @@ #define _GNU_SOURCE #include -#include "ngspice.h" -#include "ifsim.h" -#include "inpdefs.h" -#include "iferrmsg.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedev.h" -#include "ftedebug.h" -#include "const.h" -#include "devices/dev.h" +#include +#include +#include +#include +#include +#include #ifdef HAVE_PWD_H #include diff --git a/src/spicelib/devices/Makefile.am b/src/spicelib/devices/Makefile.am index 9b9026c71..70c749793 100644 --- a/src/spicelib/devices/Makefile.am +++ b/src/spicelib/devices/Makefile.am @@ -13,7 +13,6 @@ SUBDIRS = \ cccs \ ccvs \ csw \ - devsup \ dio \ ind \ isrc \ @@ -36,8 +35,13 @@ SUBDIRS = \ lib_LIBRARIES = libdev.a libdev_a_SOURCES = \ - dev.c \ - dev.h + dev.c \ + dev.h \ + devsup.c \ + cktaccept.c \ + cktaccept.h \ + cktcrte.c \ + cktinit.c INCLUDES = -I$(top_srcdir)/src/include diff --git a/src/spicelib/devices/README b/src/spicelib/devices/README new file mode 100644 index 000000000..57e9cc627 --- /dev/null +++ b/src/spicelib/devices/README @@ -0,0 +1,3 @@ +The circuit builder. + +It takes a circuit description and builds a simulator from it. diff --git a/src/analysis/cktaccpt.c b/src/spicelib/devices/cktaccept.c similarity index 52% rename from src/analysis/cktaccpt.c rename to src/spicelib/devices/cktaccept.c index c7d959ca6..bf577aee1 100644 --- a/src/analysis/cktaccpt.c +++ b/src/spicelib/devices/cktaccept.c @@ -4,31 +4,31 @@ Author: 1985 Thomas L. Quarles **********/ /* CKTaccept(ckt) - * this is a driver program to iterate through all the various - * accept functions provided for the circuit elements in the - * given circuit - */ + * + * this is a driver program to iterate through all the various accept + * functions provided for the circuit elements in the given circuit */ -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" +#include +#include +#include +#include +#include +#include "dev.h" int CKTaccept(CKTcircuit *ckt) { - extern SPICEdev *DEVices[]; - int i; int error; + SPICEdev **devs; - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVaccept))(ckt,ckt->CKThead[i]); - if(error) return(error); + devs = devices(); + for (i = 0; i < DEVmaxnum; i++) { + if ( ((*devs[i]).DEVaccept != NULL) && (ckt->CKThead[i] != NULL) ){ + error = (*((*devs[i]).DEVaccept))(ckt,ckt->CKThead[i]); + if (error) + return(error); } } #ifdef PREDICTOR diff --git a/src/spicelib/devices/cktaccept.h b/src/spicelib/devices/cktaccept.h new file mode 100644 index 000000000..c68be5601 --- /dev/null +++ b/src/spicelib/devices/cktaccept.h @@ -0,0 +1,6 @@ +#ifndef _CKTACCEPT_H +#define _CKTACCEPT_H + +int CKTaccept(CKTcircuit *ckt); + +#endif diff --git a/src/spicelib/devices/cktcrte.c b/src/spicelib/devices/cktcrte.c new file mode 100644 index 000000000..7afd64893 --- /dev/null +++ b/src/spicelib/devices/cktcrte.c @@ -0,0 +1,53 @@ +/********** +Copyright 1990 Regents of the University of California. All rights reserved. +Author: 1985 Thomas L. Quarles +**********/ + +/* CKTcrtElement(ckt,type,inModPtr,inInstPtr,name,subname) + * + * Create a device of the specified type, with the given name, using + * the specified model in the named circuit. */ + +#include +#include +#include + +#include "dev.h" + +int +CKTcrtElt(void *ckt, void *inModPtr, void **inInstPtr, IFuid name) +{ + GENinstance *instPtr = NULL; + GENmodel *modPtr=(GENmodel*)inModPtr; + SPICEdev **DEVices; + int error; + int type; + + DEVices = devices(); + if((GENmodel *)modPtr==(GENmodel*)NULL) + return E_NOMOD; + type = ((GENmodel*)modPtr)->GENmodType; + + error = CKTfndDev(ckt, &type, (void**)&instPtr, name, inModPtr, + (char *)NULL ); + if (error == OK) { + if (inInstPtr) + *inInstPtr=(void *)instPtr; + return E_EXISTS; + } else if (error != E_NODEV) + return error; + + instPtr = (GENinstance *) tmalloc(*DEVices[type]->DEVinstSize); + if (instPtr == (GENinstance *)NULL) + return E_NOMEM; + + instPtr->GENname = name; + instPtr->GENmodPtr = modPtr; + instPtr->GENnextInstance = modPtr->GENinstances; + modPtr->GENinstances = instPtr; + + if(inInstPtr != NULL) + *inInstPtr = (void *)instPtr; + + return OK; +} diff --git a/src/spicelib/devices/cktinit.c b/src/spicelib/devices/cktinit.c new file mode 100644 index 000000000..088eaf8e7 --- /dev/null +++ b/src/spicelib/devices/cktinit.c @@ -0,0 +1,64 @@ +/********** +Copyright 1990 Regents of the University of California. All rights reserved. +Author: 1985 Thomas L. Quarles +**********/ + +#include + +#include + +#include +#include + + +int +CKTinit(void **ckt) /* new circuit to create */ +{ + int i; + CKTcircuit *sckt; + + *ckt = (void *) tmalloc(sizeof(CKTcircuit)); + sckt = (CKTcircuit *)(*ckt); + if (sckt == NULL) + return(E_NOMEM); + for (i = 0; i < DEVmaxnum; i++) + sckt->CKThead[i] = (GENmodel *) NULL; + + sckt->CKTmaxEqNum = 1; + sckt->CKTnodes = (CKTnode *) NULL; + sckt->CKTlastNode = (CKTnode *) NULL; + sckt->CKTmatrix = NULL; + + sckt->CKTgmin = 1e-12; + sckt->CKTabstol = 1e-12; + sckt->CKTreltol = 1e-3; + sckt->CKTchgtol = 1e-14; + sckt->CKTvoltTol = 1e-6; + sckt->CKTtrtol = 7; + sckt->CKTbypass = 1; + sckt->CKTisSetup = 0; + sckt->CKTtranMaxIter = 10; + sckt->CKTdcMaxIter = 100; + sckt->CKTdcTrcvMaxIter = 50; + sckt->CKTintegrateMethod = TRAPEZOIDAL; + sckt->CKTorder = 1; + sckt->CKTmaxOrder = 2; + sckt->CKTpivotAbsTol = 1e-13; + sckt->CKTpivotRelTol = 1e-3; + sckt->CKTtemp = 300.15; + sckt->CKTnomTemp = 300.15; + sckt->CKTdefaultMosL = 1e-4; + sckt->CKTdefaultMosW = 1e-4; + sckt->CKTdefaultMosAD = 0; + sckt->CKTdefaultMosAS = 0; + sckt->CKTsrcFact=1; + sckt->CKTdiagGmin=0; + sckt->CKTstat = (STATistics *) tmalloc(sizeof(STATistics)); + sckt->CKTtroubleNode = 0; + sckt->CKTtroubleElt = NULL; + sckt->CKTtimePoints = NULL; + if (sckt->CKTstat == (STATistics *)NULL) + return E_NOMEM; + + return OK; +} diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index ed23930ad..99e9731c5 100644 --- a/src/spicelib/devices/dev.c +++ b/src/spicelib/devices/dev.c @@ -29,8 +29,10 @@ #include +#include +#include + #include "dev.h" -#include "devdefs.h" /* Enable the following devices */ #define DEV_asrc @@ -161,3 +163,9 @@ devices_ptr(void) { return (IFdevice **) DEVices; } + +SPICEdev ** +devices(void) +{ + return DEVices; +} diff --git a/src/spicelib/devices/dev.h b/src/spicelib/devices/dev.h index e9032a0a9..b0fdbbc48 100644 --- a/src/spicelib/devices/dev.h +++ b/src/spicelib/devices/dev.h @@ -1,10 +1,9 @@ #ifndef _DEV_H #define _DEV_H -#include - int num_devices(void); IFdevice **devices_ptr(void); +SPICEdev **devices(void); #endif diff --git a/src/spicelib/devices/devsup/devsup.c b/src/spicelib/devices/devsup.c similarity index 100% rename from src/spicelib/devices/devsup/devsup.c rename to src/spicelib/devices/devsup.c diff --git a/src/spicelib/devices/devsup/.cvsignore b/src/spicelib/devices/devsup/.cvsignore deleted file mode 100644 index dc4caac80..000000000 --- a/src/spicelib/devices/devsup/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile.in -Makefile -.deps -.libs -*.lo -*.la diff --git a/src/spicelib/devices/devsup/Makefile.am b/src/spicelib/devices/devsup/Makefile.am deleted file mode 100644 index 9c2b5051a..000000000 --- a/src/spicelib/devices/devsup/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -## Process this file with automake to produce Makefile.in - -pkglib_LTLIBRARIES = libdevsup.la - -libdevsup_la_SOURCES = devsup.c - - - -INCLUDES = -I$(top_srcdir)/src/include -MAINTAINERCLEANFILES = Makefile.in