first trial to load simkit

This commit is contained in:
dwarning 2014-09-17 22:26:06 +02:00
parent 2602a492b2
commit 1bb1cc1f47
8 changed files with 1473 additions and 2 deletions

View File

@ -141,6 +141,10 @@ AC_ARG_ENABLE([expdevices],
AC_ARG_ENABLE([xspice],
[AS_HELP_STRING([--enable-xspice], [Enable XSpice enhancements, (experimental)])])
# --enable-simkit: define SIMKIT in the code.
AC_ARG_ENABLE([simkit],
[AS_HELP_STRING([--enable-simkit], [Interface to the NXP simkit model library])])
# --enable-cider: define CIDER in the code. This is for CIDER support
AC_ARG_ENABLE([cider],
[AS_HELP_STRING([--enable-cider], [Enable CIDER enhancements, (experimental)])])
@ -921,6 +925,13 @@ AC_SUBST([XSPICEDLLIBS])
AM_CONDITIONAL([XSPICE_WANTED], [test "x$enable_xspice" = xyes])
# Add simkit model library to ngspice.
if test "x$enable_simkit" = xyes; then
AC_MSG_RESULT([SIMKIT model library enabled])
AC_DEFINE([SIMKIT], [1], [The SIMKIT model library])
fi
AM_CONDITIONAL([SIMKIT_WANTED], [test "x$enable_simkit" = xyes])
# Add CIDER enhancements to ngspice.
if test "x$enable_cider" = xyes; then

View File

@ -4,7 +4,6 @@
#include "../spicelib/devices/dev.h" /* for load library commands */
#include "com_dl.h"
#ifdef XSPICE
void com_codemodel(wordlist *wl)
{
@ -28,3 +27,14 @@ void com_use(wordlist *wl)
fprintf(cp_err, "Error: Library %s couldn't be loaded!\n", ww->wl_word);
}
#endif
#ifdef SIMKIT
void com_simkit(wordlist *wl)
{
wordlist *ww;
for (ww = wl; ww; ww = ww->wl_next)
if (load_simkit())
fprintf(cp_err, "Error: Simkit %s couldn't be loaded!\n", ww->wl_word);
}
#endif

View File

@ -9,4 +9,8 @@ void com_codemodel(wordlist *wl);
void com_use(wordlist *wl);
#endif
#ifdef SIMKIT
void com_simkit(wordlist *wl);
#endif
#endif

View File

@ -254,6 +254,12 @@ struct comm spcp_coms[] = {
{ 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS,
NULL,
"library library ... : Loads the device librarys." } ,
#endif
#ifdef SIMKIT
{ "simkit", com_simkit, FALSE, TRUE,
{ 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS,
NULL,
"library library ... : Loads the simkit model library." } ,
#endif
{ "load", com_load, FALSE, TRUE,
{ 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS,

View File

@ -36,6 +36,11 @@
#include "dev.h"
#include "ngspice/memory.h" /* to alloc, realloc devices*/
#ifdef SIMKIT
#include "sk.h"
#include "simkit_models_loader.h"
#include <dlfcn.h> /* to load libraries*/
#endif
#ifdef XSPICE
/*saj headers for xspice*/
@ -505,3 +510,31 @@ char *dlerror(void)
#endif
/*-------------------- end of XSPICE additions ----------------------*/
#ifdef SIMKIT
int load_simkit(void){
const char *msg;
SK_MODELLIB_DESCRIPTOR (*p_sk_load_models)(void) = NULL;
SK_MODELLIB_DESCRIPTOR *p_sk_modellib_descr = NULL;
void (*p_sk_unload_models)(void) = NULL;
void *p_sk_loader_lib = dlopen("/home/dwarning/local/src/spice/simkit/4.3_pub/source/lib/libsimkit_models_loader", RTLD_LAZY | RTLD_GLOBAL);
if (p_sk_loader_lib != NULL)
{
p_sk_load_models = dlsym(p_sk_loader_lib, "SK_load_models");
p_sk_unload_models = dlsym(p_sk_loader_lib, "SK_unload_models");
} else
{
msg = dlerror();
printf("%s\n", msg);
return 1;
}
if (p_sk_load_models != NULL)
{
p_sk_modellib_descr = p_sk_load_models();
}
}
#endif

View File

@ -1,7 +1,6 @@
#ifndef _DEV_H
#define _DEV_H
void spice_init_devices(void);
void spice_destroy_devices(void);
int num_devices(void);
@ -15,5 +14,9 @@ int DEVflag(int type);
void load_alldevs(void);
int load_dev(char *name);
#endif
#ifdef SIMKIT
int load_simkit(void);
#endif
#endif

View File

@ -0,0 +1,63 @@
/*---------------------------------------------------------------------
* Do not change this data manually,
* it will be automatically updated by RCS
*
* $RCSfile$
* $Date: 2012-07-19 13:58:39 +0200 (Thu, 19 Jul 2012) $
* $Revision: 11822 $
*
* ----------------------------------------------------------------------*/
#ifndef _SIMKIT_MODELS_LOADER_H
#define _SIMKIT_MODELS_LOADER_H
/**
* @file
* This file contains exported functions to load and unload the
* SiMKit models library.
*/
//#ifdef __cplusplus
//extern "C" {
//#endif
#include <stdio.h>
#include <stdarg.h>
#include "sk.h"
#ifdef _WIN32
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define MAXPATHLEN 1024
#ifdef SIMKIT_MODEL_LOAD_IMPL
#define SK_DECL extern "C" __declspec(dllexport)
#else
#define SK_DECL extern "C"
#endif
#else
#define SK_DECL extern
#endif
/**
* Load the shared library with the NXP models.
* When the library cannot be loaded the function prints an error to stderr.
* @return the pointer to the SK_MODELLIB_DESCRIPTOR (NULL on error).
*/
SK_DECL SK_MODELLIB_DESCRIPTOR* SK_load_models(void);
/**
* Unload a previously loaded shared library.
* Multiple calls are allowed without any harm.
*/
SK_DECL void SK_unload_models(void);
//#ifdef __cplusplus
//}
//#endif
#endif /* _SIMKIT_MODELS_LOADER_H */

1341
src/spicelib/devices/sk.h Normal file

File diff suppressed because it is too large Load Diff