From 7472642832b4d4bf43f724ae9748adc03ae0da37 Mon Sep 17 00:00:00 2001 From: arno Date: Mon, 1 May 2000 17:43:38 +0000 Subject: [PATCH] * src/Makefile.am src/main.c src/ngspice.c src/devices/Makefile.am, src/devices/dev.c src/devices/dev.h: Refactored devices initialization code into the devices dir. --- ChangeLog | 4 + src/Makefile.am | 1 + src/main.c | 6 ++ src/ngspice.c | 175 +++++++------------------------ src/spicelib/devices/Makefile.am | 5 + src/spicelib/devices/dev.c | 126 ++++++++++++++++++++++ src/spicelib/devices/dev.h | 10 ++ 7 files changed, 187 insertions(+), 140 deletions(-) create mode 100644 src/spicelib/devices/dev.c create mode 100644 src/spicelib/devices/dev.h diff --git a/ChangeLog b/ChangeLog index 9be8cc975..f279aac30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2000-05-01 Arno W. Peters + * src/devices/Makefile.am, src/devices/dev.c, src/devices/dev.h, + src/Makefile.am, src/ngspice.c, src/main.c: Refactored devices + initialization code into the devices dir. + * tests/respart.cir, tests/respart.out, tests/respart.sh: additional tests for resistor. diff --git a/src/Makefile.am b/src/Makefile.am index 24f81d8b4..f6f40cc27 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,6 +67,7 @@ ngspice_SOURCES = \ ngspice_LDADD = \ spice.o \ frontend/libfte.a \ + devices/libdev.a \ $(DYNAMIC_DEVICELIBS) \ analysis/libckt.a \ parser/libparser.a \ diff --git a/src/main.c b/src/main.c index 1f0b6f062..9c264b544 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ #include "ftedev.h" #include "ftedebug.h" #include "const.h" +#include "devices/dev.h" #ifdef HAVE_PWD_H #include @@ -160,6 +161,11 @@ IFfrontEnd *SPfrontEnd = NULL; int SIMinit(IFfrontEnd *frontEnd, IFsimulator **simulator) { +#ifdef SIMULATOR + SIMinfo.numDevices = num_devices(); + SIMinfo.devices = devices_ptr(); +#endif /* SIMULATOR */ + SPfrontEnd = frontEnd; *simulator = &SIMinfo; CONSTroot2 = sqrt(2.); diff --git a/src/ngspice.c b/src/ngspice.c index b30de3a59..51e4a78c2 100644 --- a/src/ngspice.c +++ b/src/ngspice.c @@ -16,41 +16,6 @@ #define AN_noise #define AN_sense -/* - * Devices - */ -#define DEV_asrc -#define DEV_bjt -#define DEV_bsim1 -#define DEV_bsim2 -#define DEV_bsim3 -#define DEV_bsim4 -#define DEV_bsim3v1 -#define DEV_bsim3v2 -#define DEV_cap -#define DEV_cccs -#define DEV_ccvs -#define DEV_csw -#define DEV_dio -#define DEV_ind -#define DEV_isrc -#define DEV_jfet -#define DEV_jfet2 -#define DEV_ltra -#define DEV_mes -#define DEV_mos1 -#define DEV_mos2 -#define DEV_mos3 -#define DEV_mos6 -#define DEV_res -#define DEV_sw -#define DEV_tra -#define DEV_urc -#define DEV_vccs -#define DEV_vcvs -#define DEV_vsrc - -#define DEVICES_USED "asrc bjt bsim1 bsim2 bsim3 bsim3v2 bsim3v1 cap cccs ccvs csw dio ind isrc jfet ltra mes mos1 mos2 mos3 mos6 res sw tra urc vccs vcvs vsrc" #define ANALYSES_USED "op dc tf ac tran pz disto noise sense" /********** @@ -65,42 +30,10 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include -#include "noisedef.h" #include "devdefs.h" +#include "noisedef.h" #include "suffix.h" -#include "asrc/asrcitf.h" -#include "bjt/bjtitf.h" -#include "cap/capitf.h" -#include "cccs/cccsitf.h" -#include "ccvs/ccvsitf.h" -#include "csw/cswitf.h" -#include "dio/dioitf.h" -#include "ind/inditf.h" -#include "isrc/isrcitf.h" -#include "mos1/mos1itf.h" -#include "mos6/mos6itf.h" -#include "res/resitf.h" -#include "sw/switf.h" -#include "vccs/vccsitf.h" -#include "vcvs/vcvsitf.h" -#include "vsrc/vsrcitf.h" -#include "bsim1/bsim1itf.h" -#include "bsim2/bsim2itf.h" -#include "bsim3/bsim3itf.h" -#include "bsim4/bsim4itf.h" -#include "bsim3v1/bsim3v1itf.h" -#include "bsim3v2/bsim3v2itf.h" -#include "mos2/mos2itf.h" -#include "mos3/mos3itf.h" -#include "jfet/jfetitf.h" -#include "jfet2/jfet2itf.h" -#include "mes/mesitf.h" -#include "ltra/ltraitf.h" -#include "tra/traitf.h" -#include "urc/urcitf.h" - - extern SPICEanalysis OPTinfo; extern SPICEanalysis ACinfo; @@ -129,44 +62,6 @@ SPICEanalysis *analInfo[] = { }; int ANALmaxnum = sizeof(analInfo)/sizeof(SPICEanalysis*); -SPICEdev *DEVices[] = { - - /* URC must appear before the resistor, capacitor, and diode */ - &URCinfo, - &ASRCinfo, - &BJTinfo, - &B1info, - &B2info, - &BSIM3info, - &B4info, - &BSIM3V2info, - &BSIM3V1info, - &CAPinfo, - &CCCSinfo, - &CCVSinfo, - &CSWinfo, - &DIOinfo, - &INDinfo, - &MUTinfo, - &ISRCinfo, - &JFETinfo, - &JFET2info, - <RAinfo, - &MESinfo, - &MOS1info, - &MOS2info, - &MOS3info, - &MOS6info, - &RESinfo, - &SWinfo, - &TRAinfo, - &VCCSinfo, - &VCVSinfo, - &VSRCinfo, -}; - -/* my internal global constant for number of device types */ -int DEVmaxnum = sizeof(DEVices)/sizeof(SPICEdev *); /* XXX Should be -1 ? There is always an extra null element at the end ? */ static char * specSigList[] = { "time" @@ -179,47 +74,47 @@ static IFparm nodeParms[] = { }; IFsimulator SIMinfo = { - "ngspice", /* name */ - "Circuit level simulation program", /* more about me */ - Spice_Version, /* version */ + "ngspice", /* name */ + "Circuit level simulation program", /* more about me */ + Spice_Version, /* version */ - CKTinit, /* newCircuit function */ - CKTdestroy, /* deleteCircuit function */ + CKTinit, /* newCircuit function */ + CKTdestroy, /* deleteCircuit function */ - CKTnewNode, /* newNode function */ - CKTground, /* groundNode function */ - CKTbindNode, /* bindNode function */ - CKTfndNode, /* findNode function */ - CKTinst2Node, /* instToNode function */ - CKTsetNodPm, /* setNodeParm function */ - CKTaskNodQst, /* askNodeQuest function */ - CKTdltNod, /* deleteNode function */ + CKTnewNode, /* newNode function */ + CKTground, /* groundNode function */ + CKTbindNode, /* bindNode function */ + CKTfndNode, /* findNode function */ + CKTinst2Node, /* instToNode function */ + CKTsetNodPm, /* setNodeParm function */ + CKTaskNodQst, /* askNodeQuest function */ + CKTdltNod, /* deleteNode function */ - CKTcrtElt, /* newInstance function */ - CKTparam, /* setInstanceParm function */ - CKTask, /* askInstanceQuest function */ - CKTfndDev, /* findInstance funciton */ - CKTdltInst, /* deleteInstance function */ + CKTcrtElt, /* newInstance function */ + CKTparam, /* setInstanceParm function */ + CKTask, /* askInstanceQuest function */ + CKTfndDev, /* findInstance funciton */ + CKTdltInst, /* deleteInstance function */ - CKTmodCrt, /* newModel function */ - CKTmodParam, /* setModelParm function */ - CKTmodAsk, /* askModelQuest function */ - CKTfndMod, /* findModel function */ - CKTdltMod, /* deleteModel function */ + CKTmodCrt, /* newModel function */ + CKTmodParam, /* setModelParm function */ + CKTmodAsk, /* askModelQuest function */ + CKTfndMod, /* findModel function */ + CKTdltMod, /* deleteModel function */ - CKTnewTask, /* newTask function */ - CKTnewAnal, /* newAnalysis function */ - CKTsetAnalPm, /* setAnalysisParm function */ - CKTaskAnalQ, /* askAnalysisQuest function */ - CKTfndAnal, /* findAnalysis function */ - CKTfndTask, /* findTask function */ - CKTdelTask, /* deleteTask function */ + CKTnewTask, /* newTask function */ + CKTnewAnal, /* newAnalysis function */ + CKTsetAnalPm, /* setAnalysisParm function */ + CKTaskAnalQ, /* askAnalysisQuest function */ + CKTfndAnal, /* findAnalysis function */ + CKTfndTask, /* findTask function */ + CKTdelTask, /* deleteTask function */ - CKTdoJob, /* doAnalyses function */ - CKTtrouble, /* non-convergence message function */ + CKTdoJob, /* doAnalyses function */ + CKTtrouble, /* non-convergence message function */ - sizeof(DEVices)/sizeof(SPICEdev *), - (IFdevice**)DEVices, + 0, /* Initialized in SIMinit() */ + NULL, /* Initialized in SIMinit() */ sizeof(analInfo)/sizeof(SPICEanalysis *), (IFanalysis **)analInfo, diff --git a/src/spicelib/devices/Makefile.am b/src/spicelib/devices/Makefile.am index 6fa8ebcaa..a1698ff92 100644 --- a/src/spicelib/devices/Makefile.am +++ b/src/spicelib/devices/Makefile.am @@ -34,5 +34,10 @@ SUBDIRS = \ vcvs \ vsrc +lib_LIBRARIES = libdev.a + +libdev_a_SOURCES = dev.c + +INCLUDES = -I$(top_srcdir)/src/include MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c new file mode 100644 index 000000000..b63324157 --- /dev/null +++ b/src/spicelib/devices/dev.c @@ -0,0 +1,126 @@ +/* Configuration file for ng-spice */ +#include + +#include "dev.h" +#include "devdefs.h" + +/* + * Devices + */ +#define DEV_asrc +#define DEV_bjt +#define DEV_bsim1 +#define DEV_bsim2 +#define DEV_bsim3 +#define DEV_bsim4 +#define DEV_bsim3v1 +#define DEV_bsim3v2 +#define DEV_cap +#define DEV_cccs +#define DEV_ccvs +#define DEV_csw +#define DEV_dio +#define DEV_ind +#define DEV_isrc +#define DEV_jfet +#define DEV_jfet2 +#define DEV_ltra +#define DEV_mes +#define DEV_mos1 +#define DEV_mos2 +#define DEV_mos3 +#define DEV_mos6 +#define DEV_res +#define DEV_sw +#define DEV_tra +#define DEV_urc +#define DEV_vccs +#define DEV_vcvs +#define DEV_vsrc + +#define DEVICES_USED "asrc bjt bsim1 bsim2 bsim3 bsim3v2 bsim3v1 cap cccs ccvs csw dio ind isrc jfet ltra mes mos1 mos2 mos3 mos6 res sw tra urc vccs vcvs vsrc" + +#include "asrc/asrcitf.h" +#include "bjt/bjtitf.h" +#include "cap/capitf.h" +#include "cccs/cccsitf.h" +#include "ccvs/ccvsitf.h" +#include "csw/cswitf.h" +#include "dio/dioitf.h" +#include "ind/inditf.h" +#include "isrc/isrcitf.h" +#include "mos1/mos1itf.h" +#include "mos6/mos6itf.h" +#include "res/resitf.h" +#include "sw/switf.h" +#include "vccs/vccsitf.h" +#include "vcvs/vcvsitf.h" +#include "vsrc/vsrcitf.h" +#include "bsim1/bsim1itf.h" +#include "bsim2/bsim2itf.h" +#include "bsim3/bsim3itf.h" +#include "bsim4/bsim4itf.h" +#include "bsim3v1/bsim3v1itf.h" +#include "bsim3v2/bsim3v2itf.h" +#include "mos2/mos2itf.h" +#include "mos3/mos3itf.h" +#include "jfet/jfetitf.h" +#include "jfet2/jfet2itf.h" +#include "mes/mesitf.h" +#include "ltra/ltraitf.h" +#include "tra/traitf.h" +#include "urc/urcitf.h" + + +SPICEdev *DEVices[] = { + + /* URC must appear before the resistor, capacitor, and diode */ + &URCinfo, + &ASRCinfo, + &BJTinfo, + &B1info, + &B2info, + &BSIM3info, + &B4info, + &BSIM3V2info, + &BSIM3V1info, + &CAPinfo, + &CCCSinfo, + &CCVSinfo, + &CSWinfo, + &DIOinfo, + &INDinfo, + &MUTinfo, + &ISRCinfo, + &JFETinfo, + &JFET2info, + <RAinfo, + &MESinfo, + &MOS1info, + &MOS2info, + &MOS3info, + &MOS6info, + &RESinfo, + &SWinfo, + &TRAinfo, + &VCCSinfo, + &VCVSinfo, + &VSRCinfo, +}; + + +/* my internal global constant for number of device types */ +int DEVmaxnum = sizeof(DEVices)/sizeof(SPICEdev *); + + +int +num_devices(void) +{ + return sizeof(DEVices)/sizeof(SPICEdev *); +} + +IFdevice ** +devices_ptr(void) +{ + return (IFdevice **) DEVices; +} diff --git a/src/spicelib/devices/dev.h b/src/spicelib/devices/dev.h new file mode 100644 index 000000000..e9032a0a9 --- /dev/null +++ b/src/spicelib/devices/dev.h @@ -0,0 +1,10 @@ +#ifndef _DEV_H +#define _DEV_H + +#include + +int num_devices(void); +IFdevice **devices_ptr(void); + +#endif +