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:
rlar
2018-02-17 11:53:06 +01:00
parent 2c9bfecbad
commit 8c7d7051ae
11 changed files with 33 additions and 26 deletions
+11 -2
View File
@@ -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 */
+1
View File
@@ -44,6 +44,7 @@ NON-STANDARD FEATURES
#include "ngspice/mifcmdat.h"
#include "ngspice/gendefs.h"
#include "ngspice/ifsim.h"
-5
View File
@@ -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 */