diff --git a/src/xspice/icm/poly/Makefile.am b/src/xspice/icm/poly/Makefile.am deleted file mode 100755 index 2490dc745..000000000 --- a/src/xspice/icm/poly/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -## Process this file with automake to produce Makefile.in -# -# JW 3/9/01 - had a go and makeing an autoconf script. - -noinst_LIBRARIES = libidnxsp.a - -libidnxsp_a_SOURCES = \ - ifspec.c \ - cfunc.c - -INCLUDES = -I$(top_srcdir)/src/include - -MAINTAINERCLEANFILES = Makefile.in - -ifspec.c: - cmpp -ifs -cfunc.c: - cmpp -mod cfunc.mod diff --git a/src/xspice/icm/poly/cfunc.c b/src/xspice/icm/poly/cfunc.c deleted file mode 100755 index c529d3851..000000000 --- a/src/xspice/icm/poly/cfunc.c +++ /dev/null @@ -1,307 +0,0 @@ -#line 1 "cfunc.mod" -#include "cm.h" -#line 1 "cfunc.mod" -/* =========================================================================== -FILE cfunc.mod - -MEMBER OF process XSPICE - -Copyright 1991 -Georgia Tech Research Corporation -Atlanta, Georgia 30332 -All Rights Reserved - -PROJECT A-8503 - -AUTHORS - - 9/12/91 Bill Kuhn - -MODIFICATIONS - - - -SUMMARY - - This file contains the definition of a code model polynomial controlled - source compatible with SPICE 2G6 poly sources. - -INTERFACES - - icm_poly() - -REFERENCED FILES - - None. - -NON-STANDARD FEATURES - - None. - -=========================================================================== */ - -/* - -This code model implements the non-linear polynomial controlled sources -available in SPICE 2G6. An automatic translator added into the simulator -front end is used to map 2G6 syntax into a call to this model in the -required syntax. - -This model may also be called directly as follows: - - a1 [ ] xxx - .model xxx poly ( coef = [ ] ) - -Refer to the 2G6 User Guide for an explanation of the coefficients. - - -This model is patterned after the FORTRAN code used in the 2G6 simulator. -Function cm_poly() below performs the functions of subroutines NLCSRC and -EVPOLY. Function evterm() performs the function of subroutine EVTERM, -and function nxtpwr() performs the function of subroutine NXTPWR. - -*/ - - - - -void *malloc(int); -void free(void *); - -/* SPICE 2G6 type utility functions */ -static double evterm(double x, int n); -static void nxtpwr(int *pwrseq, int pdim); - - - - -void icm_poly (Mif_Private_t *private) -{ - int num_inputs; /* Number of inputs to model */ - int num_coefs; /* Number of coefficients */ - int *exp; /* List of exponents in products */ - /* One for each input */ - - int i; /* Counter */ - int j; /* Counter */ - int k; /* Counter */ - - double *in; /* Values of inputs to model */ - double *coef; /* Values of coefficients */ - - double sum; /* Temporary for accumulating sum of terms */ - double product; /* Temporary for accumulating product */ - - double *acgains; /* Static variable holding AC gains for AC analysis */ - - /* debug statement */ - printf("In icm_poly!!! . . . .\n"); - - /* Get number of input values */ - - num_inputs = private->conn[0]->size; - - /* If this is the first call to the model, allocate the static variable */ - /* array */ - - if(private->circuit.init) { - acgains = malloc(num_inputs * sizeof(double)); - for(i = 0; i < num_inputs; i++) - acgains[i] = 0.0; - private->inst_var[0]->element[0].pvalue = acgains; - } - else - acgains = private->inst_var[0]->element[0].pvalue; - - /* If analysis type is AC, use the previously computed DC partials */ - /* for the AC gains */ - - if(private->circuit.anal_type == MIF_AC) { - for(i = 0; i < num_inputs; i++) { - acgains = private->inst_var[0]->element[0].pvalue; - private->conn[1]->port[0]->ac_gain[0].port[i].real = acgains[i]; - private->conn[1]->port[0]->ac_gain[0].port[i].imag = 0.0; - } - return; - } - - /* Get input values and coefficients to local storage for faster access */ - - in = malloc(num_inputs * sizeof(double)); - for(i = 0; i < num_inputs; i++) - in[i] = private->conn[0]->port[i]->input.rvalue; - - num_coefs = private->param[0]->size; - - coef = malloc(num_coefs * sizeof(double)); - for(i = 0; i < num_coefs; i++) - coef[i] = private->param[0]->element[i].rvalue; - - - /* Allocate the array of exponents used in computing the poly terms */ - exp = malloc(num_inputs * sizeof(int)); - - /* Initialize the exponents to zeros */ - for(i = 0; i < num_inputs; i++) - exp[i] = 0; - - - /* Compute the output of the source by summing the required products */ - for(i = 1, sum = coef[0]; i < num_coefs; i++) { - - /* Get the list of powers for the product terms in this term of the sum */ - nxtpwr(exp, num_inputs); - - /* Form the product of the inputs taken to the required powers */ - for(j = 0, product = 1.0; j < num_inputs; j++) - product *= evterm(in[j], exp[j]); - - /* Add the product times the appropriate coefficient into the sum */ - sum += coef[i] * product; - } - private->conn[1]->port[0]->output.rvalue = sum; - - - /* Compute and output the partials for each input */ - for(i = 0; i < num_inputs; i++) { - - /* Reinitialize the exponent list to zeros */ - for(j = 0; j < num_inputs; j++) - exp[j] = 0; - - /* Compute the partials by summing the required products */ - for(j = 1, sum = 0.0; j < num_coefs; j++) { - - /* Get the list of powers for the product terms in this term of the sum */ - nxtpwr(exp, num_inputs); - - /* If power for input for which partial is being evaluated */ - /* is zero, the term is a constant, so the partial is zero */ - if(exp[i] == 0) - continue; - - /* Form the product of the inputs taken to the required powers */ - for(k = 0, product = 1.0; k < num_inputs; k++) { - /* If input is not the one for which the partial is being taken */ - /* take the term to the specified exponent */ - if(k != i) - product *= evterm(in[k], exp[k]); - /* else, take the derivative of this term as n*x**(n-1) */ - else - product *= exp[k] * evterm(in[k], exp[k] - 1); - } - - /* Add the product times the appropriate coefficient into the sum */ - sum += coef[j] * product; - } - - private->conn[1]->port[0]->partial[0].port[i] = sum; - - /* If this is DC analysis, save the partial for use as AC gain */ - /* value in an AC analysis */ - - if(private->circuit.anal_type == MIF_DC) - acgains[i] = sum; - } - - /* Free the allocated items and return */ - free(in); - free(coef); - free(exp); - - return; -} - - -/* Function evterm computes the value of x**n */ - -static double evterm( - double x, - int n) -{ - double product; /* Temporary accumlator for forming the product */ - - product = 1.0; - while(n > 0) { - product *= x; - n--; - } - - return(product); -} - - - -/* - -This function is a literal translation of subroutine NXTPWR in SPICE 2G6. -This was done to guarantee compatibility with the ordering of -coefficients used by 2G6. The 2G6 User Guide does not completely define -the algorithm used and the GOTO loaded FORTRAN code is difficult to unravel. -Therefore, a one-to-one translation was deemed the safest approach. - -No attempt is made to document the function statements since no documentaton -is available in the 2G6 code. However, it can be noted that the code -appears to generate the exponents of the product terms in the sum-of-products -produced by the following expansion for two and three dimensional polynomials: - - 2D (a + b) ** n - 3D (a + (b + c)) ** n - -where n begins at 1 and increments as needed for as many terms as there are -coefficients on the polynomial source SPICE deck card, and where terms that -are identical under the laws of associativity are dropped. Thus, for example, -the exponents for the following sums are produced: - - 2D a + b + a**2 + ab + b**2 + c**3 + ... - 3D a + b + c + a**2 + a*b + a*c + b**2 + bc + c**2 + a**3 + ... - -*/ - -/* Define a macro to tranlate between FORTRAN-style array references */ -/* and C-style array references */ - -#define PWRSEQ(x) pwrseq[x - 1] - - -static void nxtpwr( - int *pwrseq, /* Array of exponents */ - int pdim) -{ - int i; - int k; - int km1; - int psum; - - if(pdim == 1) goto stmt80; - k = pdim; -stmt10: if(PWRSEQ(k) != 0) goto stmt20; - k = k - 1; - if(k != 0) goto stmt10; - goto stmt80; -stmt20: if(k == pdim) goto stmt30; - PWRSEQ(k) = PWRSEQ(k) - 1; - PWRSEQ(k+1) = PWRSEQ(k+1) + 1; - goto stmt100; -stmt30: km1 = k - 1; - for(i = 1; i <= km1; i++) - if(PWRSEQ(i) != 0) goto stmt50; -stmt40: PWRSEQ(1) = PWRSEQ(pdim) + 1; - PWRSEQ(pdim) = 0; - goto stmt100; -stmt50: psum = 1; - k = pdim; -stmt60: if(PWRSEQ(k-1) >= 1) goto stmt70; - psum = psum + PWRSEQ(k); - PWRSEQ(k) = 0; - k = k - 1; - goto stmt60; -stmt70: PWRSEQ(k) = PWRSEQ(k) + psum; - PWRSEQ(k-1) = PWRSEQ(k-1) - 1; - goto stmt100; -stmt80: PWRSEQ(1) = PWRSEQ(1) + 1; - -stmt100: return; - -} - diff --git a/src/xspice/icm/poly/cfunc.mod b/src/xspice/icm/poly/cfunc.mod deleted file mode 100755 index d7ec837ed..000000000 --- a/src/xspice/icm/poly/cfunc.mod +++ /dev/null @@ -1,302 +0,0 @@ -/* =========================================================================== -FILE cfunc.mod - -MEMBER OF process XSPICE - -Copyright 1991 -Georgia Tech Research Corporation -Atlanta, Georgia 30332 -All Rights Reserved - -PROJECT A-8503 - -AUTHORS - - 9/12/91 Bill Kuhn - -MODIFICATIONS - - - -SUMMARY - - This file contains the definition of a code model polynomial controlled - source compatible with SPICE 2G6 poly sources. - -INTERFACES - - icm_poly() - -REFERENCED FILES - - None. - -NON-STANDARD FEATURES - - None. - -=========================================================================== */ - -/* - -This code model implements the non-linear polynomial controlled sources -available in SPICE 2G6. An automatic translator added into the simulator -front end is used to map 2G6 syntax into a call to this model in the -required syntax. - -This model may also be called directly as follows: - - a1 [ ] xxx - .model xxx poly ( coef = [ ] ) - -Refer to the 2G6 User Guide for an explanation of the coefficients. - - -This model is patterned after the FORTRAN code used in the 2G6 simulator. -Function cm_poly() below performs the functions of subroutines NLCSRC and -EVPOLY. Function evterm() performs the function of subroutine EVTERM, -and function nxtpwr() performs the function of subroutine NXTPWR. - -*/ - - - - -void *malloc(int); -void free(void *); - -/* SPICE 2G6 type utility functions */ -static double evterm(double x, int n); -static void nxtpwr(int *pwrseq, int pdim); - - - - -void icm_poly (ARGS) -{ - int num_inputs; /* Number of inputs to model */ - int num_coefs; /* Number of coefficients */ - int *exp; /* List of exponents in products */ - /* One for each input */ - - int i; /* Counter */ - int j; /* Counter */ - int k; /* Counter */ - - double *in; /* Values of inputs to model */ - double *coef; /* Values of coefficients */ - - double sum; /* Temporary for accumulating sum of terms */ - double product; /* Temporary for accumulating product */ - - double *acgains; /* Static variable holding AC gains for AC analysis */ - - - /* Get number of input values */ - - num_inputs = PORT_SIZE(in); - - /* If this is the first call to the model, allocate the static variable */ - /* array */ - - if(INIT) { - acgains = malloc(num_inputs * sizeof(double)); - for(i = 0; i < num_inputs; i++) - acgains[i] = 0.0; - STATIC_VAR(acgains) = acgains; - } - else - acgains = STATIC_VAR(acgains); - - /* If analysis type is AC, use the previously computed DC partials */ - /* for the AC gains */ - - if(ANALYSIS == MIF_AC) { - for(i = 0; i < num_inputs; i++) { - acgains = STATIC_VAR(acgains); - AC_GAIN(out,in[i]).real = acgains[i]; - AC_GAIN(out,in[i]).imag = 0.0; - } - return; - } - - /* Get input values and coefficients to local storage for faster access */ - - in = malloc(num_inputs * sizeof(double)); - for(i = 0; i < num_inputs; i++) - in[i] = INPUT(in[i]); - - num_coefs = PARAM_SIZE(coef); - - coef = malloc(num_coefs * sizeof(double)); - for(i = 0; i < num_coefs; i++) - coef[i] = PARAM(coef[i]); - - - /* Allocate the array of exponents used in computing the poly terms */ - exp = malloc(num_inputs * sizeof(int)); - - /* Initialize the exponents to zeros */ - for(i = 0; i < num_inputs; i++) - exp[i] = 0; - - - /* Compute the output of the source by summing the required products */ - for(i = 1, sum = coef[0]; i < num_coefs; i++) { - - /* Get the list of powers for the product terms in this term of the sum */ - nxtpwr(exp, num_inputs); - - /* Form the product of the inputs taken to the required powers */ - for(j = 0, product = 1.0; j < num_inputs; j++) - product *= evterm(in[j], exp[j]); - - /* Add the product times the appropriate coefficient into the sum */ - sum += coef[i] * product; - } - OUTPUT(out) = sum; - - - /* Compute and output the partials for each input */ - for(i = 0; i < num_inputs; i++) { - - /* Reinitialize the exponent list to zeros */ - for(j = 0; j < num_inputs; j++) - exp[j] = 0; - - /* Compute the partials by summing the required products */ - for(j = 1, sum = 0.0; j < num_coefs; j++) { - - /* Get the list of powers for the product terms in this term of the sum */ - nxtpwr(exp, num_inputs); - - /* If power for input for which partial is being evaluated */ - /* is zero, the term is a constant, so the partial is zero */ - if(exp[i] == 0) - continue; - - /* Form the product of the inputs taken to the required powers */ - for(k = 0, product = 1.0; k < num_inputs; k++) { - /* If input is not the one for which the partial is being taken */ - /* take the term to the specified exponent */ - if(k != i) - product *= evterm(in[k], exp[k]); - /* else, take the derivative of this term as n*x**(n-1) */ - else - product *= exp[k] * evterm(in[k], exp[k] - 1); - } - - /* Add the product times the appropriate coefficient into the sum */ - sum += coef[j] * product; - } - - PARTIAL(out,in[i]) = sum; - - /* If this is DC analysis, save the partial for use as AC gain */ - /* value in an AC analysis */ - - if(ANALYSIS == MIF_DC) - acgains[i] = sum; - } - - /* Free the allocated items and return */ - free(in); - free(coef); - free(exp); - - return; -} - - -/* Function evterm computes the value of x**n */ - -static double evterm( - double x, - int n) -{ - double product; /* Temporary accumlator for forming the product */ - - product = 1.0; - while(n > 0) { - product *= x; - n--; - } - - return(product); -} - - - -/* - -This function is a literal translation of subroutine NXTPWR in SPICE 2G6. -This was done to guarantee compatibility with the ordering of -coefficients used by 2G6. The 2G6 User Guide does not completely define -the algorithm used and the GOTO loaded FORTRAN code is difficult to unravel. -Therefore, a one-to-one translation was deemed the safest approach. - -No attempt is made to document the function statements since no documentaton -is available in the 2G6 code. However, it can be noted that the code -appears to generate the exponents of the product terms in the sum-of-products -produced by the following expansion for two and three dimensional polynomials: - - 2D (a + b) ** n - 3D (a + (b + c)) ** n - -where n begins at 1 and increments as needed for as many terms as there are -coefficients on the polynomial source SPICE deck card, and where terms that -are identical under the laws of associativity are dropped. Thus, for example, -the exponents for the following sums are produced: - - 2D a + b + a**2 + ab + b**2 + c**3 + ... - 3D a + b + c + a**2 + a*b + a*c + b**2 + bc + c**2 + a**3 + ... - -*/ - -/* Define a macro to tranlate between FORTRAN-style array references */ -/* and C-style array references */ - -#define PWRSEQ(x) pwrseq[x - 1] - - -static void nxtpwr( - int *pwrseq, /* Array of exponents */ - int pdim) -{ - int i; - int k; - int km1; - int psum; - - if(pdim == 1) goto stmt80; - k = pdim; -stmt10: if(PWRSEQ(k) != 0) goto stmt20; - k = k - 1; - if(k != 0) goto stmt10; - goto stmt80; -stmt20: if(k == pdim) goto stmt30; - PWRSEQ(k) = PWRSEQ(k) - 1; - PWRSEQ(k+1) = PWRSEQ(k+1) + 1; - goto stmt100; -stmt30: km1 = k - 1; - for(i = 1; i <= km1; i++) - if(PWRSEQ(i) != 0) goto stmt50; -stmt40: PWRSEQ(1) = PWRSEQ(pdim) + 1; - PWRSEQ(pdim) = 0; - goto stmt100; -stmt50: psum = 1; - k = pdim; -stmt60: if(PWRSEQ(k-1) >= 1) goto stmt70; - psum = psum + PWRSEQ(k); - PWRSEQ(k) = 0; - k = k - 1; - goto stmt60; -stmt70: PWRSEQ(k) = PWRSEQ(k) + psum; - PWRSEQ(k-1) = PWRSEQ(k-1) - 1; - goto stmt100; -stmt80: PWRSEQ(1) = PWRSEQ(1) + 1; - -stmt100: return; - -} - diff --git a/src/xspice/icm/poly/ifspec.c b/src/xspice/icm/poly/ifspec.c deleted file mode 100755 index 707859a58..000000000 --- a/src/xspice/icm/poly/ifspec.c +++ /dev/null @@ -1,194 +0,0 @@ - -/* - * Structures for model: poly - * - * Automatically generated by cmpp preprocessor - * - * !!! DO NOT EDIT !!! - * - */ - - -// #include "prefix.h" -#include -#include "spice.h" -#include "devdefs.h" -#include "ifsim.h" -#include "mifdefs.h" -#include "mifproto.h" -#include "mifparse.h" -// #include "suffix.h" - - -static IFparm MIFmPTable[] = { - IOP("coef", 0, (IF_REAL|IF_VECTOR), "2g6 compatible spice card coefficient list"), -}; - - -static IFparm MIFpTable[] = { - OP("acgains", 1, IF_STRING, "partial derivatives from dc analysis used for ac gains"), -}; - - -static Mif_Port_Type_t MIFportEnum0[] = { - MIF_VOLTAGE, - MIF_DIFF_VOLTAGE, - MIF_CURRENT, - MIF_DIFF_CURRENT, - MIF_VSOURCE_CURRENT, -}; - - -static char *MIFportStr0[] = { - "v", - "vd", - "i", - "id", - "vnam", -}; - - -static Mif_Port_Type_t MIFportEnum1[] = { - MIF_VOLTAGE, - MIF_DIFF_VOLTAGE, - MIF_CURRENT, - MIF_DIFF_CURRENT, -}; - - -static char *MIFportStr1[] = { - "v", - "vd", - "i", - "id", -}; - - -static Mif_Conn_Info_t MIFconnTable[] = { - { - "in", - "input", - MIF_IN, - MIF_VOLTAGE, - "v", - 5, - MIFportEnum0, - MIFportStr0, - MIF_TRUE, - MIF_TRUE, - 1, - MIF_FALSE, - 0, - MIF_FALSE, - }, - { - "out", - "output", - MIF_OUT, - MIF_VOLTAGE, - "v", - 4, - MIFportEnum1, - MIFportStr1, - MIF_FALSE, - MIF_FALSE, - 0, - MIF_FALSE, - 0, - MIF_FALSE, - }, -}; - - -static Mif_Param_Info_t MIFparamTable[] = { - { - "coef", - "2g6 compatible spice card coefficient list", - MIF_REAL, - MIF_FALSE, - {MIF_FALSE, 0, 0.0, {0.0, 0.0}, NULL}, - MIF_FALSE, - {MIF_FALSE, 0, 0.0, {0.0, 0.0}, NULL}, - MIF_FALSE, - {MIF_FALSE, 0, 0.0, {0.0, 0.0}, NULL}, - MIF_TRUE, - MIF_FALSE, - 0, - MIF_TRUE, - 2, - MIF_FALSE, - 0, - MIF_FALSE, - }, -}; - - -static Mif_Inst_Var_Info_t MIFinst_varTable[] = { - { - "acgains", - "partial derivatives from dc analysis used for ac gains", - MIF_STRING, - MIF_FALSE, - }, -}; - - -extern void icm_poly(Mif_Private_t *); - -static int val_terms = 0; -static int val_numNames = 0; -static int val_numInstanceParms = 1; -static int val_numModelParms = 1; -static int val_sizeofMIFinstance = sizeof(MIFinstance); -static int val_sizeofMIFmodel = sizeof(MIFmodel); - -SPICEdev icm_poly_info = { - { "poly", - "2g6 compatible polynomial controlled source", - &val_terms, - &val_numNames, - NULL, - &val_numInstanceParms, - MIFpTable, - &val_numModelParms, - MIFmPTable, - icm_poly, - 2, - MIFconnTable, - 1, - MIFparamTable, - 1, - MIFinst_varTable, - }, -NULL, -MIFmParam, -MIFload, -MIFsetup, -MIFunsetup, -NULL, -NULL, -MIFtrunc, -NULL, -MIFload, -NULL, -MIFdestroy, -MIFmDelete, -MIFdelete, -NULL, -MIFask, -MIFmAsk, -NULL, -MIFconvTest, -NULL, -NULL, -NULL, -NULL, -NULL, -NULL, -NULL, -NULL, -&val_sizeofMIFinstance, -&val_sizeofMIFmodel, - -}; - diff --git a/src/xspice/icm/poly/ifspec.ifs b/src/xspice/icm/poly/ifspec.ifs deleted file mode 100755 index 39a2aaef8..000000000 --- a/src/xspice/icm/poly/ifspec.ifs +++ /dev/null @@ -1,75 +0,0 @@ -/* =========================================================================== -FILE ifspec.ifs - -MEMBER OF process XSPICE - -Copyright 1991 -Georgia Tech Research Corporation -Atlanta, Georgia 30332 -All Rights Reserved - -PROJECT A-8503 - -AUTHORS - - 9/12/91 Bill Kuhn - -MODIFICATIONS - - - -SUMMARY - - This file contains the definition of a code model polynomial controlled - source compatible with SPICE 2G6 poly sources. - -INTERFACES - - None. - -REFERENCED FILES - - None. - -NON-STANDARD FEATURES - - None. - -=========================================================================== */ - -NAME_TABLE: - -Spice_Model_Name: poly -C_Function_Name: icm_poly -Description: "2G6 compatible polynomial controlled source" - - -PORT_TABLE: - -Port_Name: in out -Description: "input" "output" -Direction: in out -Default_Type: v v -Allowed_Types: [v,vd,i,id,vnam] [v,vd,i,id] -Vector: yes no -Vector_Bounds: [1 -] - -Null_Allowed: no no - - -PARAMETER_TABLE: - -Parameter_Name: coef -Description: "2G6 compatible spice card coefficient list" -Data_Type: real -Default_Value: - -Limits: - -Vector: yes -Vector_Bounds: [2 -] -Null_Allowed: no - - -STATIC_VAR_TABLE: - -Static_Var_Name: acgains -Data_Type: pointer -Description: "Partial derivatives from DC analysis used for AC gains" diff --git a/src/xspice/icm/poly/make.bat b/src/xspice/icm/poly/make.bat deleted file mode 100755 index 19a341b81..000000000 --- a/src/xspice/icm/poly/make.bat +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cmpp -mod cfunc.mod -cmpp -ifs