load per `admsmodel' command

This commit is contained in:
rlar 2012-04-13 16:08:24 +02:00
parent 021fa1448c
commit 9f76b7d4a6
7 changed files with 58 additions and 11 deletions

View File

@ -4,6 +4,15 @@
#include <../spicelib/devices/dev.h> /*for load library commands*/
#include "com_dl.h"
#if ADMS >= 3 || 1
void com_admsmodel(wordlist *wl){
wordlist *ww;
for(ww = wl;ww;ww = ww->wl_next)
if(load_vadev(wl->wl_word))
fprintf(cp_err,"Error: ADMS Library %s couldn't be loaded!\n",ww->wl_word);
return;
}
#endif
#ifdef XSPICE
void com_codemodel(wordlist *wl){
wordlist *ww;

View File

@ -1,6 +1,10 @@
#ifndef _COM_DL_H
#define _COM_DL_H 1
#if ADMS >= 3 || 1
void com_admsmodel(wordlist *wl);
#endif
#ifdef XSPICE
void com_codemodel(wordlist *wl);
#endif

View File

@ -246,6 +246,13 @@ struct comm spcp_coms[] = {
NULL,
"library library ... : Loads the opus librarys." } ,
#endif
#if ADMS >= 3 || 1
#warning "yea, its there"
{ "admsmodel", com_admsmodel, FALSE, TRUE,
{ 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS,
NULL,
"library library ... : Loads the adms librarys." } ,
#endif
#ifdef DEVLIB
{ "use", com_use, FALSE, TRUE,
{ 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS,

View File

@ -234,7 +234,7 @@ extern int ARCHme; /* My logical process number */
extern int ARCHsize; /* Total number of processes */
#if ADMS >= 3 || 1
int load_vadev(CKTcircuit *ckt, char *name);
int load_vadev(char *name);
#endif
#ifdef TCL_MODULE

View File

@ -417,6 +417,11 @@ struct dvec *EVTfindvec(char *node){
}
#endif /* XSPICE */
int load_vadev(char *name){
NG_IGNORE(name);
return(1);
}
#endif /* SIMULATOR */
char *hlp_filelist[] = { "ngspice", 0 };

View File

@ -169,7 +169,29 @@ int DEVflag(int type){
#include "ngspice/fteext.h" /* for ft_sim */
#include "ngspice/cktdefs.h" /* for DEVmaxnum */
#include <dlfcn.h>
static void varelink(CKTcircuit *ckt) {
int
is_adms_type(const char *type_name)
{
int i;
if(strcmp(type_name, "hicum0"))
return -1;
for(i=0; i<DEVNUM; i++) {
if(!DEVices[i])
continue;
if(!strcmp(type_name, DEVices[i]->DEVpublic.name)) {
printf("found %d\n", i);
return i;
}
}
return -1;
}
static void
relink_fixme(void) {
/*
* This replacement done by SDB on 6.11.2003
@ -180,14 +202,11 @@ static void varelink(CKTcircuit *ckt) {
ft_sim->numDevices = DEVNUM;
DEVmaxnum = DEVNUM;
ckt->CKThead = TREALLOC(GENmodel *, ckt->CKThead, DEVmaxnum);
ckt->CKThead[DEVmaxnum-1] = NULL;
ft_sim->devices = devices_ptr();
return;
}
int load_vadev(CKTcircuit *ckt, char *name)
int load_vadev(char *name)
{
char *msg, libname[50];
void *lib;
@ -228,8 +247,8 @@ int load_vadev(CKTcircuit *ckt, char *name)
DEVices = TREALLOC(SPICEdev *, DEVices, DEVNUM + 1);
printf("Added device: %s from dynamic library %s\n", device->spicedev.DEVpublic.name, libname);
DEVices[DEVNUM++] = & (device->spicedev);
varelink(ckt);
return DEVNUM-1;
relink_fixme();
return 0;
}
#endif

View File

@ -31,6 +31,8 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab)
char *val;
double rval=0, lval=0;
extern int is_adms_type(const char *type_name);
NG_IGNORE(ckt);
line = image->line;
@ -46,10 +48,11 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab)
INPgetTok(&line, &type_name, 1); /* get model type */
#if ADMS >= 3 || 1
if ((type=load_vadev(ckt,type_name)) && type>=0) {
#warning "nono"
if ((type=is_adms_type(type_name)) >= 0) {
INPmodel *thismodel;
char *error;
#ifdef TRACE
#if defined(TRACE) || 1
printf("inpdomod.c: got model %s from dynamic library - create device # %i\n",type_name,type);
#endif
INPmakeMod(modname, type, image);