mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-09-07 04:53:15 +02:00
GENmodel, GENinstance, change layout, #4/4, complete the change
currently each and every device specific instance and model structure duplicates the memory layout of a struct GENmodel / GENinstance further the first structure elements behind a GENinstance header are reinterpreted as a sort of a generic "node" array. This business is very error prone, and makes it difficult to extend struct GENmodel / struct GENinstance. This patch makes this business much more bearable.
This commit is contained in:
@@ -21,10 +21,19 @@ struct GENinstance {
|
||||
* current model*/
|
||||
IFuid GENname; /* pointer to character string naming this instance */
|
||||
int GENstate; /* state index number */
|
||||
int GENnode[7]; /* node numbers to which this instance is connected to */
|
||||
/* carefull, thats overlayed into the actual device structs */
|
||||
|
||||
/* The actual device instance structs have to place their node elements
|
||||
* right after the the end of struct GENinstance
|
||||
* where they will be accessed by generic GENnode()[]
|
||||
* A notable exception is the XSPICE MIF device
|
||||
*/
|
||||
};
|
||||
|
||||
static inline int *
|
||||
GENnode(struct GENinstance *inst) {
|
||||
return (int*)(inst + 1);
|
||||
}
|
||||
|
||||
|
||||
/* per model data */
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ NON-STANDARD FEATURES
|
||||
|
||||
|
||||
#include "ngspice/mifcmdat.h"
|
||||
#include "ngspice/gendefs.h"
|
||||
#include "ngspice/ifsim.h"
|
||||
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@ typedef struct sGENnumModel { /* model structure for a numerical device */
|
||||
|
||||
struct GENmodel gen;
|
||||
|
||||
#define GENmodType gen.GENmodType
|
||||
#define GENnextModel(inst) ((struct sGENnumModel *)((inst)->gen.GENnextModel))
|
||||
#define GENinstances(inst) ((GENinstance *)((inst)->gen.GENinstances))
|
||||
#define GENmodName gen.GENmodName
|
||||
|
||||
MESHcard *GENxMeshes; /* list of xmesh cards */
|
||||
MESHcard *GENyMeshes; /* list of ymesh cards */
|
||||
DOMNcard *GENdomains; /* list of domain cards */
|
||||
|
||||
Reference in New Issue
Block a user