Re: [ng-spice] Kernel


To ng-spice@ieee.ing.uniroma1.it
From Arno <A.W.Peters@ieee.org>
Date Fri, 22 Oct 1999 09:43:29 +0200
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
In-Reply-To <Pine.LNX.3.96.991021214757.16443A-100000@ieee.ing.uniroma1.it >; from pnenzi@ieee.ing.uniroma1.it on Thu, Oct 21, 1999 at 09:53:44PM +0200
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
References <19991020221055.A27868@cgmd95104.chello.nl > <Pine.LNX.3.96.991021214757.16443A-100000@ieee.ing.uniroma1.it >
Reply-To ng-spice@ieee.ing.uniroma1.it
User-Agent Mutt/1.0pre4i

On Thu, Oct 21, 1999 at 09:53:44PM +0200, Paolo Nenzi wrote:
> 
> 
> On Wed, 20 Oct 1999, Arno wrote:
> 
> > typedef double sample_t;
>           ^^^^^^
> Good, but how to take into account for complex data ???

Multiple independent variables.  See below.

> We may modify:
> 
> > enum si_units { SECOND, METER, KILOGRAM, AMPERE, SI_UNITS };
>   enum field { REAL, COMPLEX };

I suggest the following name (not objecting to the idea):

    enum data_t { REAL, COMPLEX };   /* Type of data */


> > char scalar_unit[SI_UNITS] = {0, 0, 0, 0};
> > char time_unit[SI_UNITS] = {1, 0, 0, 0};
> > char distance_unit[SI_UNITS] = {0, 1, 0, 0};
> > char mass_unit[SI_UNITS] = {0, 0, 1, 0};
> > char current_unit[SI_UNITS] = {0, 0, 1, 0};

    char frequency_unit[SI_UNITS] = {-1, 0, 0, 0};

> > 
> > struct sample {
> >     int size;                       /* length of the sample */
> >     char *units;            /* physical measurement units */
        enum data_t data_type;    /* type of data */
> >     sample_t *data;         /* has size SIZE */
> > };

Putting `enum data_t' there allows the compiler to do type checking.


> > struct measurement {
> >     int count;                      /* number of dependent variables */
        struct sample *indep;   /* independent variables (complex) */
> >     struct sample *data;    /* dependent variables */
>       ^^^^^^^^^^^^^^^^^^^^
> What about a linked list of samples ?

To make a linked list of sample, simply add `struct sample *next' to
the `struct sample'.  Both approaches can be abstracted behind a
general sample manipulation API.  Simulation code should not be able
to directly manipulate sample or measurement objects directly.

We should investigate both methods and see which is simpler to
implement, has lower memory consumption, etc, given the current
simulation models in spice.

> It is intereseting the SI_UNITS sticked to each sample, we can use int *
> so that we can use negative mumbers: think about a frequency, it's
> dimensions are sec^-1, and so on. With this system we can even perform
> constincency checks on mathematical ops.

Exactly my idea.  It has already been taken into account: char is a
signed datatype.  I don't expect dimensions of units to go higher than
128 or lower than -127 if sizeof(char) == 1.

-- 
Arno

Partial thread listing: