From 5f716e4b61ba74b1d3109b31593da5fa76bfc27a Mon Sep 17 00:00:00 2001 From: pnenzi Date: Fri, 16 Jan 2009 14:31:07 +0000 Subject: [PATCH] Added new datatypes to vectors (impedance, admittance,atc.) A. Roldan - espice --- ChangeLog | 6 +++ src/frontend/evaluate.c | 86 ++++++++++++++++++++++++++++++++++++++++- src/frontend/typesdef.c | 15 ++++--- src/include/sim.h | 5 ++- 4 files changed, 104 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b72a783b0..2e9d7b249 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-01-16 Paolo Nenzi + * src/frontend/evaluate.c, src/frontend/typedefs.c, src/include/sim.h: + Added some vector types from Espice (impedance, admittance, power etc.) + The original implementation by A. Roldan did not fit immediatly. I had + to comment two definitions. I could not test "plotab". + 2009-01-15 Paolo Nenzi * src/spicelib/devices/vsrc/vsrc.c, * src/spicelib/devices/isrc/isrc.c, diff --git a/src/frontend/evaluate.c b/src/frontend/evaluate.c index a4d0bee53..b245e23a2 100644 --- a/src/frontend/evaluate.c +++ b/src/frontend/evaluate.c @@ -16,6 +16,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "evaluate.h" +#include "sim.h" /* To get SV_VOLTAGE definition */ /* static declarations */ static RETSIGTYPE sig_matherr(void); @@ -277,8 +278,89 @@ doop(char what, res->v_dims[i] = v2->v_dims[i]; } - /* This depends somewhat on what the operation is. XXX Should fix */ - res->v_type = v1->v_type; + /* This depends somewhat on what the operation is. XXX Should fix + * res->v_type = v1->v_type; + * Introduced to show the real units coming out from an + * operation. A.Roldán + */ + switch (what) + { + case '*': /* Multiplication of two vectors */ + switch(v1->v_type) + { + case SV_VOLTAGE: + switch(v2->v_type) + { + case SV_VOLTAGE: + res->v_type = SV_VOLTAGE; + break; + case SV_CURRENT: + res->v_type = SV_POWER; + break; + default: + break; + } + + break; + case SV_CURRENT: + + switch(v2->v_type) + { + case SV_VOLTAGE: + res->v_type = SV_POWER; + break; + case SV_CURRENT: + res->v_type = SV_CURRENT; + break; + default: + break; + } + break; + + default: + + break; + } + break; + case '/': //Multiplicación de 2 vectores + switch(v1->v_type) + { + case SV_VOLTAGE: + switch(v2->v_type) + { + case SV_VOLTAGE: + res->v_type = SV_NOTYPE; + break; + case SV_CURRENT: + res->v_type = SV_IMPEDANCE; + break; + default: + break; + } + break; + case SV_CURRENT: + + switch(v2->v_type) + { + case SV_VOLTAGE: + res->v_type = SV_ADMITANCE; + break; + case SV_CURRENT: + res->v_type = SV_NOTYPE; + break; + default: + break; + } + break; + + default: + + break; + } + + default: + break; + } vec_new(res); /* Free the temporary data areas we used, if we allocated any. */ diff --git a/src/frontend/typesdef.c b/src/frontend/typesdef.c index 5f7d586b4..563ba761d 100644 --- a/src/frontend/typesdef.c +++ b/src/frontend/typesdef.c @@ -14,7 +14,7 @@ Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group #include "typesdef.h" -#define NUMTYPES 128 /* If this is too little we can use a list. */ +#define NUMTYPES 128+4 /* If this is too little we can use a list. */ #define NUMPLOTTYPES 512 /* Since there may be more than 1 pat/type. */ struct type { @@ -40,14 +40,19 @@ struct type types[NUMTYPES] = { { "onoise-integrated", "V or A" } , { "inoise-spectrum", "(V or A)^2/Hz" } , { "inoise-integrated", "V or A" } , - { "output-noise", NULL } , - { "input-noise", NULL } , + /* { "output-noise", NULL } , */ + /* { "input-noise", NULL } , */ { "pole", NULL } , { "zero", NULL } , { "s-param", NULL } , { "temp-sweep", "Celsius" } ,/* Added by HT */ - { "res-sweep", "Ohm" } ,/* Added by HT */ + { "res-sweep", "Ohms" } ,/* Added by HT */ + { "impedance", "Ohms" } ,/* Added by A.Roldan */ + { "admittance", "Mhos" } ,/* Added by A.Roldan */ + { "power", "W" } , /* Added by A.Roldan */ + { "phase", "Degree" } , /* Added by A.Roldan */ + { "decibel", "dB" } , /* Added by A.Roldan */ } ; @@ -77,7 +82,7 @@ struct plotab plotabs[NUMPLOTTYPES] = { { "spect", "spect" }, } ; -int notypes = 15;/* change 14 to 15 by H.T*/ +int notypes = 15 ;/* change 14 to 15 by H.T*/ int noplotabs = 20;/* change 18 to 20 by H.T*/ /* A command to define types for vectors and plots. This will generally diff --git a/src/include/sim.h b/src/include/sim.h index 09379e294..ac5a6776c 100644 --- a/src/include/sim.h +++ b/src/include/sim.h @@ -15,7 +15,10 @@ enum simulation_types { SV_ZERO, SV_SPARAM, SV_TEMP, - SV_RES + SV_RES, + SV_IMPEDANCE, //Añadido por A.Roldán + SV_ADMITANCE, //Añadido por A.Roldán + SV_POWER //Añadido por A.Roldán }; #endif