diff --git a/ANALYSES b/ANALYSES deleted file mode 100644 index 3abec19fd..000000000 --- a/ANALYSES +++ /dev/null @@ -1 +0,0 @@ -This file will contain a list of implemented analyses. diff --git a/man/man1/nutmeg.1 b/man/man1/nutmeg.1 deleted file mode 100644 index 3fe2e70ed..000000000 --- a/man/man1/nutmeg.1 +++ /dev/null @@ -1,1051 +0,0 @@ -.\" RCS Info: $Revision$ on $Date$ -.\" $Source$ -.\" Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -.TH NUTMEG 1 "27 April 1987" -.UC 4 -.SH NAME -nutmeg \- spice post-processor -.SH SYNOPSIS -\fBnutmeg [ - ] [ -n ] [ -t term ] [ datafile ... ]\fR -.SH DESCRIPTION -.B Nutmeg -is a post processor for \s-2SPICE\s+2 \- it takes the raw -output file created -by \fBspice -r\fR -and plots the data on a graphics terminal or a workstation display. -Note that the raw output file is different from the -data that \s-2SPICE\s+2 writes to the standard output. -.PP -Arguments are: -.TP -\fB-\fR -Don't try to load the default data file ("rawspice") if no other files -are given. -.TP -\fB-n\fR (or \fB-N\fR) -Don't try to source the file ".spiceinit" upon startup. Normally \fBnutmeg\fR -tries to find the file in the current directory, and if it is not found then -in the user's home directory. -.TP -\fB-t term\fR (or \fB-T term\fR) -The program is being run on a terminal with \fImfb\fR name \fBterm\fR. -.PP -Further arguments are taken to be data files in binary or ascii format -(see \fBsconvert\fR(1)) which are loaded into nutmeg. If the file -is in binary format, it may be only partially completed (useful for -examining \s-2SPICE\s+2 ouput before the simulation is finished). One -file may contain any number of data sets from different analyses. -.PP -\fBNutmeg\fR -data is in the form of vectors: time, voltage, etc. Each vector has -a type, and vectors can be operated on and combined algebraicly in -ways consistent with their types. Vectors are normally created when -a data file is read in (see the -.B load -command below), and when the initial datafile is loaded. They can -also be created with the -.B let -command. -.PP -An expression -is an algebraic -formula involving vectors and scalars (a scalar is a vector of -length 1), and the following operations: -.IP -+, -, *, %, /, ^, and ,. -.PP -% is the modulo operator, and the comma operator has two meanings: -if it is present in the argument list of a user-definable function, it -serves to seperate the arguments. Otherwise, the term \fBx , y\fR is -synonymous with \fBx + j(y)\fR. -.PP -Also available are the logical operations & (and), | (or), ! (not), -and the relational operations <, >, >=, <=, =, and <> (not equal). -If used in an algebraic expression they work like they would in C, -producing values of 0 or 1. The relational operators have the -following synonyms: -\fB"gt"\fR is >, -\fB"lt"\fR is <, -\fB"ge"\fR is >=, -\fB"le"\fR is <=, -\fB"ne"\fR is <>, -\fB"eq"\fR is =, -\fB"and"\fR is &, -\fB"or"\fR is |, -and -\fB"not"\fR is !. -These are useful when < and > might be confused with IO redirection -(which is almost always). -.PP -The following functions are available: -.IP -\fBmag(vector) \-\fR -The magnitude of vector. -.IP -\fBph(vector) \-\fR -The phase of vector. -.IP -\fBj(vector) \-\fR -\fIi\fR (sqrt(-1)) times vector. -.IP -\fBreal(vector) \-\fR -The real component of vector. -.IP -\fBimag(vector) \-\fR -The imaginary part of vector. -.IP -\fBdb(vector) \-\fR -20 * log10(mag(vector)). -.IP -\fBlog(vector) \-\fR -The logarithm (base 10) of the vector. -.IP -\fBln(vector) \-\fR -The natural logarithm (base e) of vector. -.IP -\fBexp(vector) \-\fR -e to the vector power. -.IP -\fBabs(vector) \-\fR -The absolute value of vector. -.IP -\fBsqrt(vector) \-\fR -The square root of vector. -.IP -\fBsin(vector) \-\fR -The sin of vector. -.IP -\fBcos(vector) \-\fR -The cosine of vector. -.IP -\fBtan(vector) \-\fR -The tangent of vector. -.IP -\fBatan(vector) \-\fR -The inverse tangent of vector. -.IP -\fBnorm(vector) \-\fR -The \fBvector\fR normalized to 1 (i.e, the largest magnitude of any component -will be 1). -.IP -\fBrnd(vector) \-\fR -A vector with each component a random integer between 0 and the absolute -value of the vectors's corresponding component. -.IP -\fBmean(vector) \-\fR -The result is a scalar (a length 1 vector) that is the mean of the elements -of \fBvector\fR. -.IP -\fBvector(number) \-\fR -The result is a vector of length \fBnumber\fR, with elements 0, 1, ... -\fBnumber - 1\fR. If \fBnumber\fR is a vector then just the first element -is taken, and if it isn't an integer then the floor of the magnitude is -used. -.IP -\fBlength(vector) \-\fR -The length of \fBvector\fR. -.IP -\fBinterpolate(plot.vector) \-\fR -The result of interpolating the named vector onto the scale of the current -plot. This function uses the variable \fBpolydegree\fR to determine -the degree of interpolation. -.PP -A vector may be either the name of a vector already defined, a floating- -point number (a scalar), or a list like \fB[elt1 elt2 ... eltn]\fR, which -is a vector of length n. -A number may be written in any format acceptable to \s-2SPICE\s+2, such -as \fB14.6MEG\fR or \fB-1.231E-4\fR. Note that you can either use -scientific notation or one of the abbreviations like \fIMEG\fR or \fIG\fR, -but not both. As with \s-2SPICE\s+2, a number may have trailing -alphabetic characters after it. -.PP -The notation \fBexpr [lower upper]\fR, where \fBlower\fR and \fBupper\fR -are numbers, denotes the range of elements from \fBexpr\fR between -\fBlower\fR and \fBupper\fR. The notation \fBexpr [num]\fR denotes -the \fBnum\fR'th element of \fBexpr\fR. If \fBupper\fR -is lower than \fBlower\fR, the order of the elements in the vector -is reversed. In all other cases, \fB[\fR and \fB]\fR serve to surround -literal vectors as described above. (You may have to use a lot of -parentheses to make sure that you get what you want. For instance, -you have to type \fBprint (foo) ([1 2])\fR to print the two vectors. -Otherwise it will be interpreted as a function call or a vector with an -index.) Note that the expression \fBfoo[10 20][5]\fR will \fInot\fR -yield the 15th element of \fBfoo\fR, but rather the 5th. In general only -the last index suffix on an expression will take effect. -.PP -To reference vectors in a plot that is not the -\fIcurrent plot\fR (see the \fBsetplot\fR command, below), the -notation \fBplotname.vecname\fR can be used. -.PP -Either a plotname or a vector name may be the wildcard \fBall\fR. If the -plotname is \fBall\fR, matching vectors from all plots are specified, and -if the vector name is \fBall\fR, all vectors in the specified plots are -referenced. Note that you may not use binary operations on expressions -involving wildcards \- it is not obvious what \fBall + all\fR should -denote, for instance. -.PP -Thus some (contrived) examples of expressions are: -.IP -\fBcos(TIME) + db(v(3))\fR -.IP -\fBsin(cos(log([1 2 3 4 5 6 7 8 9 10])))\fR -.IP -\fBTIME * rnd(v(9)) - 15 * cos(vin#branch) ^ [7.9e5 8]\fR -.IP -\fBnot ((ac3.FREQ[32] & tran1.TIME[10]) gt 3)\fR -.PP -.B Nutmeg -commands are as follows: -.TP -\fBplot exprs [ylimit ylo yhi] [xlimit xlo xhi] [xindices xilo xihi]\fR -.ce -\fB[xcompress comp] [xdelta xdel] [ydelta ydel] [xlog] [ylog] [vs xname]\fR -.ce -\fB[xlabel word] [ylabel word] [title word] [samep]\fR -Plot the given -.B exprs -on the screen (if you are on a graphics terminal). The -.B xlimit -and -.B ylimit -arguments determine the high and low x- and y-limits of the axes, -respectively. The -.B xindices -arguments determine what range of points are to be plotted \- everything -between the \fBxilo\fR'th point and the \fBxihi\fR'th point is plotted. -The -.B xcompress -argument specifies that only one out of every \fBcomp\fR points should -be plotted. If an \fBxdelta\fR or a \fBydelta\fR parameter is present, -it specifies the spacing between grid lines on the X- and Y-axis. -These parameter names may be abbreviated to -.B xl, -.B yl, -.B xind, -.B xcomp, -.B xdel, -and -.B ydel -respectively. -The -.B xname -argument is an expression to use as the scale on the x-axis. -If \fBxlog\fR or \fBylog\fR are present, the X or Y scale respectively -will be logarithmic. -The \fBxlabel\fR and \fBylabel\fR arguments cause the specified -labels to be used for the X and Y axes, respectively. -If \fBsamep\fR is given, the values of the other parameters (other than -\fBxname\fR) from the previous \fBplot, hardcopy,\fR or \fBasciiplot\fR -command will be used unless re-defined on the command line. -Finally, the \fBtitle\fR argument will be used in the place of the plot -name at the bottom of the graph. -.TP -\fBhardcopy file \fIplotargs\fR -Just like \fBplot\fR, except creates a file called -.B file -containing the plot. The file is an image in \fIplot(5)\fR format, -and can be printed by either the \fBplot(1)\fR program or \fBlpr\fR -with the \fB-g\fR flag. -.TP -\fBasciiplot \fIplotargs\fR -Produce a line printer plot of the vectors. -The plot is sent to the standard -output, so you can put it into a file with \fIasciiplot args ... > file\fR. -The \fBset\fR options \fBwidth, height,\fR and \fBnobreak\fR determine -the width and height of the plot, and whether there are page breaks, -respectively. Note that you will have problems if you try to \fBasciiplot\fR -something with an X-scale that isn't monotonic (i.e, something -like \fIsin(TIME)\fR ), because \fBasciiplot\fR uses a simple-minded sort -of linear interpolation. -.TP -\fBdefine function(arg1, arg2, ...) expression\fR -Define the \fIuser-definable function\fR with the name \fIfunction\fR -and arguments \fIarg1, arg2, ...\fR to be \fIexpression\fR, which -may involve the arguments. When the function is later used, the arguments -it is given are substituted for the formal arguments when it is parsed. -If \fIexpression\fR is not present, any definition for \fIfunction\fR -is printed, and if there are no arguments to \fIdefine\fR then all -currently active definitions are printed. Note that you may have different -functions defined with the same name but different arities. -Some useful definitions are: -.IP -define max(x,y) (x > y) * x + (x <= y) * y -.br -define min(x,y) (x < y) * x + (x >= y) * y -.TP -\fBundefine function ...\fR -Definitions for the named user-defined functions are deleted. -.TP -\fBlet name = expr\fR -Creates a new vector called -.B name -with the value specified by -.B expr, -an expression as described above. If \fBexpr\fR is [] (a zero-length vector) -then the vector becomes undefined. -If there are no arguments, \fBlet\fR is the same as \fBdisplay\fR. -.TP -\fBprint [col] [line] expr ... \fR -Prints the vector described by the expression -.B expr. -If the -.B col -argument is present, print the vectors named side by side. If \fBline\fR -is given, the vectors are printed horizontally. \fBcol\fR is the default, -unless all the vectors named have a length of one, in which case \fBline\fR -is the default. -The options -\fBwidth, length,\fR and \fBnobreak\fR are effective for this -command (see \fBasciiplot\fR). If the expression is \fBall\fR, -all of the vectors available are printed. Thus \fBprint col all > file\fR -will print everything in the file in \s-2SPICE\s+2\&2 format. -The scale vector (time, frequency) will always be in the first column -unless the variable \fBnoprintscale\fR is true. -.TP -\fBload [filename] ... \fR -Loads the raw data in either binary or ascii format -from the files named. The default filename is \fBrawspice\fR, or the argument -to the \fB-r\fR flag if there was one. -.TP -\fBsource filename\fR -Reads commands from the file -.B filename. -Lines beginning with the character \fB*\fR are considered comments and -ignored. -.TP -\fBhelp [all] [command ...]\fR -Prints help. If the argument \fBall\fR is given, a short description -of everything you could possibly type is printed. If \fBcommand\fRs are -given, descriptions of those commands are printed. Otherwise help for -only a few major commands is printed. -.TP -\fBdisplay [varname ...]\fR -Prints a summary of currently defined vectors, or of the names specified. -The vectors are sorted by name unless the variable \fBnosort\fR is set. -The information given is the name of the vector, the length, the -type of the vector, and whether it is real or complex data. Additionally, -one vector will be labeled \fB[scale]\fR. When a command such as -\fIplot\fR is given without a \fIvs\fR argument, this scale is used -for the X-axis. It is always the first vector in a rawfile, or -the first vector defined in a new plot. If you undefine the scale -(i.e, \fIlet TIME = []\fR), a random remaining -vector will become the scale. -.TP -\fBsetplot [plotname]\fR -Set the \fBcurrent plot\fR to the plot with the given -name, or if no name is given, prompt the user with a menu. -(Note that the plots are named as they are loaded, with names -like \fBtran1\fR or \fBop2\fR. These names are shown by the -\fBsetplot\fR and \fBdisplay\fR commands and are used by \fBdiff\fR, -below.) -If the -"New plot" item is selected, the current plot will become one with -no vectors defined. -Note that here the word "plot" refers -to a group of vectors that are the result of one \s-2SPICE\s+2 run. -When -more than one file is loaded in, or more than one plot is present -in one file, \fBnutmeg\fR keeps them seperate and only shows you the -vectors in the current plot. -.TP -\fBsettype type vector ...\fR -Change the type of the named vectors to \fBtype\fR. Type names can -be found in the manual page for \fBsconvert\fR. -.TP -\fBdiff plot1 plot2 [vec ...]\fR -Compare all the vectors in the specified \fIplots\fR, or only the named -vectors if any are given. There are different vectors in the two plots, -or any values in the vectors differ significantly the difference is -reported. The variables \fBabstol, reltol,\fR and \fBvntol\fR are used -to determine what "significantly" means (see the \s-2SPICE\s+2\&3 User's -Manual). -.TP -.B quit -Quit nutmeg. -.TP -.B bug -Send a bug report. (If you have defined BUGADDR, the mail will go there.) -.TP -\fBwrite [file] [exprs]\fR -Writes out the expr's to -.B file. -First vectors are grouped together by plots, and written out as such. -(I.e, if the expression list contained three vectors from one plot -and two from another, then two plots will be written, one with three -vectors and one with two.) Additionally, if the scale for a vector -isn't present, it is automatically written out as well. -The default format -is ascii, but this can be changed with the \fBset filetype\fR command. -The default filename is \fBrawspice\fR, or the argument to the \fB-r\fR -flag on the command line, if there was one, and the default expression -list is \fBall\fR. -.TP -\fBshell [args ...]\fR -Fork a shell, or execute the arguments as a command to the shell. -.TP -\fBalias [word] [text ...]\fR -Causes \fBword\fR to be aliased to \fBtext\fR. History substitutions may -be used, as in C-shell aliases. -.TP -\fBunalias [word ...]\fR -Removes any aliases present for the \fBword\fRs. -.TP -\fBhistory [number]\fR -Print out the history, or the last \fBnumber\fR commands typed at the keyboard. -\fINote:\fR in \*S version 3a7 and earlier, all commands (including ones read -from files) were saved. -.TP -\fBset [word] [word = value] ... \fR -Set the value of \fBword\fR to be \fBvalue\fR, if it is present. -You can set any word to be any value, numeric or string. If no value is -given then the value is the boolean 'true'. The value of \fIword\fR may -be inserted into a command by writing \fI$word\fR. -If a variable is set to a list of values that are enclosed in parentheses -(which -\fBmust\fR be seperated from their values by white space), the value -of the variable is the list. -The variables meaningful to \fBnutmeg\fR (of which there are too many) are: -.IP "" 16 -\fBabstol\fR -.br -The absolute tolerance used by the \fBdiff\fR command. -.IP -\fBappendwrite\fR -.br -Append to the file when a \fBwrite\fR command is issued, if one -already exists. -.IP -\fBcolor\fIN\fR -.br -These variables determine the colors used, if \fBX\fR is being run on -a color display. -\fIN\fR may be between 0 and 15. Color 0 is the background, color 1 -is the grid and text color, and colors 2 through 15 are used in order for -vectors plotted. The value of the \fBcolor\fR variables should be names -of colors, which may be found in the file \fB/usr/lib/rgb.txt\fR. -.IP -\fBcombplot\fR -.br -Plot vectors by drawing a vertical line from each point to the X-axis, -as opposed to joining the points. Note that this option is subsumed -in the \fIplottype\fR option, below. -.IP -\fBcpdebug\fR -.br -Print \fIcshpar\fR debugging information. (Must be complied with the --DCPDEBUG flag.) -.IP -\fBdebug\fR -.br -If set then a lot of debugging information is printed. (Must be -compiled with the -DFTEDEBUG flag.) -.IP -\fBdevice\fR -.br -The name (/dev/tty??) of the graphics device. If this variable -isn't set then the user's terminal is used. To do plotting on -another monitor you will probably have to set both the \fBdevice\fR -and \fBterm\fR variables. (If \fBdevice\fR is set to the name of -a file, \fBnutmeg\fR will dump the graphics control codes into -this file -- this is useful for saving plots.) -.\".IP -.\"\fBdontplot\fR -.\".br -.\"No graphics control codes are actually sent. (Useful for debugging on -.\"non-graphics terminals.) -.IP -\fBecho\fR -.br -Print out each command before it is executed. -.IP -\fBfiletype\fR -.br -This can be either -.B ascii -or -.B binary, -and determines what the format of -.I rawfiles -will be. The default is -.B ascii. -.IP -\fBfourgridsize\fR -.br -How many points to use for interpolating into when doing fourier analysis. -.\".IP -.\"\fBgeometry\fIN\fR -.\".br -.\"The size and positioning information for X windows. \fIN\fR may be -.\"any positive integer, in which case it is the information for the \fIN\fR'th -.\"window on the screen, or may be omitted, in which case it is used whenever -.\"there is no information for the window. The geometry information is a string -.\"of the form \fR=\fIheight\fBx\fIwidth\fB+\fIxoff\fB+\fIyoff\fR, where the -.\"window will be of size \fIheight\fR by \fIwidth\fR and be positioned at -.\"(\fIxoff, yoff\fR), where (0,0) is the upper left hand corner of the screen. -.\"Either the positioning information or the size information may be omitted, -.\"in which case the window will be opened interactively (as will happen if no -.\"\fBgeometry\fR information is given). The method of interactive sizing is -.\"the same as for other X utilities. -.\"A typical use for the \fBgeometry\fR variables might be to set \fBmaxwins\fR -.\"to 3 and set \fBgeometry1, geometry2,\fR and \fBgeometry3\fR to position three -.\"plot windows in a row across the top of the screen. -.IP -\fBgridsize\fR -.br -If this variable is set to an integer, this number will be used as the number -of equally spaced points to use for the Y-axis when plotting. Otherwise -the current scale will be used (which may not have equally spaced points). -If the current scale isn't strictly monotonic, then this option will have -no effect. -.IP -\fBhcopydev\fR -.br -If this is set, when the \fBhardcopy\fR command is run the resulting file -is automatically printed on the printer named \fBhcopydev\fR with the -command \fIlpr -P\fBhcopydev\fI -g \fBfile\fR. -.IP -\fBhcopydevtype\fR -.br -This variable specifies the type of the printer output to use in the -\fBhardcopy\fR command. If hcopydevtype is not set, plot (5) format -is assumed. The standard distribution currently recognizes \fBpostscript\fR -as an alternative output format. When used in conjunction with -\fBhcopydev\fR, \fBhcopydevtype\fR should specify a format supported by -the printer. -.IP -\fBheight\fR -.br -The length of the page for \fBasciiplot\fR and \fBprint col\fR. -.IP -\fBhistory\fR -.br -The number of events to save in the history list. -.\".IP -.\"\fBmaxwins\fR -.\".br -.\"The maximum number of windows X should have on the screen at one time. -.\"If it has \fBmaxwins\fR or more windows, it will begin re-using them -.\"for plots in an oldest-first manner. -.IP -\fBnfreqs\fR -.br -The number of frequencies to compute in the -.B fourier -command. (Defaults to 10.) -.IP -\fBnobreak\fR -.br -Don't have \fBasciiplot\fR and \fBprint col\fR break between pages. -.IP -\fBnoasciiplotvalue\fR -.br -Don't print the first vector plotted to the left when doing an -\fBasciiplot\fR. -.IP -\fBnoclobber\fR -.br -Don't overwrite existing files when doing IO redirection. -.IP -\fBnoglob\fR -.br -Don't expand the global characters `*', `?', `[', and `]'. This is the -default. -.IP -\fBnogrid\fR -.br -Don't plot a grid when graphing curves (but do label the axes). -.IP -\fBnomoremode\fR -.br -If \fBnomoremode\fR is not set, whenever a large amount of data is being -printed to the screen (e.g, the \fBprint\fR or \fBasciiplot\fR commands), -the output will be stopped every screenful and will continue when -a carriage return is typed. If \fBnomoremode\fR is set then data will scroll -off the screen without hesitation. -.IP -\fBnonomatch\fR -.br -If \fBnoglob\fR is unset and a global expression cannot be matched, use -the global characters literally instead of complaining. -.IP -\fBnosort\fR -.br -Don't have \fBdisplay\fR sort the variable names. -.IP -\fBnoprintscale\fR -.br -Don't print the scale in the leftmost column when a \fBprint col\fR command -is given. -.IP -\fBnumdgt\fR -.br -The number of digits to print when printing tables of data (\fBfourier, print -col\fR). The default precision is 6 digits. On the VAX, approximately -16 decimal digits are available using double precision, so \fBnumdgt\fR -should not be more than 16. If the number is negative, one fewer digit -is printed to ensure constant widths in tables. -.IP -\fBplottype\fR -.br -This should be one of \fInormal\fR, \fIcomb\fR, or \fIpoint:\fBchars\fR. -\fInormal\fR, the default, causes points to be plotted as parts of connected -lines. \fIcomb\fR causes a comb plot to be done (see the description of the -\fIcombplot\fR variable above). \fIpoint\fR causes each point to be plotted -seperately \- the \fBchars\fR are a list of characters that will be used -for each vector plotted. If they are omitted then a default set is used. -.IP -\fBpolydegree\fR -.br -The degree of the polynomial that the \fBplot\fR command should fit -to the data. If \fIpolydegree\fR is N, then \fBnutmeg\fR will fit a degree N -polynomial to every set of N points and draw 10 intermediate points -in between each endpoint. If the points aren't monotonic, then it will try -rotating the curve and reducing the degree until a fit is achieved. -.IP -\fBpolysteps\fR -.br -The number of points to interpolate between every pair of points available -when doing curve fitting. The default is 10. (This should really be done -automatically.) -.IP -\fBprogram\fR -.br -The name of the current program (\fIargv[0]\fR). -.IP -\fBprompt\fR -.br -The prompt, with the character `!' replaced by the current event number. -.IP -\fBrawfile\fR -.br -The default name for rawfiles created. -.IP -\fBreltol\fR -.br -The relative tolerance used by the \fBdiff\fR command. -.IP -\fBrhost\fR -.br -The machine to use for remote \s-2SPICE-3\s+2 runs, instead of the -default one. (See the description of the \fBrspice\fR command, -below.) -.IP -\fBrprogram\fR -.br -The name of the remote program to use in the \fBrspice\fR command. -.\".IP -.\"\fBsavewins\fR -.\".br -.\"If true, then don't get rid of the plot window after the plot is done (X -.\"only). The window may be removed by clicking any mouse button inside of it. -.IP -\fBslowplot\fR -.br -Stop between each graph plotted and wait for the user to type -return before continuing. -.IP -\fBsourcepath\fR -.br -A list of the directories to search when a \fBsource\fR command is given. -The default is the current directory and the standard spice library -(\fI/usr/local/lib/spice\fR, or whatever \fBLIBPATH\fR is #defined to -in the \*S source. -.IP -\fBspicepath\fR -.br -The program to use for the \fBaspice\fR command. The default is -/cad/bin/spice. -.IP -\fBterm\fR -.br -The \fImfb\fR name of the current terminal. -.IP -\fBunits\fR -.br -If this is \fBdegrees\fR, then all the trig functions will use degrees -instead of radians. -.IP -\fBunixcom\fR -.br -If a command isn't defined, try to execute it as a \s-2UNIX\s+2 command. -Setting this option has the effect of giving a \fBrehash\fR command, -below. -This is useful for people who want to use \fBnutmeg\fR as a login shell. -.IP -\fBverbose\fR -.br -Be verbose. This is midway between \fBecho\fR and \fBdebug\fR / \fBcpdebug\fR. -.IP -\fBvntol\fR -.br -The absolute voltage tolerance used by the \fBdiff\fR command. -.IP -\fBwidth\fR -.br -The width of the page for \fBasciiplot\fR and \fBprint col\fR. -.IP -\fBxbrushheight\fR -.br -The height of the brush to use if \fBX\fR is being run. -.IP -\fBxbrushwidth\fR -.br -The width of the brush to use if \fBX\fR is being run. -.IP -\fBxfont\fR -.br -The name of the X font to use when plotting data and entering labels. -The plot may not look entirely great if this is a variable-width font. -.PP -.TP -\fBunset [word] ... \fR -Unset the variables \fBword\fR. -.TP -\fBshift [varname] [number]\fR -If \fIvarname\fR is the name of a list variable, it is shifted to the left -by \fInumber\fR elements. (I.e, the \fInumber\fR leftmost elements are -removed.) The default \fIvarname\fR is \fBargv\fR, and the default -\fInumber\fR is 1. -.TP -\fBrusage [resource ...]\fR -Print resource usage statistics. If any \fBresource\fR\&s are given, -just print the usage of that resource. Currently valid \fBresource\fR\&s -are: -.IP "" 16 -\fBelapsed\fR -.br -The amount of time elapsed since the last \fBrusage elaped\fR call. -.IP -\fBfaults\fR -.br -Number of page faults and context switches (BSD only). -.IP -\fBspace\fR -.br -Data space used. -.IP -\fBtime\fR -.br -CPU time used so far. -.IP -\fBeverything\fR -.br -All of the above. -.TP -\fBcd [directory]\fR -Change the current working directory to \fBdirectory\fR, or to the user's -home directory if none is given. -.TP -\fBaspice [output-file]\fR -Start a \s-2SPICE-3\s+2 run, and when it is finished load the data. The -raw data is kept in a temporary file. If \fIoutput-file\fR is specified -then the diagnostic output is directed into that file, otherwise it -is thrown away. -.TP -\fBjobs\fR -Report on the asynchronous \s-2SPICE-3\s+2 jobs currently running. -\fBNutmeg\fR checks to see if the jobs are finished every time you -execute a command. -If it is done then the data is loaded and becomes available. -.TP -\fBrspice [input file]\fR -Runs a \s-2SPICE-3\s+2 remotely taking the \fBinput file\fR as a -\s-2SPICE-3\s+2 input deck, or the current circuit if no argument is -given. \fBNutmeg\fR waits for the job to complete, and passes output -from the remote job to the user's standard output. When the job is -finished the data is loaded in as with \fRaspice\fR. If the variable -\fIrhost\fR is set, \fBnutmeg\fR will connect to this host instead of -the default remote \s-2SPICE-3\s+2 server machine. Note that this -command will only work if your system administrator is running a -\s-2SPICE-3\s+2 daemon on the remote host. If the variable \fIrprogram\fR -is set, then \fBrspice\fR will use this as the pathname to the program -to run. -.TP -\fBecho [stuff...]\fR -Echos the arguments. -.TP -\fBfourier fundamental_frequency [value ...]\fR -Does a fourier analysis of each of the given values, using the first 10 -multiples of the fundamental frequency (or the first \fInfreqs\fR, if that -variable is set \- see below). The output is like that of -the \fB.four\fR \*S card. The values may be any valid expression. -The values are interpolated onto a fixed-space grid with the number of -points given by the \fBfourgridsize\fR variable, or 200 if it is not set. -The interpolation will be of degree \fBpolydegree\fR if that variable is -set, or 1. If \fBpolydegree\fR is 0, then no interpolation will be done. -This is likely to give erroneous results if the time scale is not monotonic, -though. -.TP -\fBversion [version id]\fR -Print out the version of \fBnutmeg\fR that is running. -If there are arguments, it checks to make sure that the arguments match -the current version of \s-2SPICE\s+2. (This is mainly used as a \fBCommand:\fR -line in rawfiles.) -.TP -\fBrehash\fR -Recalculate the internal hash tables used when looking up UNIX commands, -and make all UNIX commands in the user's PATH available for command -completion. -This is useless unless you have \fBset unixcom\fR first (see above). -.PP -The following control structures are available: -.IP -.nf -\fBwhile\fR \fIcondition\fR - statement - ... -\fBend\fR -.fi -.PP -While \fIcondition\fR, an arbitrary algebraic expression, is true, -execute the statements. -.IP -.nf -\fBrepeat\fR \fI[number]\fR - statement - ... -\fBend\fR -.fi -.PP -Execute the statements \fInumber\fR times, or forever if no argument is -given. -.IP -.nf -\fBdowhile\fR \fIcondition\fR - statement - ... -\fBend\fR -.fi -.PP -The same as \fBwhile\fR, except that the \fIcondition\fR is tested after -the statements are executed. -.IP -.nf -\fBforeach\fR \fIvar\fR \fIvalue ...\fR - statement - ... -\fBend\fR -.fi -.PP -The statements are executed once for each of the \fIvalue\fRs, each time -with the variable \fIvar\fR set to the current one. (\fIvar\fR can be accessed -by the $\fIvar\fR notation \- see below). -.IP -.nf -\fBif\fR \fIcondition\fR - statement - ... -\fBelse\fR - statement - ... -\fBend\fR -.fi -.PP -If the \fIcondition\fR is non-zero then the first set of statements are -executed, otherwise the second set. The \fBelse\fR and the second set -of statements may be omitted. -.IP -\fBlabel\fR \fIword\fR -.PP -If a statement of the form \fBgoto\fI word\fR is encountered, control is -transfered to this point, otherwise this is a no-op. -.IP -\fBgoto\fR \fIword\fR -.PP -If a statement of the form \fBlabel\fI word\fR is present in the block -or an enclosing block, control is transfered there. Note that if the -label is at the top level, it \fImust\fR be before the \fBgoto\fR statement -(i.e, a forward \fBgoto\fR may occur only within a block). -.IP -\fBcontinue\fR -.PP -If there is a \fBwhile, dowhile,\fR or \fBforeach\fR block enclosing this -statement, control passes to the test, or in the case of \fBforeach\fR, -the next value is taken. -Otherwise an -error results. -.IP -\fBbreak\fR -.PP -If there is a \fBwhile, dowhile,\fR or \fBforeach\fR block enclosing this -statement, control passes out of the block. Otherwise an -error results. -.PP -Of course, control structures may be nested. When a block is entered -and the input is the terminal, the prompt becomes a number of >'s -equalling the number of blocks the user has entered. The current control -structures may be examined with the debugging command -.B cdump. -.PP -If a word is typed as a command, and there is no built-in command -with that name, the directories in the \fIsourcepath\fR list are searched -in order for the file. If it is found, it is read in as a command file (as -if it were \fBsource\fRd). Before it is read, however, the variables -\fIargc\fR and \fIargv\fR are set to the number of words following the -filename on the command line, and a list of those words respectively. -After the file is finished, these variables are \fBunset\fR. Note that -if a command file calls another, it must save its \fIargv\fR and \fIargc\fR -since they will get altered. Also, command files may not be re-entrant -since there are no local variables. (Of course, the procedures may -explicitly manipulate a stack...) -This way one can write scripts analogous to shell scripts for \fBnutmeg\fR and -\*S. Note that for the script to work with \*S, it \fBmust\fR begin -with a blank line (or whatever you like, since it will be thrown away) -and then a line with \fB.control\fR on it. This is an unfortunate result -of the \fBsource\fR command being used for both circuit input and command -file execution. Note also that this allows the user to merely type the -name of a circuit file as a command, and it will be automatically run. -.PP -There are various command scripts installed in -\fI/usr/local/lib/spice/scripts\fR (or whatever the path is on your machine), -and the default \fIsourcepath\fR includes this directory, so you can use -these command files (almost) like builtin commands. -.PP -\fBNutmeg\fR will use either \fBX\fR or \fBMFB\fR, depending on whether -it finds the variable \fBDISPLAY\fR in the environment. If you are -using \fBX\fR on a workstation, it should already be present, but if you -want to display graphics on a different machine than the one you -are running \fBnutmeg\fR on, \fBDISPLAY\fR should be of the form -\fImachine\fR:0. -.PP -If \fBX\fR is being used, the cursor may be positioned at any -point on the screen when the window is up and characters typed at the -keyboard will be added to the window at that point. The window may -then be sent to a printer using the \fBxpr(1)\fR program. -.PP -There are a number of pre-defined constants in \fBnutmeg\fR. They are: -.na -.nf - pi pi - e The base of natural logarithms - c The speed of light - i The square root of -1 - kelvin Absolute 0 in Centigrade - echarge The charge on an electron - boltz Boltzman's constant - planck Planck's constant (h) - -.fi -.ad -.PP -These are all in MKS units. If you have another variable with -a name that conflicts with one of these then it takes precedence. -.PP -Nutmeg occasionally checks to see if it -is getting close to running out of space, and warns the user if this -is the case. (This is more likely to be useful with the \s-2SPICE\s+2 -front end.) -.PP -C-shell type quoting with "" and '', and backquote substitution may -be used. Within single quotes, no further substitution (like -history substitution) is done, and within double quotes, the words -are kept together but further substitution is done. Any text between -backquotes is replaced by the result of executing the text as a command -to the shell. -.PP -Tenex-style ('set filec' in the 4.3 C-shell) -command, filename, and keyword completion is possible: If EOF -(control-D) is typed after the first character on the line, a list -of the commands or possible arguments is printed. (If it is alone -on the line it will exit \fBnutmeg\fR.) If escape is typed, then -\fBnutmeg\fR will try to complete what the user has already typed. -To get a list of all commands, the user should type ^D. -.PP -The values of variables may be used in commands by writing \fB$varname\fR -where the value of the variable is to appear. The special variables -\fI$$\fR and \fI$<\fR refer to the process ID of the program and a -line of input which is read from the terminal when the variable -is evaluated, respectively. If a variable has a name of the form -\fB$&word\fR, then \fBword\fR is considered a vector (see above), -and its value is taken to be the value of the variable. -If \fI$foo\fR is a valid variable, and is of type \fBlist\fR, then the -expression \fI$foo[low-high]\fR represents a range of elements. Either -the upper index or the lower may be left out, and the reverse of a list may -be obtained with \fI$foo[len-0]\fR. Also, the notation \fI$?foo\fR evaluates -to 1 if the variable \fIfoo\fR is defined, 0 otherwise, and \fI$#foo\fR -evaluates to the number of elements in \fIfoo\fR if it is a list, 1 if it -is a number or string, and 0 if it is a boolean variable. -.PP -History substitutions, similar to C-shell history substitutions, are -also available \- see the C-shell manual page for all of the details. -.PP -The characters ~, {, and } have the same effects as they do in the -C-Shell, i.e., home directory and alternative expansion. It is -possible to use the wildcard characters *, ?, [, and ] also, -but only if you \fBunset noglob\fR first. This makes them rather -useless for typing algebraic expressions, so you should \fBset noglob\fR -again after you are done with wildcard expansion. Note that the -pattern \fB[^abc]\fR will match all characters \fIexcept\fB a, b, -\fRand\fB c.\fR -.PP -IO redirection is available \- the symbols \fB>, >>, >&, >>&, \fRand\fB <\fR -have the same effects as in the C-shell. -.PP -You may type multiple commands on one line, seperated by semicolons. -.PP -If you want to use a different \fBmfbcap\fR file than the default (usually -\fB~cad/lib/mfbcap\fR), you have to set the environment variable \fBMFBCAP\fR -before you start \fBnutmeg\fR. The \fB-m\fR option and the \fBmfbcap\fR -variable no longer work. -.SH "VMS NOTES" -\fBNutmeg\fR can be run under VAX/VMS. Some features like command, etc -completion, expansion of *, ?, and [], backquote substitution, the -shell command, and so forth do not work. (In fact command completion -only works on 4.2 or 4.3 BSD.) -.PP -\fBNutmeg\fR will look for start-up -commands in the file \fIspice.rc\fR in the current directory. -.PP -The standard suffix for rawspice files in VMS is ".raw". -.PP -You will have to respond to the \fI-more-\fR prompt during plot with a -carriage return instead of any key as you can do on UNIX. -.SH "SEE ALSO" -sconvert(1), spice(1), mfb(3), writedata(3) -.SH AUTHOR -Wayne Christopher (faustus@cad.berkeley.edu) -.SH BUGS -.PP -The label entry facilities are very primitive \- after all, \fBnutmeg\fR isn't -a graphics editor (yet). You must be careful to type very slowly when -entering labels -- \fBnutmeg\fR checks the \fBX\fR event queue once -every second, and can get very confused if characters arrive faster than -that. -.PP -If you redefine colors after creating a plot window with X, and then -cause the window to be redrawn, it will not to the right thing. -.PP -When defining aliases like -.IP -\fIalias pdb plot db( '!:1' - '!:2' )\fR -.PP -you must be careful to quote the argument list substitutions in this -manner. If you quote the whole argument it might not work properly. -.PP -In a user-defined function, the arguments cannot be part of a name that -uses the \fIplot.vec\fR syntax. I.e, -.IP -\fIdefine poke(duck) cos(tran1.duck) -.PP -won't do the right thing. -.PP -If you type \fBplot all all\fR, or otherwise use a wildcard reference for -one plot twice in a command, bad things will happen. -.PP -The \fBasciiplot\fR command doesn't deal with log scales or the \fBdelta\fR -keywords. -.PP -There are probably some features that \fBnutmeg\fR doesn't have yet. -.SH CAVEATS -Often the names of terminals recognised by \fBMFB\fR are different -from those in /etc/termcap. Thus you may have to reset your terminal -type with the command -.IP -\fBset term = termname\fR -.PP -where \fBtermname\fR is the name in the \fBmfbcap\fR file. -.PP -The \fBhardcopy\fR command is useless on VMS and other systems without -the \fBplot\fR command, unless the user has a program that understands -\fIplot(5)\fR format. - diff --git a/man/man1/sconvert.1 b/man/man1/sconvert.1 deleted file mode 100644 index 6fcbc3a4f..000000000 --- a/man/man1/sconvert.1 +++ /dev/null @@ -1,127 +0,0 @@ -.\" RCS Info: $Revision$ on $Date$ -.\" $Source$ -.\" Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -.TH SCONVERT 1 "20 March 1986" -.UC 4 -.SH NAME -sconvert \- convert spice formats -.SH SYNOPSIS -.B sconvert fromtype fromfile totype tofile -.br -.B sconvert fromtype totype -.br -.B sconvert -.br -.SH DESCRIPTION -.B Sconvert -translates spice output files among three formats: the old -binary format, a new binary format, and a new ascii format. -The formats are specified by the -.B fromtype -and -.B totype -arguments: `o' for the old format, `b' for the new binary format, -and `a' for the new ascii format. -.B Fromtype -specifies the format to be read, and -.B totype -specifies the format to be written. -If -.B fromfile -and -.B tofile -are given, then they are used as the input and output, otherwise -standard input and output are used. (Note that this second option is -only available on \s-2UNIX\s+2 systems \- on VMS and other systems you must -supply the filenames.) -If no arguments are given, the parameters are prompted for. -.PP -Binary format is the preferred format for general use, as it is -the most economical in terms of space and speed of access, and ascii is -provided to make it easy to modify data files and transfer them -between machines with different floating-point formats. -The old format is provided only -for backward compatibility. The three formats are as follows: -.br -.nf - -.B Old: - - What Size in Bytes - - title 80 - date 8 - time 8 - numoutputs 2 - the integer 4 2 - variable names -- - char[numoutputs][8] numoutputs * 8 - types of output numoutputs * 2 - node index numoutputs * 2 - plot title numoutputs * 24 - the actual data numpoints * numoutputs * 8 - -.B Ascii: - - Title: \fITitle Card String\fR - Date: \fIDate\fR - [ Plotname: \fIPlot Name\fR - Flags: \fIcomplex\fR or \fIreal\fR - No. Variables: \fInumoutputs\fR - No. Points: \fInumpoints\fR - Command: \fInutmeg command\fR - Variables: 0 \fIvarname1\fR \fItypename1\fR - 1 \fIvarname2\fR \fItypename2\fR - etc... - Values: - 0 n n n n ... - 1 n n n n ... - And so forth... - ] repeated one or more times - -.PP -If one of the flags is \fIcomplex\fR, the points look like r,i where r and i -are floating point (in %e format). Otherwise they are in %e format. -Only one of \fIreal\fR and \fIcomplex\fR should appear. -.PP -The lines are guaranteed to be less than 80 columns wide (unless the -plot title or variable names are very long), so this format is safe -to mail between systems like CMS. -.PP -Any number of \fBCommand:\fR lines may appear between the \fBNo. Points:\fR -and the \fBVariables:\fR lines, and whenever the plot is loaded into -\fBnutmeg\fR they will be executed. -.nf - -.B Binary: - - \fITitle Card\fR (a NULL terminated string) - \fIDate, Time\fR (a NULL terminated string) - [ - \fIPlot title\fR (a NULL terminated string) - \fINumber of variables\fR (an int) - \fINumber of data points\fR (an int) - \fIflags\fR (a short) - \fIvariable header struct\fR (repeated numoutputs times) - \fIvariable name\fR (a NULL terminated string) - \fIvariable type\fR (an int) - \fIset of outputs\fR (repeated numpoints times) - ] repeated one or more times. - -.PP -A set of outputs is a vector of doubles of length numoutputs, or -a vector of real-imaginary pairs of doubles if the data is complex. -.SH "SEE ALSO" -nutmeg(1), spice(1), writedata(3) -.SH AUTHOR -Wayne Christopher (faustus@cad.berkeley.edu) -.SH BUGS -If variable names and the title -and plotname strings have trailing -blanks in them they will be stripped off when the file is read, if -it is in ascii format. -.PP -If a plot title begins with "Title:" \fBnutmeg\fR will be fooled into thinking -that this is an ascii format file. \fBSconvert\fR always requires the -type to be specified, however. - diff --git a/man/man1/spice.1 b/man/man1/spice.1 deleted file mode 100644 index 1a70aac5b..000000000 --- a/man/man1/spice.1 +++ /dev/null @@ -1,325 +0,0 @@ -.\" RCS Info: $Revision$ on $Date$ -.\" $Source$ -.\" Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -.TH SPICE 1 "20 March 1986" -.ds S \s-2SPICE\s+2\&3 -.UC 4 -.SH NAME -spice \- circuit simulator -.SH SYNOPSIS -\fBspice [ -n ] [ -t term ] [ -r rawfile] [ -b ] -[ -i ] [ input file ... ]\fR -.SH DESCRIPTION -This manual page describes the commands available for interactive -use of \*S. For details of circuit descriptions and the -process of simulating a circuit, see the \*S User's Manual. -The commands available are a superset of those available for -\fBnutmeg\fR \- only the additional commands available in \*S -are described here. You should be familiar with the manual page for -\fBnutmeg(1)\fR before reading this manual page. -.PP -Arguments are: -.TP -\fB-n\fR (or \fB-N\fR) -Don't try to source the file ".spiceinit" upon startup. Normally \*S -tries to find the file in the current directory, and if it is not found then -in the user's home directory. -.TP -\fB-t term\fR (or \fB-T term\fR) -The program is being run on a terminal with \fImfb\fR name \fBterm\fR. -.TP -\fB-b\fR (or \fB-B\fR) -Run in batch mode. \*S will read the standard input or the specified -input file and do the simulation. Note that if the standard input -is not a terminal, \*S will default to batch mode, unless the --i flag is given. -.TP -\fB-s\fR (or \fB-S\fR) -Run in server mode. This is like batch mode, except that a temporary -rawfile is used and then written to the standard output, preceded by -a line with a single "@", after the simulation is done. This mode -is used by the spice daemon. -.TP -\fB-i\fR (or \fB-I\fR) -Run in interactive mode. This is useful if the standard input is -not a terminal but interactive mode is desired. Command completion is -not available unless the standard input is a terminal, however. -.TP -\fB-r rawfile\fR (or \fB-R rawfile\fR) -Use \fBrawfile\fR as the default file into which the results of -the simulation are saved. -.PP -Further arguments are taken to be \*S input decks, which are read -and saved. (If batch mode is requested then they are run immediately.) -.PP -\*S will accept any \s-2SPICE\s+2\&2 input decks, and output -ascii plots, fourier analyses, and node printouts as specified -in .plot, .four, and .print cards. If a \fBout\fR parameter -is given on a .width card, the effect is the same as \fBset width = ...\fR. -Since \*S ascii plots do not use multiple ranges, however, if vectors -together on a .plot card have different ranges they will not provide -as much information as they would in \s-2SPICE\s+2\&2. The output -of \*S is also much less verbose than \s-2SPICE\s+2\&2, in that the only -data printed is that requested by the above cards. -.PP -Vector names are the same as in \fBnutmeg\fR, with this addition: -a name such as \fB@name[param]\fR, where \fBname\fR is either -the name of a device instance or model, denotes the value of the -\fBparam\fR parameter of the device or model. See the \*S User's -Manual for details of what parameters are available. The value is a -vector of length 1. This function is also available with the -\fBshow\fR command, and is available with variables for convenience for -command scripts. -.PP -\*S -commands are as follows (these are only those commands not also -available in \fBnutmeg\fR \- consult the \fBnutmeg\fR manual page for -more commands): -.TP -\fBsetcirc [circuit name]\fR -Change the current circuit. The current circuit is the one that is -used for the simulation commands below. When a circuit is loaded -with the \fIsource\fR command (see below) it becomes the -current circuit. -.TP -\fBop [.op card args]\fR -Do an operating point analysis. -.TP -\fBtran [.tran card args]\fR -Do a transient analysis. -.TP -\fBac [.ac card args]\fR -Do an ac analysis. -.TP -\fBdc [.dc card args]\fR -Do a dc transfer curve analysis. -.TP -\fBlisting [logical] [physical] [deck] [expand]\fR -Print a listing of the current circuit. If the \fBlogical\fR argument -is given, the listing is with all continuation lines collapsed -into one line, and if the \fBphysical\fR -argument is given the lines are printed out as they were found in -the file. The default is \fBlogical\fR. A \fBdeck\fR listing is just like -the \fBphysical\fR listing, except without the line numbers it recreates -the input file verbatim (except that it does not preserve case). -If the word \fBexpand\fR is present, the circuit will be printed with all -subcircuits expanded. -.TP -\fBedit [file]\fR -Print the current \*S deck into a file, call up the editor on that file -and allow the user to modify it, and then read it back in, replacing -the origonal deck. If a \fBfilename\fR is given, then edit that file -and load it, making the circuit the current one. -.TP -\fBresume\fR -Resume a simulation after a stop. -.TP -\fBshow \fR -Show a device parameter. -.TP -\fBalter \fR -Alter a device parameter. -.TP -\fBstate\fR -Print the state of the circuit. (This command is largely unimplemented.) -.TP -\fBsave [all] [output ...]\fR or \fB.save [all] [output ...]\fR -Save a set of outputs, discarding the rest. If a node has been mentioned -in a \fBsave\fR command, it will appear in the working plot after -a run has completed, or in the rawfile if spice is run in batch -mode. If a node is traced or plotted (see below) it will -also be saved. For backward compatibility, if there are \fBno\fR save -commands given, all outputs are saved. -.TP -\fBstop [ after n] [ when something cond something ] ... \fR -Set a breakpoint. The argument \fBafter n\fR means stop after \fBn\fR -iteration number \fBn\fR, and the argument -\fBwhen something cond something\fR means -stop when the first \fBsomething\fR is in the given relation with -the second \fBsomething\fR, the possible relations being -\fBeq\fR or = (equal to), -\fBne\fR or <> (not equal to), -\fBgt\fR or > (greater than), -\fBlt\fR or < (less than), -\fBge\fR or >= (greater than or equal to), and -\fBle\fR or <= (less than or equal to). -IO redirection is disabled for the \fBstop\fR command, since the relational -operations conflict with it (it doesn't produce any output anyway). -The \fBsomething\fR\&s above may be node names in -the running circuit, or real values. -If more than one condition is given, e.g. -\fBstop after 4 when v(1) > 4 when v(2) < 2\fR, the conjunction of -the conditions is implied. -.TP -\fBtrace [ node ...]\fR -Trace nodes. Every iteration the value of the node is printed to the -standard output. -.TP -\fBiplot [ node ...]\fR -Incrementally plot the values of the nodes while \*S runs. -.TP -\fBstep [number]\fR -Iterate \fBnumber\fR times, or once, and then stop. -.TP -\fBstatus\fR -Display all of the traces and breakpoints currently in effect. -.TP -\fBdelete [debug number ...]\fR -Delete the specified breakpoints and traces. The \fBdebug numbers\fR -are those shown by the \fBstatus\fR command. (Unless you do -\fBstatus > file\fR, in which case the debug numbers aren't printed.) -.TP -\fBreset\fR -Throw out any intermediate data in the circuit (e.g, after a breakpoint -or after one or more analyses have been done already), and re-parse -the deck. The circuit can then be re-run. (\fBNote\fR: this command -used to be \fBend\fR in \s-2SPICE\s+2 3a5 and earlier versions -- \fBend\fR -is now used for control structures.) The \fBrun\fR command will take -care of this automatically, so this command should not be necessary... -.TP -\fBrun [rawfile]\fR -Run the simulation as specified in the input file. If there were any -of the control cards .ac, .op, .tran, or .dc, they are executed. The output -is put in \fBrawfile\fR if it was given, in addition to being available -interactively. -.TP -\fBsource file\fR -Read the \*S input file \fBfile\fR. \fBNutmeg\fR and \*S commands may be -included in the file, and must be enclosed between the lines -\fI.control\fR and \fI.endc\fR. These commands -are executed immediately after the circuit is loaded, so a control line -of \fIac ...\fR will work the same as the corresponding \fI.ac\fR card. -The first line in any input file is considered a title -line and not parsed but kept as the name of the circuit. The -exception to this rule is the file \fI.spiceinit\fR. -Thus, a \*S command script must begin with a blank line and then with -a \fI.control\fR line. -Also, any line beginning with the characters *# is considered a control -line. This makes it possible to imbed commands in \*S input files -that will be ignored by earlier versions of \s-2SPICE\s+2. -\fINote:\fR in spice3a7 and before, the \fI.control\fR and \fI.endc\fR -lines were not needed, and any line beginning with the name of a front-end -command would be executed. -.TP -\fBlinearize vec ...\fR -Create a new plot with all of the vectors in the current plot, or -only those mentioned if arguments are given. The new vectors -will be interpolated onto a linear time scale, which is determined -by the values of \fBtstep, tstart,\fR and \fBtstop\fR in the -currently active transient analysis. The currently loaded deck -must include a transient analysis (a \fBtran\fR command may be run -interactively before the last \fBreset\fR, alternately), and the -current plot must be from this transient analysis. This command -is needed because \s-2SPICE\s+2\&3 doesn't output the results -from a transient analysis in the same manner that \s-2SPICE\s+2\&2 did. -.PP -There are several \fBset\fR variables that \*S uses but \fBnutmeg\fR -does not. They are: -.IP "" 16 -\fBeditor\fR -.br -The editor to use for the \fBedit\fR command. -.IP -\fBmodelcard\fR -.br -The name of the model card (normally \fB.model\fR). -.IP -\fBnoaskquit\fR -.br -Do not check to make sure that there are no circuits suspended and -no plots unsaved. Normally \*S will warn the user when he tries to -quit if this is the case. -.IP -\fBnobjthack\fR -.br -Assume that BJT's have 4 nodes. -.IP -\fBnoparse\fR -.br -Don't attempt to parse decks when they are read in (useful for -debugging). Of course, they -cannot be run if they are not parsed. -.IP -\fBnosubckt\fR -.br -Don't expand subcircuits. -.IP -\fBrenumber\fR -.br -Renumber input lines when a deck has \fB.include\fR's. -.IP -\fBsubend\fR -.br -The card to end subcircuits (normally \fB.ends\fR). -.IP -\fBsubinvoke\fR -.br -The prefix to invoke subcircuits (normally \fBx\fR). -.IP -\fBsubstart\fR -.br -The card to begin subcircuits (normally \fB.subckt\fR). -.PP -There are a number of \fBrusage\fR parameters available, in addition -to the ones available in \fBnutmeg\fR: -.IP "" 16 -.PP -If there are subcircuits in the input file, \*S expands instances of them. -A subcircuit is delimited by the cards -.B .subckt -and -.B .ends, -or whatever the value of the variables -.B substart -and -.B subend -is, respectively. An instance of a subcircuit is created by specifying -a device with type 'x' \- the device line is written -.IP -\fBxname node1 node2 ... subcktname\fR -.LP -where the nodes are the node names that replace the formal parameters -on the \fB.subckt\fR line. All nodes that are not formal parameters -are prepended with the name given to the instance and a ':', as are -the names of the devices in the subcircuit. If there are several nested -subcircuits, node and device names look like \fBsubckt1:subckt2:...:name\fR. -If the variable \fBsubinvoke\fR is set, then it is used as the prefix -that specifies instances of subcircuits, instead of 'x'. -.SH "VMS NOTES" -The standard suffix for rawspice files in VMS is ".raw". -.PP -You may have to redefine the value EDITOR if you wish to use the \fBedit\fR -command, since the default for VMS is "vi". -.SH "SEE ALSO" -nutmeg(1), sconvert(1), spice(1), mfb(3), writedata(3) -\*S User's Guide -.SH AUTHORS -\*S: Tom Quarles (quarles@cad.berkeley.edu) -.br -\fBnutmeg\fR / User interface: Wayne Christopher (faustus@cad.berkeley.edu) -.SH BUGS -.PP -\*S will recognise all the notations used in \s-2SPICE\s+2\&2 \fB.plot\fR -cards, and will translate \fBvp(1)\fR into \fBph(v(1))\fR, and so -forth. However, if there are spaces in these names it won't work. Hence -\fBv(1, 2)\fR and \fB(-.5, .5)\fR aren't recognised. -.PP -BJT's can have either 3 or 4 nodes, which makes it difficult for the subcircuit -expansion routines to decide what to rename. If the fourth parameter has -been declared as a model name, then it is assumed that there are 3 nodes, -otherwise it is considered a node. To disable this kludge, you can set -the variable "nobjthack", which will force BJT's to have 4 nodes (for the -purposes of subcircuit expansion, at least). -.PP -The \fB@name[param]\fR notation might not work with \fBtrace, iplot,\fR etc. -yet. -.PP -The first line of a command file (except for the \fI.spiceinit\fR file) -should be a comment. Otherwise \s-2SPICE\s+2 may create an empty circuit -structure. -.SH CAVEATS -.PP -\*S files specified on the command line are read in before the\fB .spiceinit\fR -file is read. Thus if you define aliases there that you call in a -\*S source file mentioned on the command line, they won't be recognised. - diff --git a/notes/Linux.changes b/notes/Linux.changes deleted file mode 100644 index fd4d1329d..000000000 --- a/notes/Linux.changes +++ /dev/null @@ -1,164 +0,0 @@ -So, this is third version of Spice3f5 for RedHat Linux 2.6. I took re-ported -version of spice3f5 and made changes to fix some bugs. If someone want to help, -please send me "newer" versions wtih more bugs fixed. -I hope that those who wnat to have good spice under Linux (no more Win95) -will find this port useful and maybe help each other to improve it. - -There was a lot of bugs in previus versions, generally in command parsiong routines. -I copy all original files to *.orig and marked all my changes with /* MW. ... */ - -I changed cp/bquote.c and cp/var2.c to handle some special situations -and commands like $foo, `foo`. Also problems with 'gets()' (in sconvert and -inp.c) function are fixed. I chnaget it to fgets(buf, BSIZE_SP, stdin) for -safe use. - -Globing ('[]{}?*') didn't work at all. Now it is removed (form cp/glob.c). -We don't need this features in spice. - -Initial command parsing (cp_lexer() from cp/lexical.c) strip all commas from -strings. This was in conflict with aritchetic expressions. - -com_let() in fte/postcoms.c caused core dump in some situations - fixed. - -Editor problems. Com_edit() in fte/inp.c failed occasionally, when it -tryies to fclose() fp second time. Now inp_spsource() always closes fp, and -other calling functions do not. It seems to work right now. - -vec_get() (fte/vectors.c) has some problems with devices parameters and -memory leaks. I hope that my changes fixed it at all. - -I have to add INPinsertNofree() in inp/inpsymt.c. This is special case for -routines from fte/spiceif.c and fte/outitf.c - It does not do free() for -any pointers that it gets. This may cause small memory leaks, but I don't -know how to make it better. - -com_alter_common() (fte/device.c) caused segmentation faults ocassionally, -due to double free the same pointers. It works right now. - -cp_lexer() corretly gets ^V, ^D, and ESC. I have to #include ioctl.h file in -cp/lexical.c and cp/complete.c - -There were problem with com_iplot() if it was called when X11 does not run. -I have to add additonal check to gr_pmsg() (from fte/graph.c) and now it -works fine. - -Trace failed to display comlex data due to segmentation fault. Someone wants -to plot realdata even if given vector was complex. I changed gr_iplot() -(in fte/graf.c) and now it is fine. - -There are some changes in os_linux.h and os_unix.h, but they are not mandatory, -I think. Also I have to add PI, and some other const. declarations in spice.h -They were needed somewhere. (why someone didn't used M_PI and so on instead ?) - -In file fte/x11.c, was a prloblem with background color for plot windows. I -changed init_colors() and now we can use color0 variable. - -Spice3f5 has a few memory leaks. I suppose that some vectors and maybe other -things are simple 'lost' somewhere. If you (just like me) trying to make this -program better, take care about this also. -Generally I didn't do much with graphisc interface, because it seems to work -quite good. Only problem is core dump, when cliking mouse on help screen. - -Manuals are sometimes in error. Vector creation by [ el. el. ...] is not -supported I think. For indexing we must use [low , hi]. For setting 'list' -variables - ( el. el. ... ). Indexing also doesn't work with let xx[...] = yy. - -Someone should change these f... manuals. - - -And now for those who think about makeing this program better. There is a big -problem with memory, when you run a few simulations. Destroy commad does not -free much memory, and after some time you can see that spice uses 3MB, when -you just clean all vectros. Also I don't know how to unload a circuit - -spice hold all sourced files in the "deck" list and there is no way to free -it from command line (or maybe I didn't find any). - Unfortunatelly I am sure that these are not all off the problems -with this program, but now I can use it quite effectively. If anyone will -know anything about bugs-free, good, commannd driven simulator for Linux -__PLEASE__ let me know. - -For easer use I made special debug file (conf/debug). I used it for makeing -"debug" version of spice with efence library and -g option. Executable files -from this are located in spice3f5/objdbg/bin, when you do 'util/build linux debug'. - -I am an electronic designer, so I really need a good working simulator... - -Original readme file is given below. - - Michael Widlok (widlok@uci.agh.edu.pl) - Uniersity of Mining and Metallurgy - Krakow, Poland. - - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This is my (re-)port of Spice3f4 to Linux version 2 (I am not the same -person who ported it before). It also wraps in the latest official -pre-3f5 patches from Berkeley I could find (found in -sp3f4.patch.tar.Z). Support for the MFB interface using the Linux -termcap library and some various Linux features have been ported. - -This was not done for the hell of it, but it seemed that something -broke due to some Linux/system/library changes, so I decided to try -porting it from scratch. In fact, if you don't have any problems with -the previous port, your probably fine then. However, if you do have -problems (e.g. exiting Spice leaves you in uppercase mode), or want -MFB for some reason, then try this. It seems to work here. - -Basically, I started out with sp3f4.kit.tar.Z. Then, I applied the -most recent patches contained in sp3f4.patch.tar.Z and wrote new Linux -build files: "linux" and "os_linux.h" (some minor mods to the source -were also necessary, protected with linux conditionals). - -Since the previous spice3f4.tar.gz port file was generally available, -there was no point in duplicating source, so I just diffed from the -spice3f4.tar.gz tree to freshly ported tree and edited or removed a -few of the diffs. A few of the changes made in spice3f4.tar.gz have -been reverted to the distribution defaults, but one notable change is -that performing the install step will install the necessary files into -/usr/local/spice. You'll need to add /usr/local/spice/bin to your -shell path. See the file conf/linux to change the installation -location (this location gets hard-coded in the spice binaries). - -This is a patched file of the original readme.Linux from -spice3f4.tar.gz, and the previous contents by Jeff@EE.Ryerson.Ca is -given below. Just follow the below instructions, so you should be -able to safely do: - - ./util/build linux - ./util/build linux install - -You should then find the spice binaries and library files -in e.g. /usr/local/spice. Example files and the man pages -are not installed, so you might want to copy them by hand. - -Andrew Veliath (veliaa@rpi.edu) -January 25, 1997 - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This is my port of Spice3f4 to Linux. It required a few more changes -than the porting document indicated would be necessary, mostly to do -with supported/unsupported functions in Linux libc & libm. - -I've tried to make these changes in as as portable a way as possible, -so it should build cleanly on other Unicies, however I've removed the -MS-DOS support so the tarred and gziped source fits on one disk. - -To build spice3, first have a look in the file readme, but you should -be able to just do... - -./util/build linux -./util/build install linux - -Note that there is a modifyer "gcc" you can try if you have trouble, but -it claims to work around some obscure bug in gcc that I'm positive got -fixed eons ago. To use it anyway, do ./util/build linux gcc. - -I found this source through archie, (look for spice3f3.tar.Z, and then -patched it to 3f4 with patches from ic.berkeley.edu), I assume that the -ftp site I got it from has read thier license from Berkeley, which if -it's the same as the 3e2 license states that the holder can distribute -copies free of charge provided it does not fall into hands unfriendly -to the U.S. So... I guess if that's you, please destroy all copies of this -you might have! - -Jeff@EE.Ryerson.Ca diff --git a/notes/dbx b/notes/dbx deleted file mode 100644 index c7c54c170..000000000 --- a/notes/dbx +++ /dev/null @@ -1,7 +0,0 @@ -A note when using dbx (under unix-type operating systems) to debug spice3: - -To avoid a segmentation fault in the initial run, use the following command -in dbx: - setenv SPICE_NO_DATASEG_CHECK "1" -Or, the comparable command in your shell before running dbx. This -disable accurate tracking of how much memory is used. diff --git a/notes/internal b/notes/internal deleted file mode 100644 index a6bf6666c..000000000 --- a/notes/internal +++ /dev/null @@ -1,98 +0,0 @@ -Internal Changes from 3e2 - - The device structure has changed: The state counter in all device - structures has been moved to correspond to GENstates in the - GENinstance structure. - - Also, a new per-device-type function has been added: XXXunsetup, - which deallocates nodes and other resources created in the - XXXsetup function. ("XXX" is the device abbreviation.) - -Internal Changes from 3d2 - -FILE NAMES: - - Of the changes to spice3 between 3d2 and 3e1, the - the most obvious is the new filenames. All filesnames - have been converted to lowercase and are at most eight - characters plus an optional dot and three character extension. - This change was made to accomodate MS-DOS and other operating - systems which limit the maximum file name length. - - -ORGANIZATION - - The top level directory contains the installation "readme" file - and a "makedefs" files used by the "build" command. - - "src/" contains all of the C source code. This used to be named - "spice3" or "spice3d2" in previous releases. - - "src/lib" is the library or "toolkit" portion of Spice3. Within - it are the following subdirectories: - - ckt/ All of the analysis code. - ni/ Numerical algorithms (used by ckt routines). - sparse/ Sparse matrix package (used by ckt and ni). - misc/ Miscellaneous utility and portability routines. - dev/ All of the device specific code, with a subdir for - each device implementation. - - inp/ Input parsing; could be much smaller. - - fte/ The front end. Really bad. - cp/ More front end -- "C shell". - hlp/ The windowed help system. - - mfb/ Terminal independant graphics package. - mfbpc/ MFB interface for the IBM PC. - - - "src/bin" contains the source for all executable programs (the - location for "main( )"). "main.c" is used by spice, nutmeg, - bspice, and cspice (the latter two for MS-DOS). The function - of "main.c" is altered by defining the pre-processor symbols - SIMULATOR (for either spice, bspice, or cspice), BATCH for - bspice, and BATCH and SPICE2 for cspice (no special defines - give nutmeg). Each variant of the simulator uses "conf.c" (or - "bconf.c" or "cconf.c", or "nconf.c" for nutmeg), which is - automatically generated from "config.c". "config.c" is a - template used to select devices and analyses. "tune.c" - ("tunepc.c") contains the compiled in pathnames. - - - "examples/" contains several spice input files. - - "lib/" contains standard data files for spice, such as the help - files and MFB capability files. - - "man/" contains UNIX style manual pages (ala "man(1)"). - - "util/" contains utility scripts, such as "build" for running the - recursive "make" and "delall.bat" for deleting the distribution on - MS-DOS systems. - - All "Makefile"s have been replaced with "makedefs" (and optionally - "depend" and "makeops"). "makedefs" is combined with other - make definition files with the "build" script. - -SOURCE LEVEL CHANGES - - (Added features are listed in the "README" file). - - DEVICES: The interface to devices has, once again, changed. - The change is small from 3d2. Table size values in the device - information struction are now pointers to integers containing - the table sizes. Per-analyses functions have been surrounded - with "#ifdef AN_xx"/"#else"/"#endif" lines. Note that the - "itf.h" files are stored only in the "include/" subdirectory. - - Adding devices to the master list is done in the file - "src/bin/config.c", instead of "FTE/SPIinit.c". - - SPARSE MATRIX PACKAGE: the sparse matrix package in Spice3e1 - and later is a more efficient implementation than in earlier releases. - The interface is the same. - - - diff --git a/notes/mac_port b/notes/mac_port deleted file mode 100644 index 921723936..000000000 --- a/notes/mac_port +++ /dev/null @@ -1,207 +0,0 @@ - - - Compiling spice with Think C on a Macintosh. - -A 68020 (Mac II) with co-processor is required. - -The src directory from the spice distribution should be moved into -the C folder. - -**** recompile think c libraries **** - - Both the ANSI and unix libraries must be recompiled with the - following additional compiler settings: - Generate 68020 instructions - Generate 68881 instructions - 4-bytes ints - Native floating-point format - - The "console.c" file must be edited and should be removed from - the ANSI project. I actually recompiled copies of the ANSI and - unix libraries that I called ANSI.68881 and unix.68881. - Copy the "console.c" source (a THINK C file) to a suitable - location so that it can be included in the spice project. (See - the next section for details of how "consol.c" must be modified.) - - -**** creating the project **** - - Create a new project and set the Options as follows: - Laguage Settings - Turn on the following options - Define #__STDC__ - Recognize trigraphs - enums are always ints - Check pointer types - Language Extension - THINK C - Compiler Settings - Turn on the following options - Generate 68020 instructions - Generate 68881 instructions - 4-bytes ints - Native floating-point format - Code Optimization - Turn on all options - Prefix - make sure there is no prefix (remove - default #include ) - - Note: The Language setting 'Strict Prototype Enforcement' must be - turned off. - - Set the project type to application with at least 1024k partition - and turn on the 'Far DATA' option. - -*** Adding the code to the project *** - - Start Adding the code to the project. The code must be divided - into segments that are less that 32K each when compiled. The - following division has been used: - - Segment 1: the ANSI.68881 and unix.68881 libraries. - Segment 2: all *.c files in /src/sparse - Segment 3: all *.c files in /src/lib/ni - Segment 4: all *.c files in /src/lib/misc - Segment 5: files /src/lib/inp/inp2dot.c - and /src/lib/inp/inptree.c - Segment 6: all other *.c files in /src/inp - Segment 7: all *.c files in /src/lib/hlp - Segment 8: all *.c files in /src/lib/cp - except /src/lib/cp/input.c - Segment 9: file /src/lib/ckt/dloadfns.c - Segment 10: files /src/lib/ckt/cktpzstr.c, - /src/lib/ckt/cktsens.c, /src/lib/ckt/dctran.c, - and /src/lib/ckt/distoan.c - Segment 11: all other *.c files in /src/lib/ckt - Segment 12: cmath*.c files in /src/lib/fte - Segment 13: files agraf.c, clip.c, display.c, graf.c, - graphdb.c, plot5.c, plotcurv.c and - postsc.c in /src/lib/fte - - Segment 14: files evaluate.c, parse.c, postcoms.c, - and subckt.c in /src/lib/fte - Segment 15: files breakp.c, device.c, doplot.c, - grid.c and shyu.c in /src/lib/fte - Segment 16: files dotcards.c, inp.c, outif.c, rawfile.c, - spiceif.c and vectors.c in /src/lib/fte - Segment 17: all other *.c files in /src/lib/fte - except nutmegif.c - Segment 18: all *.c files in /src/lib/fte/vsrc - and /src/lib/fte/isrc - Segment 19: all *.c files in /src/lib/fte/jfet - Segment 20: all *.c files in /src/lib/fte/vccs, - /src/lib/fte/vcvs, /src/lib/fte/cccs, - and /src/lib/fte/ccvs - Segment 21: all *.c files in /src/lib/fte/asrc - and /src/lib/fte/urc - Segment 22: all *.c files in /src/lib/fte/cap, - /src/lib/fte/ind, and /src/lib/fte/res - Segment 23: all *.c files in /src/lib/fte/csw, - /src/lib/fte/sw, and /src/lib/fte/tra - Segment 24: all *.c files in /src/lib/fte/mos6 - Segment 25: all *.c files in /src/lib/fte/mes - Segment 26: all *.c files in /src/lib/fte/ltra - Segment 27: file mos3load.c in /src/lib/fte/mos3 - Segment 28: files mos3dist.c, mos3dset.c, - and mos3sld.c in /src/lib/fte/mos3 - Segment 29: remaining *.c files in /src/lib/fte/mos3 - Segment 30: all *.c files in /src/lib/fte/dio - Segment 31: file mos1load.c in /src/lib/fte/mos1 - Segment 32: files mos1dist.c, mos1dset.c, - and mos1sld.c in /src/lib/fte/mos1 - Segment 33: remaining *.c files in /src/lib/fte/mos1 - Segment 34: file bjtload.c in /src/lib/fte/bjt - Segment 35: files bjtdisto.c, bjtdset.c, - and bjtsload.c in /src/lib/fte/bjt - Segment 36: remaining *.c files in /src/lib/fte/bjt - Segment 37: file mos2load.c in /src/lib/fte/mos2 - Segment 38: file mos2dset.c in /src/lib/fte/mos2 - Segment 39: files mos2dist.c, and mos2sld.c - in /src/lib/fte/mos2 - Segment 40: remaining *.c files in /src/lib/fte/mos2 - Segment 41: files b1dset.c, and b1ld.c in /src/lib/fte/bsim1 - Segment 42: files b1disto.c, and b1eval.c in /src/lib/fte/bsim1 - Segment 43: remaining *.c files in /src/lib/fte/bsim1 - Segment 44: files b2eval.c, and b2ld.c in /src/lib/fte/bsim2 - Segment 45: remaining *.c files in /src/lib/fte/bsim2 - Segment 46: all *.c files in /src/lib/dev/disto, - and devsup.c in /src/lib/dev - Segment 47 all *.c files in /src/lib/mac, - and file /src/bin/main.c - - Note that the following files are not included: - /src/lib/cp/input.c - /src/lib/fte/nutmegif.c - - Add "console.c" (the copy made as described above) and make the - following alterations to it: - 1. The lines: - static char console_environment, noPrint, interrupted; - static short console_refnum; - static MenuHandle appleMenu; - static WindowPeek theConsole; - - must be changed to make console_environment and - appleMenu external: - extern char console_environment, noPrint, interrupted; - static char noPrint, interrupted; - static short console_refnum; - extern MenuHandle appleMenu; - static WindowPeek theConsole; - - 2. Alter the function ProcessEvent() to add a default switch - case. The altered section appears following a doEvent label as - (note: this code fragment has 4-space tabs and long lines - broken to fit an 80-column page; these changes do not affect - the code): - - doEvent: - if (event.what == mouseDown) { - switch (FindWindow(event.where, &wp)) { - case inMenuBar: - InitCursor(); - choice = MenuSelect(event.where); - goto doMenu; - case inSysWindow: - SystemClick(&event, wp); - break; - default: /* For spice to pass mouse - events to graphs */ - if ((WindowPtr) wp != FrontWindow()) { - SelectWindow(wp); - in.cnt = 0; - } /* in.cnt=0 forces console to - return to application */ - } - } - - - - - - Compilation takes about 3 to 4 hours on a 25MHz mac. Set the cache - to at least 256k to eliminate a lot of disk access. - -**** makeindx **** - Create a project with the same option settings decribed above. - - Add src/bin/makeidx.c, ANSI.68881 and an unmodified version of - "console.c". - - Build the makeindex application. - - Move the application into lib/helpdir directory of the the spice - distribution. Run it and add the names of the files to be indexed - (nutmeg.txt spice.txt) to the command line and hit return. - -**** proc2mod **** - - Create a project with the same option settings decribed above. - - Add src/bin/proc2mod.c, src/lib/misc/alloc.c, src/lib/misc/string.c - src/lib/inp/inpcfix.c, src/lib/inp/inpeval.c, - src/lib/inp/inpgtok.c, ANSI.68881 and an unmodified - version of console.c. - - Build the proc2mod application. diff --git a/notes/porting b/notes/porting deleted file mode 100644 index 7ef93a409..000000000 --- a/notes/porting +++ /dev/null @@ -1,237 +0,0 @@ -(ER - 7/08/99) - -These are a few notes on the autoconf porting that is being done. - -Autoconf automaticcaly provides #defines (in config.h) that describe -the system that ng-spice is being compiled on. Thus, all the os_xxx.h -files should no longer be necessary. - - -Here is a (as complete as possible) list of new #defines and their -corresponding #defines in the old build system: - - - - -#define HAS_VAX_FPERRORS - unused (should remove the code) -#define MAXPOSINT 4294967295 - don't know about that one -#define MAX_EXP_ARG 87.0 - same - ----------- Operating System (os_xxx.h) parameters: - ------ Enabling flags -#define AVAIL_MFB -DWANT_MFB passed to cpp -#define AVAIL_X11 X_DISPLAY_MISSING (reversed) - ------ String or character constants -#define DIR_CWD "." now in spice.h -#define DIR_PATHSEP "/" now in spice;h -#define DIR_TERM '/' now in spice.h - -On Unix, I don't think that there are other possibilities. -We should get rid of those. - - ------ sprintf( ) format strings -#define TEMPFORMAT "/tmp/%s%d" /* sprintf format for creating temp files */ -#define SYSTEM_MAIL "mail -s \"%s (%s) Bug Report\" %s" /* mail command */ -#define SYSTEM_PLOT5LPR "lpr -P%s -g %s" /* For printing Unix plot(5) files */ -#define SYSTEM_PSLPR "lpr -P%s %s" /* For printing postscript files */ - - -Same for these I guess... - - - ------ System capabilities -#define HAS_ACCESS HAVE_ACCES -#define HAS_ASCII not handled yet -#define HAS_ATRIGH HAVE_ATANH HAVE_ACOSH HAVE_ASINH -#define HAS_BCOPY HAVE_BCOPY -#define HAS_BSDDIRS HAVE_DIR_H -#define HAS_BSDRANDOM unused -#define HAS_BSDRLIMIT HAVE_GETRLIMIT -#define HAS_BSDRUSAGE HAVE_GETRUSAGE -#define HAS_BSDSOCKETS unused -#define HAS_BSDTIME HAVE_GETTIMEOFDAY -#define HAS_BSDTTY HAVE_SGTTY_H -#define HAS_CHDIR removed -#define HAS_CLEARERR removed -#define HAS_CTYPE HAVE_CTYPE_H -#define HAS_DOSDIRS dos only - should remove code -#define HAS_DUP2 HAVE_DUP2 -#define HAS_ENVIRON removed -#define HAS_EXIT1 vms only - should remove the code -#define HAS_FCNTL HAVE_FCNTL_H -#define HAS_FTIME HAVE_FTIME -#define HAS_GETCWD HAVE_GETCWD -#define HAS_GETPID removed -#define HAS_GETPW HAVE_PWD_H -#define HAS_GETWD HAVE_GETWD -#define HAS_INDEX HAVE_INDEX -#define HAS_NO_IEEE_LOGB HAVE_LOGB HAVE_SCALB HAVE_SCALBN -#define HAS_NO_IEEE_LOGB_DECL removed -#define HAS_ISATTY HAVE_ISATTY -#define HAS_LONGJUMP removed -#define HAS_MINDATA dos only? - should remove code if so -#define HAS_NOINLINE dos only? - should remove code if so -#define HAS_NOVM dos only? - should remove code if so -#define HAS_NO_ATRIGH_DECL removed -#define HAS_PCTERM dos only - should remove code -#define HAS_POPEN HAVE_POPEN -#define HAS_QSORT HAVE_QSORT -#define HAS_SHORTMACRO dos only - should remove code -#define HAS_STAT STAT_MACROS_BROKEN (reversed) -#define HAS_STDLIB STDC_HEADERS -#define HAS_STRCHR HAVE_STRCHR -#define HAS_STRINGS STDC_HEADERS (reversed) not sure about that one! -#define HAS_SYSTEM removed -#define HAS_SYSVDIRS HAVE_DIRENT_H -#define HAS_SYSVRLIMIT HAVE_ULIMIT -#define HAS_SYSVRUSAGE HAVE_UTIME -#define HAS_SYSVTIME HAVE_TIME -#define HAS_SYSVTTY HAVE_TERMIO_H -#define HAS_TERMCAP HAVE_TERMCAP -#define HAS_TERMREAD don't know what to do with this one -#define HAS_UNIX_SIGS removed -#define HAS_UNLINK removed -#define HAS_VFORK HAVE_VFORK_H -#define HAS_VMSHACK vms only - should remove the code -#define HAS_VPERROR removed -#define HAS_WAIT HAVE_WAIT - -plus a few others: - -#define HAS_MEMAVL dos only - should remove code -#define HAS_FLAT_INCLUDES macos only - should remove code -#define HAS_BATCHSIM dos only - should remove code - - - ----------------------------------------------------------------------------- - -PORTING SPICE3e1 - - Porting Spice3 to a new operating system usually consists of listing - the capabilities of that operating system in a new '.h' file and - including this '.h' file in the standard portability sequence. This - also needs to be done separately for the numerical capabilities of the - system hardware (this consist of only two parameters at present). - - For each operating system there is a file in the "include/" directory - named "os_xxx.h", where xxx identifies the given operating system (ex. - "os_bsd.h", "os_aix.h"). These files are selectively #include-d by - "include/port.h". For a new operating system, you should add the - appropriate "#include" line to "include/port.h". Be sure to guard - the new "#include" line with "#ifdef/#endif", as is done with the other - operating system capability files. The same may also need to be done - for your hardware (for the file "hw_xxx.h"), though there is typically - very little difference in hardware. - - Note that operating system which are a derivative of another supported - system can '#include' the "os_xxx.h" file from the other system. For - example, "os_aix.h" includes "os_sysv.h", which in turn includes - "os_unix.h". - - The entries that can go into a "os_xxx.h" file are described below; - most are simple flags (e.g. HAS_xxxx). To turn on a flag, insert the - "#define" line for that flag; to turn off the flag, simply leave the - "#define" line out. Other entries are strings, others single-quoted - characters or numbers. Be sure to use the same type as the example - values shown. - - There are always exceptions to the rule. Some incompatibilities - have not yet been dealt with cleanly; review the other "os_xxx.h" - files, the file "capabil.h", and the file "suffix.h" to understand - how some problems have been handled (note especially the lines like - "#define index strchr"). After trying to compile, you may yet find - non-portable code that is not guarded by one of the following - options. You are encouraged to alter the source code (".c" or ".h" - files) in the style of the current portability scheme. - - Note: to enable X11 or MFB, the flag AVAIL_X11 or AVAIL_MFB, - respectively, must be included in the "os_xxx.h" file; this _was_ to - simplify the problems of forgetting to re-edit the "config.h" file, - but this is no longer necessary. - ----------- Machine architecture numerics (hw_xxx.h) parameters: - (In the future this will be more complete and will be used for - tuning the accuracy or performance of the numerical algorithms) - -#define HAS_VAX_FPERRORS /* Only for Vax */ -#define MAXPOSINT 4294967295 /* == 2^32 - 1, maximum positive integer */ -#define MAX_EXP_ARG 87.0 /* Approximate largest arg to exp() */ - ----------- Operating System (os_xxx.h) parameters: - ------ Enabling flags -#define AVAIL_MFB /* If the MFB package can work on this system */ -#define AVAIL_X11 /* If the X11 Window System can work */ - ------ String or character constants -#define DIR_CWD "." /* Current working directory */ -#define DIR_PATHSEP "/" /* subdirectory separator */ -#define DIR_TERM '/' /* Subdirectory component terminator */ - ------ sprintf( ) format strings -#define TEMPFORMAT "/tmp/%s%d" /* sprintf format for creating temp files */ -#define SYSTEM_MAIL "mail -s \"%s (%s) Bug Report\" %s" /* mail command */ -#define SYSTEM_PLOT5LPR "lpr -P%s -g %s" /* For printing Unix plot(5) files */ -#define SYSTEM_PSLPR "lpr -P%s %s" /* For printing postscript files */ - ------ System capabilities -#define HAS_ACCESS /* access( ) */ -#define HAS_ASCII /* eighth bit of a character is not used */ -#define HAS_ATRIGH /* acosh( ), asinh( ), atanh( ) */ -#define HAS_BCOPY /* bcopy( ), bzero( ) */ -#define HAS_BSDDIRS /* */ -#define HAS_BSDRANDOM /* srandom( ) and random( ) */ -#define HAS_BSDRLIMIT /* getrlimit( ) returns proc limits */ -#define HAS_BSDRUSAGE /* getrusage( ) returns cpu usage */ -#define HAS_BSDSOCKETS /* , socket( ), etc. */ -#define HAS_BSDTIME /* gettimeofday( ) return time */ -#define HAS_BSDTTY /* */ -#define HAS_CHDIR /* for tree filesystems, chdir( ) */ -#define HAS_CLEARERR /* clearerr( ), should be in stdio */ -#define HAS_CTYPE /* , iswhite( ), etc. */ -#define HAS_DOSDIRS /* Emulate opendir, etc. */ -#define HAS_DUP2 /* dup2(a, b) for shifting file descrs. */ -#define HAS_ENVIRON /* getenv( ) */ -#define HAS_EXIT1 /* If exit status of 1 is normal for procs */ -#define HAS_FCNTL /* acosh( ), asinh( ), atanh( ) */ -#define HAS_FTIME /* ftime( ), */ -#define HAS_GETCWD /* getcwd(buf, size) */ -#define HAS_GETPID /* getpid( ) to identify processes */ -#define HAS_GETPW /* getpwuid( ), etc. */ -#define HAS_GETWD /* getwd(buf) */ -#define HAS_INDEX /* index( ) instead of strchr( ) */ -#define HAS_NO_IEEE_LOGB /* no logb( ) and scalb( ) functions */ -#define HAS_NO_IEEE_LOGB_DECL /* logb( ) and scalb( ) not in math.h */ -#define HAS_ISATTY /* isatty( ) */ -#define HAS_LONGJUMP /* setjmp( ), longjmp( ) */ -#define HAS_MINDATA /* Machine has limited data area */ -#define HAS_NOINLINE /* Machine has limited data area */ -#define HAS_NOVM /* Machine has limited data area */ -#define HAS_NO_ATRIGH_DECL /* if asinh( ) is not in math.h */ -#define HAS_PCTERM /* For MS-DOS, use PC graphics for MFB */ -#define HAS_POPEN /* popen( ), pipe through shell command */ -#define HAS_QSORT /* qsort( ) exists */ -#define HAS_SHORTMACRO /* If the compiler can't handle long macros */ -#define HAS_STAT /* stat( ) returns info on files */ -#define HAS_STDLIB /* #include for libc defs */ -#define HAS_STRCHR /* strchr( ) instead of index( ) */ -#define HAS_STRINGS /* #include (else ) */ -#define HAS_SYSTEM /* system( ), execute system command */ -#define HAS_SYSVDIRS /* */ -#define HAS_SYSVRLIMIT /* ulimit( ) reports on proc size limit */ -#define HAS_SYSVRUSAGE /* utimes( ) reports on cpu usage */ -#define HAS_SYSVTIME /* time( ) returns seconds from 1970 */ -#define HAS_SYSVTTY /* */ -#define HAS_TERMCAP /* tgetxxx( ) */ -#define HAS_TERMREAD /* Has "read" syscall from terminals */ -#define HAS_UNIX_SIGS /* signal( ), kill( ) */ -#define HAS_UNLINK /* unlink( ), for removing files */ -#define HAS_VFORK /* BSD-ism, should not be necessary */ -#define HAS_VMSHACK /* Stand on your head for VMS */ -#define HAS_VPERROR /* perror( ) defined by standard '.h's */ -#define HAS_WAIT /* wait( ) wait for processes */ diff --git a/notes/spice2 b/notes/spice2 deleted file mode 100644 index 0e239036e..000000000 --- a/notes/spice2 +++ /dev/null @@ -1,15 +0,0 @@ - - Incompatibilities between spice3 and spice2 - -The output format of spice3 is slightly different for .print and .plot lines. -Most notably, different traces on plots are not scaled independently. This -is most noticeable on phase/magnitude plots from an AC analysis (also, -phase is displayed in radians). Finally, frequency for ".PRINT AC" lines -is displayed as a complex quantity with an all-zero imaginary component. - -For input, "POLY( )" sources are not supported (the non-linear dependent -source provides a more general replacement). Also, the ".ALTER" line -is not supported. The Spice3 parser may be slightly different -on subtle points of reading input (lines need not start at column 1 -for instance). - diff --git a/src/analysis/ChangeLog b/src/analysis/ChangeLog deleted file mode 100644 index dc7647af0..000000000 --- a/src/analysis/ChangeLog +++ /dev/null @@ -1,60 +0,0 @@ -2000-04-04 Paolo Nenzi - - * noisean.c: - Bug: he ac noise analysis in Spice3f4 has a serious bug. In interactive mode, - it fails to reproduce frequency dependence known to exist. In batch (Spice2) - mode, it works only if a corresponding ac analysis has been run first. - Fix: This bug is fixed by providing a call to CKTload() in noisean.c as shown - by the source code patch which is attached below. - - -1999-09-08 Emmanuel Rouat - - * ckt.h: created (and included in Makefile.am) - -1999-09-07 Arno - - * cktpzstr.c: reformatted and corrected(?) complex if condition. - -1999-08-28 Emmanuel Rouat - - * Removed all #includes of misc.h and util.h (now in spice.h) - -1999-08-27 Paolo Nenzi - - * Removed GENERIC and #include "suffix.h" from all the files. - GENERIC has been replaced by void. ANSIfied all functions with - protoize. - -1999-08-26 Paolo Nenzi - - * cktacct.c: added #include "spmatrix.h" to avoid implicit declaration - warning at compile time. - - * dctran.c: ansified and substituted void with void. - * tranasq.c: same as before. - * traninit.c: same as before. - * transetp.c: same as before. - - -1999-08-08 Emmanuel Rouat - - * Removed all HAS_SHORTMACRO and HAS_FLATINCLUDES code in directory - - * cktdest.c (and other files): changed HAS_SENSE2 in WANT_SENSE2 - -1999-08-04 Paolo Nenzi - - * changed dctrcurv.c: added code for temperature sweeps and - resistance sweeps. Now you can execute .dc temp - to do a temp sweep, temp is the keyword for temp - sweeps (The code comes from a patch supplied by Serban-Mihai - Popescu . To do a resitance sweep just - insert resistor name to the .cd line:.dc vin -5 5 1 rin 100 1000 10. - Resistance and temperature sweeps can be nested. diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am deleted file mode 100644 index 104e57ae6..000000000 --- a/src/analysis/Makefile.am +++ /dev/null @@ -1,106 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LIBRARIES = libckt.a - -libckt_a_SOURCES = \ - acan.c \ - acaskq.c \ - acsetp.c \ - cktaccpt.c \ - cktacct.c \ - cktacdum.c \ - cktask.c \ - cktaskaq.c \ - cktasknq.c \ - cktbindn.c \ - cktbkdum.c \ - cktclrbk.c \ - cktcrte.c \ - cktdelt.c \ - cktdest.c \ - cktdisto.c \ - cktdlti.c \ - cktdltm.c \ - cktdltn.c \ - cktdojob.c \ - cktdump.c \ - cktfbran.c \ - cktfdev.c \ - cktfnda.c \ - cktfndm.c \ - cktfnode.c \ - cktftask.c \ - cktgrnd.c \ - ckti2nod.c \ - cktic.c \ - cktinit.c \ - cktlnkeq.c \ - cktload.c \ - cktmapn.c \ - cktmask.c \ - cktmcrt.c \ - cktmkcur.c \ - cktmknod.c \ - cktmkvol.c \ - cktmpar.c \ - cktnames.c \ - cktnewan.c \ - cktneweq.c \ - cktnewn.c \ - cktnodn.c \ - cktnoise.c \ - cktntask.c \ - cktnum2n.c \ - cktop.c \ - cktparam.c \ - cktpartn.c \ - cktpmnam.c \ - cktpname.c \ - cktpzld.c \ - cktpzset.c \ - cktpzstr.c \ - cktsens.c \ - cktsetap.c \ - cktsetbk.c \ - cktsetnp.c \ - cktsetup.c \ - cktsgen.c \ - cktsopt.c \ - ckttemp.c \ - cktterr.c \ - ckttroub.c \ - ckttrunc.c \ - ckttyplk.c \ - daskq.c \ - dcoaskq.c \ - dcop.c \ - dcosetp.c \ - dctaskq.c \ - dctran.c \ - dctrcurv.c \ - dctsetp.c \ - distoan.c \ - dkerproc.c \ - dloadfns.c \ - dsetparm.c \ - naskq.c \ - nevalsrc.c \ - ninteg.c \ - noisean.c \ - nsetparm.c \ - pzan.c \ - pzaskq.c \ - pzsetp.c \ - sensaskq.c \ - senssetp.c \ - tfanal.c \ - tfaskq.c \ - tfsetp.c \ - tranaskq.c \ - traninit.c \ - transetp.c \ - ckt.h - - -INCLUDES = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/devices -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/analysis/acan.c b/src/analysis/acan.c deleted file mode 100644 index ce15f7fce..000000000 --- a/src/analysis/acan.c +++ /dev/null @@ -1,277 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "acdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -int -ACan(CKTcircuit *ckt, int restart) -{ - - double freq; - double freqTol; /* tolerence parameter for finding final frequency */ - double startdTime; - double startsTime; - double startlTime; - double startcTime; - double startkTime; - double startTime; - int error; - int numNames; - IFuid *nameList; - IFuid freqUid; - static void *acPlot; - void *plot; - - if(((ACAN*)ckt->CKTcurJob)->ACsaveFreq == 0 || restart) { - /* start at beginning */ - - if (((ACAN*)ckt->CKTcurJob)->ACnumberSteps < 1) - ((ACAN*)ckt->CKTcurJob)->ACnumberSteps = 1; - - switch(((ACAN*)ckt->CKTcurJob)->ACstepType) { - - case DECADE: - ((ACAN*)ckt->CKTcurJob)->ACfreqDelta = - exp(log(10.0)/((ACAN*)ckt->CKTcurJob)->ACnumberSteps); - break; - case OCTAVE: - ((ACAN*)ckt->CKTcurJob)->ACfreqDelta = - exp(log(2.0)/((ACAN*)ckt->CKTcurJob)->ACnumberSteps); - break; - case LINEAR: - if (((ACAN*)ckt->CKTcurJob)->ACnumberSteps-1 > 1) - ((ACAN*)ckt->CKTcurJob)->ACfreqDelta = - (((ACAN*)ckt->CKTcurJob)->ACstopFreq - - ((ACAN*)ckt->CKTcurJob)->ACstartFreq)/ - (((ACAN*)ckt->CKTcurJob)->ACnumberSteps-1); - else - ((ACAN*)ckt->CKTcurJob)->ACfreqDelta = HUGE; - break; - default: - return(E_BADPARM); - } - error = CKTop(ckt, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - if(error) return(error); - - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG; - error = CKTload(ckt); - if(error) return(error); - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - - if (ckt->CKTkeepOpInfo) { - /* Dump operating point. */ - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, "AC Operating Point", - (IFuid)NULL,IF_REAL,numNames,nameList, IF_REAL,&plot); - if(error) return(error); - CKTdump(ckt,(double)0,plot); - (*(SPfrontEnd->OUTendPlot))(plot); - } - - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, - ckt->CKTcurJob->JOBname,freqUid,IF_REAL,numNames,nameList, - IF_COMPLEX,&acPlot); - if(error) return(error); - - if (((ACAN*)ckt->CKTcurJob)->ACstepType != LINEAR) { - (*(SPfrontEnd->OUTattributes))((void *)acPlot,NULL, - OUT_SCALE_LOG, NULL); - } - freq = ((ACAN*)ckt->CKTcurJob)->ACstartFreq; - - } else { /* continue previous analysis */ - freq = ((ACAN*)ckt->CKTcurJob)->ACsaveFreq; - ((ACAN*)ckt->CKTcurJob)->ACsaveFreq = 0; /* clear the 'old' frequency */ - } - switch(((ACAN*)ckt->CKTcurJob)->ACstepType) { - case DECADE: - case OCTAVE: - freqTol = ((ACAN*)ckt->CKTcurJob)->ACfreqDelta * - ((ACAN*)ckt->CKTcurJob)->ACstopFreq * ckt->CKTreltol; - break; - case LINEAR: - freqTol = ((ACAN*)ckt->CKTcurJob)->ACfreqDelta * ckt->CKTreltol; - break; - default: - return(E_BADPARM); - } - - startTime = SPfrontEnd->IFseconds(); - startdTime = ckt->CKTstat->STATdecompTime; - startsTime = ckt->CKTstat->STATsolveTime; - startlTime = ckt->CKTstat->STATloadTime; - startcTime = ckt->CKTstat->STATcombineTime; - startkTime = ckt->CKTstat->STATsyncTime; - while(freq <= ((ACAN*)ckt->CKTcurJob)->ACstopFreq+freqTol) { - - if( (*(SPfrontEnd->IFpauseTest))() ) { - /* user asked us to pause via an interrupt */ - ((ACAN*)ckt->CKTcurJob)->ACsaveFreq = freq; - return(E_PAUSE); - } - ckt->CKTomega = 2.0 * M_PI *freq; - ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODEAC; - - error = NIacIter(ckt); - if (error) { - ckt->CKTcurrentAnalysis = DOING_AC; - ckt->CKTstat->STATacTime += SPfrontEnd->IFseconds() - startTime; - ckt->CKTstat->STATacDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATacSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATacLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATacCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATacSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; - return(error); - } - - - -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&ACSEN) ){ - - save = ckt->CKTmode; - ckt->CKTmode=(ckt->CKTmode&MODEUIC)|MODEDCOP|MODEINITSMSIG; - save1 = ckt->CKTsenInfo->SENmode; - ckt->CKTsenInfo->SENmode = ACSEN; - if(freq == ((ACAN*)ckt->CKTcurJob)->ACstartFreq){ - ckt->CKTsenInfo->SENacpertflag = 1; - } - else{ - ckt->CKTsenInfo->SENacpertflag = 0; - } - if(error = CKTsenAC(ckt)) return (error); - ckt->CKTmode = save; - ckt->CKTsenInfo->SENmode = save1; - } -#endif - - error = CKTacDump(ckt,freq,acPlot); - if (error) { - ckt->CKTcurrentAnalysis = DOING_AC; - ckt->CKTstat->STATacTime += SPfrontEnd->IFseconds() - startTime; - ckt->CKTstat->STATacDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATacSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATacLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATacCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATacSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; - return(error); - } - - /* increment frequency */ - - switch(((ACAN*)ckt->CKTcurJob)->ACstepType) { - case DECADE: - case OCTAVE: - freq *= ((ACAN*)ckt->CKTcurJob)->ACfreqDelta; - if(((ACAN*)ckt->CKTcurJob)->ACfreqDelta==1) goto endsweep; - break; - case LINEAR: - freq += ((ACAN*)ckt->CKTcurJob)->ACfreqDelta; - if(((ACAN*)ckt->CKTcurJob)->ACfreqDelta==0) goto endsweep; - break; - default: - return(E_INTERN); - } - } -endsweep: - (*(SPfrontEnd->OUTendPlot))(acPlot); - ckt->CKTcurrentAnalysis = 0; - ckt->CKTstat->STATacTime += SPfrontEnd->IFseconds() - startTime; - ckt->CKTstat->STATacDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATacSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATacLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATacCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATacSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; - return(0); -} - - - /* CKTacLoad(ckt) - * this is a driver program to iterate through all the various - * ac load functions provided for the circuit elements in the - * given circuit - */ - - -int -CKTacLoad(register CKTcircuit *ckt) -{ - extern SPICEdev *DEVices[]; - register int i; - register int size; - int error; -#ifdef PARALLEL_ARCH - long type = MT_ACLOAD, length = 1; -#endif /* PARALLEL_ARCH */ - double startTime; - - startTime = SPfrontEnd->IFseconds(); - size = SMPmatSize(ckt->CKTmatrix); - for (i=0;i<=size;i++) { - *(ckt->CKTrhs+i)=0; - *(ckt->CKTirhs+i)=0; - } - SMPcClear(ckt->CKTmatrix); - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVacLoad))(ckt->CKThead[i],ckt); -#ifdef PARALLEL_ARCH - if (error) goto combine; -#else - if(error) return(error); -#endif /* PARALLEL_ARCH */ - } - } -#ifdef PARALLEL_ARCH -combine: - ckt->CKTstat->STATloadTime += SPfrontEnd->IFseconds() - startTime; - startTime = SPfrontEnd->IFseconds(); - /* See if any of the DEVload functions bailed. If not, proceed. */ - IGOP_( &type, &error, &length, "max" ); - ckt->CKTstat->STATsyncTime += SPfrontEnd->IFseconds() - startTime; - if (error == OK) { - startTime = SPfrontEnd->IFseconds(); - SMPcCombine( ckt->CKTmatrix, ckt->CKTrhs, ckt->CKTrhsSpare, - ckt->CKTirhs, ckt->CKTirhsSpare ); - ckt->CKTstat->STATcombineTime += SPfrontEnd->IFseconds() - startTime; - return(OK); - } else { - return(error); - } -#else - ckt->CKTstat->STATloadTime += SPfrontEnd->IFseconds() - startTime; - return(OK); -#endif /* PARALLEL_ARCH */ -} diff --git a/src/analysis/acaskq.c b/src/analysis/acaskq.c deleted file mode 100644 index cf2136187..000000000 --- a/src/analysis/acaskq.c +++ /dev/null @@ -1,63 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "acdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -ACaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case AC_START: - value->rValue = ((ACAN*)anal)->ACstartFreq; - break; - - case AC_STOP: - value->rValue = ((ACAN*)anal)->ACstopFreq ; - break; - - case AC_STEPS: - value->iValue = ((ACAN*)anal)->ACnumberSteps; - break; - - case AC_DEC: - if(((ACAN*)anal)->ACstepType == DECADE) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case AC_OCT: - if(((ACAN*)anal)->ACstepType == OCTAVE) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case AC_LIN: - if(((ACAN*)anal)->ACstepType == LINEAR) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - default: - return(E_BADPARM); - } - return(OK); -} - diff --git a/src/analysis/acsetp.c b/src/analysis/acsetp.c deleted file mode 100644 index d4bb6e47b..000000000 --- a/src/analysis/acsetp.c +++ /dev/null @@ -1,105 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "acdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -ACsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case AC_START: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid"); - ((ACAN*)anal)->ACstartFreq = 1.0; - return(E_PARMVAL); - } - - ((ACAN*)anal)->ACstartFreq = value->rValue; - break; - - case AC_STOP: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid"); - ((ACAN*)anal)->ACstartFreq = 1.0; - return(E_PARMVAL); - } - - ((ACAN*)anal)->ACstopFreq = value->rValue; - break; - - case AC_STEPS: - ((ACAN*)anal)->ACnumberSteps = value->iValue; - break; - - case AC_DEC: - if(value->iValue) { - ((ACAN*)anal)->ACstepType = DECADE; - } else { - if( ((ACAN*)anal)->ACstepType == DECADE) { - ((ACAN*)anal)->ACstepType = 0; - } - } - break; - - case AC_OCT: - if(value->iValue) { - ((ACAN*)anal)->ACstepType = OCTAVE; - } else { - if( ((ACAN*)anal)->ACstepType == OCTAVE) { - ((ACAN*)anal)->ACstepType = 0; - } - } - break; - - case AC_LIN: - if(value->iValue) { - ((ACAN*)anal)->ACstepType = LINEAR; - } else { - if( ((ACAN*)anal)->ACstepType == LINEAR) { - ((ACAN*)anal)->ACstepType = 0; - } - } - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm ACparms[] = { - { "start", AC_START, IF_SET|IF_ASK|IF_REAL, "starting frequency" }, - { "stop", AC_STOP, IF_SET|IF_ASK|IF_REAL, "ending frequency" }, - { "numsteps", AC_STEPS,IF_SET|IF_ASK|IF_INTEGER, "number of frequencies"}, - { "dec", AC_DEC, IF_SET|IF_FLAG, "step by decades" }, - { "oct", AC_OCT, IF_SET|IF_FLAG, "step by octaves" }, - { "lin", AC_LIN, IF_SET|IF_FLAG, "step linearly" } -}; - -SPICEanalysis ACinfo = { - { - "AC", - "A.C. Small signal analysis", - - sizeof(ACparms)/sizeof(IFparm), - ACparms - }, - sizeof(ACAN), - FREQUENCYDOMAIN, - 1, - ACsetParm, - ACaskQuest, - NULL, - ACan -}; diff --git a/src/analysis/ckt.h b/src/analysis/ckt.h deleted file mode 100644 index 301002e9e..000000000 --- a/src/analysis/ckt.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1985 Thomas L. Quarles - * Modified 1999 Paolo Nenzi - Removed non STDC definitions - * Kept only prototypes (structs defined in struct.h) ER - */ - - -#ifndef CKT_H_INCLUDED -#define CKT_H_INCLUDED - - -/* function prototypes */ - -int ACan( CKTcircuit *, int ); -int ACaskQuest( CKTcircuit *, void *, int , IFvalue *); -int ACsetParm( CKTcircuit *, void *, int , IFvalue *); -int CKTacDump( CKTcircuit *, double , void *); -int CKTacLoad( CKTcircuit *); -int CKTaccept( CKTcircuit *); -int CKTacct( CKTcircuit *, void *, int , IFvalue *); -int CKTask( void *, void *, int , IFvalue *, IFvalue *); -int CKTaskAnalQ( void *, void *, int , IFvalue *, IFvalue *); -int CKTaskNodQst( void *, void *, int , IFvalue *, IFvalue *); -int CKTbindNode( void *, void *, int , void *); -void CKTbreakDump( CKTcircuit *); -int CKTclrBreak( CKTcircuit *); -int CKTconvTest( CKTcircuit *); -int CKTcrtElt( void *, void *, void **, IFuid ); -int CKTdelTask( void *, void *); -int CKTdestroy( void *); -int CKTdltAnal( void *, void *, void *); -int CKTdltInst( void *, void *); -int CKTdltMod( void *, void *); -int CKTdltNod( void *, void *); -int CKTdoJob( void *, int , void *); -void CKTdump( CKTcircuit *, double, void *); -int CKTfndAnal( void *, int *, void **, IFuid , void *, IFuid ); -int CKTfndBranch( CKTcircuit *, IFuid); -int CKTfndDev( void *, int *, void **, IFuid , void *, IFuid ); -int CKTfndMod( void *, int *, void **, IFuid ); -int CKTfndNode( void *, void **, IFuid ); -int CKTfndTask( void *, void **, IFuid ); -int CKTground( void *, void **, IFuid ); -int CKTic( CKTcircuit *); -int CKTinit( void **); -int CKTinst2Node( void *, void *, int , void **, IFuid *); -int CKTlinkEq(CKTcircuit*,CKTnode*); -int CKTload( CKTcircuit *); -int CKTmapNode( void *, void **, IFuid ); -int CKTmkCur( CKTcircuit *, CKTnode **, IFuid , char *); -int CKTmkNode(CKTcircuit*,CKTnode**); -int CKTmkVolt( CKTcircuit *, CKTnode **, IFuid , char *); -int CKTmodAsk( void *, void *, int , IFvalue *, IFvalue *); -int CKTmodCrt( void *, int , void **, IFuid ); -int CKTmodParam( void *, void *, int , IFvalue *, IFvalue *); -int CKTnames(CKTcircuit *, int *, IFuid **); -int CKTnewAnal( void *, int , IFuid , void **, void *); -int CKTnewEq( void *, void **, IFuid ); -int CKTnewNode( void *, void **, IFuid ); -int CKTnewTask( void *, void **, IFuid ); -IFuid CKTnodName( CKTcircuit *, int ); -void CKTnodOut( CKTcircuit *); -CKTnode * CKTnum2nod( CKTcircuit *, int ); -int CKTop(CKTcircuit *, long, long, int ); -int CKTpModName( char *, IFvalue *, CKTcircuit *, int , IFuid , GENmodel **); -int CKTpName( char *, IFvalue *, CKTcircuit *, int , char *, GENinstance **); -int CKTparam( void *, void *, int , IFvalue *, IFvalue *); -int CKTpzFindZeros( CKTcircuit *, PZtrial **, int * ); -int CKTpzLoad( CKTcircuit *, SPcomplex * ); -int CKTpzSetup( CKTcircuit *, int); -int CKTsenAC( CKTcircuit *); -int CKTsenComp( CKTcircuit *); -int CKTsenDCtran( CKTcircuit *); -int CKTsenLoad( CKTcircuit *); -void CKTsenPrint( CKTcircuit *); -int CKTsenSetup( CKTcircuit *); -int CKTsenUpdate( CKTcircuit *); -int CKTsetAnalPm( void *, void *, int , IFvalue *, IFvalue *); -int CKTsetBreak( CKTcircuit *, double ); -int CKTsetNodPm( void *, void *, int , IFvalue *, IFvalue *); -int CKTsetOpt( void *, void *, int , IFvalue *); -int CKTsetup( CKTcircuit *); -int CKTunsetup(CKTcircuit *ckt); -int CKTtemp( CKTcircuit *); -char *CKTtrouble(void *, char *); -void CKTterr( int , CKTcircuit *, double *); -int CKTtrunc( CKTcircuit *, double *); -int CKTtypelook( char *); -int DCOaskQuest( CKTcircuit *, void *, int , IFvalue *); -int DCOsetParm( CKTcircuit *, void *, int , IFvalue *); -int DCTaskQuest( CKTcircuit *, void *, int , IFvalue *); -int DCTsetParm( CKTcircuit *, void *, int , IFvalue *); -int DCop( CKTcircuit *); -int DCtrCurv( CKTcircuit *, int ); -int DCtran( CKTcircuit *, int ); -int DISTOan(CKTcircuit *, int); -int NOISEan(CKTcircuit *, int); -int PZan( CKTcircuit *, int ); -int PZinit( CKTcircuit * ); -int PZpost( CKTcircuit * ); -int PZaskQuest( CKTcircuit *, void *, int , IFvalue *); -int PZsetParm( CKTcircuit *, void *, int , IFvalue *); -int SENaskQuest( CKTcircuit *, void *, int , IFvalue *); -void SENdestroy( SENstruct *); -int SENsetParm( CKTcircuit *, void *, int , IFvalue *); -int SENstartup( CKTcircuit *); -int SPIinit( IFfrontEnd *, IFsimulator **); -char * SPerror( int ); -int TFanal( CKTcircuit *, int ); -int TFaskQuest( CKTcircuit *, void *, int , IFvalue *); -int TFsetParm( CKTcircuit *, void *, int , IFvalue *); -int TRANaskQuest( CKTcircuit *, void *, int , IFvalue *); -int TRANsetParm( CKTcircuit *, void *, int , IFvalue *); -int TRANinit(CKTcircuit *, JOB *); -int NIacIter( CKTcircuit * ); -int NIcomCof( CKTcircuit * ); -int NIconvTest(CKTcircuit * ); -void NIdestroy(CKTcircuit * ); -int NIinit( CKTcircuit * ); -int NIintegrate( CKTcircuit *, double *, double *, double , int ); -int NIiter( CKTcircuit * , int ); -int NIpzMuller(PZtrial **, PZtrial *); -int NIpzComplex(PZtrial **, PZtrial *); -int NIpzSym(PZtrial **, PZtrial *); -int NIpzSym2(PZtrial **, PZtrial *); -int NIreinit( CKTcircuit *); -int NIsenReinit( CKTcircuit *); -IFfrontEnd *SPfrontEnd; - -#endif /*CKT*/ diff --git a/src/analysis/cktaccpt.c b/src/analysis/cktaccpt.c deleted file mode 100644 index fddbc5739..000000000 --- a/src/analysis/cktaccpt.c +++ /dev/null @@ -1,47 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* CKTaccept(ckt) - * this is a driver program to iterate through all the various - * accept functions provided for the circuit elements in the - * given circuit - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -int -CKTaccept(register CKTcircuit *ckt) -{ - extern SPICEdev *DEVices[]; - - register int i; - int error; - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVaccept))(ckt,ckt->CKThead[i]); - if(error) return(error); - } - } -#ifdef PREDICTOR - /* now, move the sols vectors around */ - temp = ckt->CKTsols[7]; - for ( i=7;i>0;i--) { - ckt->CKTsols[i] = ckt->CKTsols[i-1]; - } - ckt->CKTsols[0]=temp; - size = SMPmatSize(ckt->CKTmatrix); - for(i=0;i<=size;i++) { - ckt->CKTsols[0][i]=ckt->CKTrhs[i]; - } -#endif /* PREDICTOR */ - return(OK); -} diff --git a/src/analysis/cktacct.c b/src/analysis/cktacct.c deleted file mode 100644 index 3c83d6565..000000000 --- a/src/analysis/cktacct.c +++ /dev/null @@ -1,142 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* - * CKTacct - * get the specified accounting item into 'value' in the - * given circuit 'ckt'. - */ - -#include "ngspice.h" -#include "const.h" -#include "optdefs.h" -#include "ifsim.h" -#include -#include "cktdefs.h" -#include "spmatrix.h" - - - -/* ARGSUSED */ -int -CKTacct(CKTcircuit *ckt, void *anal, int which, IFvalue *val) -{ - switch(which) { - - case OPT_EQNS: - val->iValue = ckt->CKTmaxEqNum; - break; - case OPT_ORIGNZ: - if ( ckt->CKTmatrix != NULL ) { - val->iValue = spOriginalCount((char *)ckt->CKTmatrix); - } else { - val->iValue = 0; - } - break; - case OPT_FILLNZ: - if ( ckt->CKTmatrix != NULL ) { - val->iValue = spFillinCount((char *)ckt->CKTmatrix); - } else { - val->iValue = 0; - } - break; - case OPT_TOTALNZ: - if ( ckt->CKTmatrix != NULL ) { - val->iValue = spElementCount((char *)ckt->CKTmatrix); - } else { - val->iValue = 0; - } - break; - case OPT_ITERS: - val->iValue = ckt->CKTstat->STATnumIter; - break; - case OPT_TRANIT: - val->iValue = ckt->CKTstat->STATtranIter; - break; - case OPT_TRANCURITER: - val->iValue = ckt->CKTstat->STATnumIter - ckt->CKTstat->STAToldIter; - break; - case OPT_TRANPTS: - val->iValue = ckt->CKTstat->STATtimePts; - break; - case OPT_TRANACCPT: - val->iValue = ckt->CKTstat->STATaccepted; - break; - case OPT_TRANRJCT: - val->iValue = ckt->CKTstat->STATrejected; - break; - case OPT_TOTANALTIME: - val->rValue = ckt->CKTstat->STATtotAnalTime; - break; - case OPT_TRANTIME: - val->rValue = ckt->CKTstat->STATtranTime; - break; - case OPT_ACTIME: - val->rValue = ckt->CKTstat->STATacTime; - break; - case OPT_LOADTIME: - val->rValue = ckt->CKTstat->STATloadTime; - break; - case OPT_SYNCTIME: - val->rValue = ckt->CKTstat->STATsyncTime; - break; - case OPT_COMBTIME: - val->rValue = ckt->CKTstat->STATcombineTime; - break; - case OPT_REORDTIME: - val->rValue = ckt->CKTstat->STATreorderTime; - break; - case OPT_DECOMP: - val->rValue = ckt->CKTstat->STATdecompTime; - break; - case OPT_SOLVE: - val->rValue = ckt->CKTstat->STATsolveTime; - break; - case OPT_TRANLOAD: - val->rValue = ckt->CKTstat->STATtranLoadTime; - break; - case OPT_TRANSYNC: - val->rValue = ckt->CKTstat->STATtranSyncTime; - break; - case OPT_TRANCOMB: - val->rValue = ckt->CKTstat->STATtranCombTime; - break; - case OPT_TRANDECOMP: - val->rValue = ckt->CKTstat->STATtranDecompTime; - break; - case OPT_TRANSOLVE: - val->rValue = ckt->CKTstat->STATtranSolveTime; - break; - case OPT_TRANTRUNC: - val->rValue = ckt->CKTstat->STATtranTruncTime; - break; - case OPT_ACLOAD: - val->rValue = ckt->CKTstat->STATacLoadTime; - break; - case OPT_ACSYNC: - val->rValue = ckt->CKTstat->STATacSyncTime; - break; - case OPT_ACCOMB: - val->rValue = ckt->CKTstat->STATacCombTime; - break; - case OPT_ACDECOMP: - val->rValue = ckt->CKTstat->STATacDecompTime; - break; - case OPT_ACSOLVE: - val->rValue = ckt->CKTstat->STATacSolveTime; - break; - case OPT_TEMP: - val->rValue = ckt->CKTtemp - CONSTCtoK; - break; - case OPT_TNOM: - val->rValue = ckt->CKTnomTemp - CONSTCtoK; - break; - default: - return(-1); - } - return(0); -} diff --git a/src/analysis/cktacdum.c b/src/analysis/cktacdum.c deleted file mode 100644 index 590ee65c8..000000000 --- a/src/analysis/cktacdum.c +++ /dev/null @@ -1,43 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTacDump(ckt,freq,file) - * this is a simple program to dump the complex rhs vector - * into the rawfile. - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "iferrmsg.h" -#include "ifsim.h" - - - -int -CKTacDump(register CKTcircuit *ckt, double freq, void *plot) -{ - register double *rhsold; - register double *irhsold; - register int i; - register IFcomplex *data; - IFvalue freqData; - IFvalue valueData; - - rhsold = ckt->CKTrhsOld; - irhsold = ckt->CKTirhsOld; - freqData.rValue = freq; - valueData.v.numValue = ckt->CKTmaxEqNum-1; - data = (IFcomplex *) MALLOC((ckt->CKTmaxEqNum-1)*sizeof(IFcomplex)); - valueData.v.vec.cVec = data; - for (i=0;iCKTmaxEqNum-1;i++) { - data[i].real = rhsold[i+1]; - data[i].imag = irhsold[i+1]; - } - (*(SPfrontEnd->OUTpData))(plot,&freqData,&valueData); - FREE(data); - return(OK); -} diff --git a/src/analysis/cktask.c b/src/analysis/cktask.c deleted file mode 100644 index f9230ca00..000000000 --- a/src/analysis/cktask.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTask - * Ask questions about a specified device. - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "devdefs.h" -#include "sperror.h" - - -extern SPICEdev *DEVices[]; - -int -CKTask(void *ckt, void *fast, int which, IFvalue *value, IFvalue *selector) -{ - register int type = ((GENinstance *)fast)->GENmodPtr->GENmodType; - int error; -#ifdef PARALLEL_ARCH - long msgtype, length; - long from = ((GENinstance *)fast)->GENowner; -#endif /* PARALLEL_ARCH */ - - if((*DEVices[type]).DEVask) { - error = DEVices[type]->DEVask((CKTcircuit *)ckt, - (GENinstance *)fast,which,value,selector); - } else { - error = E_BADPARM; - } -#ifdef PARALLEL_ARCH - msgtype = MT_ASK; - length = sizeof(IFvalue); - BRDCST_(&msgtype, (char *)value, &length, &from); - msgtype++; - length = sizeof(int); - BRDCST_(&msgtype, (char *)&error, &length, &from); -#endif /* PARALLEL_ARCH */ - return(error); -} diff --git a/src/analysis/cktaskaq.c b/src/analysis/cktaskaq.c deleted file mode 100644 index 68ebb5ec5..000000000 --- a/src/analysis/cktaskaq.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "tskdefs.h" -#include "jobdefs.h" -#include "cktdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" - - -extern SPICEanalysis *analInfo[]; - -/* ARGSUSED */ -int -CKTaskAnalQ(void *ckt, void *analPtr, int parm, IFvalue *value, IFvalue *selector) -{ - register int type = ((JOB *)analPtr)->JOBtype; - - if((analInfo[type]->askQuest) == NULL) return(E_BADPARM); - return( (*(analInfo[type]->askQuest))((CKTcircuit*)ckt,analPtr,parm,value)); -} diff --git a/src/analysis/cktasknq.c b/src/analysis/cktasknq.c deleted file mode 100644 index ad568521f..000000000 --- a/src/analysis/cktasknq.c +++ /dev/null @@ -1,43 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - *CKTaskNodQst - * - * ask about a parameter on a node. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTaskNodQst(void *ckt, void *node, int parm, IFvalue *value, IFvalue *selector) -{ - if(!node) return(E_BADPARM); - switch(parm) { - - case PARM_NS: - value->rValue = ((CKTnode *)node)->nodeset; - break; - - case PARM_IC: - value->rValue = ((CKTnode *)node)->ic; - break; - - case PARM_NODETYPE: - value->iValue = ((CKTnode *)node)->type; - break; - - default: - return(E_BADPARM); - } - return(OK); -} diff --git a/src/analysis/cktbindn.c b/src/analysis/cktbindn.c deleted file mode 100644 index b77e1da67..000000000 --- a/src/analysis/cktbindn.c +++ /dev/null @@ -1,54 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* CKTbindNode - * bind a node of the specified device of the given type to its place - * in the specified circuit. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -extern SPICEdev *DEVices[]; - -/*ARGSUSED*/ -int -CKTbindNode(void *ckt, void *fast, int term, void *node) -{ - int mappednode; - register int type = ((GENinstance *)fast)->GENmodPtr->GENmodType; - - mappednode = ((CKTnode *)node)->number; - - if(*((*DEVices[type]).DEVpublic.terms) >= term && term >0 ) { - switch(term) { - default: return(E_NOTERM); - case 1: - ((GENinstance *)fast)->GENnode1 = mappednode; - break; - case 2: - ((GENinstance *)fast)->GENnode2 = mappednode; - break; - case 3: - ((GENinstance *)fast)->GENnode3 = mappednode; - break; - case 4: - ((GENinstance *)fast)->GENnode4 = mappednode; - break; - case 5: - ((GENinstance *)fast)->GENnode5 = mappednode; - break; - } - return(OK); - } else { - return(E_NOTERM); - } -} diff --git a/src/analysis/cktbkdum.c b/src/analysis/cktbkdum.c deleted file mode 100644 index 265695928..000000000 --- a/src/analysis/cktbkdum.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTbreakDump(ckt) - dump the breakpoint table associated with - * the given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" - - - -void -CKTbreakDump(CKTcircuit *ckt) -{ - register int i; - for(i=0;iCKTbreakSize;i++) { - (void)printf("breakpoint table entry %d is %g\n",i,*(ckt->CKTbreaks+i)); - } -} diff --git a/src/analysis/cktclrbk.c b/src/analysis/cktclrbk.c deleted file mode 100644 index 36bbe9cc0..000000000 --- a/src/analysis/cktclrbk.c +++ /dev/null @@ -1,39 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTclrBreak(ckt) - * delete the first time from the breakpoint table for the given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "sperror.h" - - - -int -CKTclrBreak(register CKTcircuit *ckt) -{ - double *tmp; - register int j; - - if(ckt->CKTbreakSize >2) { - tmp = (double *)MALLOC((ckt->CKTbreakSize-1)*sizeof(double)); - if(tmp == (double *)NULL) return(E_NOMEM); - for(j=1;jCKTbreakSize;j++) { - *(tmp+j-1) = *(ckt->CKTbreaks+j); - } - FREE(ckt->CKTbreaks); - ckt->CKTbreakSize--; - ckt->CKTbreaks=tmp; - } else { - *(ckt->CKTbreaks)= *(ckt->CKTbreaks+1); - *(ckt->CKTbreaks+1) = ckt->CKTfinalTime; - } - return(OK); -} diff --git a/src/analysis/cktcrte.c b/src/analysis/cktcrte.c deleted file mode 100644 index d1cbb034e..000000000 --- a/src/analysis/cktcrte.c +++ /dev/null @@ -1,47 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTcrtElement(ckt,type,inModPtr,inInstPtr,name,subname) - * Create a device of the specified type, with the given name, using - * the specified model in the named circuit. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - - -/*ARGSUSED*/ -int -CKTcrtElt(void *ckt, void *inModPtr, void **inInstPtr, IFuid name) -{ - GENinstance *instPtr = NULL; - GENmodel *modPtr=(GENmodel*)inModPtr; - extern SPICEdev *DEVices[]; - int error; - int type; - - if((GENmodel *)modPtr==(GENmodel*)NULL) return(E_NOMOD); - type = ((GENmodel*)modPtr)->GENmodType; - error =CKTfndDev(ckt,&type,(void**)&instPtr,name,inModPtr,(char *)NULL ); - if (error== OK) { - if(inInstPtr) *inInstPtr=(void *)instPtr; - return(E_EXISTS); - } else if (error != E_NODEV) return(error); - instPtr = (GENinstance *)MALLOC(*DEVices[type]->DEVinstSize); - if(instPtr == (GENinstance *)NULL) return(E_NOMEM); - instPtr->GENname = name; - instPtr->GENmodPtr = modPtr; - instPtr->GENnextInstance = modPtr->GENinstances; - modPtr->GENinstances = instPtr; - if(inInstPtr != NULL) *inInstPtr = (void *)instPtr; - return(OK); -} diff --git a/src/analysis/cktdelt.c b/src/analysis/cktdelt.c deleted file mode 100644 index baa39e850..000000000 --- a/src/analysis/cktdelt.c +++ /dev/null @@ -1,27 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "tskdefs.h" -#include "jobdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" - - -/* ARGSUSED */ -int -CKTdelTask(void *ckt, void *task) -{ - JOB *job; - JOB *old=NULL; - for(job = ((TSKtask*)task)->jobs; job; job=job->JOBnextJob){ - if(old) FREE(old); - old=job; - } - if(old)FREE(old); - FREE(task); - return(OK); -} diff --git a/src/analysis/cktdest.c b/src/analysis/cktdest.c deleted file mode 100644 index ead8f3541..000000000 --- a/src/analysis/cktdest.c +++ /dev/null @@ -1,61 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTdestroy(ckt) - * this is a driver program to iterate through all the various - * destroy functions provided for the circuit elements in the - * given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "devdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; -int -CKTdestroy(void *inCkt) -{ - register CKTcircuit *ckt = (CKTcircuit *)inCkt; - register int i; - register CKTnode *node; - register CKTnode *nnode; - - -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo){ - if(ckt->CKTrhsOp) FREE(ckt->CKTrhsOp); - if(ckt->CKTsenRhs) FREE(ckt->CKTsenRhs); - if(ckt->CKTseniRhs) FREE(ckt->CKTseniRhs); - SENdestroy(ckt->CKTsenInfo); - } -#endif - - for (i=0;iCKThead[i] != NULL) ){ - (*((*DEVices[i]).DEVdestroy))(&(ckt->CKThead[i])); - } - } - for(i=0;i<=ckt->CKTmaxOrder+1;i++){ - FREE(ckt->CKTstates[i]); - } - if(ckt->CKTmatrix) SMPdestroy(ckt->CKTmatrix); - if(ckt->CKTbreaks) FREE(ckt->CKTbreaks); - for(node = ckt->CKTnodes; node; ) { - nnode = node->next; - FREE(node); - node = nnode; - } - ckt->CKTnodes = (CKTnode *)NULL; - ckt->CKTlastNode = (CKTnode *)NULL; - FREE(ckt); - return(OK); -} diff --git a/src/analysis/cktdisto.c b/src/analysis/cktdisto.c deleted file mode 100644 index dbdf42153..000000000 --- a/src/analysis/cktdisto.c +++ /dev/null @@ -1,177 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jaijeet S Roychowdhury -**********/ - -/* - * CKTdisto (ckt, mode) - */ - - -#include "ngspice.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "vsrc/vsrcdefs.h" -#include "isrc/isrcdefs.h" -#include "fteconst.h" -#include "iferrmsg.h" -#include "distodef.h" -#include "sperror.h" -#include - - -int -CKTdisto (register CKTcircuit *ckt, int mode) -{ - extern SPICEdev *DEVices[]; - register DISTOAN* cv = (DISTOAN*) (ckt->CKTcurJob); - register int i; - int error=0; - int size; - - switch(mode) { - - case D_SETUP: - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVdisto))(mode,ckt->CKThead[i],ckt); - if(error) return(error); - } - } - break; - - case D_TWOF1: - case D_THRF1: - case D_F1PF2: - case D_F1MF2: - case D_2F1MF2: - - size = SMPmatSize(ckt->CKTmatrix); - for (i=1; i<=size; i++) - { - ckt->CKTrhs[i] = 0.0; - ckt->CKTirhs[i] = 0.0; - } - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVdisto))(mode,ckt->CKThead[i],ckt); - if(error) return(error); - } - } - break; - - case D_RHSF1: - - cv->Df2given = 0; /* will change if any F2 source is found */ - - case D_RHSF2: - - - -{ - int vcode; - int icode; - double mag=0.0; - double phase=0.0; - int size; - - size = SMPmatSize(ckt->CKTmatrix); - for (i=0;i<=size;i++) { - *(ckt->CKTrhs+i)=0; - *(ckt->CKTirhs+i)=0; - } - - vcode = CKTtypelook("Vsource"); - icode = CKTtypelook("Isource"); - - - if(vcode >= 0) { - /* voltage sources are in this version, so use them */ - register VSRCinstance *here; - register VSRCmodel *model; - for(model = (VSRCmodel *)ckt->CKThead[vcode];model != NULL; - model=model->VSRCnextModel){ - for(here=model->VSRCinstances;here!=NULL; - here=here->VSRCnextInstance) { - -/* check if the source has a distortion input*/ - -if (here->VSRCdGiven) { - if (here->VSRCdF2given) cv->Df2given = 1; - if ((here->VSRCdF1given) && (mode == D_RHSF1)) { - - mag = here->VSRCdF1mag; - phase = here->VSRCdF1phase; -} -else if ((here->VSRCdF2given) && (mode == D_RHSF2)) { - - mag = here->VSRCdF2mag; - phase = here->VSRCdF2phase; -} -if (((here->VSRCdF1given) && (mode == D_RHSF1)) || - ((here->VSRCdF2given) && (mode == D_RHSF2))) { - - *(ckt->CKTrhs + here->VSRCbranch) = 0.5*mag* cos(M_PI*phase/180.0); - *(ckt->CKTirhs + here->VSRCbranch) = 0.5*mag*sin(M_PI*phase/180.0); -} - - - } - } - } - } - if(icode >= 0 ) { - /* current sources are in this version, so use them */ - register ISRCinstance *here; - register ISRCmodel *model; - - for(model= (ISRCmodel *)ckt->CKThead[icode];model != NULL; - model=model->ISRCnextModel){ - for(here=model->ISRCinstances;here!=NULL; - here=here->ISRCnextInstance) { - -/* check if the source has a distortion input*/ - -if (here->ISRCdGiven) { - if (here->ISRCdF2given) cv->Df2given = 1; - if ((here->ISRCdF1given) && (mode == D_RHSF1)) { - - mag = here->ISRCdF1mag; - phase = here->ISRCdF1phase; -} -else if ((here->ISRCdF2given) && (mode == D_RHSF2)) { - - mag = here->ISRCdF2mag; - phase = here->ISRCdF2phase; -} -if (((here->ISRCdF1given) && (mode == D_RHSF1)) || - ((here->ISRCdF2given) && (mode == D_RHSF2))) { - - *(ckt->CKTrhs + here->ISRCposNode) = - 0.5 * mag - * cos(M_PI*phase/180.0); - *(ckt->CKTrhs + here->ISRCnegNode) = 0.5 * mag * cos( - M_PI*phase/180.0); - *(ckt->CKTirhs + here->ISRCposNode) = - 0.5 * mag * sin( - M_PI*phase/180.0); - *(ckt->CKTirhs + here->ISRCnegNode) = 0.5 * mag * sin( - M_PI*phase/180.0); -} - } - } - } - } -} -error = 0; -break; - - default: - - error = E_BADPARM; - break; - } - - return(error); - -} diff --git a/src/analysis/cktdlti.c b/src/analysis/cktdlti.c deleted file mode 100644 index ac07253c8..000000000 --- a/src/analysis/cktdlti.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTdltInst - * delete the specified instance - not yet supported in spice - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -/* ARGSUSED */ -int -CKTdltInst(void *ckt, void *instance) -{ - return(E_UNSUPP); -} diff --git a/src/analysis/cktdltm.c b/src/analysis/cktdltm.c deleted file mode 100644 index 17e763da6..000000000 --- a/src/analysis/cktdltm.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* CKTdltMod - * delete the specified model - not yet supported in spice - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -/* ARGSUSED */ -int -CKTdltMod(void *cktp, void *modPtr) -{ - CKTcircuit *ckt = (CKTcircuit *) cktp; - GENmodel *m = (GENmodel *) modPtr, *mod, **prevp; - GENinstance *h, *next_i; - int error; - - prevp = &ckt->CKThead[m->GENmodType]; - for (mod = *prevp; m && mod != m; mod = mod->GENnextModel) - prevp = &mod->GENnextModel; - - if (!mod) - return OK; - - *prevp = m->GENnextModel; - - for (h = m->GENinstances; h; h = next_i) { - next_i = h->GENnextInstance; - error = (*(SPfrontEnd->IFdelUid))((void *)ckt,h->GENname, - UID_INSTANCE); - tfree(h); - } - error = (*(SPfrontEnd->IFdelUid))((void *)ckt,m->GENmodName, UID_MODEL); - tfree(m); - return(OK); -} diff --git a/src/analysis/cktdltn.c b/src/analysis/cktdltn.c deleted file mode 100644 index c76e2ff30..000000000 --- a/src/analysis/cktdltn.c +++ /dev/null @@ -1,59 +0,0 @@ -/********** -Copyright 1992 Regents of the University of California. All rights reserved. -**********/ - -/* CKTdltNod -*/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - -int CKTdltNNum(void *cktp, int num); - -/* ARGSUSED */ -int -CKTdltNod(void *ckt, void *node) -{ - return CKTdltNNum(ckt, ((CKTnode *) node)->number); -} - -int -CKTdltNNum(void *cktp, int num) -{ - CKTcircuit *ckt = (CKTcircuit *) cktp; - CKTnode *n, *prev, *node, *sprev; - int error; - - prev = NULL; - node = NULL; - sprev = NULL; - - for (n = ckt->CKTnodes; n; n = n->next) { - if (n->number == num) { - node = n; - sprev = prev; - } - prev = n; - } - - if (!node) - return OK; - - ckt->CKTmaxEqNum -= 1; - - if (!sprev) { - ckt->CKTnodes = node->next; - } else { - sprev->next = node->next; - } - if (node == ckt->CKTlastNode) - ckt->CKTlastNode = sprev; - - error = (*(SPfrontEnd->IFdelUid))((void *)ckt,node->name, UID_SIGNAL); - tfree(node); - - return error; -} diff --git a/src/analysis/cktdojob.c b/src/analysis/cktdojob.c deleted file mode 100644 index 5a124e915..000000000 --- a/src/analysis/cktdojob.c +++ /dev/null @@ -1,146 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include "cktdefs.h" -#include -#include "sperror.h" -#include "trandefs.h" - - -extern SPICEanalysis *analInfo[]; -extern int ANALmaxnum; - -int -CKTdoJob(void *inCkt, int reset, void *inTask) -{ - CKTcircuit *ckt = (CKTcircuit *)inCkt; - TSKtask *task = (TSKtask *)inTask; - JOB *job; - double startTime; - int error, i, error2; - -#ifdef WANT_SENSE2 - int senflag; - static int sens_num = -1; - - /* Sensitivity is special */ - if (sens_num < 0) { - for (i = 0; i < ANALmaxnum; i++) - if (!strcmp("SENS2", analInfo[i]->public.name)) - break; - sens_num = i; - } -#endif - - startTime = (*(SPfrontEnd->IFseconds))( ); - - ckt->CKTtemp = task->TSKtemp; - ckt->CKTnomTemp = task->TSKnomTemp; - ckt->CKTmaxOrder = task->TSKmaxOrder; - ckt->CKTintegrateMethod = task->TSKintegrateMethod; - ckt->CKTbypass = task->TSKbypass; - ckt->CKTdcMaxIter = task->TSKdcMaxIter; - ckt->CKTdcTrcvMaxIter = task->TSKdcTrcvMaxIter; - ckt->CKTtranMaxIter = task->TSKtranMaxIter; - ckt->CKTnumSrcSteps = task->TSKnumSrcSteps; - ckt->CKTnumGminSteps = task->TSKnumGminSteps; - ckt->CKTminBreak = task->TSKminBreak; - ckt->CKTabstol = task->TSKabstol; - ckt->CKTpivotAbsTol = task->TSKpivotAbsTol; - ckt->CKTpivotRelTol = task->TSKpivotRelTol; - ckt->CKTreltol = task->TSKreltol; - ckt->CKTchgtol = task->TSKchgtol; - ckt->CKTvoltTol = task->TSKvoltTol; - ckt->CKTgmin = task->TSKgmin; - ckt->CKTdelmin = task->TSKdelmin; - ckt->CKTtrtol = task->TSKtrtol; - ckt->CKTdefaultMosL = task->TSKdefaultMosL; - ckt->CKTdefaultMosW = task->TSKdefaultMosW; - ckt->CKTdefaultMosAD = task->TSKdefaultMosAD; - ckt->CKTdefaultMosAS = task->TSKdefaultMosAS; - ckt->CKTfixLimit = task->TSKfixLimit; - ckt->CKTnoOpIter = task->TSKnoOpIter; - ckt->CKTtryToCompact = task->TSKtryToCompact; - ckt->CKTbadMos3 = task->TSKbadMos3; - ckt->CKTkeepOpInfo = task->TSKkeepOpInfo; - ckt->CKTtroubleNode = 0; - ckt->CKTtroubleElt = NULL; -#ifdef NEWTRUNC - ckt->CKTlteReltol = task->TSKlteReltol; - ckt->CKTlteAbstol = task->TSKlteAbstol; -#endif /* NEWTRUNC */ - - error = 0; - - if (reset) { - - ckt->CKTdelta = 0.0; - ckt->CKTtime = 0.0; - ckt->CKTcurrentAnalysis = 0; - -#ifdef WANT_SENSE2 - senflag = 0; - if (sens_num < ANALmaxnum) - for (job = task->jobs; !error && job; job = job->JOBnextJob) { - if (job->JOBtype == sens_num) { - senflag = 1; - ckt->CKTcurJob = job; - ckt->CKTsenInfo = (SENstruct *) job; - error = (*(analInfo[sens_num]->an_func))(ckt, reset); - } - } - - if (ckt->CKTsenInfo && (!senflag || error)) - FREE(ckt->CKTsenInfo); -#endif - - /* normal reset */ - if (!error) - error = CKTunsetup(ckt); - if (!error) - error = CKTsetup(ckt); - if (!error) - error = CKTtemp(ckt); - if (error) - return error; - } - - error2 = OK; - - /* Analysis order is important */ - for (i = 0; i < ANALmaxnum; i++) { - -#ifdef WANT_SENSE2 - if (i == sens_num) - continue; -#endif - - for (job = task->jobs; job; job = job->JOBnextJob) { - if (job->JOBtype == i) { - ckt->CKTcurJob=job; - error = OK; - if (analInfo[i]->an_init) - error = (*(analInfo[i]->an_init))(ckt, job); - if (!error && analInfo[i]->do_ic) - error = CKTic(ckt); - if (!error) - error = (*(analInfo[i]->an_func))(ckt, reset); - if (error) - error2 = error; - } - } - } - - ckt->CKTstat->STATtotAnalTime += (*(SPfrontEnd->IFseconds))( ) - startTime; - -#ifdef WANT_SENSE2 - if (ckt->CKTsenInfo) - SENdestroy(ckt->CKTsenInfo); -#endif - - return(error2); -} - diff --git a/src/analysis/cktdump.c b/src/analysis/cktdump.c deleted file mode 100644 index 75ee9657d..000000000 --- a/src/analysis/cktdump.c +++ /dev/null @@ -1,29 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTdump(ckt) - * this is a simple program to dump the rhs vector to stdout - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" - - - -void -CKTdump(register CKTcircuit *ckt, double ref, void *plot) -{ - IFvalue refData; - IFvalue valData; - - refData.rValue = ref; - valData.v.numValue = ckt->CKTmaxEqNum-1; - valData.v.vec.rVec = ckt->CKTrhsOld+1; - (*(SPfrontEnd->OUTpData))(plot,&refData,&valData); -} diff --git a/src/analysis/cktfbran.c b/src/analysis/cktfbran.c deleted file mode 100644 index c9ea291ac..000000000 --- a/src/analysis/cktfbran.c +++ /dev/null @@ -1,36 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTfndBranch(ckt,name) - * this is a driver program to iterate through all the various - * findBranch functions provided for the circuit elements in the - * given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "devdefs.h" - - - -int -CKTfndBranch(register CKTcircuit *ckt, IFuid name) -{ - extern SPICEdev *DEVices[]; - - register int i; - int j; - - for (i=0;iCKThead[i] != NULL) { - j = (*((*DEVices[i]).DEVfindBranch))(ckt,ckt->CKThead[i],name); - if(j != 0) return(j); - } - } - return(0); -} diff --git a/src/analysis/cktfdev.c b/src/analysis/cktfdev.c deleted file mode 100644 index fd8109a8c..000000000 --- a/src/analysis/cktfdev.c +++ /dev/null @@ -1,86 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cktdefs.h" -#include "sperror.h" - - - -int -CKTfndDev(void *Ckt, int *type, void **fast, IFuid name, void *modfast, IFuid modname) -{ - register CKTcircuit *ckt=(CKTcircuit *)Ckt; - register GENinstance *here; - register GENmodel *mods; - - if((GENinstance **)fast != (GENinstance **)NULL && - *(GENinstance **)fast != (GENinstance *)NULL) { - /* already have fast, so nothing much to do */ - /* just get & set type */ - if(type) *type = (*((GENinstance**)fast))->GENmodPtr->GENmodType; - return(OK); - } - if(modfast) { - /* have model, just need device */ - mods = (GENmodel*)modfast; - for(here = mods->GENinstances ; here != NULL; - here = here->GENnextInstance) { - if (here->GENname == name) { - if(fast != NULL) *(GENinstance **)fast = here; - if(type) *type = mods->GENmodType; - return(OK); - } - } - return(E_NODEV); - } - if(*type >=0 && *type < DEVmaxnum) { - /* have device type, need to find model & device */ - /* look through all models */ - for(mods=(GENmodel *)ckt->CKThead[*type]; mods != NULL ; - mods = mods->GENnextModel) { - /* and all instances */ - if(modname == (char *)NULL || mods->GENmodName == modname) { - for(here = mods->GENinstances ; here != NULL; - here = here->GENnextInstance) { - if (here->GENname == name) { - if(fast != 0) *(GENinstance **)fast = here; - return(OK); - } - } - if(mods->GENmodName == modname) { - return(E_NODEV); - } - } - } - return(E_NOMOD); - } else if(*type == -1) { - /* look through all types (UGH - worst case - take forever) */ - for(*type = 0;*type CKThead[*type];mods!=NULL; - mods = mods->GENnextModel) { - /* and all instances */ - if(modname == (char *)NULL || mods->GENmodName == modname) { - for(here = mods->GENinstances ; here != NULL; - here = here->GENnextInstance) { - if (here->GENname == name) { - if(fast != 0) *(GENinstance **)fast = here; - return(OK); - } - } - if(mods->GENmodName == modname) { - return(E_NODEV); - } - } - } - } - *type = -1; - return(E_NODEV); - } else return(E_BADPARM); -} diff --git a/src/analysis/cktfnda.c b/src/analysis/cktfnda.c deleted file mode 100644 index 4b3fb3189..000000000 --- a/src/analysis/cktfnda.c +++ /dev/null @@ -1,36 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTfndAnal - * find the given Analysis given its name and return the Analysis pointer - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "jobdefs.h" -#include "tskdefs.h" -#include "sperror.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTfndAnal(void *ckt, int *analIndex, void **anal, IFuid name, void *inTask, IFuid taskName) -{ - TSKtask *task = (TSKtask *)inTask; - register JOB *here; - - for (here = ((TSKtask *)task)->jobs;here;here = here->JOBnextJob) { - if(strcmp(here->JOBname,name)==0) { - if(anal) *anal = (void *)here; - return(OK); - } - } - return(E_NOTFOUND); -} diff --git a/src/analysis/cktfndm.c b/src/analysis/cktfndm.c deleted file mode 100644 index 452952924..000000000 --- a/src/analysis/cktfndm.c +++ /dev/null @@ -1,53 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -int -CKTfndMod(void *ckt, int *type, void **modfast, IFuid modname) -{ - register GENmodel *mods; - - if(modfast != NULL && *(GENmodel **)modfast != NULL) { - /* already have modfast, so nothing to do */ - if(type) *type = (*(GENmodel **)modfast)->GENmodType; - return(OK); - } - if(*type >=0 && *type < DEVmaxnum) { - /* have device type, need to find model */ - /* look through all models */ - for(mods=((CKTcircuit *)ckt)->CKThead[*type]; mods != NULL ; - mods = mods->GENnextModel) { - if(mods->GENmodName == modname) { - *modfast = (char *)mods; - return(OK); - } - } - return(E_NOMOD); - } else if(*type == -1) { - /* look through all types (UGH - worst case - take forever) */ - for(*type = 0;*type CKThead[*type];mods!=NULL; - mods = mods->GENnextModel) { - if(mods->GENmodName == modname) { - *modfast = (char *)mods; - return(OK); - } - } - } - *type = -1; - return(E_NOMOD); - } else return(E_BADPARM); -} diff --git a/src/analysis/cktfnode.c b/src/analysis/cktfnode.c deleted file mode 100644 index 8cc3d8f34..000000000 --- a/src/analysis/cktfnode.c +++ /dev/null @@ -1,33 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTfndNode - * find the given node given its name and return the node pointer - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "sperror.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTfndNode(void *ckt, void **node, IFuid name) -{ - register CKTnode *here; - - for (here = ((CKTcircuit *)ckt)->CKTnodes; here; here = here->next) { - if(here->name == name) { - if(node) *node = (char *)here; - return(OK); - } - } - return(E_NOTFOUND); -} diff --git a/src/analysis/cktftask.c b/src/analysis/cktftask.c deleted file mode 100644 index d5186845b..000000000 --- a/src/analysis/cktftask.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTfndTask - * find the specified task - not yet supported in spice - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -/* ARGSUSED */ -int -CKTfndTask(void *ckt, void **taskPtr, IFuid taskName) -{ - return(E_UNSUPP); -} diff --git a/src/analysis/cktgrnd.c b/src/analysis/cktgrnd.c deleted file mode 100644 index b154dc085..000000000 --- a/src/analysis/cktgrnd.c +++ /dev/null @@ -1,46 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTground(ckt,node) - * specify the node to be the ground node of the given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -int -CKTground(void *inCkt, void **node, IFuid name) -{ - register CKTcircuit *ckt = (CKTcircuit *)inCkt; - - if(ckt->CKTnodes) { - if(ckt->CKTnodes->name) { - /*already exists - keep old name, but return it */ - if(node)*node = (char *)ckt->CKTnodes; - return(E_EXISTS); - } - ckt->CKTnodes->name = name; - ckt->CKTnodes->type = SP_VOLTAGE; - ckt->CKTnodes->number = 0; - } else { - ckt->CKTnodes = (CKTnode *)MALLOC(sizeof(CKTnode)); - if(ckt->CKTnodes == NULL) return(E_NOMEM); - ckt->CKTnodes->name = name; - ckt->CKTnodes->type = SP_VOLTAGE; - ckt->CKTnodes->number = 0; - ckt->CKTnodes->next = (CKTnode *)NULL; - ckt->CKTlastNode = ckt->CKTnodes; - } - if(node)*node = (char *)ckt->CKTnodes; - return(OK); - -} diff --git a/src/analysis/ckti2nod.c b/src/analysis/ckti2nod.c deleted file mode 100644 index 6726e21c1..000000000 --- a/src/analysis/ckti2nod.c +++ /dev/null @@ -1,66 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTinst2Node - * get the name and node pointer for a node given a device it is - * bound to and the terminal of the device. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "sperror.h" -#include "cktdefs.h" -#include "gendefs.h" -#include "devdefs.h" - - - -extern SPICEdev *DEVices[]; - -int -CKTinst2Node(void *ckt, void *instPtr, int terminal, void **node, IFuid *nodeName) -{ - int nodenum; - register int type; - CKTnode *here; - - type = ((GENinstance *)instPtr)->GENmodPtr->GENmodType; - - if(*((*DEVices[type]).DEVpublic.terms) >= terminal && terminal >0 ) { - switch(terminal) { - default: return(E_NOTERM); - case 1: - nodenum = ((GENinstance *)instPtr)->GENnode1; - break; - case 2: - nodenum = ((GENinstance *)instPtr)->GENnode2; - break; - case 3: - nodenum = ((GENinstance *)instPtr)->GENnode3; - break; - case 4: - nodenum = ((GENinstance *)instPtr)->GENnode4; - break; - case 5: - nodenum = ((GENinstance *)instPtr)->GENnode5; - break; - } - /* ok, now we know its number, so we just have to find it.*/ - for(here = ((CKTcircuit*)ckt)->CKTnodes;here;here = here->next) { - if(here->number == nodenum) { - /* found it */ - *node = (void*) here; - *nodeName = here->name; - return(OK); - } - } - return(E_NOTFOUND); - } else { - return(E_NOTERM); - } -} diff --git a/src/analysis/cktic.c b/src/analysis/cktic.c deleted file mode 100644 index 8bf0f03d8..000000000 --- a/src/analysis/cktic.c +++ /dev/null @@ -1,57 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "smpdefs.h" -#include "sperror.h" -#include "devdefs.h" - - - -extern SPICEdev *DEVices[]; - -int -CKTic(CKTcircuit *ckt) -{ - int error; - int size; - int i; - CKTnode *node; - - size = SMPmatSize(ckt->CKTmatrix); - for (i=0;i<=size;i++) { - *(ckt->CKTrhs+i)=0; - } - - for(node = ckt->CKTnodes;node != NULL; node = node->next) { - if(node->nsGiven) { - node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number); - if(node->ptr == (double *)NULL) return(E_NOMEM); - ckt->CKThadNodeset = 1; - *(ckt->CKTrhs+node->number) = node->nodeset; - } - if(node->icGiven) { - if(! ( node->ptr)) { - node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number, - node->number); - if(node->ptr == (double *)NULL) return(E_NOMEM); - } - *(ckt->CKTrhs+node->number) = node->ic; - } - } - - if(ckt->CKTmode & MODEUIC) { - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVsetic))(ckt->CKThead[i],ckt); - if(error) return(error); - } - } - } - - return(OK); -} diff --git a/src/analysis/cktinit.c b/src/analysis/cktinit.c deleted file mode 100644 index c796ef697..000000000 --- a/src/analysis/cktinit.c +++ /dev/null @@ -1,66 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cktdefs.h" -#include "const.h" -#include "sperror.h" - - -int -CKTinit(void **ckt) - /* new circuit to create */ -{ - register int i; - register CKTcircuit *sckt; - - sckt = (CKTcircuit *)( *ckt = (char *)MALLOC(sizeof(CKTcircuit)) ); - if(sckt == NULL) return(E_NOMEM); - for (i=0;iCKThead[i] = (GENmodel *) NULL; - } - (sckt)->CKTmaxEqNum = 1; - (sckt)->CKTnodes = (CKTnode *)NULL; - (sckt)->CKTlastNode = (CKTnode *)NULL; - sckt->CKTmatrix = NULL; -#ifdef notdef - error = NIinit(sckt); - if(error) return(error); -#endif - - (sckt)->CKTgmin = 1e-12; - (sckt)->CKTabstol = 1e-12; - (sckt)->CKTreltol = 1e-3; - (sckt)->CKTchgtol = 1e-14; - (sckt)->CKTvoltTol = 1e-6; - (sckt)->CKTtrtol = 7; - (sckt)->CKTbypass = 1; - (sckt)->CKTisSetup = 0; - (sckt)->CKTtranMaxIter = 10; - (sckt)->CKTdcMaxIter = 100; - (sckt)->CKTdcTrcvMaxIter = 50; - (sckt)->CKTintegrateMethod = TRAPEZOIDAL; - (sckt)->CKTorder = 1; - (sckt)->CKTmaxOrder = 2; - (sckt)->CKTpivotAbsTol = 1e-13; - (sckt)->CKTpivotRelTol = 1e-3; - (sckt)->CKTtemp = 300.15; - (sckt)->CKTnomTemp = 300.15; - (sckt)->CKTdefaultMosL = 1e-4; - (sckt)->CKTdefaultMosW = 1e-4; - (sckt)->CKTdefaultMosAD = 0; - (sckt)->CKTdefaultMosAS = 0; - (sckt)->CKTsrcFact=1; - (sckt)->CKTdiagGmin=0; - (sckt)->CKTstat = (STATistics *)MALLOC(sizeof(STATistics)); - (sckt)->CKTtroubleNode = 0; - (sckt)->CKTtroubleElt = NULL; - (sckt)->CKTtimePoints = NULL; - if( (sckt)->CKTstat == (STATistics *)NULL) return(E_NOMEM); - - return(OK); -} diff --git a/src/analysis/cktlnkeq.c b/src/analysis/cktlnkeq.c deleted file mode 100644 index ae9f65286..000000000 --- a/src/analysis/cktlnkeq.c +++ /dev/null @@ -1,36 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - *CKTlinkEq - * Link an already allocated node into the necessary structure - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "smpdefs.h" -#include "cktdefs.h" - - -int -CKTlinkEq(CKTcircuit *ckt, CKTnode *node) -{ - if(!(ckt->CKTnodes)) { /* starting the list - allocate both ground and 1 */ - ckt->CKTnodes = (CKTnode *) MALLOC(sizeof(CKTnode)); - if(ckt->CKTnodes == (CKTnode *)NULL) return(E_NOMEM); - ckt->CKTnodes->name = (char *)NULL; - ckt->CKTnodes->type = SP_VOLTAGE; - ckt->CKTnodes->number = 0; - ckt->CKTlastNode = ckt->CKTnodes; - } - if(node == (CKTnode *)NULL) return(E_BADPARM); - ckt->CKTlastNode->next = node; - ckt->CKTlastNode = ckt->CKTlastNode->next; - ckt->CKTlastNode->number = ckt->CKTmaxEqNum++; - ckt->CKTlastNode->next = (CKTnode *)NULL; - return(OK); -} diff --git a/src/analysis/cktload.c b/src/analysis/cktload.c deleted file mode 100644 index bdab4f964..000000000 --- a/src/analysis/cktload.c +++ /dev/null @@ -1,166 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTload(ckt) - * this is a driver program to iterate through all the various - * load functions provided for the circuit elements in the - * given circuit - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -static int ZeroNoncurRow(SMPmatrix *matrix, CKTnode *nodes, int rownum); - -int -CKTload(register CKTcircuit *ckt) -{ - extern SPICEdev *DEVices[]; - register int i; - register int size; - double startTime; - CKTnode *node; - int error; -#ifdef PARALLEL_ARCH - int ibuf[2]; - long type = MT_LOAD, length = 2; -#endif /* PARALLEL_ARCH */ -#ifdef STEPDEBUG - int noncon; -#endif /* STEPDEBUG */ - - startTime = (*(SPfrontEnd->IFseconds))(); - size = SMPmatSize(ckt->CKTmatrix); - for (i=0;i<=size;i++) { - *(ckt->CKTrhs+i)=0; - } - SMPclear(ckt->CKTmatrix); -#ifdef STEPDEBUG - noncon = ckt->CKTnoncon; -#endif /* STEPDEBUG */ - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVload))(ckt->CKThead[i],ckt); - if (ckt->CKTnoncon) - ckt->CKTtroubleNode = 0; -#ifdef STEPDEBUG - if(noncon != ckt->CKTnoncon) { - printf("device type %s nonconvergence\n", - (*DEVices[i]).DEVpublic.name); - noncon = ckt->CKTnoncon; - } -#endif /* STEPDEBUG */ -#ifdef PARALLEL_ARCH - if (error) goto combine; -#else - if(error) return(error); -#endif /* PARALLEL_ARCH */ - } - } - if(ckt->CKTmode & MODEDC) { - /* consider doing nodeset & ic assignments */ - if(ckt->CKTmode & (MODEINITJCT | MODEINITFIX)) { - /* do nodesets */ - for(node=ckt->CKTnodes;node;node=node->next) { - if(node->nsGiven) { - if (ZeroNoncurRow(ckt->CKTmatrix, ckt->CKTnodes, - node->number)) - { - *(ckt->CKTrhs+node->number) = 1.0e10 * node->nodeset; - *(node->ptr) = 1e10; - } else { - *(ckt->CKTrhs+node->number) = node->nodeset; - *(node->ptr) = 1; - } - /* DAG: Original CIDER fix. If above fix doesn't work, - * revert to this. - */ - /* - *(ckt->CKTrhs+node->number) += 1.0e10 * node->nodeset; - *(node->ptr) += 1.0e10; - */ - } - } - } - if( (ckt->CKTmode & MODETRANOP) && (!(ckt->CKTmode & MODEUIC))) { - for(node=ckt->CKTnodes;node;node=node->next) { - if(node->icGiven) { - if (ZeroNoncurRow(ckt->CKTmatrix, ckt->CKTnodes, - node->number)) - { - *(ckt->CKTrhs+node->number) += 1.0e10 * node->ic; - *(node->ptr) += 1.0e10; - } else { - *(ckt->CKTrhs+node->number) = node->ic; - *(node->ptr) = 1; - } - /* DAG: Original CIDER fix. If above fix doesn't work, - * revert to this. - */ - /* - *(ckt->CKTrhs+node->number) += 1.0e10 * node->ic; - *(node->ptr) += 1.0e10; - */ - } - } - } - } - /* SMPprint(ckt->CKTmatrix, stdout); if you want to debug, this is a - good place to start ... */ - -#ifdef PARALLEL_ARCH -combine: - ckt->CKTstat->STATloadTime += SPfrontEnd->IFseconds() - startTime; - startTime = SPfrontEnd->IFseconds(); - /* See if any of the DEVload functions bailed. If not, proceed. */ - ibuf[0] = error; - ibuf[1] = ckt->CKTnoncon; - IGOP_( &type, ibuf, &length, "+" ); - ckt->CKTnoncon = ibuf[1]; - ckt->CKTstat->STATsyncTime += SPfrontEnd->IFseconds() - startTime; - if (ibuf[0] == OK) { - startTime = SPfrontEnd->IFseconds(); - SMPcombine( ckt->CKTmatrix, ckt->CKTrhs, ckt->CKTrhsSpare ); - ckt->CKTstat->STATcombineTime += SPfrontEnd->IFseconds() - startTime; - return(OK); - } else { - if ( ibuf[0] != error ) { - error = E_MULTIERR; - } - return(error); - } -#else - ckt->CKTstat->STATloadTime += SPfrontEnd->IFseconds()-startTime; - return(OK); -#endif /* PARALLEL_ARCH */ -} - -static int -ZeroNoncurRow(SMPmatrix *matrix, CKTnode *nodes, int rownum) -{ - CKTnode *n; - double *x; - int currents; - - currents = 0; - for (n = nodes; n; n = n->next) { - x = (double *) SMPfindElt(matrix, rownum, n->number, 0); - if (x) { - if (n->type == SP_CURRENT) - currents = 1; - else - *x = 0.0; - } - } - return currents; -} diff --git a/src/analysis/cktmapn.c b/src/analysis/cktmapn.c deleted file mode 100644 index 61077ea98..000000000 --- a/src/analysis/cktmapn.c +++ /dev/null @@ -1,51 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTmapNode(ckt,node) - * map the given node to the compact node numbering set of the - * specified circuit - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "sperror.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTmapNode(void *ckt, void **node, IFuid name) -{ - register CKTnode *here; - int error; - IFuid uid; - CKTnode *mynode; - - for (here = ((CKTcircuit *)ckt)->CKTnodes; here; here = here->next) { - if(here->name == name) { - if(node) *node = (char *)here; - return(E_EXISTS); - } - } - /* not found, so must be a new one */ - error = CKTmkNode((CKTcircuit*)ckt,&mynode); /*allocate the node*/ - if(error) return(error); - error = (*(SPfrontEnd->IFnewUid))((void *)ckt, - &uid, - (IFuid) NULL, - name, - UID_SIGNAL, - (void**)mynode); /* get a uid for it */ - if(error) return(error); - mynode->name = uid; /* set the info we have */ - mynode->type = SP_VOLTAGE; - error = CKTlinkEq((CKTcircuit*)ckt,mynode); /* and link it in */ - if(node) *node = (void *)mynode; /* and finally, return it */ - return(OK); -} diff --git a/src/analysis/cktmask.c b/src/analysis/cktmask.c deleted file mode 100644 index 8a27c21e8..000000000 --- a/src/analysis/cktmask.c +++ /dev/null @@ -1,30 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTmodAsk - * Ask questions about a specified device. - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "devdefs.h" -#include "sperror.h" - - -extern SPICEdev *DEVices[]; - -/* ARGSUSED */ -int -CKTmodAsk(void *ckt, void *modfast, int which, IFvalue *value, IFvalue *selector) -{ - int type = ((GENmodel *)modfast)->GENmodType; - if((*DEVices[type]).DEVmodAsk) { - return( (*((*DEVices[type]).DEVmodAsk)) ((CKTcircuit *)ckt, - (GENmodel *)modfast,which,value) ); - } - return(E_BADPARM); -} diff --git a/src/analysis/cktmcrt.c b/src/analysis/cktmcrt.c deleted file mode 100644 index 73fb7d76a..000000000 --- a/src/analysis/cktmcrt.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTmodCrt(type,name,ckt,fast) - * Create a device model of the specified type, with the given name - * in the named circuit. - */ - -#include "ngspice.h" -#include -#include "devdefs.h" -#include "cktdefs.h" -#include "sperror.h" - - - -int -CKTmodCrt(void *ckt, int type, void **modfast, IFuid name) -{ - extern SPICEdev *DEVices[]; - GENmodel *mymodfast = NULL; - int error; - - error = CKTfndMod(ckt,&type,(void**)&mymodfast,name); - if(error == E_NOMOD) { - mymodfast = (GENmodel *)MALLOC(*DEVices[type]->DEVmodSize); - if(mymodfast == (GENmodel *)NULL) return(E_NOMEM); - mymodfast->GENmodType = type; - mymodfast->GENmodName = name; - mymodfast->GENnextModel =(GENmodel *)((CKTcircuit *)ckt)->CKThead[type]; - ((CKTcircuit *)ckt)->CKThead[type]=(GENmodel *)mymodfast; - if(modfast) *modfast=(void *)mymodfast; - return(OK); - } else if (error==0) { - if(modfast) *modfast=(void *)mymodfast; - return(E_EXISTS); - } else { - return(error); - } - /*NOTREACHED*/ -} diff --git a/src/analysis/cktmkcur.c b/src/analysis/cktmkcur.c deleted file mode 100644 index 1c5d4b834..000000000 --- a/src/analysis/cktmkcur.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTmkCur - * make the given name a 'node' of type current in the - * specified circuit - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "sperror.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTmkCur(CKTcircuit *ckt, CKTnode **node, IFuid basename, char *suffix) -{ - IFuid uid; - int error; - CKTnode *mynode; - CKTnode *checknode; - - error = CKTmkNode(ckt,&mynode); - if(error) return(error); - checknode = mynode; - error = (*(SPfrontEnd->IFnewUid))((void *)ckt,&uid,basename, - suffix,UID_SIGNAL,(void**)&checknode); - if(error) { - FREE(mynode); - if(node) *node = checknode; - return(error); - } - mynode->name = uid; - mynode->type = SP_CURRENT; - if(node) *node = mynode; - error = CKTlinkEq(ckt,mynode); - return(error); -} diff --git a/src/analysis/cktmknod.c b/src/analysis/cktmknod.c deleted file mode 100644 index ac916fab5..000000000 --- a/src/analysis/cktmknod.c +++ /dev/null @@ -1,32 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - *CKTmkNode(ckt,node) - * Tentatively allocate a new circuit equation structure - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "smpdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -CKTmkNode(CKTcircuit *ckt, CKTnode **node) -{ - CKTnode *mynode; - - mynode = (CKTnode *)MALLOC(sizeof(CKTnode)); - if(mynode == (CKTnode *)NULL) return(E_NOMEM); - mynode->next = (CKTnode *)NULL; - mynode->name = (IFuid) 0; - - if(node) *node = mynode; - return(OK); -} diff --git a/src/analysis/cktmkvol.c b/src/analysis/cktmkvol.c deleted file mode 100644 index 72b15484c..000000000 --- a/src/analysis/cktmkvol.c +++ /dev/null @@ -1,43 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* CKTmkVolt - * make the given name a 'node' of type current in the - * specified circuit - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "sperror.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTmkVolt(CKTcircuit *ckt, CKTnode **node, IFuid basename, char *suffix) -{ - IFuid uid; - int error; - CKTnode *mynode; - CKTnode *checknode; - - error = CKTmkNode(ckt,&mynode); - if(error) return(error); - checknode = mynode; - error = (*(SPfrontEnd->IFnewUid))((void *)ckt,&uid,basename, - suffix,UID_SIGNAL,(void**)&checknode); - if(error) { - FREE(mynode); - if(node) *node = checknode; - return(error); - } - mynode->name = uid; - mynode->type = SP_VOLTAGE; - if(node) *node = mynode; - error = CKTlinkEq(ckt,mynode); - return(error); -} diff --git a/src/analysis/cktmpar.c b/src/analysis/cktmpar.c deleted file mode 100644 index 232db4d88..000000000 --- a/src/analysis/cktmpar.c +++ /dev/null @@ -1,32 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTmodParam - * attach the given parameter to the specified model in the given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "devdefs.h" -#include "sperror.h" - - -extern SPICEdev *DEVices[]; - -/* ARGSUSED */ -int -CKTmodParam(void *ckt, void *modfast, int param, IFvalue *val, IFvalue *selector) -{ - register int type = ((GENmodel *)modfast)->GENmodType; - - if (((*DEVices[type]).DEVmodParam)) { - return(((*((*DEVices[type]).DEVmodParam)) (param,val, - (GENmodel *)modfast))); - } else { - return(E_BADPARM); - } -} diff --git a/src/analysis/cktnames.c b/src/analysis/cktnames.c deleted file mode 100644 index da0afb9b6..000000000 --- a/src/analysis/cktnames.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - - /* - * CKTnames(ckt) - * output information on all circuit nodes/equations - * - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" - - -int -CKTnames(register CKTcircuit *ckt, int *numNames, register IFuid **nameList) -{ - register CKTnode *here; - register int i; - *numNames = ckt->CKTmaxEqNum-1; - *nameList = (IFuid *)MALLOC(*numNames * sizeof(IFuid )); - if ((*nameList) == (IFuid *)NULL) return(E_NOMEM); - i=0; - for (here = ckt->CKTnodes->next; here; here = here->next) { - *((*nameList)+i++) = here->name; - } - return(OK); -} - -int -CKTdnames(CKTcircuit *ckt) -{ - CKTnode *here; - register int i; - - i=0; - for (here = ckt->CKTnodes->next; here; here = here->next) { - printf("%03d: %s\n", here->number, (char *)here->name); - } - return(OK); -} diff --git a/src/analysis/cktnewan.c b/src/analysis/cktnewan.c deleted file mode 100644 index 63e10fe29..000000000 --- a/src/analysis/cktnewan.c +++ /dev/null @@ -1,34 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "tskdefs.h" -#include "jobdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" - - -extern SPICEanalysis *analInfo[]; - -/* ARGSUSED */ -int -CKTnewAnal(void *ckt, int type, IFuid name, void **analPtr, void *taskPtr) -{ - if(type==0) { - /* special case for analysis type 0 == option card */ - *analPtr=taskPtr; /* pointer to the task itself */ - (*(JOB **)analPtr)->JOBname = name; - (*(JOB **)analPtr)->JOBtype = type; - return(OK); /* doesn't need to be created */ - } - *analPtr = (void *)MALLOC(analInfo[type]->size); - if(*analPtr==NULL) return(E_NOMEM); - (*(JOB **)analPtr)->JOBname = name; - (*(JOB **)analPtr)->JOBtype = type; - (*(JOB **)analPtr)->JOBnextJob = ((TSKtask *)taskPtr)->jobs; - ((TSKtask *)taskPtr)->jobs = (JOB *)*analPtr; - return(OK); -} diff --git a/src/analysis/cktneweq.c b/src/analysis/cktneweq.c deleted file mode 100644 index 86009cb0f..000000000 --- a/src/analysis/cktneweq.c +++ /dev/null @@ -1,38 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - *CKTnewEq(ckt,node,name) - * Allocate a new circuit equation number (returned) in the specified - * circuit to contain a new equation or node - * returns -1 for failure to allocate a node number - * - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "smpdefs.h" -#include "cktdefs.h" - - -int -CKTnewEq(void *inCkt, void **node, IFuid name) -{ - CKTnode *mynode; - register CKTcircuit *ckt = (CKTcircuit *)inCkt; - int error; - - error = CKTmkNode(ckt,&mynode); - if(error) return(error); - - if(node) *node = (void *)mynode; - mynode->name = name; - - error = CKTlinkEq(ckt,mynode); - - return(error); -} diff --git a/src/analysis/cktnewn.c b/src/analysis/cktnewn.c deleted file mode 100644 index 2b5505fd0..000000000 --- a/src/analysis/cktnewn.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - *CKTnewNode(ckt,node,name) - * Allocate a new circuit equation number (returned) in the specified - * circuit to contain a new equation or node - * returns -1 for failure to allocate a node number - * - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "smpdefs.h" -#include "cktdefs.h" - - -/* should just call CKTnewEQ and set node type afterwards */ -int -CKTnewNode(void *inCkt, void **node, IFuid name) -{ - register CKTcircuit *ckt = (CKTcircuit *)inCkt; - if(!(ckt->CKTnodes)) { /* starting the list - allocate both ground and 1 */ - ckt->CKTnodes = (CKTnode *) MALLOC(sizeof(CKTnode)); - if(ckt->CKTnodes == (CKTnode *)NULL) return(E_NOMEM); - ckt->CKTnodes->name = (char *)NULL; - ckt->CKTnodes->type = SP_VOLTAGE; - ckt->CKTnodes->number = 0; - ckt->CKTlastNode = ckt->CKTnodes; - } - ckt->CKTlastNode->next = (CKTnode *)MALLOC(sizeof(CKTnode)); - if(ckt->CKTlastNode->next == (CKTnode *)NULL) return(E_NOMEM); - ckt->CKTlastNode = ckt->CKTlastNode->next; - ckt->CKTlastNode->name = name; - ckt->CKTlastNode->number = ckt->CKTmaxEqNum++; - ckt->CKTlastNode->type = SP_VOLTAGE; - ckt->CKTlastNode->next = (CKTnode *)NULL; - - if(node) *node = (void *)ckt->CKTlastNode; - return(OK); -} diff --git a/src/analysis/cktnodn.c b/src/analysis/cktnodn.c deleted file mode 100644 index 14f6db467..000000000 --- a/src/analysis/cktnodn.c +++ /dev/null @@ -1,33 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* - *CKTnodName(ckt) - * output information on all circuit nodes/equations - * - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" - - - -IFuid -CKTnodName(CKTcircuit *ckt, register int nodenum) -{ - register CKTnode *here; - - for(here = ckt->CKTnodes;here; here = here->next) { - if(here->number == nodenum) { - /* found it */ - return(here->name); - } - } - /* doesn't exist - do something */ - return("UNKNOWN NODE"); -} diff --git a/src/analysis/cktnoise.c b/src/analysis/cktnoise.c deleted file mode 100644 index 6e51d1e0f..000000000 --- a/src/analysis/cktnoise.c +++ /dev/null @@ -1,140 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Gary W. Ng -**********/ - -/* - * CKTnoise (ckt, mode, operation, data) - * - * This routine is responsible for naming and evaluating all of the - * noise sources in the circuit. It uses a series of subroutines to - * name and evaluate the sources associated with each model, and then - * it evaluates the noise for the entire circuit. - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "devdefs.h" -#include "fteconst.h" -#include "iferrmsg.h" -#include "noisedef.h" -#include "sperror.h" - - -int -CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data) -{ - double outNdens; - int i; - extern SPICEdev *DEVices[]; - IFvalue outData; /* output variable (points to list of outputs)*/ - IFvalue refVal; /* reference variable (always 0)*/ - int error; - - outNdens = 0.0; - - /* let each device decide how many and what type of noise sources it has */ - - for (i=0; i < DEVmaxnum; i++) { - if ( ((*DEVices[i]).DEVnoise != NULL) && (ckt->CKThead[i] != NULL) ) { - error = (*((*DEVices[i]).DEVnoise))(mode,operation,ckt->CKThead[i], - ckt,data, &outNdens); - if (error) return (error); - } - } - - switch (operation) { - - case N_OPEN: - - /* take care of the noise for the circuit as a whole */ - - switch (mode) { - - case N_DENS: - - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); - - (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), - (IFuid)NULL,"onoise_spectrum",UID_OTHER,(void **)NULL); - - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); - - (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), - (IFuid)NULL,"inoise_spectrum",UID_OTHER,(void **)NULL); - - /* we've added two more plots */ - - data->outpVector = - (double *)MALLOC(data->numPlots * sizeof(double)); - break; - - case INT_NOIZ: - - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); - (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), - (IFuid)NULL,"onoise_total",UID_OTHER,(void **)NULL); - - data->namelist = (IFuid *)trealloc((char *)data->namelist, - (data->numPlots + 1)*sizeof(IFuid)); - (*(SPfrontEnd->IFnewUid))(ckt, &(data->namelist[data->numPlots++]), - (IFuid)NULL,"inoise_total",UID_OTHER,(void **)NULL); - /* we've added two more plots */ - - data->outpVector = - (double *) MALLOC(data->numPlots * sizeof(double)); - break; - - default: - return (E_INTERN); - } - - break; - - case N_CALC: - - switch (mode) { - - case N_DENS: - if ((((NOISEAN*)ckt->CKTcurJob)->NStpsSm == 0) - || data->prtSummary) - { - data->outpVector[data->outNumber++] = outNdens; - data->outpVector[data->outNumber++] = - (outNdens * data->GainSqInv); - - refVal.rValue = data->freq; /* the reference is the freq */ - outData.v.numValue = data->outNumber; /* vector number */ - outData.v.vec.rVec = data->outpVector; /* vector of outputs */ - (*(SPfrontEnd->OUTpData))(data->NplotPtr,&refVal,&outData); - } - break; - - case INT_NOIZ: - data->outpVector[data->outNumber++] = data->outNoiz; - data->outpVector[data->outNumber++] = data->inNoise; - outData.v.vec.rVec = data->outpVector; /* vector of outputs */ - outData.v.numValue = data->outNumber; /* vector number */ - (*(SPfrontEnd->OUTpData))(data->NplotPtr,&refVal,&outData); - break; - - default: - return (E_INTERN); - } - break; - - case N_CLOSE: - (*(SPfrontEnd->OUTendPlot))(data->NplotPtr); - FREE(data->namelist); - FREE(data->outpVector); - break; - - default: - return (E_INTERN); - } - return (OK); -} diff --git a/src/analysis/cktntask.c b/src/analysis/cktntask.c deleted file mode 100644 index 0aa6e035c..000000000 --- a/src/analysis/cktntask.c +++ /dev/null @@ -1,56 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "tskdefs.h" -#include "ifsim.h" -#include "cktdefs.h" -#include "iferrmsg.h" - - -/* ARGSUSED */ -int -CKTnewTask(void *ckt, void **taskPtr, IFuid taskName) -{ - register TSKtask *tsk; - *taskPtr = (void *)MALLOC(sizeof(TSKtask)); - if(*taskPtr==NULL) return(E_NOMEM); - tsk = *(TSKtask **)taskPtr; - tsk->TSKname = taskName; - tsk->TSKgmin = 1e-12; - tsk->TSKabstol = 1e-12; - tsk->TSKreltol = 1e-3; - tsk->TSKchgtol = 1e-14; - tsk->TSKvoltTol = 1e-6; -#ifdef NEWTRUNC - tsk->TSKlteReltol = 1e-3; - tsk->TSKlteAbstol = 1e-6; -#endif /* NEWTRUNC */ - tsk->TSKtrtol = 7; - tsk->TSKbypass = 1; - tsk->TSKtranMaxIter = 10; - tsk->TSKdcMaxIter = 100; - tsk->TSKdcTrcvMaxIter = 50; - tsk->TSKintegrateMethod = TRAPEZOIDAL; - tsk->TSKmaxOrder = 2; - tsk->TSKnumSrcSteps = 10; - tsk->TSKnumGminSteps = 10; - tsk->TSKpivotAbsTol = 1e-13; - tsk->TSKpivotRelTol = 1e-3; - tsk->TSKtemp = 300.15; - tsk->TSKnomTemp = 300.15; - tsk->TSKdefaultMosL = 1e-4; - tsk->TSKdefaultMosW = 1e-4; - tsk->TSKdefaultMosAD = 0; - tsk->TSKdefaultMosAS = 0; - tsk->TSKnoOpIter=0; - tsk->TSKtryToCompact=0; - tsk->TSKbadMos3=0; - tsk->TSKkeepOpInfo=0; - return(OK); -} diff --git a/src/analysis/cktnum2n.c b/src/analysis/cktnum2n.c deleted file mode 100644 index d9e8177fd..000000000 --- a/src/analysis/cktnum2n.c +++ /dev/null @@ -1,32 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTnum2nod - * find the given node given its name and return the node pointer - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "sperror.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -CKTnode * -CKTnum2nod(CKTcircuit *ckt, int node) -{ - register CKTnode *here; - - for (here = ((CKTcircuit *)ckt)->CKTnodes; here; here = here->next) { - if(here->number == node) { - return(here); - } - } - return((CKTnode *)NULL); -} diff --git a/src/analysis/cktop.c b/src/analysis/cktop.c deleted file mode 100644 index d68fc3e56..000000000 --- a/src/analysis/cktop.c +++ /dev/null @@ -1,146 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -int -CKTop(CKTcircuit *ckt, long int firstmode, long int continuemode, int iterlim) -{ - int converged; - int i; - - ckt->CKTmode = firstmode; - if(!ckt->CKTnoOpIter) { - converged = NIiter(ckt,iterlim); - } else { - converged = 1; /* the 'go directly to gmin stepping' option */ - } - if(converged != 0) { - /* no convergence on the first try, so we do something else */ - /* first, check if we should try gmin stepping */ - /* note that no path out of this code allows ckt->CKTdiagGmin to be - * anything but 0.000000000 - */ - if(ckt->CKTnumGminSteps >1) { - ckt->CKTmode = firstmode; - (*(SPfrontEnd->IFerror))(ERR_INFO, - "starting Gmin stepping",(IFuid *)NULL); - ckt->CKTdiagGmin = ckt->CKTgmin; - for(i=0;iCKTnumGminSteps;i++) { - ckt->CKTdiagGmin *= 10; - } - for(i=0;i<=ckt->CKTnumGminSteps;i++) { - ckt->CKTnoncon =1; - converged = NIiter(ckt,iterlim); - if(converged != 0) { - ckt->CKTdiagGmin = 0; - (*(SPfrontEnd->IFerror))(ERR_WARNING, - "Gmin step failed",(IFuid *)NULL); - break; - } - ckt->CKTdiagGmin /= 10; - ckt->CKTmode=continuemode; - (*(SPfrontEnd->IFerror))(ERR_INFO, - "One successful Gmin step",(IFuid *)NULL); - } - ckt->CKTdiagGmin = 0; - converged = NIiter(ckt,iterlim); - if(converged == 0) { - (*(SPfrontEnd->IFerror))(ERR_INFO, - "Gmin stepping completed",(IFuid *)NULL); - return(0); - } - (*(SPfrontEnd->IFerror))(ERR_WARNING, - "Gmin stepping failed",(IFuid *)NULL); - - } - /* now, we'll try source stepping - we scale the sources - * to 0, converge, then start stepping them up until they - * are at their normal values - * - * note that no path out of this code allows ckt->CKTsrcFact to be - * anything but 1.000000000 - */ - if(ckt->CKTnumSrcSteps >1) { - ckt->CKTmode = firstmode; - (*(SPfrontEnd->IFerror))(ERR_INFO, - "starting source stepping",(IFuid *)NULL); - for(i=0;i<=ckt->CKTnumSrcSteps;i++) { - ckt->CKTsrcFact = ((double)i)/((double)ckt->CKTnumSrcSteps); - converged = NIiter(ckt,iterlim); - ckt->CKTmode = continuemode; - if(converged != 0) { - ckt->CKTsrcFact = 1; - ckt->CKTcurrentAnalysis = DOING_TRAN; - (*(SPfrontEnd->IFerror))(ERR_WARNING, - "source stepping failed",(IFuid *)NULL); - return(converged); - } - (*(SPfrontEnd->IFerror))(ERR_INFO, - "One successful source step",(IFuid *)NULL); - } - (*(SPfrontEnd->IFerror))(ERR_INFO, - "Source stepping completed",(IFuid *)NULL); - ckt->CKTsrcFact = 1; - return(0); - } else { - return(converged); - } - } - return(0); -} - -/* CKTconvTest(ckt) - * this is a driver program to iterate through all the various - * convTest functions provided for the circuit elements in the - * given circuit - */ - -int -CKTconvTest(register CKTcircuit *ckt) -{ - extern SPICEdev *DEVices[]; - register int i; - int error = OK; -#ifdef PARALLEL_ARCH - int ibuf[2]; - long type = MT_CONV, length = 2; -#endif /* PARALLEL_ARCH */ - - for (i=0;iCKThead[i] != NULL)) { - error = (*((*DEVices[i]).DEVconvTest))(ckt->CKThead[i],ckt); - } -#ifdef PARALLEL_ARCH - if (error || ckt->CKTnoncon) goto combine; -#else - if (error) return(error); - if (ckt->CKTnoncon) { - /* printf("convTest: device %s failed\n", - (*DEVices[i]).DEVpublic.name); */ - return(OK); - } -#endif /* PARALLEL_ARCH */ - } -#ifdef PARALLEL_ARCH -combine: - /* See if any of the DEVconvTest functions bailed. If not, proceed. */ - ibuf[0] = error; - ibuf[1] = ckt->CKTnoncon; - IGOP_( &type, ibuf, &length, "+" ); - ckt->CKTnoncon = ibuf[1]; - if ( ibuf[0] != error ) { - error = E_MULTIERR; - } - return (error); -#else - return(OK); -#endif /* PARALLEL_ARCH */ -} diff --git a/src/analysis/cktparam.c b/src/analysis/cktparam.c deleted file mode 100644 index 355598467..000000000 --- a/src/analysis/cktparam.c +++ /dev/null @@ -1,33 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTparam - * attach the given parameter to the specified device in the given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "devdefs.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; - -/* ARGSUSED */ -int -CKTparam(void *ckt, void *fast, int param, IFvalue *val, IFvalue *selector) -{ - register int type; - GENinstance *myfast = (GENinstance *)fast; - type = myfast->GENmodPtr->GENmodType; - if(((*DEVices[type]).DEVparam)) { - return(((*((*DEVices[type]).DEVparam)) (param,val,myfast,selector))); - } else { - return(E_BADPARM); - } -} diff --git a/src/analysis/cktpartn.c b/src/analysis/cktpartn.c deleted file mode 100644 index e912ac344..000000000 --- a/src/analysis/cktpartn.c +++ /dev/null @@ -1,42 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1992 David A. Gates, UC Berkeley CADgroup -**********/ - - /* CKTpartition(ckt) - * this labels each instance of a circuit as belonging to a - * particular processor in a multiprocessor computer. - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "const.h" -#include "devdefs.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; - -int -CKTpartition(register CKTcircuit *ckt) -{ - register int i, instNum = 0; - register GENmodel *model; - register GENinstance *inst; - - for (i=0;iCKThead[i] != NULL) ) { - for (model = ckt->CKThead[i]; model; model = model->GENnextModel) { - for (inst = model->GENinstances; inst; - inst = inst->GENnextInstance) { - inst->GENowner = instNum % ARCHsize; - instNum++; - } - } - } - } - return(OK); -} diff --git a/src/analysis/cktpmnam.c b/src/analysis/cktpmnam.c deleted file mode 100644 index 6743d6e3b..000000000 --- a/src/analysis/cktpmnam.c +++ /dev/null @@ -1,51 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* - * CKTpModName() - * - * Take a parameter by Name and set it on the specified model - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "devdefs.h" -#include "cktdefs.h" -#include "gendefs.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; - -/* ARGSUSED */ -int -CKTpModName(char *parm, IFvalue *val, CKTcircuit *ckt, int type, IFuid name, GENmodel **modfast) - /* the name of the parameter to set */ - /* the parameter union containing the value to set */ - /* the circuit this model is a member of */ - /* the device type code to the model being parsed */ - /* the name of the model being parsed */ - /* direct pointer to model being parsed */ - -{ - int error; /* int to store evaluate error return codes in */ - int i; - - for(i=0;i<(*(*DEVices[type]).DEVpublic.numModelParms);i++) { - if(strcmp(parm,((*DEVices[type]).DEVpublic.modelParms[i].keyword))==0){ - error = CKTmodParam((void *)ckt,(void *)*modfast, - (*DEVices[type]).DEVpublic.modelParms[i].id,val, - (IFvalue*)NULL); - if(error) return(error); - break; - } - } - if(i==(*(*DEVices[type]).DEVpublic.numModelParms)) { - return(E_BADPARM); - } - return(OK); -} diff --git a/src/analysis/cktpname.c b/src/analysis/cktpname.c deleted file mode 100644 index 187e5df3a..000000000 --- a/src/analysis/cktpname.c +++ /dev/null @@ -1,54 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* - * CKTpName() - * - * Take a parameter by Name and set it on the specified device - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "devdefs.h" -#include "cktdefs.h" -#include "gendefs.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; - -/* ARGSUSED */ -int -CKTpName(char *parm, IFvalue *val, CKTcircuit *ckt, int dev, char *name, GENinstance **fast) - /* the name of the parameter to set */ - /* the parameter union containing the value to set */ - /* the circuit this device is a member of */ - /* the device type code to the device being parsed */ - /* the name of the device being parsed */ - /* direct pointer to device being parsed */ - -{ - int error; /* int to store evaluate error return codes in */ - int i; - - for(i=0;i<(*(*DEVices[dev]).DEVpublic.numInstanceParms);i++) { - if(strcmp(parm, - ((*DEVices[dev]).DEVpublic.instanceParms[i].keyword))==0) { - error = CKTparam((void*)ckt,(void *)*fast, - (*DEVices[dev]).DEVpublic.instanceParms[i].id,val, - (IFvalue *)NULL); - if(error) return(error); - break; - } - } - if(i==(*(*DEVices[dev]).DEVpublic.numInstanceParms)) { - return(E_BADPARM); - } - return(OK); -} diff --git a/src/analysis/cktpzld.c b/src/analysis/cktpzld.c deleted file mode 100644 index 0abbf31eb..000000000 --- a/src/analysis/cktpzld.c +++ /dev/null @@ -1,81 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include -#include "pzdefs.h" -#include "smpdefs.h" -#include "cktdefs.h" -#include "complex.h" -#include "devdefs.h" -#include "sperror.h" - - -extern SPICEdev *DEVices[]; - -int -CKTpzLoad(CKTcircuit *ckt, SPcomplex *s) -{ - PZAN *pzan = (PZAN *) (ckt->CKTcurJob); - int error; - int i; -#ifdef PARALLEL_ARCH - long type = MT_PZLOAD, length = 1; -#endif /* PARALLEL_ARCH */ - - for (i = 0; i <= SMPmatSize(ckt->CKTmatrix); i++) { - ckt->CKTrhs[i] = 0.0; - ckt->CKTirhs[i] = 0.0; - } - - SMPcClear(ckt->CKTmatrix); - for (i = 0; i < DEVmaxnum; i++) { - if (DEVices[i]->DEVpzLoad != NULL && ckt->CKThead[i] != NULL) { - error = (*DEVices[i]->DEVpzLoad)(ckt->CKThead[i], ckt, s); -#ifdef PARALLEL_ARCH - if (error) goto combine; -#else - if(error) return(error); -#endif /* PARALLEL_ARCH */ - } - } -#ifdef PARALLEL_ARCH -combine: - /* See if any of the DEVload functions bailed. If not, proceed. */ - IGOP_( &type, &error, &length, "max" ); - if (error == OK) { - SMPcCombine( ckt->CKTmatrix, ckt->CKTrhs, ckt->CKTrhsSpare, - ckt->CKTirhs, ckt->CKTirhsSpare ); - } else { - return(error); - } -#endif /* PARALLEL_ARCH */ - -#ifdef notdef - printf("*** Before PZ adjustments *\n"); - SMPprint(ckt->CKTmatrix, stdout); -#endif - - if (pzan->PZbalance_col && pzan->PZsolution_col) { - SMPcAddCol(ckt->CKTmatrix, pzan->PZbalance_col, pzan->PZsolution_col); - /* AC sources ?? XXX */ - } - - if (pzan->PZsolution_col) { - SMPcZeroCol(ckt->CKTmatrix, pzan->PZsolution_col); - } - - /* Driving function (current source) */ - if (pzan->PZdrive_pptr) - *pzan->PZdrive_pptr = 1.0; - if (pzan->PZdrive_nptr) - *pzan->PZdrive_nptr = -1.0; - -#ifdef notdef - printf("*** After PZ adjustments *\n"); - SMPprint(ckt->CKTmatrix, stdout); -#endif - - return(OK); -} diff --git a/src/analysis/cktpzset.c b/src/analysis/cktpzset.c deleted file mode 100644 index 095c35e29..000000000 --- a/src/analysis/cktpzset.c +++ /dev/null @@ -1,105 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -/* CKTpzSetup(ckt) - * iterate through all the various - * pzSetup functions provided for the circuit elements in the - * given circuit, setup ... - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -#define CKALLOC(var,size,type) \ - if(size && (!(var =(type *)MALLOC((size)*sizeof(type))))){\ - return(E_NOMEM);\ -} - -int -CKTpzSetup(register CKTcircuit *ckt, int type) -{ - extern SPICEdev *DEVices[]; - PZAN *pzan = (PZAN *) ckt->CKTcurJob; - SMPmatrix *matrix; - int error; - int i, temp, solution_col, balance_col; - int input_pos, input_neg, output_pos, output_neg; - - NIdestroy(ckt); - error = NIinit(ckt); - if (error) - return(error); - matrix = ckt->CKTmatrix; - - /* Really awful . . . */ - ckt->CKTnumStates = 0; - - for (i = 0; i < DEVmaxnum; i++) { - if (DEVices[i]->DEVpzSetup != NULL && ckt->CKThead[i] != NULL) { - error = (*DEVices[i]->DEVpzSetup)(matrix, ckt->CKThead[i], - ckt, &ckt->CKTnumStates); - if (error != OK) - return(error); - } - } - - solution_col = 0; - balance_col = 0; - - input_pos = pzan->PZin_pos; - input_neg = pzan->PZin_neg; - - if (type == PZ_DO_ZEROS) { - /* Vo/Ii in Y */ - output_pos = pzan->PZout_pos; - output_neg = pzan->PZout_neg; - } else if (pzan->PZinput_type == PZ_IN_VOL) { - /* Vi/Ii in Y */ - output_pos = pzan->PZin_pos; - output_neg = pzan->PZin_neg; - } else { - /* Denominator */ - output_pos = 0; - output_neg = 0; - input_pos = 0; - input_neg = 0; - } - - if (output_pos) { - solution_col = output_pos; - if (output_neg) - balance_col = output_neg; - } else { - solution_col = output_neg; - temp = input_pos; - input_pos = input_neg; - input_neg = temp; - } - - if (input_pos) - pzan->PZdrive_pptr = SMPmakeElt(matrix, input_pos, solution_col); - else - pzan->PZdrive_pptr = NULL; - - if (input_neg) - pzan->PZdrive_nptr = SMPmakeElt(matrix, input_neg, solution_col); - else - pzan->PZdrive_nptr = NULL; - - pzan->PZsolution_col = solution_col; - pzan->PZbalance_col = balance_col; - - pzan->PZnumswaps = 1; - - error = NIreinit(ckt); - if (error) - return(error); - - return OK; -} diff --git a/src/analysis/cktpzstr.c b/src/analysis/cktpzstr.c deleted file mode 100644 index 7f70fa7d6..000000000 --- a/src/analysis/cktpzstr.c +++ /dev/null @@ -1,1196 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -/* - * A variant on the "zeroin" method. This is a bit convoluted. - */ - -#include "ngspice.h" -#include -#include "pzdefs.h" -#include "complex.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -#ifdef PZDEBUG -# ifndef notdef -# define DEBUG(N) if (Debug >= (unsigned) (N)) -static unsigned int Debug = 1; -# else -# define DEBUG(N) if (0) -# endif -#endif - -/* static function definitions */ - -static int CKTpzStrat(PZtrial **set); -static int CKTpzStep(int strat, PZtrial **set); -static int CKTpzRunTrial(CKTcircuit *ckt, PZtrial **new_trialp, PZtrial **set); -static int CKTpzVerify(PZtrial **set, PZtrial *new_trial); -static void clear_trials(int mode); -static void check_flat(PZtrial *a, PZtrial *b); -void CKTpzUpdateSet(PZtrial **set, PZtrial *new); -void zaddeq(double *a, int *amag, double x, int xmag, double y, int ymag); -void CKTpzReset(PZtrial **set); - - -#ifdef PZDEBUG -static void show_trial( ); -#endif - -#define NITER_LIM 200 - -#define SHIFT_LEFT 2 -#define SHIFT_RIGHT 3 -#define SKIP_LEFT 4 -#define SKIP_RIGHT 5 -#define INIT 6 - -#define GUESS 7 -#define SPLIT_LEFT 8 -#define SPLIT_RIGHT 9 - -#define MULLER 10 -#define SYM 11 -#define SYM2 12 -#define COMPLEX_INIT 13 -#define COMPLEX_GUESS 14 -#define QUIT 15 - -#define NEAR_LEFT 4 -#define MID_LEFT 5 -#define FAR_LEFT 6 -#define NEAR_RIGHT 7 -#define FAR_RIGHT 8 -#define MID_RIGHT 9 - -#ifdef PZDEBUG -static char *snames[ ] = { - "none", - "none", - "shift left", - "shift right", - "skip left", - "skip right", - "init", - "guess", - "split left", - "split right", - "Muller", - "sym 1", - "sym 2", - "complex_init", - "complex_guess", - "quit", - "none" - }; -#endif - -#define sgn(X) ((X) < 0 ? -1 : (X) == 0 ? 0 : 1) - -#define ISAROOT 2 -#define ISAREPEAT 4 -#define ISANABERRATION 8 -#define ISAMINIMA 16 - -extern double NIpzK; -extern int NIpzK_mag; - -int CKTpzTrapped; - -static int NZeros, NFlat, Max_Zeros; -static PZtrial *ZeroTrial, *Trials; -static int Seq_Num; -static double Guess_Param; -static double High_Guess, Low_Guess; -static int Last_Move, Consec_Moves; -static int NIter, NTrials; -static int Aberr_Num; - -int PZeval(int strat, PZtrial **set, PZtrial **new_trial_p); -static PZtrial *pzseek(PZtrial *t, int dir); -static int alter(PZtrial *new, PZtrial *nearto, double abstol, double reltol); - -int -CKTpzFindZeros(CKTcircuit *ckt, PZtrial **rootinfo, int *rootcount) -{ - PZtrial *new_trial; - PZtrial *neighborhood[3]; - int strat; - int error; - char ebuf[513]; - - NIpzK = 0.0; - NIpzK_mag = 0; - High_Guess = -1.0; - Low_Guess = 1.0; - ZeroTrial = 0; - Trials = 0; - NZeros = 0; - NFlat = 0; - Max_Zeros = SMPmatSize(ckt->CKTmatrix); - NIter = 0; - error = OK; - CKTpzTrapped = 0; - Aberr_Num = 0; - NTrials = 0; - ckt->CKTniState |= NIPZSHOULDREORDER; /* Initial for LU fill-ins */ - - Seq_Num = 1; - - CKTpzReset(neighborhood); - - do { - - while ((strat = CKTpzStrat(neighborhood)) < GUESS && !CKTpzTrapped) - if (!CKTpzStep(strat, neighborhood)) { - strat = GUESS; -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "\t\tGuess\n"); -#endif - break; - } - - NIter += 1; - - /* Evaluate current strategy */ - error = PZeval(strat, neighborhood, &new_trial); - if (error != OK) - return error; - - error = CKTpzRunTrial(ckt, &new_trial, neighborhood); - if (error != OK) - return error; - - if (new_trial->flags & ISAROOT) { - if (CKTpzVerify(neighborhood, new_trial)) { - NIter = 0; - CKTpzReset(neighborhood); - } else - /* XXX Verify fails ?!? */ - CKTpzUpdateSet(neighborhood, new_trial); - } else if (new_trial->flags & ISANABERRATION) { - CKTpzReset(neighborhood); - Aberr_Num += 1; - free(new_trial); - } else if (new_trial->flags & ISAMINIMA) { - neighborhood[0] = NULL; - neighborhood[1] = new_trial; - neighborhood[2] = NULL; - } else { - CKTpzUpdateSet(neighborhood, new_trial); /* Replace a value */ - } - - if ((*(SPfrontEnd->IFpauseTest))( )) { - sprintf(ebuf, - "Pole-Zero analysis interrupted; %d trials, %d roots\n", - Seq_Num, NZeros); - (*(SPfrontEnd->IFerror))(ERR_WARNING, ebuf, 0); - error = E_PAUSE; - break; - } - } while (High_Guess - Low_Guess < 1e40 - && NZeros < Max_Zeros - && NIter < NITER_LIM && Aberr_Num < 3 - && High_Guess - Low_Guess < 1e35 /* XXX Should use mach const */ - && (!neighborhood[0] || !neighborhood[2] || CKTpzTrapped - || neighborhood[2]->s.real - neighborhood[0]->s.real < 1e22)); - /* XXX ZZZ */ - -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, - "Finished: NFlat %d, NZeros: %d, NTrials %d, Guess %g to %g, aber %d\n", - NFlat, NZeros, NTrials, Low_Guess, High_Guess, Aberr_Num); -#endif - - if (NZeros >= Seq_Num - 1) { - /* Short */ - clear_trials(ISAROOT); - *rootinfo = NULL; - *rootcount = 0; - ERROR(E_SHORT, "The input signal is shorted on the way to the output"); - } else - clear_trials(0); - - *rootinfo = Trials; - *rootcount = NZeros; - - if (Aberr_Num > 2) { - sprintf(ebuf, - "Pole-zero converging to numerical aberrations; giving up after %d trials", - Seq_Num); - (*(SPfrontEnd->IFerror))(ERR_WARNING, ebuf, 0); - } - - if (NIter >= NITER_LIM) { - sprintf(ebuf, - "Pole-zero iteration limit reached; giving up after %d trials", - Seq_Num); - (*(SPfrontEnd->IFerror))(ERR_WARNING, ebuf, 0); - } - - return error; -} - -/* PZeval: evaluate an estimation function (given by 'strat') for the next - guess (returned in a PZtrial) */ - -/* XXX ZZZ */ -int -PZeval(int strat, PZtrial **set, PZtrial **new_trial_p) -{ - int error; - PZtrial *new_trial; - - new_trial = NEW(PZtrial); - new_trial->multiplicity = 0; - new_trial->count = 0; - new_trial->seq_num = Seq_Num++; - - switch (strat) { - case GUESS: - if (High_Guess < Low_Guess) - Guess_Param = 0.0; - else if (Guess_Param > 0.0) { - if (High_Guess > 0.0) - Guess_Param = High_Guess * 10.0; - else - Guess_Param = 1.0; - } else { - if (Low_Guess < 0.0) - Guess_Param = Low_Guess * 10.0; - else - Guess_Param = -1.0; - } - if (Guess_Param > High_Guess) - High_Guess = Guess_Param; - if (Guess_Param < Low_Guess) - Low_Guess = Guess_Param; - new_trial->s.real = Guess_Param; - if (set[1]) - new_trial->s.imag = set[1]->s.imag; - else - new_trial->s.imag = 0.0; - error = OK; - break; - - case SYM: - case SYM2: - error = NIpzSym(set, new_trial); - - if (CKTpzTrapped == 1) { - if (new_trial->s.real < set[0]->s.real - || new_trial->s.real > set[1]->s.real) { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, - "FIXED UP BAD Strat: %s (%d) was (%.15g,%.15g)\n", - snames[strat], CKTpzTrapped, - new_trial->s.real, new_trial->s.imag); -#endif - new_trial->s.real = (set[0]->s.real + set[1]->s.real) / 2.0; - } - } else if (CKTpzTrapped == 2) { - if (new_trial->s.real < set[1]->s.real - || new_trial->s.real > set[2]->s.real) { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, - "FIXED UP BAD Strat: %s (%d) was (%.15g,%.15g)\n", - snames[strat], CKTpzTrapped, - new_trial->s.real, new_trial->s.imag); -#endif - new_trial->s.real = (set[1]->s.real + set[2]->s.real) / 2.0; - } - } else if (CKTpzTrapped == 3) { - if ((new_trial->s.real <= set[0]->s.real - || new_trial->s.real == set[1]->s.real) - && (new_trial->s.imag == set[1]->s.imag - || new_trial->s.real >= set[2]->s.real)) { -#ifdef PZDEBUG - DEBUG(1) - fprintf(stderr, - "FIXED UP BAD Strat: %s (%d), was (%.15g %.15g)\n", - snames[strat], CKTpzTrapped, - new_trial->s.real, new_trial->s.imag); -#endif - new_trial->s.real = (set[0]->s.real + set[2]->s.real) / 2.0; - if (new_trial->s.real == set[1]->s.real) { -#ifdef PZDEBUG - DEBUG(1) - fprintf(stderr, "Still off!"); -#endif - if (Last_Move == MID_LEFT || Last_Move == NEAR_RIGHT) - new_trial->s.real = (set[0]->s.real + set[1]->s.real) - / 2.0; - else - new_trial->s.real = (set[1]->s.real + set[2]->s.real) - / 2.0; - } - } - } - - break; - - case COMPLEX_INIT: - /* Not automatic */ -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "\tPZ minima at: %-30g %d\n", - NIpzK, NIpzK_mag); -#endif - - new_trial->s.real = set[1]->s.real; - - /* NIpzK is a good idea, but the value gets trashed - * due to the numerics when zooming in on a minima. - * The key is to know when to stop taking new values for NIpzK - * (which I don't). For now I take the first value indicated - * by the NIpzSym2 routine. A "hack". - */ - - if (NIpzK != 0.0 && NIpzK_mag > -10) { - while (NIpzK_mag > 0) { - NIpzK *= 2.0; - NIpzK_mag -= 1; - } - while (NIpzK_mag < 0) { - NIpzK /= 2.0; - NIpzK_mag += 1; - } - new_trial->s.imag = NIpzK; - } else - new_trial->s.imag = 10000.0; - - /* - * Reset NIpzK so the same value doesn't get used again. - */ - - NIpzK = 0.0; - NIpzK_mag = 0; - error = OK; - break; - - case COMPLEX_GUESS: - if (!set[2]) { - new_trial->s.real = set[0]->s.real; - new_trial->s.imag = 1.0e8; - } else { - new_trial->s.real = set[0]->s.real; - new_trial->s.imag = 1.0e12; - } - error = OK; - break; - - case MULLER: - error = NIpzMuller(set, new_trial); - break; - - case SPLIT_LEFT: - new_trial->s.real = (set[0]->s.real + 2 * set[1]->s.real) / 3.0; - error = OK; - break; - - case SPLIT_RIGHT: - new_trial->s.real = (set[2]->s.real + 2 * set[1]->s.real) / 3.0; - error = OK; - break; - - default: - ERROR(E_PANIC, "Step type unkown"); - break; - } - - *new_trial_p = new_trial; - return error; -} - -/* CKTpzStrat: given three points, determine a good direction or method for - guessing the next zero */ - -/* XXX ZZZ what is a strategy for complex hunting? */ -int CKTpzStrat(PZtrial **set) -{ - int suggestion; - double a, b; - int a_mag, b_mag; - double k1, k2; - int new_trap; - - new_trap = 0; - - if (set[1] && (set[1]->flags & ISAMINIMA)) { - suggestion = COMPLEX_INIT; - } else if (set[0] && set[0]->s.imag != 0.0) { - if (!set[1] || !set[2]) - suggestion = COMPLEX_GUESS; - else - suggestion = MULLER; - } else if (!set[0] || !set[1] || !set[2]) { - suggestion = INIT; - } else { - if (sgn(set[0]->f_def.real) != sgn(set[1]->f_def.real)) { - /* Zero crossing between s[0] and s[1] */ - new_trap = 1; - suggestion = SYM2; - } else if (sgn(set[1]->f_def.real) != sgn(set[2]->f_def.real)) { - /* Zero crossing between s[1] and s[2] */ - new_trap = 2; - suggestion = SYM2; - } else { - - zaddeq(&a, &a_mag, set[1]->f_def.real, set[1]->mag_def, - -set[0]->f_def.real, set[0]->mag_def); - zaddeq(&b, &b_mag, set[2]->f_def.real, set[2]->mag_def, - -set[1]->f_def.real, set[1]->mag_def); - - if (!CKTpzTrapped) { - - k1 = set[1]->s.real - set[0]->s.real; - k2 = set[2]->s.real - set[1]->s.real; - if (a_mag + 10 < set[0]->mag_def - && a_mag + 10 < set[1]->mag_def - && b_mag + 10 < set[1]->mag_def - && b_mag + 10 < set[2]->mag_def) { - if (k1 > k2) - suggestion = SKIP_RIGHT; - else - suggestion = SKIP_LEFT; - } else if (sgn(a) != -sgn(b)) { - if (a == 0.0) - suggestion = SKIP_LEFT; - else if (b == 0.0) - suggestion = SKIP_RIGHT; - else if (sgn(a) == sgn(set[1]->f_def.real)) - suggestion = SHIFT_LEFT; - else - suggestion = SHIFT_RIGHT; - } else if (sgn(a) == -sgn(set[1]->f_def.real)) { - new_trap = 3; - /* minima in magnitude above the x axis */ - /* Search for exact mag. minima, look for complex pair */ - suggestion = SYM; - } else if (k1 > k2) - suggestion = SKIP_RIGHT; - else - suggestion = SKIP_LEFT; - } else { - new_trap = 3; /* still */ - /* XXX ? Are these tests needed or is SYM safe all the time? */ - if (sgn(a) != sgn(b)) { - /* minima in magnitude */ - /* Search for exact mag. minima, look for complex pair */ - suggestion = SYM; - } else if ((a_mag > b_mag || a_mag == b_mag) - && fabs(a) > fabs(b)) - suggestion = SPLIT_LEFT; - else - suggestion = SPLIT_RIGHT; - } - } - if (Consec_Moves >= 3 && CKTpzTrapped == new_trap) { - new_trap = CKTpzTrapped; - if (Last_Move == MID_LEFT || Last_Move == NEAR_RIGHT) - suggestion = SPLIT_LEFT; - else if (Last_Move == MID_RIGHT || Last_Move == NEAR_LEFT) - suggestion = SPLIT_RIGHT; - else - abort( ); /* XXX */ - Consec_Moves = 0; - } - } - - CKTpzTrapped = new_trap; -#ifdef PZDEBUG - DEBUG(1) { - if (set[0] && set[1] && set[2]) - fprintf(stderr, "given %.15g %.15g / %.15g %.15g / %.15g %.15g\n", - set[0]->s.real, set[0]->s.imag, set[1]->s.real, set[1]->s.imag, - set[2]->s.real, set[2]->s.imag); - fprintf(stderr, "suggestion(%d/%d/%d | %d): %s\n", - NFlat, NZeros, Max_Zeros, CKTpzTrapped, snames[suggestion]); - } -#endif - return suggestion; -} - -/* CKTpzRunTrial: eval the function at a given 's', fold in deflation */ - -int -CKTpzRunTrial(CKTcircuit *ckt, PZtrial **new_trialp, PZtrial **set) -{ - PZtrial *match, *base, *new_trial; - PZtrial *p, *prev; - SPcomplex def_frac, diff_frac; - double reltol, abstol; - int def_mag, diff_mag, error; - int i; - int pretest, shifted, was_shifted; - int repeat; - - new_trial = *new_trialp; - - if (new_trial->s.imag < 0.0) - new_trial->s.imag *= -1.0; - - /* Insert the trial into the list of Trials, while calculating - the deflation factor from previous zeros */ - - pretest = 0; - shifted = 0; - repeat = 0; - - do { - - def_mag = 0; - def_frac.real = 1.0; - def_frac.imag = 0.0; - was_shifted = shifted; - shifted = 0; - - prev = NULL; - base = NULL; - match = NULL; - - for (p = Trials; p != NULL; p = p->next) { - - C_SUBEQ(diff_frac,p->s,new_trial->s); - - if ((diff_frac.real < 0.0 - || diff_frac.real == 0.0) && diff_frac.imag < 0.0) { - prev = p; - if (p->flags & ISAMINIMA) - base = p; - } - - if (p->flags & ISAROOT) { - abstol = 1e-5; - reltol = 1e-6; - } else { - abstol = 1e-20; - reltol = 1e-12; - } - - if (diff_frac.imag == 0.0 && - fabs(diff_frac.real) / (fabs(p->s.real) + abstol/reltol) - < reltol) { - -#ifdef PZDEBUG - DEBUG(1) { - fprintf(stderr, - "diff_frac.real = %10g, p->s = %10g, nt = %10g\n", - diff_frac.real, p->s.real, new_trial->s.real); - fprintf(stderr, "ab=%g,rel=%g\n", abstol, reltol); - } -#endif - if (was_shifted || p->count >= 3 - || !alter(new_trial, set[1], abstol, reltol)) { - /* assume either a root or minima */ - p->count = 0; - pretest = 1; - break; - } else - p->count += 1; /* try to shift */ - - shifted = 1; /* Re-calculate deflation */ - break; - - } else { - if (!CKTpzTrapped) - p->count = 0; - if (p->flags & ISAROOT) { - diff_mag = 0; - C_NORM(diff_frac,diff_mag); - if (diff_frac.imag != 0.0) { - C_MAG2(diff_frac); - diff_mag *= 2; - } - C_NORM(diff_frac,diff_mag); - - for (i = p->multiplicity; i > 0; i--) { - C_MUL(def_frac,diff_frac); - def_mag += diff_mag; - C_NORM(def_frac,def_mag); - } - } else if (!match) - match = p; - } - } - - } while (shifted); - - if (pretest) { - -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "Pre-test taken\n"); - - /* XXX Should catch the double-zero right off - * if K is 0.0 - * instead of forcing a re-converge */ - DEBUG(1) { - fprintf(stderr, "NIpzK == %g, mag = %d\n", NIpzK, NIpzK_mag); - fprintf(stderr, "over at %.30g %.30g (new %.30g %.30g, %x)\n", - p->s.real, p->s.imag, new_trial->s.real, new_trial->s.imag, - p->flags); - } -#endif - if (!(p->flags & ISAROOT) && CKTpzTrapped == 3 - && NIpzK != 0.0 && NIpzK_mag > -10) { -#ifdef notdef - if (p->flags & ISAROOT) { - /* Ugh! muller doesn't work right */ - new_trial->flags = ISAMINIMA; - new_trial->s.imag = scalb(NIpzK, (int) (NIpzK_mag / 2)); - pretest = 0; - } else { -#endif - p->flags |= ISAMINIMA; - free(new_trial); - *new_trialp = p; - repeat = 1; - } else if (p->flags & ISAROOT) { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "Repeat at %.30g %.30g\n", - p->s.real, p->s.imag); -#endif - *new_trialp = p; - p->flags |= ISAREPEAT; - p->multiplicity += 1; - repeat = 1; - } else { - /* Regular zero, as precise as we can get it */ - error = E_SINGULAR; - } - - } - - if (!repeat) { - if (!pretest) { - /* Run the trial */ - ckt->CKTniState |= NIPZSHOULDREORDER; /* XXX */ - if (!(ckt->CKTniState & NIPZSHOULDREORDER)) { - CKTpzLoad(ckt, &new_trial->s); -#ifdef PZDEBUG - DEBUG(3) { - printf("Original:\n"); - SMPprint(ckt->CKTmatrix, stdout); - } -#endif - error = SMPcLUfac(ckt->CKTmatrix, ckt->CKTpivotAbsTol); - if (error == E_SINGULAR) { -#ifdef PZDEBUG - DEBUG(1) printf("Needs reordering\n"); -#endif - ckt->CKTniState |= NIPZSHOULDREORDER; - } else if (error != OK) - return error; - } - if (ckt->CKTniState & NIPZSHOULDREORDER) { - CKTpzLoad(ckt, &new_trial->s); - error = SMPcReorder(ckt->CKTmatrix, 1.0e-30, - 0.0 /* 0.1 Piv. Rel. */, - &(((PZAN *) ckt->CKTcurJob)->PZnumswaps)); - } - - if (error != E_SINGULAR) { - ckt->CKTniState &= ~NIPZSHOULDREORDER; -#ifdef PZDEBUG - DEBUG(3) { - printf("Factored:\n"); - SMPprint(ckt->CKTmatrix, stdout); - } -#endif - error = SMPcDProd(ckt->CKTmatrix, &new_trial->f_raw, - &new_trial->mag_raw); - } - } - - if ((error == E_SINGULAR || new_trial->f_raw.real == 0.0) - && new_trial->f_raw.imag == 0.0) { - new_trial->f_raw.real = 0.0; - new_trial->f_raw.imag = 0.0; - new_trial->mag_raw = 0; - new_trial->f_def.real = 0.0; - new_trial->f_def.imag = 0.0; - new_trial->mag_def = 0; - new_trial->flags = ISAROOT; - /*printf("SMP Det: Singular\n");*/ - } else if (error != OK) - return error; - else { - - /* PZnumswaps is either 0 or 1 */ - new_trial->f_raw.real *= ((PZAN *) ckt->CKTcurJob)->PZnumswaps; - new_trial->f_raw.imag *= ((PZAN *) ckt->CKTcurJob)->PZnumswaps; - /* - printf("SMP Det: (%g,%g)^%d\n", new_trial->f_raw.real, - new_trial->f_raw.imag, new_trial->mag_raw); - */ - - new_trial->f_def.real = new_trial->f_raw.real; - new_trial->f_def.imag = new_trial->f_raw.imag; - new_trial->mag_def = new_trial->mag_raw; - - C_DIV(new_trial->f_def,def_frac); - new_trial->mag_def -= def_mag; - C_NORM(new_trial->f_def,new_trial->mag_def); - } - - /* Link into the rest of the list */ - if (prev) { - new_trial->next = prev->next; - if (prev->next) - prev->next->prev = new_trial; - prev->next = new_trial; - } else { - if (Trials) - Trials->prev = new_trial; - else - ZeroTrial = new_trial; - new_trial->next = Trials; - Trials = new_trial; - } - new_trial->prev = prev; - - NTrials += 1; - - if (!(new_trial->flags & ISAROOT)) { - if (match) - check_flat(match, new_trial); - else - NFlat = 1; - } - } - -#ifdef PZDEBUG - show_trial(new_trial, '*'); -#endif - - return OK; -} - -/* Process a zero; inc. zero count, deflate other trials */ - -int -CKTpzVerify(PZtrial **set, PZtrial *new_trial) -{ - PZtrial *next; - int diff_mag; - SPcomplex diff_frac; - double tdiff; - - PZtrial *t, *prev; - - NZeros += 1; - if (new_trial->s.imag != 0.0) - NZeros += 1; - NFlat = 0; - - if (new_trial->multiplicity == 0) { - new_trial->flags |= ISAROOT; - new_trial->multiplicity = 1; - } - - prev = NULL; - - for (t = Trials; t; t = next) { - - next = t->next; - - if (t->flags & ISAROOT) { - prev = t; - /* Don't need to bother */ - continue; - } - - C_SUBEQ(diff_frac,new_trial->s,t->s); - if (new_trial->s.imag != 0.0) - C_MAG2(diff_frac); - - tdiff = diff_frac.real; - /* Note that Verify is called for each time the root is found, so - * multiplicity is not significant - */ - if (diff_frac.real != 0.0) { - diff_mag = 0; - C_NORM(diff_frac,diff_mag); - diff_mag *= -1; - C_DIV(t->f_def,diff_frac); - C_NORM(t->f_def,diff_mag); - t->mag_def += diff_mag; - } - - if (t->s.imag != 0.0 - || fabs(tdiff) / (fabs(new_trial->s.real) + 200) < 0.005) { - if (prev) - prev->next = t->next; - if (t->next) - t->next->prev = prev; - NTrials -= 1; -#ifdef PZDEBUG - show_trial(t, '-'); -#endif - if (t == ZeroTrial) { - if (t->next) - ZeroTrial = t->next; - else if (t->prev) - ZeroTrial = t->prev; - else - ZeroTrial = NULL; - } - if (t == Trials) { - Trials = t->next; - } - free(t); - } else { - - if (prev) - check_flat(prev, t); - else - NFlat = 1; - - if (t->flags & ISAMINIMA) - t->flags &= ~ISAMINIMA; - - prev = t; -#ifdef PZDEBUG - show_trial(t, '+'); -#endif - } - - } - - return 1; /* always ok */ -} - -/* pzseek: search the trial list (given a starting point) for the first - * non-zero entry; direction: -1 for prev, 1 for next, 0 for next - * -or- first. Also, sets "Guess_Param" at the next reasonable - * value to guess at if the search falls of the end of the list - */ - -static PZtrial * -pzseek(PZtrial *t, int dir) -{ - Guess_Param = dir; - if (t == NULL) - return NULL; - - if (dir == 0 && !(t->flags & ISAROOT) && !(t->flags & ISAMINIMA)) - return t; - - do { - if (dir >= 0) - t = t->next; - else - t = t->prev; - } while (t && ((t->flags & ISAROOT) || (t->flags & ISAMINIMA))); - - return t; -} - -static void -clear_trials(int mode) -{ - PZtrial *t, *next, *prev; - - prev = NULL; - - for (t = Trials; t; t = next) { - next = t->next; - if (mode || !(t->flags & ISAROOT)) { - free(t); - } else { - if (prev) - prev->next = t; - else - Trials = t; - t->prev = prev; - prev = t; - } - } - - if (prev) - prev->next = NULL; - else - Trials = NULL; -} - -void -CKTpzUpdateSet(PZtrial **set, PZtrial *new) -{ - int this_move; - - this_move = 0; - - if (new->s.imag != 0.0) { - set[2] = set[1]; - set[1] = set[0]; - set[0] = new; - } else if (!set[1]) - set[1] = new; - else if (!set[2] && new->s.real > set[1]->s.real) { - set[2] = new; - } else if (!set[0]) { - set[0] = new; - } else if (new->flags & ISAMINIMA) { - set[1] = new; - } else if (new->s.real < set[0]->s.real) { - set[2] = set[1]; - set[1] = set[0]; - set[0] = new; - this_move = FAR_LEFT; - } else if (new->s.real < set[1]->s.real) { - if ((!CKTpzTrapped || new->mag_def < set[1]->mag_def - || new->mag_def == set[1]->mag_def) - && fabs(new->f_def.real) < fabs(set[1]->f_def.real)) { - /* Really should check signs, not just compare fabs( ) */ - set[2] = set[1]; /* XXX = set[2]->prev :: possible opt */ - set[1] = new; - this_move = MID_LEFT; - } else { - set[0] = new; - this_move = NEAR_LEFT; - } - } else if (new->s.real < set[2]->s.real) { - if ((!CKTpzTrapped || new->mag_def < set[1]->mag_def - || new->mag_def == set[1]->mag_def) - && fabs(new->f_def.real) < fabs(set[1]->f_def.real)) { - /* Really should check signs, not just compare fabs( ) */ - set[0] = set[1]; - set[1] = new; - this_move = MID_RIGHT; - } else { - set[2] = new; - this_move = NEAR_RIGHT; - } - } else { - set[0] = set[1]; - set[1] = set[2]; - set[2] = new; - this_move = FAR_RIGHT; - } - - if (CKTpzTrapped && this_move == Last_Move) - Consec_Moves += 1; - else - Consec_Moves = 0; - Last_Move = this_move; -} - -void -zaddeq(double *a, int *amag, double x, int xmag, double y, int ymag) -{ - /* Balance magnitudes . . . */ - if (xmag > ymag) { - *amag = xmag; - if (xmag > 50 + ymag) - y = 0.0; - else - for (xmag -= ymag; xmag > 0; xmag--) - y /= 2.0; - } else { - *amag = ymag; - if (ymag > 50 + xmag) - x = 0.0; - else - for (ymag -= xmag; ymag > 0; ymag--) - x /= 2.0; - } - - *a = x + y; - if (*a == 0.0) - *amag = 0; - else { - while (fabs(*a) > 1.0) { - *a /= 2.0; - *amag += 1; - } - while (fabs(*a) < 0.5) { - *a *= 2.0; - *amag -= 1; - } - } -} - -#ifdef PZDEBUG -static void -show_trial(new_trial, x) - PZtrial *new_trial; - char x; -{ - DEBUG(1) fprintf(stderr, "%c (%3d/%3d) %.15g %.15g :: %.30g %.30g %d\n", x, - NIter, new_trial->seq_num, new_trial->s.real, new_trial->s.imag, - new_trial->f_def.real, new_trial->f_def.imag, new_trial->mag_def); - DEBUG(1) - if (new_trial->flags & ISANABERRATION) { - fprintf(stderr, "*** numerical aberration ***\n"); - } -} -#endif - -static void -check_flat(PZtrial *a, PZtrial *b) -{ - int diff_mag; - SPcomplex diff_frac; - double mult; - - diff_mag = a->mag_def - b->mag_def; - if (abs(diff_mag) <= 1) { - if (diff_mag == 1) - mult = 2.0; - else if (diff_mag == -1) - mult = 0.5; - else - mult = 1.0; - C_SUBEQ(diff_frac, mult * a->f_def, b->f_def); - C_MAG2(diff_frac); - if (diff_frac.real < 1.0e-20) - NFlat += 1; - } - /* XXX else NFlat = ?????? */ -} - -/* XXX ZZZ */ -int -CKTpzStep(int strat, PZtrial **set) -{ - switch (strat) { - case INIT: - if (!set[1]) { - set[1] = pzseek(ZeroTrial, 0); - } else if (!set[2]) - set[2] = pzseek(set[1], 1); - else if (!set[0]) - set[0] = pzseek(set[1], -1); - break; - - case SKIP_LEFT: - set[0] = pzseek(set[0], -1); - break; - - case SKIP_RIGHT: - set[2] = pzseek(set[2], 1); - break; - - case SHIFT_LEFT: - set[2] = set[1]; - set[1] = set[0]; - set[0] = pzseek(set[0], -1); - break; - - case SHIFT_RIGHT: - set[0] = set[1]; - set[1] = set[2]; - set[2] = pzseek(set[2], 1); - break; - - } - if (!set[0] || !set[1] || !set[2]) - return 0; - else - return 1; -} - -void -CKTpzReset(PZtrial **set) -{ - CKTpzTrapped = 0; - Consec_Moves = 0; - - set[1] = pzseek(ZeroTrial, 0); - if (set[1] != NULL) { - set[0] = pzseek(set[1], -1); - set[2] = pzseek(set[1], 1); - } else { - set[0] = NULL; - set[2] = NULL; - } -} - -static int -alter(PZtrial *new, PZtrial *nearto, double abstol, double reltol) -{ - double p1, p2; - -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "ALTER from: %.30g %.30g\n", - new->s.real, new->s.imag); - DEBUG(1) fprintf(stderr, "nt->next %g\n", nearto->prev->s.real); - DEBUG(1) fprintf(stderr, "nt->next %g\n", nearto->next->s.real); -#endif - - if (CKTpzTrapped != 2) { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "not 2\n"); -#endif - p1 = nearto->s.real; - if (nearto->flags & ISAROOT) - p1 -= 1e-6 * nearto->s.real + 1e-5; - if (nearto->prev) { - p1 += nearto->prev->s.real; -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "p1 %g\n", p1); -#endif - } else - p1 -= 10.0 * (fabs(p1) + 1.0); - - p1 /= 2.0; - } else - p1 = nearto->s.real; - - if (CKTpzTrapped != 1) { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "not 1\n"); -#endif - p2 = nearto->s.real; - if (nearto->flags & ISAROOT) - p2 += 1e-6 * nearto->s.real + 1e-5; /* XXX Would rather use pow(2)*/ - if (nearto->next) { - p2 += nearto->next->s.real; -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "p2 %g\n", p2); -#endif - } else - p2 += 10.0 * (fabs(p2)+ 1.0); - - p2 /= 2.0; - } else - p2 = nearto->s.real; - - if ((nearto->prev && - fabs(p1 - nearto->prev->s.real) / - fabs(nearto->prev->s.real) + abstol/reltol < reltol) - || - (nearto->next && - fabs(p2 - nearto->next->s.real) / - fabs(nearto->next->s.real) + abstol/reltol < reltol)) { - -#ifdef PZDEBUG - DEBUG(1) - fprintf(stderr, "Bailed out\n"); -#endif - - return 0; - } - - if (CKTpzTrapped != 2 && nearto->s.real - p1 > p2 - nearto->s.real) { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "take p1\n"); -#endif - new->s.real = p1; - } else { -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "take p2\n"); -#endif - new->s.real = p2; - } - -#ifdef PZDEBUG - DEBUG(1) fprintf(stderr, "ALTER to : %.30g %.30g\n", - new->s.real, new->s.imag); -#endif - return 1; - -} diff --git a/src/analysis/cktsens.c b/src/analysis/cktsens.c deleted file mode 100644 index 7ebc8e824..000000000 --- a/src/analysis/cktsens.c +++ /dev/null @@ -1,788 +0,0 @@ -/********** -Copyright 1991 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include "ifsim.h" -#include "sperror.h" -#include "spmatrix.h" -#include "gendefs.h" -#include "devdefs.h" -#include "cktdefs.h" -#include "smpdefs.h" -#include "sensdefs.h" -#include "sensgen.h" - -/* #define ASDEBUG */ -#ifdef ASDEBUG -#define DEBUG(X) if ((X) < Sens_Debug) -int Sens_Debug = 0; -char SF1[] = "res"; -char SF2[] = "dc"; -char SF3[] = "bf"; -#endif - -char *Sfilter = NULL; -double Sens_Delta = 0.000001; -double Sens_Abs_Delta = 0.000001; - -static int sens_setp(sgen *sg, CKTcircuit *ckt, IFvalue *val); -static int sens_load(sgen *sg, CKTcircuit *ckt, int is_dc); -static int sens_temp(sgen *sg, CKTcircuit *ckt); -static int count_steps(int type, double low, double high, int steps, double *stepsize); -static double inc_freq(double freq, int type, double step_size); - -extern SPICEdev *DEVices[]; - -/* - * Procedure: - * - * Determine operating point (call CKTop) - * - * For each frequency point: - * (for AC) call NIacIter to get base node voltages - * For each element/parameter in the test list: - * construct the perturbation matrix - * Solve for the sensitivities: - * delta_E = Y^-1 (delta_Y E - delta_I) - * save results - */ - -static int error; -int sens_sens(CKTcircuit *ckt, int restart) -{ - SENS_AN *sen_info = ((SENS_AN *) ckt->CKTcurJob); - static int size; - static double *delta_I, *delta_iI, - *delta_I_delta_Y, *delta_iI_delta_Y; - sgen *sg; - static double freq; - static int nfreqs; - static int i; - static SMPmatrix *delta_Y = NULL, *Y; - static double step_size; - double *E, *iE; - IFvalue value, nvalue; - double *output_values; - IFcomplex *output_cvalues; - double delta_var; - int (*fn)( ); - static int is_dc; - int k, j, n; - int num_vars, branch_eq; - char *sen_data; - char namebuf[513]; - IFuid *output_names, freq_name; - int bypass; - int type; - -#ifndef notdef -#ifdef notdef - for (sg = sgen_init(ckt, 0); sg; sgen_next(&sg)) { - if (sg->is_instparam) - printf("%s:%s:%s -> param %s\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword); - else - printf("%s:%s:%s -> mparam %s\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword); - } -#endif -#ifdef ASDEBUG - DEBUG(1) - printf(">>> restart : %d\n", restart); -#endif - - /* get to work */ - - restart = 1; - if (restart) { - - freq = 0.0; - is_dc = (sen_info->step_type == SENS_DC); - nfreqs = count_steps(sen_info->step_type, sen_info->start_freq, - sen_info->stop_freq, sen_info->n_freq_steps, - &step_size); - - if (!is_dc) - freq = sen_info->start_freq; - - error = CKTop(ckt, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - -#ifdef notdef - ckt->CKTmode = (ckt->CKTmode & MODEUIC) - | MODEDCOP | MODEINITSMSIG; -#endif - if (error) - return error; - - size = spGetSize(ckt->CKTmatrix, 1); - - /* Create the perturbation matrix */ - /* XXX check error return, '1' is complex -- necessary? - * only in ac */ - delta_Y = spCreate(size, !is_dc, &error); - - size += 1; - - /* Create an extra rhs */ - delta_I = NEWN(double, size); - delta_iI = NEWN(double, size); - - delta_I_delta_Y = NEWN(double, size); - delta_iI_delta_Y = NEWN(double, size); - - - num_vars = 0; - for (sg = sgen_init(ckt, is_dc); sg; sgen_next(&sg)) { - num_vars += 1; - } - - if (!num_vars) - return OK; /* XXXX Should be E_ something */ - - k = 0; - output_names = NEWN(IFuid, num_vars); - for (sg = sgen_init(ckt, is_dc); sg; sgen_next(&sg)) { - if (!sg->is_instparam) { - sprintf(namebuf, "%s:%s", - sg->instance->GENname, - sg->ptable[sg->param].keyword); - } else if ((sg->ptable[sg->param].dataType - & IF_PRINCIPAL) && sg->is_principle == 1) - { - sprintf(namebuf, "%s", sg->instance->GENname); - } else { - sprintf(namebuf, "%s_%s", - sg->instance->GENname, - sg->ptable[sg->param].keyword); - } - - (*SPfrontEnd->IFnewUid)((void *) ckt, - output_names + k, NULL, - namebuf, UID_OTHER, NULL); - k += 1; - } - - if (is_dc) { - type = IF_REAL; - freq_name = NULL; - } else { - type = IF_COMPLEX; - (*SPfrontEnd->IFnewUid)((void *) ckt, - &freq_name, NULL, - "frequency", UID_OTHER, NULL); - } - - error = (*SPfrontEnd->OUTpBeginPlot)((void *) ckt, - (void *) ckt->CKTcurJob, - ckt->CKTcurJob->JOBname, freq_name, IF_REAL, num_vars, - output_names, type, (void **) &sen_data); - if (error) - return error; - - FREE(output_names); - if (is_dc) { - output_values = NEWN(double, num_vars); - output_cvalues = NULL; - } else { - output_values = NULL; - output_cvalues = NEWN(IFcomplex, num_vars); - if (sen_info->step_type != SENS_LINEAR) - (*(SPfrontEnd->OUTattributes))((void *)sen_data, - NULL, OUT_SCALE_LOG, NULL); - - } - - } else { - /*XXX Restore saved state */ - } - -#ifdef ASDEBUG - DEBUG(1) - printf("start: %f, num: %d, dc: %d\n", freq, nfreqs, is_dc); -#endif - - if (!sen_info->output_volt) - branch_eq = CKTfndBranch(ckt, sen_info->output_src); - bypass = ckt->CKTbypass; - ckt->CKTbypass = 0; - - /* The unknown vector of node voltages overwrites rhs */ - E = ckt->CKTrhs; - iE = ckt->CKTirhs; - ckt->CKTrhsOld = E; - ckt->CKTirhsOld = iE; - Y = ckt->CKTmatrix; -#ifdef ASDEBUG - DEBUG(1) { - printf("Operating point:\n"); - for (i = 0; i < size; i++) - printf(" E [%d] = %20.15g\n", i, E[i]); - } -#endif - -#ifdef notdef - for (j = 0; j <= ckt->CKTmaxOrder + 1; j++) { - save_states[j] = ckt->CKTstates[j]; - ckt->CKTstates[j] = NULL; - } -#endif - - for (i = 0; i < nfreqs; i++) { - /* XXX handle restart */ - - n = 0; - - if ((*SPfrontEnd->IFpauseTest)( )) { - /* XXX Save State */ - return E_PAUSE; - } - - for (j = 0; j < size; j++) { - delta_I[j] = 0.0; - delta_iI[j] = 0.0; - } - - if (freq != 0.0) { - ckt->CKTrhs = E; - ckt->CKTirhs = iE; - ckt->CKTmatrix = Y; - - /* This generates Y in LU form */ - ckt->CKTomega = 2.0 * M_PI * freq; - - /* Yes, all this has to be re-done */ - /* XXX Free old states */ - error = CKTunsetup(ckt); - if (error) - return error; - - /* XXX ckt->CKTmatrix = Y; */ - - error = CKTsetup(ckt); - if (error) - return error; - - E = ckt->CKTrhs; - iE = ckt->CKTirhs; - Y = ckt->CKTmatrix; -#ifdef notdef - for (j = 0; j <= ckt->CKTmaxOrder + 1; j++) { - /* XXX Free new states */ - ckt->CKTstates[j] = save_states[j]; - } -#endif - error = CKTtemp(ckt); - if (error) - return error; - error = CKTload(ckt); /* INITSMSIGS */ - if (error) - return error; - error = NIacIter(ckt); - if (error) - return error; - -#ifdef notdef - /* XXX Why? */ - for (j = 0; j <= ckt->CKTmaxOrder + 1; j++) { - ckt->CKTstates[j] = NULL; - } -#endif - - } - - /* Use a different vector & matrix */ - ckt->CKTrhs = delta_I; - ckt->CKTirhs = delta_iI; - ckt->CKTmatrix = delta_Y; - - /* calc. effect of each param */ - for (sg = sgen_init(ckt, is_dc /* sen_info->plist */); - sg; sgen_next(&sg)) - { - -#ifdef ASDEBUG - DEBUG(2) { - printf("E/iE: %x/%x; delta_I/iI: %x/%x\n", - E, iE, delta_I, delta_iI); - printf("cktrhs/irhs: %x/%x\n", - ckt->CKTrhs, ckt->CKTirhs); - - if (sg->is_instparam) - printf("%s:%s:%s -> param %s\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword); - else - printf("%s:%s:%s -> mparam %s\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword); - } -#endif - - spClear(delta_Y); - - for (j = 0; j < size; j++) { - delta_I[j] = 0.0; - delta_iI[j] = 0.0; - } - - /* ? should this just call CKTsetup - * ? but then CKThead would have to get fiddled with */ - - ckt->CKTnumStates = sg->istate; - - fn = DEVices[sg->dev]->DEVsetup; - if (fn) - (*fn)(delta_Y, sg->model, ckt, - /* XXXX insert old state base here ?? */ - &ckt->CKTnumStates); - - /* ? CKTsetup would call NIreinit instead */ - ckt->CKTniState = NISHOULDREORDER | NIACSHOULDREORDER; - - /* XXX instead of calling temp here, just swap - * back to the original states */ - (void) sens_temp(sg, ckt); - - /* XXX Leave original E until here!! so that temp reads - * the right node voltages */ - - if (sens_load(sg, ckt, is_dc)) { - if (error && error != E_BADPARM) - return error; /* XXX */ - continue; - } - - /* Alter the parameter */ - -#ifdef ASDEBUG - DEBUG(1) printf("Original value: %g\n", sg->value); -#endif - -#ifdef ASDEBUG - DEBUG(2) { - printf("Effect of device:\n"); - spPrint(delta_Y, 0, 1, 1); - printf("LHS:\n"); - for (j = 0; j < size; j++) - printf("%d: %g, %g\n", j, - delta_I[j], delta_iI[j]); - } -#endif - - if (sg->value != 0.0) - delta_var = sg->value * Sens_Delta; - else - delta_var = Sens_Abs_Delta; - - nvalue.rValue = sg->value + delta_var; - -#ifdef ASDEBUG - DEBUG(1) - printf("New value: %g\n", nvalue.rValue); -#endif - - sens_setp(sg, ckt, &nvalue); - if (error && error != E_BADPARM) - return error; - - spConstMult(delta_Y, -1.0); - for (j = 0; j < size; j++) { - delta_I[j] *= -1.0; - delta_iI[j] *= -1.0; - } - -#ifdef ASDEBUG - DEBUG(2) { - printf("Effect of negating matrix:\n"); - spPrint(delta_Y, 0, 1, 1); - for (j = 0; j < size; j++) - printf("%d: %g, %g\n", j, - delta_I[j], delta_iI[j]); - } -#endif - - /* XXX swap back to temp states ?? Naw ... */ - (void) sens_temp(sg, ckt); - -#ifdef ASDEBUG - DEBUG(1) { - if (sens_getp(sg, ckt, &value)) { - continue; - } - - printf("New value in device: %g\n", - value.rValue); - } -#endif - - sens_load(sg, ckt, is_dc); - -#ifdef ASDEBUG - DEBUG(2) { - printf("Effect of changing the parameter:\n"); - spPrint(delta_Y, 0, 1, 1); - for (j = 0; j < size; j++) - printf("%d: %g, %g\n", j, - delta_I[j], delta_iI[j]); - } -#endif - /* Set the perturbed variable back to it's - * original value - */ - - value.rValue = sg->value; - sens_setp(sg, ckt, &value); - (void) sens_temp(sg, ckt); /* XXX is this necessary? */ - - /* Back to business . . . */ - -#ifdef ASDEBUG - DEBUG(2) - for (j = 0; j < size; j++) - printf(" E [%d] = %20.15g\n", - j, E[j]); -#endif - - /* delta_Y E */ - spMultiply(delta_Y, delta_I_delta_Y, E, - delta_iI_delta_Y, iE); - -#ifdef ASDEBUG - DEBUG(2) - for (j = 0; j < size; j++) - printf("delta_Y * E [%d] = %20.15g\n", - j, delta_I_delta_Y[j]); -#endif - - /* delta_I - delta_Y E */ - for (j = 0; j < size; j++) { - delta_I[j] -= delta_I_delta_Y[j]; - delta_iI[j] -= delta_iI_delta_Y[j]; - } - -#ifdef ASDEBUG - DEBUG(2) { - printf(">>> Y:\n"); - spPrint(Y, 0, 1, 1); - for (j = 0; j < size; j++) - printf("%d: %g, %g\n", j, - delta_I[j], delta_iI[j]); - } -#endif - /* Solve; Y already factored */ - spSolve(Y, delta_I, delta_I, delta_iI, delta_iI); - -#ifdef ASDEBUG - DEBUG(2) { - for (j = 1; j < size; j++) { - - if (sg->is_instparam) - printf("%d/%s.%s = %g, %g\n", - j, - sg->instance->GENname, - sg->ptable[sg->param].keyword, - delta_I[j], delta_iI[j]); - else - printf("%d/%s:%s = %g, %g\n", - j, - sg->instance->GENname, - sg->ptable[sg->param].keyword, - delta_I[j], delta_iI[j]); - - } - } -#endif - - /* delta_I is now equal to delta_E */ - - if (is_dc) { - if (sen_info->output_volt) - output_values[n] = delta_I - [sen_info->output_pos->number] - - delta_I - [sen_info->output_neg->number]; - else { - output_values[n] = delta_I[branch_eq]; - } - output_values[n] /= delta_var; - } else { - if (sen_info->output_volt) { - output_cvalues[n].real = delta_I - [sen_info->output_pos->number] - - delta_I - [sen_info->output_neg->number]; - output_cvalues[n].imag = delta_iI - [sen_info->output_pos->number] - - delta_iI - [sen_info->output_neg->number]; - } else { - output_cvalues[n].real = - delta_I[branch_eq]; - output_cvalues[n].imag = - delta_iI[branch_eq]; - } - output_cvalues[n].real /= delta_var; - output_cvalues[n].imag /= delta_var; - } - - n += 1; - - } - - if (is_dc) - nvalue.v.vec.rVec = output_values; - else - nvalue.v.vec.cVec = output_cvalues; - - value.rValue = freq; - OUTpData(sen_data, &value, &nvalue); - freq = inc_freq(freq, sen_info->step_type, step_size); - - } - - (*SPfrontEnd->OUTendPlot)((void *) sen_data); - - if (is_dc) { - FREE(output_values); /* XXX free various vectors */ - } else { - FREE(output_cvalues); /* XXX free various vectors */ - } - - spDestroy(delta_Y); - FREE(delta_I); - FREE(delta_iI); - - ckt->CKTrhs = E; - ckt->CKTirhs = iE; - ckt->CKTmatrix = Y; - ckt->CKTbypass = bypass; - -#ifdef notdef - for (j = 0; j <= ckt->CKTmaxOrder + 1; j++) { - if (ckt->CKTstates[j]) - FREE(ckt->CKTstates[j]); - ckt->CKTstates[j] = save_states[j]; - } -#endif -#endif - - return OK; -} - -double -inc_freq(double freq, int type, double step_size) -{ - if (type != LINEAR) - freq *= step_size; - else - freq += step_size; - - return freq; -} - -double -next_freq(int type, double freq, double stepsize) -{ - double s; - - switch (type) { - case SENS_DC: - s = 0; - break; - - case SENS_LINEAR: - s = freq + stepsize; - break; - - case SENS_DECADE: - case SENS_OCTAVE: - s = freq * stepsize; - break; - } - return s; -} - -int -count_steps(int type, double low, double high, int steps, double *stepsize) -{ - double s; - int n; - - if (steps < 1) - steps = 1; - - switch (type) { - default: - case SENS_DC: - n = 0; - s = 0; - break; - - case SENS_LINEAR: - n = steps; - s = (high - low) / steps; - break; - - case SENS_DECADE: - if (low <= 0.0) - low = 1e-3; - if (high <= low) - high = 10.0 * low; - n = steps * log10(high/low) + 1.01; - s = pow(10.0, 1.0 / steps); - break; - - case SENS_OCTAVE: - if (low <= 0.0) - low = 1e-3; - if (high <= low) - high = 2.0 * low; - n = steps * log(high/low) / M_LOG2E + 1.01; - s = pow(2.0, 1.0 / steps); - break; - } - - if (n <= 0) - n = 1; - - *stepsize = s; - return n; -} - -static int -sens_load(sgen *sg, CKTcircuit *ckt, int is_dc) -{ - int (*fn)( ); - - error = 0; - - if (!is_dc) - fn = DEVices[sg->dev]->DEVacLoad; - else - fn = DEVices[sg->dev]->DEVload; - - if (fn) - error = (*fn)(sg->model, ckt); - else - return 1; - - return error; -} - - -static int -sens_temp(sgen *sg, CKTcircuit *ckt) -{ - int (*fn)( ); - - error = 0; - - fn = DEVices[sg->dev]->DEVtemperature; - - if (fn) - error = (*fn)(sg->model, ckt); - else - return 1; - - return error; -} - -/* Get parameter value */ -int -sens_getp(sgen *sg, CKTcircuit *ckt, IFvalue *val) -{ - int (*fn)( ); - int pid; - - error = 0; - - if (sg->is_instparam) { - fn = DEVices[sg->dev]->DEVask; - pid = DEVices[sg->dev]->DEVpublic.instanceParms[sg->param].id; - if (fn) - error = (*fn)(ckt, sg->instance, pid, val, NULL); - else - return 1; - } else { - fn = DEVices[sg->dev]->DEVmodAsk; - pid = DEVices[sg->dev]->DEVpublic.modelParms[sg->param].id; - if (fn) - error = (*fn)(ckt, sg->model, pid, val, NULL); - else - return 1; - } - - if (error) { - if (sg->is_instparam) - printf("GET ERROR: %s:%s:%s -> param %s (%d)\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword, pid); - else - printf("GET ERROR: %s:%s:%s -> mparam %s (%d)\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword, pid); - } - - return error; -} - -/* Get parameter value */ -int -sens_setp(sgen *sg, CKTcircuit *ckt, IFvalue *val) -{ - int (*fn)( ); - int pid; - - error = 0; - - if (sg->is_instparam) { - fn = DEVices[sg->dev]->DEVparam; - pid = DEVices[sg->dev]->DEVpublic.instanceParms[sg->param].id; - if (fn) - error = (*fn)(pid, val, sg->instance, NULL); - else - return 1; - } else { - fn = DEVices[sg->dev]->DEVmodParam; - pid = DEVices[sg->dev]->DEVpublic.modelParms[sg->param].id; - if (fn) - error = (*fn)(pid, val, sg->model); - else - return 1; - } - - if (error) { - if (sg->is_instparam) - printf("SET ERROR: %s:%s:%s -> param %s (%d)\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword, pid); - else - printf("SET ERROR: %s:%s:%s -> mparam %s (%d)\n", - DEVices[sg->dev]->DEVpublic.name, - sg->model->GENmodName, - sg->instance->GENname, - sg->ptable[sg->param].keyword, pid); - } - - return error; -} diff --git a/src/analysis/cktsetap.c b/src/analysis/cktsetap.c deleted file mode 100644 index 657b670b1..000000000 --- a/src/analysis/cktsetap.c +++ /dev/null @@ -1,24 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "tskdefs.h" -#include "jobdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" - - -extern SPICEanalysis *analInfo[]; - -/* ARGSUSED */ -int -CKTsetAnalPm(void *ckt, void *analPtr, int parm, IFvalue *value, IFvalue *selector) -{ - register int type = ((JOB *)analPtr)->JOBtype; - if((analInfo[type]->setParm)==NULL) return(E_BADPARM); - return( (*(analInfo[type]->setParm))(ckt,analPtr,parm,value) ); -} diff --git a/src/analysis/cktsetbk.c b/src/analysis/cktsetbk.c deleted file mode 100644 index 77ed328a5..000000000 --- a/src/analysis/cktsetbk.c +++ /dev/null @@ -1,69 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* CKTsetBreak(ckt,time) - * add the given time to the breakpoint table for the given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" - - - -int -CKTsetBreak(register CKTcircuit *ckt, double time) -{ - double *tmp; - register int i,j; - - if(ckt->CKTtime > time) { - (*(SPfrontEnd->IFerror))(ERR_PANIC,"breakpoint in the past - HELP!", - (IFuid *)NULL); - return(E_INTERN); - } - for(i=0;iCKTbreakSize;i++) { - if(*(ckt->CKTbreaks+i)>time) { /* passed */ - if((*(ckt->CKTbreaks+i)-time) <= ckt->CKTminBreak) { - /* very close together - take earlier point */ - *(ckt->CKTbreaks+i) = time; - return(OK); - } - if(time-*(ckt->CKTbreaks+i-1) <= ckt->CKTminBreak) { - /* very close together, but after, so skip */ - return(OK); - } - /* fits in middle - new array & insert */ - tmp = (double *)MALLOC((ckt->CKTbreakSize+1)*sizeof(double)); - if(tmp == (double *)NULL) return(E_NOMEM); - for(j=0;jCKTbreaks+j); - } - *(tmp+i)=time; - for(j=i;jCKTbreakSize;j++) { - *(tmp+j+1) = *(ckt->CKTbreaks+j); - } - FREE(ckt->CKTbreaks); - ckt->CKTbreakSize++; - ckt->CKTbreaks=tmp; - return(OK); - } - } - /* never found it - beyond end of time - extend out idea of time */ - if(time-ckt->CKTbreaks[ckt->CKTbreakSize-1]<=ckt->CKTminBreak) { - /* very close tegether - keep earlier, throw out new point */ - return(OK); - } - /* fits at end - grow array & add on */ - ckt->CKTbreaks = (double *)REALLOC(ckt->CKTbreaks, - (ckt->CKTbreakSize+1)*sizeof(double)); - ckt->CKTbreakSize++; - ckt->CKTbreaks[ckt->CKTbreakSize-1]=time; - return(OK); -} diff --git a/src/analysis/cktsetnp.c b/src/analysis/cktsetnp.c deleted file mode 100644 index db4c86010..000000000 --- a/src/analysis/cktsetnp.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - *CKTsetNodPm - * - * set a parameter on a node. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" - - - -/* ARGSUSED */ -int -CKTsetNodPm(void *ckt, void *node, int parm, IFvalue *value, IFvalue *selector) -{ - if(!node) return(E_BADPARM); - switch(parm) { - - case PARM_NS: - ((CKTnode *)node)->nodeset = value->rValue; - ((CKTnode *)node)->nsGiven = 1; - break; - - case PARM_IC: - ((CKTnode *)node)->ic = value->rValue; - ((CKTnode *)node)->icGiven = 1; - break; - - case PARM_NODETYPE: - ((CKTnode *)node)->type = value->iValue; - break; - - default: - return(E_BADPARM); - } - return(OK); -} diff --git a/src/analysis/cktsetup.c b/src/analysis/cktsetup.c deleted file mode 100644 index 096c0a78c..000000000 --- a/src/analysis/cktsetup.c +++ /dev/null @@ -1,112 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTsetup(ckt) - * this is a driver program to iterate through all the various - * setup functions provided for the circuit elements in the - * given circuit - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - - -#define CKALLOC(var,size,type) \ - if(size && (!(var =(type *)MALLOC((size)*sizeof(type))))){\ - return(E_NOMEM);\ -} - -extern SPICEdev *DEVices[]; - -int -CKTsetup(register CKTcircuit *ckt) -{ - register int i; - int error; - - register SMPmatrix *matrix; - ckt->CKTnumStates=0; - -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo){ - if (error = CKTsenSetup(ckt)) return(error); - } -#endif - - if (ckt->CKTisSetup) - return E_NOCHANGE; - - CKTpartition(ckt); - - error = NIinit(ckt); - if (error) return(error); - ckt->CKTisSetup = 1; - - matrix = ckt->CKTmatrix; - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVsetup))(matrix,ckt->CKThead[i],ckt, - &ckt->CKTnumStates); - if(error) return(error); - } - } - for(i=0;i<=ckt->CKTmaxOrder+1;i++) { - CKALLOC(ckt->CKTstates[i],ckt->CKTnumStates,double); - } -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo){ - /* to allocate memory to sensitivity structures if - * it is not done before */ - - error = NIsenReinit(ckt); - if(error) return(error); - } -#endif - if(ckt->CKTniState & NIUNINITIALIZED) { - error = NIreinit(ckt); - if(error) return(error); - } - - return(OK); -} - -int -CKTunsetup(CKTcircuit *ckt) -{ - int i, error, e2; - - error = OK; - if (!ckt->CKTisSetup) - return OK; - - for(i=0;i<=ckt->CKTmaxOrder+1;i++) { - tfree(ckt->CKTstates[i]); - } - - for (i=0;iCKThead[i] != NULL) ){ - e2 = (*((*DEVices[i]).DEVunsetup))(ckt->CKThead[i],ckt); - if (!error && e2) - error = e2; - } - } - ckt->CKTisSetup = 0; - if(error) return(error); - - NIdestroy(ckt); - /* - if (ckt->CKTmatrix) - SMPdestroy(ckt->CKTmatrix); - ckt->CKTmatrix = NULL; - */ - - return OK; -} diff --git a/src/analysis/cktsgen.c b/src/analysis/cktsgen.c deleted file mode 100644 index e431807db..000000000 --- a/src/analysis/cktsgen.c +++ /dev/null @@ -1,250 +0,0 @@ -/********** -Copyright 1991 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include "gendefs.h" -#include "devdefs.h" -#include "cktdefs.h" -#include "ifsim.h" -#include "sensgen.h" -#include - -extern SPICEdev *DEVices[]; /* XXX */ -extern char *Sfilter; - -sgen * -sgen_init(CKTcircuit *ckt, int is_dc) -{ - sgen *sg; - - sg = NEW(sgen); - sg->param = 99999; - sg->is_instparam = 0; - sg->dev = -1; - sg->istate = 0; - sg->ckt = ckt; - sg->devlist = ckt->CKThead; - sg->instance = sg->first_instance = sg->next_instance = NULL; - sg->model = sg->next_model = NULL; - sg->ptable = NULL; - sg->is_dc = is_dc; - sg->is_principle = 0; - sg->is_q = 0; - sg->is_zerook = 0; - sg->value = 0.0; - - sgen_next(&sg); /* get the ball rolling XXX check return val? */ - - return sg; -} - -int -sgen_next(sgen **xsg) -{ - sgen *sg = *xsg; - int good, done; - int i; - - done = 0; - i = sg->dev; - - do { - if (sg->instance) { - if (sg->ptable) { - do { - sg->param += 1; - } while (sg->param < sg->max_param - && !set_param(sg)); - } else { - sg->max_param = -1; - } - - if (sg->param < sg->max_param) { - done = 1; - } else if (!sg->is_instparam) { - /* Try instance parameters now */ - sg->is_instparam = 1; - sg->param = -1; - sg->max_param = - *DEVices[i]->DEVpublic.numInstanceParms; - sg->ptable = - DEVices[i]->DEVpublic.instanceParms; - } else { - sg->is_principle = 0; - sg->instance->GENnextInstance = - sg->next_instance; - sg->instance->GENstate = sg->istate; - sg->instance = NULL; - } - - } else if (sg->model) { - - /* Find the first/next good instance for this model */ - for (good = 0; !good && sg->next_instance; - good = set_inst(sg)) - { - sg->instance = sg->next_instance; - sg->next_instance = - sg->instance->GENnextInstance; - } - - - if (good) { - sg->is_principle = 0; - sg->istate = sg->instance->GENstate; - sg->instance->GENnextInstance = NULL; - sg->model->GENinstances = sg->instance; - if (DEVices[i]->DEVpublic.modelParms) { - sg->max_param = - *DEVices[i]->DEVpublic. - numModelParms; - sg->ptable = - DEVices[i]->DEVpublic. - modelParms; - } else { - sg->ptable = NULL; - } - sg->param = -1; - sg->is_instparam = 0; - } else { - /* No good instances of this model */ - sg->model->GENinstances = sg->first_instance; - sg->model->GENnextModel = sg->next_model; - sg->model = NULL; - } - - } else if (i >= 0) { - - /* Find the first/next good model for this device */ - for (good = 0; !good && sg->next_model; - good = set_model(sg)) - { - sg->model = sg->next_model; - sg->next_model = sg->model->GENnextModel; - } - - if (good) { - sg->model->GENnextModel = NULL; - sg->devlist[i] = sg->model; - if (DEVices[i]->DEVpublic.modelParms) { - sg->max_param = - *DEVices[i]->DEVpublic. - numModelParms; - sg->ptable = - DEVices[i]->DEVpublic. - modelParms; - } else { - sg->ptable = NULL; - } - sg->next_instance = sg->first_instance - = sg->model->GENinstances; - } else { - /* No more good models for this device */ - sg->devlist[i] = sg->first_model; - i = -1; /* Try the next good device */ - } - - } else if (i < DEVmaxnum && sg->dev < DEVmaxnum) { - - /* Find the next good device in this circuit */ - - do - sg->dev++; - while (sg->dev < DEVmaxnum && sg->devlist[sg->dev] - && !set_dev(sg)); - - i = sg->dev; - - if (i > DEVmaxnum) - done = 1; - sg->first_model = sg->next_model = sg->devlist[i]; - - } else { - done = 1; - } - - } while (!done); - - if (sg->dev >= DEVmaxnum) { - FREE(sg); - *xsg = NULL; - } - return 1; -} - -int set_inst(sgen *sg) -{ - return 1; -} - -int set_model(sgen *sg) -{ - return 1; -} - -int set_dev(sgen *sg) -{ - return 1; -} - -int set_param(sgen *sg) -{ - IFvalue ifval; - - if (!sg->ptable[sg->param].keyword) - return 0; - if (Sfilter && strncmp(sg->ptable[sg->param].keyword, Sfilter, - strlen(Sfilter))) - return 0; - if ((sg->ptable[sg->param].dataType & - (IF_SET|IF_ASK|IF_REAL|IF_VECTOR|IF_REDUNDANT|IF_NONSENSE)) - != (IF_SET|IF_ASK|IF_REAL)) - return 0; - if (sg->is_dc && - (sg->ptable[sg->param].dataType & (IF_AC | IF_AC_ONLY))) - return 0; - if ((sg->ptable[sg->param].dataType & IF_CHKQUERY) && !sg->is_q) - return 0; - - if (sens_getp(sg, sg->ckt, &ifval)) - return 0; - - if (fabs(ifval.rValue) < 1e-30) { - if (sg->ptable[sg->param].dataType & IF_SETQUERY) - sg->is_q = 0; - - if (!sg->is_zerook - && !(sg->ptable[sg->param].dataType & IF_PRINCIPAL)) - return 0; - - } else if (sg->ptable[sg->param].dataType & (IF_SETQUERY|IF_ORQUERY)) - sg->is_q = 1; - - if (sg->ptable[sg->param].dataType & IF_PRINCIPAL) - sg->is_principle += 1; - - sg->value = ifval.rValue; - - return 1; -} - -#ifdef notdef -sgen_suspend(sg) - sgen *sg; -{ - sg->devlist[sg->dev] = sg->first_model; - sg->model->GENnextModel = sg->next_model; - sg->instance->GENnextInstance = sg->next_instance; - sg->model->GENinstances = sg->first_instance; -} - -sgen_restore(sg) - sgen *sg; -{ - sg->devlist[sg->dev] = sg->model; - sg->model->GENnextModel = NULL; - sg->instance->GENnextInstance = NULL; - sg->model->GENinstances = sg->instance; -} -#endif diff --git a/src/analysis/cktsopt.c b/src/analysis/cktsopt.c deleted file mode 100644 index eba172ad7..000000000 --- a/src/analysis/cktsopt.c +++ /dev/null @@ -1,223 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - * CKTsetOpt(ckt,opt,value) - * set the specified 'opt' to have value 'value' in the - * given circuit 'ckt'. - */ - -#include "ngspice.h" -#include -#include "const.h" -#include "optdefs.h" -#include "tskdefs.h" -#include "ifsim.h" -#include "cktdefs.h" -#include "sperror.h" - - -/* ARGSUSED */ -int -CKTsetOpt(void *ckt, void *anal, int opt, IFvalue *val) -{ - register TSKtask *task = (TSKtask *)anal; - - switch(opt) { - - case OPT_NOOPITER: - task->TSKnoOpIter = val->iValue; - break; - case OPT_GMIN: - task->TSKgmin = val->rValue; - break; - case OPT_RELTOL: - task->TSKreltol = val->rValue; - break; - case OPT_ABSTOL: - task->TSKabstol = val->rValue; - break; - case OPT_VNTOL: - task->TSKvoltTol = val->rValue; - break; - case OPT_TRTOL: - task->TSKtrtol = val->rValue; - break; - case OPT_CHGTOL: - task->TSKchgtol = val->rValue; - break; - case OPT_PIVTOL: - task->TSKpivotAbsTol = val->rValue; - break; - case OPT_PIVREL: - task->TSKpivotRelTol = val->rValue; - break; - case OPT_TNOM: - task->TSKnomTemp = val->rValue + CONSTCtoK; /* Centegrade to Kelvin */ - break; - case OPT_TEMP: - task->TSKtemp = val->rValue + CONSTCtoK; /* Centegrade to Kelvin */ - break; - case OPT_ITL1: - task->TSKdcMaxIter = val->iValue; - break; - case OPT_ITL2: - task->TSKdcTrcvMaxIter = val->iValue; - break; - case OPT_ITL3: - break; - case OPT_ITL4: - task->TSKtranMaxIter = val->iValue; - break; - case OPT_ITL5: - break; - case OPT_SRCSTEPS: - task->TSKnumSrcSteps = val->iValue; - break; - case OPT_GMINSTEPS: - task->TSKnumGminSteps = val->iValue; - break; - case OPT_DEFL: - task->TSKdefaultMosL = val->rValue; - break; - case OPT_DEFW: - task->TSKdefaultMosW = val->rValue; - break; - case OPT_DEFAD: - task->TSKdefaultMosAD = val->rValue; - break; - case OPT_DEFAS: - task->TSKdefaultMosAD = val->rValue; - break; - case OPT_BYPASS: - task->TSKbypass = val->iValue; - break; - case OPT_MAXORD: - task->TSKmaxOrder = val->iValue; - break; - case OPT_OLDLIMIT: - task->TSKfixLimit = val->iValue; - break; - case OPT_MINBREAK: - task->TSKminBreak = val->rValue; - break; - case OPT_METHOD: - if(strncmp(val->sValue,"trap", 4)==0) - task->TSKintegrateMethod=TRAPEZOIDAL; - else if (strcmp(val->sValue,"gear")==0) - task->TSKintegrateMethod=GEAR; - else return(E_METHOD); - break; - case OPT_TRYTOCOMPACT: - task->TSKtryToCompact = val->iValue; - break; - case OPT_BADMOS3: - task->TSKbadMos3 = val->iValue; - break; - case OPT_KEEPOPINFO: - task->TSKkeepOpInfo = val->iValue; - break; - default: - return(-1); - } - return(0); -} -static IFparm OPTtbl[] = { - { "noopiter", OPT_NOOPITER,IF_SET|IF_FLAG,"Go directly to gmin stepping" }, - { "gmin", OPT_GMIN,IF_SET|IF_REAL,"Minimum conductance" }, - { "reltol", OPT_RELTOL,IF_SET|IF_REAL ,"Relative error tolerence"}, - { "abstol", OPT_ABSTOL,IF_SET|IF_REAL,"Absolute error tolerence" }, - { "vntol", OPT_VNTOL,IF_SET|IF_REAL,"Voltage error tolerence" }, - { "trtol", OPT_TRTOL,IF_SET|IF_REAL,"Truncation error overestimation factor" }, - { "chgtol", OPT_CHGTOL,IF_SET|IF_REAL, "Charge error tolerence" }, - { "pivtol", OPT_PIVTOL,IF_SET|IF_REAL, "Minimum acceptable pivot" }, - { "pivrel", OPT_PIVREL,IF_SET|IF_REAL, "Minimum acceptable ratio of pivot" }, - { "tnom", OPT_TNOM,IF_SET|IF_ASK|IF_REAL, "Nominal temperature" }, - { "temp", OPT_TEMP,IF_SET|IF_ASK|IF_REAL, "Operating temperature" }, - { "itl1", OPT_ITL1,IF_SET|IF_INTEGER,"DC iteration limit" }, - { "itl2", OPT_ITL2,IF_SET|IF_INTEGER,"DC transfer curve iteration limit" }, - { "itl3", OPT_ITL3, IF_INTEGER,"Lower transient iteration limit"}, - { "itl4", OPT_ITL4,IF_SET|IF_INTEGER,"Upper transient iteration limit" }, - { "itl5", OPT_ITL5, IF_INTEGER,"Total transient iteration limit"}, - { "itl6", OPT_SRCSTEPS, IF_SET|IF_INTEGER,"number of source steps"}, - { "srcsteps", OPT_SRCSTEPS, IF_SET|IF_INTEGER,"number of source steps"}, - { "gminsteps", OPT_GMINSTEPS, IF_SET|IF_INTEGER,"number of Gmin steps"}, - { "acct", 0, IF_FLAG ,"Print accounting"}, - { "list", 0, IF_FLAG, "Print a listing" }, - { "nomod", 0, IF_FLAG, "Don't print a model summary" }, - { "nopage", 0, IF_FLAG, "Don't insert page breaks" }, - { "node", 0, IF_FLAG,"Print a node connection summary" }, - { "opts", 0, IF_FLAG, "Print a list of the options" }, - { "oldlimit", OPT_OLDLIMIT, IF_SET|IF_FLAG, "use SPICE2 MOSfet limiting" }, - { "numdgt", 0, IF_INTEGER, "Set number of digits printed"}, - { "cptime", 0, IF_REAL, "Total cpu time in seconds" }, - { "limtim", 0, IF_INTEGER, "Time to reserve for output" }, - { "limpts", 0,IF_INTEGER,"Maximum points per analysis"}, - { "lvlcod", 0, IF_INTEGER,"Generate machine code" }, - { "lvltim", 0, IF_INTEGER,"Type of timestep control" }, - { "method", OPT_METHOD, IF_SET|IF_STRING,"Integration method" }, - { "maxord", OPT_MAXORD, IF_SET|IF_INTEGER,"Maximum integration order" }, - { "defl", OPT_DEFL,IF_SET|IF_REAL,"Default MOSfet length" }, - { "defw", OPT_DEFW,IF_SET|IF_REAL,"Default MOSfet width" }, - { "minbreak", OPT_MINBREAK,IF_SET|IF_REAL,"Minimum time between breakpoints" }, - { "defad", OPT_DEFAD,IF_SET|IF_REAL,"Default MOSfet area of drain" }, - { "defas", OPT_DEFAS,IF_SET|IF_REAL,"Default MOSfet area of source" }, - { "bypass",OPT_BYPASS,IF_SET|IF_INTEGER,"Allow bypass of unchanging elements"}, - { "totiter", OPT_ITERS, IF_ASK|IF_INTEGER,"Total iterations" }, - { "traniter", OPT_TRANIT, IF_ASK|IF_INTEGER ,"Transient iterations"}, - { "equations", OPT_EQNS, IF_ASK|IF_INTEGER,"Circuit Equations" }, - { "originalnz", OPT_ORIGNZ, IF_ASK|IF_INTEGER,"Circuit original non-zeroes" }, - { "fillinnz", OPT_FILLNZ, IF_ASK|IF_INTEGER,"Circuit fill-in non-zeroes" }, - { "totalnz", OPT_TOTALNZ, IF_ASK|IF_INTEGER,"Circuit total non-zeroes" }, - { "tranpoints", OPT_TRANPTS, IF_ASK|IF_INTEGER,"Transient timepoints" }, - { "accept", OPT_TRANACCPT, IF_ASK|IF_INTEGER,"Accepted timepoints" }, - { "rejected", OPT_TRANRJCT, IF_ASK|IF_INTEGER,"Rejected timepoints" }, - { "time", OPT_TOTANALTIME, IF_ASK|IF_REAL,"Total analysis time" }, - { "loadtime", OPT_LOADTIME, IF_ASK|IF_REAL,"Matrix load time" }, - { "synctime", OPT_SYNCTIME, IF_ASK|IF_REAL,"Matrix synchronize time" }, - { "combinetime", OPT_COMBTIME, IF_ASK|IF_REAL,"Matrix combine time" }, - { "reordertime", OPT_REORDTIME, IF_ASK|IF_REAL,"Matrix reorder time" }, - { "factortime", OPT_DECOMP, IF_ASK|IF_REAL,"Matrix factor time" }, - { "solvetime", OPT_SOLVE, IF_ASK|IF_REAL,"Matrix solve time" }, - { "trantime", OPT_TRANTIME, IF_ASK|IF_REAL,"Transient analysis time" }, - { "tranloadtime", OPT_TRANLOAD, IF_ASK|IF_REAL,"Transient load time" }, - { "transynctime", OPT_TRANSYNC, IF_ASK|IF_REAL,"Transient sync time" }, - { "trancombinetime", OPT_TRANCOMB, IF_ASK|IF_REAL,"Transient combine time" }, - { "tranfactortime", OPT_TRANDECOMP,IF_ASK|IF_REAL,"Transient factor time" }, - { "transolvetime", OPT_TRANSOLVE, IF_ASK|IF_REAL,"Transient solve time" }, - { "trantrunctime", OPT_TRANTRUNC, IF_ASK|IF_REAL,"Transient trunc time" }, - { "trancuriters", OPT_TRANCURITER, IF_ASK|IF_INTEGER, - "Transient iters per point" }, - { "actime", OPT_ACTIME, IF_ASK|IF_REAL,"AC analysis time" }, - { "acloadtime", OPT_ACLOAD, IF_ASK|IF_REAL,"AC load time" }, - { "acsynctime", OPT_ACSYNC, IF_ASK|IF_REAL,"AC sync time" }, - { "accombinetime", OPT_ACCOMB, IF_ASK|IF_REAL,"AC combine time" }, - { "acfactortime", OPT_ACDECOMP,IF_ASK|IF_REAL,"AC factor time" }, - { "acsolvetime", OPT_ACSOLVE, IF_ASK|IF_REAL,"AC solve time" }, - { "trytocompact", OPT_TRYTOCOMPACT, IF_SET|IF_FLAG, - "Try compaction for LTRA lines" }, - { "badmos3", OPT_BADMOS3, IF_SET|IF_FLAG, - "use old mos3 model (discontinuous with respect to kappa)" }, - { "keepopinfo", OPT_KEEPOPINFO, IF_SET|IF_FLAG, - "Record operating point for each small-signal analysis" } -}; - -int OPTcount = sizeof(OPTtbl)/sizeof(IFparm); - -SPICEanalysis OPTinfo = { - { - "options", - "Task option selection", - sizeof(OPTtbl)/sizeof(IFparm), - OPTtbl - }, - 0, /* no size associated with options */ - NODOMAIN, - 0, - CKTsetOpt, - CKTacct, - NULL, - NULL -}; diff --git a/src/analysis/ckttemp.c b/src/analysis/ckttemp.c deleted file mode 100644 index fa93cfda4..000000000 --- a/src/analysis/ckttemp.c +++ /dev/null @@ -1,40 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTtemp(ckt) - * this is a driver program to iterate through all the various - * temperature dependency functions provided for the circuit - * elements in the given circuit - */ - -#include "ngspice.h" -#include -#include "smpdefs.h" -#include "cktdefs.h" -#include "const.h" -#include "devdefs.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; - -int -CKTtemp(register CKTcircuit *ckt) -{ - int error; - register int i; - - ckt->CKTvt = CONSTKoverQ * ckt->CKTtemp; - - for (i=0;iCKThead[i] != NULL) ){ - error = (*((*DEVices[i]).DEVtemperature))(ckt->CKThead[i],ckt); - if(error) return(error); - } - } - return(OK); -} diff --git a/src/analysis/cktterr.c b/src/analysis/cktterr.c deleted file mode 100644 index 6f3493c62..000000000 --- a/src/analysis/cktterr.c +++ /dev/null @@ -1,79 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" - - - -#define ccap (qcap+1) - -void -CKTterr(register int qcap, register CKTcircuit *ckt, register double *timeStep) -{ - double volttol; - double chargetol; - double tol; - double del; - double diff[8]; - double deltmp[8]; - double factor; - register int i; - register int j; - static double gearCoeff[] = { - .5, - .2222222222, - .1363636364, - .096, - .07299270073, - .05830903790 - }; - static double trapCoeff[] = { - .5, - .08333333333 - }; - - volttol = ckt->CKTabstol + ckt->CKTreltol * - MAX( fabs(*(ckt->CKTstate0+ccap)), fabs(*(ckt->CKTstate1+ccap))); - - chargetol = MAX(fabs(*(ckt->CKTstate0 +qcap)),fabs(*(ckt->CKTstate1+qcap))); - chargetol = ckt->CKTreltol * MAX(chargetol,ckt->CKTchgtol)/ckt->CKTdelta; - tol = MAX(volttol,chargetol); - /* now divided differences */ - for(i=ckt->CKTorder+1;i>=0;i--) { - diff[i] = *(ckt->CKTstates[i] + qcap); - } - for(i=0 ; i <= ckt->CKTorder ; i++) { - deltmp[i] = ckt->CKTdeltaOld[i]; - } - j = ckt->CKTorder; - while(1) { - for(i=0;i <= j;i++) { - diff[i] = (diff[i] - diff[i+1])/deltmp[i]; - } - if (--j < 0) break; - for(i=0;i <= j;i++) { - deltmp[i] = deltmp[i+1] + ckt->CKTdeltaOld[i]; - } - } - switch(ckt->CKTintegrateMethod) { - case GEAR: - factor = gearCoeff[ckt->CKTorder-1]; - break; - - case TRAPEZOIDAL: - factor = trapCoeff[ckt->CKTorder - 1] ; - break; - } - del = ckt->CKTtrtol * tol/MAX(ckt->CKTabstol,factor * fabs(diff[0])); - if(ckt->CKTorder == 2) { - del = sqrt(del); - } else if (ckt->CKTorder > 2) { - del = exp(log(del)/ckt->CKTorder); - } - *timeStep = MIN(*timeStep,del); - return; -} diff --git a/src/analysis/ckttroub.c b/src/analysis/ckttroub.c deleted file mode 100644 index 0cdca9bd3..000000000 --- a/src/analysis/ckttroub.c +++ /dev/null @@ -1,96 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include -#include "trandefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "vsrc/vsrcdefs.h" -#include "isrc/isrcdefs.h" -#include "jobdefs.h" - - -extern SPICEdev *DEVices[]; -extern SPICEanalysis *analInfo[]; - -char * -CKTtrouble(void *cktp, char *optmsg) -{ - CKTcircuit *ckt = (CKTcircuit *) cktp; - char msg_buf[513]; - char *emsg; - TRCV *cv; - int vcode, icode; - char *msg_p; - SPICEanalysis *an; - int i; - - if (!ckt || !ckt->CKTcurJob) - return NULL; - - an = analInfo[ckt->CKTcurJob->JOBtype]; - - if (optmsg && *optmsg) { - sprintf(msg_buf, "%s: %s; ", an->public.name, optmsg); - } else { - sprintf(msg_buf, "%s: ", an->public.name); - } - - msg_p = msg_buf + strlen(msg_buf); - - switch (an->domain) { - case TIMEDOMAIN: - if (ckt->CKTtime == 0.0) - sprintf(msg_p, "initial timepoint: "); - else - sprintf(msg_p, "time = %g, timestep = %g: ", ckt->CKTtime, - ckt->CKTdelta); - break; - - case FREQUENCYDOMAIN: - sprintf(msg_p, "frequency = %g: ", ckt->CKTomega / (2.0 * M_PI)); - break; - - case SWEEPDOMAIN: - cv = (TRCV*) ckt->CKTcurJob; - vcode = CKTtypelook("Vsource"); - icode = CKTtypelook("Isource"); - - for (i = 0; i <= cv->TRCVnestLevel; i++) { - msg_p += strlen(msg_p); - if(cv->TRCVvType[i]==vcode) { /* voltage source */ - sprintf(msg_p, " %s = %g: ", cv->TRCVvName[i], - ((VSRCinstance*)(cv->TRCVvElt[i]))->VSRCdcValue); - } else { - sprintf(msg_p, " %s = %g: ", cv->TRCVvName[i], - ((ISRCinstance*)(cv->TRCVvElt[i]))->ISRCdcValue); - } - } - break; - - case NODOMAIN: - default: - break; - } - - msg_p += strlen(msg_p); - - if (ckt->CKTtroubleNode) { - sprintf(msg_p, "trouble with node \"%s\"\n", - CKTnodName(ckt, ckt->CKTtroubleNode)); - } else if (ckt->CKTtroubleElt) { - /* "-" for dop */ - sprintf(msg_p, "trouble with %s-instance %s\n", - ckt->CKTtroubleElt->GENmodPtr->GENmodName, - ckt->CKTtroubleElt->GENname); - } else { - sprintf(msg_p, "cause unrecorded.\n"); - } - - emsg = MALLOC(strlen(msg_buf)+1); - strcpy(emsg,msg_buf); - - return emsg; -} diff --git a/src/analysis/ckttrunc.c b/src/analysis/ckttrunc.c deleted file mode 100644 index 3baed0e50..000000000 --- a/src/analysis/ckttrunc.c +++ /dev/null @@ -1,201 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* CKTtrunc(ckt) - * this is a driver program to iterate through all the various - * truncation error functions provided for the circuit elements in the - * given circuit - */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "smpdefs.h" -#include "devdefs.h" -#include "sperror.h" - - - -extern SPICEdev *DEVices[]; - -int -CKTtrunc(register CKTcircuit *ckt, double *timeStep) -{ -#ifndef NEWTRUNC - register int i; - double timetemp; -#ifdef PARALLEL_ARCH - long type = MT_TRUNC, length = 1; -#endif /* PARALLEL_ARCH */ -#ifdef STEPDEBUG - double debugtemp; -#endif /* STEPDEBUG */ - double startTime; - int error = OK; - - startTime = SPfrontEnd->IFseconds(); - - timetemp = HUGE; - for (i=0;iCKThead[i] != NULL) { -#ifdef STEPDEBUG - debugtemp = timetemp; -#endif /* STEPDEBUG */ - error = (*((*DEVices[i]).DEVtrunc))(ckt->CKThead[i],ckt,&timetemp); - if(error) { - ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - - startTime; - return(error); - } -#ifdef STEPDEBUG - if(debugtemp != timetemp) { - printf("timestep cut by device type %s from %g to %g\n", - (*DEVices[i]).DEVpublic.name, debugtemp,timetemp); - } -#endif /* STEPDEBUG */ - } - } - *timeStep = MIN(2 * *timeStep,timetemp); - -#ifdef PARALLEL_ARCH - DGOP_( &type, timeStep, &length, "min" ); -#endif /* PARALLEL_ARCH */ - - ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime; - return(OK); -#else /* NEWTRUNC */ - register int i; - register CKTnode *node; - double timetemp; - double tmp; - double diff; - double tol; - double startTime; - int size; - - startTime = (*(SPfrontEnd->IFseconds))(); - - timetemp = HUGE; - size = SMPmatSize(ckt->CKTmatrix); -#ifdef STEPDEBUG - printf("at time %g, delta %g\n",ckt->CKTtime,ckt->CKTdeltaOld[0]); -#endif STEPDEBUG - node = ckt->CKTnodes; - switch(ckt->CKTintegrateMethod) { - - case TRAPEZOIDAL: - switch(ckt->CKTorder) { - case 1: - for(i=1;iCKTrhs[i]),fabs(ckt->CKTpred[i]))* - ckt->CKTlteReltol+ckt->CKTlteAbstol; - node = node->next; - if(node->type!= 3) continue; - diff = ckt->CKTrhs[i]-ckt->CKTpred[i]; -#ifdef STEPDEBUG - printf("%s: cor=%g, pred=%g ",node->name, - ckt->CKTrhs[i],ckt->CKTpred[i]); -#endif - if(diff != 0) { - tmp = ckt->CKTtrtol * tol * 2 /diff; - tmp = ckt->CKTdeltaOld[0]*sqrt(fabs(tmp)); - timetemp = MIN(timetemp,tmp); -#ifdef STEPDEBUG - printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp); -#endif - } else { -#ifdef STEPDEBUG - printf("diff is 0\n"); -#endif - } - } - break; - case 2: - for(i=1;iCKTrhs[i]),fabs(ckt->CKTpred[i]))* - ckt->CKTlteReltol+ckt->CKTlteAbstol; - node = node->next; - if(node->type!= 3) continue; - diff = ckt->CKTrhs[i]-ckt->CKTpred[i]; -#ifdef STEPDEBUG - printf("%s: cor=%g, pred=%g ",node->name,ckt->CKTrhs[i], - ckt->CKTpred[i]); -#endif - if(diff != 0) { - tmp = ckt->CKTdeltaOld[0]*ckt->CKTtrtol * tol * 3 * - (ckt->CKTdeltaOld[0]+ckt->CKTdeltaOld[1])/diff; - tmp = fabs(tmp); - timetemp = MIN(timetemp,tmp); -#ifdef STEPDEBUG - printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp); -#endif - } else { -#ifdef STEPDEBUG - printf("diff is 0\n"); -#endif - } - } - break; - default: - return(E_ORDER); - break; - - } - break; - - case GEAR: { - double delsum=0; - for(i=0;i<=ckt->CKTorder;i++) { - delsum += ckt->CKTdeltaOld[i]; - } - for(i=1;inext; - if(node->type!= 3) continue; - tol = MAX( fabs(ckt->CKTrhs[i]),fabs(ckt->CKTpred[i]))* - ckt->CKTlteReltol+ckt->CKTlteAbstol; - diff = (ckt->CKTrhs[i]-ckt->CKTpred[i]); -#ifdef STEPDEBUG - printf("%s: cor=%g, pred=%g ",node->name,ckt->CKTrhs[i], - ckt->CKTpred[i]); -#endif - if(diff != 0) { - tmp = tol*ckt->CKTtrtol*delsum/(diff*ckt->CKTdelta); - tmp = fabs(tmp); - switch(ckt->CKTorder) { - case 0: - break; - case 1: - tmp = sqrt(tmp); - break; - default: - tmp = exp(log(tmp)/(ckt->CKTorder+1)); - break; - } - tmp *= ckt->CKTdelta; - timetemp = MIN(timetemp,tmp); -#ifdef STEPDEBUG - printf("tol = %g, diff = %g, h->%g\n",tol,diff,tmp); -#endif - } else { -#ifdef STEPDEBUG - printf("diff is 0\n"); -#endif - } - } - } - break; - - default: - return(E_METHOD); - - } - *timeStep = MIN(2 * *timeStep,timetemp); -#ifdef PARALLEL_ARCH - DGOP_( &type, timeStep, &length, "min" ); -#endif /* PARALLEL_ARCH */ - ckt->CKTstat->STATtranTruncTime += SPfrontEnd->IFseconds() - startTime; - return(OK); -#endif /* NEWTRUNC */ -} diff --git a/src/analysis/ckttyplk.c b/src/analysis/ckttyplk.c deleted file mode 100644 index acd136426..000000000 --- a/src/analysis/ckttyplk.c +++ /dev/null @@ -1,31 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* look up the 'type' in the device description struct and return the - * appropriatestrchr for the device found, or -1 for not found - */ - -#include "ngspice.h" -#include "cktdefs.h" -#include "devdefs.h" - - - -extern SPICEdev *DEVices[]; - -int -CKTtypelook(char *type) -{ - - int i; - for(i=0;i -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" -#include "distodef.h" - - -/* ARGSUSED */ -int -DaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case D_START: - value->rValue = ((DISTOAN*)anal)->DstartF1; - break; - - case D_STOP: - value->rValue = ((DISTOAN*)anal)->DstopF1 ; - break; - - case D_STEPS: - value->iValue = ((DISTOAN*)anal)->DnumSteps; - break; - - case D_DEC: - if(((DISTOAN*)anal)->DstepType == DECADE) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case D_OCT: - if(((DISTOAN*)anal)->DstepType == OCTAVE) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case D_LIN: - if(((DISTOAN*)anal)->DstepType == LINEAR) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case D_F2OVRF1: - value->rValue = ((DISTOAN*)anal)->Df2ovrF1; - break; - default: - return(E_BADPARM); - } - return(OK); -} diff --git a/src/analysis/dcoaskq.c b/src/analysis/dcoaskq.c deleted file mode 100644 index 67fd67c83..000000000 --- a/src/analysis/dcoaskq.c +++ /dev/null @@ -1,20 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "opdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -DCOaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - return(E_BADPARM); -} - diff --git a/src/analysis/dcop.c b/src/analysis/dcop.c deleted file mode 100644 index 39d88f585..000000000 --- a/src/analysis/dcop.c +++ /dev/null @@ -1,63 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "sperror.h" -#include "ifsim.h" - - -int -DCop(CKTcircuit *ckt) -{ - int CKTload(register CKTcircuit *ckt); - int converged; - int error; - IFuid *nameList; - int numNames; - void *plot; - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, ckt->CKTcurJob->JOBname, - (IFuid)NULL,IF_REAL,numNames,nameList, IF_REAL,&plot); - if(error) return(error); - - converged = CKTop(ckt, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - if(converged != 0) return(converged); - - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG; - - -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && ((ckt->CKTsenInfo->SENmode&DCSEN) || - (ckt->CKTsenInfo->SENmode&ACSEN)) ){ -#ifdef SENSDEBUG - printf("\nDC Operating Point Sensitivity Results\n\n"); - CKTsenPrint(ckt); -#endif /* SENSDEBUG */ - senmode = ckt->CKTsenInfo->SENmode; - save = ckt->CKTmode; - ckt->CKTsenInfo->SENmode = DCSEN; - size = SMPmatSize(ckt->CKTmatrix); - for(i = 1; i<=size ; i++){ - *(ckt->CKTrhsOp + i) = *(ckt->CKTrhsOld + i); - } - if(error = CKTsenDCtran(ckt)) return(error); - ckt->CKTmode = save; - ckt->CKTsenInfo->SENmode = senmode; - - } -#endif - converged = CKTload(ckt); - CKTdump(ckt,(double)0,plot); - (*(SPfrontEnd->OUTendPlot))(plot); - return(converged); -} diff --git a/src/analysis/dcosetp.c b/src/analysis/dcosetp.c deleted file mode 100644 index 31d507c65..000000000 --- a/src/analysis/dcosetp.c +++ /dev/null @@ -1,42 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" -#include "opdefs.h" - - -/* ARGSUSED */ -int -DCOsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - default: - break; - } - return(E_BADPARM); -} - - -SPICEanalysis DCOinfo = { - { - "OP", - "D.C. Operating point analysis", - - 0, - NULL, - }, - sizeof(OP), - NODOMAIN, - 1, - DCOsetParm, - DCOaskQuest, - NULL, - DCop -}; diff --git a/src/analysis/dctaskq.c b/src/analysis/dctaskq.c deleted file mode 100644 index 9748a61bf..000000000 --- a/src/analysis/dctaskq.c +++ /dev/null @@ -1,26 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "trcvdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -DCTaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - default: - break; - } - /* NOTREACHED */ /* TEMPORARY until cases get added */ - return(E_BADPARM); -} - diff --git a/src/analysis/dctran.c b/src/analysis/dctran.c deleted file mode 100644 index 04e99cafd..000000000 --- a/src/analysis/dctran.c +++ /dev/null @@ -1,498 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* subroutine to do DC TRANSIENT analysis - --- ONLY, unlike spice2 routine with the same name! */ - -#include "ngspice.h" -#include -#include "trandefs.h" -#include "cktdefs.h" -#include "sperror.h" - -int -DCtran(CKTcircuit *ckt, int restart) -/* restart: forced restart flag */ -{ - int i; - double olddelta; - double delta; - double new; - double *temp; - double startdTime; - double startsTime; - double startlTime; - double startcTime; - double startkTime; - double startTime; - int startIters; - int converged; - int firsttime; - int error; -#ifdef WANT_SENSE2 -#ifdef SENSDEBUG - FILE *outsen; -#endif /* SENSDEBUG */ -#endif - int save_order; - long save_mode; - IFuid timeUid; - IFuid *nameList; - int numNames; - double maxstepsize=0.0; - - int ltra_num; -#ifdef PARALLEL_ARCH - long type = MT_TRANAN, length = 1; -#endif /* PARALLEL_ARCH */ - - if(restart || ckt->CKTtime == 0) { - delta=MIN(ckt->CKTfinalTime/50,ckt->CKTstep)/10; - - /* begin LTRA code addition */ - if (ckt->CKTtimePoints != NULL) - FREE(ckt->CKTtimePoints); - - if (ckt->CKTstep >= ckt->CKTmaxStep) - maxstepsize = ckt->CKTstep; - else - maxstepsize = ckt->CKTmaxStep; - - ckt->CKTsizeIncr = 10; - ckt->CKTtimeIndex = -1; /* before the DC soln has been stored */ - ckt->CKTtimeListSize = ckt->CKTfinalTime / maxstepsize + 0.5; - ltra_num = CKTtypelook("LTRA"); - if (ltra_num >= 0 && ckt->CKThead[ltra_num] != NULL) - ckt->CKTtimePoints = NEWN(double, ckt->CKTtimeListSize); - /* end LTRA code addition */ - - if(ckt->CKTbreaks) FREE(ckt->CKTbreaks); - ckt->CKTbreaks=(double *)MALLOC(2*sizeof(double)); - if(ckt->CKTbreaks == (double *)NULL) return(E_NOMEM); - *(ckt->CKTbreaks)=0; - *(ckt->CKTbreaks+1)=ckt->CKTfinalTime; - ckt->CKTbreakSize=2; - if(ckt->CKTminBreak==0) ckt->CKTminBreak=ckt->CKTmaxStep*5e-5; - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - (*(SPfrontEnd->IFnewUid))((void *)ckt,&timeUid,(IFuid)NULL, - "time", UID_OTHER, (void **)NULL); - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, - ckt->CKTcurJob->JOBname,timeUid,IF_REAL,numNames,nameList, - IF_REAL,&(((TRANan*)ckt->CKTcurJob)->TRANplot)); - if(error) return(error); - - ckt->CKTtime = 0; - ckt->CKTdelta = 0; - ckt->CKTbreak=1; - firsttime = 1; - save_mode = (ckt->CKTmode&MODEUIC)|MODETRANOP | MODEINITJCT; - save_order = ckt->CKTorder; - converged = CKTop(ckt, - (ckt->CKTmode & MODEUIC)|MODETRANOP| MODEINITJCT, - (ckt->CKTmode & MODEUIC)|MODETRANOP| MODEINITFLOAT, - ckt->CKTdcMaxIter); - if(converged != 0) return(converged); - ckt->CKTstat->STATtimePts ++; - ckt->CKTorder=1; - for(i=0;i<7;i++) { - ckt->CKTdeltaOld[i]=ckt->CKTmaxStep; - } - ckt->CKTdelta = delta; -#ifdef STEPDEBUG - (void)printf("delta initialized to %g\n",ckt->CKTdelta); -#endif - ckt->CKTsaveDelta = ckt->CKTfinalTime/50; - -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){ -#ifdef SENSDEBUG - printf("\nTransient Sensitivity Results\n\n"); - CKTsenPrint(ckt); -#endif /* SENSDEBUG */ - save = ckt->CKTsenInfo->SENmode; - ckt->CKTsenInfo->SENmode = TRANSEN; - save1 = ckt->CKTmode; - save2 = ckt->CKTorder; - ckt->CKTmode = save_mode; - ckt->CKTorder = save_order; - if(error = CKTsenDCtran(ckt)) return(error); - ckt->CKTmode = save1; - ckt->CKTorder = save2; - } -#endif - - ckt->CKTmode = (ckt->CKTmode&MODEUIC)|MODETRAN | MODEINITTRAN; - /* modeinittran set here */ - ckt->CKTag[0]=ckt->CKTag[1]=0; - bcopy((char *)ckt->CKTstate0,(char *)ckt->CKTstate1, - ckt->CKTnumStates*sizeof(double)); - -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){ - size = SMPmatSize(ckt->CKTmatrix); - for(i = 1; i<=size ; i++) - *(ckt->CKTrhsOp + i) = *(ckt->CKTrhsOld + i); - } -#endif - - startTime=(*(SPfrontEnd->IFseconds))(); - startIters = ckt->CKTstat->STATnumIter; - startdTime = ckt->CKTstat->STATdecompTime; - startsTime = ckt->CKTstat->STATsolveTime; - startlTime = ckt->CKTstat->STATloadTime; - startcTime = ckt->CKTstat->STATcombineTime; - startkTime = ckt->CKTstat->STATsyncTime; - } else { - startTime=(*(SPfrontEnd->IFseconds))(); - startIters = ckt->CKTstat->STATnumIter; - startdTime = ckt->CKTstat->STATdecompTime; - startsTime = ckt->CKTstat->STATsolveTime; - startlTime = ckt->CKTstat->STATloadTime; - startcTime = ckt->CKTstat->STATcombineTime; - startkTime = ckt->CKTstat->STATsyncTime; - if(ckt->CKTminBreak==0) ckt->CKTminBreak=ckt->CKTmaxStep*5e-5; - firsttime=0; - goto resume; - } - -/* 650 */ -nextTime: - - /* begin LTRA code addition */ - if (ckt->CKTtimePoints) { - ckt->CKTtimeIndex++; - if (ckt->CKTtimeIndex >= ckt->CKTtimeListSize) { - /* need more space */ - int need; - need = 0.5 + (ckt->CKTfinalTime - ckt->CKTtime) / maxstepsize; - if (need < ckt->CKTsizeIncr) - need = ckt->CKTsizeIncr; - ckt->CKTtimeListSize += need; - ckt->CKTtimePoints = (double *) REALLOC( (char *) - ckt->CKTtimePoints, sizeof(double) * ckt->CKTtimeListSize); - ckt->CKTsizeIncr *= 1.4; - } - *(ckt->CKTtimePoints + ckt->CKTtimeIndex) = ckt->CKTtime; - } - /* end LTRA code addition */ - - error = CKTaccept(ckt); - /* check if current breakpoint is outdated; if so, clear */ - if (ckt->CKTtime > *(ckt->CKTbreaks)) CKTclrBreak(ckt); - -/* - * Breakpoint handling scheme: - * When a timepoint t is accepted (by CKTaccept), clear all previous - * breakpoints, because they will never be needed again. - * - * t may itself be a breakpoint, or indistinguishably close. DON'T - * clear t itself; recognise it as a breakpoint and act accordingly - * - * if t is not a breakpoint, limit the timestep so that the next - * breakpoint is not crossed - */ - -#ifdef STEPDEBUG - printf("accepted at %g\n",ckt->CKTtime); -#endif /* STEPDEBUG */ - ckt->CKTstat->STATaccepted ++; - ckt->CKTbreak=0; - /* XXX Error will cause single process to bail. */ - if(error) { - ckt->CKTcurrentAnalysis = DOING_TRAN; - ckt->CKTstat->STATtranTime += (*(SPfrontEnd->IFseconds))()-startTime; - ckt->CKTstat->STATtranIter += ckt->CKTstat->STATnumIter - startIters; - ckt->CKTstat->STATtranDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATtranSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATtranLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATtranCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATtranSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; - return(error); - } - if(ckt->CKTtime >= ckt->CKTinitTime) CKTdump(ckt,ckt->CKTtime, - (((TRANan*)ckt->CKTcurJob)->TRANplot)); - ckt->CKTstat->STAToldIter = ckt->CKTstat->STATnumIter; - if(fabs(ckt->CKTtime - ckt->CKTfinalTime) < ckt->CKTminBreak) { - /*printf(" done: time is %g, final time is %g, and tol is %g\n",*/ - /*ckt->CKTtime,ckt->CKTfinalTime,ckt->CKTminBreak);*/ - (*(SPfrontEnd->OUTendPlot))( (((TRANan*)ckt->CKTcurJob)->TRANplot)); - ckt->CKTcurrentAnalysis = 0; - ckt->CKTstat->STATtranTime += (*(SPfrontEnd->IFseconds))()-startTime; - ckt->CKTstat->STATtranIter += ckt->CKTstat->STATnumIter - startIters; - ckt->CKTstat->STATtranDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATtranSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATtranLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATtranCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATtranSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){ - ckt->CKTsenInfo->SENmode = save; -#ifdef SENSDEBUG - fclose(outsen); -#endif /* SENSDEBUG */ - } -#endif - return(OK); - } - if( (*(SPfrontEnd->IFpauseTest))() ) { - /* user requested pause... */ - ckt->CKTcurrentAnalysis = DOING_TRAN; - ckt->CKTstat->STATtranTime += (*(SPfrontEnd->IFseconds))()-startTime; - ckt->CKTstat->STATtranIter += ckt->CKTstat->STATnumIter - startIters; - ckt->CKTstat->STATtranDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATtranSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATtranLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATtranCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATtranSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; - return(E_PAUSE); - } -resume: -#ifdef STEPDEBUG - if( (ckt->CKTdelta <= ckt->CKTfinalTime/50) && - (ckt->CKTdelta <= ckt->CKTmaxStep)) { - ; - } else { - if(ckt->CKTfinalTime/50CKTmaxStep) { - (void)printf("limited by Tstop/50\n"); - } else { - (void)printf("limited by Tmax\n"); - } - } -#endif - ckt->CKTdelta = - MIN(ckt->CKTdelta,ckt->CKTmaxStep); - /* are we at a breakpoint, or indistinguishably close? */ - if ((ckt->CKTtime == *(ckt->CKTbreaks)) || (*(ckt->CKTbreaks) - - (ckt->CKTtime) <= ckt->CKTdelmin)) { - /* first timepoint after a breakpoint - cut integration order */ - /* and limit timestep to .1 times minimum of time to next breakpoint, - * and previous timestep - */ - ckt->CKTorder = 1; -#ifdef STEPDEBUG - if( (ckt->CKTdelta >.1* ckt->CKTsaveDelta) || - (ckt->CKTdelta > .1*(*(ckt->CKTbreaks+1)-*(ckt->CKTbreaks))) ) { - if(ckt->CKTsaveDelta < (*(ckt->CKTbreaks+1)-*(ckt->CKTbreaks))) { - (void)printf("limited by pre-breakpoint delta\n"); - } else { - (void)printf("limited by next breakpoint\n"); - } - } -#endif - - ckt->CKTdelta = MIN(ckt->CKTdelta, .1 * MIN(ckt->CKTsaveDelta, - *(ckt->CKTbreaks+1)-*(ckt->CKTbreaks))); - - if(firsttime) { - ckt->CKTdelta /= 10; -#ifdef STEPDEBUG - (void)printf("delta cut for initial timepoint\n"); -#endif - } - - /* don't want to get below delmin for no reason */ - ckt->CKTdelta = MAX(ckt->CKTdelta, ckt->CKTdelmin*2.0); - } - else if(ckt->CKTtime + ckt->CKTdelta >= *(ckt->CKTbreaks)) { - ckt->CKTsaveDelta = ckt->CKTdelta; - ckt->CKTdelta = *(ckt->CKTbreaks) - ckt->CKTtime; -#ifdef STEPDEBUG - (void)printf("delta cut to hit breakpoint\n"); -#endif - ckt->CKTbreak = 1; /* why? the current pt. is not a bkpt. */ - } - -#ifdef PARALLEL_ARCH - DGOP_( &type, &(ckt->CKTdelta), &length, "min" ); -#endif /* PARALLEL_ARCH */ - - for(i=5;i>=0;i--) { - ckt->CKTdeltaOld[i+1]=ckt->CKTdeltaOld[i]; - } - ckt->CKTdeltaOld[0]=ckt->CKTdelta; - - temp = ckt->CKTstates[ckt->CKTmaxOrder+1]; - for(i=ckt->CKTmaxOrder;i>=0;i--) { - ckt->CKTstates[i+1] = ckt->CKTstates[i]; - } - ckt->CKTstates[0] = temp; - -/* 600 */ - while (1) { - olddelta=ckt->CKTdelta; - /* time abort? */ - ckt->CKTtime += ckt->CKTdelta; - ckt->CKTdeltaOld[0]=ckt->CKTdelta; - NIcomCof(ckt); -#ifdef PREDICTOR - error = NIpred(ckt); -#endif /* PREDICTOR */ - save_mode = ckt->CKTmode; - save_order = ckt->CKTorder; - converged = NIiter(ckt,ckt->CKTtranMaxIter); - ckt->CKTstat->STATtimePts ++; - ckt->CKTmode = (ckt->CKTmode&MODEUIC)|MODETRAN | MODEINITPRED; - if(firsttime) { - for(i=0;iCKTnumStates;i++) { - *(ckt->CKTstate2+i) = *(ckt->CKTstate1+i); - *(ckt->CKTstate3+i) = *(ckt->CKTstate1+i); - } - } - if(converged != 0) { - ckt->CKTtime = ckt->CKTtime -ckt->CKTdelta; - ckt->CKTstat->STATrejected ++; - ckt->CKTdelta = ckt->CKTdelta/8; -#ifdef STEPDEBUG - (void)printf("delta cut for non-convergence\n"); -#endif - if(firsttime) { - ckt->CKTmode = (ckt->CKTmode&MODEUIC)|MODETRAN | MODEINITTRAN; - } - ckt->CKTorder = 1; - } else { - if (firsttime) { -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){ - save1 = ckt->CKTmode; - save2 = ckt->CKTorder; - ckt->CKTmode = save_mode; - ckt->CKTorder = save_order; - if(error = CKTsenDCtran(ckt)) return(error); - ckt->CKTmode = save1; - ckt->CKTorder = save2; - } -#endif - firsttime =0; - goto nextTime; /* no check on - * first time point - */ - } - new = ckt->CKTdelta; - error = CKTtrunc(ckt,&new); - if(error) { - ckt->CKTcurrentAnalysis = DOING_TRAN; - ckt->CKTstat->STATtranTime += - (*(SPfrontEnd->IFseconds))()-startTime; - ckt->CKTstat->STATtranIter += - ckt->CKTstat->STATnumIter - startIters; - ckt->CKTstat->STATtranDecompTime += ckt->CKTstat->STATdecompTime - - startdTime; - ckt->CKTstat->STATtranSolveTime += ckt->CKTstat->STATsolveTime - - startsTime; - ckt->CKTstat->STATtranLoadTime += ckt->CKTstat->STATloadTime - - startlTime; - ckt->CKTstat->STATtranCombTime += ckt->CKTstat->STATcombineTime - - startcTime; - ckt->CKTstat->STATtranSyncTime += ckt->CKTstat->STATsyncTime - - startkTime; - return(error); - } - if(new>.9 * ckt->CKTdelta) { - if(ckt->CKTorder == 1) { - new = ckt->CKTdelta; - ckt->CKTorder = 2; - error = CKTtrunc(ckt,&new); - if(error) { - ckt->CKTcurrentAnalysis = DOING_TRAN; - ckt->CKTstat->STATtranTime += - (*(SPfrontEnd->IFseconds))()-startTime; - ckt->CKTstat->STATtranIter += - ckt->CKTstat->STATnumIter - startIters; - ckt->CKTstat->STATtranDecompTime += - ckt->CKTstat->STATdecompTime - startdTime; - ckt->CKTstat->STATtranSolveTime += - ckt->CKTstat->STATsolveTime - startsTime; - ckt->CKTstat->STATtranLoadTime += - ckt->CKTstat->STATloadTime - startlTime; - ckt->CKTstat->STATtranCombTime += - ckt->CKTstat->STATcombineTime - startcTime; - ckt->CKTstat->STATtranSyncTime += - ckt->CKTstat->STATsyncTime - startkTime; - return(error); - } - if(new <= 1.05 * ckt->CKTdelta) { - ckt->CKTorder = 1; - } - } - /* time point OK - 630*/ - ckt->CKTdelta = new; -#ifdef STEPDEBUG - (void)printf( - "delta set to truncation error result:point accepted\n"); -#endif -#ifdef WANT_SENSE2 - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN)){ - save1 = ckt->CKTmode; - save2 = ckt->CKTorder; - ckt->CKTmode = save_mode; - ckt->CKTorder = save_order; - if(error = CKTsenDCtran(ckt)) return(error); - ckt->CKTmode = save1; - ckt->CKTorder = save2; - } -#endif - /* go to 650 - trapezoidal */ - goto nextTime; - } else { - ckt->CKTtime = ckt->CKTtime -ckt->CKTdelta; - ckt->CKTstat->STATrejected ++; - ckt->CKTdelta = new; -#ifdef STEPDEBUG - (void)printf( - "delta set to truncation error result:point rejected\n"); -#endif - } - } -#ifdef PARALLEL_ARCH - DGOP_( &type, &(ckt->CKTdelta), &length, "min" ); -#endif /* PARALLEL_ARCH */ - - if (ckt->CKTdelta <= ckt->CKTdelmin) { - if (olddelta > ckt->CKTdelmin) { - ckt->CKTdelta = ckt->CKTdelmin; -#ifdef STEPDEBUG - (void)printf("delta at delmin\n"); -#endif - } else { - ckt->CKTcurrentAnalysis = DOING_TRAN; - ckt->CKTstat->STATtranTime += - (*(SPfrontEnd->IFseconds))()-startTime; - ckt->CKTstat->STATtranIter += - ckt->CKTstat->STATnumIter - startIters; - ckt->CKTstat->STATtranDecompTime += - ckt->CKTstat->STATdecompTime - startdTime; - ckt->CKTstat->STATtranSolveTime += - ckt->CKTstat->STATsolveTime - startsTime; - ckt->CKTstat->STATtranLoadTime += - ckt->CKTstat->STATloadTime - startlTime; - ckt->CKTstat->STATtranCombTime += - ckt->CKTstat->STATcombineTime - startcTime; - ckt->CKTstat->STATtranSyncTime += - ckt->CKTstat->STATsyncTime - startkTime; - errMsg = CKTtrouble((void *) ckt, "Timestep too small"); - return(E_TIMESTEP); - } - } - } - /* NOTREACHED */ -} diff --git a/src/analysis/dctrcurv.c b/src/analysis/dctrcurv.c deleted file mode 100644 index 016e5a717..000000000 --- a/src/analysis/dctrcurv.c +++ /dev/null @@ -1,403 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -Modified: 1999 Paolo Nenzi -**********/ - -#include "ngspice.h" -#include - -#include "vsrc/vsrcdefs.h" -#include "isrc/isrcdefs.h" -#include "res/resdefs.h" - -#include "cktdefs.h" -#include "const.h" -#include "sperror.h" - - -int -DCtrCurv(CKTcircuit *ckt, int restart) - - /* forced restart flag */ -{ - register TRCV* cv = (TRCV*)ckt->CKTcurJob; /* Where we get the job to do */ - int i; - double *temp; - int converged; - int rcode; - int vcode; - int icode; - int j; - int error; - IFuid varUid; - IFuid *nameList; - int numNames; - int firstTime=1; - static void *plot; - -#ifdef WANT_SENSE2 -#ifdef SENSDEBUG - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&DCSEN) ){ - printf("\nDC Sensitivity Results\n\n"); - CKTsenPrint(ckt); - } -#endif /* SENSDEBUG */ -#endif - - - rcode = CKTtypelook("Resistor"); - vcode = CKTtypelook("Vsource"); - icode = CKTtypelook("Isource"); - if(!restart && cv->TRCVnestState >= 0) { - /* continuing */ - i = cv->TRCVnestState; - goto resume; - } - ckt->CKTtime = 0; - ckt->CKTdelta = cv->TRCVvStep[0]; - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT ; - ckt->CKTorder=1; - - - /* Save the state of the circuit */ - for(i=0;i<7;i++) { - ckt->CKTdeltaOld[i]=ckt->CKTdelta; - } - - for(i=0;i<=cv->TRCVnestLevel;i++) { - if(rcode >= 0) { - /* resistances are in this version, so use them */ - register RESinstance *here; - register RESmodel *model; - for(model = (RESmodel *)ckt->CKThead[rcode];model != NULL; - model=model->RESnextModel){ - for(here=model->RESinstances;here!=NULL; - here=here->RESnextInstance) { - if(here->RESname == cv->TRCVvName[i]) { - cv->TRCVvElt[i] = (GENinstance *)here; - cv->TRCVvSave[i] = here->RESresist; - cv->TRCVgSave[i] = here->RESresGiven; - cv->TRCVvType[i] = rcode; - here->RESresist = cv->TRCVvStart[i]; - here->RESresGiven = 1; - printf("** Resistor sweep is highly alpha code\n**Results may not be accurate.\n"); - goto found; - } - } - } - } - if(vcode >= 0) { - /* voltage sources are in this version, so use them */ - register VSRCinstance *here; - register VSRCmodel *model; - for(model = (VSRCmodel *)ckt->CKThead[vcode];model != NULL; - model=model->VSRCnextModel){ - for(here=model->VSRCinstances;here!=NULL; - here=here->VSRCnextInstance) { - if(here->VSRCname == cv->TRCVvName[i]) { - cv->TRCVvElt[i] = (GENinstance *)here; - cv->TRCVvSave[i] = here->VSRCdcValue; - cv->TRCVgSave[i] = here->VSRCdcGiven; - cv->TRCVvType[i] = vcode; - here->VSRCdcValue = cv->TRCVvStart[i]; - here->VSRCdcGiven = 1; - goto found; - } - } - } - } - if(icode >= 0 ) { - /* current sources are in this version, so use them */ - register ISRCinstance *here; - register ISRCmodel *model; - - for(model= (ISRCmodel *)ckt->CKThead[icode];model != NULL; - model=model->ISRCnextModel){ - for(here=model->ISRCinstances;here!=NULL; - here=here->ISRCnextInstance) { - if(here->ISRCname == cv->TRCVvName[i]) { - cv->TRCVvElt[i] = (GENinstance *)here; - cv->TRCVvSave[i] = here->ISRCdcValue; - cv->TRCVgSave[i] = here->ISRCdcGiven; - cv->TRCVvType[i] = icode; - here->ISRCdcValue = cv->TRCVvStart[i]; - here->ISRCdcGiven = 1; - goto found; - } - } - } - } - - if(!strcmp(cv->TRCVvName[i], "temp")) - { - cv->TRCVvSave[i]=ckt->CKTtemp; /* Saves the old circuit temperature */ - cv->TRCVvType[i]=TEMP_CODE; /* Set the sweep type code */ - ckt->CKTtemp = cv->TRCVvStart[i] + CONSTCtoK; /* Set the new circuit temp */ - printf("Temperature sweep is alpha code\nresults may not be accurate\n"); - goto found; - } - - (*(SPfrontEnd->IFerror))(ERR_FATAL, - "DCtrCurv: source / resistor %s not in circuit", &(cv->TRCVvName[i])); - return(E_NODEV); - -found:; - } - - i--; /* PN: This seems to do nothing ??? */ - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - - if (cv->TRCVvType[i]==vcode) - (*(SPfrontEnd->IFnewUid))((void *)ckt,&varUid,(IFuid )NULL, - "v-sweep", UID_OTHER, (void **)NULL); - else if (cv->TRCVvType[i]==icode) - (*(SPfrontEnd->IFnewUid))((void *)ckt,&varUid,(IFuid )NULL, - "i-sweep", UID_OTHER, (void **)NULL); - else if (cv->TRCVvType[i]==TEMP_CODE) - (*(SPfrontEnd->IFnewUid))((void *)ckt,&varUid,(IFuid )NULL, - "temp-sweep", UID_OTHER, (void **)NULL); - /* PN Resistance Sweep */ - else if (cv->TRCVvType[i]==rcode) - (*(SPfrontEnd->IFnewUid))((void *)ckt,&varUid,(IFuid )NULL, - "res-sweep", UID_OTHER, (void **)NULL); - else - (*(SPfrontEnd->IFnewUid))((void *)ckt,&varUid,(IFuid )NULL, - "?-sweep", UID_OTHER, (void **)NULL); - - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, ckt->CKTcurJob->JOBname, - varUid,IF_REAL,numNames,nameList, IF_REAL,&plot); - - if(error) return(error); - /* now have finished the initialization - can start doing hard part */ - - i = 0; - -resume: - - for(;;) { - - if(cv->TRCVvType[i]==vcode) { /* voltage source */ - if((((VSRCinstance*)(cv->TRCVvElt[i]))->VSRCdcValue)* - SIGN(1.,cv->TRCVvStep[i]) - - SIGN(1.,cv->TRCVvStep[i]) * cv->TRCVvStop[i] > - 0.5 * fabs(cv->TRCVvStep[i])) - { - i++ ; - firstTime=1; - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | - MODEDCTRANCURVE | MODEINITJCT ; - if (i > cv->TRCVnestLevel ) break ; - goto nextstep; - } - } else if(cv->TRCVvType[i]==icode) { /* current source */ - if((((ISRCinstance*)(cv->TRCVvElt[i]))->ISRCdcValue)* - SIGN(1.,cv->TRCVvStep[i]) - - SIGN(1.,cv->TRCVvStep[i]) * cv->TRCVvStop[i] > - 0.5 * fabs(cv->TRCVvStep[i])) - { - i++ ; - firstTime=1; - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | - MODEDCTRANCURVE | MODEINITJCT ; - if (i > cv->TRCVnestLevel ) break ; - goto nextstep; - } - - } else if(cv->TRCVvType[i]==rcode) { /* resistance */ - if((((RESinstance*)(cv->TRCVvElt[i]))->RESresist)* - SIGN(1.,cv->TRCVvStep[i]) - - SIGN(1.,cv->TRCVvStep[i]) * cv->TRCVvStop[i] > - 0.5 * fabs(cv->TRCVvStep[i])) - { - i++ ; - firstTime=1; - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | - MODEDCTRANCURVE | MODEINITJCT ; - if (i > cv->TRCVnestLevel ) break ; - goto nextstep; - } - } else if(cv->TRCVvType[i]==TEMP_CODE) { /* temp sweep */ - if(((ckt->CKTtemp) - CONSTCtoK) * SIGN(1.,cv->TRCVvStep[i]) - - SIGN(1.,cv->TRCVvStep[i]) * cv->TRCVvStop[i] > - 0.5 * fabs(cv->TRCVvStep[i])) - { - i++ ; - firstTime=1; - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | - MODEDCTRANCURVE | MODEINITJCT ; - if (i > cv->TRCVnestLevel ) break ; - goto nextstep; - - } - - } /* else not possible */ - while (i > 0) { - /* init(i); */ - i--; - if(cv->TRCVvType[i]==vcode) { /* voltage source */ - ((VSRCinstance *)(cv->TRCVvElt[i]))->VSRCdcValue = - cv->TRCVvStart[i]; - - } else if(cv->TRCVvType[i]==icode) { /* current source */ - ((ISRCinstance *)(cv->TRCVvElt[i]))->ISRCdcValue = - cv->TRCVvStart[i]; - - } else if(cv->TRCVvType[i]==TEMP_CODE) { - ckt->CKTtemp = cv->TRCVvStart[i] + CONSTCtoK; - CKTtemp(ckt); - - } else if(cv->TRCVvType[i]==rcode) { - ((RESinstance *)(cv->TRCVvElt[i]))->RESresist = - cv->TRCVvStart[i]; - ((RESinstance *)(cv->TRCVvElt[i]))->RESconduct = - 1/(((RESinstance *)(cv->TRCVvElt[i]))->RESresist); - /* Note: changing the resistance does nothing */ - /* changing the conductance 1/r instead */ - RESload((GENmodel*)(cv->TRCVvElt[i]->GENmodPtr),ckt); - - - } /* else not possible */ - } - - /* Rotate state vectors. */ - temp = ckt->CKTstates[ckt->CKTmaxOrder+1]; - for(j=ckt->CKTmaxOrder;j>=0;j--) { - ckt->CKTstates[j+1] = ckt->CKTstates[j]; - } - ckt->CKTstate0 = temp; - - /* do operation */ - converged = NIiter(ckt,ckt->CKTdcTrcvMaxIter); - if(converged != 0) { - converged = CKTop(ckt, - (ckt->CKTmode&MODEUIC)|MODEDCTRANCURVE | MODEINITJCT, - (ckt->CKTmode&MODEUIC)|MODEDCTRANCURVE | MODEINITFLOAT, - ckt->CKTdcMaxIter); - if(converged != 0) { - return(converged); - } - } - ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODEDCTRANCURVE | MODEINITPRED ; - if(cv->TRCVvType[0] == vcode) { - ckt->CKTtime = ((VSRCinstance *)(cv->TRCVvElt[i])) - ->VSRCdcValue ; - } else if(cv->TRCVvType[0] == icode) { - ckt->CKTtime = ((ISRCinstance *)(cv->TRCVvElt[i])) - ->ISRCdcValue ; - } else if(cv->TRCVvType[0] == rcode) { - ckt->CKTtime = ((RESinstance *)(cv->TRCVvElt[i])) - ->RESresist; - } - /* PN Temp sweep */ - else - { - ckt->CKTtime = ckt->CKTtemp - CONSTCtoK ; - } -#ifdef WANT_SENSE2 -/* - if(!ckt->CKTsenInfo) printf("sensitivity structure does not exist\n"); - */ - if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&DCSEN) ){ - int senmode; - -#ifdef SENSDEBUG - if(cv->TRCVvType[i]==vcode) { /* voltage source */ - printf("Voltage Source Value : %.5e V\n", - ((VSRCinstance*) (cv->TRCVvElt[i]))->VSRCdcValue); - } - if(cv->TRCVvType[i]==icode) { /* current source */ - printf("Current Source Value : %.5e A\n", - ((ISRCinstance*)(cv->TRCVvElt[i]))->ISRCdcValue); - } - if(cv->TRCVvType[i]==rcode) { /* resistance */ - printf("Current Resistance Value : %.5e Ohm\n", - ((RESinstance*)(cv->TRCVvElt[i]->GENmodPtr))->RESresist); - } - if(cv->TRCVvType[i]==TEMP_CODE) { /* Temperature */ - printf("Current Circuit Temperature : %.5e C\n", - ckt-CKTtime - CONSTCtoK); - } - -#endif /* SENSDEBUG */ - - senmode = ckt->CKTsenInfo->SENmode; - save = ckt->CKTmode; - ckt->CKTsenInfo->SENmode = DCSEN; - if(error = CKTsenDCtran(ckt)) return (error); - ckt->CKTmode = save; - ckt->CKTsenInfo->SENmode = senmode; - - } -#endif - - - CKTdump(ckt,ckt->CKTtime,plot); - if(firstTime) { - firstTime=0; - bcopy((char *)ckt->CKTstate0,(char *)ckt->CKTstate1, - ckt->CKTnumStates*sizeof(double)); - } - -nextstep:; - if(cv->TRCVvType[i]==vcode) { /* voltage source */ - ((VSRCinstance*)(cv->TRCVvElt[i]))->VSRCdcValue += - cv->TRCVvStep[i]; - } else if(cv->TRCVvType[i]==icode) { /* current source */ - ((ISRCinstance*)(cv->TRCVvElt[i]))->ISRCdcValue += - cv->TRCVvStep[i]; - } else if(cv->TRCVvType[i]==rcode) { /* resistance */ - ((RESinstance*)(cv->TRCVvElt[i]))->RESresist += - cv->TRCVvStep[i]; - /* This code should update resistance and conductance */ - ((RESinstance*)(cv->TRCVvElt[i]))->RESconduct = - 1/(((RESinstance*)(cv->TRCVvElt[i]))->RESresist); - RESload((GENmodel*)(cv->TRCVvElt[i]->GENmodPtr),ckt); - } - /* PN Temp Sweep - serban */ - else if (cv->TRCVvType[i]==TEMP_CODE) - { - ckt->CKTtemp += cv->TRCVvStep[i]; - CKTtemp(ckt); - } /* else not possible */ - - if( (*(SPfrontEnd->IFpauseTest))() ) { - /* user asked us to pause, so save state */ - cv->TRCVnestState = i; - return(E_PAUSE); - } - } - - /* all done, lets put everything back */ - - for(i=0;i<=cv->TRCVnestLevel;i++) { - if(cv->TRCVvType[i] == vcode) { /* voltage source */ - ((VSRCinstance*)(cv->TRCVvElt[i]))->VSRCdcValue = - cv->TRCVvSave[i]; - ((VSRCinstance*)(cv->TRCVvElt[i]))->VSRCdcGiven = cv->TRCVgSave[i]; - } else if(cv->TRCVvType[i] == icode) /*current source */ { - ((ISRCinstance*)(cv->TRCVvElt[i]))->ISRCdcValue = - cv->TRCVvSave[i]; - ((ISRCinstance*)(cv->TRCVvElt[i]))->ISRCdcGiven = cv->TRCVgSave[i]; - } else if(cv->TRCVvType[i] == rcode) /* Resistance */ { - ((RESinstance*)(cv->TRCVvElt[i]))->RESresist = - cv->TRCVvSave[i]; - /* We restore both resistance and conductance */ - ((RESinstance*)(cv->TRCVvElt[i]))->RESconduct = - 1/(((RESinstance*)(cv->TRCVvElt[i]))->RESresist); - - ((RESinstance*)(cv->TRCVvElt[i]))->RESresGiven = cv->TRCVgSave[i]; - RESload((GENmodel*)(cv->TRCVvElt[i]->GENmodPtr),ckt); - } - else if(cv->TRCVvType[i] == TEMP_CODE) { - ckt->CKTtemp = cv->TRCVvSave[i]; - CKTtemp(ckt); - } /* else not possible */ - } - (*(SPfrontEnd->OUTendPlot))(plot); - - return(OK); -} diff --git a/src/analysis/dctsetp.c b/src/analysis/dctsetp.c deleted file mode 100644 index fc199ff12..000000000 --- a/src/analysis/dctsetp.c +++ /dev/null @@ -1,116 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "trcvdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -DCTsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - register TRCV* cv= (TRCV*)anal; - switch(which) { - - case DCT_START1: - cv->TRCVvStart[0] = value->rValue; - cv->TRCVnestLevel = MAX(0,cv->TRCVnestLevel); - cv->TRCVset[0]=TRUE; - break; - - case DCT_STOP1: - cv->TRCVvStop[0] = value->rValue; - cv->TRCVnestLevel = MAX(0,cv->TRCVnestLevel); - cv->TRCVset[0]=TRUE; - break; - - case DCT_STEP1: - cv->TRCVvStep[0] = value->rValue; - cv->TRCVnestLevel = MAX(0,cv->TRCVnestLevel); - cv->TRCVset[0]=TRUE; - break; - - case DCT_START2: - cv->TRCVvStart[1] = value->rValue; - cv->TRCVnestLevel = MAX(1,cv->TRCVnestLevel); - cv->TRCVset[1]=TRUE; - break; - - case DCT_STOP2: - cv->TRCVvStop[1] = value->rValue; - cv->TRCVnestLevel = MAX(1,cv->TRCVnestLevel); - cv->TRCVset[1]=TRUE; - break; - - case DCT_STEP2: - cv->TRCVvStep[1] = value->rValue; - cv->TRCVnestLevel = MAX(1,cv->TRCVnestLevel); - cv->TRCVset[1]=TRUE; - break; - - case DCT_NAME1: - cv->TRCVvName[0] = value->uValue; - cv->TRCVnestLevel = MAX(0,cv->TRCVnestLevel); - cv->TRCVset[0]=TRUE; - break; - - case DCT_NAME2: - cv->TRCVvName[1] = value->uValue; - cv->TRCVnestLevel = MAX(1,cv->TRCVnestLevel); - cv->TRCVset[1]=TRUE; - break; - - case DCT_TYPE1: - cv->TRCVvType[0] = value->iValue; - cv->TRCVnestLevel = MAX(0,cv->TRCVnestLevel); - cv->TRCVset[0]=TRUE; - break; - - case DCT_TYPE2: - cv->TRCVvType[1] = value->iValue; - cv->TRCVnestLevel = MAX(1,cv->TRCVnestLevel); - cv->TRCVset[1]=TRUE; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm DCTparms[] = { - { "start1", DCT_START1, IF_SET|IF_REAL, "starting voltage/current"}, - { "stop1", DCT_STOP1, IF_SET|IF_REAL, "ending voltage/current" }, - { "step1", DCT_STEP1, IF_SET|IF_REAL, "voltage/current step" }, - { "start2", DCT_START2, IF_SET|IF_REAL, "starting voltage/current"}, - { "stop2", DCT_STOP2, IF_SET|IF_REAL, "ending voltage/current" }, - { "step2", DCT_STEP2, IF_SET|IF_REAL, "voltage/current step" }, - { "name1", DCT_NAME1, IF_SET|IF_INSTANCE, "name of source to step" }, - { "name2", DCT_NAME2, IF_SET|IF_INSTANCE, "name of source to step" }, - { "type1", DCT_TYPE1, IF_SET|IF_INTEGER, "type of source to step" }, - { "type2", DCT_TYPE2, IF_SET|IF_INTEGER, "type of source to step" } -}; - -SPICEanalysis DCTinfo = { - { - "DC", - "D.C. Transfer curve analysis", - - sizeof(DCTparms)/sizeof(IFparm), - DCTparms - }, - sizeof(TRCV), - SWEEPDOMAIN, - 1, - DCTsetParm, - DCTaskQuest, - NULL, - DCtrCurv -}; diff --git a/src/analysis/distoan.c b/src/analysis/distoan.c deleted file mode 100644 index 9ab5c2dda..000000000 --- a/src/analysis/distoan.c +++ /dev/null @@ -1,668 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jaijeet S Roychowdhury -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "distodef.h" -#include "sperror.h" - - -void -DISswap(double **a, double **b) -{ -double *c; - -c = *a; -*a = *b; -*b = c; -} - -void -DmemAlloc(double **a, int size) -{ -*a = (double *) MALLOC( sizeof(double) * size + 1); -} - - - -void -DstorAlloc(double ***header, int size) -{ -*header = (double **) MALLOC( sizeof(double *)*size); -} - - -#ifdef STDC -extern int CKTdisto(CKTcircuit*, int); -extern int DkerProc(int,double*,double*,int,DISTOan*); -#else -extern int CKTdisto(register CKTcircuit *ckt, int mode); -extern int DkerProc(int type, double *rPtr, double *iPtr, int size, DISTOAN *job); -#endif - - -int -DISTOan(CKTcircuit *ckt, int restart) -{ - - double freq; - static double freqTol; /* tolerence parameter for finding final frequency */ - static int NoOfPoints; - static int size; - static int displacement; - int error; - int i; - int numNames; - IFuid *nameList; - IFuid freqUid; - void *acPlot; - register DISTOAN* job = (DISTOAN *) (ckt->CKTcurJob); - static char *nof2src = "No source with f2 distortion input"; -#ifdef DISTODEBUG - double time,time1; -#endif - - - /* start at beginning */ - -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))(); -#endif - switch(job->DstepType) { - - case DECADE: - job->DfreqDelta = - exp(log(10.0)/job->DnumSteps); - freqTol = job->DfreqDelta * - job->DstopF1 * ckt->CKTreltol; - NoOfPoints = 1 + floor ((job->DnumSteps) / log(10.0) * log((job->DstopF1+freqTol)/(job->DstartF1))); - break; - case OCTAVE: - job->DfreqDelta = - exp(log(2.0)/job->DnumSteps); - freqTol = job->DfreqDelta * - job->DstopF1 * ckt->CKTreltol; - NoOfPoints = 1 + floor ((job->DnumSteps) / log(2.0) * log((job->DstopF1+freqTol)/(job->DstartF1))); - break; - case LINEAR: - job->DfreqDelta = - (job->DstopF1 - - job->DstartF1)/ - (job->DnumSteps+1); - freqTol = job->DfreqDelta * ckt->CKTreltol; - NoOfPoints = job->DnumSteps+1+ floor(freqTol/(job->DfreqDelta)); - break; - default: - return(E_BADPARM); - } - - error = CKTop(ckt, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - if(error) return(error); - - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG; - error = CKTload(ckt); - if(error) return(error); - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - - if (ckt->CKTkeepOpInfo) { - /* Dump operating point. */ - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, "Distortion Operating Point", - (IFuid)NULL,IF_REAL,numNames,nameList, IF_REAL,&acPlot); - if(error) return(error); - CKTdump(ckt,(double)0,acPlot); - (*(SPfrontEnd->OUTendPlot))(acPlot); - } - -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))() - time1; -printf("Time for initial work (including op. pt.): %g seconds \n", time1); -#endif - -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_SETUP); -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))() - time1; -printf("Time outside D_SETUP: %g seconds \n", time1); -#endif - if (error) return(error); - - displacement = 0; - -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))(); -#endif - freq = job->DstartF1; - if (job->Df2wanted) { - /* - omegadelta = 2.0 * M_PI * freq *(1. - job->Df2ovrF1); - */ - /* keeping f2 const to be compatible with spectre */ - job->Domega2 = 2.0 * M_PI * freq * job->Df2ovrF1; - } - DstorAlloc( &(job->r1H1stor),NoOfPoints+2); - DstorAlloc( &(job->r2H11stor),NoOfPoints+2); - DstorAlloc( &(job->i1H1stor),NoOfPoints+2); - DstorAlloc( &(job->i2H11stor),NoOfPoints+2); - size = SMPmatSize(ckt->CKTmatrix); - if (! job->r1H1ptr) - { - DmemAlloc( &(job->r1H1ptr) , size+2); - if (! job->r1H1ptr) return (E_NOMEM); - } - - if (! job->r2H11ptr) - { - DmemAlloc( &(job->r2H11ptr) , size+2); - if (! job->r2H11ptr) return (E_NOMEM); - } - if (! job->i1H1ptr) - { - DmemAlloc( &(job->i1H1ptr) , size+2); - if (! job->i1H1ptr) return (E_NOMEM); - } - - if (! job->i2H11ptr) - { - DmemAlloc( &(job->i2H11ptr) , size+2); - if (! job->i2H11ptr) return (E_NOMEM); - } - - if (! (job->Df2wanted)) - { - DstorAlloc( &(job->r3H11stor),NoOfPoints+2); - DstorAlloc( &(job->i3H11stor),NoOfPoints+2); - if (! job->r3H11ptr) - { - DmemAlloc( &(job->r3H11ptr) , size+2); - if (! job->r3H11ptr) return (E_NOMEM); - } - if (! job->i3H11ptr) - { - DmemAlloc( &(job->i3H11ptr) , size+2); - if (! job->i3H11ptr) return (E_NOMEM); - } - } else { - DstorAlloc ( &(job->r1H2stor),NoOfPoints+2); - DstorAlloc ( &(job->i1H2stor),NoOfPoints+2); - DstorAlloc ( &(job->r2H12stor),NoOfPoints+2); - DstorAlloc ( &(job->i2H12stor),NoOfPoints+2); - DstorAlloc ( &(job->r2H1m2stor),NoOfPoints+2); - DstorAlloc ( &(job->i2H1m2stor),NoOfPoints+2); - DstorAlloc ( &(job->r3H1m2stor),NoOfPoints+2); - DstorAlloc ( &(job->i3H1m2stor),NoOfPoints+2); - if (! job->r1H2ptr) - { - DmemAlloc( &(job->r1H2ptr) , size+2); - if (! job->r1H2ptr) return (E_NOMEM); - } - - if (! job->r2H12ptr) - { - DmemAlloc( &(job->r2H12ptr) , size+2); - if (! job->r2H12ptr) return (E_NOMEM); - } - - if (! job->r2H1m2ptr) - { - DmemAlloc( &(job->r2H1m2ptr) , size+2); - if (! job->r2H1m2ptr) return (E_NOMEM); - } - - if (! job->r3H1m2ptr) - { - DmemAlloc( &(job->r3H1m2ptr) , size+2); - if (! job->r3H1m2ptr) return (E_NOMEM); - } - if (! job->i1H2ptr) - { - DmemAlloc( &(job->i1H2ptr) , size+2); - if (! job->i1H2ptr) return (E_NOMEM); - } - - if (! job->i2H12ptr) - { - DmemAlloc( &(job->i2H12ptr) , size+2); - if (! job->i2H12ptr) return (E_NOMEM); - } - - if (! job->i2H1m2ptr) - { - DmemAlloc( &(job->i2H1m2ptr) , size+2); - if (! job->i2H1m2ptr) return (E_NOMEM); - } - - if (! job->i3H1m2ptr) - { - DmemAlloc( &(job->i3H1m2ptr) , size+2); - if (! job->i3H1m2ptr) return (E_NOMEM); - } -} - -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))() - time1; -printf("Time for other setup (storage allocation etc.): %g seconds \n", time1); -#endif - - - -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))(); -#endif - while(freq <= job->DstopF1+freqTol) { - -/* - if( (*(SPfrontEnd->IFpauseTest))() ) { - job->DsaveF1 = freq; - return(E_PAUSE); - } - */ - ckt->CKTomega = 2.0 * M_PI *freq; - job->Domega1 = ckt->CKTomega; - ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODEAC; -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTacLoad(ckt); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time for CKTacLoad: %g seconds \n", time); -#endif - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_RHSF1); /* sets up the RHS vector - for all inputs corresponding to F1 */ -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside DISTO_RHSFIX: %g seconds \n", time); -#endif - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = NIdIter(ckt); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time for NIdIter: %g seconds \n", time); -#endif - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r1H1ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i1H1ptr)); - - ckt->CKTomega *= 2; - error = CKTacLoad(ckt); - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_TWOF1); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside D_TWOF1: %g seconds \n", time); -#endif - if (error) return(error); - error = NIdIter(ckt); - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r2H11ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i2H11ptr)); - - if (! (job->Df2wanted )) - { - - - ckt->CKTomega = 3 * job->Domega1; - error = CKTacLoad(ckt); - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_THRF1); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside D_THRF1: %g seconds \n", time); -#endif - if (error) return(error); - error = NIdIter(ckt); - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r3H11ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i3H11ptr)); - - - } - else if (job->Df2given) - { - - - /* - ckt->CKTomega = job->Domega1 - omegadelta; - job->Domega2 = ckt->CKTomega; - */ - ckt->CKTomega = job->Domega2; - error = CKTacLoad(ckt); - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_RHSF2); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside DISTO_RHSFIX: %g seconds \n", time); -#endif - if (error) return(error); - error = NIdIter(ckt); - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r1H2ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i1H2ptr)); - - - ckt->CKTomega = job->Domega1 + - job->Domega2; - error = CKTacLoad(ckt); - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_F1PF2); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside D_F1PF2: %g seconds \n", time); -#endif - if (error) return(error); - error = NIdIter(ckt); - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r2H12ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i2H12ptr)); - - - - ckt->CKTomega = job->Domega1 - - job->Domega2; - error = CKTacLoad(ckt); - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_F1MF2); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside D_F1MF2: %g seconds \n", time); -#endif - if (error) return(error); - error = NIdIter(ckt); - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r2H1m2ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i2H1m2ptr)); - - - ckt->CKTomega = 2*job->Domega1 - - job->Domega2; - error = CKTacLoad(ckt); - if (error) return(error); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))(); -#endif - error = CKTdisto(ckt,D_2F1MF2); -#ifdef D_DBG_SMALLTIMES -time = (*(SPfrontEnd->IFseconds))() - time; -printf("Time outside D_2F1MF2: %g seconds \n", time); -#endif - if (error) return(error); - error = NIdIter(ckt); - if (error) return(error); - DISswap(&(ckt->CKTrhsOld),&(job->r3H1m2ptr)); - DISswap(&(ckt->CKTirhsOld),&(job->i3H1m2ptr)); - - - } - else - { - errMsg = MALLOC(strlen(nof2src)+1); - strcpy(errMsg,nof2src); - return(E_NOF2SRC); - } - - - - - DmemAlloc( &(job->r1H1stor[displacement]),size); - DISswap(&(job->r1H1stor[displacement]),&(job->r1H1ptr)); - job->r1H1stor[displacement][0]=freq; - DmemAlloc( &(job->r2H11stor[displacement]),size); - DISswap(&(job->r2H11stor[displacement]),&((job->r2H11ptr))); - job->r2H11stor[displacement][0]=freq; - DmemAlloc( &(job->i1H1stor[displacement]),size); - DISswap(&(job->i1H1stor[displacement]),&((job->i1H1ptr))); - job->i1H1stor[displacement][0]=0.0; - DmemAlloc( &(job->i2H11stor[displacement]),size); - DISswap(&(job->i2H11stor[displacement]),&((job->i2H11ptr))); - job->i2H11stor[displacement][0]=0.0; - if (! (job->Df2wanted)) - { - DmemAlloc( &(job->r3H11stor[displacement]),size); - DISswap(&(job->r3H11stor[displacement]),&((job->r3H11ptr))); - job->r3H11stor[displacement][0]=freq; - DmemAlloc( &(job->i3H11stor[displacement]),size); - DISswap(&(job->i3H11stor[displacement]),&((job->i3H11ptr))); - job->i3H11stor[displacement][0]=0.0; - } else { - DmemAlloc( &(job->r1H2stor[displacement]),size); - DISswap(&(job->r1H2stor[displacement]),&((job->r1H2ptr))); - job->r1H2stor[displacement][0]=freq; - DmemAlloc( &(job->r2H12stor[displacement]),size); - DISswap(&(job->r2H12stor[displacement]),&((job->r2H12ptr))); - job->r2H12stor[displacement][0]=freq; - DmemAlloc( &(job->r2H1m2stor[displacement]),size); - DISswap(&(job->r2H1m2stor[displacement]),&((job->r2H1m2ptr))); - job->r2H1m2stor[displacement][0]=freq; - DmemAlloc( &(job->r3H1m2stor[displacement]),size); - DISswap(&(job->r3H1m2stor[displacement]),&((job->r3H1m2ptr))); - job->r3H1m2stor[displacement][0]=freq; - - DmemAlloc( &(job->i1H2stor[displacement]),size); - DISswap(&(job->i1H2stor[displacement]),&((job->i1H2ptr))); - job->i1H2stor[displacement][0]=0.0; - DmemAlloc( &(job->i2H12stor[displacement]),size); - DISswap(&(job->i2H12stor[displacement]),&((job->i2H12ptr))); - job->i2H12stor[displacement][0]=0.0; - DmemAlloc( &(job->i2H1m2stor[displacement]),size); - DISswap(&(job->i2H1m2stor[displacement]),&((job->i2H1m2ptr))); - job->i2H1m2stor[displacement][0]=0.0; - DmemAlloc( &(job->i3H1m2stor[displacement]),size); - DISswap(&(job->i3H1m2stor[displacement]),&((job->i3H1m2ptr))); - job->i3H1m2stor[displacement][0]=0.0; - } - displacement++; - - - - switch(job->DstepType) { - case DECADE: - case OCTAVE: - freq *= job->DfreqDelta; - if(job->DfreqDelta==1) goto endsweep; - break; - case LINEAR: - freq += job->DfreqDelta; - if(job->DfreqDelta==0) goto endsweep; - break; - default: - return(E_INTERN); - } - } -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))() - time1; -printf("Time inside frequency loop: %g seconds \n", time1); -#endif - -endsweep: - - - /* output routines to process the H's and output actual ckt variable - values */ -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))(); -#endif - - - - if (! job->Df2wanted) { - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob,"DISTORTION - 2nd harmonic", - freqUid,IF_REAL, numNames,nameList,IF_COMPLEX,&acPlot); - if (job->DstepType != LINEAR) { - (*(SPfrontEnd->OUTattributes))((void *)acPlot,NULL, - OUT_SCALE_LOG, NULL); - } - for (i=0; i< displacement ; i++) - { - DkerProc(D_TWOF1,*(job->r2H11stor + i), - *(job->i2H11stor + i), - size, job); - ckt->CKTrhsOld = *((job->r2H11stor) + i); - ckt->CKTirhsOld = *((job->i2H11stor) + i); - error = CKTacDump(ckt,ckt->CKTrhsOld[0],acPlot); - if(error) return(error); - } - (*(SPfrontEnd->OUTendPlot))(acPlot); - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob,"DISTORTION - 3rd harmonic",freqUid,IF_REAL, - numNames,nameList,IF_COMPLEX,&acPlot); - for (i=0; i< displacement ; i++) - { - DkerProc(D_THRF1,*(job->r3H11stor + i), - *(job->i3H11stor + i), - size, job); - ckt->CKTrhsOld = *((job->r3H11stor) + i); - ckt->CKTirhsOld = *((job->i3H11stor) + i); - error = CKTacDump(ckt,ckt->CKTrhsOld[0],acPlot); - } - (*(SPfrontEnd->OUTendPlot))(acPlot); - - } else { - - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob,"DISTORTION - IM: f1+f2",freqUid,IF_REAL, - numNames,nameList,IF_COMPLEX,&acPlot); - for (i=0; i< displacement ; i++) - { - DkerProc(D_F1PF2,*(job->r2H12stor + i), - *(job->i2H12stor + i), - size, job); - ckt->CKTrhsOld = *((job->r2H12stor) + i); - ckt->CKTirhsOld = *((job->i2H12stor) + i); - error = CKTacDump(ckt,ckt->CKTrhsOld[0],acPlot); - if(error) return(error); - } - (*(SPfrontEnd->OUTendPlot))(acPlot); - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob,"DISTORTION - IM: f1-f2",freqUid,IF_REAL, - numNames,nameList,IF_COMPLEX,&acPlot); - for (i=0; i< displacement ; i++) - { - DkerProc(D_F1MF2, - *(job->r2H1m2stor + i), - *(job->i2H1m2stor + i), - size, job); - ckt->CKTrhsOld = *((job->r2H1m2stor) + i); - ckt->CKTirhsOld = *((job->i2H1m2stor) + i); - error = CKTacDump(ckt,ckt->CKTrhsOld[0],acPlot); - if(error) return(error); - } - (*(SPfrontEnd->OUTendPlot))(acPlot); - - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob,"DISTORTION - IM: 2f1-f2",freqUid,IF_REAL, - numNames,nameList,IF_COMPLEX,&acPlot); - for (i=0; i< displacement ; i++) - { - DkerProc(D_2F1MF2, - *(job->r3H1m2stor + i), - *(job->i3H1m2stor + i), - size, job); - ckt->CKTrhsOld = *((job->r3H1m2stor) + i); - ckt->CKTirhsOld = *((job->i3H1m2stor) + i); - error = CKTacDump(ckt,ckt->CKTrhsOld[0],acPlot); - if(error) return(error); - } - (*(SPfrontEnd->OUTendPlot))(acPlot); - - } -FREE(job->r1H1ptr); -FREE(job->i1H1ptr); -FREE(job->r2H11ptr); -FREE(job->i2H11ptr); - -FREE(job->r1H1stor); -FREE(job->i1H1stor); -FREE(job->r2H11stor); -FREE(job->i2H11stor); - - if (! (job->Df2wanted)) - { -FREE(job->r3H11ptr); -FREE(job->i3H11ptr); - -FREE(job->i3H11stor); -FREE(job->r3H11stor); -} -else { - -FREE(job->r2H1m2ptr); -FREE(job->r3H1m2ptr); -FREE(job->r1H2ptr); -FREE(job->i1H2ptr); -FREE(job->r2H12ptr); -FREE(job->i2H12ptr); -FREE(job->i2H1m2ptr); -FREE(job->i3H1m2ptr); - -FREE(job->r1H2stor); -FREE(job->r2H12stor); -FREE(job->r2H1m2stor); -FREE(job->r3H1m2stor); -FREE(job->i1H2stor); -FREE(job->i2H12stor); -FREE(job->i2H1m2stor); -FREE(job->i3H1m2stor); - } -#ifdef D_DBG_BLOCKTIMES -time1 = (*(SPfrontEnd->IFseconds))() - time1; -printf("Time for output and deallocation: %g seconds \n", time1); -#endif - return(OK); -} diff --git a/src/analysis/dkerproc.c b/src/analysis/dkerproc.c deleted file mode 100644 index 887769338..000000000 --- a/src/analysis/dkerproc.c +++ /dev/null @@ -1,102 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jaijeet S Roychowdhury -**********/ - -#include "ngspice.h" -#include "cktdefs.h" -#include "sperror.h" -#include "distodef.h" - - -int -DkerProc(int type, double *rPtr, double *iPtr, int size, DISTOAN *job) -{ -int i; - -switch(type) { - - case D_F1: - - - for (i=1;i<=size;i++) - { - iPtr[i] *= 2.0; /* convert to sinusoid amplitude */ - rPtr[i] *= 2.0; - } - - break; - - case D_F2: - - - for (i=1;i<=size;i++) - { - rPtr[i] *= 2.0; - iPtr[i] *= 2.0; - } - - break; - - case D_TWOF1: - - - for (i=1;i<=size;i++) - { - iPtr[i] *= 2.0; - rPtr[i] *= 2.0; - } - - break; - - case D_THRF1: - - - for (i=1;i<=size;i++) - { - iPtr[i] *= 2.0; - rPtr[i] *= 2.0; - } - - break; - - case D_F1PF2: - - - for (i=1;i<=size;i++) - { - iPtr[i] *= 4.0; - rPtr[i] *= 4.0; - } - - break; - - case D_F1MF2: - - - for (i=1;i<=size;i++) - { - iPtr[i] *= 4.0; - rPtr[i] *= 4.0; - } - - break; - - case D_2F1MF2: - - for (i=1;i<=size;i++) - { - iPtr[i] *= 6.0; - rPtr[i] *= 6.0; - } - - break; - - default: - - return(E_BADPARM); - -} - -return(OK); -} diff --git a/src/analysis/dloadfns.c b/src/analysis/dloadfns.c deleted file mode 100644 index e404a214d..000000000 --- a/src/analysis/dloadfns.c +++ /dev/null @@ -1,673 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jaijeet S Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" - - -/* - * all subFns are local to this file so they need not be renamed to - * the awful 7 letter standard; however, for reasons of uniformity, - * they are being renamed, losing all readability in the process. - * the renaming convention is as follows: - * example: 3v3F1m2 - * 3v => 3 variable term xyz - * 2F1m2 => Two F1 minus F2 - * therefore the old name would be : S3v3F1minusF2 - * for the imaginary sub functions, the v is replaced by an i - * - */ -double -S2v2F1(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y) - - /* 5 arguments */ - -{ -return(cxy*(r1h1x*r1h1y - i1h1x*i1h1y)); -} - -double -S2i2F1(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y) - - /* 5 arguments */ - -{ -return(cxy*(r1h1x*i1h1y + i1h1x*r1h1y)); -} - -double -S2v3F1(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r2h11x, double i2h11x, double r2h11y, double i2h11y) - - /* 9 arguments */ - - -{ -return(cxy*(r1h1x*r2h11y - i1h1x*i2h11y + r1h1y*r2h11x - i1h1y* - i2h11x)); -} - - -double -S2i3F1(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r2h11x, double i2h11x, double r2h11y, double i2h11y) - - /* 9 arguments */ - - -{ -return(cxy*(r1h1x*i2h11y + i1h1x*r2h11y + r1h1y*i2h11x + i1h1y* - r2h11x)); -} - -double -S2vF12(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h2x, double i1h2x, double r1h2y, double i1h2y) - - /* 9 arguments */ - - -{ -return(cxy*(r1h1x*r1h2y - i1h1x*i1h2y + r1h1y*r1h2x - i1h1y*i1h2x)); -} - -double -S2iF12(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h2x, double i1h2x, double r1h2y, double i1h2y) - - /* 9 arguments */ - - -{ -return(cxy*(r1h1x*i1h2y + i1h1x*r1h2y + r1h1y*i1h2x + i1h1y*r1h2x)); -} - -double -S2v2F12(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h2x, double i1h2x, double r1h2y, double i1h2y, double r2h11x, double i2h11x, double r2h11y, double i2h11y, double h2f1f2x, double ih2f1f2x, double h2f1f2y, double ih2f1f2y) - - /* 17 arguments */ - - - - -{ -return ( cxy * ( - 2*(r1h1x*h2f1f2y - i1h1x*ih2f1f2y - +r1h1y*h2f1f2x - i1h1y*ih2f1f2x) - + r1h2x*r2h11y - i1h2x*i2h11y - + r1h2y*r2h11x - i1h2y*i2h11x - )); -} - -double -S2i2F12(double cxy, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h2x, double i1h2x, double r1h2y, double i1h2y, double r2h11x, double i2h11x, double r2h11y, double i2h11y, double h2f1f2x, double ih2f1f2x, double h2f1f2y, double ih2f1f2y) - - /* 17 arguments */ - - - - -{ -return ( cxy * ( - 2*(r1h1x*ih2f1f2y + i1h1x*h2f1f2y - +r1h1y*ih2f1f2x + i1h1y*h2f1f2x) - + r1h2x*i2h11y + i1h2x*r2h11y - + r1h2y*i2h11x + i1h2y*r2h11x - )); -} - -double -S3v3F1(double cxyz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z) - - /* 7 arguments */ - - -{ -return( cxyz * ( - (r1h1x*r1h1y - i1h1x*i1h1y)*r1h1z - (i1h1x*r1h1y + r1h1x*i1h1y)*i1h1z - )); -} - -double -S3i3F1(double cxyz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z) - - /* 7 arguments */ - - -{ -return( cxyz * ( - (r1h1x*r1h1y - i1h1x*i1h1y)*i1h1z + (i1h1x*r1h1y + r1h1x*i1h1y)*r1h1z - )); -} - -double -S3v2F12(double cxyz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z, double r1h2x, double i1h2x, double r1h2y, double i1h2y, double r1h2z, double i1h2z) - - /* 13 arguments */ - - - -{ -return ( cxyz * ( - (r1h1x*r1h1y - i1h1x*i1h1y)*r1h2z - (i1h1x*r1h1y + r1h1x*i1h1y)*i1h2z - + - (r1h1x*r1h1z - i1h1x*i1h1z)*r1h2y - (i1h1x*r1h1z + r1h1x*i1h1z)*i1h2y - + - (r1h1z*r1h1y - i1h1z*i1h1y)*r1h2x - (i1h1z*r1h1y + r1h1z*i1h1y)*i1h2x - )); -} - -double -S3i2F12(double cxyz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z, double r1h2x, double i1h2x, double r1h2y, double i1h2y, double r1h2z, double i1h2z) - - /* 13 arguments */ - - - -{ -return ( cxyz * ( - (r1h1x*r1h1y - i1h1x*i1h1y)*i1h2z + (i1h1x*r1h1y + r1h1x*i1h1y)*r1h2z - + - (r1h1x*r1h1z - i1h1x*i1h1z)*i1h2y + (i1h1x*r1h1z + r1h1x*i1h1z)*r1h2y - + - (r1h1z*r1h1y - i1h1z*i1h1y)*i1h2x + (i1h1z*r1h1y + r1h1z*i1h1y)*r1h2x - )); -} - - /* the load functions */ - /* also renamed... */ -double -DFn2F1(double cxx, double cyy, double czz, double cxy, double cyz, double cxz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z) - - /* 12 variables */ - - -{ -double temp; - - temp = S2v2F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x) + - S2v2F1(cyy,r1h1y,i1h1y,r1h1y,i1h1y) + - S2v2F1(czz,r1h1z,i1h1z,r1h1z,i1h1z) + - S2v2F1(cxy,r1h1x,i1h1x,r1h1y,i1h1y) + - S2v2F1(cyz,r1h1y,i1h1y,r1h1z,i1h1z) + - S2v2F1(cxz,r1h1x,i1h1x,r1h1z,i1h1z); - - return(temp); -} - -double -DFi2F1(double cxx, double cyy, double czz, double cxy, double cyz, double cxz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z) - - /* 12 variables */ - - -{ -double temp; - - temp = S2i2F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x) + - S2i2F1(cyy,r1h1y,i1h1y,r1h1y,i1h1y) + - S2i2F1(czz,r1h1z,i1h1z,r1h1z,i1h1z) + - S2i2F1(cxy,r1h1x,i1h1x,r1h1y,i1h1y) + - S2i2F1(cyz,r1h1y,i1h1y,r1h1z,i1h1z) + - S2i2F1(cxz,r1h1x,i1h1x,r1h1z,i1h1z); - - return(temp); -} - -double -DFn3F1(double cxx, double cyy, double czz, double cxy, double cyz, double cxz, double cxxx, double cyyy, double czzz, double cxxy, double cxxz, double cxyy, double cyyz, double cxzz, double cyzz, double cxyz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z, double r2h11x, double i2h11x, double r2h11y, double i2h11y, double r2h11z, double i2h11z) - /* 28 args - 16 + 6 + 6 */ - - - -{ -double temp; - - temp = S2v3F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r2h11x,i2h11x,r2h11x,i2h11x) - +S2v3F1(cyy,r1h1y,i1h1y,r1h1y,i1h1y,r2h11y,i2h11y,r2h11y,i2h11y) - +S2v3F1(czz,r1h1z,i1h1z,r1h1z,i1h1z,r2h11z,i2h11z,r2h11z,i2h11z); - temp += - S2v3F1(cxy,r1h1x,i1h1x,r1h1y,i1h1y,r2h11x,i2h11x,r2h11y,i2h11y) - +S2v3F1(cyz,r1h1y,i1h1y,r1h1z,i1h1z,r2h11y,i2h11y,r2h11z,i2h11z) - +S2v3F1(cxz,r1h1x,i1h1x,r1h1z,i1h1z,r2h11x,i2h11x,r2h11z,i2h11z) - +S3v3F1(cxxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h1x,i1h1x); - temp += - S3v3F1(cyyy,r1h1y,i1h1y,r1h1y,i1h1y,r1h1y,i1h1y) - +S3v3F1(czzz,r1h1z,i1h1z,r1h1z,i1h1z,r1h1z,i1h1z) - +S3v3F1(cxxy,r1h1x,i1h1x,r1h1x,i1h1x,r1h1y,i1h1y) - +S3v3F1(cxxz,r1h1x,i1h1x,r1h1x,i1h1x,r1h1z,i1h1z) - +S3v3F1(cxyy,r1h1x,i1h1x,r1h1y,i1h1y,r1h1y,i1h1y); - temp += - S3v3F1(cyyz,r1h1y,i1h1y,r1h1y,i1h1y,r1h1z,i1h1z) - +S3v3F1(cxzz,r1h1x,i1h1x,r1h1z,i1h1z,r1h1z,i1h1z) - +S3v3F1(cyzz,r1h1y,i1h1y,r1h1z,i1h1z,r1h1z,i1h1z) - +S3v3F1(cxyz,r1h1x,i1h1x,r1h1y,i1h1y,r1h1z,i1h1z); - - return(temp); -} - -double -DFi3F1(double cxx, double cyy, double czz, double cxy, double cyz, double cxz, double cxxx, double cyyy, double czzz, double cxxy, double cxxz, double cxyy, double cyyz, double cxzz, double cyzz, double cxyz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z, double r2h11x, double i2h11x, double r2h11y, double i2h11y, double r2h11z, double i2h11z) - /* 28 args - 10 + 6 + 6 */ - - - -{ -double temp; - - temp = S2i3F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r2h11x,i2h11x,r2h11x,i2h11x) - +S2i3F1(cyy,r1h1y,i1h1y,r1h1y,i1h1y,r2h11y,i2h11y,r2h11y,i2h11y) - +S2i3F1(czz,r1h1z,i1h1z,r1h1z,i1h1z,r2h11z,i2h11z,r2h11z,i2h11z) - +S2i3F1(cxy,r1h1x,i1h1x,r1h1y,i1h1y,r2h11x,i2h11x,r2h11y,i2h11y); - temp += - S2i3F1(cyz,r1h1y,i1h1y,r1h1z,i1h1z,r2h11y,i2h11y,r2h11z,i2h11z) - +S2i3F1(cxz,r1h1x,i1h1x,r1h1z,i1h1z,r2h11x,i2h11x,r2h11z,i2h11z) - +S3i3F1(cxxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h1x,i1h1x) - +S3i3F1(cyyy,r1h1y,i1h1y,r1h1y,i1h1y,r1h1y,i1h1y); - temp += - S3i3F1(czzz,r1h1z,i1h1z,r1h1z,i1h1z,r1h1z,i1h1z) - +S3i3F1(cxxy,r1h1x,i1h1x,r1h1x,i1h1x,r1h1y,i1h1y) - +S3i3F1(cxxz,r1h1x,i1h1x,r1h1x,i1h1x,r1h1z,i1h1z) - +S3i3F1(cxyy,r1h1x,i1h1x,r1h1y,i1h1y,r1h1y,i1h1y); - temp += - S3i3F1(cyyz,r1h1y,i1h1y,r1h1y,i1h1y,r1h1z,i1h1z) - +S3i3F1(cxzz,r1h1x,i1h1x,r1h1z,i1h1z,r1h1z,i1h1z) - +S3i3F1(cyzz,r1h1y,i1h1y,r1h1z,i1h1z,r1h1z,i1h1z) - +S3i3F1(cxyz,r1h1x,i1h1x,r1h1y,i1h1y,r1h1z,i1h1z); - - return(temp); -} - -double -DFnF12(double cxx, double cyy, double czz, double cxy, double cyz, double cxz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z, double r1h2x, double i1h2x, double r1h2y, double i1h2y, double r1h2z, double i1h2z) - - /* 18 args - 6 + 6 + 6 */ - - - -{ -double temp; - - temp = S2vF12(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h2x,i1h2x,r1h2x,i1h2x) - +S2vF12(cyy,r1h1y,i1h1y,r1h1y,i1h1y,r1h2y,i1h2y,r1h2y,i1h2y) - +S2vF12(czz,r1h1z,i1h1z,r1h1z,i1h1z,r1h2z,i1h2z,r1h2z,i1h2z); - temp += - S2vF12(cxy,r1h1x,i1h1x,r1h1y,i1h1y,r1h2x,i1h2x,r1h2y,i1h2y) - +S2vF12(cyz,r1h1y,i1h1y,r1h1z,i1h1z,r1h2y,i1h2y,r1h2z,i1h2z) - +S2vF12(cxz,r1h1x,i1h1x,r1h1z,i1h1z,r1h2x,i1h2x,r1h2z,i1h2z); - - return(0.5*temp); -} - -double -DFiF12(double cxx, double cyy, double czz, double cxy, double cyz, double cxz, double r1h1x, double i1h1x, double r1h1y, double i1h1y, double r1h1z, double i1h1z, double r1h2x, double i1h2x, double r1h2y, double i1h2y, double r1h2z, double i1h2z) - - /* 18 args - 6 + 6 + 6 */ - - - -{ -double temp; - - temp = S2iF12(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h2x,i1h2x,r1h2x,i1h2x) - +S2iF12(cyy,r1h1y,i1h1y,r1h1y,i1h1y,r1h2y,i1h2y,r1h2y,i1h2y) - +S2iF12(czz,r1h1z,i1h1z,r1h1z,i1h1z,r1h2z,i1h2z,r1h2z,i1h2z); - temp += - S2iF12(cxy,r1h1x,i1h1x,r1h1y,i1h1y,r1h2x,i1h2x,r1h2y,i1h2y) - +S2iF12(cyz,r1h1y,i1h1y,r1h1z,i1h1z,r1h2y,i1h2y,r1h2z,i1h2z) - +S2iF12(cxz,r1h1x,i1h1x,r1h1z,i1h1z,r1h2x,i1h2x,r1h2z,i1h2z); - - return(temp*0.5); /* divided by two to scale down */ -} - -double -DFn2F12(DpassStr *p) - - /* 40 vars - 16 + 6 + 6 + 6 + 6 */ -/* - * a structure because a standard C compiler can handle only - * 32 variables. - * - */ -{ -double temp; - - temp = S2v2F12(p->cxx,p->r1h1x,p->i1h1x, - p->r1h1x,p->i1h1x, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x, - p->r2h11x,p->i2h11x, - p->r2h11x,p->i2h11x, - p->h2f1f2x,p->ih2f1f2x, - p->h2f1f2x,p->ih2f1f2x); - temp += - S2v2F12(p->cyy,p->r1h1y,p->i1h1y, - p->r1h1y,p->i1h1y, - p->r1h2y,p->i1h2y, - p->r1h2y,p->i1h2y, - p->r2h11y,p->i2h11y, - p->r2h11y,p->i2h11y, - p->h2f1f2y,p->ih2f1f2y, - p->h2f1f2y,p->ih2f1f2y); - temp += - S2v2F12(p->czz,p->r1h1z,p->i1h1z, - p->r1h1z,p->i1h1z, - p->r1h2z,p->i1h2z, - p->r1h2z,p->i1h2z, - p->r2h11z,p->i2h11z, - p->r2h11z,p->i2h11z, - p->h2f1f2z,p->ih2f1f2z, - p->h2f1f2z,p->ih2f1f2z); - temp += - S2v2F12(p->cxy,p->r1h1x,p->i1h1x, - p->r1h1y,p->i1h1y, - p->r1h2x,p->i1h2x, - p->r1h2y,p->i1h2y, - p->r2h11x,p->i2h11x, - p->r2h11y,p->i2h11y, - p->h2f1f2x,p->ih2f1f2x, - p->h2f1f2y,p->ih2f1f2y); - temp += - S2v2F12(p->cyz,p->r1h1y,p->i1h1y, - p->r1h1z,p->i1h1z, - p->r1h2y,p->i1h2y, - p->r1h2z,p->i1h2z, - p->r2h11y,p->i2h11y, - p->r2h11z,p->i2h11z, - p->h2f1f2y,p->ih2f1f2y, - p->h2f1f2z,p->ih2f1f2z); - temp += - S2v2F12(p->cxz,p->r1h1x,p->i1h1x, - p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2z,p->i1h2z, - p->r2h11x,p->i2h11x, - p->r2h11z,p->i2h11z, - p->h2f1f2x,p->ih2f1f2x, - p->h2f1f2z,p->ih2f1f2z); - temp += - S3v2F12(p->cxxx,p->r1h1x, - p->i1h1x,p->r1h1x,p->i1h1x,p->r1h1x,p->i1h1x, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x,p->r1h2x,p->i1h2x) - +S3v2F12(p->cyyy,p->r1h1y, - p->i1h1y,p->r1h1y,p->i1h1y,p->r1h1y,p->i1h1y, - p->r1h2y,p->i1h2y, - p->r1h2y,p->i1h2y,p->r1h2y,p->i1h2y); - temp += - S3v2F12(p->czzz,p->r1h1z, - p->i1h1z,p->r1h1z,p->i1h1z,p->r1h1z,p->i1h1z, - p->r1h2z,p->i1h2z, - p->r1h2z,p->i1h2z,p->r1h2z,p->i1h2z) - +S3v2F12(p->cxxy,p->r1h1x, - p->i1h1x,p->r1h1x,p->i1h1x,p->r1h1y,p->i1h1y, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x,p->r1h2y,p->i1h2y); - temp += - S3v2F12(p->cxxz,p->r1h1x, - p->i1h1x,p->r1h1x,p->i1h1x,p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x,p->r1h2z,p->i1h2z) - +S3v2F12(p->cxyy,p->r1h1x, - p->i1h1x,p->r1h1y,p->i1h1y,p->r1h1y,p->i1h1y, - p->r1h2x,p->i1h2x, - p->r1h2y,p->i1h2y,p->r1h2y,p->i1h2y); - temp += - S3v2F12(p->cyyz,p->r1h1y, - p->i1h1y,p->r1h1y,p->i1h1y,p->r1h1z,p->i1h1z, - p->r1h2y,p->i1h2y, - p->r1h2y,p->i1h2y,p->r1h2z,p->i1h2z) - +S3v2F12(p->cxzz,p->r1h1x, - p->i1h1x,p->r1h1z,p->i1h1z,p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2z,p->i1h2z,p->r1h2z,p->i1h2z); - temp += - S3v2F12(p->cyzz,p->r1h1y, - p->i1h1y,p->r1h1z,p->i1h1z,p->r1h1z,p->i1h1z, - p->r1h2y,p->i1h2y, - p->r1h2z,p->i1h2z,p->r1h2z,p->i1h2z) - +S3v2F12(p->cxyz,p->r1h1x, - p->i1h1x,p->r1h1y,p->i1h1y,p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2y,p->i1h2y,p->r1h2z,p->i1h2z); - - return(temp/3.); /* divided by 3 to get kernel (otherwise we get 3*kernel) */ -} - -double -DFi2F12(DpassStr *p) - - /* 40 vars - 16 + 6 + 6 + 6 + 6 */ -{ -double temp; - - temp = S2i2F12(p->cxx,p->r1h1x,p->i1h1x, - p->r1h1x,p->i1h1x, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x, - p->r2h11x,p->i2h11x, - p->r2h11x,p->i2h11x, - p->h2f1f2x,p->ih2f1f2x, - p->h2f1f2x,p->ih2f1f2x); - temp += - S2i2F12(p->cyy,p->r1h1y,p->i1h1y, - p->r1h1y,p->i1h1y, - p->r1h2y,p->i1h2y, - p->r1h2y,p->i1h2y, - p->r2h11y,p->i2h11y, - p->r2h11y,p->i2h11y, - p->h2f1f2y,p->ih2f1f2y, - p->h2f1f2y,p->ih2f1f2y); - temp += - S2i2F12(p->czz,p->r1h1z,p->i1h1z, - p->r1h1z,p->i1h1z, - p->r1h2z,p->i1h2z, - p->r1h2z,p->i1h2z, - p->r2h11z,p->i2h11z, - p->r2h11z,p->i2h11z, - p->h2f1f2z,p->ih2f1f2z, - p->h2f1f2z,p->ih2f1f2z); - temp += - S2i2F12(p->cxy,p->r1h1x,p->i1h1x, - p->r1h1y,p->i1h1y, - p->r1h2x,p->i1h2x, - p->r1h2y,p->i1h2y, - p->r2h11x,p->i2h11x, - p->r2h11y,p->i2h11y, - p->h2f1f2x,p->ih2f1f2x, - p->h2f1f2y,p->ih2f1f2y); - temp += - S2i2F12(p->cyz,p->r1h1y,p->i1h1y, - p->r1h1z,p->i1h1z, - p->r1h2y,p->i1h2y, - p->r1h2z,p->i1h2z, - p->r2h11y,p->i2h11y, - p->r2h11z,p->i2h11z, - p->h2f1f2y,p->ih2f1f2y, - p->h2f1f2z,p->ih2f1f2z); - temp += - S2i2F12(p->cxz,p->r1h1x,p->i1h1x, - p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2z,p->i1h2z, - p->r2h11x,p->i2h11x, - p->r2h11z,p->i2h11z, - p->h2f1f2x,p->ih2f1f2x, - p->h2f1f2z,p->ih2f1f2z); - temp += - S3i2F12(p->cxxx,p->r1h1x, - p->i1h1x,p->r1h1x,p->i1h1x,p->r1h1x,p->i1h1x, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x,p->r1h2x,p->i1h2x); - temp += - S3i2F12(p->cyyy,p->r1h1y, - p->i1h1y,p->r1h1y,p->i1h1y,p->r1h1y,p->i1h1y, - p->r1h2y,p->i1h2y, - p->r1h2y,p->i1h2y,p->r1h2y,p->i1h2y) - +S3i2F12(p->czzz,p->r1h1z, - p->i1h1z,p->r1h1z,p->i1h1z,p->r1h1z,p->i1h1z, - p->r1h2z,p->i1h2z, - p->r1h2z,p->i1h2z,p->r1h2z,p->i1h2z); - temp += - S3i2F12(p->cxxy,p->r1h1x, - p->i1h1x,p->r1h1x,p->i1h1x,p->r1h1y,p->i1h1y, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x,p->r1h2y,p->i1h2y) - +S3i2F12(p->cxxz,p->r1h1x, - p->i1h1x,p->r1h1x,p->i1h1x,p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2x,p->i1h2x,p->r1h2z,p->i1h2z); - temp += - S3i2F12(p->cxyy,p->r1h1x, - p->i1h1x,p->r1h1y,p->i1h1y,p->r1h1y,p->i1h1y, - p->r1h2x,p->i1h2x, - p->r1h2y,p->i1h2y,p->r1h2y,p->i1h2y) - +S3i2F12(p->cyyz,p->r1h1y, - p->i1h1y,p->r1h1y,p->i1h1y,p->r1h1z,p->i1h1z, - p->r1h2y,p->i1h2y, - p->r1h2y,p->i1h2y,p->r1h2z,p->i1h2z); - temp += - S3i2F12(p->cxzz,p->r1h1x, - p->i1h1x,p->r1h1z,p->i1h1z,p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2z,p->i1h2z,p->r1h2z,p->i1h2z); - temp += S3i2F12(p->cyzz,p->r1h1y, - p->i1h1y,p->r1h1z,p->i1h1z,p->r1h1z,p->i1h1z, - p->r1h2y,p->i1h2y, - p->r1h2z,p->i1h2z,p->r1h2z,p->i1h2z) - +S3i2F12(p->cxyz,p->r1h1x, - p->i1h1x,p->r1h1y,p->i1h1y,p->r1h1z,p->i1h1z, - p->r1h2x,p->i1h2x, - p->r1h2y,p->i1h2y,p->r1h2z,p->i1h2z); - - return(temp/3.); /* divided by 3 to get kernel (otherwise we get 3*kernel) */ -} - -double -D1n2F1(double cxx, double r1h1x, double i1h1x) - - /* 12 variables */ - - -{ -double temp; - - temp = S2v2F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x); - - return(temp); -} - -double -D1n3F1(double cxx, double cxxx, double r1h1x, double i1h1x, double r2h11x, double i2h11x) -{ -double temp; - - temp = S2v3F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r2h11x,i2h11x,r2h11x,i2h11x) - +S3v3F1(cxxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h1x,i1h1x); - - return(temp); -} - - -double -D1nF12(double cxx, double r1h1x, double i1h1x, double r1h2x, double i1h2x) - - /* 18 args - 6 + 6 + 6 */ - - - -{ -double temp; - - temp = S2vF12(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h2x,i1h2x,r1h2x,i1h2x); - - return(0.5*temp); -} - - -double -D1n2F12(double cxx, double cxxx, double r1h1x, double i1h1x, double r1h2x, double i1h2x, double r2h11x, double i2h11x, double h2f1f2x, double ih2f1f2x) - - /* 40 vars - 16 + 6 + 6 + 6 + 6 */ - - - - - -{ -double temp; - - temp = S2v2F12(cxx,r1h1x,i1h1x,r1h1x,i1h1x, - r1h2x,i1h2x,r1h2x,i1h2x, - r2h11x,i2h11x,r2h11x,i2h11x, - h2f1f2x,ih2f1f2x,h2f1f2x,ih2f1f2x) - +S3v2F12(cxxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h1x,i1h1x, - r1h2x,i1h2x,r1h2x,i1h2x,r1h2x,i1h2x); - - return(temp/3.); /* divided by 3 to get kernel (otherwise we get 3*kernel) */ -} - - -double -D1i2F1(double cxx, double r1h1x, double i1h1x) - - /* 12 variables */ - - -{ -double temp; - - temp = S2i2F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x); - - return(temp); -} - - -double -D1i3F1(double cxx, double cxxx, double r1h1x, double i1h1x, double r2h11x, double i2h11x) -{ -double temp; - - temp = S2i3F1(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r2h11x,i2h11x,r2h11x,i2h11x) - +S3i3F1(cxxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h1x,i1h1x); - - return(temp); -} - - -double -D1iF12(double cxx, double r1h1x, double i1h1x, double r1h2x, double i1h2x) - - /* 18 args - 6 + 6 + 6 */ - - - -{ -double temp; - - temp = S2iF12(cxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h2x,i1h2x,r1h2x,i1h2x); - - return(0.5*temp); -} - - -double -D1i2F12(double cxx, double cxxx, double r1h1x, double i1h1x, double r1h2x, double i1h2x, double r2h11x, double i2h11x, double h2f1f2x, double ih2f1f2x) - - /* 40 vars - 16 + 6 + 6 + 6 + 6 */ - - - - - -{ -double temp; - - temp = S2i2F12(cxx,r1h1x,i1h1x,r1h1x,i1h1x, - r1h2x,i1h2x,r1h2x,i1h2x, - r2h11x,i2h11x,r2h11x,i2h11x, - h2f1f2x,ih2f1f2x,h2f1f2x,ih2f1f2x) - +S3i2F12(cxxx,r1h1x,i1h1x,r1h1x,i1h1x,r1h1x,i1h1x, - r1h2x,i1h2x,r1h2x,i1h2x,r1h2x,i1h2x); - - return(temp/3.); /* divided by 3 to get kernel (otherwise we get 3*kernel) */ -} - diff --git a/src/analysis/dsetparm.c b/src/analysis/dsetparm.c deleted file mode 100644 index fc96b0606..000000000 --- a/src/analysis/dsetparm.c +++ /dev/null @@ -1,93 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jaijeet S Roychowdhury -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" -#include "distodef.h" - - -/* ARGSUSED */ -int -DsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case D_START: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid"); - ((DISTOAN*)anal)->DstartF1 = 1.0; - return(E_PARMVAL); - } - - ((DISTOAN*)anal)->DstartF1 = value->rValue; - break; - - case D_STOP: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid"); - ((DISTOAN*)anal)->DstartF1 = 1.0; - return(E_PARMVAL); - } - - ((DISTOAN*)anal)->DstopF1 = value->rValue; - break; - - case D_STEPS: - ((DISTOAN*)anal)->DnumSteps = value->iValue; - break; - - case D_DEC: - ((DISTOAN*)anal)->DstepType = DECADE; - break; - - case D_OCT: - ((DISTOAN*)anal)->DstepType = OCTAVE; - break; - - case D_LIN: - ((DISTOAN*)anal)->DstepType = LINEAR; - break; - - case D_F2OVRF1: - ((DISTOAN*)anal)->Df2ovrF1 = value->rValue; - ((DISTOAN*)anal)->Df2wanted = 1; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm Dparms[] = { - { "start", D_START, IF_SET|IF_REAL, "starting frequency" }, - { "stop", D_STOP, IF_SET|IF_REAL, "ending frequency" }, - { "numsteps", D_STEPS, IF_SET|IF_INTEGER, "number of frequencies" }, - { "dec", D_DEC, IF_SET|IF_FLAG, "step by decades" }, - { "oct", D_OCT, IF_SET|IF_FLAG, "step by octaves" }, - { "lin", D_LIN, IF_SET|IF_FLAG, "step linearly" }, - { "f2overf1", D_F2OVRF1, IF_SET|IF_REAL, "ratio of F2 to F1" }, -}; - -SPICEanalysis DISTOinfo = { - { - "DISTO", - "Small signal distortion analysis", - - sizeof(Dparms)/sizeof(IFparm), - Dparms - }, - sizeof(DISTOAN), - FREQUENCYDOMAIN, - 1, - DsetParm, - DaskQuest, - NULL, - DISTOan -}; diff --git a/src/analysis/naskq.c b/src/analysis/naskq.c deleted file mode 100644 index 9138819b7..000000000 --- a/src/analysis/naskq.c +++ /dev/null @@ -1,76 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Gary W. Ng -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "noisedef.h" - - -int -NaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case N_OUTPUT: - value->nValue = ((NOISEAN*)anal)->output; - break; - - case N_OUTREF: - value->nValue = ((NOISEAN*)anal)->outputRef; - break; - - case N_INPUT: - value->uValue = ((NOISEAN*)anal)->input; - break; - - case N_DEC: - if(((NOISEAN*)anal)->NstpType == DECADE) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case N_OCT: - if(((NOISEAN*)anal)->NstpType == OCTAVE) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case N_LIN: - if(((NOISEAN*)anal)->NstpType == LINEAR) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case N_STEPS: - value->iValue = ((NOISEAN*)anal)->NnumSteps; - break; - - case N_START: - value->rValue = ((NOISEAN*)anal)->NstartFreq; - break; - - case N_STOP: - value->rValue = ((NOISEAN*)anal)->NstopFreq; - break; - - case N_PTSPERSUM: - value->iValue = ((NOISEAN*)anal)->NStpsSm; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - diff --git a/src/analysis/nevalsrc.c b/src/analysis/nevalsrc.c deleted file mode 100644 index 14fb6d952..000000000 --- a/src/analysis/nevalsrc.c +++ /dev/null @@ -1,51 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Gary W. Ng -**********/ - -/* - * NevalSrc (noise, lnNoise, ckt, type, node1, node2, param) - * This routine evaluates the noise due to different physical - * phenomena. This includes the "shot" noise associated with dc - * currents in semiconductors and the "thermal" noise associated with - * resistance. Although semiconductors also display "flicker" (1/f) - * noise, the lack of a unified model requires us to handle it on a - * "case by case" basis. What we CAN provide, though, is the noise - * gain associated with the 1/f source. - */ - - -#include "ngspice.h" -#include "cktdefs.h" -#include "const.h" -#include "noisedef.h" - - -void -NevalSrc (double *noise, double *lnNoise, CKTcircuit *ckt, int type, int node1, int node2, double param) -{ - double realVal; - double imagVal; - double gain; - - realVal = *((ckt->CKTrhs) + node1) - *((ckt->CKTrhs) + node2); - imagVal = *((ckt->CKTirhs) + node1) - *((ckt->CKTirhs) + node2); - gain = (realVal*realVal) + (imagVal*imagVal); - switch (type) { - - case SHOTNOISE: - *noise = gain * 2 * CHARGE * fabs(param); /* param is the dc current in a semiconductor */ - *lnNoise = log( MAX(*noise,N_MINLOG) ); - break; - - case THERMNOISE: - *noise = gain * 4 * CONSTboltz * ckt->CKTtemp * param; /* param is the conductance of a resistor */ - *lnNoise = log( MAX(*noise,N_MINLOG) ); - break; - - case N_GAIN: - *noise = gain; - break; - - } -} diff --git a/src/analysis/ninteg.c b/src/analysis/ninteg.c deleted file mode 100644 index b98832b02..000000000 --- a/src/analysis/ninteg.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Gary W. Ng -**********/ - -/* - * Nintegrate.c (noizDens, lnNdens, lnNlstDens, data) - * - * This subroutine evaluates the integral of the function - * - * EXPONENT - * NOISE = a * (FREQUENCY) - * - * given two points from the curve. If EXPONENT is relatively close - * to 0, the noise is simply multiplied by the change in frequency. - * If it isn't, a more complicated expression must be used. Note that - * EXPONENT = -1 gives a different equation than EXPONENT <> -1. - * Hence, the reason for the constant 'N_INTUSELOG'. - */ - -#include -#include "ngspice.h" -#include "noisedef.h" - - -double -Nintegrate (double noizDens, double lnNdens, double lnNlstDens, register Ndata *data) -{ - double exponent; - double a; - - exponent = (lnNdens - lnNlstDens) / data->delLnFreq; - if ( fabs(exponent) < N_INTFTHRESH ) { - return (noizDens * data->delFreq); - } else { - a = exp(lnNdens - exponent*data->lnFreq); - exponent += 1.0; - if (fabs(exponent) < N_INTUSELOG) { - return (a * (data->lnFreq - data->lnLastFreq)); - } else { - return (a * ((exp(exponent * data->lnFreq) - exp(exponent * data->lnLastFreq)) / - exponent)); - } - } -} diff --git a/src/analysis/noisean.c b/src/analysis/noisean.c deleted file mode 100644 index 184af4f50..000000000 --- a/src/analysis/noisean.c +++ /dev/null @@ -1,286 +0,0 @@ -/* Patch to noisean.c by Richard D. McRoberts. - * Patched with modifications from Weidong Lu (2000) - * There is a strange #ifdef near the end of the file. - */ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Gary W. Ng -**********/ - -#define INT_NOISE /* Inserted to compile the ifdef'd code */ - -#include "ngspice.h" -#include -#include "acdefs.h" -#include "cktdefs.h" -#include "fteconst.h" -#include "iferrmsg.h" -#include "noisedef.h" -#include "sperror.h" -#include "vsrc/vsrcdefs.h" -#include "isrc/isrcdefs.h" - -int -NOISEan (CKTcircuit *ckt, int restart) -{ - register Ndata *data; - double realVal; - double imagVal; - int error; - int posOutNode; - int negOutNode; - int code; - int step; - /* register CKTnode *node; WL but not used ???? */ - IFuid freqUid; - void *inst; /* PN fixes incompatible pointer type warning */ - double freqTol; /* tolerence parameter for finding final frequency; hack */ - - register NOISEAN *job = (NOISEAN*) (ckt->CKTcurJob); - static char *noacinput = "noise input source has no AC value"; - - posOutNode = ((CKTnode*) (job->output))->number; - negOutNode = ((CKTnode*) (job->outputRef))->number; - - /* see if the source specified is AC */ - inst = NULL; - code = CKTtypelook("Vsource"); - if (code != -1) { - error = CKTfndDev((void *)ckt,&code,&inst, - job->input, (void *)NULL, (IFuid)NULL); - if (!error && !((VSRCinstance *)inst)->VSRCacGiven) { - errMsg = MALLOC(strlen(noacinput)+1); - strcpy(errMsg,noacinput); - return (E_NOACINPUT); - } - } - - code = CKTtypelook("Isource"); - if (code != -1 && inst==NULL) { - error = CKTfndDev((void *)ckt,&code,&inst, - job->input, (void *)NULL,(IFuid)NULL); - if (error) { - /* XXX ??? */ - (*(SPfrontEnd->IFerror))(ERR_WARNING, - "Noise input source %s not in circuit", - &job->input); - return (E_NOTFOUND); - } - if (!((ISRCinstance *)inst)->ISRCacGiven) { - errMsg = MALLOC(strlen(noacinput)+1); - strcpy(errMsg,noacinput); - return (E_NOACINPUT); - } - } - - if ( (job->NsavFstp == 0) || restart) { - switch (job->NstpType) { - - - case DECADE: - job->NfreqDelta = exp(log(10.0)/ - job->NnumSteps); - break; - - case OCTAVE: - job->NfreqDelta = exp(log(2.0)/ - job->NnumSteps); - break; - - case LINEAR: - job->NfreqDelta = (job->NstopFreq - - job->NstartFreq)/ - (job->NnumSteps+1); - break; - - default: - return(E_BADPARM); - } - - /* error = DCop(ckt); */ - error = CKTop(ckt, (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - if (error) return(error); - - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG; - error = CKTload(ckt); - if (error) return(error); - - data = (Ndata*)MALLOC(sizeof(Ndata)); - step = 0; - data->freq = job->NstartFreq; - data->outNoiz = 0.0; - data->inNoise = 0.0; - - /* the current front-end needs the namelist to be fully - declared before an OUTpBeginplot */ - - (*(SPfrontEnd->IFnewUid))((void *)ckt,&freqUid,(IFuid)NULL, - "frequency", UID_OTHER,(void **)NULL); - - data->numPlots = 0; /* we don't have any plots yet */ - error = CKTnoise(ckt,N_DENS,N_OPEN,data); - if (error) return(error); - - /* - * all names in the namelist have been declared. now start the - * plot - */ - - error = (*(SPfrontEnd->OUTpBeginPlot))(ckt,(void *)(ckt->CKTcurJob), - "Noise Spectral Density Curves - (V^2 or A^2)/Hz", - freqUid,IF_REAL,data->numPlots,data->namelist,IF_REAL, - &(data->NplotPtr)); - if (error) return(error); - - if (job->NstpType != LINEAR) { - (*(SPfrontEnd->OUTattributes))((void *)data->NplotPtr,NULL, - OUT_SCALE_LOG, NULL); - } - - } else { /* we must have paused before. pick up where we left off */ - step = job->NsavFstp; - switch (job->NstpType) { - - case DECADE: - case OCTAVE: - data->freq = job->NstartFreq * exp (step * - log (job->NfreqDelta)); - break; - - case LINEAR: - data->freq = job->NstartFreq + step * - job->NfreqDelta; - break; - - default: - return(E_BADPARM); - - } - job->NsavFstp = 0; - data->outNoiz = job->NsavOnoise; - data->inNoise = job->NsavInoise; - } - - switch (job->NstpType) { - case DECADE: - case OCTAVE: - freqTol = job->NfreqDelta * job->NstopFreq * ckt->CKTreltol; - break; - case LINEAR: - freqTol = job->NfreqDelta * ckt->CKTreltol; - break; - default: - return(E_BADPARM); - } - - data->lstFreq = data->freq; - - /* do the noise analysis over all frequencies */ - - while (data->freq <= job->NstopFreq + freqTol) { - if( (*(SPfrontEnd->IFpauseTest))() ) { - job->NsavFstp = step; /* save our results */ - job->NsavOnoise = data->outNoiz; /* up until now */ - job->NsavInoise = data->inNoise; - return (E_PAUSE); - } - ckt->CKTomega = 2.0 * M_PI * data->freq; - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEAC; - - /* - * solve the original AC system to get the transfer - * function between the input and output - */ - - NIacIter(ckt); - realVal = *((ckt->CKTrhsOld) + posOutNode) - - *((ckt->CKTrhsOld) + negOutNode); - imagVal = *((ckt->CKTirhsOld) + posOutNode) - - *((ckt->CKTirhsOld) + negOutNode); - data->GainSqInv = 1.0 / MAX(((realVal*realVal) - + (imagVal*imagVal)),N_MINGAIN); - data->lnGainInv = log(data->GainSqInv); - - /* set up a block of "common" data so we don't have to - * recalculate it for every device - */ - - data->delFreq = data->freq - data->lstFreq; - data->lnFreq = log(MAX(data->freq,N_MINLOG)); - data->lnLastFreq = log(MAX(data->lstFreq,N_MINLOG)); - data->delLnFreq = data->lnFreq - data->lnLastFreq; - - if ((job->NStpsSm != 0) && ((step % (job->NStpsSm)) == 0)) { - data->prtSummary = TRUE; - } else { - data->prtSummary = FALSE; - } - - /* - data->outNumber = 1; - */ - - data->outNumber = 0; - /* the frequency will NOT be stored in array[0] as before; instead, - * it will be given in refVal.rValue (see later) - */ - - NInzIter(ckt,posOutNode,negOutNode); /* solve the adjoint system */ - - /* now we use the adjoint system to calculate the noise - * contributions of each generator in the circuit - */ - - error = CKTnoise(ckt,N_DENS,N_CALC,data); - if (error) return(error); - data->lstFreq = data->freq; - - /* update the frequency */ - - switch (job->NstpType) { - - case DECADE: - case OCTAVE: - data->freq *= job->NfreqDelta; - break; - - case LINEAR: - data->freq += job->NfreqDelta; - break; - - default: - return(E_INTERN); - } - step++; - } - - error = CKTnoise(ckt,N_DENS,N_CLOSE,data); - if (error) return(error); - -#ifdef INT_NOISE /* WL */ - data->numPlots = 0; - data->outNumber = 0; - - if (job->NstartFreq != job->NstopFreq) { - error = CKTnoise(ckt,INT_NOIZ,N_OPEN,data); - - if (error) return(error); - - (*(SPfrontEnd->OUTpBeginPlot))(ckt,(void *)(ckt->CKTcurJob), - "Integrated Noise - V^2 or A^2", - (IFuid)NULL,(int)0,data->numPlots,data->namelist,IF_REAL, - &(data->NplotPtr)); - - error = CKTnoise(ckt,INT_NOIZ,N_CALC,data); - if (error) return(error); - - error = CKTnoise(ckt,INT_NOIZ,N_CLOSE,data); - if (error) return(error); - } -#endif - - FREE(data); - return(OK); -} diff --git a/src/analysis/nsetparm.c b/src/analysis/nsetparm.c deleted file mode 100644 index d1e932178..000000000 --- a/src/analysis/nsetparm.c +++ /dev/null @@ -1,106 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Gary W. Ng -**********/ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "noisedef.h" - - -int -NsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case N_OUTPUT: - ((NOISEAN*)anal)->output = value->nValue; - break; - - case N_OUTREF: - ((NOISEAN*)anal)->outputRef = value->nValue; - break; - - case N_INPUT: - ((NOISEAN*)anal)->input = value->uValue; - break; - - case N_DEC: - ((NOISEAN*)anal)->NstpType = DECADE; - break; - - case N_OCT: - ((NOISEAN*)anal)->NstpType = OCTAVE; - break; - - case N_LIN: - ((NOISEAN*)anal)->NstpType = LINEAR; - break; - - case N_STEPS: - ((NOISEAN*)anal)->NnumSteps = value->iValue; - break; - - case N_START: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid"); - ((NOISEAN*)anal)->NstartFreq = 1.0; - return(E_PARMVAL); - } - - ((NOISEAN*)anal)->NstartFreq = value->rValue; - break; - - case N_STOP: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid"); - ((NOISEAN*)anal)->NstartFreq = 1.0; - return(E_PARMVAL); - } - - ((NOISEAN*)anal)->NstopFreq = value->rValue; - break; - - case N_PTSPERSUM: - ((NOISEAN*)anal)->NStpsSm = value->iValue; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm Nparms[] = { - { "output", N_OUTPUT, IF_SET|IF_STRING, "output noise summation node" }, - { "outputref", N_OUTREF, IF_SET|IF_STRING, "output noise reference node" }, - { "input", N_INPUT, IF_SET|IF_STRING, "input noise source" }, - { "dec", N_DEC, IF_SET|IF_FLAG, "step by decades" }, - { "oct", N_OCT, IF_SET|IF_FLAG, "step by octaves" }, - { "lin", N_LIN, IF_SET|IF_FLAG, "step linearly" }, - { "numsteps", N_STEPS, IF_SET|IF_INTEGER, "number of frequencies" }, - { "start", N_START, IF_SET|IF_REAL, "starting frequency" }, - { "stop", N_STOP, IF_SET|IF_REAL, "ending frequency" }, - { "ptspersum", N_PTSPERSUM, IF_SET|IF_INTEGER, "frequency points per summary report" } -}; - -SPICEanalysis NOISEinfo = { - { - "NOISE", - "Noise analysis", - - sizeof(Nparms)/sizeof(IFparm), - Nparms - }, - sizeof(NOISEAN), - FREQUENCYDOMAIN, - 1, - NsetParm, - NaskQuest, - NULL, - NOISEan -}; diff --git a/src/analysis/pzan.c b/src/analysis/pzan.c deleted file mode 100644 index 40e1dad7a..000000000 --- a/src/analysis/pzan.c +++ /dev/null @@ -1,197 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include -#include "complex.h" -#include "cktdefs.h" -#include "smpdefs.h" -#include "pzdefs.h" -#include "trandefs.h" /* only to get the 'mode' definitions */ -#include "sperror.h" - - -#define DEBUG if (0) - -/* ARGSUSED */ -int -PZan(CKTcircuit *ckt, int reset) -{ - PZAN *pzan = (PZAN *) ckt->CKTcurJob; - int error; - int numNames; - IFuid *nameList; - void *plot; - - error = PZinit(ckt); - if (error != OK) return error; - - /* Calculate small signal parameters at the operating point */ - error = CKTop(ckt, (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - if (error) - return(error); - - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG; - error = CKTload(ckt); /* Make sure that all small signal params are - * set */ - if (error) - return(error); - - if (ckt->CKTkeepOpInfo) { - /* Dump operating point. */ - error = CKTnames(ckt,&numNames,&nameList); - if(error) return(error); - error = (*(SPfrontEnd->OUTpBeginPlot))((void *)ckt, - (void*)ckt->CKTcurJob, "Distortion Operating Point", - (IFuid)NULL,IF_REAL,numNames,nameList, IF_REAL,&plot); - if(error) return(error); - CKTdump(ckt,(double)0,plot); - (*(SPfrontEnd->OUTendPlot))(plot); - } - - if (pzan->PZwhich & PZ_DO_POLES) { - error = CKTpzSetup(ckt, PZ_DO_POLES); - if (error != OK) - return error; - error = CKTpzFindZeros(ckt, &pzan->PZpoleList, &pzan->PZnPoles); - if (error != OK) - return(error); - } - - if (pzan->PZwhich & PZ_DO_ZEROS) { - error = CKTpzSetup(ckt, PZ_DO_ZEROS); - if (error != OK) - return error; - error = CKTpzFindZeros(ckt, &pzan->PZzeroList, &pzan->PZnZeros); - if (error != OK) - return(error); - } - - return PZpost(ckt); -} - -/* - * Perform error checking - */ - -int -PZinit(CKTcircuit *ckt) -{ - PZAN *pzan = (PZAN *) ckt->CKTcurJob; - int i; - - i = CKTtypelook("transmission line"); - if (i == -1) { - i = CKTtypelook("Tranline"); - if (i == -1) - i = CKTtypelook("LTRA"); - } - if (i != -1 && ckt->CKThead[i] != NULL) - ERROR(E_XMISSIONLINE, "Transmission lines not supported") - - pzan->PZpoleList = (PZtrial *) NULL; - pzan->PZzeroList = (PZtrial *) NULL; - pzan->PZnPoles = 0; - pzan->PZnZeros = 0; - - if (pzan->PZin_pos == pzan->PZin_neg) - ERROR(E_SHORT, "Input is shorted") - - if (pzan->PZout_pos == pzan->PZout_neg) - ERROR(E_SHORT, "Output is shorted") - - if (pzan->PZin_pos == pzan->PZout_pos - && pzan->PZin_neg == pzan->PZout_neg - && pzan->PZinput_type == PZ_IN_VOL) - ERROR(E_INISOUT, "Transfer function is unity") - else if (pzan->PZin_pos == pzan->PZout_neg - && pzan->PZin_neg == pzan->PZout_pos - && pzan->PZinput_type == PZ_IN_VOL) - ERROR(E_INISOUT, "Transfer function is -1") - - return(OK); -} - -/* - * PZpost Post-processing of the pole-zero analysis results - */ - -int -PZpost(CKTcircuit *ckt) -{ - PZAN *pzan = (PZAN *) ckt->CKTcurJob; - void *pzPlotPtr; /* the plot pointer for front end */ - IFcomplex *out_list; - IFvalue outData; /* output variable (points to out_list) */ - IFuid *namelist; - PZtrial *root; - char name[50]; - int i, j; - - namelist = (IFuid *) MALLOC((pzan->PZnPoles - + pzan->PZnZeros)*sizeof(IFuid)); - out_list = (IFcomplex *)MALLOC((pzan->PZnPoles - + pzan->PZnZeros)*sizeof(IFcomplex)); - - j = 0; - for (i = 0; i < pzan->PZnPoles; i++) { - sprintf(name, "pole(%-u)", i+1); - (*(SPfrontEnd->IFnewUid))(ckt,&(namelist[j++]),(IFuid)NULL, - name,UID_OTHER,(void **)NULL); - } - for (i = 0; i < pzan->PZnZeros; i++) { - sprintf(name, "zero(%-u)", i+1); - (*(SPfrontEnd->IFnewUid))(ckt,&(namelist[j++]),(IFuid)NULL, - name,UID_OTHER,(void **)NULL); - } - - (*SPfrontEnd->OUTpBeginPlot)(ckt, (void *)pzan, pzan->JOBname, - (IFuid)NULL, (int)0, pzan->PZnPoles + pzan->PZnZeros, namelist, - IF_COMPLEX, &pzPlotPtr); - - j = 0; - if (pzan->PZnPoles > 0) { - for (root = pzan->PZpoleList; root != NULL; root = root->next) { - for (i = 0; i < root->multiplicity; i++) { - out_list[j].real = root->s.real; - out_list[j].imag = root->s.imag; - j += 1; - if (root->s.imag != 0.0) { - out_list[j].real = root->s.real; - out_list[j].imag = -root->s.imag; - j += 1; - } - } - DEBUG printf("LIST pole: (%g,%g) x %d\n", - root->s.real, root->s.imag, root->multiplicity); - } - } - - if (pzan->PZnZeros > 0) { - for (root = pzan->PZzeroList; root != NULL; root = root->next) { - for (i = 0; i < root->multiplicity; i++) { - out_list[j].real = root->s.real; - out_list[j].imag = root->s.imag; - j += 1; - if (root->s.imag != 0.0) { - out_list[j].real = root->s.real; - out_list[j].imag = -root->s.imag; - j += 1; - } - } - DEBUG printf("LIST zero: (%g,%g) x %d\n", - root->s.real, root->s.imag, root->multiplicity); - } - } - - outData.v.numValue = pzan->PZnPoles + pzan->PZnZeros; - outData.v.vec.cVec = out_list; - - (*SPfrontEnd->OUTpData)(pzPlotPtr, (IFvalue *) 0, &outData); - (*(SPfrontEnd->OUTendPlot))(pzPlotPtr); - - return(OK); -} diff --git a/src/analysis/pzaskq.c b/src/analysis/pzaskq.c deleted file mode 100644 index c1f41c42d..000000000 --- a/src/analysis/pzaskq.c +++ /dev/null @@ -1,80 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "pzdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -PZaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case PZ_NODEI: - value->nValue = (IFnode)CKTnum2nod(ckt,((PZAN*)anal)->PZin_pos); - break; - - case PZ_NODEG: - value->nValue = (IFnode)CKTnum2nod(ckt,((PZAN*)anal)->PZin_neg); - break; - - case PZ_NODEJ: - value->nValue = (IFnode)CKTnum2nod(ckt,((PZAN*)anal)->PZout_pos); - break; - - case PZ_NODEK: - value->nValue = (IFnode)CKTnum2nod(ckt,((PZAN*)anal)->PZout_neg); - break; - - case PZ_V: - if( ((PZAN*)anal)->PZinput_type == PZ_IN_VOL) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case PZ_I: - if( ((PZAN*)anal)->PZinput_type == PZ_IN_CUR) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case PZ_POL: - if( ((PZAN*)anal)->PZwhich == PZ_DO_POLES) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case PZ_ZER: - if( ((PZAN*)anal)->PZwhich == PZ_DO_ZEROS) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - case PZ_PZ: - if( ((PZAN*)anal)->PZwhich == (PZ_DO_POLES | PZ_DO_ZEROS)) { - value->iValue=1; - } else { - value->iValue=0; - } - break; - - default: - return(E_BADPARM); - } - return(OK); -} diff --git a/src/analysis/pzsetp.c b/src/analysis/pzsetp.c deleted file mode 100644 index 6e2822542..000000000 --- a/src/analysis/pzsetp.c +++ /dev/null @@ -1,100 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "pzdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -PZsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case PZ_NODEI: - ((PZAN*)anal)->PZin_pos = ((CKTnode*)value->nValue)->number; - break; - - case PZ_NODEG: - ((PZAN*)anal)->PZin_neg = ((CKTnode*)value->nValue)->number; - break; - - case PZ_NODEJ: - ((PZAN*)anal)->PZout_pos = ((CKTnode*)value->nValue)->number; - break; - - case PZ_NODEK: - ((PZAN*)anal)->PZout_neg = ((CKTnode*)value->nValue)->number; - break; - - case PZ_V: - if(value->iValue) { - ((PZAN*)anal)->PZinput_type = PZ_IN_VOL; - } - break; - - case PZ_I: - if(value->iValue) { - ((PZAN*)anal)->PZinput_type = PZ_IN_CUR; - } - break; - - case PZ_POL: - if(value->iValue) { - ((PZAN*)anal)->PZwhich = PZ_DO_POLES; - } - break; - - case PZ_ZER: - if(value->iValue) { - ((PZAN*)anal)->PZwhich = PZ_DO_ZEROS; - } - break; - - case PZ_PZ: - if(value->iValue) { - ((PZAN*)anal)->PZwhich = PZ_DO_POLES | PZ_DO_ZEROS; - } - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm PZparms[] = { - { "nodei", PZ_NODEI, IF_SET|IF_ASK|IF_NODE, "" }, - { "nodeg", PZ_NODEG, IF_SET|IF_ASK|IF_NODE, "" }, - { "nodej", PZ_NODEJ, IF_SET|IF_ASK|IF_NODE, "" }, - { "nodek", PZ_NODEK, IF_SET|IF_ASK|IF_NODE, "" }, - { "vol", PZ_V, IF_SET|IF_ASK|IF_FLAG, "" }, - { "cur", PZ_I, IF_SET|IF_ASK|IF_FLAG, "" }, - { "pol", PZ_POL, IF_SET|IF_ASK|IF_FLAG, "" }, - { "zer", PZ_ZER, IF_SET|IF_ASK|IF_FLAG, "" }, - { "pz", PZ_PZ, IF_SET|IF_ASK|IF_FLAG, "" } -}; - -SPICEanalysis PZinfo = { - { - "PZ", - "pole-zero analysis", - - sizeof(PZparms)/sizeof(IFparm), - PZparms - }, - sizeof(PZAN), - NODOMAIN, - 1, - PZsetParm, - PZaskQuest, - NULL, - PZan -}; diff --git a/src/analysis/sensaskq.c b/src/analysis/sensaskq.c deleted file mode 100644 index caff46c98..000000000 --- a/src/analysis/sensaskq.c +++ /dev/null @@ -1,59 +0,0 @@ -/********** -Copyright 1991 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" -#include "sensdefs.h" - - -/* ARGSUSED */ -int -SENSask(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - SENS_AN *sinfo = (SENS_AN *) anal; - - switch (which) { - - case SENS_START: - value->rValue = sinfo->start_freq; - break; - - case SENS_STOP: - value->rValue = sinfo->stop_freq; - break; - - case SENS_STEPS: - value->iValue = sinfo->n_freq_steps; - break; - - case SENS_DEC: - case SENS_OCT: - case SENS_LIN: - case SENS_DC: - value->iValue = sinfo->step_type == which; - break; - - case SENS_DEFTOL: - sinfo->deftol = value->rValue; - break; - - case SENS_DEFPERTURB: - value->rValue = sinfo->defperturb; - break; - -#ifdef notdef - case SENS_TYPE: - value->sValue = sinfo->type; - break; -#endif - - default: - return(E_BADPARM); - } - return(OK); -} - diff --git a/src/analysis/senssetp.c b/src/analysis/senssetp.c deleted file mode 100644 index 879e4c06b..000000000 --- a/src/analysis/senssetp.c +++ /dev/null @@ -1,145 +0,0 @@ -/********** -Copyright 1991 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cktdefs.h" -#include "sensdefs.h" - - -/* ARGSUSED */ -int -SENSsetParam(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - SENS_AN *sinfo = (SENS_AN *) anal; - - switch(which) { - - case SENS_POS: - sinfo->output_pos = (CKTnode *) value->nValue; - sinfo->output_neg = NULL; - sinfo->output_volt = 1; - sinfo->step_type = SENS_DC; - break; - - case SENS_NEG: - sinfo->output_neg = (CKTnode *) value->nValue; - break; - - case SENS_SRC: - sinfo->output_src = value->uValue; - sinfo->output_volt = 0; - sinfo->step_type = SENS_DC; - break; - - case SENS_NAME: - sinfo->output_name = value->sValue; - break; - - case SENS_START: - sinfo->start_freq = value->rValue; - break; - - case SENS_STOP: - sinfo->stop_freq = value->rValue; - break; - - case SENS_STEPS: - sinfo->n_freq_steps = value->iValue; - break; - - case SENS_DEC: - sinfo->step_type = SENS_DECADE; - break; - - case SENS_OCT: - sinfo->step_type = SENS_OCTAVE; - break; - - case SENS_LIN: - sinfo->step_type = SENS_LINEAR; - break; - - case SENS_DC: - sinfo->step_type = SENS_DC; - break; - - case SENS_DEFTOL: - sinfo->deftol = value->rValue; - break; - - case SENS_DEFPERTURB: - sinfo->defperturb = value->rValue; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm SENSparms[] = { - /* TF like parameters */ - { "outpos", SENS_POS, IF_SET|IF_ASK|IF_NODE, "output positive node" }, - { "outneg", SENS_NEG, IF_SET|IF_ASK|IF_NODE, "output negative node" }, - { "outsrc", SENS_SRC, IF_SET|IF_ASK|IF_INSTANCE, "output current" }, - { "outname", SENS_NAME, IF_SET|IF_ASK|IF_STRING, - "Name of output variable" }, - - /* AC parameters */ - { "start", SENS_START, IF_SET|IF_ASK|IF_REAL, "starting frequency" }, - { "stop", SENS_STOP, IF_SET|IF_ASK|IF_REAL, "ending frequency" }, - { "numsteps", SENS_STEPS,IF_SET|IF_ASK|IF_INTEGER, - "number of frequencies"}, - { "dec", SENS_DEC, IF_SET|IF_FLAG, "step by decades" }, - { "oct", SENS_OCT, IF_SET|IF_FLAG, "step by octaves" }, - { "lin", SENS_LIN, IF_SET|IF_FLAG, "step linearly" }, - { "dc", SENS_DC, IF_SET|IF_FLAG, "analysis at DC" }, - -#ifdef notdef - /* Future coding */ - /* perturbation limits */ - /* defaults for the analysis */ - { "deftol", SENS_DEFTOL, IF_SET|IF_REAL, "default tolerance" }, - { "defperturb", SENS_DEFPERT, IF_SET|IF_REAL, "default perterbation" }, - { "type", SENS_TYPE, IF_SET|IF_INTEGER, - "describe device, model or element parameters" }, - - { "device", SENS_DEVICE, IF_STRING, "type of model or device" }, - { "devdeftol", SENS_DEVDEFTOL, IF_SET|IF_REAL, - "default tolerance (device type)" }, - { "devdefperturb",SENS_DEVDEFPERT, IF_SET|IF_REAL, - "default perturbation (device type)" }, - { "moddeftol", SENS_DEVDEFTOL, IF_SET|IF_REAL, - "default tolerance (model)" }, - { "moddefperturb",SENS_DEVDEFPERT, IF_SET|IF_REAL, - "default perturbation (model)" }, - - /*{ "name", SENS_NAME, IF_SET|IF_STRING, - "name of model or element" }, */ - { "param", SENS_PARAM,IF_SET|IF_STRING, "name of parameter" }, - { "tol", SENS_TOL, IF_SET|IF_REAL, "tolerance" }, - { "perturb", SENS_PERT, IF_SET|IF_REAL, "perturbation" } -#endif - -}; - -SPICEanalysis SENSinfo = { - { - "SENS", - "Sensitivity analysis", - sizeof(SENSparms)/sizeof(IFparm), - SENSparms - }, - sizeof(SENS_AN), - FREQUENCYDOMAIN, - 1, - SENSsetParam, - SENSask, - NULL, - sens_sens -}; diff --git a/src/analysis/tfanal.c b/src/analysis/tfanal.c deleted file mode 100644 index 8effddfa1..000000000 --- a/src/analysis/tfanal.c +++ /dev/null @@ -1,186 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -/* subroutine to do DC Transfer Function analysis */ - -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "sperror.h" -#include "smpdefs.h" -#include "tfdefs.h" - - -/* ARGSUSED */ -int -TFanal(CKTcircuit *ckt, int restart) - - /* forced restart flag */ -{ - int size; - int insrc,outsrc; - double outputs[3]; - IFvalue outdata; /* structure for output data vector, will point to - * outputs vector above */ - IFvalue refval; /* structure for 'reference' value (not used here) */ - int error; - int converged; - register int i; - void *plotptr; /* pointer to out plot */ - void *ptr = NULL; - IFuid uids[3]; - int Itype; - int Vtype; - char *name; -#define tfuid (uids[0]) /* unique id for the transfer function output */ -#define inuid (uids[1]) /* unique id for the transfer function input imp. */ -#define outuid (uids[2]) /* unique id for the transfer function out. imp. */ - - - /* first, find the operating point */ - converged = CKTop(ckt, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITJCT, - (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT, - ckt->CKTdcMaxIter); - -#ifdef notdef - /* don't need this any more since newconvtest leaves the matrix factored */ - ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITFLOAT; - error = CKTload(ckt); - if(error) return(error); - - error=SMPluFac(ckt->CKTmatrix,ckt->CKTpivotAbsTol,ckt->CKTdiagGmin); - if(error) return(error); -#endif /* notdef */ - - Itype = CKTtypelook("Isource"); - Vtype = CKTtypelook("Vsource"); - if(Itype != -1) { - error = CKTfndDev((void*)ckt,&Itype,&ptr, - ((TFan*)ckt->CKTcurJob)->TFinSrc, (void *)NULL,(IFuid)NULL); - if(error ==0) { - ((TFan*)ckt->CKTcurJob)->TFinIsI = 1; - ((TFan*)ckt->CKTcurJob)->TFinIsV = 0; - } else { - ptr = NULL; - } - } - - if( (Vtype != -1) && (ptr==NULL) ) { - error = CKTfndDev((void*)ckt,&Vtype,&ptr, - ((TFan*)ckt->CKTcurJob)->TFinSrc, (void *)NULL, - (IFuid)NULL); - ((TFan*)ckt->CKTcurJob)->TFinIsV = 1; - ((TFan*)ckt->CKTcurJob)->TFinIsI = 0; - if(error !=0) { - (*(SPfrontEnd->IFerror))(ERR_WARNING, - "Transfer function source %s not in circuit", - &(((TFan*)ckt->CKTcurJob)->TFinSrc)); - ((TFan*)ckt->CKTcurJob)->TFinIsV = 0; - return(E_NOTFOUND); - } - } - - size = SMPmatSize(ckt->CKTmatrix); - for(i=0;i<=size;i++) { - ckt->CKTrhs[i] = 0; - } - - if(((TFan*)ckt->CKTcurJob)->TFinIsI) { - ckt->CKTrhs[((GENinstance*)ptr)->GENnode1] -= 1; - ckt->CKTrhs[((GENinstance*)ptr)->GENnode2] += 1; - } else { - insrc = CKTfndBranch(ckt,((TFan*)ckt->CKTcurJob)->TFinSrc); - ckt->CKTrhs[insrc] += 1; - } - - - SMPsolve(ckt->CKTmatrix,ckt->CKTrhs,ckt->CKTrhsSpare); - ckt->CKTrhs[0]=0; - - /* make a UID for the transfer function output */ - (*(SPfrontEnd->IFnewUid))(ckt,&tfuid,(IFuid)NULL,"Transfer_function", - UID_OTHER,(void **)NULL); - - /* make a UID for the input impedance */ - (*(SPfrontEnd->IFnewUid))(ckt,&inuid,((TFan*)ckt->CKTcurJob)->TFinSrc, - "Input_impedance", UID_OTHER,(void **)NULL); - - /* make a UID for the output impedance */ - if(((TFan*)ckt->CKTcurJob)->TFoutIsI) { - (*(SPfrontEnd->IFnewUid))(ckt,&outuid,((TFan*)ckt->CKTcurJob)->TFoutSrc - ,"Output_impedance", UID_OTHER,(void **)NULL); - } else { - name = (char *) - MALLOC(sizeof(char)*(strlen(((TFan*)ckt->CKTcurJob)->TFoutName)+22)); - (void)sprintf(name,"output_impedance_at_%s", - ((TFan*)ckt->CKTcurJob)->TFoutName); - (*(SPfrontEnd->IFnewUid))(ckt,&outuid,(IFuid)NULL, - name, UID_OTHER,(void **)NULL); - } - - error = (*(SPfrontEnd->OUTpBeginPlot))(ckt,(void *)(ckt->CKTcurJob), - ((TFan*)(ckt->CKTcurJob))->JOBname,(IFuid)NULL,(int)0,3, - uids,IF_REAL,&plotptr); - if(error) return(error); - - /*find transfer function */ - if(((TFan*)ckt->CKTcurJob)->TFoutIsV) { - outputs[0] = ckt->CKTrhs[((TFan*)ckt->CKTcurJob)->TFoutPos->number] - - ckt->CKTrhs[((TFan*)ckt->CKTcurJob)->TFoutNeg->number] ; - } else { - outsrc = CKTfndBranch(ckt,((TFan*)ckt->CKTcurJob)->TFoutSrc); - outputs[0] = ckt->CKTrhs[outsrc]; - } - - /* now for input resistance */ - if(((TFan*)ckt->CKTcurJob)->TFinIsI) { - outputs[1] = ckt->CKTrhs[((GENinstance*)ptr)->GENnode2] - - ckt->CKTrhs[((GENinstance*)ptr)->GENnode1]; - } else { - if(fabs(ckt->CKTrhs[insrc])<1e-20) { - outputs[1]=1e20; - } else { - outputs[1] = -1/ckt->CKTrhs[insrc]; - } - } - - if(((TFan*)ckt->CKTcurJob)->TFoutIsI && - (((TFan*)ckt->CKTcurJob)->TFoutSrc == - ((TFan*)ckt->CKTcurJob)->TFinSrc)) { - outputs[2]=outputs[1]; - goto done; - /* no need to compute output resistance when it is the same as - the input */ - } - /* now for output resistance */ - for(i=0;i<=size;i++) { - ckt->CKTrhs[i] = 0; - } - if(((TFan*)ckt->CKTcurJob)->TFoutIsV) { - ckt->CKTrhs[((TFan*)ckt->CKTcurJob)->TFoutPos->number] -= 1; - ckt->CKTrhs[((TFan*)ckt->CKTcurJob)->TFoutNeg->number] += 1; - } else { - ckt->CKTrhs[outsrc] += 1; - } - SMPsolve(ckt->CKTmatrix,ckt->CKTrhs,ckt->CKTrhsSpare); - ckt->CKTrhs[0]=0; - if(((TFan*)ckt->CKTcurJob)->TFoutIsV) { - outputs[2]= ckt->CKTrhs[((TFan*)ckt->CKTcurJob)->TFoutNeg->number] - - ckt->CKTrhs[((TFan*)ckt->CKTcurJob)->TFoutPos->number]; - } else { - outputs[2] = 1/MAX(1e-20,ckt->CKTrhs[outsrc]); - } -done: - outdata.v.numValue=3; - outdata.v.vec.rVec=outputs; - refval.rValue = 0; - (*(SPfrontEnd->OUTpData))(plotptr,&refval,&outdata); - (*(SPfrontEnd->OUTendPlot))(plotptr); - return(OK); -} - - diff --git a/src/analysis/tfaskq.c b/src/analysis/tfaskq.c deleted file mode 100644 index 1a51786e2..000000000 --- a/src/analysis/tfaskq.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "trcvdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -TFaskQuest(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - default: - break; - } - return(E_BADPARM); -} - diff --git a/src/analysis/tfsetp.c b/src/analysis/tfsetp.c deleted file mode 100644 index 411d78829..000000000 --- a/src/analysis/tfsetp.c +++ /dev/null @@ -1,72 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "tfdefs.h" -#include "cktdefs.h" - - -/* ARGSUSED */ -int -TFsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case TF_OUTPOS: - ((TFan *)anal)->TFoutPos = (CKTnode *)value->nValue; - ((TFan *)anal)->TFoutIsV = TRUE; - ((TFan *)anal)->TFoutIsI = FALSE; - break; - case TF_OUTNEG: - ((TFan *)anal)->TFoutNeg = (CKTnode *)value->nValue; - ((TFan *)anal)->TFoutIsV = TRUE; - ((TFan *)anal)->TFoutIsI = FALSE; - break; - case TF_OUTNAME: - ((TFan *)anal)->TFoutName = value->sValue; - break; - case TF_OUTSRC: - ((TFan *)anal)->TFoutSrc = value->uValue; - ((TFan *)anal)->TFoutIsV = FALSE; - ((TFan *)anal)->TFoutIsI = TRUE; - break; - case TF_INSRC: - ((TFan *)anal)->TFinSrc = value->uValue; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm TFparms[] = { - { "outpos", TF_OUTPOS, IF_SET|IF_NODE, "Positive output node" }, - { "outneg", TF_OUTNEG, IF_SET|IF_NODE, "Negative output node" }, - { "outname", TF_OUTNAME, IF_SET|IF_STRING,"Name of output variable"}, - { "outsrc", TF_OUTSRC, IF_SET|IF_INSTANCE, "Output source" }, - { "insrc", TF_INSRC, IF_SET|IF_INSTANCE, "Input source" } -}; - -SPICEanalysis TFinfo = { - { - "TF", - "transfer function analysis", - - sizeof(TFparms)/sizeof(IFparm), - TFparms - }, - sizeof(TFan), - NODOMAIN, - 0, - TFsetParm, - TFaskQuest, - NULL, - TFanal -}; diff --git a/src/analysis/tranaskq.c b/src/analysis/tranaskq.c deleted file mode 100644 index 2f2bd7b2c..000000000 --- a/src/analysis/tranaskq.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "trandefs.h" -#include "cktdefs.h" - -/* ARGSUSED */ -int -TRANaskQuest(CKTcircuit *ckt, void *anal, int which,IFvalue *value) -{ - switch(which) { - - case TRAN_TSTOP: - value->rValue = ((TRANan *)anal)->TRANfinalTime; - break; - case TRAN_TSTEP: - value->rValue = ((TRANan *)anal)->TRANstep; - break; - case TRAN_TSTART: - value->rValue = ((TRANan *)anal)->TRANinitTime; - break; - case TRAN_TMAX: - value->rValue = ((TRANan *)anal)->TRANmaxStep; - break; - case TRAN_UIC: - if(((TRANan *)anal)->TRANmode & MODEUIC) { - value->iValue = 1; - } else { - value->iValue = 0; - } - break; - - - default: - return(E_BADPARM); - } - return(OK); -} - diff --git a/src/analysis/traninit.c b/src/analysis/traninit.c deleted file mode 100644 index b91a02859..000000000 --- a/src/analysis/traninit.c +++ /dev/null @@ -1,28 +0,0 @@ -/********** -Copyright 1991 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include "cktdefs.h" -#include "trandefs.h" -#include "iferrmsg.h" - -/* - * this used to be in setup, but we need it here now - * (must be done after mode is set as below) - */ - -int TRANinit(CKTcircuit *ckt, JOB *job) -{ - ckt->CKTfinalTime = ((TRANan*)job)->TRANfinalTime; - ckt->CKTstep = ((TRANan*)job)->TRANstep; - ckt->CKTinitTime = ((TRANan*)job)->TRANinitTime; - ckt->CKTmaxStep = ((TRANan*)job)->TRANmaxStep; - if(ckt->CKTmaxStep == 0) { - ckt->CKTmaxStep = (ckt->CKTfinalTime-ckt->CKTinitTime)/50; - } - ckt->CKTdelmin = 1e-9*ckt->CKTmaxStep; /* XXX */ - ckt->CKTmode = ((TRANan*)job)->TRANmode; - - return OK; -} diff --git a/src/analysis/transetp.c b/src/analysis/transetp.c deleted file mode 100644 index 1c81b851a..000000000 --- a/src/analysis/transetp.c +++ /dev/null @@ -1,67 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "trandefs.h" -#include "cktdefs.h" - -/* ARGSUSED */ -int -TRANsetParm(CKTcircuit *ckt, void *anal, int which, IFvalue *value) -{ - switch(which) { - - case TRAN_TSTOP: - ((TRANan *)anal)->TRANfinalTime = value->rValue; - break; - case TRAN_TSTEP: - ((TRANan *)anal)->TRANstep = value->rValue; - break; - case TRAN_TSTART: - ((TRANan *)anal)->TRANinitTime = value->rValue; - break; - case TRAN_TMAX: - ((TRANan *)anal)->TRANmaxStep = value->rValue; - break; - case TRAN_UIC: - if(value->iValue) { - ((TRANan *)anal)->TRANmode |= MODEUIC; - } - break; - - default: - return(E_BADPARM); - } - return(OK); -} - - -static IFparm TRANparms[] = { - { "tstart", TRAN_TSTART, IF_SET|IF_REAL, "starting time" }, - { "tstop", TRAN_TSTOP, IF_SET|IF_REAL, "ending time" }, - { "tstep", TRAN_TSTEP, IF_SET|IF_REAL, "time step" }, - { "tmax", TRAN_TMAX, IF_SET|IF_REAL, "maximum time step" }, - { "uic", TRAN_UIC, IF_SET|IF_FLAG, "use initial conditions" }, -}; - -SPICEanalysis TRANinfo = { - { - "TRAN", - "Transient analysis", - - sizeof(TRANparms)/sizeof(IFparm), - TRANparms - }, - sizeof(TRANan), - TIMEDOMAIN, - 1, - TRANsetParm, - TRANaskQuest, - TRANinit, - DCtran -}; diff --git a/src/circuit/ChangeLog b/src/circuit/ChangeLog deleted file mode 100644 index bc6d059bf..000000000 --- a/src/circuit/ChangeLog +++ /dev/null @@ -1,85 +0,0 @@ -2000-04-04 Paolo Nenzi - - * inpfindl.c: Modified the file for BSIM4 and future extensions to - BSIM5 and BSIM6. I have merged the inpfindl.c coming - with the BSIM4 distribution. - * inp2r.c: Added acval=val to initialize the acval parameter to - a significative value. Hope does not brak anything. - - - * inp2m.c: Added BSIM4 support. - - * inpdomod.c: Added support for BSIM4 device model. - -2000-03-28 Paolo Nenzi - - * ptfuncs.c: I have applied a couple of patches by GLAO Dezay. He noted - that PTln, PTlog and PTsqrt returned non consistent values - if the argument was out of domain. If arg <0 they returned - f(-arg). The patch is masked by #ifdef EXPERIMENTAL_CODE. - You have to remove these lines or #define it to compile - Dezai's patched code. - -2000-03-11 Paolo Nenzi - * inp2dot.c: Applied Glao Dezai patch, adding which = -1 in the .sens code. - -2000-01-17 Paolo Nenzi - * inp2m.c, inpdomod.c: Inserted code to dupport BSIM3V1 model as - level 49. - -2000-01-16 Paolo Nenzi - - * inp2r.c: Modified resistor code. Added ac value (ala HSPICE), from - Serban Popescu contributed sources. - -2000-01-15 Paolo Nenzi - - * inp2m.c, inpdomod.c : Inserted code to support BSIM3V2 model as - level 50. - -1999-12-20 Paolo Nenzi - - * inpgtok.c, inpptree.c: Bug Fix - Bug: Scale factors (eg. m, k, meg, etc.) for constants in arbitrary - source (b devices) are not recognized. - Fix: Changes to inpgtok.c and inpptree.c, as supplied by Berkeley. - NOTE: These changes were orignally supplied to me as a patch to 3e2 - by Beorn Johnson who was maintaining Spice a while back. They were - supposed to have been incorporated in Spice 3f2 at that time, but are - missing from the 3f5 version that I recently got from Berkeley. I - don't know if they were removed in ignorance or because of a conflict - with some other requirement, but they appear to work in 3f5. ALSO, - the fix for 3e2 had many more changes, all of which remain in 3f5, so - don't try these alone on 3e2. - -1999-09-07 Arno - - * inpsymt.c: removed unused function prototype for local_remove(). - - * sperror.c: removed unused variable `notempty' - -1999-09-05 Emmanuel Rouat - - * inpptree.c (PTdifferentiate): removed superfluous argument - to 2 occurences of function mkf - - * *.c: put all function prototypes in inp.h - -1999-08-28 Emmanuel Rouat - - * Removed all #includes of misc.h and util.h (now in spice.h) - -1999-08-24 Paolo Nenzi - - * inpdomod.c: added level check for ps model, jfet level 2 - - * inp2j.c: added code for ps model, jfet level 2 -1999-08-08 Emmanuel Rouat - - * inp2dot.c (INP2dot):changed HAS_SENSE2 in WANT_SENSE2 - -1999-08-03 Emmanuel Rouat - - * ptfuncs.c: changed HAS_ATRIGH to HAVE_ACOSH,HAVE_ASINH and - HAVE_ATANH provided in config.h - diff --git a/src/circuit/Makefile.am b/src/circuit/Makefile.am deleted file mode 100644 index f05d7645a..000000000 --- a/src/circuit/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LIBRARIES = libinp.a - -libinp_a_SOURCES = \ - ifeval.c \ - ifnewuid.c \ - inp2b.c \ - inp2c.c \ - inp2d.c \ - inp2dot.c \ - inp2e.c \ - inp2f.c \ - inp2g.c \ - inp2h.c \ - inp2i.c \ - inp2j.c \ - inp2k.c \ - inp2l.c \ - inp2m.c \ - inp2o.c \ - inp2q.c \ - inp2r.c \ - inp2s.c \ - inp2t.c \ - inp2u.c \ - inp2v.c \ - inp2w.c \ - inp2z.c \ - inpaname.c \ - inpapnam.c \ - inpcfix.c \ - inpdomod.c \ - inpdoopt.c \ - inpdpar.c \ - inperrc.c \ - inperror.c \ - inpeval.c \ - inpfindl.c \ - inpgmod.c \ - inpgstr.c \ - inpgtitl.c \ - inpgtok.c \ - inpgval.c \ - inpkmods.c \ - inplist.c \ - inplkmod.c \ - inpmkmod.c \ - inpmktmp.c \ - inppas1.c \ - inppas2.c \ - inppname.c \ - inpptree.c \ - inpsymt.c \ - inptyplk.c \ - ptfuncs.c \ - sperror.c \ - inp.h - - - -INCLUDES = -I$(top_srcdir)/src/include - -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/circuit/ifeval.c b/src/circuit/ifeval.c deleted file mode 100644 index 54aa5b008..000000000 --- a/src/circuit/ifeval.c +++ /dev/null @@ -1,108 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpmacs.h" -#include "fteext.h" -#include "iferrmsg.h" -#include "inpptree.h" -#include "inp.h" - - - - -extern double PTfudge_factor; - -static int PTeval(INPparseNode *tree, double gmin, double *res, double *vals); - - - -int -IFeval(IFparseTree *tree, double gmin, double *result, double *vals, double *derivs) -{ - int i, err; - INPparseTree *myTree = (INPparseTree*) tree;; - -/* -INPptPrint("calling PTeval, tree = ", myTree); -printf("values:"); -for (i = 0; i < myTree->p.numVars; i++) -printf("\tvar%d = %lg\n", i, vals[i]); -*/ - - if ((err = PTeval(myTree->tree, gmin, result, vals)) != OK) - return (err); - - for (i = 0; i < myTree->p.numVars; i++) - if ((err = PTeval(myTree->derivs[i], gmin, &derivs[i], vals)) != OK) - return (err); - -/* -printf("results: function = %lg\n", *result); -for (i = 0; i < myTree->p.numVars; i++) -printf("\td / d var%d = %lg\n", i, derivs[i]); -*/ - - return (OK); -} - -static int -PTeval(INPparseNode *tree, double gmin, double *res, double *vals) -{ - double r1, r2; - int err; - - PTfudge_factor = gmin; - switch (tree->type) { - case PT_CONSTANT: - *res = tree->constant; - break; - - case PT_VAR: - *res = vals[tree->valueIndex]; - break; - - case PT_FUNCTION: - err = PTeval(tree->left, gmin, &r1, vals); - if (err != OK) - return (err); - *res = (*tree->function)(r1); - if (*res == HUGE) { - fprintf(stderr, "Error: %g out of range for %s\n", - r1, tree->funcname); - return (E_PARMVAL); - } - break; - - case PT_PLUS: - case PT_MINUS: - case PT_TIMES: - case PT_DIVIDE: - case PT_POWER: - err = PTeval(tree->left, gmin, &r1, vals); - if (err != OK) - return (err); - err = PTeval(tree->right, gmin, &r2, vals); - if (err != OK) - return (err); - *res = (*tree->function)(r1, r2); - if (*res == HUGE) { - fprintf(stderr, "Error: %g, %g out of range for %s\n", - r1, r2, tree->funcname); - return (E_PARMVAL); - } - break; - - default: - fprintf(stderr, "Internal Error: bad node type %d\n", - tree->type); - return (E_PANIC); - } - - return (OK); -} - diff --git a/src/circuit/ifnewuid.c b/src/circuit/ifnewuid.c deleted file mode 100644 index 366775126..000000000 --- a/src/circuit/ifnewuid.c +++ /dev/null @@ -1,82 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "cpdefs.h" -#include "fteext.h" -#include "inp.h" - - -int -IFnewUid(void *ckt, IFuid *newuid, IFuid olduid, char *suffix, int type, void **nodedata) -{ - char *newname; - int error; - - if(olduid) { - newname=(char *) - MALLOC(sizeof(char)*(strlen(suffix)+strlen((char*)olduid)+2)); - /* 2 = '#' + '\0' */ - sprintf(newname,"%s#%s",(char*)olduid,suffix); - } else { - newname=(char *)MALLOC(sizeof(char)* - (strlen(suffix)+1)); /* 1 = '\0' */ - sprintf(newname,"%s",suffix); - } - - switch(type) { - case UID_ANALYSIS: - case UID_TASK: - case UID_INSTANCE: - case UID_OTHER: - case UID_MODEL: - error = INPinsert(&newname, - (INPtables *)ft_curckt->ci_symtab); - if(error && error != E_EXISTS) return(error); - *newuid = (IFuid) newname; - break; - - case UID_SIGNAL: - error = INPmkTerm(ckt,&newname, - (INPtables *)ft_curckt->ci_symtab,nodedata); - if(error && error != E_EXISTS) return(error); - *newuid = (IFuid) newname; - break; - - default: - return(E_BADPARM); - } - return(OK); -} - -int -IFdelUid(void *ckt, IFuid uid, int type) -{ - int error; - - switch(type) { - case UID_ANALYSIS: - case UID_TASK: - case UID_INSTANCE: - case UID_OTHER: - case UID_MODEL: - error = INPremove(uid, (INPtables *)ft_curckt->ci_symtab); - if(error && error != E_EXISTS) return(error); - break; - - case UID_SIGNAL: - error = INPremTerm(uid, (INPtables *)ft_curckt->ci_symtab); - if(error && error != E_EXISTS) return(error); - break; - - default: - return(E_BADPARM); - } - return(OK); -} diff --git a/src/circuit/inp.h b/src/circuit/inp.h deleted file mode 100644 index 0edacf41c..000000000 --- a/src/circuit/inp.h +++ /dev/null @@ -1,127 +0,0 @@ -/************* - * Header file for inpxx.c - * 1999 E. Rouat - ************/ - -#ifndef INP_H_INCLUDED -#define INP_H_INCLUDED - -/* ifeval.c */ - -int IFeval(IFparseTree *tree, double gmin, double *result, double *vals, - double *derivs); - -/* ifnewuid.c */ - -int IFnewUid(void *ckt, IFuid *newuid, IFuid olduid, char *suffix, int type, - void **nodedata); -int IFdelUid(void *ckt, IFuid uid, int type); - -/* inp2xx.c */ - -void INP2B(void *ckt, INPtables *tab, card *current); -void INP2C(void *ckt, INPtables *tab, card *current); -void INP2D(void *ckt, INPtables *tab, card *current); -void INP2E(void *ckt, INPtables *tab, card *current); -void INP2F(void *ckt, INPtables *tab, card *current); -void INP2G(void *ckt, INPtables *tab, card *current); -void INP2H(void *ckt, INPtables *tab, card *current); -void INP2I(void *ckt, INPtables *tab, card *current); -void INP2J(void *ckt, INPtables *tab, card *current); -void INP2K(void *ckt, INPtables *tab, card *current); -void INP2L(void *ckt, INPtables *tab, card *current); -void INP2M(void *ckt, INPtables *tab, card *current); -void INP2O(void *ckt, INPtables *tab, card *current); -void INP2Q(void *ckt, INPtables *tab, card *current, void *gnode); -void INP2R(void *ckt, INPtables *tab, card *current); -void INP2S(void *ckt, INPtables *tab, card *current); -void INP2T(void *ckt, INPtables *tab, card *current); -void INP2U(void *ckt, INPtables *tab, card *current); -void INP2V(void *ckt, INPtables *tab, card *current); -void INP2W(void *ckt, INPtables *tab, card *current); -void INP2Z(void *ckt, INPtables *tab, card *current); -int INP2dot(void *ckt, INPtables *tab, card *current, void *task, void *gnode); - -/* inpxxxx.c */ - -int INPaName(char *parm, IFvalue *val, void *ckt, int *dev, char *devnam, - void **fast, IFsimulator *sim, int *dataType, IFvalue *selector); -int INPapName(void *ckt, int type, void *analPtr, char *parmname, IFvalue *value); -void INPcaseFix(register char *string); -char * INPdomodel(void *ckt, card *image, INPtables *tab); -void INPdoOpts(void *ckt, void *anal, card *optCard, INPtables *tab); -char * INPdevParse(char **line, void *ckt, int dev, void *fast, double *leading, - int *waslead, INPtables *tab); -char * INPerrCat(char *a, char *b); -char * INPerror(int type); -double INPevaluate(char **line, int *error, int gobble); -char * INPfindLev(char *line, int *level); -char * INPgetMod(void *ckt, char *name, INPmodel **model, INPtables *tab); -int INPgetStr(char **line, char **token, int gobble); -int INPgetTitle(void **ckt, card **data); -int INPgetTok(char **line, char **token, int gobble); -int INPgetUTok(char **line, char **token, int gobble); -IFvalue * INPgetValue(void *ckt, char **line, int type, INPtables *tab); -void INPkillMods(void); -void INPlist(FILE *file, card *deck, int type); -int INPlookMod(char *name); -int INPmakeMod(char *token, int type, card *line); -char * INPmkTemp(char *string); -void INPpas1(void *ckt, card *deck, INPtables *tab); -void INPpas2(void *ckt, card *data, INPtables *tab, void *task); -int INPpName(char *parm, IFvalue *val, void *ckt, int dev, void *fast); - -/* inpptree.c */ - -void INPgetTree(char **line, INPparseTree **pt, void *ckt, INPtables *tab); - - -/* inpsymt.c */ - -INPtables * INPtabInit(int numlines); -int INPtermInsert(void *ckt, char **token, INPtables *tab, void **node); -int INPmkTerm(void *ckt, char **token, INPtables *tab, void **node); -int INPgndInsert(void *ckt, char **token, INPtables *tab, void **node); -int INPretrieve(char **token, INPtables *tab); -int INPinsert(char **token, INPtables *tab); -int INPinsertNofree(char **token, INPtables *tab); -int INPremove(char *token, INPtables *tab); -int INPremTerm(char *token, INPtables *tab); -void INPtabEnd(INPtables *tab); - -int INPtypelook(char *type); - -/* ptfuncs.c */ - -double PTabs(double arg); -double PTsgn(double arg); -double PTplus(double arg1, double arg2); -double PTminus(double arg1, double arg2); -double PTtimes(double arg1, double arg2); -double PTtimes(double arg1, double arg2); -double PTdivide(double arg1, double arg2); -double PTpower(double arg1, double arg2); -double PTacos(double arg); -double PTacosh(double arg); -double PTasin(double arg); -double PTasinh(double arg); -double PTatan(double arg); -double PTatanh(double arg); -double PTustep(double arg); -double PTuramp(double arg); -double PTcos(double arg); -double PTcosh(double arg); -double PTexp(double arg); -double PTln(double arg); -double PTlog(double arg); -double PTsin(double arg); -double PTsinh(double arg); -double PTsqrt(double arg); -double PTtan(double arg); -double PTuminus(double arg); - -/* sperror.c */ - -char * SPerror(int type); - -#endif diff --git a/src/circuit/inp2b.c b/src/circuit/inp2b.c deleted file mode 100644 index df61af1dd..000000000 --- a/src/circuit/inp2b.c +++ /dev/null @@ -1,59 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2B(void *ckt, INPtables *tab, card *current) -{ - - /* Bname [V=expr] [I=expr] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model name */ - - /* Arbitrary source. */ - type = INPtypelook("ASRC"); - if (type < 0) { - LITERR("Device type Asource not supported by this binary\n") - return; - } - - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - - INPgetTok(&line,&nname1,1); - error = INPtermInsert(ckt,&nname1,tab,&node1); - - INPgetTok(&line,&nname2,1); - error = INPtermInsert(ckt,&nname2,tab,&node2); - - if(!tab->defBmod) { - /* create default B model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"B",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defBmod),uid)) - } - IFC(newInstance,(ckt,tab->defBmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) -} diff --git a/src/circuit/inp2c.c b/src/circuit/inp2c.c deleted file mode 100644 index e5ba57c40..000000000 --- a/src/circuit/inp2c.c +++ /dev/null @@ -1,91 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2C(void *ckt, INPtables *tab, card *current) -{ - -/* parse a capacitor card */ -/* Cname [IC=] */ - -int mytype; /* the type we determine resistors are */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *model; /* the name of the resistor's model */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -double val; /* temp to held resistance */ -int error; /* error code temporary */ -INPmodel *thismodel; /* pointer to model structure describing our model */ -void *mdfast; /* pointer to the actual model */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default cap model */ - - mytype = INPtypelook("Capacitor"); - if(mytype < 0 ) { - LITERR("Device type Capacitor not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - val = INPevaluate(&line,&error,1); - if(error == 0) { /* Looks like a number */ - type = mytype; - ptemp.rValue = val; - if(!tab->defCmod) { - IFnewUid(ckt,&uid,(IFuid)NULL,"C",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defCmod),uid)) - } - IFC(newInstance,(ckt,tab->defCmod,&fast,name)) - GCA(INPpName,("capacitance",&ptemp,ckt,type,fast)) - } else { /* looks like character strings */ - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - thismodel = (INPmodel *)NULL; - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = thismodel->INPmodfast; - } else { - type = mytype; - if(!tab->defCmod) { - IFnewUid(ckt,&uid,(IFuid)NULL,"C",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defCmod),uid)) - } - mdfast = tab->defCmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - } - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("capacitance",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2d.c b/src/circuit/inp2d.c deleted file mode 100644 index ace8c2343..000000000 --- a/src/circuit/inp2d.c +++ /dev/null @@ -1,77 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2D(void *ckt, INPtables *tab, card *current) -{ - -/* Dname [] [OFF] [IC=] */ - -int mytype; /* the type we looked up */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* the name of the model */ -INPmodel *thismodel; /* pointer to model description for user's model */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid of default model */ - - mytype = INPtypelook("Diode"); - if(mytype < 0 ) { - LITERR("Device type Diode not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if(!tab->defDmod) { - /* create default D model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"D",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defDmod),uid)) - } - mdfast = tab->defDmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("area",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2dot.c b/src/circuit/inp2dot.c deleted file mode 100644 index 722b172f8..000000000 --- a/src/circuit/inp2dot.c +++ /dev/null @@ -1,602 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -int -INP2dot(void *ckt, INPtables *tab, card *current, void *task, void *gnode) -{ - - /* . Many possibilities */ - -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *point; -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -IFvalue ptemp; /* a value structure to package resistance into */ -IFvalue *parm; /* a pointer to a value struct for function returns */ -IFparm *prm; /* pointer to parameter to search through array */ -char *token; /* a token from the line */ -int which; /* which analysis we are performing */ -int found; -int i; /* generic loop variable */ -void *foo; /* pointer to analysis */ -int length; /* length of a name */ -char *steptype; /* ac analysis, type of stepping function */ -double dtemp; /* random double precision temporary */ -char *word; /* something to stick a word of input into */ - - - line = current->line; - INPgetTok(&line,&token,1); - if (strcmp(token,".model")==0) { - /* don't have to do anything, since models were all done in - * pass 1 - */ - return(0); - } else if ((strcmp(token,".width") == 0) || - strcmp(token,".print") == 0 || - strcmp(token,".plot") == 0) { - /* obsolete - ignore */ - LITERR(" Warning: obsolete control card - ignored \n") - return(0); - } else if ( (strcmp(token,".temp")==0)){ - /* .temp temp1 temp2 temp3 temp4 ..... */ - /* not yet implemented - warn & ignore */ - LITERR(" Warning: .TEMP card obsolete - use .options TEMP and TNOM\n") - return(0); - } else if ( (strcmp(token,".op")==0)){ - /* .op */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"OP")==0) { - which=i; - break; - } - } - if(which == -1) { - LITERR("DC operating point analysis unsupported\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"Operating Point",&foo, task)) - return(0); - } else if ( (strcmp(token,".nodeset")==0)){ - /* .nodeset */ - which = -1; - for(prm=ft_sim->nodeParms; - prmnodeParms+ft_sim->numNodeParms;prm++) { - if(strcmp(prm->keyword,"nodeset")==0) { - which=prm->id; - break; - } - } - if(which == -1) { - LITERR("nodeset unknown to simulator. \n") - return(0); - } - for(;;) { /* loop until we run out of data */ - INPgetTok(&line,&name,1); - /* check to see if in the form V(xxx) and grab the xxx */ - if( *name == (char)NULL) break; /* end of line */ - length = strlen(name); - if( (*name == 'V' || *(name) == 'v') && (length == 1)){ - /* looks like V - must be V(xx) - get xx now*/ - INPgetTok(&line,&name,1); - INPtermInsert(ckt,&name,tab,&node1); - ptemp.rValue = INPevaluate(&line,&error,1); - IFC(setNodeParm,(ckt,node1,which,&ptemp,(IFvalue*)NULL)) - continue; - } - LITERR(" Error: .nodeset syntax error.\n") - break; - } - return(0); - } else if ( (strcmp(token,".disto")==0)){ - /* .disto {DEC OCT LIN} NP FSTART FSTOP */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"DISTO")==0) { - which=i; - break; - } - } - if(which == -1) { - LITERR("Small signal distortion analysis unsupported.\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"Distortion Analysis",&foo, task)) - INPgetTok(&line,&steptype,1); /* get DEC, OCT, or LIN */ - ptemp.iValue=1; - GCA(INPapName,(ckt,which,foo,steptype,&ptemp)) - parm=INPgetValue(ckt,&line,IF_INTEGER,tab);/* number of points*/ - GCA(INPapName,(ckt,which,foo,"numsteps",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstart */ - GCA(INPapName,(ckt,which,foo,"start",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstop */ - GCA(INPapName,(ckt,which,foo,"stop",parm)) - if(*line) { - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* f1phase */ - GCA(INPapName,(ckt,which,foo,"f2overf1",parm)) - } - return(0); - } else if ( (strcmp(token,".noise")==0)){ - /* .noise V(OUTPUT,REF) SRC {DEC OCT LIN} NP FSTART FSTOP */ - which = -1; - for (i=0; inumAnalyses; i++) { - if (strcmp(ft_sim->analyses[i]->name, "NOISE") == 0) { - which = i; - break; - } - } - if (which == -1) { - LITERR("Noise analysis unsupported.\n"); - return(0); - } - IFC(newAnalysis, (ckt,which,"Noise Analysis",&foo,task)) - INPgetTok(&line,&name,1); - - /* Make sure the ".noise" command is followed by */ - /* V(xxxx). If it is, extract 'xxxx'. If not, report an error. */ - - if (name != NULL) { - length = strlen(name); - if (((*name == 'V') || (*name == 'v')) && (length == 1)) { - - INPgetTok(&line,&nname1,0); - INPtermInsert(ckt,&nname1,tab,&node1); - ptemp.nValue=(IFnode)node1; - GCA(INPapName,(ckt,which,foo,"output",&ptemp)) - - if (*line != /* match ( */ ')') { - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - ptemp.nValue=(IFnode)node2; - } else { - ptemp.nValue=(IFnode)gnode; - } - GCA(INPapName,(ckt,which,foo,"outputref",&ptemp)) - - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - ptemp.uValue=name; - GCA(INPapName,(ckt,which,foo,"input",&ptemp)) - - INPgetTok(&line,&steptype,1); - ptemp.iValue = 1; - error=INPapName(ckt,which,foo,steptype,&ptemp); - if (error) - current->error = INPerrCat(current->error,INPerror(error)); - parm = INPgetValue(ckt,&line,IF_INTEGER,tab); - error = INPapName(ckt,which,foo,"numsteps",parm); - if (error) - current->error = INPerrCat(current->error,INPerror(error)); - parm = INPgetValue(ckt,&line,IF_REAL,tab); - error = INPapName(ckt,which,foo,"start",parm); - if (error) - current->error = INPerrCat(current->error,INPerror(error)); - parm = INPgetValue(ckt,&line,IF_REAL,tab); - error = INPapName(ckt,which,foo,"stop",parm); - if (error) - current->error = INPerrCat(current->error,INPerror(error)); - - /* now see if "ptspersum" has been specified by the user */ - - for (found=0, point=line; (!found) && (*point != '\0'); - found = ((*point != ' ') && (*(point++) != '\t'))); - if (found) { - parm = INPgetValue(ckt,&line,IF_INTEGER,tab); - error = INPapName(ckt,which,foo,"ptspersum",parm); - if (error) - current->error = - INPerrCat(current->error,INPerror(error)); - } else { - ptemp.iValue = 0; - error = INPapName(ckt,which,foo,"ptspersum",&ptemp); - if (error) current->error = - INPerrCat(current->error,INPerror(error)); - } - } else - LITERR( -"bad syntax [.noise v(OUT) SRC {DEC OCT LIN} NP FSTART FSTOP ]\n"); - } - else { - LITERR( -"bad syntax [.noise v(OUT) SRC {DEC OCT LIN} NP FSTART FSTOP ]\n"); - } - return(0); - } else if ( (strcmp(token,".four")==0) || (strcmp(token,".fourier")==0) ){ - /* .four */ - /* not implemented - warn & ignore */ - LITERR("Use fourier command to obtain fourier analysis\n") - return(0); - } else if ( (strcmp(token,".ic")==0)){ - /* .ic */ - which = -1; - for(prm=ft_sim->nodeParms; - prmnodeParms+ft_sim->numNodeParms;prm++) { - if(strcmp(prm->keyword,"ic")==0) { - which=prm->id; - break; - } - } - if(which==-1) { - LITERR("ic unknown to simulator. \n") - return(0); - } - for(;;) { /* loop until we run out of data */ - INPgetTok(&line,&name,1); - /* check to see if in the form V(xxx) and grab the xxx */ - if( *name == 0) break; /* end of line */ - length = strlen(name); - if( (*name == 'V' || *(name) == 'v') && (length == 1)){ - /* looks like V - must be V(xx) - get xx now*/ - INPgetTok(&line,&name,1); - INPtermInsert(ckt,&name,tab,&node1); - ptemp.rValue = INPevaluate(&line,&error,1); - IFC(setNodeParm,(ckt,node1,which,&ptemp,(IFvalue*)NULL)) - continue; - } - LITERR(" Error: .ic syntax error.\n") - break; - } - return(0); - } else if ( (strcmp(token,".ac")==0)){ - /* .ac {DEC OCT LIN} NP FSTART FSTOP */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"AC")==0) { - which=i; - break; - } - } - if(which == -1) { - LITERR("AC small signal analysis unsupported.\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"AC Analysis",&foo, task)) - INPgetTok(&line,&steptype,1); /* get DEC, OCT, or LIN */ - ptemp.iValue=1; - GCA(INPapName,(ckt,which,foo,steptype,&ptemp)) - parm=INPgetValue(ckt,&line,IF_INTEGER,tab);/* number of points*/ - GCA(INPapName,(ckt,which,foo,"numsteps",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstart */ - GCA(INPapName,(ckt,which,foo,"start",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstop */ - GCA(INPapName,(ckt,which,foo,"stop",parm)) - return(0); - } else if ( (strcmp(token,".pz")==0)){ - /* .pz nodeI nodeG nodeJ nodeK {V I} {POL ZER PZ} */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"PZ")==0) { - which=i; - break; - } - } - if(which == -1) { - LITERR("Pole-zero analysis unsupported.\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"Pole-Zero Analysis",&foo, task)) - parm = INPgetValue(ckt,&line,IF_NODE,tab); - GCA(INPapName,(ckt,which,foo,"nodei",parm)) - parm = INPgetValue(ckt,&line,IF_NODE,tab); - GCA(INPapName,(ckt,which,foo,"nodeg",parm)) - parm = INPgetValue(ckt,&line,IF_NODE,tab); - GCA(INPapName,(ckt,which,foo,"nodej",parm)) - parm = INPgetValue(ckt,&line,IF_NODE,tab); - GCA(INPapName,(ckt,which,foo,"nodek",parm)) - INPgetTok(&line,&steptype,1); /* get V or I */ - ptemp.iValue=1; - GCA(INPapName,(ckt,which,foo,steptype,&ptemp)) - INPgetTok(&line,&steptype,1); /* get POL, ZER, or PZ */ - ptemp.iValue=1; - GCA(INPapName,(ckt,which,foo,steptype,&ptemp)) - return(0); - } else if ( (strcmp(token,".dc")==0)){ - /* .dc SRC1NAME Vstart1 Vstop1 Vinc1 [SRC2NAME Vstart2 */ - /* Vstop2 Vinc2 */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"DC")==0) { - which=i; - break; - } - } - if(which==-1) { - LITERR("DC transfer curve analysis unsupported\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"DC transfer characteristic",&foo, task)) - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - ptemp.uValue=name; - GCA(INPapName,(ckt,which,foo,"name1",&ptemp)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* vstart1 */ - GCA(INPapName,(ckt,which,foo,"start1",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* vstop1 */ - GCA(INPapName,(ckt,which,foo,"stop1",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* vinc1 */ - GCA(INPapName,(ckt,which,foo,"step1",parm)) - if(*line) { - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - ptemp.uValue=name; - GCA(INPapName,(ckt,which,foo,"name2",&ptemp)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* vstart1 */ - GCA(INPapName,(ckt,which,foo,"start2",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* vstop1 */ - GCA(INPapName,(ckt,which,foo,"stop2",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* vinc1 */ - GCA(INPapName,(ckt,which,foo,"step2",parm)) - } - return(0); - } else if ( (strcmp(token,".tf")==0)){ - /* .tf v( node1, node2 ) src */ - /* .tf vsrc2 src */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"TF")==0) { - which=i; - break; - } - } - if(which==-1) { - LITERR("Transfer Function analysis unsupported.\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"Transfer Function",&foo,task)) - INPgetTok(&line,&name,0); - /* name is now either V or I or a serious error */ - if(*name == 'v' && strlen(name)==1) { - if(*line != '(' /* match) */ ) { - /* error, bad input format */ - } - INPgetTok(&line,&nname1,0); - INPtermInsert(ckt,&nname1,tab,&node1); - ptemp.nValue=(IFnode)node1; - GCA(INPapName,(ckt,which,foo,"outpos",&ptemp)) - if(*line != /* match ( */ ')') { - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - ptemp.nValue=(IFnode)node2; - GCA(INPapName,(ckt,which,foo,"outneg",&ptemp)) - ptemp.sValue = (char *) - MALLOC(sizeof(char)*(5+strlen(nname1)+strlen(nname2))); - (void)sprintf(ptemp.sValue,"V(%s,%s)",nname1,nname2); - GCA(INPapName,(ckt,which,foo,"outname",&ptemp)) - } else { - ptemp.nValue=(IFnode)gnode; - GCA(INPapName,(ckt,which,foo,"outneg",&ptemp)) - ptemp.sValue = (char *)MALLOC(sizeof(char)*(4+strlen(nname1))); - (void)sprintf(ptemp.sValue,"V(%s)",nname1); - GCA(INPapName,(ckt,which,foo,"outname",&ptemp)) - } - } else if(*name == 'i' && strlen(name)==1) { - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - ptemp.uValue=name; - GCA(INPapName,(ckt,which,foo,"outsrc",&ptemp)) - } else { - LITERR("Syntax error: voltage or current expected.\n") - return 0; - } - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - ptemp.uValue=name; - GCA(INPapName,(ckt,which,foo,"insrc",&ptemp)) - return(0); - } else if ( (strcmp(token,".tran")==0)){ - /* .tran Tstep Tstop > */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"TRAN")==0) { - which=i; - break; - } - } - if(which == -1) { - LITERR("Transient analysis unsupported.\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"Transient Analysis",&foo, task)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* Tstep */ - GCA(INPapName,(ckt,which,foo,"tstep",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* Tstop */ - GCA(INPapName,(ckt,which,foo,"tstop",parm)) - if(*line) { - dtemp = INPevaluate(&line,&error,1); /* tstart? */ - if(error==0) { - ptemp.rValue=dtemp; - GCA(INPapName,(ckt,which,foo,"tstart",&ptemp)) - dtemp = INPevaluate(&line,&error,1); /* tmax? */ - if(error==0) { - ptemp.rValue=dtemp; - GCA(INPapName,(ckt,which,foo,"tmax",&ptemp)) - } - } - } - if(*line) { - INPgetTok(&line,&word,1); /* uic? */ - if(strcmp(word,"uic")==0) { - ptemp.iValue=1; - GCA(INPapName,(ckt,which,foo,"uic",&ptemp)) - } else { - LITERR(" Error: unknown parameter on .tran - ignored\n") - } - } - return(0); - } else if ( (strcmp(token,".subckt")==0) || - (strcmp(token,".ends")==0) ){ - /* not yet implemented - warn & ignore */ - LITERR(" Warning: Subcircuits not yet implemented - ignored \n") - return(0); - } else if ( (strcmp(token,".end")==0)){ - /* .end - end of input */ - /* not allowed to pay attention to additional input - return */ - return(1); - /*NOTREACHED*/ - } else if ( (strcmp(token,".options")==0) || - (strcmp(token,".option")==0) || - (strcmp(token,".opt")==0) ){ - /* .option - specify program options - rather complicated */ - /* use a subroutine to handle all of them to keep this */ - /* subroutine managable */ - INPdoOpts(ckt,ft_curckt->ci_curOpt,current,tab); - return(0); - } else if (strcmp(token, ".sens") == 0) { - which = -1; /* Bug fix from Glao Dezai */ - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"SENS")==0) { - which=i; - break; - } - } - if(which==-1) { - LITERR("Sensitivity unsupported.\n") - return(0); - } - - IFC(newAnalysis,(ckt,which,"Sensitivity Analysis",&foo, task)) - - /* Format is: - * .sens - * + [ac [dec|lin|oct] | dc ] - */ - - /* Get the output voltage or current */ - INPgetTok(&line,&name,0); - /* name is now either V or I or a serious error */ - if (*name == 'v' && strlen(name) == 1) { - if (*line != '(' /* match) */) { - LITERR("Syntax error: '(' expected after 'v'\n"); - return 0; - } - INPgetTok(&line, &nname1, 0); - INPtermInsert(ckt, &nname1, tab, &node1); - ptemp.nValue=(IFnode)node1; - GCA(INPapName,(ckt,which,foo,"outpos",&ptemp)) - - if(*line != /* match ( */ ')') { - INPgetTok(&line, &nname2, 1); - INPtermInsert(ckt, &nname2, tab, &node2); - ptemp.nValue = (IFnode)node2; - GCA(INPapName,(ckt,which,foo,"outneg",&ptemp)) - ptemp.sValue = (char *) - MALLOC(sizeof(char)*(5+strlen(nname1)+strlen(nname2))); - (void)sprintf(ptemp.sValue,"V(%s,%s)",nname1,nname2); - GCA(INPapName,(ckt,which,foo,"outname",&ptemp)) - } else { - ptemp.nValue=(IFnode)gnode; - GCA(INPapName,(ckt,which,foo,"outneg",&ptemp)) - ptemp.sValue = (char *)MALLOC(sizeof(char)*(4+strlen(nname1))); - (void)sprintf(ptemp.sValue,"V(%s)",nname1); - GCA(INPapName,(ckt,which,foo,"outname",&ptemp)) - } - } else if (*name == 'i' && strlen(name) == 1) { - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - ptemp.uValue=name; - GCA(INPapName,(ckt,which,foo,"outsrc",&ptemp)) - } else { - LITERR("Syntax error: voltage or current expected.\n") - return 0; - } - - INPgetTok(&line,&name,1); - if (name && !strcmp(name, "pct")) { - ptemp.iValue = 1; - GCA(INPapName,(ckt,which,foo,"pct",&ptemp)) - INPgetTok(&line,&name,1); - } - if (name && !strcmp(name, "ac")) { - INPgetTok(&line,&steptype,1); /* get DEC, OCT, or LIN */ - ptemp.iValue=1; - GCA(INPapName,(ckt,which,foo,steptype,&ptemp)) - parm=INPgetValue(ckt,&line,IF_INTEGER,tab);/* number of points*/ - GCA(INPapName,(ckt,which,foo,"numsteps",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstart */ - GCA(INPapName,(ckt,which,foo,"start",parm)) - parm = INPgetValue(ckt,&line,IF_REAL,tab); /* fstop */ - GCA(INPapName,(ckt,which,foo,"stop",parm)) - return(0); - } else if (name && *name && strcmp(name, "dc")) { - /* Bad flag */ - LITERR("Syntax error: 'ac' or 'dc' expected.\n") - return 0; - } - return(0); - } -#ifdef WANT_SENSE2 - else if ( (strcmp(token,".sens2")==0)) { - /* .sens {AC} {DC} {TRAN} [dev=nnn parm=nnn]* */ - which = -1; - for(i=0;inumAnalyses;i++) { - if(strcmp(ft_sim->analyses[i]->name,"SENS2")==0) { - which=i; - break; - } - } - if(which == -1) { - LITERR("Sensitivity-2 analysis unsupported\n") - return(0); - } - IFC(newAnalysis,(ckt,which,"Sensitivity-2 Analysis",&foo, task)) - while(*line) { /* read the entire line */ - INPgetTok(&line,&token,1); - for(i=0;ianalyses[which]->numParms;i++) { - /* find the parameter */ - if(0==strcmp(token , - ft_sim->analyses[which]->analysisParms[i]. - keyword) ){ - /* found it, analysis which, parameter i */ - if(ft_sim->analyses[which]->analysisParms[i]. - dataType & IF_FLAG) { - /* one of the keywords! */ - ptemp.iValue = 1; - error = (*(ft_sim->setAnalysisParm))(ckt, - foo, ft_sim->analyses[which]-> - analysisParms[i].id,&ptemp,(IFvalue*)NULL); - if(error) current->error = INPerrCat( - current->error, INPerror(error)); - } else { - parm = INPgetValue(ckt,&line,ft_sim-> - analyses[which]->analysisParms[i]. - dataType,tab); - error = (*(ft_sim->setAnalysisParm))(ckt, - foo, ft_sim->analyses[which]-> - analysisParms[i].id,parm,(IFvalue*)NULL); - if(error) current->error = INPerrCat( - current->error, INPerror(error)); - - } - break; - } - } - if(i==ft_sim->analyses[which]->numParms) { - /* didn't find it! */ - LITERR(" Error: unknown parameter on .sens-ignored \n") - } - } - return(0); - } -#endif - else if ( (strcmp(token,".probe")==0)) { - /* Maybe generate a "probe" format file in the future. */ - return 0; - } - LITERR(" unimplemented control card - error \n") - return(0); -} diff --git a/src/circuit/inp2e.c b/src/circuit/inp2e.c deleted file mode 100644 index 0346060f6..000000000 --- a/src/circuit/inp2e.c +++ /dev/null @@ -1,69 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2E(void *ckt, INPtables *tab, card *current) -{ - -/* Ename */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - type = INPtypelook("VCVS"); - if(type < 0 ) { - LITERR("Device type VCVS not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&nname4,1); - INPtermInsert(ckt,&nname4,tab,&node4); - if(!tab->defEmod) { - /* create default E model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"E",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defEmod),uid)) - } - IFC(newInstance,(ckt,tab->defEmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("gain",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2f.c b/src/circuit/inp2f.c deleted file mode 100644 index ff398b236..000000000 --- a/src/circuit/inp2f.c +++ /dev/null @@ -1,62 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2F(void *ckt, INPtables *tab, card *current) -{ - -/* Fname */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -IFvalue *parm; /* a pointer to a value structure to pick things up into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - type = INPtypelook("CCCS"); - if(type < 0 ) { - LITERR("Device type CCCS not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - if(!tab->defFmod) { - /* create default F model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"F",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defFmod),uid)) - } - IFC(newInstance,(ckt,tab->defFmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - parm=INPgetValue(ckt,&line,IF_INSTANCE,tab); - GCA(INPpName,("control",parm,ckt,type,fast)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("gain",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2g.c b/src/circuit/inp2g.c deleted file mode 100644 index 6943c1c62..000000000 --- a/src/circuit/inp2g.c +++ /dev/null @@ -1,69 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2G(void *ckt, INPtables *tab, card *current) -{ - -/* Gname */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid of default model to be created */ - - type = INPtypelook("VCCS"); - if(type < 0 ) { - LITERR("Device type VCCS not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&nname4,1); - INPtermInsert(ckt,&nname4,tab,&node4); - if(!tab->defGmod) { - /* create default G model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"G",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defGmod),uid)) - } - IFC(newInstance,(ckt,tab->defGmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("gain",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2h.c b/src/circuit/inp2h.c deleted file mode 100644 index 658907107..000000000 --- a/src/circuit/inp2h.c +++ /dev/null @@ -1,62 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2H(void *ckt, INPtables *tab, card *current) -{ - -/* Hname */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -IFvalue *parm; /* pointer to a value structure for functions which return one*/ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model to be created */ - - type = INPtypelook("CCVS"); - if(type < 0 ) { - LITERR("Device type CCVS not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - if(!tab->defHmod) { - /* create default H model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"H",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defHmod),uid)) - } - IFC(newInstance,(ckt,tab->defHmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - parm=INPgetValue(ckt,&line,IF_INSTANCE,tab); - GCA(INPpName,("control",parm,ckt,type,fast)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("gain",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2i.c b/src/circuit/inp2i.c deleted file mode 100644 index fc426d029..000000000 --- a/src/circuit/inp2i.c +++ /dev/null @@ -1,60 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2I(void *ckt, INPtables *tab, card *current) -{ - - /* Iname [ [DC] ] [AC [ [ ] ] ] - * [] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - type = INPtypelook("Isource"); - if(type < 0 ) { - LITERR("Device type Isource not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - if(!tab->defImod) { - /* create default I model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"I",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defImod),uid)) - } - IFC(newInstance,(ckt,tab->defImod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("dc",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2j.c b/src/circuit/inp2j.c deleted file mode 100644 index 089b82ffd..000000000 --- a/src/circuit/inp2j.c +++ /dev/null @@ -1,84 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2J(void *ckt, INPtables *tab, card *current) -{ - - /* Jname [] [OFF] [IC=,] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* the name of the model */ -INPmodel *thismodel; /* pointer to model description for user's model */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid of default model */ - - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - thismodel = (INPmodel *)NULL; - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if (thismodel->INPmodType != INPtypelook("JFET") - && thismodel->INPmodType != INPtypelook("JFET2") - ) - { - LITERR("incorrect model type") - return; - } - type = thismodel->INPmodType; - mdfast = (thismodel->INPmodfast); - } else { - type = INPtypelook("JFET"); - if(type < 0 ) { - LITERR("Device type JFET not supported by this binary\n") - return; - } - if(!tab->defJmod) { - /* create default J model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"J",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defJmod),uid)) - } - mdfast = tab->defJmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("area",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2k.c b/src/circuit/inp2k.c deleted file mode 100644 index 7614955f3..000000000 --- a/src/circuit/inp2k.c +++ /dev/null @@ -1,56 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2K(void *ckt, INPtables *tab, card *current) -{ - -/* Kname Lname Lname */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -IFvalue *parm; /* ptr to a value structure for function return values */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - line = current->line; - type = INPtypelook("mutual"); - if(type < 0 ) { - LITERR("Device type mutual not supported by this binary\n") - return; - } - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - if(!tab->defKmod) { - /* create deafult K model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"K",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defKmod),uid)) - } - IFC(newInstance,(ckt,tab->defKmod,&fast,name)) - - parm = INPgetValue(ckt,&line,IF_INSTANCE,tab); - GCA(INPpName,("inductor1",parm,ckt,type,fast)) - parm = INPgetValue(ckt,&line,IF_INSTANCE,tab); - GCA(INPpName,("inductor2",parm,ckt,type,fast)) - - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("coefficient",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2l.c b/src/circuit/inp2l.c deleted file mode 100644 index d2282dba5..000000000 --- a/src/circuit/inp2l.c +++ /dev/null @@ -1,59 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2L(void *ckt, INPtables *tab, card *current) -{ -/* parse an inductor card */ -/* Lname [IC=] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - type = INPtypelook("Inductor"); - if(type < 0 ) { - LITERR("Device type Inductor not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - if(!tab->defLmod) { - /* create default L model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"L",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defLmod),uid)) - } - IFC(newInstance,(ckt,tab->defLmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("inductance",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2m.c b/src/circuit/inp2m.c deleted file mode 100644 index d0b203f74..000000000 --- a/src/circuit/inp2m.c +++ /dev/null @@ -1,101 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2M(void *ckt, INPtables *tab, card *current) -{ - - /* Mname [L=] - * [W=] [AD=] [AS=] [PD=] - * [PS=] [NRD=] [NRS=] [OFF] - * [IC=,,] - */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* the name of the model */ -INPmodel *thismodel; /* pointer to model description for user's model */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid for default model */ - - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&nname4,1); - INPtermInsert(ckt,&nname4,tab,&node4); - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - thismodel = (INPmodel *)NULL; - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if (thismodel->INPmodType != INPtypelook("Mos1") - && thismodel->INPmodType != INPtypelook("Mos2") - && thismodel->INPmodType != INPtypelook("Mos3") - && thismodel->INPmodType != INPtypelook("Mos5") - && thismodel->INPmodType != INPtypelook("Mos6") - && thismodel->INPmodType != INPtypelook("Mos8") - && thismodel->INPmodType != INPtypelook("BSIM1") - && thismodel->INPmodType != INPtypelook("BSIM2") - && thismodel->INPmodType != INPtypelook("BSIM3") - && thismodel->INPmodType != INPtypelook("BSIM4") - && thismodel->INPmodType != INPtypelook("BSIM3V1") - && thismodel->INPmodType != INPtypelook("BSIM3V2") - ) - { - LITERR("incorrect model type") - return; - } - type = thismodel->INPmodType; - mdfast = (thismodel->INPmodfast); - } else { - type = INPtypelook("Mos1"); - if(type < 0 ) { - LITERR("Device type MOS1 not supported by this binary\n") - return; - } - if(!tab->defMmod) { - /* create default M model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"M",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defMmod),uid)) - } - mdfast = tab->defMmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - LITERR(" error: no unlabeled parameter permitted on mosfet\n") - } -} diff --git a/src/circuit/inp2o.c b/src/circuit/inp2o.c deleted file mode 100644 index cb6bc1210..000000000 --- a/src/circuit/inp2o.c +++ /dev/null @@ -1,91 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1990 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - - -void -INP2O(void *ckt, INPtables *tab, card *current) -{ - - /* Oname [IC=,,,] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* the name of the model */ -INPmodel *thismodel; /* pointer to model description for user's model */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid for default model */ - - - type = INPtypelook("LTRA"); - if(type < 0 ) { - LITERR("Device type LossyXmissionLine not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&nname4,1); - INPtermInsert(ckt,&nname4,tab,&node4); - INPgetTok(&line,&model,1); - if( INPlookMod(model) ) { - /* do nothing for now */ - /* no action required */ - } else { - /* - nname4 = model; - INPtermInsert(ckt,&nname4,tab,&node4); - INPgetTok(&line,&model,1); - */ - } - INPinsert(&model,tab); - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(type != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - mdfast = (thismodel->INPmodfast); - } else { - if(!tab->defOmod) { - /* create default O model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"O",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defOmod),uid)) - } - mdfast = tab->defOmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) -} diff --git a/src/circuit/inp2q.c b/src/circuit/inp2q.c deleted file mode 100644 index 1992854e1..000000000 --- a/src/circuit/inp2q.c +++ /dev/null @@ -1,95 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2Q(void *ckt, INPtables *tab, card *current, void *gnode) -{ - - /* Qname [] [] [OFF] - * [IC=,] */ - -int mytype; /* the type we looked up */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* the name of the model */ -INPmodel *thismodel; /* pointer to model description for user's model */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid of default model */ - - mytype = INPtypelook("BJT"); - if(mytype < 0 ) { - LITERR("Device type BJT not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&model,1); - if( INPlookMod(model) ) { - /* do nothing for now */ - node4 = gnode; - /* no action required */ - } else { - nname4 = model; - INPtermInsert(ckt,&nname4,tab,&node4); - INPgetTok(&line,&model,1); - } - INPinsert(&model,tab); - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if(!tab->defQmod) { - /* create default Q model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"Q",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defQmod),uid)) - } - mdfast = tab->defQmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("area",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2r.c b/src/circuit/inp2r.c deleted file mode 100644 index 29b683436..000000000 --- a/src/circuit/inp2r.c +++ /dev/null @@ -1,116 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2R(void *ckt, INPtables *tab, card *current) -{ -/* parse a resistor card */ -/* serban */ -/* Rname [][][w=][l=][ac=] */ - -int mytype; /* the type we determine resistors are */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *model; /* the name of the resistor's model */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -double val; /* temp to held resistance */ -double acval; /* temp to held resistance */ -int error; /* error code temporary */ -int error1; /* secondary error code temporary */ -int error2; /* third error code temporary */ -INPmodel *thismodel; /* pointer to model structure describing our model */ -void *mdfast; /* pointer to the actual model */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - mytype = INPtypelook("Resistor"); - if(mytype < 0 ) { - LITERR("Device type Resistor not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - val = INPevaluate(&line,&error1,1); - acval = val; /* PN: This is a safe choice */ - /* either not a number -> model, or - * follows a number, so must be a model name - * -> MUST be a model name (or null) - */ -again: - INPgetTok(&line,&model,1); - if(*model) { /* token isn't null */ - if(!strcmp(model, "ac")) { - acval = INPevaluate(&line,&error2,1); - goto again; - } else { - INPinsert(&model,tab); - thismodel = (INPmodel *)NULL; - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - mdfast = thismodel->INPmodfast; - type = thismodel->INPmodType; - } else { - type = mytype; - if(!tab->defRmod) { - /* create default R model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"R",UID_MODEL,(void **)NULL); - IFC(newModel, (ckt,type,&(tab->defRmod),uid)) - } - mdfast = tab->defRmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - } - } else { - type = mytype; - if(!tab->defRmod) { - /* create default R model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"R",UID_MODEL,(void **)NULL); - IFC(newModel, (ckt,type,&(tab->defRmod),uid)) - } - IFC(newInstance,(ckt,tab->defRmod,&fast,name)) - } - if(error1 == 0) { /* got a resistance above */ - ptemp.rValue = val; - GCA(INPpName,("resistance",&ptemp,ckt,type,fast)) - } - if(error2 == 0) { /* got an AC resistance above */ - ptemp.rValue = acval; - GCA(INPpName,("ac",&ptemp,ckt,type,fast)) - } - - - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("resistance",&ptemp,ckt,type,fast)) - } - return; -} diff --git a/src/circuit/inp2s.c b/src/circuit/inp2s.c deleted file mode 100644 index 406df4329..000000000 --- a/src/circuit/inp2s.c +++ /dev/null @@ -1,86 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2S(void *ckt, INPtables *tab, card *current) -{ - - /* Sname [] [IC] */ - /* VOLTAGE CONTROLLED SWITCH */ - -int mytype; /* the type we determine resistors are */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *model; /* the name of the resistor's model */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -INPmodel *thismodel; /* pointer to model structure describing our model */ -void *mdfast; /* pointer to the actual model */ -void *fast; /* pointer to the actual instance */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid of default model */ - - mytype = INPtypelook("Switch"); - if(mytype < 0 ) { - LITERR("Device type Switch not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&nname4,1); - INPtermInsert(ckt,&nname4,tab,&node4); - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if(!tab->defSmod) { - /* create deafult S model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"S",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defSmod),uid)) - } - mdfast = tab->defSmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - /* ignore a number */ - } -} diff --git a/src/circuit/inp2t.c b/src/circuit/inp2t.c deleted file mode 100644 index 05b619ffd..000000000 --- a/src/circuit/inp2t.c +++ /dev/null @@ -1,66 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2T(void *ckt, INPtables *tab, card *current) -{ - - /* Tname [TD=] - * [F= [NL=]][IC=,,,] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -char *nname4; /* the fourth node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -void *node4; /* the fourth node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - - type = INPtypelook("Tranline"); - if(type < 0 ) { - LITERR("Device type Tranline not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&nname4,1); - INPtermInsert(ckt,&nname4,tab,&node4); - if(!tab->defTmod) { - /* create deafult T model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"T",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defTmod),uid)) - } - IFC(newInstance,(ckt,tab->defTmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - IFC(bindNode,(ckt,fast,4,node4)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) -} diff --git a/src/circuit/inp2u.c b/src/circuit/inp2u.c deleted file mode 100644 index 18b1afc72..000000000 --- a/src/circuit/inp2u.c +++ /dev/null @@ -1,77 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2U(void *ckt, INPtables *tab, card *current) -{ - - /* Uname [l=] [n=] */ - -int mytype; /* the type my lookup says URC is */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* name of the model */ -INPmodel *thismodel; /* pointer to our model descriptor */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid for default model */ - - mytype = INPtypelook("URC"); - if(mytype < 0 ) { - LITERR("Device type URC not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if(!tab->defUmod) { - /* create deafult U model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"U",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defUmod),uid)) - } - mdfast = tab->defUmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) -} diff --git a/src/circuit/inp2v.c b/src/circuit/inp2v.c deleted file mode 100644 index 7a0a42cb7..000000000 --- a/src/circuit/inp2v.c +++ /dev/null @@ -1,60 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2V(void *ckt, INPtables *tab, card *current) -{ - - /* Vname [ [DC] ] [AC [ [ ] ] ] - * [] */ - -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - type = INPtypelook("Vsource"); - if(type < 0 ) { - LITERR("Device type Vsource not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - if(!tab->defVmod) { - /* create default V model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"V",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defVmod),uid)) - } - IFC(newInstance,(ckt,tab->defVmod,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("dc",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inp2w.c b/src/circuit/inp2w.c deleted file mode 100644 index 01bdb62e1..000000000 --- a/src/circuit/inp2w.c +++ /dev/null @@ -1,83 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2W(void *ckt, INPtables *tab, card *current) -{ - - /* Wname [] [IC] */ - /* CURRENT CONTROLLED SWITCH */ - -int mytype; /* the type we determine resistors are */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *model; /* the name of the resistor's model */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -int error; /* error code temporary */ -INPmodel *thismodel; /* pointer to model structure describing our model */ -void *mdfast; /* pointer to the actual model */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -IFvalue *parm; /* pointer to a value structure for functions to return */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -IFuid uid; /* uid for default model */ - - mytype = INPtypelook("CSwitch"); - if(mytype < 0 ) { - LITERR("Device type CSwitch not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - parm=INPgetValue(ckt,&line,IF_INSTANCE,tab); - ptemp.uValue = parm->uValue; - - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if(!tab->defWmod) { - /* create deafult W model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"W",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defWmod),uid)) - } - mdfast = tab->defWmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - - GCA(INPpName,("control",&ptemp,ckt,type,fast)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - /* ignore a number */ - } -} diff --git a/src/circuit/inp2z.c b/src/circuit/inp2z.c deleted file mode 100644 index 0db46a852..000000000 --- a/src/circuit/inp2z.c +++ /dev/null @@ -1,83 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpmacs.h" -#include "fteext.h" -#include "inp.h" - -void -INP2Z(void *ckt, INPtables *tab, card *current) -{ - - /* Zname [] [OFF] [IC=,] */ - -int mytype; /* the type we looked up */ -int type; /* the type the model says it is */ -char *line; /* the part of the current line left to parse */ -char *name; /* the resistor's name */ -char *nname1; /* the first node's name */ -char *nname2; /* the second node's name */ -char *nname3; /* the third node's name */ -void *node1; /* the first node's node pointer */ -void *node2; /* the second node's node pointer */ -void *node3; /* the third node's node pointer */ -int error; /* error code temporary */ -void *fast; /* pointer to the actual instance */ -IFvalue ptemp; /* a value structure to package resistance into */ -int waslead; /* flag to indicate that funny unlabeled number was found */ -double leadval; /* actual value of unlabeled number */ -char *model; /* the name of the model */ -INPmodel *thismodel; /* pointer to model description for user's model */ -void *mdfast; /* pointer to the actual model */ -IFuid uid; /* uid for default model */ - - mytype = INPtypelook("MES"); - if(mytype < 0 ) { - LITERR("Device type MES not supported by this binary\n") - return; - } - line = current->line; - INPgetTok(&line,&name,1); - INPinsert(&name,tab); - INPgetTok(&line,&nname1,1); - INPtermInsert(ckt,&nname1,tab,&node1); - INPgetTok(&line,&nname2,1); - INPtermInsert(ckt,&nname2,tab,&node2); - INPgetTok(&line,&nname3,1); - INPtermInsert(ckt,&nname3,tab,&node3); - INPgetTok(&line,&model,1); - INPinsert(&model,tab); - thismodel = (INPmodel *)NULL; - current->error = INPgetMod(ckt,model,&thismodel,tab); - if(thismodel != NULL) { - if(mytype != thismodel->INPmodType) { - LITERR("incorrect model type") - return; - } - type = mytype; - mdfast = (thismodel->INPmodfast); - } else { - type = mytype; - if(!tab->defZmod) { - /* create default Z model */ - IFnewUid(ckt,&uid,(IFuid)NULL,"Z",UID_MODEL,(void**)NULL); - IFC(newModel,(ckt,type,&(tab->defZmod),uid)) - } - mdfast = tab->defZmod; - } - IFC(newInstance,(ckt,mdfast,&fast,name)) - IFC(bindNode,(ckt,fast,1,node1)) - IFC(bindNode,(ckt,fast,2,node2)) - IFC(bindNode,(ckt,fast,3,node3)) - PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab)) - if(waslead) { - ptemp.rValue = leadval; - GCA(INPpName,("area",&ptemp,ckt,type,fast)) - } -} diff --git a/src/circuit/inpaname.c b/src/circuit/inpaname.c deleted file mode 100644 index a461a7cac..000000000 --- a/src/circuit/inpaname.c +++ /dev/null @@ -1,68 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - * INPaName() - * - * Take a parameter by Name and ask for the specified value - * *dev is -1 if type unknown, otherwise, device type - * **fast is a device, and will be set if possible. - */ - -#include "ngspice.h" -#include -#include "cpdefs.h" -#include "fteext.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "inp.h" - -int -INPaName(char *parm, IFvalue *val, void *ckt, int *dev, char *devnam, void **fast, IFsimulator *sim, int *dataType, IFvalue *selector) - /* the name of the parameter to set */ - /* the parameter union containing the value to set */ - /* the circuit this device is a member of */ - /* the device type code to the device being parsed */ - /* the name of the device */ - /* direct pointer to device being parsed */ - /* the simulator data structure */ - /* the datatype of the returned value structure */ - /* data sub-selector for questions */ - -{ - int error; /* int to store evaluate error return codes in */ - int i; - - /* find the instance - don't know about model, so use null there, - * otherwise pass on as much info as we have about the device - * (name, type, direct pointer) - the type and direct pointer - * WILL be set on return unless error is not OK - */ - error = (*(sim->findInstance))(ckt,dev,fast,devnam,(void *)NULL, - (char *)NULL); - if(error) return(error); - - /* now find the parameter - hunt through the parameter tables for - * this device type and look for a name match of an 'ask'able - * parameter. - */ - for(i=0;i<(*(*(sim->devices)[*dev]).numInstanceParms);i++) { - if(strcmp(parm, - ((*(sim->devices)[*dev]).instanceParms[i].keyword))==0 && - (((*(sim->devices)[*dev]).instanceParms[i].dataType)&IF_ASK)) { - /* found it, so we ask the question using the device info we got - * above and put the results in the IFvalue structure our caller - * gave us originally - */ - error = (*(sim->askInstanceQuest))(ckt,*fast, - (*(sim->devices)[*dev]).instanceParms[i].id,val, - selector); - if(dataType) *dataType = - (*(sim->devices)[*dev]).instanceParms[i].dataType; - return(error); - } - } - return(E_BADPARM); -} diff --git a/src/circuit/inpapnam.c b/src/circuit/inpapnam.c deleted file mode 100644 index 88a53cd87..000000000 --- a/src/circuit/inpapnam.c +++ /dev/null @@ -1,30 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "cpdefs.h" -#include "fteext.h" -#include "inp.h" - -int -INPapName(void *ckt, int type, void *analPtr, char *parmname, IFvalue *value) -{ - int i; - - if (parmname && ft_sim->analyses[type]) { - for(i=0;ianalyses[type]->numParms;i++) - if (strcmp(parmname, - ft_sim->analyses[type]->analysisParms[i].keyword) == 0) - { - return (*(ft_sim->setAnalysisParm))(ckt, analPtr, - ft_sim->analyses[type]->analysisParms[i].id, - value, (IFvalue*)NULL); - } - } - return(E_BADPARM); -} diff --git a/src/circuit/inpcfix.c b/src/circuit/inpcfix.c deleted file mode 100644 index a0969b1bd..000000000 --- a/src/circuit/inpcfix.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "fteext.h" -#include "inpdefs.h" -#include "inp.h" - - -void -INPcaseFix(register char *string) -{ - - while(*string) { - if(isupper(*string)) { - *string = tolower(*string); - } - string++; - } -} diff --git a/src/circuit/inpdomod.c b/src/circuit/inpdomod.c deleted file mode 100644 index f5bbc41e0..000000000 --- a/src/circuit/inpdomod.c +++ /dev/null @@ -1,227 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "iferrmsg.h" -#include "inpdefs.h" -#include "inp.h" - - -char * -INPdomodel(void *ckt, card *image, INPtables *tab) -{ - - char *modname; - int type=-1; - int lev; - char *typename; - char *err = (char *)NULL; - char *line; - - line = image->line; - INPgetTok(&line,&modname,1); /* throw away '.model' */ - INPgetTok(&line,&modname,1); - INPinsert(&modname,tab); - INPgetTok(&line,&typename,1); - if( (strcmp(typename,"npn") == 0)||(strcmp(typename,"pnp")==0) ) { - type = INPtypelook("BJT"); - if(type < 0) { - err = INPmkTemp("Device type BJT not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"d") == 0) { - type = INPtypelook("Diode"); - if(type < 0) { - err = INPmkTemp("Device type Diode not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if( (strcmp(typename,"njf") == 0) || (strcmp(typename,"pjf") == 0)){ - err = INPfindLev(line,&lev); - switch(lev) { - case 0: - case 1: - type = INPtypelook("JFET"); - if(type < 0) { - err = INPmkTemp( - "Device type JFET not available in this binary\n"); - } - break; - case 2: - type = INPtypelook("JFET2"); - if(type < 0) { - err = INPmkTemp( - "Device type JFET2 not available in this binary\n"); - } - break; - default: /* placeholder; use level 3 for the next model */ - err = INPmkTemp( - "Only JFET device levels 1-2 are supported in this binary\n"); - break; - } - INPmakeMod(modname,type,image); - } else if( (strcmp(typename,"nmf") == 0) || (strcmp(typename,"pmf")==0) ) { - type = INPtypelook("MES"); - if(type < 0) { - err = INPmkTemp("Device type MES not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"urc") == 0) { - type = INPtypelook("URC"); - if(type < 0) { - err = INPmkTemp("Device type URC not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if( (strcmp(typename,"nmos")==0) || (strcmp(typename,"pmos")==0) ) { - err = INPfindLev(line,&lev); - switch(lev) { - case 0: - case 1: - type = INPtypelook("Mos1"); - if(type < 0) { - err = INPmkTemp( - "Device type MOS1 not available in this binary\n"); - } - break; - case 2: - type = INPtypelook("Mos2"); - if(type < 0) { - err = INPmkTemp( - "Device type MOS2 not available in this binary\n"); - } - break; - case 3: - type = INPtypelook("Mos3"); - if(type < 0) { - err = INPmkTemp( - "Device type MOS3 not available in this binary\n"); - } - break; - case 4: - type = INPtypelook("BSIM1"); - if(type < 0) { - err = INPmkTemp( - "Device type BSIM1 not available in this binary\n"); - } - break; - case 5: - type = INPtypelook("BSIM2"); - if(type < 0) { - err = INPmkTemp( - "Device type BSIM2 not available in this binary\n"); - } - break; - case 6: - type = INPtypelook("Mos6"); - if(type < 0) { - err = INPmkTemp( - "Device type MOS6 not available in this binary\n"); - } - break; - case 7: - type = INPtypelook("MOS7"); - if(type < 0) { - err = INPmkTemp( - "Device type MOS7 not available in this binary\n"); - } - break; - case 8: - type = INPtypelook("BSIM3"); - if(type < 0) { - err = INPmkTemp( - "Device type BSIM3 not available in this binary\n"); - } - break; - case 9: - type = INPtypelook("BSIMsoi"); - if(type < 0) { - err = INPmkTemp( - "Device type BSIMsoi not available in this binary\n"); - } - break; - case 14: - type = INPtypelook("BSIM4"); - if(type < 0) { - err = INPmkTemp( - "Device type BSIM4 not available in this binary\n"); } - break; - case 15: - type = INPtypelook("BSIM5"); - if(type < 0) { - err = INPmkTemp( - "Placeholder: Device type BSIM5 not available in this binary\n"); - } - break; - case 16: - type = INPtypelook("BSIM6"); - if(type < 0) { - err = INPmkTemp( - "Placeholder: Device type BSIM6 not available in this binary\n"); - } - break; - case 49: - type = INPtypelook("BSIM3V1"); - if (type < 0) { - err = INPmkTemp( - "Device type BSIM3V1 not available in this binary\n"); - } - break; - - - case 50: - type = INPtypelook("BSIM3V2"); - if(type < 0) { - err = INPmkTemp( - "Device type BSIM3V2 not available in this binary\n"); - } - break; - default: /* placeholder; use level xxx for the next model */ - err = INPmkTemp( - "Only MOS device levels 1-6,8,14 are supported in this binary\n"); - break; - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"r") == 0) { - type = INPtypelook("Resistor"); - if(type < 0) { - err = INPmkTemp( - "Device type Resistor not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"c") == 0) { - type = INPtypelook("Capacitor"); - if(type < 0) { - err = INPmkTemp( - "Device type Capacitor not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"sw") == 0) { - type = INPtypelook("Switch"); - if(type < 0) { - err = INPmkTemp( - "Device type Switch not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"csw") == 0) { - type = INPtypelook("CSwitch"); - if(type < 0) { - err = INPmkTemp( - "Device type CSwitch not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else if(strcmp(typename,"ltra") == 0) { - type = INPtypelook("LTRA"); - if(type < 0) { - err = INPmkTemp( - "Device type LTRA not available in this binary\n"); - } - INPmakeMod(modname,type,image); - } else { - type = -1; - err = (char *)MALLOC(35 + strlen(typename)); - (void)sprintf(err,"unknown model type %s - ignored\n",typename); - } - return(err); -} diff --git a/src/circuit/inpdoopt.c b/src/circuit/inpdoopt.c deleted file mode 100644 index baa937ee4..000000000 --- a/src/circuit/inpdoopt.c +++ /dev/null @@ -1,82 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* INPdoOpts(ckt,option card) - * parse the options off of the given option card and add them to - * the given circuit - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "ifsim.h" -#include "cpdefs.h" -#include "fteext.h" -#include "inp.h" - -void -INPdoOpts(void *ckt, void *anal, card *optCard, INPtables *tab) -{ - char *line; - char *token; - char *errmsg; - IFvalue *val; - int error; - int i; - int which; - IFanalysis *prm=NULL; - - which = -1; - i=0; - for(i=0;inumAnalyses;i++) { - prm = ft_sim->analyses[i]; - if(strcmp(prm->name,"options")==0) { - which = i; - break; - } - i++; - } - if(which == -1) { - optCard->error = INPerrCat(optCard->error,INPmkTemp( - "errr: analysis options table not found\n")); - return; - } - line = optCard->line; - INPgetTok(&line,&token,1); /* throw away '.option' */ - while (*line) { - INPgetTok(&line,&token,1); - for(i=0;inumParms;i++) { - if(strcmp(token,prm->analysisParms[i].keyword) == 0) { - if(!(prm->analysisParms[i].dataType & IF_UNIMP_MASK)) { - errmsg = (char *)MALLOC((45+strlen(token)) * sizeof(char)); - (void) sprintf(errmsg, - " Warning: %s not yet implemented - ignored \n",token); - optCard->error = INPerrCat(optCard->error,errmsg); - val = INPgetValue(ckt,&line, - prm->analysisParms[i].dataType, tab); - break; - } - if(prm->analysisParms[i].dataType & IF_SET) { - val = INPgetValue(ckt,&line, - prm->analysisParms[i].dataType&IF_VARTYPES, tab); - error = (*(ft_sim->setAnalysisParm))(ckt,anal, - prm->analysisParms[i].id,val,(IFvalue*)NULL); - if(error) { - errmsg =(char *)MALLOC((35+strlen(token))*sizeof(char)); - (void) sprintf(errmsg, - "Warning: can't set optione %s\n", token); - optCard->error = INPerrCat(optCard->error, errmsg); - } - break; - } - } - } - if(i == prm->numParms) { - errmsg = (char *)MALLOC(100 * sizeof(char)); - (void) strcpy(errmsg," Error: unknown option - ignored\n"); - optCard->error = INPerrCat(optCard->error,errmsg); - } - } -} diff --git a/src/circuit/inpdpar.c b/src/circuit/inpdpar.c deleted file mode 100644 index 0d8def06c..000000000 --- a/src/circuit/inpdpar.c +++ /dev/null @@ -1,74 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - * INPdevParse() - * - * parse a given input according to the standard rules - look - * for the parameters given in the parmlists, In addition, - * an optional leading numeric parameter is handled. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "iferrmsg.h" -#include "cpdefs.h" -#include "fteext.h" -#include "inp.h" - -char * -INPdevParse(char **line, void *ckt, int dev, void *fast, double *leading, int *waslead, INPtables *tab) - /* the line to parse */ - /* the circuit this device is a member of */ - /* the device type code to the device being parsed */ - /* direct pointer to device being parsed */ - /* the optional leading numeric parameter */ - /* flag - 1 if leading double given, 0 otherwise */ - - -{ - int error; /* int to store evaluate error return codes in */ - char *parm; - char *errbuf; - int i; - IFvalue *val; - - /* check for leading value */ - *waslead = 0; - *leading = INPevaluate(line,&error,1); - if(error == 0) { /* found a good leading number */ - *waslead = 1; - } else *leading=0.0; - while (**line != (char) 0) { - error = INPgetTok(line,&parm,1); - if (!*parm) - continue; - if(error) return(INPerror(error)); - for(i=0;i<(*(*(ft_sim->devices)[dev]).numInstanceParms);i++) { - if(strcmp(parm, - ((*(ft_sim->devices)[dev]).instanceParms[i].keyword)) ==0) { - val = INPgetValue(ckt,line, - ((*(ft_sim->devices)[dev]).instanceParms[i].dataType), - tab); - if (!val) - return (INPerror(E_PARMVAL)); - error = (*(ft_sim->setInstanceParm))(ckt,fast, - (*(ft_sim->devices)[dev]).instanceParms[i].id, - val,(IFvalue*)NULL); - if(error) return(INPerror(error)); - break; - } - } - if(i==(*(*(ft_sim->devices)[dev]).numInstanceParms)) { - errbuf = MALLOC(strlen(parm)+25); - (void)sprintf(errbuf," unknown parameter (%s) \n",parm); - return(errbuf); - } - FREE(parm); - } - return((char *)NULL); -} diff --git a/src/circuit/inperrc.c b/src/circuit/inperrc.c deleted file mode 100644 index 44d8b559e..000000000 --- a/src/circuit/inperrc.c +++ /dev/null @@ -1,34 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "inp.h" - - -char * -INPerrCat(char *a, char *b) -{ - - if(a != (char *)NULL) { - if(b == (char *)NULL) { /* a valid, b null, return a */ - return(a); - } else { /* both valid - hard work...*/ - register char *errtmp; - errtmp = (char *)MALLOC( (strlen(a) + strlen(b)+2)*sizeof(char)); - (void) strcpy(errtmp,a); - (void) strcat(errtmp,"\n"); - (void) strcat(errtmp,b); - FREE(a); - FREE(b); - return(errtmp); - } - } else { /* a null, so return b */ - return(b); - } -} diff --git a/src/circuit/inperror.c b/src/circuit/inperror.c deleted file mode 100644 index 265415b8c..000000000 --- a/src/circuit/inperror.c +++ /dev/null @@ -1,41 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* - * provide the error message appropriate for the given error code - */ - -#include "ngspice.h" -#include -#include "fteext.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "sperror.h" -#include "inp.h" - -char * -INPerror(int type) -{ - char *val; - char ebuf[513]; - - val = SPerror(type); - - if (!val) - return(val); - - if(errRtn) - sprintf(ebuf, "%s detected in routine \"%s\"\n", val, errRtn); - else - sprintf(ebuf, "%s\n", val); - - FREE(val); - val = MALLOC(strlen(ebuf) + 1); - if (val) - strcpy(val, ebuf); - - return(val); -} - diff --git a/src/circuit/inpeval.c b/src/circuit/inpeval.c deleted file mode 100644 index 1f72902cb..000000000 --- a/src/circuit/inpeval.c +++ /dev/null @@ -1,172 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include -#include "inpdefs.h" -#include "inp.h" - -double -INPevaluate(char **line, int *error, int gobble) - /* non-zero to gobble rest of token, zero to leave it alone */ -{ - char * token; - char * here; - double mantis; - int expo1; - int expo2; - int sign; - int expsgn; - char * tmpline; - - /* setup */ - tmpline = *line; - if(gobble) { - *error = INPgetUTok(line,&token,1); - if(*error) return((double)0.0); - } else { - token = *line; - *error = 0; - } - mantis=0; - expo1=0; - expo2=0; - sign=1; - expsgn=1; - /* loop through all of the input token */ - here = token; - if(*here == '+') here++; /* plus, so do nothing except skip it */ - if(*here == '-') { /* minus, so skip it, and change sign */ - here++; - sign = -1; - } - if( (*here == 0) || ((!(isdigit(*here))) && (*here != '.'))) { - /* number looks like just a sign! */ - *error = 1; - /* back out the 'gettok' operation */ - *line = tmpline; - if(gobble) { FREE(token); }else{ *line=here;} - return(0); - } - while(isdigit(*here)) { - /* digit, so accumulate it. */ - mantis=10*mantis+*here-'0'; - here++; - } - if(*here == 0) { - /* reached the end of token - done. */ - if(gobble) { FREE(token); }else{ *line=here;} - return ((double)mantis*sign); - } - if(*here == ':') { - /* hack for subcircuit node numbering */ - *error = 1; - *line = tmpline; - return 0.0; - } - /* after decimal point! */ - if(*here == '.') { - /* found a decimal point! */ - here++; /* skip to next character */ - if(*here == 0) { - /* number ends in the decimal point */ - if(gobble) { FREE(token); }else{ *line=here;} - return ((double)mantis*sign); - } - while(isdigit(*here)) { - /* digit, so accumulate it. */ - mantis=10*mantis+*here - '0'; - expo1=expo1-1; - if(*here == 0) { - /* reached the end of token - done. */ - if(gobble) { FREE(token); }else{ *line=here;} - return (mantis*sign*pow(10.,(double)expo1)); - } - here++; - } - } - /* now look for "E","e",etc to indicate an exponent */ - if((*here == 'E') || (*here == 'e') || (*here == 'D') || (*here == 'd') ) { - /* have an exponent, so skip the e */ - here++; - /* now look for exponent sign */ - if(*here == '+') here++; /* just skip + */ - if(*here == '-') { - here++; /* skip over minus sign */ - expsgn = -1; /* and make a negative exponent */ - /* now look for the digits of the exponent */ - } - while (isdigit(*here)) { - expo2=10*expo2+*here - '0'; - here++; - } - } - /* now we have all of the numeric part of the number, time to - * look for the scale factor (alphabetic) - */ - switch(*here) { - case 't': - case 'T': - expo1=expo1+12; - break; - case 'g': - case 'G': - expo1=expo1+9; - break; - case 'k': - case 'K': - expo1=expo1+3; - break; - case 'u': - case 'U': - expo1=expo1-6; - break; - case 'n': - case 'N': - expo1=expo1-9; - break; - case 'p': - case 'P': - expo1=expo1-12; - break; - case 'f': - case 'F': - expo1=expo1-15; - break; - case 'm': - case 'M': - { - /* special case for m - may be m or mil or meg */ - if(*(here+1) != 0 && *(here+2) != 0) { - /* at least 2 characters, so check them. */ - if((*(here+1) == 'E') || (*(here+1) == 'e')) { - if((*(here+2) == 'G') || (*(here+2) == 'g')) { - expo1=expo1+6; - if(gobble) { FREE(token); }else{ *line=here;} - return (sign*mantis* - pow((double)10,(double)(expo1+expsgn*expo2))); - } - } - else if ((*(here+1) == 'I') || (*(here+1) == 'i')) { - if( (*(here+2) == 'L') || (*(here+2) == 'l')) { - expo1=expo1-6; - mantis=mantis*25.4; - if(gobble) { FREE(token); }else{ *line=here;} - return (sign*mantis* - pow((double)10,(double)(expo1+expsgn*expo2))); - } - } - } - /* not either special case, so just m => 1e-3 */ - expo1=expo1-3; - } - break; - default: - break; - } - if(gobble) { FREE(token); }else{ *line=here;} - return (sign*mantis*pow((double)10,(double)(expo1+expsgn*expo2))); -} diff --git a/src/circuit/inpfindl.c b/src/circuit/inpfindl.c deleted file mode 100644 index 02504b0e2..000000000 --- a/src/circuit/inpfindl.c +++ /dev/null @@ -1,67 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -Modified: 1999 Paolo Nenzi - Now we can use a two digits level code - -**********/ - - /* INPfindLev(line,level) - * find the 'level' parameter on the given line and return its - * value (1,2,..,99 for now, 1 default) - * - */ - -#include "ngspice.h" -#include -#include -#include "inpdefs.h" -#include "inp.h" - -char * -INPfindLev(char *line, int *level) -{ - char *where; - - where = line; - - where=strstr(line, "level"); - - if (where!=NULL) { /* found a level keyword on the line */ - - where += 5; /* skip the level keyword */ - while( (*where == ' ') || (*where == '\t') || (*where == '=') || - (*where == ',') || (*where == '(') || (*where == ')') || - (*where == '+') ) { /* legal white space - ignore */ - where++; - } - - /* now the magic number */ - sscanf(where,"%2d",level); /* We get the level number */ - if (*level<0) { - *level=1; - printf("Illegal value for level.\n"); - printf("Level must be >0 (Setting level to 1)\n"); - return(INPmkTemp(" illegal (negative) argument to level parameter - level=1 assumed")); - } - - if (*level>99) { /* Limit to change in the future */ - *level=1; - printf("Illegal value for level.\n"); - printf("Level must be <99 (Setting Level to 1)\n"); - return(INPmkTemp(" illegal (too high) argument to level parameter - level=1 assumed")); - } - - return((char *)NULL); - } - - - - else { /* no level on the line => default */ - *level = 1; - printf("Level not specified: Using level 1.\n"); - return((char *)NULL); - } - - - - -} diff --git a/src/circuit/inpgmod.c b/src/circuit/inpgmod.c deleted file mode 100644 index 465142bd8..000000000 --- a/src/circuit/inpgmod.c +++ /dev/null @@ -1,98 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "ifsim.h" -#include "cpstd.h" -#include "fteext.h" -#include "inp.h" - -extern INPmodel *modtab; - -char * -INPgetMod(void *ckt, char *name, INPmodel **model, INPtables *tab) -{ - INPmodel *modtmp; - IFvalue * val; - register int j; - char * line; - char *parm; - char *err = NULL; - char *temp; - int error; - - for (modtmp = modtab;modtmp != (INPmodel *)NULL;modtmp = - ((modtmp)->INPnextModel)) { - if (strcmp((modtmp)->INPmodName,name) == 0) { - /* found the model in question - now instantiate if necessary */ - /* and return an appropriate pointer to it */ - if(modtmp->INPmodType<0) { - /* illegal device type, so can't handle */ - *model = (INPmodel *)NULL; - err = (char *)MALLOC((35+strlen(name)) * sizeof(char)); - (void) sprintf(err, - "Unknown device type for model %s \n",name); - return(err); - } - if(! ((modtmp)->INPmodUsed )) { - /* not already defined, so create & give parameters */ - error = (*(ft_sim->newModel))( ckt,(modtmp)->INPmodType, - &((modtmp)->INPmodfast), (modtmp)->INPmodName); - if(error) return(INPerror(error)); - /* parameter isolation, identification, binding */ - line = ((modtmp)->INPmodLine)->line; - INPgetTok(&line,&parm,1); /* throw away '.model' */ - INPgetTok(&line,&parm,1); /* throw away 'modname' */ - while(*line != 0) { - INPgetTok(&line,&parm,1); - if (!*parm) - continue; - for(j=0;j<(*(*(ft_sim->devices)[(modtmp)->INPmodType]). - numModelParms); j++) { - if (strcmp(parm,((*(ft_sim->devices) [ (modtmp)-> - INPmodType ]).modelParms[j].keyword)) == 0) { - val = INPgetValue(ckt,&line, - ((*(ft_sim->devices)[(modtmp)-> - INPmodType ]).modelParms[j]. - dataType),tab); - error = (*(ft_sim->setModelParm))(ckt, - ((modtmp)->INPmodfast), - (*(ft_sim->devices)[(modtmp)->INPmodType ]). - modelParms[j].id,val,(IFvalue*)NULL); - if(error) return(INPerror(error)); - break; - } - } - if (strcmp(parm,"level")==0) { - /* just grab the level number and throw away */ - /* since we already have that info from pass1 */ - val = INPgetValue(ckt,&line,IF_REAL,tab); - } else if(j >= - (*(*(ft_sim->devices)[(modtmp)->INPmodType]). - numModelParms)) { - temp = (char *)MALLOC((40+strlen(parm)) * sizeof(char)); - (void)sprintf(temp, - "unrecognized parameter (%s) - ignored\n", parm); - err = INPerrCat(err,temp); - } - FREE(parm); - } - (modtmp)->INPmodUsed=1; - (modtmp)->INPmodLine->error = err; - } - *model = modtmp; - return((char *)NULL); - } - } - /* didn't find model - ERROR - return model */ - *model = (INPmodel *)NULL; - err = (char *)MALLOC((60+strlen(name)) * sizeof(char)); - (void) sprintf(err, - " unable to find definition of model %s - default assumed \n",name); - return(err); -} - diff --git a/src/circuit/inpgstr.c b/src/circuit/inpgstr.c deleted file mode 100644 index f6208fd45..000000000 --- a/src/circuit/inpgstr.c +++ /dev/null @@ -1,73 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* - * Get string input token from 'line', and return a pointer to it in 'token' - */ - -#include "ngspice.h" -#include -#include "iferrmsg.h" -#include "inpdefs.h" -#include "inp.h" - -int -INPgetStr(char **line, char **token, int gobble) - /* eat non-whitespace trash AFTER token? */ -{ - char *point; - char separator = '\0'; - - /* Scan along throwing away garbage characters. */ - for (point = *line; *point != '\0'; point++) { - if ( (*point == ' ') || - (*point == '\t') || - (*point == '=') || - (*point == '(') || - (*point == ')') || - (*point == ',') ) continue; - break; - } - if (*point == '"') { - separator = '"'; - point++; - } else if (*point == '\'') { - separator = '\''; - point++; - } - /* mark beginning of token */ - *line = point; - /* now find all good characters */ - for (point = *line; *point != '\0'; point++) { - if ( (*point == ' ') || - (*point == '\t') || - (*point == '=') || - (*point == '(') || - (*point == ')') || - (*point == ',') || - (*point == separator) ) break; - } - - /* Create token */ - *token = (char *) MALLOC(1 + point - *line); - if (!*token) - return (E_NOMEM); - (void) strncpy(*token, *line, point - *line); - *(*token + (point - *line)) = '\0'; - *line = point; - - /* Gobble garbage to next token. */ - if (separator && **line == separator) { - (*line)++; /* Skip one closing separator */ - } - for (; **line != '\0'; (*line)++) { - if(**line == ' ') continue; - if(**line == '\t') continue; - if((**line == '=') && gobble) continue; - if((**line == ',') && gobble) continue; - break; - } - return (OK); -} diff --git a/src/circuit/inpgtitl.c b/src/circuit/inpgtitl.c deleted file mode 100644 index ff5b679a7..000000000 --- a/src/circuit/inpgtitl.c +++ /dev/null @@ -1,29 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* INPgetTitle(ckt,data) - * get the title card from the specified data deck and pass - * it through to SPICE-3. - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "iferrmsg.h" -#include "cpstd.h" -#include "fteext.h" -#include "inp.h" - -int -INPgetTitle(void **ckt, card **data) -{ - int error; - - error = (*(ft_sim->newCircuit))(ckt); - if(error) return(error); - *data = (*data)->nextcard; - return(OK); -} - diff --git a/src/circuit/inpgtok.c b/src/circuit/inpgtok.c deleted file mode 100644 index 925ee3803..000000000 --- a/src/circuit/inpgtok.c +++ /dev/null @@ -1,179 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* get input token from 'line', - * and return a pointer to it in 'token' - */ - -/* INPgetTok: node names - INPgetUTok: numbers and other elements in expressions - (called from INPevaluate) - */ - -#include "ngspice.h" -#include -#include "iferrmsg.h" -#include "inpdefs.h" -#include "inp.h" - -int -INPgetTok(char **line, char **token, int gobble) - /* eat non-whitespace trash AFTER token? */ -{ - char * point; - int signstate; - - /* scan along throwing away garbage characters */ - for(point = *line;*point != '\0' ; point++ ) { - if(*point == ' ') continue; - if(*point == '\t') continue; - if(*point == '=') continue; - if(*point == '(') continue; - if(*point == ')') continue; - if(*point == ',') continue; - break; - } - /* mark beginning of token */ - *line = point; - /* now find all good characters */ - signstate = 0; - for(point = *line;*point!='\0';point++) { - if(*point == ' ') break; - if(*point == '\t') break; - if(*point == '=') break; - if(*point == '(') break; - if(*point == ')') break; - if(*point == ',') break; - /* This is not complex enough to catch all errors, but it will get the "good" parses */ - if(*point == '+' && (signstate == 1 || signstate == 3)) break; - if(*point == '-' && (signstate == 1 || signstate == 3)) break; - if(*point == '*') break; - if(*point == '/') break; - if(*point == '^') break; - if (isdigit(*point) || *point == '.') { - if (signstate > 1) - signstate = 3; - else - signstate = 1; - } else if (tolower(*point) == 'e' && signstate == 1) - signstate = 2; - else - signstate = 3; - - } - if (point == *line && *point) /* Weird items, 1 char */ - point++; - *token=(char *)MALLOC(1+point-*line); - if(!*token) return(E_NOMEM); - (void) strncpy(*token,*line,point-*line); - *(*token + (point-*line)) = '\0'; - *line = point; - /* gobble garbage to next token */ - for( ;**line != '\0' ; (*line)++ ) { - if(**line == ' ') continue; - if(**line == '\t') continue; - if((**line == '=') && gobble) continue; - if((**line == ',') && gobble) continue; -#ifdef notdef - /* This is the wrong thing to do for expression-valued parameters. The - parens will get taken out at the beginning, leave them here for - parse trees */ - if((**line == /* (match */')') && gobble) continue; - if((**line == '(' /* match) */) && gobble) continue; -#endif - break; - } - /*printf("found token (%s) and rest of line (%s)\n",*token,*line);*/ - return(OK); -} - -int -INPgetUTok(char **line, char **token, int gobble) - - - /* eat non-whitespace trash AFTER token? */ -{ - char * point, separator; - int signstate; - /* scan along throwing away garbage characters */ - for(point = *line;*point != '\0' ; point++ ) { - if(*point == ' ') continue; - if(*point == '\t') continue; - if(*point == '=') continue; - if(*point == '(') continue; - if(*point == ')') continue; - if(*point == ',') continue; - break; - } - if (*point == '"') { - separator = '"'; - point++; - } else if (*point == '\'') { - separator = '\''; - point++; - } else - separator = 0; - - /* mark beginning of token */ - *line = point; - - /* now find all good characters */ - signstate = 0; - for(point = *line;*point!='\0';point++) { - if (separator) { - if (*point == separator) - break; - else - continue; - } - if(*point == ' ') break; - if(*point == '\t') break; - if(*point == '=') break; - if(*point == '(') break; - if(*point == ')') break; - if(*point == ',') break; - /* This is not complex enough to catch all errors, but it will - get the "good" parses */ - if(*point == '+' && (signstate == 1 || signstate == 3)) break; - if(*point == '-') { - if (signstate == 1 || signstate == 3) break; - signstate += 1; - continue; - } - if(*point == '*') break; - if(*point == '/') break; - if(*point == '^') break; - if (isdigit(*point) || *point == '.') { - if (signstate > 1) - signstate = 3; - else - signstate = 1; - } else if (tolower(*point) == 'e' && signstate == 1) - signstate = 2; - else - signstate = 3; - } - if (separator && *point == separator) - point--; - if (point == *line && *point) /* Weird items, 1 char */ - point++; - *token=(char *)MALLOC(1+point-*line); - if(!*token) return(E_NOMEM); - (void) strncpy(*token,*line,point-*line); - *(*token + (point-*line)) = '\0'; - /* gobble garbage to next token */ - for( ;*point != '\0' ; point++ ) { - if (*point == separator) - continue; - if(*point == ' ') continue; - if(*point == '\t') continue; - if((*point == '=') && gobble) continue; - if((*point == ',') && gobble) continue; - break; - } - *line = point; - /* printf("found token (%s) and rest of line (%s)\n",*token,*line); */ - return(OK); -} diff --git a/src/circuit/inpgval.c b/src/circuit/inpgval.c deleted file mode 100644 index 31129be7c..000000000 --- a/src/circuit/inpgval.c +++ /dev/null @@ -1,78 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "inpdefs.h" -#include "inpptree.h" -#include "inp.h" - -IFvalue * -INPgetValue(void *ckt, char **line, int type, INPtables *tab) -{ - double *list; - int *ilist; - double tmp; - char *word; - int error; - static IFvalue temp; - INPparseTree *pt; - - /* make sure we get rid of extra bits in type */ - type &= IF_VARTYPES; - if(type == IF_INTEGER) { - temp.iValue = INPevaluate(line,&error,1); - /*printf(" returning integer value %d\n",temp.iValue);*/ - } else if (type == IF_REAL) { - temp.rValue = INPevaluate(line,&error,1); - /*printf(" returning real value %e\n",temp.rValue);*/ - } else if (type == IF_REALVEC) { - temp.v.numValue = 0; - list = (double *)MALLOC(sizeof(double)); - tmp = INPevaluate(line,&error,1); - while (error == 0) { - /*printf(" returning vector value %g\n",tmp); */ - temp.v.numValue++; - list=(double *)REALLOC((char *)list,temp.v.numValue*sizeof(double)); - *(list+temp.v.numValue-1) = tmp; - tmp = INPevaluate(line,&error,1); - } - temp.v.vec.rVec=list; - } else if (type == IF_INTVEC) { - temp.v.numValue = 0; - ilist = (int *)MALLOC(sizeof(int)); - tmp = INPevaluate(line,&error,1); - while (error == 0) { - /*printf(" returning vector value %g\n",tmp); */ - temp.v.numValue++; - ilist=(int *)REALLOC((char *)ilist,temp.v.numValue*sizeof(int)); - *(ilist+temp.v.numValue-1) = tmp; - tmp = INPevaluate(line,&error,1); - } - temp.v.vec.iVec=ilist; - } else if (type == IF_FLAG) { - temp.iValue = 1; - } else if (type == IF_NODE) { - INPgetTok(line,&word,1); - INPtermInsert(ckt,&word,tab,&(temp.nValue)); - } else if (type == IF_INSTANCE) { - INPgetTok(line,&word,1); - INPinsert(&word,tab); - temp.nValue = word; - } else if (type == IF_STRING) { - INPgetStr(line,&word,1); - temp.sValue = word; - } else if (type == IF_PARSETREE) { - INPgetTree(line, &pt, ckt, tab); - if (!pt) - return((IFvalue *)NULL); - temp.tValue = (IFparseTree *) pt; - /*INPptPrint("Parse tree is: ", temp.tValue);*/ - } else { /* don't know what type of parameter caller is talking about! */ - return((IFvalue *)NULL); - } - return(&temp); -} diff --git a/src/circuit/inpkmods.c b/src/circuit/inpkmods.c deleted file mode 100644 index 8981bc840..000000000 --- a/src/circuit/inpkmods.c +++ /dev/null @@ -1,30 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "inp.h" - - -extern INPmodel *modtab; - -void -INPkillMods(void) -{ - INPmodel *modtmp; - INPmodel *prev = NULL; - - for (modtmp = modtab;modtmp != (INPmodel *)NULL;modtmp = - modtmp->INPnextModel) { - if(prev) FREE(prev); - prev = modtmp; - } - if(prev) FREE(prev); - modtab = (INPmodel *)NULL; -} - diff --git a/src/circuit/inplist.c b/src/circuit/inplist.c deleted file mode 100644 index 87e4e0e89..000000000 --- a/src/circuit/inplist.c +++ /dev/null @@ -1,54 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - - /* INPlist(file,deck,type) - * provide an input listing on the specified file of the given - * card deck. The listing should be of either PHYSICAL or LOGICAL - * lines as specified by the type parameter. - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "inp.h" - - -void -INPlist(FILE *file, card *deck, int type) -{ - - card *here; - card *there; - - if(type == LOGICAL) { - for(here = deck;here != NULL;here = here->nextcard) { - fprintf(file,"%6d : %s\n",here->linenum, here->line); - if(here->error != (char *)NULL) { - fprintf(file,"%s",here->error); - } - } - } else if (type == PHYSICAL) { - for(here = deck;here != NULL;here = here->nextcard) { - if(here->actualLine == (card *)NULL) { - fprintf(file,"%6d : %s\n",here->linenum,here->line); - if(here->error != (char *)NULL) { - fprintf(file,"%s",here->error); - } - } else { - for(there = here->actualLine;there != NULL; - there=there->nextcard) { - fprintf(file,"%6d : %s\n",there->linenum, there->line); - if(there->error != (char *)NULL) { - fprintf(file,"%s",there->error); - } - } - } - } - } -} - - diff --git a/src/circuit/inplkmod.c b/src/circuit/inplkmod.c deleted file mode 100644 index 38bfb0d09..000000000 --- a/src/circuit/inplkmod.c +++ /dev/null @@ -1,31 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "inp.h" - - -extern INPmodel *modtab; - - -int -INPlookMod(char *name) -{ - register INPmodel **i; - - for (i = &modtab;*i != (INPmodel *)NULL;i = &((*i)->INPnextModel)) { - if (strcmp((*i)->INPmodName,name) == 0) { - /* found the model in question - return TRUE */ - return(1); - } - } - /* didn't find model - return FALSE */ - return(0); -} - diff --git a/src/circuit/inpmkmod.c b/src/circuit/inpmkmod.c deleted file mode 100644 index d6819b738..000000000 --- a/src/circuit/inpmkmod.c +++ /dev/null @@ -1,35 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "iferrmsg.h" -#include "inp.h" - -INPmodel *modtab; - - /* create/lookup a 'model' entry */ - -int -INPmakeMod(char *token, int type, card *line) -{ - register INPmodel **i; - - for (i = &modtab;*i != (INPmodel *)NULL;i = &((*i)->INPnextModel)) { - if (strcmp((*i)->INPmodName,token) == 0) { - return(OK); - } - } - *i = (INPmodel *)MALLOC(sizeof(INPmodel)); - if(*i==NULL) return(E_NOMEM); - (*i)->INPmodName = token; - (*i)->INPmodType = type; - (*i)->INPnextModel = (INPmodel *)NULL; - (*i)->INPmodUsed = 0; - (*i)->INPmodLine = line; - (*i)->INPmodfast = NULL; - return(OK); -} diff --git a/src/circuit/inpmktmp.c b/src/circuit/inpmktmp.c deleted file mode 100644 index b2c9e102b..000000000 --- a/src/circuit/inpmktmp.c +++ /dev/null @@ -1,25 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ -/* - */ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "inp.h" - - -char * -INPmkTemp(char *string) -{ -int len; -char *temp; - - len = strlen(string); - temp = MALLOC(len+1); - if(temp!=(char *)NULL) (void)strcpy(temp,string); - return(temp); - -} diff --git a/src/circuit/inppas1.c b/src/circuit/inppas1.c deleted file mode 100644 index a55d1114d..000000000 --- a/src/circuit/inppas1.c +++ /dev/null @@ -1,41 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "ifsim.h" -#include "inp.h" - -/* - * The first pass of the circuit parser just looks for '.model' lines - */ - -void -INPpas1(void *ckt, card *deck, INPtables *tab) -{ - card *current; - char *INPdomodel(void *ckt, card *image, INPtables *tab); - char *temp, *thisline; - - for(current = deck;current != NULL;current = current->nextcard) { - /* SPICE-2 keys off of the first character of the line */ - thisline = current->line; - - while (*thisline && ((*thisline == ' ') || (*thisline == '\t'))) - thisline++; - - if (*thisline == '.') { - if(strncmp(thisline,".model",6)==0) { - temp = INPdomodel(ckt,current,tab); - current->error = INPerrCat(current->error,temp); - } - } - - /* for now, we do nothing with the other cards - just - * keep them in the list for pass 2 - */ - } -} diff --git a/src/circuit/inppas2.c b/src/circuit/inppas2.c deleted file mode 100644 index 863e88917..000000000 --- a/src/circuit/inppas2.c +++ /dev/null @@ -1,156 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cpdefs.h" -#include "fteext.h" -#include "ftedefs.h" -#include "inpdefs.h" -#include "iferrmsg.h" -#include "tskdefs.h" -#include "inpmacs.h" -#include "inp.h" - -/* pass 2 - Scan through the lines. ".model" cards have processed - * in pass1 and are ignored here. - */ - -void -INPpas2(void *ckt, card *data, INPtables *tab, void *task) -{ - -card *current; -char c; -char * groundname="0"; -char * gname; -void *gnode; -int error; /* used by the macros defined above */ - - error = INPgetTok(&groundname,&gname,1); - if(error) data->error = INPerrCat(data->error,INPmkTemp( - "can't read internal ground node name!\n")); - - error = INPgndInsert(ckt,&gname,tab,&gnode); - if(error && error!=E_EXISTS)data->error = INPerrCat(data->error,INPmkTemp( - "can't insert internal ground node in symbol table!\n")); - - for(current = data; current != NULL; current = current->nextcard) { - - c = *(current->line); - c = islower(c) ? toupper(c) : c; - - switch(c) { - - case ' ': /* blank line (space leading) */ - case '\t': /* blank line (tab leading) */ - break; - - case 'R': /* Rname [][][w=][l=] */ - INP2R(ckt,tab,current); - break; - case 'C': /* Cname [IC=] */ - INP2C(ckt,tab,current); - break; - case 'L': /* Lname [IC=] */ - INP2L(ckt,tab,current); - break; - case 'G': /* Gname */ - INP2G(ckt,tab,current); - break; - case 'E': /* Ename */ - INP2E(ckt,tab,current); - break; - case 'F': /* Fname */ - INP2F(ckt,tab,current); - break; - case 'H': /* Hname */ - INP2H(ckt,tab,current); - break; - case 'D': /* Dname [] [OFF] [IC=] */ - INP2D(ckt,tab,current); - break; - case 'J': /* Jname [] [OFF] - * [IC=,] */ - INP2J(ckt,tab,current); - break; - case 'Z': /* Zname [] [OFF] - * [IC=,] */ - INP2Z(ckt,tab,current); - break; - case 'M': /* Mname [L=] - * [W=] [AD=] [AS=] [PD=] - * [PS=] [NRD=] [NRS=] [OFF] - * [IC=,,] */ - INP2M(ckt,tab,current); - break; - - case 'O': /* Oname - * [IC=,,,] */ - INP2O(ckt,tab,current); - break; - - case 'V': /* Vname [ [DC] ] [AC [ [ ] ] ] - * [] */ - INP2V(ckt,tab,current); - break; - case 'I': /* Iname [ [DC] ] [AC [ [ ] ] ] - * [] */ - INP2I(ckt,tab,current); - break; - - case 'Q': /* Qname [] [] [OFF] - * [IC=,] */ - INP2Q(ckt,tab,current,gnode); - break; - - case 'T': /* Tname [TD=] - * [F= [NL=]][IC=,,,] */ - INP2T(ckt,tab,current); - break; - - case 'S': /* Sname [] [IC] */ - INP2S(ckt,tab,current); - break; - - case 'W': /* Wname [] [IC] */ - /* CURRENT CONTROLLED SWITCH */ - INP2W(ckt,tab,current); - break; - - case 'U': /* Uname [l=] [n=] */ - INP2U(ckt,tab,current); - break; - - case 'K': /* Kname Lname Lname */ - INP2K(ckt,tab,current); - break; - - case '*': /* * - a comment - ignore */ - break; - - case 'B': /* Bname [V=expr] [I=expr] */ - /* Arbitrary source. */ - INP2B(ckt,tab,current); - break; - - case '.': /* . Many possibilities */ - if (INP2dot(ckt,tab,current,task,gnode)) goto end; - break; - - case 0: - break; - - default: - /* the un-implemented device */ - LITERR(" unknown device type - error \n") - break; - } - } -end: - return; -} - diff --git a/src/circuit/inppname.c b/src/circuit/inppname.c deleted file mode 100644 index 3b8e78c2a..000000000 --- a/src/circuit/inppname.c +++ /dev/null @@ -1,45 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* - * INPpName() - * - * Take a parameter by Name and set it on the specified device - */ - -#include "ngspice.h" -#include -#include "cpdefs.h" -#include "fteext.h" -#include "ifsim.h" -#include "iferrmsg.h" -#include "inp.h" - -int -INPpName(char *parm, IFvalue *val, void *ckt, int dev, void *fast) - /* the name of the parameter to set */ - /* the parameter union containing the value to set */ - /* the circuit this device is a member of */ - /* the device type code to the device being parsed */ - /* direct pointer to device being parsed */ - -{ - int error; /* int to store evaluate error return codes in */ - int i; - - for(i=0;i<(*(*(ft_sim->devices)[dev]).numInstanceParms);i++) { - if(strcmp(parm, - ((*(ft_sim->devices)[dev]).instanceParms[i].keyword))==0) { - error = (*(ft_sim->setInstanceParm))(ckt,fast, (*(ft_sim-> - devices)[dev]).instanceParms[i].id,val,(IFvalue*)NULL); - if(error) return(error); - break; - } - } - if(i==(*(*(ft_sim->devices)[dev]).numInstanceParms)) { - return(E_BADPARM); - } - return(OK); -} diff --git a/src/circuit/inpptree.c b/src/circuit/inpptree.c deleted file mode 100644 index 80721bd28..000000000 --- a/src/circuit/inpptree.c +++ /dev/null @@ -1,1087 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -#include "ngspice.h" -#include -#include -#include "ifsim.h" -#include "iferrmsg.h" -#include "inpdefs.h" -#include "inpptree.h" -#include "inp.h" - -static INPparseNode * mkcon(double value); -static INPparseNode * mkb(int type, INPparseNode *left, INPparseNode *right); -static INPparseNode * mkf(int type, INPparseNode *arg); -static int PTcheck(INPparseNode *p); -static INPparseNode * PTparse(char **line); -static INPparseNode * makepnode(PTelement *elem); -static INPparseNode * mkbnode(int opnum, INPparseNode *arg1, INPparseNode *arg2); -static INPparseNode * mkfnode(char *fname, INPparseNode *arg); -static INPparseNode * mknnode(double number); -static INPparseNode * mksnode(char *string); -static INPparseNode * PTdifferentiate(INPparseNode *p, int varnum); -static PTelement * PTlexer(char **line); - -static IFvalue *values = NULL; -static int *types; -static int numvalues; -static void *circuit; -static INPtables *tables; - - - -extern IFsimulator *ft_sim; /* XXX */ - -/* Some tables that the parser uses. */ - -static struct op { - int number; - char *name; - double (*funcptr)(); -} ops[] = { - { PT_COMMA, ",", NULL } , - { PT_PLUS, "+", PTplus } , - { PT_MINUS, "-", PTminus } , - { PT_TIMES, "*", PTtimes } , - { PT_DIVIDE, "/", PTdivide } , - { PT_POWER, "^", PTpower } -} ; - -#define NUM_OPS (sizeof (ops) / sizeof (struct op)) - -static struct func { - char *name; - int number; - double (*funcptr)(); -} funcs[] = { - { "abs", PTF_ABS, PTabs } , - { "acos", PTF_ACOS, PTacos } , - { "acosh", PTF_ACOSH, PTacosh } , - { "asin", PTF_ASIN, PTasin } , - { "asinh", PTF_ASINH, PTasinh } , - { "atan", PTF_ATAN, PTatan } , - { "atanh", PTF_ATANH, PTatanh } , - { "cos", PTF_COS, PTcos } , - { "cosh", PTF_COSH, PTcosh } , - { "exp", PTF_EXP, PTexp } , - { "ln", PTF_LN, PTln } , - { "log", PTF_LOG, PTlog } , - { "sgn", PTF_SGN, PTsgn } , - { "sin", PTF_SIN, PTsin } , - { "sinh", PTF_SINH, PTsinh } , - { "sqrt", PTF_SQRT, PTsqrt } , - { "tan", PTF_TAN, PTtan } , - { "tanh", PTF_TANH, PTtanh } , - { "u", PTF_USTEP, PTustep } , - { "uramp", PTF_URAMP, PTuramp } , - { "-", PTF_UMINUS, PTuminus } -} ; - -#define NUM_FUNCS (sizeof (funcs) / sizeof (struct func)) - -/* These are all the constants any sane person needs. */ - -static struct constant { - char *name; - double value; -} constants[] = { - { "e", M_E }, - { "pi", M_PI } -} ; - -#define NUM_CONSTANTS (sizeof (constants) / sizeof (struct constant)) - -/* Parse the expression in *line as far as possible, and return the parse - * tree obtained. If there is an error, *pt will be set to NULL and an error - * message will be printed. - */ - -void -INPgetTree(char **line, INPparseTree **pt, void *ckt, INPtables *tab) -{ - INPparseNode *p; - int i; - - values = NULL; - types = NULL; - numvalues = 0; - - circuit = ckt; - tables = tab; - - p = PTparse(line); - - if (!p || !PTcheck(p)) { - *pt = NULL; - return; - } - - (*pt) = (INPparseTree *) MALLOC(sizeof (INPparseTree)); - - (*pt)->p.numVars = numvalues; - (*pt)->p.varTypes = types; - (*pt)->p.vars = values; - (*pt)->p.IFeval = IFeval; - (*pt)->tree = p; - - (*pt)->derivs = (INPparseNode **) - MALLOC(numvalues * sizeof (INPparseNode *)); - - for (i = 0; i < numvalues; i++) - (*pt)->derivs[i] = PTdifferentiate(p, i); - - return; -} - -/* This routine takes the partial derivative of the parse tree with respect to - * the i'th variable. We try to do optimizations like getting rid of 0-valued - * terms. - * - *** Note that in the interests of simplicity we share some subtrees between - *** the function and its derivatives. This means that you can't free the - *** trees. - */ - -static INPparseNode * -PTdifferentiate(INPparseNode *p, int varnum) -{ - INPparseNode *arg1, *arg2, *newp; - -/* printf("differentiating: "); printTree(p); printf(" wrt var %d\n", varnum);*/ - - switch (p->type) { - case PT_CONSTANT: - newp = mkcon((double) 0); - break; - - case PT_VAR: - /* Is this the variable we're differentiating wrt? */ - if (p->valueIndex == varnum) - newp = mkcon((double) 1); - else - newp = mkcon((double) 0); - break; - - case PT_PLUS: - case PT_MINUS: - arg1 = PTdifferentiate(p->left, varnum); - arg2 = PTdifferentiate(p->right, varnum); - newp = mkb(p->type, arg1, arg2); - break; - - case PT_TIMES: - /* d(a * b) = d(a) * b + d(b) * a */ - arg1 = PTdifferentiate(p->left, varnum); - arg2 = PTdifferentiate(p->right, varnum); - - newp = mkb(PT_PLUS, mkb(PT_TIMES, arg1, p->right), - mkb(PT_TIMES, p->left, arg2)); - break; - - case PT_DIVIDE: - /* d(a / b) = (d(a) * b - d(b) * a) / b^2 */ - arg1 = PTdifferentiate(p->left, varnum); - arg2 = PTdifferentiate(p->right, varnum); - - newp = mkb(PT_DIVIDE, mkb(PT_MINUS, mkb(PT_TIMES, arg1, - p->right), mkb(PT_TIMES, p->left, arg2)), - mkb(PT_POWER, p->right, mkcon((double) 2))); - break; - - case PT_POWER: - /* Two cases... If the power is a constant then we're cool. - * Otherwise we have to be tricky. - */ - if (p->right->type == PT_CONSTANT) { - arg1 = PTdifferentiate(p->left, varnum); - - newp = mkb(PT_TIMES, mkb(PT_TIMES, - mkcon(p->right->constant), - mkb(PT_POWER, p->left, - mkcon(p->right->constant - 1))), - arg1); - } else { - /* This is complicated. f(x) ^ g(x) -> - * exp(y(x) * ln(f(x)) ... - */ - arg1 = PTdifferentiate(p->left, varnum); - arg2 = PTdifferentiate(p->right, varnum); - newp = mkb(PT_TIMES, mkf(PTF_EXP, mkb(PT_TIMES, - p->right, mkf(PTF_LN, p->left))), - mkb(PT_PLUS, mkb(PT_TIMES, p->right, - mkb(PT_DIVIDE, arg1, p->left)), - mkb(PT_TIMES, arg2, - mkf(PTF_LN, arg1)))); - - } - break; - - case PT_FUNCTION: - /* Many cases. Set arg1 to the derivative of the function, - * and arg2 to the derivative of the argument. - */ - switch (p->funcnum) { - case PTF_ABS: /* sgn(u) */ - /* arg1 = mkf(PTF_SGN, p->left, 0); */ - arg1 = mkf(PTF_SGN, p->left); - break; - - case PTF_SGN: - arg1 = mkcon((double) 0.0); - break; - - case PTF_ACOS: /* - 1 / sqrt(1 - u^2) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) -1), mkf(PTF_SQRT, - mkb(PT_MINUS, mkcon((double) 1), - mkb(PT_POWER, p->left, mkcon((double) - 2))))); - break; - - case PTF_ACOSH: /* 1 / sqrt(u^2 - 1) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkf(PTF_SQRT, - mkb(PT_MINUS, mkb(PT_POWER, p->left, - mkcon((double) 2)), - mkcon((double) 1)))); - - break; - - case PTF_ASIN: /* 1 / sqrt(1 - u^2) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkf(PTF_SQRT, - mkb(PT_MINUS, mkcon((double) 1), - mkb(PT_POWER, p->left, mkcon((double) - 2))))); - break; - - case PTF_ASINH: /* 1 / sqrt(u^2 + 1) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkf(PTF_SQRT, - mkb(PT_PLUS, mkb(PT_POWER, p->left, - mkcon((double) 2)), - mkcon((double) 1)))); - break; - - case PTF_ATAN: /* 1 / (1 + u^2) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkb(PT_PLUS, - mkb(PT_POWER, p->left, mkcon((double) - 2)), mkcon((double) 1))); - break; - - case PTF_ATANH: /* 1 / (1 - u^2) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkb(PT_MINUS, - mkcon((double) 1), mkb(PT_POWER, - p->left, mkcon((double) 2)))); - break; - - case PTF_COS: /* - sin(u) */ - arg1 = mkf(PTF_UMINUS, mkf(PTF_SIN, p->left)); - break; - - case PTF_COSH: /* sinh(u) */ - arg1 = mkf(PTF_SINH, p->left); - break; - - case PTF_EXP: /* exp(u) */ - /* arg1 = mkf(PTF_EXP, p->left, 0); */ - arg1 = mkf(PTF_EXP, p->left); - break; - - case PTF_LN: /* 1 / u */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), p->left); - break; - - case PTF_LOG: /* log(e) / u */ - arg1 = mkb(PT_DIVIDE, mkcon((double) M_LOG10E), p->left); - break; - - case PTF_SIN: /* cos(u) */ - arg1 = mkf(PTF_COS, p->left); - break; - - case PTF_SINH: /* cosh(u) */ - arg1 = mkf(PTF_COSH, p->left); - break; - - case PTF_SQRT: /* 1 / (2 * sqrt(u)) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkb(PT_TIMES, - mkcon((double) 2), mkf(PTF_SQRT, - p->left))); - break; - - case PTF_TAN: /* 1 / (cos(u) ^ 2) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkb(PT_POWER, - mkf(PTF_COS, p->left), mkcon((double) - 2))); - break; - - case PTF_TANH: /* 1 / (cosh(u) ^ 2) */ - arg1 = mkb(PT_DIVIDE, mkcon((double) 1), mkb(PT_POWER, - mkf(PTF_COSH, p->left), mkcon((double) - 2))); - break; - - case PTF_USTEP: - arg1 = mkcon((double) 0.0); - break; - - case PTF_URAMP: - arg1 = mkf(PTF_USTEP, p->left); - break; - - case PTF_UMINUS: /* - 1 ; like a constant (was 0 !) */ - arg1 = mkcon((double) - 1.0); - break; - - default: - fprintf(stderr, "Internal Error: bad function # %d\n", - p->funcnum); - newp = NULL; - break; - } - - arg2 = PTdifferentiate(p->left, varnum); - - newp = mkb(PT_TIMES, arg1, arg2); - - break; - - default: - fprintf(stderr, "Internal error: bad node type %d\n", p->type); - newp = NULL; - break; - } - -/* printf("result is: "); printTree(newp); printf("\n"); */ - return (newp); -} - -static INPparseNode * -mkcon(double value) -{ - INPparseNode *p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - - p->type = PT_CONSTANT; - p->constant = value; - - return (p); -} - -static INPparseNode * -mkb(int type, INPparseNode *left, INPparseNode *right) -{ - INPparseNode *p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - int i; - - if ((right->type == PT_CONSTANT) && (left->type == PT_CONSTANT)) { - switch (type) { - case PT_TIMES: - return (mkcon(left->constant * right->constant)); - - case PT_DIVIDE: - return (mkcon(left->constant / right->constant)); - - case PT_PLUS: - return (mkcon(left->constant + right->constant)); - - case PT_MINUS: - return (mkcon(left->constant - right->constant)); - - case PT_POWER: - return (mkcon(pow(left->constant, right->constant))); - } - } - switch (type) { - case PT_TIMES: - if ((left->type == PT_CONSTANT) && (left->constant == 0)) - return (left); - else if ((right->type == PT_CONSTANT) && (right->constant == 0)) - return (right); - else if ((left->type == PT_CONSTANT) && (left->constant == 1)) - return (right); - else if ((right->type == PT_CONSTANT) && (right->constant == 1)) - return (left); - break; - - case PT_DIVIDE: - if ((left->type == PT_CONSTANT) && (left->constant == 0)) - return (left); - else if ((right->type == PT_CONSTANT) && (right->constant == 1)) - return (left); - break; - - case PT_PLUS: - if ((left->type == PT_CONSTANT) && (left->constant == 0)) - return (right); - else if ((right->type == PT_CONSTANT) && (right->constant == 0)) - return (left); - break; - - case PT_MINUS: - if ((right->type == PT_CONSTANT) && (right->constant == 0)) - return (left); - else if ((left->type == PT_CONSTANT) && (left->constant == 0)) - return (mkf(PTF_UMINUS, right)); - break; - - case PT_POWER: - if (right->type == PT_CONSTANT) { - if (right->constant == 0) - return (mkcon(1.0)); - else if (right->constant == 1) - return (left); - } - break; - } - - p->type = type; - p->left = left; - p->right = right; - - for (i = 0; i < NUM_OPS; i++) - if (ops[i].number == type) - break; - if (i == NUM_OPS) { - fprintf(stderr, "Internal Error: bad type %d\n", type); - return (NULL); - } - p->function = ops[i].funcptr; - p->funcname = ops[i].name; - - return (p); -} - -static INPparseNode * -mkf(int type, INPparseNode *arg) -{ - INPparseNode *p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - int i; - double constval; - - for (i = 0; i < NUM_FUNCS; i++) - if (funcs[i].number == type) - break; - if (i == NUM_FUNCS) { - fprintf(stderr, "Internal Error: bad type %d\n", type); - return (NULL); - } - - if (arg->type == PT_CONSTANT) { - constval = ((*funcs[i].funcptr) (arg->constant)); - return (mkcon(constval)); - } - - p->type = PT_FUNCTION; - p->left = arg; - - p->funcnum = i; - p->function = funcs[i].funcptr; - p->funcname = funcs[i].name; - - return (p); -} - -/* Check for remaining PT_PLACEHOLDERs in the parse tree. Returns 1 if ok. */ - -static int -PTcheck(INPparseNode *p) -{ - switch (p->type) { - case PT_PLACEHOLDER: - return (0); - - case PT_CONSTANT: - case PT_VAR: - return (1); - - case PT_FUNCTION: - return (PTcheck(p->left)); - - case PT_PLUS: - case PT_MINUS: - case PT_TIMES: - case PT_DIVIDE: - case PT_POWER: - return (PTcheck(p->left) && PTcheck(p->right)); - - default: - fprintf(stderr, "Internal error: bad node type %d\n", p->type); - return (0); - } -} - -/* The operator-precedence table for the parser. */ - -#define G 1 /* Greater than. */ -#define L 2 /* Less than. */ -#define E 3 /* Equal. */ -#define R 4 /* Error. */ - -static char prectable[11][11] = { - /* $ + - * / ^ u- ( ) v , */ -/* $ */ { R, L, L, L, L, L, L, L, R, L, R }, -/* + */ { G, G, G, L, L, L, L, L, G, L, G }, -/* - */ { G, G, G, L, L, L, L, L, G, L, G }, -/* * */ { G, G, G, G, G, L, L, L, G, L, G }, -/* / */ { G, G, G, G, G, L, L, L, G, L, G }, -/* ^ */ { G, G, G, G, G, L, L, L, G, L, G }, -/* u-*/ { G, G, G, G, G, G, G, L, G, L, R }, -/* ( */ { R, L, L, L, L, L, L, L, E, L, L }, -/* ) */ { G, G, G, G, G, G, G, R, G, R, G }, -/* v */ { G, G, G, G, G, G, G, G, G, R, G }, -/* , */ { G, L, L, L, L, L, L, L, G, L, G } - -} ; - -/* Return an expr. */ - -static INPparseNode * -PTparse(char **line) -{ - PTelement stack[PT_STACKSIZE]; - int sp = 0, st, i; - PTelement *top, *next; - INPparseNode *pn, *lpn, *rpn; - - stack[0].token = TOK_END; - next = PTlexer(line); - - while ((sp > 1) || (next->token != TOK_END)) { - /* Find the top-most terminal. */ - i = sp; - do { - top = &stack[i--]; - } while (top->token == TOK_VALUE); - - - switch (prectable[top->token][next->token]) { - case L: - case E: - /* Push the token read. */ - if (sp == (PT_STACKSIZE - 1)) { - fprintf(stderr, "Error: stack overflow\n"); - return (NULL); - } - bcopy((char *) next, (char *) &stack[++sp], - sizeof (PTelement)); - next = PTlexer(line); - continue; - - case R: - fprintf(stderr, "Syntax error.\n"); - return (NULL); - - case G: - /* Reduce. Make st and sp point to the elts on the - * stack at the end and beginning of the junk to - * reduce, then try and do some stuff. When scanning - * back for a <, ignore VALUES. - */ - st = sp; - if (stack[sp].token == TOK_VALUE) - sp--; - while (sp > 0) { - if (stack[sp - 1].token == TOK_VALUE) - i = 2; /* No 2 pnodes together... */ - else - i = 1; - if (prectable[stack[sp - i].token] - [stack[sp].token] == L) - break; - else - sp = sp - i; - } - if (stack[sp - 1].token == TOK_VALUE) - sp--; - /* Now try and see what we can make of this. - * The possibilities are: - node - * node op node - * ( node ) - * func ( node ) - * func ( node, node, node, ... ) <- new - * node - */ - if (st == sp) { - pn = makepnode(&stack[st]); - if (pn == NULL) - goto err; - } else if ((stack[sp].token == TOK_UMINUS) && - (st == sp + 1)) { - lpn = makepnode(&stack[st]); - if (lpn == NULL) - goto err; - pn = mkfnode("-", lpn); - } else if ((stack[sp].token == TOK_LPAREN) && - (stack[st].token == TOK_RPAREN)) { - pn = makepnode(&stack[sp + 1]); - if (pn == NULL) - goto err; - } else if ((stack[sp + 1].token == TOK_LPAREN) && - (stack[st].token == TOK_RPAREN)) { - lpn = makepnode(&stack[sp + 2]); - if ((lpn == NULL) || (stack[sp].type != TYP_STRING)) - goto err; - if (!(pn = mkfnode(stack[sp].value.string, lpn))) - return (NULL); - } else { /* node op node */ - lpn = makepnode(&stack[sp]); - rpn = makepnode(&stack[st]); - if ((lpn == NULL) || (rpn == NULL)) - goto err; - pn = mkbnode(stack[sp + 1].token, lpn, rpn); - } - stack[sp].token = TOK_VALUE; - stack[sp].type = TYP_PNODE; - stack[sp].value.pnode = pn; - continue; - } - } - pn = makepnode(&stack[1]); - if (pn) - return (pn); -err: - fprintf(stderr, "Syntax error.\n"); - return (NULL); -} - -/* Given a pointer to an element, make a pnode out of it (if it already - * is one, return a pointer to it). If it isn't of type VALUE, then return - * NULL. - */ - -static INPparseNode * -makepnode(PTelement *elem) -{ - if (elem->token != TOK_VALUE) - return (NULL); - - switch (elem->type) { - case TYP_STRING: - return (mksnode(elem->value.string)); - - case TYP_NUM: - return (mknnode(elem->value.real)); - - case TYP_PNODE: - return (elem->value.pnode); - - default: - fprintf(stderr, "Internal Error: bad token type\n"); - return (NULL); - } -} - -/* Binop node. */ - -static INPparseNode * -mkbnode(int opnum, INPparseNode *arg1, INPparseNode *arg2) -{ - INPparseNode *p; - int i; - - for (i = 0; i < NUM_OPS; i++) - if (ops[i].number == opnum) - break; - - if (i == NUM_OPS) { - fprintf(stderr, "Internal Error: no such op num %d\n", - opnum); - return (NULL); - } - p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - - p->type = opnum; - p->funcname = ops[i].name; - p->function = ops[i].funcptr; - p->left = arg1; - p->right = arg2; - - return (p); -} - -static INPparseNode * -mkfnode(char *fname, INPparseNode *arg) -{ - int i; - INPparseNode *p; - char buf[128], *name, *s; - IFvalue temp; - - /* Make sure the case is ok. */ - (void) strcpy(buf, fname); - for (s = buf; *s; s++) - if (isupper(*s)) - *s = tolower(*s); - - p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - - if (!strcmp(buf, "v")) { - name = MALLOC(128); - if (arg->type == PT_PLACEHOLDER) { - strcpy(name, arg->funcname); - } else if (arg->type == PT_CONSTANT) { - (void) sprintf(name, "%d", (int) arg->constant); - } else if (arg->type != PT_COMMA) { - fprintf(stderr, "Error: badly formed node voltage\n"); - return (NULL); - } - - if (arg->type == PT_COMMA) { - /* Change v(a,b) into v(a) - v(b) */ - p = mkb(PT_MINUS, mkfnode(fname, arg->left), - mkfnode(fname, arg->right)); - } else { - /* printf("getting a node called '%s'\n", name); */ - INPtermInsert(circuit, &name, tables, &(temp.nValue)); - for (i = 0; i < numvalues; i++) - if ((types[i] == IF_NODE) && (values[i].nValue == - temp.nValue)) - break; - if (i == numvalues) { - if (numvalues) { - values = (IFvalue *) - REALLOC((char *) values, (numvalues + 1) * sizeof (IFvalue)); - types = (int *) - REALLOC((char *) types, (numvalues + 1) * sizeof (int)); - } else { - values = (IFvalue *) MALLOC(sizeof (IFvalue)); - types = (int *) MALLOC(sizeof (int)); - } - values[i] = temp; - types[i] = IF_NODE; - numvalues++; - } - p->valueIndex = i; - p->type = PT_VAR; - } - } else if (!strcmp(buf, "i")) { - name = MALLOC(128); - if (arg->type == PT_PLACEHOLDER) - strcpy(name, arg->funcname); - else if (arg->type == PT_CONSTANT) - (void) sprintf(name, "%d", (int) arg->constant); - else { - fprintf(stderr, "Error: badly formed branch current\n"); - return (NULL); - } -/* printf("getting a device called '%s'\n", name); */ - INPinsert(&name, tables); - for (i = 0; i < numvalues; i++) - if ((types[i] == IF_INSTANCE) && (values[i].uValue == - temp.uValue)) - break; - if (i == numvalues) { - if (numvalues) { - values = (IFvalue *) - REALLOC((char *) values, (numvalues + 1) * sizeof (IFvalue)); - types = (int *) - REALLOC((char *) types, (numvalues + 1) * sizeof (int)); - } else { - values = (IFvalue *) MALLOC(sizeof (IFvalue)); - types = (int *) MALLOC(sizeof (int)); - } - values[i].uValue = (IFuid) name; - types[i] = IF_INSTANCE; - numvalues++; - } - p->valueIndex = i; - p->type = PT_VAR; - } else { - for (i = 0; i < NUM_FUNCS; i++) - if (!strcmp(funcs[i].name, buf)) - break; - - if (i == NUM_FUNCS) { - fprintf(stderr, "Error: no such function '%s'\n", buf); - return (NULL); - } - - p->type = PT_FUNCTION; - p->left = arg; - p->funcname = funcs[i].name; - p->funcnum = funcs[i].number; - p->function = funcs[i].funcptr; - } - - return (p); -} - -/* Number node. */ - -static INPparseNode * -mknnode(double number) -{ - struct INPparseNode *p; - - p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - - p->type = PT_CONSTANT; - p->constant = number; - - return (p); -} - -/* String node. */ - -static INPparseNode * -mksnode(char *string) -{ - int i, j; - char buf[128], *s; - INPparseNode *p; - - /* Make sure the case is ok. */ - (void) strcpy(buf, string); - for (s = buf; *s; s++) - if (isupper(*s)) - *s = tolower(*s); - - p = (INPparseNode *) MALLOC(sizeof (INPparseNode)); - - /* First see if it's something special. */ - for (i = 0; i < ft_sim->numSpecSigs; i++) - if (!strcmp(ft_sim->specSigs[i], buf)) - break; - if (i < ft_sim->numSpecSigs) { - for (j = 0; j < numvalues; j++) - if ((types[j] == IF_STRING) && !strcmp(buf, - values[i].sValue)) - break; - if (j == numvalues) { - if (numvalues) { - values = (IFvalue *) - REALLOC((char *) values, (numvalues + 1) * sizeof (IFvalue)); - types = (int *) - REALLOC((char *) types, (numvalues + 1) * sizeof (int)); - } else { - values = (IFvalue *) MALLOC(sizeof (IFvalue)); - types = (int *) MALLOC(sizeof (int)); - } - values[i].sValue = MALLOC(strlen(buf) + 1); - strcpy(values[i].sValue, buf); - types[i] = IF_STRING; - numvalues++; - } - p->valueIndex = i; - p->type = PT_VAR; - return (p); - } - - for (i = 0; i < NUM_CONSTANTS; i++) - if (!strcmp(constants[i].name, buf)) - break; - - if (i == NUM_CONSTANTS) { - /* We'd better save this in case it's part of i(something). */ - p->type = PT_PLACEHOLDER; - p->funcname = string; - } else { - p->type = PT_CONSTANT; - p->constant = constants[i].value; - } - - return (p); -} - -/* The lexical analysis routine. */ - -static PTelement * -PTlexer(char **line) -{ - double td; - int err; - static PTelement el; - static char *specials = " \t()^+-*/,"; - static int lasttoken = TOK_END, lasttype; - char *sbuf, *s; - - sbuf = *line; -#ifdef notdef - printf("entering lexer, sbuf = '%s', lastoken = %d, lasttype = %d\n", - sbuf, lasttoken, lasttype); -#endif - while ((*sbuf == ' ') || (*sbuf == '\t') || (*sbuf == '=')) - sbuf++; - - switch (*sbuf) { - case '\0': - el.token = TOK_END; - break; - - case ',': - el.token = TOK_COMMA; - sbuf++; - break; - - case '-': - if ((lasttoken == TOK_VALUE) || (lasttoken == TOK_RPAREN)) - el.token = TOK_MINUS; - else - el.token = TOK_UMINUS; - sbuf++; - break; - - case '+': - el.token = TOK_PLUS; - sbuf++; - break; - - case '*': - el.token = TOK_TIMES; - sbuf++; - break; - - case '/': - el.token = TOK_DIVIDE; - sbuf++; - break; - - case '^': - el.token = TOK_POWER; - sbuf++; - break; - - case '(': - if (((lasttoken == TOK_VALUE) && ((lasttype == TYP_NUM))) || - (lasttoken == TOK_RPAREN)) { - el.token = TOK_END; - } else { - el.token = TOK_LPAREN; - sbuf++; - } - break; - - case ')': - el.token = TOK_RPAREN; - sbuf++; - break; - - default: - if ((lasttoken == TOK_VALUE) || (lasttoken == TOK_RPAREN)) { - el.token = TOK_END; - break; - } - - td = INPevaluate(&sbuf, &err, 1); - if (err == OK) { - el.token = TOK_VALUE; - el.type = TYP_NUM; - el.value.real = td; - } else { - el.token = TOK_VALUE; - el.type = TYP_STRING; - for (s = sbuf; *s; s++) - if (index(specials, *s)) - break; - el.value.string = MALLOC(s - sbuf + 1); - strncpy(el.value.string, sbuf, s - sbuf); - el.value.string[s - sbuf] = '\0'; - sbuf = s; - } - } - - lasttoken = el.token; - lasttype = el.type; - - *line = sbuf; - -/* printf("PTlexer: token = %d, type = %d, left = '%s'\n", - el.token, el.type, sbuf); */ - - return (&el); -} - -#ifdef notdef - -/* Debugging stuff. */ - -#ifdef __STDC__ -void printTree(INPparseNode*); -#else /* stdc */ -void printTree(); -#endif /* stdc */ -void -INPptPrint(str, ptree) - char *str; - IFparseTree *ptree; -{ - int i; - - printf("%s\n\t", str); - printTree(((INPparseTree *) ptree)->tree); - printf("\n"); - for (i = 0; i < ptree->numVars; i++) { - printf("d / d v%d : ", i); - printTree(((INPparseTree *) ptree)->derivs[i]); - printf("\n"); - } - return; -} - -void -printTree(pt) - INPparseNode *pt; -{ - switch (pt->type) { - case PT_CONSTANT: - printf("%g", pt->constant); - break; - - case PT_VAR: - printf("v%d", pt->valueIndex); - break; - - case PT_PLUS: - printf("("); - printTree(pt->left); - printf(") + ("); - printTree(pt->right); - printf(")"); - break; - - case PT_MINUS: - printf("("); - printTree(pt->left); - printf(") - ("); - printTree(pt->right); - printf(")"); - break; - - case PT_TIMES: - printf("("); - printTree(pt->left); - printf(") * ("); - printTree(pt->right); - printf(")"); - break; - - case PT_DIVIDE: - printf("("); - printTree(pt->left); - printf(") / ("); - printTree(pt->right); - printf(")"); - break; - - case PT_POWER: - printf("("); - printTree(pt->left); - printf(") ^ ("); - printTree(pt->right); - printf(")"); - break; - - case PT_FUNCTION: - printf("%s (", pt->funcname); - printTree(pt->left); - printf(")"); - break; - - default: - printf("oops"); - break; - } - return; -} - -#endif diff --git a/src/circuit/inpsymt.c b/src/circuit/inpsymt.c deleted file mode 100644 index b228bd20c..000000000 --- a/src/circuit/inpsymt.c +++ /dev/null @@ -1,280 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Stuff for the terminal and node symbol tables. - * Defined: INPtabInit, INPinsert, INPtermInsert, INPtabEnd - */ -/* MW. Special INPinsertNofree for routines from spiceif.c and outif.c */ - -#include "ngspice.h" -#include /* Take this out soon. */ -#include "ifsim.h" -#include "iferrmsg.h" -#include "inpdefs.h" -#include "cpstd.h" -#include "fteext.h" -#include "inp.h" - - -static int hash(char *name, int tsize); - -/* Initialize the symbol tables. */ - -INPtables * -INPtabInit(int numlines) -{ - INPtables *tab; - - tab = (INPtables *)tmalloc(sizeof(INPtables)); - tab->INPsymtab = (struct INPtab **) tmalloc((numlines / 4 + 1) * - sizeof (struct INPtab *)); - ZERO(tab->INPsymtab, (numlines / 4 + 1) * sizeof (struct INPtab *)); - tab->INPtermsymtab = (struct INPnTab **) tmalloc(numlines * - sizeof (struct INPnTab *)); - ZERO(tab->INPtermsymtab, numlines * sizeof (struct INPnTab *)); - tab->INPsize = numlines / 4 + 1; - tab->INPtermsize = numlines; - return(tab); -} - -/* insert 'token' into the terminal symbol table */ -/* create a NEW NODE and return a pointer to it in *node */ - -int -INPtermInsert(void *ckt, char **token, INPtables *tab, void **node) -{ - int key; - int error; - struct INPnTab *t; - - key = hash(*token, tab->INPtermsize); - for (t = tab->INPtermsymtab[key]; t; t = t->t_next) { - if (!strcmp(*token, t->t_ent)) { - FREE(*token); - *token = t->t_ent; - if(node) *node = t->t_node; - return(E_EXISTS); - } - } - t = (struct INPnTab *) tmalloc(sizeof (struct INPnTab)); - if(t == (struct INPnTab*)NULL) return(E_NOMEM); - ZERO(t,struct INPnTab); - error = (*(ft_sim->newNode))(ckt,&t->t_node,*token); - if(error) return(error); - if(node) *node = t->t_node; - t->t_ent = *token; - t->t_next = tab->INPtermsymtab[key]; - tab->INPtermsymtab[key] = t; - return(OK); -} - - -/* insert 'token' into the terminal symbol table */ -/* USE node as the node pointer */ - - -int -INPmkTerm(void *ckt, char **token, INPtables *tab, void **node) -{ - int key; - struct INPnTab *t; - - key = hash(*token, tab->INPtermsize); - for (t = tab->INPtermsymtab[key]; t; t = t->t_next) { - if (!strcmp(*token, t->t_ent)) { - FREE(*token); - *token = t->t_ent; - if(node) *node = t->t_node; - return(E_EXISTS); - } - } - t = (struct INPnTab *) tmalloc(sizeof (struct INPnTab)); - if(t == (struct INPnTab*)NULL) return(E_NOMEM); - ZERO(t,struct INPnTab); - t->t_node = *node ; - t->t_ent = *token; - t->t_next = tab->INPtermsymtab[key]; - tab->INPtermsymtab[key] = t; - return(OK); -} - -/* insert 'token' into the terminal symbol table as a name for ground*/ - -int -INPgndInsert(void *ckt, char **token, INPtables *tab, void **node) -{ - int key; - int error; - struct INPnTab *t; - - key = hash(*token, tab->INPtermsize); - for (t = tab->INPtermsymtab[key]; t; t = t->t_next) { - if (!strcmp(*token, t->t_ent)) { - FREE(*token); - *token = t->t_ent; - if(node) *node = t->t_node; - return(E_EXISTS); - } - } - t = (struct INPnTab *) tmalloc(sizeof (struct INPnTab)); - if(t == (struct INPnTab*)NULL) return(E_NOMEM); - ZERO(t,struct INPnTab); - error = (*(ft_sim->groundNode))(ckt,&t->t_node,*token); - if(error) return(error); - if(node) *node = t->t_node; - t->t_ent = *token; - t->t_next = tab->INPtermsymtab[key]; - tab->INPtermsymtab[key] = t; - return(OK); -} - -/* retrieve 'token' from the symbol table */ - -int -INPretrieve(char **token, INPtables *tab) -{ - struct INPtab *t; - int key; - - key = hash(*token, tab->INPsize); - for (t = tab->INPsymtab[key]; t; t = t->t_next) - if (!strcmp(*token, t->t_ent)) { - *token = t->t_ent; - return(OK); - } - return(E_BADPARM); -} - - -/* insert 'token' into the symbol table */ - -int -INPinsert(char **token, INPtables *tab) -{ - struct INPtab *t; - int key; - - key = hash(*token, tab->INPsize); - for (t = tab->INPsymtab[key]; t; t = t->t_next) - if (!strcmp(*token, t->t_ent)) { - FREE(*token); - *token = t->t_ent; - return(E_EXISTS); - } - t = (struct INPtab *) tmalloc(sizeof (struct INPtab)); - if(t == (struct INPtab*)NULL) return(E_NOMEM); - ZERO(t,struct INPtab); - t->t_ent = *token; - t->t_next = tab->INPsymtab[key]; - tab->INPsymtab[key] = t; - return(OK); -} - - -/* MW. insert 'token' into the symbol table but no free() token pointer. -* Calling routine should take care for this */ - -int -INPinsertNofree(char **token, INPtables *tab) -{ - struct INPtab *t; - int key; - - key = hash(*token, tab->INPsize); - for (t = tab->INPsymtab[key]; t; t = t->t_next) - if (!strcmp(*token, t->t_ent)) { - - /* MW. We can't touch memory pointed by token now */ - *token = t->t_ent; - return(E_EXISTS); - } - t = (struct INPtab *) tmalloc(sizeof (struct INPtab)); - if(t == (struct INPtab*)NULL) return(E_NOMEM); - ZERO(t,struct INPtab); - t->t_ent = *token; - t->t_next = tab->INPsymtab[key]; - tab->INPsymtab[key] = t; - return(OK); -} - -/* remove 'token' from the symbol table */ -int -INPremove(char *token, INPtables *tab) -{ - struct INPtab *t, **prevp; - int key; - - key = hash(token, tab->INPsize); - prevp = &tab->INPsymtab[key]; - for (t = *prevp; t && token != t->t_ent; t = t->t_next) - prevp = &t->t_next; - if (!t) - return OK; - - *prevp = t->t_next; - tfree(t->t_ent); - tfree(t); - - return OK; -} - -/* remove 'token' from the symbol table */ -int -INPremTerm(char *token, INPtables *tab) -{ - struct INPnTab *t, **prevp; - int key; - - key = hash(token, tab->INPtermsize); - prevp = &tab->INPtermsymtab[key]; - for (t = *prevp; t && token != t->t_ent; t = t->t_next) - prevp = &t->t_next; - if (!t) - return OK; - - *prevp = t->t_next; - tfree(t->t_ent); - tfree(t); - - return OK; -} - -/* Free the space used by the symbol tables. */ - -void -INPtabEnd(INPtables *tab) -{ - struct INPtab *t, *lt; - struct INPnTab *n, *ln; - int i; - - for (i = 0; i < tab->INPsize; i++) - for (t = tab->INPsymtab[i]; t; t = lt) { - lt = t->t_next; - FREE(t); /* But not t_ent ! */ - } - FREE(tab->INPsymtab); - for (i = 0; i < tab->INPtermsize; i++) - for (n = tab->INPtermsymtab[i]; n; n = ln) { - ln = n->t_next; - FREE(n); /* But not t_ent ! */ - } - FREE(tab->INPtermsymtab); - FREE(tab); - return; -} - -static int -hash(char *name, int tsize) -{ - char *s; - register int i = 0; - - for (s = name; *s; s++) - i += *s; - return (i % tsize); -} - diff --git a/src/circuit/inptyplk.c b/src/circuit/inptyplk.c deleted file mode 100644 index ec23011ad..000000000 --- a/src/circuit/inptyplk.c +++ /dev/null @@ -1,30 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* look up the 'type' in the device description struct and return the - * appropriatestrchr for the device found, or -1 for not found - */ - -#include "ngspice.h" -#include "inpdefs.h" -#include "cpdefs.h" -#include "fteext.h" -#include "ifsim.h" -#include "inp.h" - -int -INPtypelook(char *type) -{ - - int i; - for(i=0;inumDevices;i++) { - if(strcmp(type,(*(ft_sim->devices)[i]).name)==0) { - /*found the device - return it */ - return(i); - } - } - return(-1); -} - diff --git a/src/circuit/ptfuncs.c b/src/circuit/ptfuncs.c deleted file mode 100644 index 69783bdcb..000000000 --- a/src/circuit/ptfuncs.c +++ /dev/null @@ -1,244 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * All the functions used in the parse tree. These functions return HUGE - * if their argument is out of range. - */ - -#include -#include "ngspice.h" -#include -#include "fteext.h" -#include "ifsim.h" -#include "inpptree.h" -#include "inp.h" - -/* XXX These should be in math.h */ - - -#ifndef HAVE_ATANH -extern double asinh(), acosh(), atanh(); -#endif - -double PTfudge_factor; - -#define MODULUS(NUM,LIMIT) ((NUM) - ((int) ((NUM) / (LIMIT))) * (LIMIT)) - -double -PTabs(double arg) -{ - return arg >= 0.0 ? arg : -arg; -} - -double -PTsgn(double arg) -{ - return arg > 0.0 ? 1.0 : arg < 0.0 ? -1.0 : 0.0; -} - -double -PTplus(double arg1, double arg2) -{ - return (arg1 + arg2); -} - -double -PTminus(double arg1, double arg2) -{ - return (arg1 - arg2); -} - -double -PTtimes(double arg1, double arg2) -{ - return (arg1 * arg2); -} - -double -PTdivide(double arg1, double arg2) -{ - if (arg2 >= 0.0) - arg2 += PTfudge_factor; - else - arg2 -= PTfudge_factor; - - if (arg2 == 0.0) - return (HUGE); - - return (arg1 / arg2); -} - -double -PTpower(double arg1, double arg2) -{ - if (arg1 < 0.0) { - if (fabs(arg2 - ((int) arg2)) / (arg2 + 0.001) < 0.000001) { - arg2 = (int) arg2; - } else { - arg1 = -arg1; - } - } - return (pow(arg1, arg2)); -} - -double -PTacos(double arg) -{ - return (acos(arg)); -} - -double -PTacosh(double arg) -{ -#ifdef HAVE_ACOSH - return (acosh(arg)); -#else - if (arg < 1.0) - arg = 1.0; - return (log(arg + sqrt(arg*arg-1.0))); -#endif -} - -double -PTasin(double arg) -{ - return (asin(arg)); -} - -double -PTasinh(double arg) -{ -#ifdef HAVE_ASINH - return (asinh(arg)); -#else - return log(arg + sqrt(arg * arg + 1.0)); -#endif -} - -double -PTatan(double arg) -{ - return (atan(arg)); -} - -double -PTatanh(double arg) -{ -#ifdef HAVE_ATANH - return (atanh(arg)); -#else - if (arg < -1.0) - arg = -1.0 + PTfudge_factor + 1e-10; - else if (arg > 1.0) - arg = 1.0 - PTfudge_factor - 1e-10; - return (log((1.0 + arg) / (1.0 - arg)) / 2.0); -#endif -} - -double -PTustep(double arg) -{ - if (arg < 0.0) - return 0.0; - else if (arg > 0.0) - return 1.0; - else - return 0.5; /* Ick! */ -} - -double -PTuramp(double arg) -{ - if (arg < 0.0) - return 0.0; - else - return arg; -} - -double -PTcos(double arg) -{ - return (cos(MODULUS(arg, 2 * M_PI))); -} - -double -PTcosh(double arg) -{ - return (cosh(arg)); -} - -double -PTexp(double arg) -{ - return (exp(arg)); -} - -double -PTln(double arg) -{ - if (arg < 0.0) -#ifdef EXPERIMENTAL_CODE - return (HUGE); -#else - arg = -arg; -#endif - return (log(arg)); -} - -double -PTlog(double arg) -{ - if (arg <= 0.0) -#ifdef EXPERIMENTAL_CODE - return (HUGE); -#else - arg = -arg; -#endif - return (log10(arg)); -} - -double -PTsin(double arg) -{ - return (sin(MODULUS(arg, 2 * M_PI))); -} - -double -PTsinh(double arg) -{ - return (sinh(arg)); -} - -double -PTsqrt(double arg) -{ - if (arg < 0.0) -#ifdef EXPERIMENTAL_CODE - return (HUGE); -#else - arg = -arg; -#endif - return (sqrt(arg)); -} - -double -PTtan(double arg) -{ - return (tan(MODULUS(arg, M_PI))); -} - -double -PTtanh(double arg) -{ - return (tanh(arg)); -} - -double -PTuminus(double arg) -{ - return (- arg); -} - diff --git a/src/circuit/sperror.c b/src/circuit/sperror.c deleted file mode 100644 index 17760307e..000000000 --- a/src/circuit/sperror.c +++ /dev/null @@ -1,137 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* - * provide the error message appropriate for the given error code - */ - -#include "ngspice.h" -#include -#include "fteext.h" -#include "sperror.h" -#include "cktdefs.h" -#include "ifsim.h" -#include "inp.h" - -#define MSG(a) \ - msg = a; \ - break; - -static char *unknownError = "Unknown error code"; -static char *Pause = "Pause requested"; -static char *intern = "Impossible error - can't occur"; -static char *exists = "Device already exists, existing one being used"; -static char *nodev = "No such device"; -static char *noterm = "No such terminal on this device"; -static char *nomod = "No such model"; -static char *badparm = "No such parameter on this device"; -static char *nomem = "Out of Memory"; -static char *nodecon = "Node already connected; connection replaced"; -static char *unsupp = "operation not supported"; -static char *parmval = "parameter value out of range or the wrong type"; -static char *badmatrix = "Matrix can't be decomposed as is"; -static char *singular = "Matrix is singular"; -static char *iterlim = "Iteration limit reached"; -static char *order = "Unsupported integration order"; -static char *method = "Unsupported integration method"; -static char *timestep = "Timestep too small"; -static char *xmission = "transmission lines not supported by pole-zero"; -static char *toobig = "magnitude overflow"; -static char *isshort = "input or output shorted"; -static char *inisout = "transfer function is 1"; -static char *nodisto = "Distortion analysis not present"; -static char *nonoise = "Noise analysis not present"; -static char *noacinput = "AC input not found"; -static char *noanal = "No such analysis type"; -static char *nochange = "Unsupported action; no change made"; -static char *notfound = "Not found"; -static char *nof2src = "No F2 source for IM disto analysis"; -#ifdef PARALLEL_ARCH -static char *multierr = "Multiple errors detected by parallel machine"; -#endif /* PARALLEL_ARCH */ - -char * -SPerror(int type) -{ - char *val; - char *msg; - - switch(type) { - default: - MSG(unknownError) - case E_PAUSE: - MSG(Pause) - case OK: - return(NULL); - case E_INTERN: - MSG(intern) - case E_EXISTS: - MSG(exists) - case E_NODEV: - MSG(nodev) - case E_NOMOD: - MSG(nomod) - case E_NOTERM: - MSG(noterm) - case E_BADPARM: - MSG(badparm) - case E_NOMEM: - MSG(nomem) - case E_NODECON: - MSG(nodecon) - case E_UNSUPP: - MSG(unsupp) - case E_PARMVAL: - MSG(parmval) - case E_BADMATRIX: - MSG(badmatrix) - case E_SINGULAR: - MSG(singular) - case E_ITERLIM: - MSG(iterlim) - case E_ORDER: - MSG(order) - case E_METHOD: - MSG(method) - case E_TIMESTEP: - MSG(timestep) - case E_XMISSIONLINE: - MSG(xmission) - case E_MAGEXCEEDED: - MSG(toobig) - case E_SHORT: - MSG(isshort) - case E_INISOUT: - MSG(inisout) - case E_NODISTO: - MSG(nodisto) - case E_NONOISE: - MSG(nonoise) - case E_NOANAL: - MSG(noanal) - case E_NOCHANGE: - MSG(nochange) - case E_NOTFOUND: - MSG(notfound) - case E_NOACINPUT: - MSG(noacinput) - case E_NOF2SRC: - MSG(nof2src) -#ifdef PARALLEL_ARCH - case E_MULTIERR: - MSG(multierr) -#endif /* PARALLEL_ARCH */ - } - - val = MALLOC(strlen(msg) + 1); - if (val) { - (void) strcpy(val, msg); - } -#ifdef notdef - else - (*(SPfrontEnd->IFerror))(ERR_PANIC,nomem,(IFuid *)NULL); -#endif - return(val); -} diff --git a/src/frontend/agraf.c b/src/frontend/agraf.c deleted file mode 100644 index e036221d0..000000000 --- a/src/frontend/agraf.c +++ /dev/null @@ -1,334 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Line-printer (ASCII) plots. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "fteparse.h" -#include "agraf.h" - -#define FUDGE 7 -#define MARGIN_BASE 11 -#define LCHAR '.' -#define MCHAR 'X' -#define PCHARS "+*=$%!0123456789" - -/* We should really deal with the xlog and delta arguments. This routine is - * full of magic numbers that make the formatting correct. - */ - - -void -ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, struct dvec *vecs, double xdel, double ydel, bool xlog, bool ylog, bool nointerp) -{ - int height; - bool nobreakp, novalue; - int maxx, maxy, omaxy; /* The size of the plotting area. */ - bool /* xlogscale = FALSE, */ ylogscale = FALSE; - char *field, buf[BSIZE_SP]; - char *line1, *line2, c, cb; - double xrange[2], yrange[2], x1, x2, yy1, y2, x, y; - int mag, hmt, lmt, dst, spacing, nsp, ypt, upper, lower, curline; - double tenpowmag, diff, *values; - struct dvec *v; - int margin = MARGIN_BASE; - int omargin; - register int i, j, k; - int shift; - - - /* ANSI C does not specify how many digits are in an exponent for %c - * We assumed it was 2. If it's more, shift starting position over. - */ - (void) sprintf(buf, "%1.1e", 0.0); /* expect 0.0e+00 */ - shift = strlen(buf) - 7; - margin += shift; - - /* Make sure the margin is correct */ - omargin = margin; - if (!cp_getvar("noasciiplotvalue", VT_BOOL, (char *) &novalue) && - !vec_eq(xscale, vecs)) { - margin *= 2; - } else - novalue = TRUE; - if ((xscale->v_gridtype == GRID_YLOG) || - (xscale->v_gridtype == GRID_LOGLOG)) - ylogscale = TRUE; - if (!cp_getvar("width", VT_NUM, (char *) &maxy)) { - maxy = DEF_WIDTH; - } - if (!cp_getvar("height", VT_NUM, (char *) &height)) - height = DEF_HEIGHT; - if (ft_nopage) - nobreakp = TRUE; - else - cp_getvar("nobreak", VT_BOOL, (char *) &nobreakp); - maxy -= (margin + FUDGE); - maxx = xscale->v_length; - xrange[0] = xlims[0]; - xrange[1] = xlims[1]; - yrange[0] = ylims[0]; - yrange[1] = ylims[1]; - - if (maxx < 2) { - fprintf(cp_err, - "Error: asciiplot can't handle scale with length < 2\n"); - return; - } - - if (maxx <= 0) { - fprintf(cp_err, "Note: no points to plot\n"); - return; - } - - for (v = vecs, i = 0; v; v = v->v_link2) { - v->v_linestyle = (PCHARS[i] ? PCHARS[i++] : '#'); - } - /* Now allocate the field and stuff. */ - field = tmalloc((maxy + 1) * (maxx + 1)); - line1 = tmalloc(maxy + margin + FUDGE + 1); - line2 = tmalloc(maxy + margin + FUDGE + 1); - if (!novalue) - values = (double *) tmalloc(maxx * sizeof (double)); - - /* Clear the field, put the lines in the right places, and create - * the headers. - */ - for (i = 0, j = (maxx + 1) * (maxy + 1); i < j; i++) - field[i] = ' '; - for (i = 0, j = maxy + margin + FUDGE; i < j; i++) { - line1[i] = '-'; - line2[i] = ' '; - } - line1[j] = line2[j] = '\0'; - - /* The following is similar to the stuff in grid.c */ - if ((xrange[0] > xrange[1]) || (yrange[0] > yrange[1])) { - fprintf(cp_err, - "ft_agraf: Internal Error: bad limits %g, %g, %g, %g\n", - xrange[0], xrange[1], yrange[0], yrange[1]); - return; - } - - /* gcc doesn't like !double */ - if (ylims[1] == 0.0) { - mag = (int) floor(mylog10(- ylims[0])); - tenpowmag = pow(10.0, (double) mag); - } else if (ylims[0] == 0.0) { - mag = (int) floor(mylog10(ylims[1])); - tenpowmag = pow(10.0, (double) mag); - } else { - diff = ylims[1] - ylims[0]; - mag = (int) floor(mylog10(diff)); - tenpowmag = pow(10.0, (double) mag); - } - - lmt = (int) floor(ylims[0] / tenpowmag); - yrange[0] = ylims[0] = lmt * tenpowmag; - hmt = (int) ceil(ylims[1] / tenpowmag); - yrange[1] = ylims[1] = hmt * tenpowmag; - - dst = hmt - lmt; - - /* This is a strange case; I don't know why it's here. */ - if (dst == 11) - dst = 12; - else if (dst == 1) { - dst = 10; - mag++; - hmt *= 10.0; - lmt *= 10.0; - } else if (dst == 0) { - dst = 2; - lmt -= 1; - hmt += 1; - } - - for (nsp = 4; nsp < 8; nsp++) - if (!(dst % nsp)) - break; - if (nsp == 8) - for (nsp = 2; nsp < 4; nsp++) - if (!(dst % nsp)) - break; - spacing = maxy / nsp; - - /* Reset the max X coordinate to deal with round-off error. */ - omaxy = maxy + 1; - maxy = spacing * nsp; - - for (i = 0, j = lmt; j <= hmt; i += spacing, j += dst / nsp) { - for (k = 0; k < maxx; k++) - field[k * omaxy + i] = LCHAR; - line1[i + margin + 2 * shift] = '|'; - (void) sprintf(buf, "%.2e", j * pow(10.0, (double) mag)); - bcopy(buf, &line2[i + margin - ((j < 0) ? 2 : 1) - shift], - strlen(buf)); - } - line1[i - spacing + margin + 1] = '\0'; - - for (i = 1; i < omargin - 1 && xscale->v_name[i - 1]; i++) - line2[i] = xscale->v_name[i - 1]; - if (!novalue) - for (i = omargin + 1; - i < margin - 2 && (vecs->v_name[i - omargin - 1]); - i++) - line2[i] = vecs->v_name[i - omargin - 1]; - - /* Now the buffers are all set up properly. Plot points for each - * vector using interpolation. For each point on the x-axis, find the - * two bracketing points in xscale, and then interpolate their - * y values for each vector. - */ - - upper = lower = 0; - for (i = 0; i < maxx; i++) { - if (nointerp) - x = isreal(xscale) ? xscale->v_realdata[i] : - realpart(&xscale->v_compdata[i]); - else if (xlog && xrange[0] > 0.0 && xrange[1] > 0.0) - x = xrange[0] * pow( 10.0, mylog10(xrange[1]/xrange[0]) - * i / (maxx - 1)); - else - x = xrange[0] + (xrange[1] - xrange[0]) * i / - (maxx - 1); - while ((isreal(xscale) ? (xscale->v_realdata[upper] < x) : - (realpart(&xscale->v_compdata[upper]) < x)) && - (upper < xscale->v_length - 1)) - upper++; - while ((isreal(xscale) ? (xscale->v_realdata[lower] < x) : - (realpart(&xscale->v_compdata[lower]) < x)) && - (lower < xscale->v_length - 1)) - lower++; - if ((isreal(xscale) ? (xscale->v_realdata[lower] > x) : - (realpart(&xscale->v_compdata[lower]) > x)) && - (lower > 0)) - lower--; - x1 = (isreal(xscale) ? xscale->v_realdata[lower] : - realpart(&xscale->v_compdata[lower])); - x2 = (isreal(xscale) ? xscale->v_realdata[upper] : - realpart(&xscale->v_compdata[upper])); - if (x1 > x2) { - fprintf(cp_err, "Error: X scale (%s) not monotonic\n", - xscale->v_name); - return; - } - for (v = vecs; v; v = v->v_link2) { - yy1 = (isreal(v) ? v->v_realdata[lower] : - realpart(&v->v_compdata[lower])); - y2 = (isreal(v) ? v->v_realdata[upper] : - realpart(&v->v_compdata[upper])); - if (x1 == x2) - y = yy1; - else - y = yy1 + (y2 - yy1) * (x - x1) / (x2 - x1); - if (!novalue && (v == vecs)) - values[i] = y; - ypt = ft_findpoint(y, yrange, maxy, 0, ylogscale); - c = field[omaxy * i + ypt]; - if ((c == ' ') || (c == LCHAR)) - field[omaxy * i + ypt] = (char) v->v_linestyle; - else - field[omaxy * i + ypt] = MCHAR; - } - } - - out_init(); - for (i = 0; i < omaxy + margin; i++) - out_send("-"); - out_send("\n"); - i = (omaxy + margin - strlen(plot->pl_title)) / 2; - while (i-- > 0) - out_send(" "); - (void) strcpy(buf, plot->pl_title); - buf[maxy + margin] = '\0'; /* Cut off if too wide */ - out_send(buf); - out_send("\n"); - (void) sprintf(buf, "%s %s", plot->pl_name, plot->pl_date); - buf[maxy + margin] = '\0'; - i = (omaxy + margin - strlen(buf)) / 2; - while (i-- > 0) - out_send(" "); - out_send(buf); - out_send("\n\n"); - curline = 7; - out_send("Legend: "); - i = 0; - j = (maxx + margin - 8) / 20; - if (j == 0) - j = 1; - for (v = vecs; v; v = v->v_link2) { - out_pbuf[0] = (char) v->v_linestyle; - out_pbuf[1] = '\0'; -/* out_printf("%c = %-17s", (char) v->v_linestyle, v->v_name); */ - out_printf("%s = %-17s", out_pbuf, v->v_name); - if (!(++i % j) && v->v_link2) { - out_send("\n "); - curline++; - } - } - out_send("\n"); - for (i = 0; i < omaxy + margin; i++) - out_send("-"); - out_send("\n"); - i = 0; - out_printf("%s\n%s\n", line2, line1); - curline += 2; - for (i = 0; i < maxx; i++) { - if (nointerp) - x = isreal(xscale) ? xscale->v_realdata[i] : - realpart(&xscale->v_compdata[i]); - else if (xlog && xrange[0] > 0.0 && xrange[1] > 0.0) - x = xrange[0] * pow( 10.0, mylog10(xrange[1]/xrange[0]) - * i / (maxx - 1)); - else - x = xrange[0] + (xrange[1] - xrange[0]) * i / (maxx - 1); - if (x < 0.0) { - sprintf(out_pbuf, "%.3e ", x); - out_send(out_pbuf); -/* out_printf("%.3e ", x); */ - } else { - sprintf(out_pbuf, " %.3e ", x); - out_send(out_pbuf); -/* out_printf(" %.3e ", x); */ - } - if (!novalue) { - if (values[i] < 0.0) { - sprintf(out_pbuf, "%.3e ", values[i]); - out_send(out_pbuf); -/* out_printf("%.3e ", values[i]); */ - } else { - sprintf(out_pbuf, " %.3e ", values[i]); - out_send(out_pbuf); -/* out_printf(" %.3e ", values[i]); */ - } - } - cb = field[(i + 1) * omaxy]; - field[(i + 1) * omaxy] = '\0'; - out_send(&field[i * omaxy]); - field[(i + 1) * omaxy] = cb; - out_send("\n"); - if (((curline++ % height) == 0) && (i < maxx - 1) && - !nobreakp) { - out_printf("%s\n%s\n\014\n%s\n%s\n", line1, line2, - line2, line1); - curline += 5; - } - } - out_printf("%s\n%s\n", line1, line2); - - tfree(field); - tfree(line1); - tfree(line2); - if (!novalue) - tfree(values); - return; -} - diff --git a/src/frontend/agraf.h b/src/frontend/agraf.h deleted file mode 100644 index eb54ee764..000000000 --- a/src/frontend/agraf.h +++ /dev/null @@ -1,13 +0,0 @@ -/************* - * Header file for agraf.c - * 1999 E. Rouat - ************/ - -#ifndef AGRAF_H_INCLUDED -#define AGRAF_H_INCLUDED - -void ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, - struct dvec *vecs, double xdel, double ydel, bool xlog, bool ylog, - bool nointerp); - -#endif diff --git a/src/frontend/clip.c b/src/frontend/clip.c deleted file mode 100644 index d7da33f89..000000000 --- a/src/frontend/clip.c +++ /dev/null @@ -1,214 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopyher, U. C. Berkeley CAD Group -Author: 1982 Giles Billingsley -**********/ - -/* - * Some routines to do clipping of polygons, etc to boxes. Most of this code - * was rescued from MFB: - * sccsid "@(#)mfbclip.c 1.2 12/21/83" - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "clip.h" - - -#define POLYGONBUFSIZE 512 -/* XXX */ - -#define CODEMINX 1 -#define CODEMINY 2 -#define CODEMAXX 4 -#define CODEMAXY 8 -#define CODE(x,y,c) c = 0;\ - if (x < l)\ - c = CODEMINX;\ - else if (x > r)\ - c = CODEMAXX;\ - if (y < b)\ - c |= CODEMINY;\ - else if (y > t)\ - c |= CODEMAXY; - - -#define SWAPINT(a, b) { int xxxx = (a); (a) = (b); (b) = xxxx; } - -/* clip_line will clip a line to a rectangular area. The returned - * value is 'TRUE' if the line is out of the AOI (therefore does not - * need to be displayed) and 'FALSE' if the line is in the AOI. - */ - -bool -clip_line(int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t) -{ - int x1 = *pX1; - int y1 = *pY1; - int x2 = *pX2; - int y2 = *pY2; - int x,y,c,c1,c2; - - CODE(x1,y1,c1) - CODE(x2,y2,c2) - while (c1 || c2) { - if (c1 & c2) - return (TRUE); /* Line is invisible. */ - if (!(c = c1)) - c = c2; - if (c & CODEMINX) { - y = y1+(y2-y1)*(l-x1)/(x2-x1); - x = l; - } else if (c & CODEMAXX) { - y = y1+(y2-y1)*(r-x1)/(x2-x1); - x = r; - } else if (c & CODEMINY) { - x = x1+(x2-x1)*(b-y1)/(y2-y1); - y = b; - } else if (c & CODEMAXY) { - x = x1+(x2-x1)*(t-y1)/(y2-y1); - y = t; - } - if (c == c1) { - x1 = x; - y1 = y; - CODE(x,y,c1) - } else { - x2 = x; - y2 = y; - CODE(x,y,c2) - } - } - *pX1 = x1; - *pY1 = y1; - *pX2 = x2; - *pY2 = y2; - return (FALSE); /* Line is at least partially visible.*/ -} - -/* This routine will clip a line to a circle, returning TRUE if the line - * is entirely outside the circle. Note that we have to be careful not - * to switch the points around, since in grid.c we need to know which is - * the outer point for putting the label on. - */ - -bool -clip_to_circle(int *x1, int *y1, int *x2, int *y2, int cx, int cy, int rad) -{ - double perplen, a, b, c; - double tx, ty, dt; - double dtheta; - double theta1, theta2, tt, alpha, beta, gamma; - bool flip = FALSE; - int i; - - /* Get the angles between the origin and the endpoints. */ - if ((*x1-cx) || (*y1-cy)) - theta1 = atan2((double) *y1 - cy, (double) *x1 - cx); - else - theta1 = M_PI; - if ((*x2-cx) || (*y2-cy)) - theta2 = atan2((double) *y2 - cy, (double) *x2 - cx); - else - theta2 = M_PI; - - if (theta1 < 0.0) - theta1 = 2 * M_PI + theta1; - if (theta2 < 0.0) - theta2 = 2 * M_PI + theta2; - - dtheta = theta2 - theta1; - if (dtheta > M_PI) - dtheta = dtheta - 2 * M_PI; - else if (dtheta < - M_PI) - dtheta = 2 * M_PI - dtheta; - - /* Make sure that p1 is the first point */ - if (dtheta < 0) { - tt = theta1; - theta1 = theta2; - theta2 = tt; - i = *x1; - *x1 = *x2; - *x2 = i; - i = *y1; - *y1 = *y2; - *y2 = i; - flip = TRUE; - dtheta = -dtheta; - } - - /* Figure out the distances between the points */ - a = sqrt((double) ((*x1 - cx) * (*x1 - cx) + (*y1 - cy) * (*y1 - cy))); - b = sqrt((double) ((*x2 - cx) * (*x2 - cx) + (*y2 - cy) * (*y2 - cy))); - c = sqrt((double) ((*x1 - *x2) * (*x1 - *x2) + - (*y1 - *y2) * (*y1 - *y2))); - - /* We have three cases now -- either the midpoint of the line is - * closest to the origon, or point 1 or point 2 is. Actually the - * midpoint won't in general be the closest, but if a point besides - * one of the endpoints is closest, the midpoint will be closer than - * both endpoints. - */ - tx = (*x1 + *x2) / 2; - ty = (*y1 + *y2) / 2; - dt = sqrt((double) ((tx - cx) * (tx - cx) + (ty - cy) * (ty - cy))); - if ((dt < a) && (dt < b)) { - /* This is wierd -- round-off errors I guess. */ - tt = (a * a + c * c - b * b) / (2 * a * c); - if (tt > 1.0) - tt = 1.0; - else if (tt < -1.0) - tt = -1.0; - alpha = acos(tt); - perplen = a * sin(alpha); - } else if (a < b) { - perplen = a; - } else { - perplen = b; - } - - /* Now we should see if the line is outside of the circle */ - if (perplen >= rad) - return (TRUE); - - /* It's at least partially inside */ - if (a > rad) { - tt = (a * a + c * c - b * b) / (2 * a * c); - if (tt > 1.0) - tt = 1.0; - else if (tt < -1.0) - tt = -1.0; - alpha = acos(tt); - gamma = asin(sin(alpha) * a / rad); - if (gamma < M_PI / 2) - gamma = M_PI - gamma; - beta = M_PI - alpha - gamma; - *x1 = cx + rad * cos(theta1 + beta); - *y1 = cy + rad * sin(theta1 + beta); - } - if (b > rad) { - tt = (c * c + b * b - a * a) / (2 * b * c); - if (tt > 1.0) - tt = 1.0; - else if (tt < -1.0) - tt = -1.0; - alpha = acos(tt); - gamma = asin(sin(alpha) * b / rad); - if (gamma < M_PI / 2) - gamma = M_PI - gamma; - beta = M_PI - alpha - gamma; - *x2 = cx + rad * cos(theta2 - beta); - *y2 = cy + rad * sin(theta2 - beta); - } - if (flip) { - i = *x1; - *x1 = *x2; - *x2 = i; - i = *y1; - *y1 = *y2; - *y2 = i; - } - return (FALSE); -} diff --git a/src/frontend/clip.h b/src/frontend/clip.h deleted file mode 100644 index d5eee1f39..000000000 --- a/src/frontend/clip.h +++ /dev/null @@ -1,15 +0,0 @@ -/************* - * Header file for clip.c - * 1999 E. Rouat - ************/ - -#ifndef CLIP_H_INCLUDED -#define CLIP_H_INCLUDED - - -bool clip_line(int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t); -bool clip_to_circle(int *x1, int *y1, int *x2, int *y2, int cx, int cy, int rad); - - - -#endif diff --git a/src/frontend/compose.c b/src/frontend/compose.c deleted file mode 100644 index 6dbcbf947..000000000 --- a/src/frontend/compose.c +++ /dev/null @@ -1,484 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * The 'compose' command. This is a more powerful and convenient form of the - * 'let' command. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "fteparse.h" -#include "compose.h" - - -static void dimxpand(struct dvec *v, int *newdims, double *data); - - -/* The general syntax is 'compose name parm = val ...' - * The possible parms are: - * start The value at which the vector should start. - * stop The value at which the vector should end. - * step The difference between sucessive elements. - * lin The number of points, linearly spaced. - * log The number of points, logarithmically spaced. - * dec The number of points per decade, logarithmically spaced. - * center Where to center the range of points. - * span The size of the range of points. - * unif ?? - * gauss The number of points in the gaussian distribution. - * mean The mean value for the gass. dist. - * sd The standard deviation for the gauss. dist. - * random The number of randomly selected points. - * pool The name of a vector (must be already defined) to get - * random values -- default is 'unitvec(npoints)' - * - * The case 'compose name values val val ...' takes the values and creates a - * new vector -- the vals may be arbitrary expressions. - * - * NOTE: most of this doesn't work -- there will be plenty of unused variable - * lint messages... - */ - -void -com_compose(wordlist *wl) -{ - double start, stop, step, lin; - double center; - double span; - double mean, sd; - bool startgiven = FALSE, stopgiven = FALSE, stepgiven = FALSE; - bool lingiven = FALSE; - bool loggiven = FALSE, decgiven = FALSE, gaussgiven = FALSE; - bool randmgiven = FALSE; - bool spangiven = FALSE; - bool centergiven = FALSE; - bool meangiven = FALSE; - bool poolgiven = FALSE; - bool sdgiven = FALSE; - int log, dec, gauss, randm; - char *pool; - int i; - - char *resname, *s, *var, *val; - double *td, tt; - double *data; - complex *cdata; - int length, dim, type = SV_NOTYPE, blocksize; - bool realflag = TRUE; - int dims[MAXDIMS]; - struct dvec *result, *vecs = NULL, *v, *lv = NULL; - struct pnode *pn, *first_pn; - bool reverse = FALSE; - - resname = cp_unquote(wl->wl_word); - vec_remove(resname); - wl = wl->wl_next; - if (eq(wl->wl_word, "values")) { - /* Build up the vector from the rest of the line... */ - wl = wl->wl_next; - if (!(pn = ft_getpnames(wl, TRUE))) - return; - first_pn = pn; - while (pn) { - if (!(v = ft_evaluate(pn))) - return; - if (!vecs) - vecs = lv = v; - else - lv->v_link2 = v; - for (lv = v; lv->v_link2; lv = lv->v_link2) - ; - pn = pn->pn_next; - } - free_pnode(first_pn); - /* Now make sure these are all of the same dimensionality. We - * can coerce the sizes... - */ - dim = vecs->v_numdims; - if (dim < 2) - dim = (vecs->v_length > 1) ? 1 : 0; - if (dim == MAXDIMS) { - fprintf(cp_err, "Error: max dimensionality is %d\n", - MAXDIMS); - return; - } - for (v = vecs; v; v = v->v_link2) - if (v->v_numdims < 2) - v->v_dims[0] = v->v_length; - - for (v = vecs->v_link2, length = 1; v; v = v->v_link2) { - i = v->v_numdims; - if (i < 2) - i = (v->v_length > 1) ? 1 : 0; - if (i != dim) { - fprintf(cp_err, - "Error: all vectors must be of the same dimensionality\n"); - return; - } - length++; - if (iscomplex(v)) - realflag = FALSE; - } - for (i = 0; i < dim; i++) { - dims[i] = vecs->v_dims[i]; - for (v = vecs->v_link2; v; v = v->v_link2) - if (v->v_dims[i] > dims[i]) - dims[i] = v->v_dims[i]; - } - dim++; - dims[dim - 1] = length; - for (i = 0, blocksize = 1; i < dim - 1; i++) - blocksize *= dims[i]; - if (realflag) - data = (double *) tmalloc(sizeof (double) * length * - blocksize); - else - cdata = (complex *) tmalloc(sizeof (complex) * length * - blocksize); - - /* Now copy all the data over... If the sizes are too small - * then the extra elements are left as 0. - */ - for (v = vecs, i = 0; v; v = v->v_link2) { - if (dim == 1) { - if (realflag && isreal(v)) - data[i] = v->v_realdata[0]; - else if (isreal(v)) { - realpart(&cdata[i]) = - realpart(&v->v_compdata[0]); - imagpart(&cdata[i]) = 0.0; - } else { - realpart(&cdata[i]) = - realpart(&v->v_compdata[0]); - imagpart(&cdata[i]) = - imagpart(&v->v_compdata[0]); - } - i++; - continue; - } - dimxpand(v, dims, (realflag ? (data + i * blocksize) : - (double *) (cdata + i * blocksize))); - } - - length *= blocksize; - } else { - /* Parse the line... */ - while (wl) { - if ((s =strchr(wl->wl_word, '=')) && s[1]) { - /* This is var=val. */ - *s = '\0'; - var = wl->wl_word; - val = s + 1; - wl = wl->wl_next; - } else if (index(wl->wl_word, '=')) { - /* This is var= val. */ - *s = '\0'; - var = wl->wl_word; - wl = wl->wl_next; - if (wl) { - val = wl->wl_word; - wl = wl->wl_next; - } else { - fprintf(cp_err, "Error: bad syntax\n"); - return; - } - } else { - /* This is var =val or var = val. */ - var = wl->wl_word; - wl = wl->wl_next; - if (wl) { - val = wl->wl_word; - if (*val != '=') { - fprintf(cp_err, - "Error: bad syntax\n"); - return; - } - val++; - if (!*val) { - wl = wl->wl_next; - if (wl) { - val = wl->wl_word; - } else { - fprintf(cp_err, - "Error: bad syntax\n"); - return; - } - } - wl = wl->wl_next; - } else { - fprintf(cp_err, "Error: bad syntax\n"); - return; - } - } - if (cieq(var, "start")) { - startgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - start = *td; - } else if (cieq(var, "stop")) { - stopgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - stop = *td; - } else if (cieq(var, "step")) { - stepgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - step = *td; - } else if (cieq(var, "center")) { - centergiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - center = *td; - } else if (cieq(var, "span")) { - spangiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - span = *td; - } else if (cieq(var, "mean")) { - meangiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - mean = *td; - } else if (cieq(var, "sd")) { - sdgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - sd = *td; - } else if (cieq(var, "lin")) { - lingiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - lin = *td; - } else if (cieq(var, "log")) { - loggiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - log = *td; - } else if (cieq(var, "dec")) { - decgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - dec = *td; - } else if (cieq(var, "gauss")) { - gaussgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - gauss = *td; - } else if (cieq(var, "random")) { - randmgiven = TRUE; - if (!(td = ft_numparse(&val, FALSE))) { - fprintf(cp_err, - "Error: bad parm %s = %s\n", - var, val); - return; - } - randm = *td; - } else if (cieq(var, "pool")) { - poolgiven = TRUE; - pool = val; - } - } - -#ifdef LINT -/* XXX Now, doesn't this look just a little suspicious */ - if (centergiven || spangiven || meangiven || sdgiven || - poolgiven) - j = k = l = m = q = inds = center + span + mean + sd + - log + dec + gauss + randm + pool; -#endif - /* Now see what we have... start and stop are pretty much - * compatible with everything... - */ - if (stepgiven && (step == 0.0)) { - fprintf(cp_err, "Error: step cannot = 0.0\n"); - return; - } - if (startgiven && stopgiven && (start > stop)) { - tt = start; - start = stop; - stop = tt; - reverse = TRUE; - } - if (lingiven + loggiven + decgiven + randmgiven + gaussgiven - > 1) { - fprintf(cp_err, - "Error: can have at most one of (lin, log, dec, random, gauss)\n"); - return; - } else if (lingiven + loggiven + decgiven + randmgiven + - gaussgiven == 0) { - /* Hmm, if we have a start, stop, and step we're ok. */ - if (startgiven && stopgiven && stepgiven) { - lingiven = TRUE; - lin = (stop - start) / step + 1; - stepgiven = FALSE; /* Problems below... */ - } else { - fprintf(cp_err, -"Error: either one of (lin, log, dec, random, gauss) must be given, or all\n"); - fprintf(cp_err, - "\tof (start, stop, and step) must be given.\n"); - return; - } - } - if (lingiven) { - /* Create a linear sweep... */ - data = (double *) tmalloc(sizeof (double) * (int) lin); - if (stepgiven && startgiven && stopgiven) { - if (step != (stop - start) / lin * (reverse ? - -1 : 1)) { - fprintf(cp_err, - "Warning: bad step -- should be %g\n", - (stop - start) / lin * - (reverse ? -1 : 1)); - stepgiven = FALSE; - } - } - if (!startgiven) { - if (stopgiven && stepgiven) { - start = stop - step * lin; - } else if (stopgiven) { - start = stop - lin; - } else { - start = 0; - } - startgiven = TRUE; - } - if (!stopgiven) { - if (stepgiven) - stop = start + lin * step; - else - stop = start + lin; - stopgiven = TRUE; - } - if (!stepgiven) { - step = (stop - start) / lin; - } - if (reverse) - for (i = 0, tt = stop; i < lin; - i++, tt -= step) - data[i] = tt; - else - for (i = 0, tt = start; i < lin; - i++, tt += step) - data[i] = tt; - length = lin; - } else if (loggiven || decgiven) { - /* Create a log sweep... */ - } else if (randmgiven) { - /* Create a set of random values... */ - } else if (gaussgiven) { - /* Create a gaussian distribution... */ - } - } - result = alloc(struct dvec); - ZERO(result, struct dvec); - result->v_name = copy(resname); - result->v_type = type; - result->v_flags = (realflag ? VF_REAL : VF_COMPLEX) | VF_PERMANENT; - if (realflag) - result->v_realdata = data; - else - result->v_compdata = cdata; - result->v_length = length; - result->v_numdims = 1; - result->v_dims[0] = length; - vec_new(result); - cp_addkword(CT_VECTOR, result->v_name); - return; -} - -/* Copy the data from a vector into a buffer with larger dimensions. */ - -static void -dimxpand(struct dvec *v, int *newdims, double *data) -{ - complex *cdata = (complex *) data; - bool realflag = isreal(v); - int i, j, o, n, t, u; - int ncount[MAXDIMS], ocount[MAXDIMS]; - - for (i = 0; i < MAXDIMS; i++) - ncount[i] = ocount[i] = 0; - - for (;;) { - for (o = n = i = 0; i < v->v_numdims; i++) { - for (j = i, t = u = 1; j < v->v_numdims; j++) { - t *= v->v_dims[j]; - u *= newdims[j]; - } - o += ocount[i] * t; - n += ncount[i] * u; - } - - if (realflag) { - data[n] = v->v_realdata[o]; - } else { - realpart(&cdata[n]) = realpart(&v->v_compdata[o]); - imagpart(&cdata[n]) = imagpart(&v->v_compdata[o]); - } - /* Now find the nextstrchr element... */ - for (i = v->v_numdims - 1; i >= 0; i--) { - if ((ocount[i] < v->v_dims[i] - 1) && - (ncount[i] < newdims[i] - 1)) { - ocount[i]++; - ncount[i]++; - break; - } else - ocount[i] = ncount[i] = 0; - } - if (i < 0) - break; - } - - return; -} - diff --git a/src/frontend/compose.h b/src/frontend/compose.h deleted file mode 100644 index 7e03a72e9..000000000 --- a/src/frontend/compose.h +++ /dev/null @@ -1,12 +0,0 @@ -/************* - * Header file for compose.c - * 1999 E. Rouat - ************/ - -#ifndef COMPOSE_H_INCLUDED -#define COMPOSE_H_INCLUDED - -void com_compose(wordlist *wl); - - -#endif diff --git a/src/frontend/debugcom.c b/src/frontend/debugcom.c deleted file mode 100644 index bc2c6584f..000000000 --- a/src/frontend/debugcom.c +++ /dev/null @@ -1,49 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Circuit debugging commands. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedebug.h" -#include "ftedata.h" -#include "fteinp.h" -#include "debugcom.h" - - -void -com_state(wordlist *wl) -{ - if (!ft_curckt) { - fprintf(cp_err, "Error: no circuit loaded.\n"); - return; - } - fprintf(cp_out, "Current circuit: %s\n", ft_curckt->ci_name); - if (!ft_curckt->ci_inprogress) { - fprintf(cp_out, "No run in progress.\n"); - return; - } - fprintf(cp_out, "Type of run: %s\n", plot_cur->pl_name); - fprintf(cp_out, "Number of points so far: %d\n", - plot_cur->pl_scale->v_length); - fprintf(cp_out, "(That's all this command does so far)\n"); - return; -} - - -void -com_dump(wordlist *wl) -{ - if (!ft_curckt || !ft_curckt->ci_ckt) { - fprintf(cp_err, "Error: no circuit loaded.\n"); - return; - } - if_dump(ft_curckt->ci_ckt, cp_out); - return; -} - diff --git a/src/frontend/debugcom.h b/src/frontend/debugcom.h deleted file mode 100644 index 54399ee4e..000000000 --- a/src/frontend/debugcom.h +++ /dev/null @@ -1,14 +0,0 @@ -/************* - * Header file for debugcom.c - * 1999 E. Rouat - ************/ - -#ifndef DEBUGCOM_H_INCLUDED -#define DEBUGCOM_H_INCLUDED - -void com_state(wordlist *wl); -void com_dump(wordlist *wl); - - - -#endif diff --git a/src/frontend/doplot.c b/src/frontend/doplot.c deleted file mode 100644 index 310978bda..000000000 --- a/src/frontend/doplot.c +++ /dev/null @@ -1,1276 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Plotting routines - */ - -#include "ngspice.h" -#include "fteinput.h" -#include "ftedbgra.h" -#include "cpdefs.h" -#include "fteconst.h" -#include "ftedefs.h" -#include "ftedev.h" -#include "ftedata.h" -#include "fteparse.h" -#include "fteext.h" -#include "doplot.h" - - - -extern double *ft_SMITHminmax(struct dvec *v, bool yval); -extern void ft_xgraph(double *xlims, double *ylims, char *filename, char *title, char *xlabel, char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype, struct dvec *vecs); - -static bool sameflag; - -static bool plotit(wordlist *wl, char *hcopy, char *devname); -static double * getlims(wordlist *wl, char *name, int number); -static char * getword(wordlist *wl, char *name); -static bool getflag(wordlist *wl, char *name); -static void xtend(struct dvec *v, int length); -static void compress(struct dvec *d, double *xcomp, double *xind); - - - - -/* asciiplot file name ... [xlimit] xhi xlo] [vs xname] */ - - -extern void Input (REQUEST *request, RESPONSE *response); -extern int DevSwitch (char *devname); -extern int NewViewport (GRAPH *pgraph); -extern void gr_resize (GRAPH *graph); -extern void gr_redraw (GRAPH *graph); -extern int DestroyGraph (int id); -extern int unlink (const char *); - -void -com_asciiplot(wordlist *wl) -{ - (void) plotit(wl, (char *) NULL, "lpr"); - return; -} - -/* xgraph file plotargs - */ - -void -com_xgraph(wordlist *wl) -{ - char *fname; - bool tempf = FALSE; - - if (wl) { - fname = wl->wl_word; - wl = wl->wl_next; - } - if (!wl) { - return; - } - if (cieq(fname, "temp") || cieq(fname, "tmp")) { - fname = smktemp("xg"); - tempf = TRUE; - } - - (void) plotit(wl, fname, "xgraph"); - -/* Leave temp file sitting around so xgraph can grab it from background. - if (tempf) - (void) unlink(fname); -*/ - - - return; -} - -/* hardcopy file plotargs, or 'hardcopy file' -- with no other args this - * prompts the user for a window to dump to a plot file. XXX no it doesn't. - */ - -void -com_hardcopy(wordlist *wl) -{ - char *buf2, *prompt(FILE *fp); - wordlist *process(wordlist *wlist); - char *fname; - char buf[BSIZE_SP], device[BSIZE_SP]; - bool tempf = FALSE; - char *devtype; - char format[513]; - int printed; - int hc_button; - int foundit; - - if (!cp_getvar("hcopydev", VT_STRING, device)) - *device = '\0'; - - if (wl) { - hc_button = 0; - fname = wl->wl_word; - wl = wl->wl_next; - } else { - hc_button = 1; - fname = smktemp("hc"); - tempf = TRUE; - } - - if (!cp_getvar("hcopydevtype", VT_STRING, buf)) { - devtype = "plot5"; - } else { - devtype = buf; - } - -/* enable screen plot selection for these display types */ - - foundit = 0; - -#ifndef X_DISPLAY_MISSING - if (!wl && hc_button) { - - REQUEST request; - RESPONSE response; - GRAPH *tempgraph; - - request.option = click_option; - Input(&request, &response); - - if (response.option == error_option) return; - - if (response.reply.graph) { - - if (DevSwitch(devtype)) return; - tempgraph = CopyGraph(response.reply.graph); - tempgraph->devdep = fname; - if (NewViewport(tempgraph)) { - DevSwitch(NULL); - return; - } - gr_resize(tempgraph); - gr_redraw(tempgraph); - DestroyGraph(tempgraph->graphid); - DevSwitch(NULL); - foundit = 1; - } - } - -#endif - - - if (!foundit) { - - if (!wl) { - outmenuprompt("which variable ? "); - if ((buf2 = prompt(cp_in)) == (char *) -1) /* XXXX Sick */ - return; - wl = alloc(struct wordlist); - wl->wl_word = buf2; - wl->wl_next = NULL; - wl = process(wl); - } - - - - if (DevSwitch(devtype)) return; - - if (!wl || !plotit(wl, fname, (char *) NULL)) { - printf("com_hardcopy: graph not defined\n"); - DevSwitch(NULL); /* remember to switch back */ - return; - } - - DevSwitch(NULL); - - } - - printed = 0; - - - if (*device) { -#ifdef SYSTEM_PLOT5LPR - if (!strcmp(devtype, "plot5") || !strcmp(devtype, "MFB")) { - if (!cp_getvar("lprplot5", VT_STRING, format)) - strcpy(format, SYSTEM_PLOT5LPR); - (void) sprintf(buf, format, device, fname); - fprintf(cp_out, "Printing %s on the %s printer.\n", fname, device); - (void) system(buf); - printed = 1; - } -#endif -#ifdef SYSTEM_PSLPR - if (!printed && !strcmp(devtype, "postscript")) { - /* note: check if that was a postscript printer XXX */ - if (!cp_getvar("lprps", VT_STRING, format)) - strcpy(format, SYSTEM_PSLPR); - (void) sprintf(buf, format, device, fname); - fprintf(cp_out, "Printing %s on the %s printer.\n", fname, device); - (void) system(buf); - printed = 1; - } -#endif - } - - if (!printed) { - if (!strcmp(devtype, "plot5")) { - fprintf(cp_out, - "The file \"%s\" may be printed with the Unix \"plot\" command,\n", - fname); - fprintf(cp_out, - "\tor by using the '-g' flag to the Unix lpr command.\n"); - } else if (!strcmp(devtype, "postscript")) { - fprintf(cp_out, - "The file \"%s\" may be printed on a postscript printer.\n", - fname); - } else if (!strcmp(devtype, "MFB")) { - fprintf(cp_out, - "The file \"%s\" may be printed on a MFB device.\n", - fname); - } - } - - if (tempf && *device) - (void) unlink(fname); - - return; -} - -/* plot name ... [xl[imit]] xlo xhi] [yl[imit ylo yhi] [vs xname] */ - -void -com_plot(wordlist *wl) -{ - (void) plotit(wl, (char *) NULL, (char *) NULL); - return; -} - -/* The common routine for all plotting commands. This does hardcopy - * and graphics plotting. - */ - -static wordlist *wl_root; - -static bool -plotit(wordlist *wl, char *hcopy, char *devname) -{ - /* All these things are static so that "samep" will work. */ - static double *xcompress = NULL, *xindices = NULL; - static double *xlim = NULL, *ylim = NULL; - static double *xdelta = NULL, *ydelta = NULL; - static char *xlabel = NULL, *ylabel = NULL, *title = NULL; - static bool nointerp = FALSE; - static GRIDTYPE gtype = GRID_LIN; - static PLOTTYPE ptype = PLOT_LIN; - - bool gfound = FALSE, pfound = FALSE, oneval = FALSE; - double *dd, ylims[2], xlims[2]; - struct pnode *n, *names; - struct dvec *dv, *d = NULL, *vecs = NULL, *lv, *lastvs = NULL; - char *xn; - int i, j, xt; - double tt, mx, my, rad; - wordlist *wwl, *tw; - char cline[BSIZE_SP], buf[BSIZE_SP], *pname; - - int newlen; - struct dvec *v, *newv_scale; - double *newdata, *newscale; - double tstep, tstart, tstop, ttime; - - if (!wl) - return FALSE; - wl_root = wl; - - /* First get the command line, without the limits. */ - wwl = wl_copy(wl); - (void) getlims(wwl, "xl", 2); - (void) getlims(wwl, "xlimit", 2); - (void) getlims(wwl, "yl", 2); - (void) getlims(wwl, "ylimit", 2); - (void) sprintf(cline, "plot %s", wl_flatten(wwl)); - - wl_free(wwl); - - /* Now extract all the parameters. */ - - /* In case the parameter is the first on the line, we need a - * "buffer" word... - */ - tw = alloc(struct wordlist); - wl->wl_prev = tw; - tw->wl_next = wl; - wl = tw; - tw->wl_word = ""; - - sameflag = getflag(wl, "samep"); - - if (!sameflag || !xlim) { - xlim = getlims(wl, "xl", 2); - if (!xlim) - xlim = getlims(wl, "xlimit", 2); - } else { - (void) getlims(wl, "xl", 2); - (void) getlims(wl, "xlimit", 2); - } - - if (!sameflag || !ylim) { - ylim = getlims(wl, "yl", 2); - if (!ylim) - ylim = getlims(wl, "ylimit", 2); - } else { - (void) getlims(wl, "yl", 2); - (void) getlims(wl, "ylimit", 2); - } - - if (!sameflag || !xcompress) { - xcompress = getlims(wl, "xcompress", 1); - if (!xcompress) - xcompress = getlims(wl, "xcomp", 1); - } else { - (void) getlims(wl, "xcompress", 1); - (void) getlims(wl, "xcomp", 1); - } - - if (!sameflag || !xindices) { - xindices = getlims(wl, "xindices", 2); - if (!xindices) - xindices = getlims(wl, "xind", 2); - } else { - (void) getlims(wl, "xindices", 2); - (void) getlims(wl, "xind", 2); - } - - if (!sameflag || !xdelta) { - xdelta = getlims(wl, "xdelta", 1); - if (!xdelta) - xdelta = getlims(wl, "xdel", 1); - } else { - (void) getlims(wl, "xdelta", 1); - (void) getlims(wl, "xdel", 1); - } - if (!sameflag || !ydelta) { - ydelta = getlims(wl, "ydelta", 1); - if (!ydelta) - ydelta = getlims(wl, "ydel", 1); - } else { - (void) getlims(wl, "ydelta", 1); - (void) getlims(wl, "ydel", 1); - } - - /* Get the grid type and the point type. Note we can't do if-else - * here because we want to catch all the grid types. - */ - if (getflag(wl, "lingrid")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_LIN; - gfound = TRUE; - } - } - if (getflag(wl, "loglog")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_LOGLOG; - gfound = TRUE; - } - } - if (getflag(wl, "nogrid")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_NONE; - gfound = TRUE; - } - } - if (getflag(wl, "linear")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_LIN; - gfound = TRUE; - } - } - if (getflag(wl, "xlog")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_XLOG; - gfound = TRUE; - } - } - if (getflag(wl, "ylog")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_YLOG; - gfound = TRUE; - } - } - if (getflag(wl, "polar")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_POLAR; - gfound = TRUE; - } - } - if (getflag(wl, "smith")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_SMITH; - gfound = TRUE; - } - } - if (getflag(wl, "smithgrid")) { - if (gfound) - fprintf(cp_err, - "Warning: too many grid types given\n"); - else { - gtype = GRID_SMITHGRID; - gfound = TRUE; - } - } - - if (!sameflag && !gfound) { - if (cp_getvar("gridstyle", VT_STRING, buf)) { - if (eq(buf, "lingrid")) - gtype = GRID_LIN; - else if (eq(buf, "loglog")) - gtype = GRID_LOGLOG; - else if (eq(buf, "xlog")) - gtype = GRID_XLOG; - else if (eq(buf, "ylog")) - gtype = GRID_YLOG; - else if (eq(buf, "smith")) - gtype = GRID_SMITH; - else if (eq(buf, "smithgrid")) - gtype = GRID_SMITHGRID; - else if (eq(buf, "polar")) - gtype = GRID_POLAR; - else if (eq(buf, "nogrid")) - gtype = GRID_NONE; - else { - fprintf(cp_err, - "Warning: strange grid type %s\n", - buf); - gtype = GRID_LIN; - } - gfound = TRUE; - } else - gtype = GRID_LIN; - } - - /* Now get the point type. */ - - if (getflag(wl, "linplot")) { - if (pfound) - fprintf(cp_err, - "Warning: too many plot types given\n"); - else { - ptype = PLOT_LIN; - pfound = TRUE; - } - } - if (getflag(wl, "combplot")) { - if (pfound) - fprintf(cp_err, - "Warning: too many plot types given\n"); - else { - ptype = PLOT_COMB; - pfound = TRUE; - } - } - if (getflag(wl, "pointplot")) { - if (pfound) - fprintf(cp_err, - "Warning: too many plot types given\n"); - else { - ptype = PLOT_POINT; - pfound = TRUE; - } - } - - if (!sameflag && !pfound) { - if (cp_getvar("plotstyle", VT_STRING, buf)) { - if (eq(buf, "linplot")) - ptype = PLOT_LIN; - else if (eq(buf, "combplot")) - ptype = PLOT_COMB; - else if (eq(buf, "pointplot")) - ptype = PLOT_POINT; - else { - fprintf(cp_err, - "Warning: strange plot type %s\n", - buf); - ptype = PLOT_LIN; - } - pfound = TRUE; - } else - ptype = PLOT_LIN; - } - - if (!sameflag || !xlabel) - xlabel = getword(wl, "xlabel"); - else - (void) getword(wl, "xlabel"); - if (!sameflag || !ylabel) - ylabel = getword(wl, "ylabel"); - else - (void) getword(wl, "ylabel"); - if (!sameflag || !title) - title = getword(wl, "title"); - else - (void) getword(wl, "title"); - - if (!sameflag) - nointerp = getflag(wl, "nointerp"); - else if (getflag(wl, "nointerp")) - nointerp = TRUE; - - wl = wl->wl_next; - if (!wl) { - fprintf(cp_err, "Error: no vectors given\n"); - return (FALSE); - } - - wl->wl_prev = NULL; - - /* Now parse the vectors. We have a list of the form - * "a b vs c d e vs f g h". Since it's a bit of a hassle for - * us to parse the vector boundaries here, we do this -- call - * ft_getpnames() without the check flag, and then look for 0-length - * vectors with the name "vs"... This is a sort of a gross hack, - * since we have to check for 0-length vectors ourselves after - * evaulating the pnodes... - */ - - names = ft_getpnames(wl, FALSE); - if (names == NULL) - return (FALSE); - - /* Now evaluate the names. */ - for (n = names, lv = NULL; n; n = n->pn_next) { - if (n->pn_value && (n->pn_value->v_length == 0) && - eq(n->pn_value->v_name, "vs")) { - if (!lv) { - fprintf(cp_err, "Error: misplaced vs arg\n"); - return (FALSE); - } else { - if (!(n = n->pn_next)) { - fprintf(cp_err, - "Error: missing vs arg\n"); - return (FALSE); - } - dv = ft_evaluate(n); - if (!dv) - return (FALSE); - if (lastvs) - lv = lastvs->v_link2; - else - lv = vecs; - while (lv) { - lv->v_scale = dv; - lastvs = lv; - lv = lv->v_link2; - } - } - continue; - } - dv = ft_evaluate(n); - if (!dv) - return (FALSE); - if (!d) - vecs = dv; - else - d->v_link2 = dv; - for (d = dv; d->v_link2; d = d->v_link2) - ; - lv = dv; - } - free_pnode(names); - d->v_link2 = NULL; - - /* Now check for 0-length vectors. */ - for (d = vecs; d; d = d->v_link2) - if (!d->v_length) { - fprintf(cp_err, "Error: %s: no such vector\n", - d->v_name); - return (FALSE); - } - - /* If there are higher dimensional vectors, transform them into a - * family of vectors. - */ - for (d = vecs, lv = NULL; d; d = d->v_link2) { - if (d->v_numdims > 1) { - if (lv) - lv->v_link2 = vec_mkfamily(d); - else - vecs = lv = vec_mkfamily(d); - while (lv->v_link2) - lv = lv->v_link2; - lv->v_link2 = d->v_link2; - d = lv; - } else { - lv = d; - } - } - - /* Now fill in the scales for vectors who aren't already fixed up. */ - for (d = vecs; d; d = d->v_link2) - if (!d->v_scale) { - if (d->v_plot->pl_scale) - d->v_scale = d->v_plot->pl_scale; - else - d->v_scale = d; - } - - - /* See if the log flag is set anywhere... */ - if (!gfound) { - for (d = vecs; d; d = d->v_link2) - if (d->v_scale && (d->v_scale->v_gridtype == GRID_XLOG)) - gtype = GRID_XLOG; - for (d = vecs; d; d = d->v_link2) - if (d->v_gridtype == GRID_YLOG) { - if ((gtype == GRID_XLOG) || - (gtype == GRID_LOGLOG)) - gtype = GRID_LOGLOG; - else - gtype = GRID_YLOG; - } - for (d = vecs; d; d = d->v_link2) - if (d->v_gridtype == GRID_SMITH || d->v_gridtype == GRID_SMITHGRID - || d->v_gridtype == GRID_POLAR) - { - gtype = d->v_gridtype; - break; - } - } - - /* See if there are any default plot types... Here, like above, we - * don't do entirely the best thing when there is a mixed set of - * default plot types... - */ - if (!sameflag && !pfound) { - ptype = PLOT_LIN; - for (d = vecs; d; d = d->v_link2) - if (d->v_plottype != PLOT_LIN) { - ptype = d->v_plottype; - break; - } - } - - /* Check and see if this is pole zero stuff. */ - if ((vecs->v_type == SV_POLE) || (vecs->v_type == SV_ZERO)) - oneval = TRUE; - - for (d = vecs; d; d = d->v_link2) - if (((d->v_type == SV_POLE) || (d->v_type == SV_ZERO)) != - oneval ? 1 : 0) { - fprintf(cp_err, -"Error: plot must be either all pole-zero or contain no poles or zeros\n"); - return (FALSE); - } - - if ((gtype == GRID_POLAR) || (gtype == GRID_SMITH - || gtype == GRID_SMITHGRID)) - { - oneval = TRUE; - } - - /* If we are plotting scalars, make sure there is enough - * data to fit on the screen. - */ - - for (d = vecs; d; d = d->v_link2) - if (d->v_length == 1) - xtend(d, d->v_scale->v_length); - - /* Now patch up each vector with the compression and thestrchr - * selection. - */ - if (xcompress || xindices) { - for (d = vecs; d; d = d->v_link2) { - compress(d, xcompress, xindices); - d->v_scale = vec_copy(d->v_scale); - compress(d->v_scale, xcompress, xindices); - } - } - - /* Transform for smith plots */ - if (gtype == GRID_SMITH) { - double re, im, rex, imx; - double r, i, x; - struct dvec **prevvp, *n; - int j; - - prevvp = &vecs; - for (d = vecs; d; d = d->v_link2) { - if (d->v_flags & VF_PERMANENT) { - n = vec_copy(d); - n->v_flags &= ~VF_PERMANENT; - n->v_link2 = d->v_link2; - d = n; - *prevvp = d; - } - prevvp = &d->v_link2; - - if (isreal(d)) { - fprintf(cp_err, - "Warning: plotting real data \"%s\" on a smith grid\n", - d->v_name); - - for (j = 0; j < d->v_length; j++) { - r = d->v_realdata[j]; - d->v_realdata[j] = (r - 1) / (r + 1); - } - } else { - for (j = 0; j < d->v_length; j++) { - /* (re - 1, im) / (re + 1, im) */ - - re = realpart(d->v_compdata + j); - im = imagpart(d->v_compdata + j); - - rex = re + 1; - imx = im; - re = re - 1; - - /* (re, im) / (rex, imx) */ - x = 1 - (imx / rex) * (imx / rex); - r = re / rex + im / rex * imx / rex; - i = im / rex - re / rex * imx / rex; - - realpart(d->v_compdata + j) = r / x; - imagpart(d->v_compdata + j) = i / x; - } - } - } - } - - /* Figure out the proper x- and y-axis limits. */ - if (ylim) { -#ifdef notdef - if (gtype == GRID_SMITH) { - if (xlim) { - SMITH_tfm(xlim[0], ylim[0], &dummy, &ylims[0]); - SMITH_tfm(xlim[1], ylim[1], &dummy, &ylims[1]); - } else { - SMITH_tfm(0.0, ylim[0], &dummy, &ylims[0]); - SMITH_tfm(0.0, ylim[1], &dummy, &ylims[1]); - } - } else { - } -#endif - ylims[0] = ylim[0]; - ylims[1] = ylim[1]; - } else if (oneval) { - ylims[0] = HUGE; - ylims[1] = - ylims[0]; - for (d = vecs; d; d = d->v_link2) { -#ifdef notdef - if (gtype == GRID_SMITH) { - dd = ft_SMITHminmax(d, TRUE); - if( dd[0] < 0.0 ) - dd[0] *= 1.1; - else - dd[0] *= 0.9; - if( dd[1] >= 0.0 ) - dd[1] *= 1.1; - else - dd[1] *= 0.9; - } else -#endif - dd = ft_minmax(d, TRUE); - if (dd[0] < ylims[0]) - ylims[0] = dd[0]; - if (dd[1] > ylims[1]) - ylims[1] = dd[1]; - } - } else { - ylims[0] = HUGE; - ylims[1] = - ylims[0]; - for (d = vecs; d; d = d->v_link2) { - dd = ft_minmax(d, TRUE); - if (dd[0] < ylims[0]) - ylims[0] = dd[0]; - if (dd[1] > ylims[1]) - ylims[1] = dd[1]; - } - - /* XXX */ - for (d = vecs; d; d = d->v_link2) { - if (d->v_flags & VF_MINGIVEN) - if (ylims[0] < d->v_minsignal) - ylims[0] = d->v_minsignal; - if (d->v_flags & VF_MAXGIVEN) - if (ylims[1] > d->v_maxsignal) - ylims[1] = d->v_maxsignal; - } - } - - if (xlim) { -#ifdef notdef - if (gtype == GRID_SMITH) { - if (ylim) { - SMITH_tfm(xlim[0], ylim[0], &xlims[0], &dummy); - SMITH_tfm(xlim[1], ylim[1], &xlims[1], &dummy); - } else { - SMITH_tfm(xlim[0], 0.0, &xlims[0], &dummy); - SMITH_tfm(xlim[1], 0.0, &xlims[1], &dummy); - } - } else { - } -#endif - xlims[0] = xlim[0]; - xlims[1] = xlim[1]; - } else if (oneval) { - xlims[0] = HUGE; - xlims[1] = - xlims[0]; - for (d = vecs; d; d = d->v_link2) { -#ifdef notdef - if (gtype == GRID_SMITH) { - dd = ft_SMITHminmax(d, FALSE); - if( dd[0] < 0.0 ) - dd[0] *= 1.1; - else - dd[0] *= 0.9; - if( dd[1] >= 0.0 ) - dd[1] *= 1.1; - else - dd[1] *= 0.9; - } else -#endif - dd = ft_minmax(d, FALSE); - - if (dd[0] < xlims[0]) - xlims[0] = dd[0]; - if (dd[1] > xlims[1]) - xlims[1] = dd[1]; - } - } else { - xlims[0] = HUGE; - xlims[1] = - xlims[0]; - for (d = vecs; d; d = d->v_link2) { - dd = ft_minmax(d->v_scale, TRUE); - if (dd[0] < xlims[0]) - xlims[0] = dd[0]; - if (dd[1] > xlims[1]) - xlims[1] = dd[1]; - } - for (d = vecs; d; d = d->v_link2) { - if (d->v_scale->v_flags & VF_MINGIVEN) - if (xlims[0] < d->v_scale->v_minsignal) - xlims[0] = d->v_scale->v_minsignal; - if (d->v_scale->v_flags & VF_MAXGIVEN) - if (xlims[1] > d->v_scale->v_maxsignal) - xlims[1] = d->v_scale->v_maxsignal; - } - } - - /* Do some coercion of the limits to make them reasonable. */ - if ((xlims[0] == 0) && (xlims[1] == 0)) { - xlims[0] = -1.0; - xlims[1] = 1.0; - } - if ((ylims[0] == 0) && (ylims[1] == 0)) { - ylims[0] = -1.0; - ylims[1] = 1.0; - } - if (xlims[0] > xlims[1]) { - tt = xlims[1]; - xlims[1] = xlims[0]; - xlims[0] = tt; - } - if (ylims[0] > ylims[1]) { - tt = ylims[1]; - ylims[1] = ylims[0]; - ylims[0] = tt; - } - if (xlims[0] == xlims[1]) { - xlims[0] *= (xlims[0] > 0) ? 0.9 : 1.1; - xlims[1] *= (xlims[1] > 0) ? 1.1 : 0.9; - } - if (ylims[0] == ylims[1]) { - /* || fabs(ylims[0])/(ylims[1]-ylims[0]) > 1.0e9 - || fabs(ylims[1])/(ylims[1]-ylims[0]) > 1.0e9) */ - ylims[0] *= (ylims[0] > 0) ? 0.9 : 1.1; - ylims[1] *= (ylims[1] > 0) ? 1.1 : 0.9; - } - -#ifdef notdef - /* Now shrink the limits very slightly -- this helps prevent round-off - * error from doing bad things. - */ - if (gtype != GRID_LOGLOG && gtype != GRID_XLOG - && gtype != GRID_POLAR && gtype != GRID_SMITH) - { - tt = xlims[1] - xlims[0]; - xlims[0] += tt * 0.001; - xlims[1] -= tt * 0.001; - } - if (gtype != GRID_LOGLOG && gtype != GRID_YLOG - && gtype != GRID_POLAR && gtype != GRID_SMITH) { - tt = ylims[1] - ylims[0]; - ylims[0] += tt * 0.001; - ylims[1] -= tt * 0.001; - } -#endif - - if ((xlims[0] <= 0.0) && ((gtype == GRID_XLOG) || - (gtype == GRID_LOGLOG))) { - fprintf(cp_err, - "Error: X values must be > 0 for log scale\n"); - return (FALSE); - } - if ((ylims[0] <= 0.0) && ((gtype == GRID_YLOG) || - (gtype == GRID_LOGLOG))) { - fprintf(cp_err, - "Error: Y values must be > 0 for log scale\n"); - return (FALSE); - } - - /* Fix the plot limits for smith and polar grids. */ - if ((!xlim || !ylim) && (gtype == GRID_POLAR)) { - /* (0,0) must be in the center of the screen. */ - mx = (fabs(xlims[0]) > fabs(xlims[1])) ? fabs(xlims[0]) : - fabs(xlims[1]); - my = (fabs(ylims[0]) > fabs(ylims[1])) ? fabs(ylims[0]) : - fabs(ylims[1]); - rad = (mx > my) ? mx : my; - /* rad = sqrt(mx * mx + my * my); */ - xlims[0] = - rad; - xlims[1] = rad; - ylims[0] = - rad; - ylims[1] = rad; - } else if ((!xlim || !ylim) && (gtype == GRID_SMITH - || gtype == GRID_SMITHGRID)) - { -#ifdef notdef - /* Let the user zoom in */ - mx = (fabs(xlims[0]) > fabs(xlims[1])) ? fabs(xlims[0]) : - fabs(xlims[1]); - my = (fabs(ylims[0]) > fabs(ylims[1])) ? fabs(ylims[0]) : - fabs(ylims[1]); - rad = (mx > my) ? mx : my; - /* XXX */ - xlims[0] = - rad; - xlims[1] = rad; - ylims[0] = - rad; - ylims[1] = rad; -#endif - xlims[0] = -1.0; - xlims[1] = 1.0; - ylims[0] = -1.0; - ylims[1] = 1.0; - } - - /* We don't want to try to deal with smith plots for asciiplot. */ - if (devname && eq(devname, "lpr")) { - /* check if we should (can) linearize */ - if (!(!ft_curckt || !ft_curckt->ci_ckt || - strcmp(ft_curckt->ci_name, plot_cur->pl_title) || - !if_tranparams(ft_curckt, &tstart, &tstop, &tstep) || - ((tstop - tstart) * tstep <= 0.0) || - ((tstop - tstart) < tstep) || - !plot_cur || !plot_cur->pl_dvecs || - !plot_cur->pl_scale || - !isreal(plot_cur->pl_scale) || - !ciprefix("tran", plot_cur->pl_typename))) { - - newlen = (tstop - tstart) / tstep + 1.5; - - newscale = (double *) tmalloc(newlen * sizeof(double)); - - newv_scale = alloc(struct dvec); - newv_scale->v_flags = vecs->v_scale->v_flags; - newv_scale->v_type = vecs->v_scale->v_type; - newv_scale->v_gridtype = vecs->v_scale->v_gridtype; - newv_scale->v_length = newlen; - newv_scale->v_name = copy(vecs->v_scale->v_name); - newv_scale->v_realdata = newscale; - - for (i = 0, ttime = tstart; i < newlen; i++, ttime += tstep) - newscale[i] = ttime; - - for (v = vecs; v; v= v->v_link2) { - newdata = (double *) tmalloc(newlen * sizeof (double)); - - if (!ft_interpolate(v->v_realdata, newdata, - v->v_scale->v_realdata, v->v_scale->v_length, - newscale, newlen, 1)) { - fprintf(cp_err, - "Error: can't interpolate %s\n", v->v_name); - return(FALSE); - } - - tfree(v->v_realdata); - v->v_realdata = newdata; - - /* Why go to all this trouble if agraf ignores it? */ - nointerp = TRUE; - } - - vecs->v_scale = newv_scale; - - } - ft_agraf(xlims, ylims, vecs->v_scale, vecs->v_plot, vecs, - xdelta ? *xdelta : 0.0, ydelta ? *ydelta : 0.0, - ((gtype == GRID_XLOG) || (gtype == GRID_LOGLOG)), - ((gtype == GRID_YLOG) || (gtype == GRID_LOGLOG)), - nointerp); - return (TRUE); - } - - /* See if there is one type we can give for the y scale... */ - for (j = vecs->v_type, d = vecs->v_link2; d; d = d->v_link2) - if (d->v_type != j) { - j = SV_NOTYPE; - break; - } - - if (devname && eq(devname, "xgraph")) { - /* Interface to XGraph-11 Plot Program */ - ft_xgraph(xlims, ylims, hcopy, - title ? title : vecs->v_plot->pl_title, - xlabel ? xlabel : ft_typabbrev(vecs->v_scale->v_type), - ylabel ? ylabel : ft_typabbrev(j), - gtype, ptype, vecs); - return (TRUE); - } - for (d = vecs, i = 0; d; d = d->v_link2) - i++; - - /* Figure out the X name and the X type. This is sort of bad... */ - xn = vecs->v_scale->v_name; - xt = vecs->v_scale->v_type; - - pname = plot_cur->pl_typename; - - if (!gr_init(xlims, ylims, (oneval ? (char *) NULL : xn), - title ? title : vecs->v_plot->pl_title, hcopy, i, - xdelta ? *xdelta : 0.0, ydelta ? *ydelta : 0.0, gtype, - ptype, xlabel, ylabel, xt, j, pname, cline)) - return (FALSE); - - /* Now plot all the graphs. */ - for (d = vecs; d; d = d->v_link2) - ft_graf(d, oneval ? (struct dvec *) NULL : d->v_scale, FALSE); - - gr_clean(); - - return (TRUE); -} - -/* This routine gets parameters from the command line, which are of the - * form "name number ..." It returns a pointer to the parameter values. - */ - -static double * -getlims(wordlist *wl, char *name, int number) -{ - double *d, *td; - wordlist *beg, *wk; - char *ss; - int n; - - for (beg = wl; beg; beg = beg->wl_next) { - if (eq(beg->wl_word, name)) { - if (beg == wl) { - fprintf(cp_err, - "Syntax error: looking for plot parameters \"%s\".\n", - name); - return (NULL); - } - wk = beg; - if (number) { - d = (double *) tmalloc(sizeof (double) * - number); - for (n = 0; n < number; n++) { - wk = wk->wl_next; - if (!wk) { - fprintf(cp_err, - "Syntax error: not enough parameters for \"%s\".\n", - name); - return (NULL); - } - ss = wk->wl_word; - td = ft_numparse(&ss, FALSE); - if (td == NULL) - goto bad; - d[n] = *td; - } - } else - /* Minor hack... */ - d = (double *) 1; - - if (beg->wl_prev) - beg->wl_prev->wl_next = wk->wl_next; - if (wk->wl_next) { - wk->wl_next->wl_prev = beg->wl_prev; - wk->wl_next = NULL; - } - if (beg != wl_root) - wl_free(beg); - return (d); - } - } - return (NULL); -bad: - fprintf(cp_err, "Syntax error: bad parameters for \"%s\".\n", name); - return (NULL); -} - -/* Return a parameter of the form "xlabel foo" */ - -static char * -getword(wordlist *wl, char *name) -{ - wordlist *beg; - char *s; - - for (beg = wl; beg; beg = beg->wl_next) { - if (eq(beg->wl_word, name)) { - if ((beg == wl) || !beg->wl_next) { - fprintf(cp_err, - "Syntax error: looking for plot keyword at \"%s\".\n", - name); - return (NULL); - } - s = copy(beg->wl_next->wl_word); - beg->wl_prev->wl_next = beg->wl_next->wl_next; - if (beg->wl_next->wl_next) - beg->wl_next->wl_next->wl_prev = beg->wl_prev; - beg->wl_next->wl_next = NULL; - wl_free(beg); - return (s); - } - } - return (NULL); -} - -/* Check for and remove a one-word keyword. */ - -static bool -getflag(wordlist *wl, char *name) -{ - while (wl) { - if (eq(wl->wl_word, name)) { - if (wl->wl_prev) - wl->wl_prev->wl_next = wl->wl_next; - if (wl->wl_next) - wl->wl_next->wl_prev = wl->wl_prev; - return (TRUE); - } - wl = wl->wl_next; - } - return (FALSE); -} - -/* Extend a data vector to length by replicating the - * last element, or truncate it if it is too long. - */ - -static void -xtend(struct dvec *v, int length) -{ - int i; - complex c, *oc; - double d, *od; - - if (v->v_length == length) - return; - if (v->v_length > length) { - v->v_length = length; - return; - } - if (isreal(v)) { - od = v->v_realdata; - v->v_realdata = (double *) tmalloc(length * sizeof (double)); - for (i = 0; i < v->v_length; i++) - v->v_realdata[i] = od[i]; - d = od[--i]; - while (i < length) - v->v_realdata[i++] = d; - tfree(od); - } else { - oc = v->v_compdata; - v->v_compdata = (complex *) tmalloc(length * sizeof (complex)); - for (i = 0; i < v->v_length; i++) { - realpart(&v->v_compdata[i]) = realpart(&oc[i]); - imagpart(&v->v_compdata[i]) = imagpart(&oc[i]); - } - realpart(&c) = realpart(&oc[--i]); - imagpart(&c) = imagpart(&oc[i]); - while (i < length) { - realpart(&v->v_compdata[i]) = realpart(&c); - imagpart(&v->v_compdata[i++]) = imagpart(&c); - tfree(oc); - } - } - v->v_length = length; - return; -} - -/* Collapse every *xcomp elements into one, and use only the elements - * between xind[0] and xind[1]. - */ - -static void -compress(struct dvec *d, double *xcomp, double *xind) -{ - int cfac, ihi, ilo, newlen, i; - int sz = isreal(d) ? sizeof (double) : sizeof (complex); - double *dd; - complex *cc; - - if (xind) { - ilo = (int) xind[0]; - ihi = (int) xind[1]; - if ((ilo <= ihi) && (ilo > 0) && (ilo < d->v_length) && - (ihi > 1) && (ihi <= d->v_length)) { - newlen = ihi - ilo; - dd = (double *) tmalloc(newlen * sz); - cc = (complex *) dd; - if (isreal(d)) { - bcopy((char *) (d->v_realdata + ilo), - (char *) dd, newlen * sz); - tfree(d->v_realdata); - d->v_realdata = dd; - } else { - bcopy((char *) (d->v_compdata + ilo), - (char *) cc, newlen * sz); - tfree(d->v_compdata); - d->v_compdata = cc; - } - d->v_length = newlen; - } - } - - if (xcomp) { - cfac = (int) *xcomp; - if ((cfac > 1) && (cfac < d->v_length)) { - for (i = 0; i * cfac < d->v_length; i++) - if (isreal(d)) - d->v_realdata[i] = - d->v_realdata[i * cfac]; - else - d->v_compdata[i] = - d->v_compdata[i * cfac]; - d->v_length = i; - } - } - return; -} diff --git a/src/frontend/doplot.h b/src/frontend/doplot.h deleted file mode 100644 index 45b6950d0..000000000 --- a/src/frontend/doplot.h +++ /dev/null @@ -1,15 +0,0 @@ -/************* - * Header file for doplot.c - * 1999 E. Rouat - ************/ - -#ifndef DOPLOT_H_INCLUDED -#define DOPLOT_H_INCLUDED - -void com_asciiplot(wordlist *wl); -void com_xgraph(wordlist *wl); -void com_hardcopy(wordlist *wl); -void com_plot(wordlist *wl); - - -#endif diff --git a/src/frontend/graf.c b/src/frontend/graf.c deleted file mode 100644 index eaa082a0f..000000000 --- a/src/frontend/graf.c +++ /dev/null @@ -1,1090 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jeffrey M. Hsu -**********/ - -/* - * Most of the gr_ module resides here, in particular, gr_init - * and gr_point, expect for the gr_ grid routines. - * - */ - - -#include "ngspice.h" -#include "cpdefs.h" /* for VT_ */ -#include "cpextern.h" -#include "fteconst.h" -#include "ftedebug.h" /* for iplot */ -#include "ftedata.h" /* for struct dvec */ -#include "ftedefs.h" /* for FTEextern.h and IPOINT{MIN,MAX} */ -#include "fteinput.h" -#include "ftegraph.h" -#include "ftedbgra.h" -#include "ftedev.h" -#include "graf.h" - - -/* static declarations */ -static void gr_start_internal(struct dvec *dv, bool copyvec); -static int iplot(struct plot *pl, int id); -static void set(struct plot *plot, struct dbcomm *db, bool unset, int mode); -static char * getitright(char *buf, double num); - - -extern struct dbcomm *dbs; /* for iplot */ - -/* note: let's try to get rid of these */ -/* global variables */ -/* Graphics mode in progress, so signal handlers know to call gr_clean */ -/* bool gr_gmode = FALSE; */ - -/* for legends, set in gr_start, reset in gr_iplot and gr_init */ -static int plotno; -static int curcolor = 1; /* for assigning unique colors */ -static int curlst = 0; /* for assigning line styles */ - -/* invariant: currentgraph contains the current graph */ - -/* These are what gets plotted as points when you specify point plots */ -static char pointchars[128]; -#define DEFPOINTCHARS "oxabcdefhgijklmnpqrstuvwyz" - -/* Buffer for ticmarks if given a list */ -static char ticbuf[1024]; -static char *ticlist = ticbuf; -#define MAXTICS 100 -double *readtics(char *string); - -#define XFACTOR 2 /* How much to expand the X scale during iplot. */ -#define YFACTOR 1.5 /* How much to expand the Y scale during iplot. */ - -/* - * Start of a new graph. - * Fill in the data that gets displayed. - * Difference from old gr_init - * we don't try to determine the look of the screen from here - * leave to lower level routines - * - */ - -extern void SetGraphContext (int graphid); -extern void internalerror (char *message); -extern int NewViewport (GRAPH *pgraph); -extern void DevClear (void); -extern void gr_redrawgrid (GRAPH *graph); -extern void DatatoScreen (GRAPH *graph, double x, double y, int *screenx, int *screeny); -extern void SetLinestyle (int linestyleid); -extern void SetColor (int colorid); -extern void DrawLine (int x1, int y1, int x2, int y2); -extern void Text (char *text, int x, int y); -extern void SaveText (GRAPH *graph, char *text, int x, int y); -extern void Update (void); -extern void PushGraphContext (GRAPH *graph); -extern void PopGraphContext (void); -extern void Input (REQUEST *request, RESPONSE *response); -extern int DestroyGraph (int id); - -int -gr_init(double *xlims, double *ylims, char *xname, char *plotname, char *hcopy, int nplots, double xdelta, double ydelta, GRIDTYPE gridtype, PLOTTYPE plottype, char *xlabel, char *ylabel, int xtype, int ytype, char *pname, char *commandline) - /* The size of the screen. */ - /* What to label things. */ - /* The raster file. */ - /* How many plots there will be. */ - /* Line increments for the scale. */ - /* The grid type */ - /* and the plot type. */ - /* Labels for axes. */ - /* The types of the data graphed. */ - - /* For xi_zoomdata() */ -{ - - GRAPH *graph; - int b; - wordlist *wl; - char *comb_title; - - - if (!(graph = NewGraph())) { - return(FALSE); - } - - /* - The global currentgraph will always be the current graph. - */ - SetGraphContext(graph->graphid); - - graph->onevalue = (xname ? FALSE : TRUE); - - /* communicate filename to plot 5 driver */ - if (hcopy) { - graph->devdep = hcopy; - } - - plotno = 0; - - /* note: should do only once, maybe in gr_init_once */ - if (!cp_getvar("pointchars", VT_STRING, pointchars)) - (void) strcpy(pointchars, DEFPOINTCHARS); - - if (!cp_getvar("ticmarks", VT_NUM, (char *) &graph->ticmarks)) { - if (cp_getvar("ticmarks", VT_BOOL, (char *) &b)) - graph->ticmarks = 10; - else - graph->ticmarks = 0; - } - - if (cp_getvar("ticlist", VT_LIST, ticlist)) { - wl = (wordlist *)vareval("ticlist"); - ticlist = (char *)wl_flatten(wl); - graph->ticdata = (double *) readtics(ticlist); - } else - graph->ticdata = NULL; - - /* set slow flag to stop between each plot and prompt the - user for a return - This is used mainly for graphics terminals w/o windows. - */ -/* - if (incremental) - slow = FALSE; - else - (void) cp_getvar("slowplot", VT_BOOL, (char *) &slow); -*/ - - if (!xlims || !ylims) { - internalerror("gr_init: no range specified"); - return(FALSE); - } - - /* indicate some graphics going on */ -/* gr_gmode = TRUE; */ - - /* save upper and lower limits */ - graph->data.xmin = xlims[0]; - graph->data.xmax = xlims[1]; - graph->data.ymin = ylims[0]; - graph->data.ymax = ylims[1]; - - /* note: have enum here or some better convention */ - if (NewViewport(graph) == 1) { - /* note: where is the error message generated? */ - /* note: undo mallocs */ - fprintf(cp_err, "Can't open viewport for graphics.\n"); - return(FALSE); - } - - /* layout decisions */ - /* note: have to do before gr_fixgrid and after NewViewport */ - graph->viewportxoff = graph->fontwidth * 8; /* 8 lines on left */ - graph->viewportyoff = graph->fontheight * 4; /* 4 on bottom */ - - DevClear(); - - graph->grid.gridtype = gridtype; - graph->plottype = plottype; - graph->grid.xdatatype = xtype; - graph->grid.ydatatype = ytype; - graph->grid.xdelta = xdelta; - graph->grid.ydelta = ydelta; - graph->grid.ysized = 0; - graph->grid.xsized = 0; - - if (!graph->onevalue) { - if (xlabel) { - graph->grid.xlabel = xlabel; - } else { - graph->grid.xlabel = xname; - } - if (ylabel) { - graph->grid.ylabel = ylabel; - } - } else { - if (xlabel) { - graph->grid.xlabel = xlabel; - } else { - graph->grid.xlabel = "real"; - } - if (ylabel) { - graph->grid.ylabel = ylabel; - } else { - graph->grid.ylabel = "imag"; - } - } - - if (!pname) - pname = "(unknown)"; - if (!plotname) - plotname = "(unknown)"; - comb_title = tmalloc(strlen(plotname) + strlen(pname) + 3); - sprintf(comb_title, "%s: %s", pname, plotname); - graph->plotname = comb_title; - - gr_resize_internal(graph); - gr_redrawgrid(graph); - - /* Set up colors and line styles. */ - if (dispdev->numlinestyles == 1) - curlst = 0; /* Use the same one all the time. */ - else - curlst = 1; - /* XXX Special exception for SMITH */ - if (dispdev->numcolors > 2 && (graph->grid.gridtype == GRID_SMITH - || graph->grid.gridtype == GRID_SMITHGRID)) - { - curcolor = 3; - } else - curcolor = 1; - - graph->commandline = copy(commandline); - - return(TRUE); - -} - -/* - * Add a point to the curve we're currently drawing. - * Should be in between a gr_init() and a gr_end() - * expect when iplotting, very bad hack - * Differences from old gr_point: - * We save points here, instead of in lower levels. - * Assume we are in right context - * Save points in data space (not screen space). - * We pass two points in so we can multiplex plots. - * - */ -void -gr_point(struct dvec *dv, double newx, double newy, double oldx, double oldy, int np) -{ - int oldtox, oldtoy; /* value before clipping */ - - char pointc[2]; - - int fromx, fromy, tox, toy; - int ymin, dummy; - - DatatoScreen(currentgraph, oldx, oldy, &fromx, &fromy); - DatatoScreen(currentgraph, newx, newy, &tox, &toy); - -/* note: we do not particularly want to clip here */ - oldtox = tox; oldtoy = toy; - if (!currentgraph->grid.circular) { - if (clip_line(&fromx, &fromy, &tox, &toy, - currentgraph->viewportxoff, currentgraph->viewportyoff, - currentgraph->viewport.width + currentgraph->viewportxoff, - currentgraph->viewport.height + currentgraph->viewportyoff)) - return; - } else { - if (clip_to_circle(&fromx, &fromy, &tox, &toy, - currentgraph->grid.xaxis.circular.center, - currentgraph->grid.yaxis.circular.center, - currentgraph->grid.xaxis.circular.radius)) - return; - } - - if (currentgraph->plottype != PLOT_POINT) { - SetLinestyle(dv->v_linestyle); - } else { - /* if PLOT_POINT, - don't want to plot an endpoint which have been clipped */ - if (tox != oldtox || toy != oldtoy) - return; - } - SetColor(dv->v_color); - - switch (currentgraph->plottype) { - double *tics; - case PLOT_LIN: - - /* If it's a linear plot, ignore first point since we don't want - to connect with oldx and oldy. */ - if (np) - DrawLine(fromx, fromy, tox, toy); - if ((tics = (double *) currentgraph->ticdata)) { - for (; *tics < HUGE; tics++) { - if (*tics == (double) np) { - Text("x", (int) (tox - currentgraph->fontwidth / 2), - (int) (toy - currentgraph->fontheight / 2)); - SaveText(currentgraph, "x", - (int) (tox - currentgraph->fontwidth / 2), - (int) (toy - currentgraph->fontheight / 2)); - break; - } - } - } else if ((currentgraph->ticmarks >0) && (np > 0) - && (np % currentgraph->ticmarks == 0)) - { - /* Draw an 'x' */ - Text("x", (int) (tox - currentgraph->fontwidth / 2), - (int) (toy - currentgraph->fontheight / 2)); - SaveText(currentgraph, "x", - (int) (tox - currentgraph->fontwidth / 2), - (int) (toy - currentgraph->fontheight / 2)); - } - break; - case PLOT_COMB: - DatatoScreen(currentgraph, - (double) 0, currentgraph->datawindow.ymin, - &dummy, &ymin); - DrawLine(tox, ymin, tox, toy); - break; - case PLOT_POINT: - /* Here, gi_linestyle is the character used for the point. */ - pointc[0] = dv->v_linestyle; - pointc[1] = '\0'; - Text(pointc, (int) (tox - currentgraph->fontwidth / 2), - (int) (toy - currentgraph->fontheight / 2)); - /* gr_redraw will redraw this w/o our having to save it */ - /* SaveText(currentgraph, pointc, - (int) (tox - currentgraph->fontwidth / 2), - (int) (toy - currentgraph->fontheight / 2)); */ - default: - break; - } - -} - -static void -gr_start_internal(struct dvec *dv, bool copyvec) -{ - - struct dveclist *link; - char *s; - - /* Do something special with poles and zeros. Poles are 'x's, and - * zeros are 'o's. - */ - s = ft_typenames(dv->v_type); - if (eq(s, "pole")) { - dv->v_linestyle = 'x'; - return; - } else if (eq(s, "zero")) { - dv->v_linestyle = 'o'; - return; - } - - /* Find a (hopefully) new line style and color. */ - if (currentgraph->plottype == PLOT_POINT) { - if (pointchars[curlst - 1]) - curlst++; - else - curlst = 2; - } else if ((curlst > 0) && (++curlst == dispdev->numlinestyles)) - curlst = 2; - if ((curcolor > 0) && (++curcolor == dispdev->numcolors)) - curcolor = (((currentgraph->grid.gridtype == GRID_SMITH - || currentgraph->grid.gridtype == GRID_SMITHGRID) && - (dispdev->numcolors > 3)) ? 4 : 2); - if (currentgraph->plottype == PLOT_POINT) - dv->v_linestyle = pointchars[curlst - 2]; - else - dv->v_linestyle = curlst; - dv->v_color = curcolor; - -/* note: XXX */ -#ifdef notdef - /* This is a minor hack -- reset the color */ - if (dv->v_defcolor) - ReSetColor(curcolor, dv->v_defcolor); -#endif - - /* save the data so we can refresh */ - link = (struct dveclist *) calloc(1, sizeof(struct dveclist)); - link->next = currentgraph->plotdata; - - if (copyvec) { - link->vector = vec_copy(dv); - /* vec_copy doesn't set v_color or v_linestyle */ - link->vector->v_color = dv->v_color; - link->vector->v_linestyle = dv->v_linestyle; - link->vector->v_flags |= VF_PERMANENT; - } else { - link->vector = dv; - } - - currentgraph->plotdata = link; - - /* Put the legend entry on the screen. */ - drawlegend(currentgraph, plotno, dv); - - plotno++; - -} - -/* start one plot of a graph */ -void -gr_start(struct dvec *dv) -{ - - gr_start_internal(dv, TRUE); - -} - -/* make sure the linestyles in this graph don't exceed the number of - linestyles available in the current display device */ -void -gr_relinestyle(GRAPH *graph) -{ - - struct dveclist *link; - - for (link = graph->plotdata; link; link = link->next) { - if (graph->plottype == PLOT_POINT) continue; - if (!(link->vector->v_linestyle < dispdev->numlinestyles)) { - link->vector->v_linestyle %= dispdev->numlinestyles; - } - if (!(link->vector->v_color < dispdev->numcolors)) { - link->vector->v_color %= dispdev->numcolors; - } - } - -} - - /* PN static */ -void -drawlegend(GRAPH *graph, int plotno, struct dvec *dv) -{ - - int x, y, i; - char buf[16]; - - x = ((plotno % 2) ? graph->viewportxoff : - ((graph->viewport.width) / 2)); - y = graph->absolute.height - graph->fontheight - - ((plotno + 2) / 2) * (graph->fontheight); - i = y + graph->fontheight / 2 + 1; - SetColor(dv->v_color); - if (graph->plottype == PLOT_POINT) { - (void) sprintf(buf, "%c : ", dv->v_linestyle); - Text(buf, x + graph->viewport.width / 20 - - 3 * graph->fontwidth, y); - } else { - SetLinestyle(dv->v_linestyle); - DrawLine(x, i, x + graph->viewport.width / 20, i); - } - SetColor(1); - Text(dv->v_name, x + graph->viewport.width / 20 - + graph->fontwidth, y); - -} - -/* end one plot of a graph */ -void -gr_end(struct dvec *dv) -{ - Update(); -} - -/* Print text in the bottom line. */ - -void -gr_pmsg(char *text) -{ - char buf[BSIZE_SP]; - buf[0] = 0; - - Update(); - - if (cp_getvar("device", VT_STRING, buf) - && !(strcmp("/dev/tty", buf) == 0)) - fprintf(cp_err, "%s", text); - else - - if (currentgraph->grid.xlabel) /* MW. grid.xlabel may be NULL */ - Text(text, currentgraph->viewport.width - - (strlen(currentgraph->grid.xlabel) + 3) - * currentgraph->fontwidth, - currentgraph->absolute.height - currentgraph->fontheight); - - else fprintf(cp_err, " %s \n", text); - - Update(); - (void) getchar(); - return; -} - -void -gr_clean(void) -{ - Update(); - return; -} - -/* call this routine after viewport size changes */ -void -gr_resize(GRAPH *graph) -{ - - double oldxratio, oldyratio; - double scalex, scaley; - struct _keyed *k; - - oldxratio = graph->aspectratiox; - oldyratio = graph->aspectratioy; - - graph->grid.xsized = 0; - graph->grid.ysized = 0; - - gr_resize_internal(graph); - - /* scale keyed text */ - scalex = oldxratio / graph->aspectratiox; - scaley = oldyratio / graph->aspectratioy; - for (k = graph->keyed; k; k = k->next) { - k->x = (k->x - graph->viewportxoff) * scalex + graph->viewportxoff; - k->y = (k->y - graph->viewportyoff) * scaley + graph->viewportyoff; - } - - /* X also generates an expose after a resize - This is handled in X10 by not redrawing on resizes and waiting for - the expose event to redraw. In X11, the expose routine tries to - be clever and only redraws the region specified in an expose - event, which does not cover the entire region of the plot if the - resize was from a small window to a larger window. So in order - to keep the clever X11 expose event handling, we have the X11 - resize routine pull out expose events for that window, and we - redraw on resize also. - */ -#ifdef X_DISPLAY_MISSING - gr_redraw(graph); -#endif - -} - -/* PN static */ -void -gr_resize_internal(GRAPH *graph) -{ - - if (!graph->grid.xsized) - graph->viewport.width = graph->absolute.width - - 1.4 * graph->viewportxoff; - if (!graph->grid.ysized) - graph->viewport.height = graph->absolute.height - - 2 * graph->viewportyoff; - - gr_fixgrid(graph, graph->grid.xdelta, graph->grid.ydelta, - graph->grid.xdatatype, graph->grid.ydatatype); - - /* cache width and height info to make DatatoScreen go fast */ - /* note: XXX see if this is actually used anywhere */ - graph->datawindow.width = graph->datawindow.xmax - - graph->datawindow.xmin; - graph->datawindow.height = graph->datawindow.ymax - - graph->datawindow.ymin; - - /* cache (datawindow size) / (viewport size) */ - graph->aspectratiox = graph->datawindow.width / graph->viewport.width; - graph->aspectratioy = graph->datawindow.height / graph->viewport.height; - -} - -/* redraw everything in struct graph */ -void -gr_redraw(GRAPH *graph) -{ - - struct dveclist *link; - - /* establish current graph so default graphic calls will work right */ - PushGraphContext(graph); - - DevClear(); - - /* redraw grid */ - gr_redrawgrid(graph); - - for (link=graph->plotdata, plotno = 0; link; - link = link->next, plotno++) { - /* redraw legend */ - drawlegend(graph, plotno, link->vector); - - /* replot data - if onevalue, pass it a NULL scale - otherwise, if vec has its own scale, pass that - else pass vec's plot's scale - */ - ft_graf(link->vector, - graph->onevalue ? (struct dvec *) NULL : - (link->vector->v_scale ? - link->vector->v_scale : - link->vector->v_plot->pl_scale), - TRUE); - } - - gr_restoretext(graph); - - PopGraphContext(); - -} - -void -gr_restoretext(GRAPH *graph) -{ - - struct _keyed *k; - - /* restore text */ - for (k=graph->keyed; k; k = k->next) { - SetColor(k->colorindex); - Text(k->text, k->x, k->y); - } - -} - -/* Do some incremental plotting. 3 cases -- first, if length < IPOINTMIN, don't - * do anything. Second, if length = IPOINTMIN, plot what we have so far. Third, - * if length > IPOINTMIN, plot the last points and resize if needed. - * Note we don't check for pole / zero because they are of length 1. - */ - -/* note: there is a problem with multiple iplots that use the same vector, - namely, that vector has the same color throughout. This is another - reason why we need to pull color and linestyle out of dvec XXX - Or maybe even something more drastic ?? */ - -extern bool resumption; - -static int -iplot(struct plot *pl, int id) -{ - int len = pl->pl_scale->v_length; - struct dvec *v, *xs = pl->pl_scale; - double *lims, dy; - double start, stop, step; - register int j; - bool changed = FALSE; - int yt; - char *yl = NULL; - double xlims[2], ylims[2]; - static REQUEST reqst = { checkup_option, 0 }; - int inited = 0; - char commandline[513]; - - for (j = 0, v = pl->pl_dvecs; v; v = v->v_next) - if (v->v_flags & VF_PLOT) - j++; - if (!j) - return(0); - if (ft_grdb) - fprintf(cp_err, "Entering iplot, len = %d\n\r", len); - - if (len < IPOINTMIN) { - /* Nothing yet */ - return(0); - } else if (len == IPOINTMIN || !id - /* || (len > IPOINTMIN && resumption) */) { - resumption = FALSE; - /* Draw the grid for the first time, and plot everything. */ - lims = ft_minmax(xs, TRUE); - xlims[0] = lims[0]; - xlims[1] = lims[1]; - ylims[0] = HUGE; - ylims[1] = - ylims[0]; - for (v = pl->pl_dvecs; v; v = v->v_next) - if (v->v_flags & VF_PLOT) { - lims = ft_minmax(v, TRUE); - if (lims[0] < ylims[0]) - ylims[0] = lims[0]; - if (lims[1] > ylims[1]) - ylims[1] = lims[1]; - if (!yl) - yl = v->v_name; - } - if (ft_grdb) - fprintf(cp_err, - "iplot: after 5, xlims = %G, %G, ylims = %G, %G\n\r", - xlims[0], - xlims[1], - ylims[0], - ylims[1]); - for (yt = pl->pl_dvecs->v_type, v = pl->pl_dvecs->v_next; v; - v = v->v_next) - if ((v->v_flags & VF_PLOT) && (v->v_type != yt)) { - yt = 0; - break; - } -/* - (void) gr_init((double *) NULL, (double *) NULL, xs->v_name, - pl->pl_title, (char *) NULL, j, xdelta, ydelta, - GRID_LIN, plottype, xs->v_name, yl, xs->v_type, yt, - commandline, plotname); -*/ -/* note: have command options for iplot to specify xdelta, etc. - So don't need static variables hack. - Assume default values for now. -*/ - sprintf(commandline, "iplot %s", xs->v_name); - - (void) gr_init(xlims, ylims, xs->v_name, - pl->pl_title, (char *) NULL, j, 0.0, 0.0, - GRID_LIN, PLOT_LIN, xs->v_name, yl, xs->v_type, yt, - plot_cur->pl_typename, commandline); - for (v = pl->pl_dvecs; v; v = v->v_next) - if (v->v_flags & VF_PLOT) { - gr_start_internal(v, FALSE); - ft_graf(v, xs, TRUE); - } - inited = 1; - } else { - Input(&reqst, 0); - /* First see if we have to make the screen bigger */ - dy = (isreal(xs) ? xs->v_realdata[len - 1] : - realpart(&xs->v_compdata[len - 1])); - if (ft_grdb) - fprintf(cp_err, "x = %G\n\r", dy); - if (!if_tranparams(ft_curckt, &start, &stop, &step) || - !ciprefix("tran", pl->pl_typename)) { - stop = HUGE; - start = - stop; - } - while (dy < currentgraph->data.xmin) { - changed = TRUE; - if (ft_grdb) - fprintf(cp_err, "resize: xlo %G -> %G\n\r", - currentgraph->data.xmin, - currentgraph->data.xmin - - (currentgraph->data.xmax - - currentgraph->data.xmin) - * XFACTOR); - currentgraph->data.xmin -= - (currentgraph->data.xmax - - currentgraph->data.xmin) - * XFACTOR; - if (currentgraph->data.xmin < start) { - currentgraph->data.xmin = start; - break; - } - } - if (currentgraph->data.xmax < - currentgraph->data.xmin) - currentgraph->data.xmax = - currentgraph->data.xmin; - while (dy > currentgraph->data.xmax) { - changed = TRUE; - if (ft_grdb) - fprintf(cp_err, "resize: xhi %G -> %G\n\r", - currentgraph->data.xmax, - currentgraph->data.xmax + - (currentgraph->data.xmax - - currentgraph->data.xmin) * XFACTOR); - currentgraph->data.xmax += - (currentgraph->data.xmax - - currentgraph->data.xmin) * - XFACTOR; - if (currentgraph->data.xmax > stop) { - currentgraph->data.xmax = stop; - break; - } - } - for (v = pl->pl_dvecs; v; v = v->v_next) { - if (!(v->v_flags & VF_PLOT)) - continue; - dy = (isreal(v) ? v->v_realdata[len - 1] : - realpart(&v->v_compdata[len - 1])); - if (ft_grdb) - fprintf(cp_err, "y = %G\n\r", dy); - while (dy < currentgraph->data.ymin) { - changed = TRUE; - if (ft_grdb) - fprintf(cp_err, "resize: ylo %G -> %G\n\r", - currentgraph->data.ymin, - currentgraph->data.ymin - - (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR); - currentgraph->data.ymin -= - (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR; - } - if (currentgraph->data.ymax < - currentgraph->data.ymin) - currentgraph->data.ymax = - currentgraph->data.ymin; - while (dy > currentgraph->data.ymax) { - changed = TRUE; - if (ft_grdb) - fprintf(cp_err, "resize: yhi %G -> %G\n\r", - currentgraph->data.ymax, - currentgraph->data.ymax + - (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR); - currentgraph->data.ymax += - (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR; - } - } - if (changed) { - /* Redraw everything. */ - gr_pmsg("Resizing screen"); - gr_resize(currentgraph); - gr_redraw(currentgraph); - } else { - /* Just connect the last two points. This won't - * be done with curve interpolation, so it might - * look funny. - */ - for (v = pl->pl_dvecs; v; v = v->v_next) - if (v->v_flags & VF_PLOT) { - gr_point(v, - (isreal(xs) ? xs->v_realdata[len - 1] : - realpart(&xs->v_compdata[len - 1])), - (isreal(v) ? v->v_realdata[len - 1] : - realpart(&v->v_compdata[len - 1])), - (isreal(xs) ? xs->v_realdata[len - 2] : - realpart(&xs->v_compdata[len - 2])), - (isreal(v) ? v->v_realdata[len - 2] : - realpart(&v->v_compdata[len - 2])), - len - 1); - } - } - } - Update(); - return(inited); -} - -static void -set(struct plot *plot, struct dbcomm *db, bool unset, int mode) -{ - - struct dvec *v; - struct dbcomm *dc; - - if (db->db_type == DB_IPLOTALL || db->db_type == DB_TRACEALL) { - for (v = plot->pl_dvecs; v; v = v->v_next) { - if (unset) - v->v_flags &= ~mode; - else - v->v_flags |= mode; - } - return; - } - for (dc = db; dc; dc = dc->db_also) { - v = vec_fromplot(dc->db_nodename1, plot); - if (!v || v->v_plot != plot) { - if (!eq(dc->db_nodename1, "0") && !unset) { - fprintf(cp_err, "Warning: node %s non-existent in %s.\n", - dc->db_nodename1, plot->pl_name); - /* note: XXX remove it from dbs, so won't get further errors */ - } - continue; - } - if (unset) - v->v_flags &= ~mode; - else - v->v_flags |= mode; - } - return; -} - -static char * -getitright(char *buf, double num) -{ - char *p; - int k; - - sprintf(buf, " % .5g", num); - p =strchr(buf, '.'); - - if (p) { - return p - 4; - } else { - k = strlen(buf); - if (k > 8) - return buf + 4; - else /* k >= 4 */ - return buf + k - 4; - } -} - -static int hit, hit2; - -void reset_trace(void) -{ - hit = -1; - hit2 = -1; -} - -void -gr_iplot(struct plot *plot) -{ - - struct dbcomm *db; - int dontpop; /* So we don't pop w/o push. */ - char buf[30]; - - hit = 0; - for (db = dbs; db; db = db->db_next) { - if (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL) { - - if (db->db_graphid) PushGraphContext(FindGraph(db->db_graphid)); - - set(plot, db, FALSE, VF_PLOT); - - dontpop = 0; - if (iplot(plot, db->db_graphid)) { - /* graph just assigned */ - db->db_graphid = currentgraph->graphid; - dontpop = 1; - } - - set(plot, db, TRUE, VF_PLOT); - - if (!dontpop && db->db_graphid) PopGraphContext(); - - } else if (db->db_type == DB_TRACENODE || db->db_type == DB_TRACEALL) { - - struct dvec *v, *u; - int len; - - set(plot, db, FALSE, VF_PRINT); - - len = plot->pl_scale->v_length; - - dontpop = 0; - for (v = plot->pl_dvecs; v; v = v->v_next) { - if (v->v_flags & VF_PRINT) { - u = plot->pl_scale; - if (len <= 1 || hit <= 0 || hit2 < 0) { - if (len <= 1 || hit2 < 0) - term_clear( ); - else - term_home( ); - hit = 1; - hit2 = 1; - printf( - "\tExecution trace (remove with the \"delete\" command)"); - term_cleol( ); - printf("\n"); - - if (u) { - printf("%12s:", u->v_name); - if (isreal(u)) { - printf("%s", - getitright(buf, u->v_realdata[len - 1])); - } else { - - /* MW. Complex data here, realdata is NULL - (why someone use realdata here again) */ - printf("%s", - getitright(buf, u->v_compdata[len - 1].cx_real)); - printf(", %s", - getitright(buf, u->v_compdata[len - 1].cx_imag)); - } - term_cleol( ); - printf("\n"); - } - } - if (v == u) - continue; - printf("%12s:", v->v_name); - if (isreal(v)) { - printf("%s", getitright(buf, v->v_realdata[len - 1])); - } else { - - /* MW. Complex data again */ - printf("%s", getitright(buf, v->v_compdata[len - 1].cx_real)); - printf(", %s", getitright(buf, v->v_compdata[len - 1].cx_imag)); - } - term_cleol( ); - printf("\n"); - } - } - set(plot, db, TRUE, VF_PRINT); - - } - - } - -} - -/* - * This gets called after iplotting is done. We clear out the db_graphid - * fields. Copy the dvecs, which we referenced by reference, so - * DestroyGraph gets to free its own copy. Note: This is a clear - * case for separating the linestyle and color fields from dvec. - */ - -void -gr_end_iplot(void) -{ - - struct dbcomm *db, *prev, *next; - GRAPH *graph; - struct dveclist *link; - struct dvec *dv; - - prev = NULL; - for (db = dbs; db; prev = db, db = next) { - next = db->db_next; - if (db->db_type == DB_DEADIPLOT) { - if (db->db_graphid) { - DestroyGraph(db->db_graphid); - if (prev) - prev->db_next = next; - else - dbs = next; - dbfree(db); - } - } else if (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL) { - if (db->db_graphid) { - - /* get private copy of dvecs */ - graph = FindGraph(db->db_graphid); - - link = graph->plotdata; - - while (link) { - dv = link->vector; - link->vector = vec_copy(dv); - /* vec_copy doesn't set v_color or v_linestyle */ - link->vector->v_color = dv->v_color; - link->vector->v_linestyle = dv->v_linestyle; - link->vector->v_flags |= VF_PERMANENT; - link = link->next; - } - - db->db_graphid = 0; - } else { - /* warn that this wasn't plotted */ - fprintf(cp_err, "Warning: iplot %d was not executed.\n", - db->db_number); - } - } - } - - - return; -} - -double * -readtics(char *string) -{ - int i, k; - char *words, *worde; - double *tics, *ticsk; - - tics = (double *) tmalloc(MAXTICS * sizeof(double)); - ticsk = tics; - words = string; - - for (i = k = 0; *words && k < MAXTICS; words = worde) { - - while (isspace(*words)) - words++; - - worde = words; - while (isalpha(*worde) || isdigit(*worde)) - worde++; - - if (*worde) - *worde++ = '\0'; - - sscanf(words, "%lf", ticsk++); - - k++; - - } - *ticsk = HUGE; - return(tics); -} - diff --git a/src/frontend/graf.h b/src/frontend/graf.h deleted file mode 100644 index 7f72e0a06..000000000 --- a/src/frontend/graf.h +++ /dev/null @@ -1,30 +0,0 @@ -/************* - * Header file for graf.c - * 1999 E. Rouat - ************/ - -#ifndef GRAF_H_INCLUDED -#define GRAF_H_INCLUDED - -int gr_init(double *xlims, double *ylims, char *xname, char *plotname, char *hcopy, - int nplots, double xdelta, double ydelta, GRIDTYPE gridtype, PLOTTYPE plottype, - char *xlabel, char *ylabel, int xtype, int ytype, char *pname, char *commandline); -void gr_point(struct dvec *dv, double newx, double newy, double oldx, double oldy, int np); -void gr_start(struct dvec *dv); -void gr_relinestyle(GRAPH *graph); -void drawlegend(GRAPH *graph, int plotno, struct dvec *dv); -void gr_end(struct dvec *dv); -void gr_pmsg(char *text); -void gr_clean(void); -void gr_resize(GRAPH *graph); -void gr_resize_internal(GRAPH *graph); -void gr_redraw(GRAPH *graph); -void gr_restoretext(GRAPH *graph); -void reset_trace(void); -void gr_iplot(struct plot *plot); -void gr_end_iplot(void); -double * readtics(char *string); - - - -#endif diff --git a/src/frontend/graphdb.c b/src/frontend/graphdb.c deleted file mode 100644 index 6477da792..000000000 --- a/src/frontend/graphdb.c +++ /dev/null @@ -1,284 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -/* - Manage graph data structure. -*/ - -#include "ngspice.h" -#include "ftegraph.h" -#include "ftedebug.h" -#include "fteext.h" -#include "graphdb.h" - - - -/* invariant: currentgraph contains the current graph */ -GRAPH *currentgraph; - -/* - * We use a linked list rather than a circular one because we - * expect few links per list and we don't need to add at the - * end of a list (we can add at the beginning). - */ - -/* linked list of graphs */ -typedef struct listgraph { - /* we use GRAPH here instead of a pointer to save a calloc */ - GRAPH graph; - struct listgraph *next; -} LISTGRAPH; -#define NEWLISTGRAPH (LISTGRAPH *) calloc(1, sizeof(LISTGRAPH)) - -#define NUMGBUCKETS 16 - -typedef struct gbucket { - LISTGRAPH *list; -} GBUCKET; -/* #define NEWGBUCKET (GBUCKET *) calloc(1, sizeof(GBUCKET)) */ - -static GBUCKET GBucket[NUMGBUCKETS]; - -/* note: Zero is not a valid id. This is used in plot() in graf.c. */ -static int RunningId = 1; - -/* initialize graph structure */ -#define SETGRAPH(pgraph, id) (pgraph)->graphid = (id); \ - (pgraph)->degree = 1; \ - (pgraph)->linestyle = -1 - -/* returns NULL on error */ - -extern void internalerror (char *message); -extern void SaveText (GRAPH *graph, char *text, int x, int y); - -GRAPH *NewGraph(void) -{ - - GRAPH *pgraph; - LISTGRAPH *list; - int BucketId = RunningId % NUMGBUCKETS; - - if (!(list = NEWLISTGRAPH)) { - internalerror("can't allocate a listgraph"); - return((GRAPH *) NULL); - } - - pgraph = &list->graph; - SETGRAPH(pgraph, RunningId); - - if (!GBucket[BucketId].list) { - GBucket[BucketId].list = list; - } else { - /* insert at front of current list */ - list->next = GBucket[BucketId].list; - GBucket[BucketId].list = list; - } - - RunningId++ ; - - return(pgraph); - -} - -/* Given graph id, return graph */ -GRAPH *FindGraph(int id) -{ - - LISTGRAPH *list; - - for (list = GBucket[id % NUMGBUCKETS].list; - list && list->graph.graphid != id; - list = list->next) - - ; - - if (list) - return(&list->graph); - else - return(NULL); - -} - -GRAPH *CopyGraph(GRAPH *graph) -{ - - GRAPH *ret; - struct _keyed *k; - struct dveclist *link, *newlink; - - ret = NewGraph(); - bcopy(graph, ret, sizeof(struct graph)); - - ret->graphid = RunningId - 1; /* restore id */ - - /* copy keyed */ - for (ret->keyed = NULL, k = graph->keyed; k; k = k->next) { - SaveText(ret, k->text, k->x, k->y); - } - - /* copy dvecs */ - ret->plotdata = NULL; - for (link = graph->plotdata; link; link = link->next) { - newlink = (struct dveclist *) calloc(1, sizeof(struct dveclist)); - newlink->next = ret->plotdata; - newlink->vector = vec_copy(link->vector); - /* vec_copy doesn't set v_color or v_linestyle */ - newlink->vector->v_color = link->vector->v_color; - newlink->vector->v_linestyle = link->vector->v_linestyle; - newlink->vector->v_flags |= VF_PERMANENT; - ret->plotdata = newlink; - } - - ret->commandline = copy(graph->commandline); - ret->plotname = copy(graph->plotname); - - return(ret); - -} - -int -DestroyGraph(int id) -{ - - LISTGRAPH *list, *lastlist; - struct _keyed *k, *nextk; - struct dveclist *d, *nextd; - extern struct dbcomm *dbs; - struct dbcomm *db; - - list = GBucket[id % NUMGBUCKETS].list; - lastlist = NULL; - while (list) { - if (list->graph.graphid == id) { /* found it */ - - /* Fix the iplot/trace dbs list */ - for (db = dbs; db && db->db_graphid != id; db = db->db_next) - ; - - if (db && (db->db_type == DB_IPLOT - || db->db_type == DB_IPLOTALL)) { - db->db_type = DB_DEADIPLOT; - /* Delete this later */ - return(0); - } - - /* adjust bucket pointers */ - if (lastlist) { - lastlist->next = list->next; - } else { - GBucket[id % NUMGBUCKETS].list = list->next; - } - - /* run through and de-allocate dynamically allocated keyed list */ - k=list->graph.keyed; - while (k) { - nextk = k->next; - free(k->text); - free(k); - k = nextk; - } - - /* de-allocate dveclist */ - d = list->graph.plotdata; - while (d) { - nextd = d->next; - tfree(d->vector->v_name); - if (isreal(d->vector)) { - tfree(d->vector->v_realdata); - } else { - tfree(d->vector->v_compdata); - } - free(d->vector); - free(d); - d = nextd; - } - - free(list->graph.commandline); - free(list->graph.plotname); - - /* If device dependent space allocated, free it. */ - if (list->graph.devdep) - free(list->graph.devdep); - free(list); - - return(1); - } - lastlist = list; - list = list->next; - } - - internalerror("tried to destroy non-existent graph"); - return (0); - -} - -/* free up all dynamically allocated data structures */ -void -FreeGraphs(void) -{ - - GBUCKET *gbucket; - LISTGRAPH *list, *deadl; - - for (gbucket = GBucket; gbucket < &GBucket[NUMGBUCKETS]; gbucket++) { - list = gbucket->list; - while (list) { - deadl = list; - list = list->next; - free(deadl); - } - } - -} - -void -SetGraphContext(int graphid) -{ - - currentgraph = FindGraph(graphid); - -} - -typedef struct gcstack { - GRAPH *pgraph; - struct gcstack *next; -} GCSTACK; -GCSTACK *gcstacktop; -#define NEWGCSTACK (GCSTACK *) calloc(1, sizeof(GCSTACK)) - -/* note: This Push and Pop has tricky semantics. - Push(graph) will push the currentgraph onto the stack - and set currentgraph to graph. - Pop() simply sets currentgraph to the top of the stack and pops stack. -*/ -void -PushGraphContext(GRAPH *graph) -{ - - GCSTACK *gcstack = NEWGCSTACK; - - if (!gcstacktop) { - gcstacktop = gcstack; - } else { - gcstack->next = gcstacktop; - gcstacktop = gcstack; - } - gcstacktop->pgraph = currentgraph; - currentgraph = graph; - -} - -void -PopGraphContext(void) -{ - - GCSTACK *dead; - - currentgraph = gcstacktop->pgraph; - dead = gcstacktop; - gcstacktop = gcstacktop->next; - free(dead); - -} diff --git a/src/frontend/graphdb.h b/src/frontend/graphdb.h deleted file mode 100644 index 130e1450d..000000000 --- a/src/frontend/graphdb.h +++ /dev/null @@ -1,20 +0,0 @@ -/************* - * Header file for graphdb.c - * 1999 E. Rouat - ************/ - -#ifndef GRAPHDB_H_INCLUDED -#define GRAPHDB_H_INCLUDED - -GRAPH *NewGraph(void); -GRAPH *FindGraph(int id); -GRAPH *CopyGraph(GRAPH *graph); -int DestroyGraph(int id); -void FreeGraphs(void); -void SetGraphContext(int graphid); -void PushGraphContext(GRAPH *graph); -void PopGraphContext(void); - - - -#endif diff --git a/src/frontend/grid.c b/src/frontend/grid.c deleted file mode 100644 index 7f2fd635f..000000000 --- a/src/frontend/grid.c +++ /dev/null @@ -1,1602 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -/* - - Routines to draw the various sorts of grids -- linear, log, polar. -*/ - -#include "ngspice.h" -#include "ftegraph.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "fteparse.h" -#include "grid.h" - - -#define RAD_TO_DEG (180.0 / M_PI) -#define LABEL_CHARS 20 - - -/* static declarations */ -static double * lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis); -static double * loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis); -static void polargrid(GRAPH *graph); -static void drawpolargrid(GRAPH *graph); -static void adddeglabel(GRAPH *graph, int deg, int x, int y, int cx, int cy, int lx, int ly); -static void addradlabel(GRAPH *graph, int lab, double theta, int x, int y); -static void smithgrid(GRAPH *graph); -static void drawsmithgrid(GRAPH *graph); -static void arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, - double radoff, int maxrad, int centx, int centy, int xoffset, int yoffset, - char *plab, char *nlab, int pdeg, int ndeg, int pxmin, int pxmax); -static double cliparc(double cx, double cy, double rad, double start, double end, int iclipx, - int iclipy, int icliprad, int flag); - - - - -/* note: scaleunits is static and never changed in this file - ie, can get rid of it */ -static bool scaleunits = TRUE; - - -extern void SetColor (int colorid); -extern void SetLinestyle (int linestyleid); -extern void Text (char *text, int x, int y); -void drawloggrid (GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, int pp, Axis axis); -void drawlingrid (GRAPH *graph, char *units, int spacing, int nsp, double dst, double lmt, double hmt, bool onedec, int mult, double mag, int digits, Axis axis); -extern void DrawLine (int x1, int y1, int x2, int y2); -extern void Update (void); -extern void Arc (int x0, int y0, int radius, double theta1, double theta2); - -void -gr_fixgrid(GRAPH *graph, double xdelta, double ydelta, int xtype, int ytype) -{ - double *dd; - - if (graph->grid.gridtype == GRID_NONE) { - graph->grid.gridtype = GRID_LIN; - } - - SetColor(1); - SetLinestyle(1); - - if ((graph->data.xmin > graph->data.xmax) - || (graph->data.ymin > graph->data.ymax)) { - fprintf(cp_err, - "gr_fixgrid: Internal Error - bad limits: %g, %g, %g, %g\r\n", - graph->data.xmin, graph->data.xmax, - graph->data.ymin, graph->data.ymax); - return; - } - - if (graph->grid.gridtype == GRID_POLAR) { - graph->grid.circular = TRUE; - polargrid(graph); - return; - } else if (graph->grid.gridtype == GRID_SMITH - || graph->grid.gridtype == GRID_SMITHGRID) - { - graph->grid.circular = TRUE; - smithgrid(graph); - return; - } - graph->grid.circular = FALSE; - - if ((graph->grid.gridtype == GRID_YLOG) - || (graph->grid.gridtype == GRID_LOGLOG)) - dd = loggrid(graph, graph->data.ymin, graph->data.ymax, - ytype, y_axis); - else - dd = lingrid(graph, graph->data.ymin, graph->data.ymax, - ydelta, ytype, y_axis); - - graph->datawindow.ymin = dd[0]; - graph->datawindow.ymax = dd[1]; - - if ((graph->grid.gridtype == GRID_XLOG) - || (graph->grid.gridtype == GRID_LOGLOG)) - dd = loggrid(graph, graph->data.xmin, graph->data.xmax, - xtype, x_axis); - else - dd = lingrid(graph, graph->data.xmin, graph->data.xmax, - xdelta, xtype, x_axis); - - graph->datawindow.xmin = dd[0]; - graph->datawindow.xmax = dd[1]; - -/* do we really need this? */ -/* - SetLinestyle(0); - DrawLine(graph->viewportxoff, graph->viewportyoff, - graph->viewport.width + graph->viewportxoff, - graph->viewportyoff); - DrawLine(graph->viewportxoff, graph->viewportyoff, - graph->viewportxoff, - graph->viewport.height + graph->viewportyoff); - SetLinestyle(1); -*/ - - return; -} - -void -gr_redrawgrid(GRAPH *graph) -{ - - SetColor(1); - SetLinestyle(1); - /* draw labels */ - if (graph->grid.xlabel) { - Text(graph->grid.xlabel, - (int) (graph->absolute.width * 0.35), - graph->fontheight); - } - if (graph->grid.ylabel) { - if (graph->grid.gridtype == GRID_POLAR - || graph->grid.gridtype == GRID_SMITH - || graph->grid.gridtype == GRID_SMITHGRID) { - Text(graph->grid.ylabel, - graph->fontwidth, - (graph->absolute.height * 3) / 4 ); - } else { - Text(graph->grid.ylabel, - graph->fontwidth, - graph->absolute.height / 2 ); - } - } - - switch( graph->grid.gridtype ) { - case GRID_POLAR: - drawpolargrid(graph); - break; - case GRID_SMITH: - drawsmithgrid(graph); - break; - case GRID_SMITHGRID: - drawsmithgrid(graph); - break; - - - case GRID_XLOG: - case GRID_LOGLOG: - drawloggrid(graph, - graph->grid.xaxis.log.units, - graph->grid.xaxis.log.hmt, - graph->grid.xaxis.log.lmt, - graph->grid.xaxis.log.decsp, - graph->grid.xaxis.log.subs, - graph->grid.xaxis.log.pp, x_axis); - break; - default: - drawlingrid(graph, - graph->grid.xaxis.lin.units, - graph->grid.xaxis.lin.spacing, - graph->grid.xaxis.lin.numspace, - graph->grid.xaxis.lin.distance, - graph->grid.xaxis.lin.lowlimit, - graph->grid.xaxis.lin.highlimit, - graph->grid.xaxis.lin.onedec, - graph->grid.xaxis.lin.mult, - graph->grid.xaxis.lin.tenpowmag - / graph->grid.xaxis.lin.tenpowmagx, - graph->grid.xaxis.lin.digits, - x_axis); - break; - } - - switch( graph->grid.gridtype ) { - case GRID_POLAR: - case GRID_SMITH: - case GRID_SMITHGRID: - break; - - case GRID_YLOG: - case GRID_LOGLOG: - drawloggrid(graph, - graph->grid.yaxis.log.units, - graph->grid.yaxis.log.hmt, - graph->grid.yaxis.log.lmt, - graph->grid.yaxis.log.decsp, - graph->grid.yaxis.log.subs, - graph->grid.yaxis.log.pp, y_axis); - break; - default: - drawlingrid(graph, - graph->grid.yaxis.lin.units, - graph->grid.yaxis.lin.spacing, - graph->grid.yaxis.lin.numspace, - graph->grid.yaxis.lin.distance, - graph->grid.yaxis.lin.lowlimit, - graph->grid.yaxis.lin.highlimit, - graph->grid.yaxis.lin.onedec, - graph->grid.yaxis.lin.mult, - graph->grid.yaxis.lin.tenpowmag - / graph->grid.yaxis.lin.tenpowmagx, - graph->grid.yaxis.lin.digits, - y_axis); - break; - } - -} - -/* Plot a linear grid. Returns the new hi and lo limits. */ -static double * -lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis) -{ - int mag, mag2, mag3; - double hmt, lmt, dst; - int nsp; - double tenpowmag, tenpowmag2, step, spacing; - bool onedec = FALSE; - int margin; - int max; - static double dd[2]; - int mult = 1; - char buf[LABEL_CHARS], *s; - int slim, digits; - - if (axis == y_axis && graph->grid.ysized) { - lmt = graph->grid.yaxis.lin.lowlimit; - hmt = graph->grid.yaxis.lin.highlimit; - tenpowmag = graph->grid.yaxis.lin.tenpowmag; - dd[0] = lmt * tenpowmag; - dd[1] = hmt * tenpowmag; - return dd; - } - - if (axis == x_axis && graph->grid.xsized) { - lmt = graph->grid.xaxis.lin.lowlimit; - hmt = graph->grid.xaxis.lin.highlimit; - tenpowmag = graph->grid.xaxis.lin.tenpowmag; - dd[0] = lmt * tenpowmag; - dd[1] = hmt * tenpowmag; - return dd; - } - - if (delta < 0.0) { - fprintf(cp_err, "Warning: %cdelta is negative -- reversed\n", - (axis == x_axis) ? 'x' : 'y'); - delta = -delta; - } - - mag2 = floor(log10(fabs(hi - lo))); - tenpowmag2 = pow(10.0, (double) mag2); - - /* Round lo down, and hi up */ - - /* First, round lo _up_ and hi _down_ out to the 3rd digit of accuracy */ - lmt = (ceil(1000 * lo / tenpowmag2)) / 1000.0; - hmt = (floor(1000 * hi / tenpowmag2 + 0.9)) / 1000.0; - - lmt = floor(10.0 * lmt) / 10.0; - hmt = ceil(10.0 * hmt) / 10.0; - - lo = lmt * tenpowmag2; - hi = hmt * tenpowmag2; - - if (fabs(hi) > fabs(lo)) - mag = floor(log10(fabs(hi))); - else - mag = floor(log10(fabs(lo))); - - if (mag >= 0) - mag3 = ((int) (mag / 3)) * 3; - else - mag3 = - ((int) ((2 - mag) / 3)) * 3; - - if (scaleunits) - digits = mag3 - mag2; - else { - digits = mag - mag2; - mag3 = mag; - } - - if (digits < 1) - digits = 0; - - if (axis == x_axis) { - margin = graph->viewportxoff; - /*max = graph->viewport.width + graph->viewportxoff;*/ - max = graph->absolute.width - graph->viewportxoff; - } else { - graph->viewportxoff = (digits + 5 + mag - mag3) * graph->fontwidth; - margin = graph->viewportyoff; - /*max = graph->viewport.height + graph->viewportyoff;*/ - max = graph->absolute.height - graph->viewportyoff; - } - - /* Express the difference between the high and low values as - * diff = d * 10^mag. We know diff >= 0.0. If scaleunits is - * set then make sure that mag is modulo 3. - */ - - dst = hmt - lmt; - - /* We have to go from lmt to hmt, so think of some useful places - * to put grid lines. We will have a total of nsp lines, one - * every spacing pixels, which is every dst / nsp units. - */ - - if (scaleunits) { - static char scaleletters[ ] = "afpnum\0kMGT"; - char *p; - int i, j; - - tenpowmag = pow(10.0, (double) mag3); - - *buf = 0; - - i = (mag3 + 18) / 3; - - if (i < 0) - i = 6; /* No scale units */ - else if (i >= sizeof(scaleletters) - 1) { - /* sizeof includes '\0' at end, which is useless */ - /* i = sizeof(scaleletters) - 2; */ - i = 6; /* No scale units */ - } - - j = mag3 - i * 3 + 18; - if (j == 1) - (void) sprintf(buf, "x10 "); - else if (j == 2) - (void) sprintf(buf, "x100 "); - else if (j) - (void) sprintf(buf, "x10^%d ", j); - - if (scaleletters[i]) { - for (p = buf; *p; p++) - ; - *p++ = scaleletters[i]; - *p++ = 0; - } - - } else if (mag > 1) { - tenpowmag = pow(10.0, (double) mag); - (void) sprintf(buf, "x10^%d ", mag); - } - - if ((s = ft_typabbrev(type))) { - (void) strcat(buf, s); - } else { - (void) strcat(buf, "Units"); - } - - if (delta == 0.0) { - int i; - double step; - - static struct { float div_lim, step; } div_list[ ] = { - { 100.0, 10.0 }, - { 50.0, 5.0 }, - { 20.0, 2.0 }, - { 6.0, 1.0 }, - { 3.0, 0.5 }, - { 1.0, 0.2 }, - { 0.5, 0.1 }, - { 0.0, 0.05 }, - { 0.0, 0.01 } - }; - - for (i = 0; i < NUMELEMS(div_list); i++) { - if (dst > div_list[i].div_lim) { - break; - } - } - - do { - step = div_list[i].step; - nsp = (dst + step - 0.0001) / step; - spacing = (max - margin) / nsp; - i += 1; - } while (i < NUMELEMS(div_list) && spacing > 50); - - if (axis == x_axis) { - slim = digits + 5 + mag - mag3; - slim = graph->fontwidth * (slim + 1); - } else - slim = graph->fontheight * 3; - - while (i > 0 && spacing < slim + 3) { - i -= 1; - step = div_list[i].step; - nsp = (dst + step - 0.0001) / step; - spacing = (max - margin) / nsp; - } - - if (lmt < 0) - lmt = - ceil(-lmt / step) * step; - else - lmt = floor(lmt / step) * step; - - if (hmt < 0) - hmt = - floor(-hmt / step) * step; - else - hmt = ceil(hmt / step) * step; - - dst = hmt - lmt; - - lo = lmt * tenpowmag2; - hi = hmt * tenpowmag2; - - nsp = (dst + step - 0.0001) / step; - - } else { - /* The user told us where to put the grid lines. They will - * not be equally spaced in this case (i.e, the right edge - * won't be a line). - */ - nsp = (hi - lo) / delta; - if (nsp > 100) - nsp = 100; - step = (max - margin) * delta / (hi - lo); - } - spacing = (max - margin) / nsp; - - dd[0] = lo; - dd[1] = hi; - - /* Reset the max coordinate to deal with round-off error. */ - if (nsp && (delta == 0.0)) { - if (axis == x_axis) - graph->viewport.width = spacing * nsp; - else - graph->viewport.height = spacing * nsp; - } else if (!nsp) { - nsp = 1; - } - - /* have to save non-intuitive variables left over - from old algorithms for redraws */ - - if (axis == x_axis) { - graph->grid.xsized = 1; - graph->grid.xaxis.lin.onedec = onedec; - graph->grid.xaxis.lin.mult = mult; - graph->grid.xaxis.lin.tenpowmag = tenpowmag2; - graph->grid.xaxis.lin.tenpowmagx = tenpowmag; - graph->grid.xaxis.lin.digits = digits; - (void) strcpy(graph->grid.xaxis.lin.units, buf); - graph->grid.xaxis.lin.distance = dst; - graph->grid.xaxis.lin.lowlimit = lmt; - graph->grid.xaxis.lin.highlimit = hmt; - graph->grid.xaxis.lin.spacing = spacing; - graph->grid.xaxis.lin.numspace = nsp; - } else { - graph->grid.ysized = 1; - graph->grid.yaxis.lin.onedec = onedec; - graph->grid.yaxis.lin.mult = mult; - graph->grid.yaxis.lin.tenpowmag = tenpowmag2; - graph->grid.yaxis.lin.tenpowmagx = tenpowmag; - graph->grid.yaxis.lin.digits = digits; - (void) strcpy(graph->grid.yaxis.lin.units, buf); - graph->grid.yaxis.lin.distance = dst; - graph->grid.yaxis.lin.lowlimit = lmt; - graph->grid.yaxis.lin.highlimit = hmt; - graph->grid.yaxis.lin.spacing = spacing; - graph->grid.yaxis.lin.numspace = nsp; - } - - return (dd); -} - -/* PN static */ -void -drawlingrid(GRAPH *graph, char *units, int spacing, int nsp, double dst, double lmt, double hmt, bool onedec, int mult, double mag, int digits, Axis axis) -{ - - int i, j; - double m, step; - char buf[LABEL_CHARS]; - - /* i counts how many pixels we have drawn, and j counts which unit - * we are at. - */ - SetLinestyle(1); - step = floor((double) dst / nsp * 100.0 + 0.000001); - for (i = 0, m = lmt * 100.0; m - 0.001 <= hmt * 100.0; - i += spacing, m += step) - { - j = m; - if (j == 0) - SetLinestyle(0); - if (graph->grid.gridtype != GRID_NONE) { - if (axis == x_axis) - DrawLine(graph->viewportxoff + i, - graph->viewportyoff, graph->viewportxoff + i, - graph->viewport.height + graph->viewportyoff); - else - DrawLine(graph->viewportxoff, - graph->viewportyoff + i, - graph->viewport.width + graph->viewportxoff, - graph->viewportyoff + i); - } - if (j == 0) - SetLinestyle(1); - - (void) sprintf(buf, "%.*f", digits + 1, m * mag / 100.0); - -#ifdef notdef - if (floor(step/10.0) != step/10.0) - (void) sprintf(buf, "%.*lf", mag, m * mag / 100.0); - else if (floor(step/100.0) != step/100.0) - (void) sprintf(buf, "%.1lf", m * mag / 100.0); - else - (void) sprintf(buf, "%lg", j * mag / 100); -#endif - - if (axis == x_axis) - Text(buf, graph->viewportxoff + i - - strlen(buf) / 2 * graph->fontwidth, - (int) (graph->fontheight * 2.5)); - else - Text(buf, graph->viewportxoff - - graph->fontwidth * (strlen(buf)), - graph->viewportyoff + i - - graph->fontheight / 2); - - /* This is to make sure things work when delta > hi - lo. */ - if (nsp == 1) - j += 1000; - } - if (axis == x_axis) - Text(units, (int) (graph->absolute.width * 0.6), - graph->fontheight); - else - Text(units, graph->fontwidth, - (int) (graph->absolute.height - 2 * graph->fontheight)); - Update(); - -} - -/* Plot a log grid. Note that we pay no attention to x- and y-delta here. */ -static double * -loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis) -{ - static double dd[2]; - int margin; - int max; - int subs, pp, decsp, lmt, hmt; - int i, j; - double k; - double decs; - char buf[LABEL_CHARS], *s; - - if (axis == x_axis && graph->grid.xsized) { - lmt = graph->grid.xaxis.log.lmt; - hmt = graph->grid.xaxis.log.hmt; - dd[0] = pow(10.0, (double) lmt); - dd[1] = pow(10.0, (double) hmt); - return dd; - } else if (axis == y_axis && graph->grid.ysized) { - lmt = graph->grid.yaxis.log.lmt; - hmt = graph->grid.yaxis.log.hmt; - dd[0] = pow(10.0, (double) lmt); - dd[1] = pow(10.0, (double) hmt); - return dd; - } - - if (axis == x_axis) { - margin = graph->viewportxoff; - max = graph->absolute.width - graph->viewportxoff; - } else { - margin = graph->viewportyoff; - max = graph->absolute.height - graph->viewportyoff; - } - - /* How many orders of magnitude. We are already guaranteed that hi - * and lo are positive. - */ - - lmt = floor(mylog10(lo)); - hmt = ceil(mylog10(hi)); - - decs = hmt - lmt; - - pp = 1; - decsp = (max - margin) / decs; - - if (decsp < 20) { - pp = ceil(20.0 / decsp); - decsp *= pp; - subs = 1; - } else if (decsp > 50) { - static int divs[ ] = { 20, 10, 5, 4, 2, 1 }; - - k = 5.0 / decsp; - - for (i = 0; i < NUMELEMS(divs) - 1; i++) { - j = divs[i]; - if (-log10(((double) j - 1.0) / j) > k) - break; - } - - subs = divs[i]; - - } else - subs = 1; - - /* Start at a line */ - lmt = floor((double) lmt / pp) * pp; - decs = hmt - lmt; - decsp = (max - margin) / decs; - - dd[0] = pow(10.0, (double) lmt); - dd[1] = pow(10.0, (double) hmt); - - if ((s = ft_typabbrev(type))) { - (void) strcpy(buf, s); - } else { - (void) strcpy(buf, "Units"); - } - - if (axis == x_axis) { - (void) strcpy(graph->grid.xaxis.log.units, buf); - graph->viewport.width = decs * decsp; - graph->grid.xaxis.log.hmt = hmt; - graph->grid.xaxis.log.lmt = lmt; - graph->grid.xaxis.log.decsp = decsp; - graph->grid.xaxis.log.subs = subs; - graph->grid.xaxis.log.pp = pp; - graph->grid.xsized = 1; - } else { - (void) strcpy(graph->grid.yaxis.log.units, buf); - graph->viewport.height = decs * decsp; - graph->grid.yaxis.log.hmt = hmt; - graph->grid.yaxis.log.lmt = lmt; - graph->grid.yaxis.log.decsp = decsp; - graph->grid.yaxis.log.subs = subs; - graph->grid.yaxis.log.pp = pp; - graph->grid.ysized = 1; - } - - return (dd); - -} - -/* PN static */ -void -drawloggrid(GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, int pp, Axis axis) -{ - int i, j, k, m; - double t; - char buf[LABEL_CHARS]; - - /* Now plot every pp'th decade line, with subs lines between them. */ - if (subs > 1) - SetLinestyle(0); - for (i = 0, j = lmt; j <= hmt; i += decsp * pp, j += pp) { - /* Draw the decade line */ - if (graph->grid.gridtype != GRID_NONE) { - if (axis == x_axis) - DrawLine(graph->viewportxoff + i, - graph->viewportyoff, - graph->viewportxoff + i, - graph->viewport.height - +graph->viewportyoff); - else - DrawLine(graph->viewportxoff, - graph->viewportyoff + i, - graph->viewport.width - + graph->viewportxoff, - graph->viewportyoff + i); - } - if (j == -2) - (void) sprintf(buf, "0.01"); - else if (j == -1) - (void) sprintf(buf, "0.1"); - else if (j == 0) - (void) sprintf(buf, "1"); - else if (j == 1) - (void) sprintf(buf, "10"); - else if (j == 2) - (void) sprintf(buf, "100"); - else - (void) sprintf(buf, "10^%d", j); - if (axis == x_axis) - Text(buf, graph->viewportxoff + i - strlen(buf) / 2, - (int) (graph->fontheight * 2.5)); - else - Text(buf, graph->viewportxoff - graph->fontwidth * - (strlen(buf) + 1), - graph->viewportyoff + i - - graph->fontheight / 2); - - if (j >= hmt) - break; - - /* Now draw the subdivision lines */ - if (subs > 1) { - SetLinestyle(1); - t = 10.0 / subs; - for (k = ceil(subs / 10.0) + 1; k < subs; k++) { - m = i + decsp * log10((double) t * k); - if (graph->grid.gridtype != GRID_NONE) { - if (axis == x_axis) - DrawLine(graph->viewportxoff + m, - graph->viewportyoff, - graph->viewportxoff + m, - graph->viewport.height - + graph->viewportyoff); - else - DrawLine(graph->viewportxoff, - graph->viewportyoff + m, - graph->viewport.width - + graph->viewportxoff, - graph->viewportyoff + m); - } - } - SetLinestyle(0); - } - } - if (axis == x_axis) - Text(units, (int) (graph->absolute.width * 0.6), - graph->fontheight); - else - Text(units, graph->fontwidth, - (int) (graph->absolute.height - 2 * graph->fontheight)); - Update(); -} - -/* Polar grids */ - -static void -polargrid(GRAPH *graph) -{ - double d, mx, my, tenpowmag; - int hmt, lmt, mag; - double minrad, maxrad; - bool centered = FALSE; - - /* Make sure that our area is square. */ - if (graph->viewport.width > graph->viewport.height) { - graph->viewport.width = graph->viewport.height; - } else { - graph->viewport.height = graph->viewport.width; - } - - /* Make sure that the borders are even */ - if (graph->viewport.width & 1) { - graph->viewport.width += 1; - graph->viewport.height += 1; - } - graph->grid.xaxis.circular.center = graph->viewport.width / 2 - + graph->viewportxoff; - graph->grid.yaxis.circular.center = graph->viewport.height / 2 - + graph->viewportyoff; - - graph->grid.xaxis.circular.radius = graph->viewport.width / 2; - - /* Figure out the minimum and maximum radii we're dealing with. */ - mx = (graph->data.xmin + graph->data.xmax) / 2; - my = (graph->data.ymin + graph->data.ymax) / 2; - d = sqrt(mx * mx + my * my); - maxrad = d + (graph->data.xmax - graph->data.xmin) / 2; - minrad = d - (graph->data.xmax - graph->data.xmin) / 2; - - if (maxrad == 0.0) { - fprintf(cp_err, "Error: 0 radius in polargrid\n"); - return; - } - if ((graph->data.xmin < 0) && (graph->data.ymin < 0) && - (graph->data.xmax > 0) && (graph->data.ymax > 0)) - minrad = 0; - if ((graph->data.xmin == - graph->data.xmax) - && (graph->data.ymin == -graph->data.ymax) - && (graph->data.xmin == graph->data.ymin)) - centered = TRUE; - - mag = floor(mylog10(maxrad)); - tenpowmag = pow(10.0, (double) mag); - hmt = maxrad / tenpowmag; - lmt = minrad / tenpowmag; - if (hmt * tenpowmag < maxrad) - hmt++; - if (lmt * tenpowmag > minrad) - lmt--; - maxrad = hmt * tenpowmag; - minrad = lmt * tenpowmag; - - /* Make sure that the range is square */ - mx = graph->data.xmax - graph->data.xmin; - my = graph->data.ymax - graph->data.ymin; - graph->datawindow.xmin = graph->data.xmin; - graph->datawindow.xmax = graph->data.xmax; - graph->datawindow.ymin = graph->data.ymin; - graph->datawindow.ymax = graph->data.ymax; - if (mx > my) { - graph->datawindow.ymin -= (mx - my) / 2; - graph->datawindow.ymax += (mx - my) / 2; - } else if (mx < my) { - graph->datawindow.xmin -= (my - mx) / 2; - graph->datawindow.xmax += (my - mx) / 2; - } - - /* Range is square with upper bound maxrad */ - -#ifdef notdef - xx = graph->datawindow.xmin + graph->datawindow.xmax; - yy = graph->datawindow.ymin + graph->datawindow.ymax; - graph->datawindow.xmin = xx - maxrad; - graph->datawindow.xmax = xx + maxrad; - graph->datawindow.ymin = yy - maxrad; - graph->datawindow.ymax = yy + maxrad; -#endif - - -#ifdef notdef - if (ft_grdb) - printf("polar: maxrad = %g, center = (%g, %g)\n", maxrad, xx, yy); - - if ((minrad == 0) && ((hmt - lmt) > 5)) { - if (!((hmt - lmt) % 2)) - step = 2; - else if (!((hmt - lmt) % 3)) - step = 3; - else - step = 1; - } else - step = 1; - - graph->grid.xaxis.circular.lmt = lmt; - graph->grid.yaxis.circular.lmt = step; -#endif - - graph->grid.xaxis.circular.hmt = hmt; - graph->grid.xaxis.circular.lmt = lmt; - graph->grid.xaxis.circular.mag = mag; - -#ifdef notdef - graph->datawindow.xmin = xx - maxrad; - graph->datawindow.xmax = xx + maxrad; - graph->datawindow.ymin = yy - maxrad; - graph->datawindow.ymax = yy + maxrad; -#endif - -} - - -static void -drawpolargrid(GRAPH *graph) -{ - double tenpowmag, theta; - int hmt, lmt, i, step, mag; - int relcx, relcy, relrad, dist, degs; - int x1, y1, x2, y2; - double minrad, maxrad, pixperunit; - char buf[64]; - -#ifdef notdef - step = graph->grid.yaxis.circular.lmt; - mag = floor(mylog10(maxrad)); - tenpowmag = pow(10.0, (double) mag); - pixperunit = graph->grid.xaxis.circular.radius / (maxrad - minrad); -#endif - hmt = graph->grid.xaxis.circular.hmt; - lmt = graph->grid.xaxis.circular.lmt; - mag = graph->grid.xaxis.circular.mag; - tenpowmag = pow(10.0, (double) mag); - maxrad = hmt * tenpowmag; - minrad = lmt * tenpowmag; - - if ((minrad == 0) && ((hmt - lmt) > 5)) { - if (!((hmt - lmt) % 2)) - step = 2; - else if (!((hmt - lmt) % 3)) - step = 3; - else - step = 1; - } else - step = 1; - pixperunit = graph->grid.xaxis.circular.radius * 2 / - (graph->datawindow.xmax - graph->datawindow.xmin); - - relcx = - (graph->datawindow.xmin + graph->datawindow.xmax) / 2 - * pixperunit; - relcy = - (graph->datawindow.ymin + graph->datawindow.ymax) / 2 - * pixperunit; - - /* The distance from the center of the plotting area to the center of - * the logical area. - */ - dist = sqrt((double) (relcx * relcx + relcy * relcy)); - - SetLinestyle(0); - Arc(graph->grid.xaxis.circular.center, - graph->grid.yaxis.circular.center, - graph->grid.xaxis.circular.radius, - (double) 0.0, (double) 0.0); - SetLinestyle(1); - - /* Now draw the circles. */ - for (i = lmt; - (relrad = i * tenpowmag * pixperunit) - <= dist + graph->grid.xaxis.circular.radius; - i += step) - { - cliparc((double) graph->grid.xaxis.circular.center + relcx, - (double) graph->grid.yaxis.circular.center + relcy, - (double) relrad, 0.0, 0.0, - graph->grid.xaxis.circular.center, - graph->grid.yaxis.circular.center, - graph->grid.xaxis.circular.radius, 0); - /* Toss on the label */ - if (relcx || relcy) - theta = atan2((double) relcy, (double) relcx); - else - theta = M_PI; - if (i && (relrad > dist - graph->grid.xaxis.circular.radius)) - addradlabel(graph, i, theta, - (int) (graph->grid.xaxis.circular.center - - (relrad - dist) * cos(theta)), - (int) (graph->grid.yaxis.circular.center - - (relrad - dist) * sin(theta))); - } - - /* Now draw the spokes. We have two possible cases -- first, the - * origin may be inside the area -- in this case draw 12 spokes. - * Otherwise, draw several spokes at convenient places. - */ - if ((graph->datawindow.xmin <= 0.0) - && (graph->datawindow.xmax >= 0.0) - && (graph->datawindow.ymin <= 0.0) - && (graph->datawindow.ymax >= 0.0)) { - for (i = 0; i < 12; i++) { - x1 = graph->grid.xaxis.circular.center + relcx; - y1 = graph->grid.yaxis.circular.center + relcy; - x2 = x1 + graph->grid.xaxis.circular.radius * 2 - * cos(i * M_PI / 6); - y2 = y1 + graph->grid.xaxis.circular.radius * 2 - * sin(i * M_PI / 6); - if (!clip_to_circle(&x1, &y1, &x2, &y2, - graph->grid.xaxis.circular.center, - graph->grid.yaxis.circular.center, - graph->grid.xaxis.circular.radius)) - { - DrawLine(x1, y1, x2, y2); - /* Add a label here */ - /*XXXX*/ - adddeglabel(graph, i * 30, x2, y2, x1, y1, - graph->grid.xaxis.circular.center, - graph->grid.yaxis.circular.center); - } - } - } else { - /* Figure out the angle that we have to fill up */ - theta = 2 * asin((double) graph->grid.xaxis.circular.radius - / dist); - theta = theta * 180 / M_PI; /* Convert to degrees. */ - - /* See if we should put lines at 30, 15, 5, or 1 degree - * increments. - */ - if (theta / 30 > 3) - degs = 30; - else if (theta / 15 > 3) - degs = 15; - else if (theta / 5 > 3) - degs = 5; - else - degs = 1; - - /* We'll be cheap */ - for (i = 0; i < 360; i+= degs) { - x1 = graph->grid.xaxis.circular.center + relcx; - y1 = graph->grid.yaxis.circular.center + relcy; - x2 = x1 + dist * 2 * cos(i * M_PI / 180); - y2 = y1 + dist * 2 * sin(i * M_PI / 180); - if (!clip_to_circle(&x1, &y1, &x2, &y2, - graph->grid.xaxis.circular.center, - graph->grid.yaxis.circular.center, - graph->grid.xaxis.circular.radius)) { - DrawLine(x1, y1, x2, y2); - /* Put on the label */ - adddeglabel(graph, i, x2, y2, x1, y1, - graph->grid.xaxis.circular.center, - graph->grid.yaxis.circular.center); - } - } - } - - (void) sprintf(buf, "e%d", mag); - Text(buf, graph->grid.xaxis.circular.center - + graph->grid.xaxis.circular.radius, - graph->grid.yaxis.circular.center - - graph->grid.xaxis.circular.radius); - Update(); - return; -} - -/* Put a degree label on the screen, with 'deg' as the label, near point (x, y) - * such that the perpendicular to (cx, cy) and (x, y) doesn't overwrite the - * label. If the distance between the center and the point is - * too small, don't put the label on. - */ - -#define LOFF 5 -#define MINDIST 10 - -static void -adddeglabel(GRAPH *graph, int deg, int x, int y, int cx, int cy, int lx, int ly) -{ - char buf[8]; - int d, w, h; - double angle; - - if (sqrt((double) (x - cx) * (x - cx) + (y - cy) * (y - cy)) < MINDIST) - return; - (void) sprintf(buf, "%d", deg); - w = graph->fontwidth * (strlen(buf) + 1); - h = graph->fontheight * 1.5; - angle = atan2((double) (y - ly), (double) (x - lx)); - d = fabs(cos(angle)) * w / 2 + fabs(sin(angle)) * h / 2 + LOFF; - - x = x + d * cos(angle) - w / 2; - y = y + d * sin(angle) - h / 2; - - Text(buf, x, y); - Text("o", x + strlen(buf) * graph->fontwidth, - y + graph->fontheight / 2); - return; -} - -/* This is kind of wierd. If dist = 0, then this is the normal case, where - * the labels should go along the positive X-axis. Otherwise, to make - * sure that all circles drawn have labels, put the label near the circle - * along the line from the logical center to the physical center. - */ - -static void -addradlabel(GRAPH *graph, int lab, double theta, int x, int y) -{ - char buf[32]; - - (void) sprintf(buf, "%d", lab); - if (theta == M_PI) { - y = y - graph->fontheight - 2; - x = x - graph->fontwidth * strlen(buf) - 3; - } else - x = x - graph->fontwidth * strlen(buf) - 3; - Text(buf, x, y); - return; -} - - -/* Smith charts. */ - -#define gr_xcenter graph->grid.xaxis.circular.center -#define gr_ycenter graph->grid.yaxis.circular.center -#define gr_radius graph->grid.xaxis.circular.radius -#define gi_fntwidth graph->fontwidth -#define gi_fntheight graph->fontheight -#define gi_maxx graph->viewport.width+graph->viewportxoff -#define gr_xmargin graph->viewportxoff -#define gr_ymargin graph->viewportyoff - -static void -smithgrid(GRAPH *graph) -{ - double mx, my; - bool centered = FALSE; - - SetLinestyle(0); - - /* Make sure that our area is square. */ - if (graph->viewport.width > graph->viewport.height) { - graph->viewport.width = graph->viewport.height; - } else { - graph->viewport.height = graph->viewport.width; - } - - /* Make sure that the borders are even */ - if (graph->viewport.width & 1) { - graph->viewport.width += 1; - graph->viewport.height += 1; - } - - graph->grid.xaxis.circular.center = graph->viewport.width / 2 - + graph->viewportxoff; - graph->grid.yaxis.circular.center = graph->viewport.height / 2 - + graph->viewportyoff; - graph->grid.xaxis.circular.radius = graph->viewport.width / 2; - - - /* We have to make sure that the range is square. */ - graph->datawindow.xmin = graph->data.xmin; - graph->datawindow.xmax = graph->data.xmax; - graph->datawindow.ymin = graph->data.ymin; - graph->datawindow.ymax = graph->data.ymax; - - if (graph->datawindow.ymin > 0) - graph->datawindow.ymin *= -1; - if (graph->datawindow.xmin > 0) - graph->datawindow.xmin *= -1; - - if (graph->datawindow.ymax < 0) - graph->datawindow.ymax *= -1; - if (graph->datawindow.xmax < 0) - graph->datawindow.xmax *= -1; - - if (fabs(graph->datawindow.ymin) > fabs(graph->datawindow.ymax)) - graph->datawindow.ymax = - graph->datawindow.ymin; - else - graph->datawindow.ymin = - graph->datawindow.ymax; - - if (fabs(graph->datawindow.xmin) > fabs(graph->datawindow.xmax)) - graph->datawindow.xmax = - graph->datawindow.xmin; - else - graph->datawindow.xmin = - graph->datawindow.xmax; - - mx = graph->datawindow.xmax - graph->datawindow.xmin; - my = graph->datawindow.ymax - graph->datawindow.ymin; - if (mx > my) { - graph->datawindow.ymin -= (mx - my) / 2; - graph->datawindow.ymax += (mx - my) / 2; - } else if (mx < my) { - graph->datawindow.xmin -= (my - mx) / 2; - graph->datawindow.xmax += (my - mx) / 2; - } - - if ((graph->datawindow.xmin == - graph->datawindow.xmax) && - (graph->datawindow.ymin == - - graph->datawindow.ymax) && (graph->datawindow.xmin == - graph->datawindow.ymin)) - centered = TRUE; - -#ifdef notdef - /* Figure out the minimum and maximum radii we're dealing with. */ - mx = (graph->datawindow.xmin + graph->datawindow.xmax) / 2; - my = (graph->datawindow.ymin + graph->datawindow.ymax) / 2; - d = sqrt(mx * mx + my * my); - maxrad = d + (graph->datawindow.xmax - graph->datawindow.xmin) / 2; - minrad = d - (graph->datawindow.xmax - graph->datawindow.xmin) / 2; -#endif - - /* Issue a warning if our data range is not normalized */ - if (graph->datawindow.ymax > 1.1) { - printf("\nwarning: exceeding range for smith chart"); - printf("\nplease normalize your data to -1 < r < +1\n"); - } - -} - -/* maximum number of circles */ -#define CMAX 50 - -static void -drawsmithgrid(GRAPH *graph) -{ - double mx, my, tenpowmag, d, dphi[CMAX], minrad, maxrad, rnorm[CMAX]; - double pixperunit; - int mag, i, j, k; - double ir[CMAX], rr[CMAX], ki[CMAX], kr[CMAX], ks[CMAX]; - int xoff, yoff, zheight; - int basemag, plen; - char buf[64], plab[32], nlab[32]; - - /* Figure out the minimum and maximum radii we're dealing with. */ - mx = (graph->datawindow.xmin + graph->datawindow.xmax) / 2; - my = (graph->datawindow.ymin + graph->datawindow.ymax) / 2; - d = sqrt(mx * mx + my * my); - maxrad = d + (graph->datawindow.xmax - graph->datawindow.xmin) / 2; - minrad = d - (graph->datawindow.xmax - graph->datawindow.xmin) / 2; - - mag = floor(mylog10(maxrad)); - tenpowmag = pow(10.0, (double) mag); - - pixperunit = graph->viewport.width / (graph->datawindow.xmax - - graph->datawindow.xmin); - - xoff = - pixperunit * (graph->datawindow.xmin + graph->datawindow.xmax) / 2; - yoff = - pixperunit * (graph->datawindow.ymin + graph->datawindow.ymax) / 2; - - /* Sweep the range from 10e-20 to 10e20. If any arcs fall into the - * picture, plot the arc set. - */ - for (mag = -20; mag < 20; mag++) { - i = gr_radius * pow(10.0, (double) mag) / maxrad; - if (i > 10) { - j = 1; - break; - } else if (i > 5) { - j = 2; - break; - } else if (i > 2) { - j = 5; - break; - } - } - k = 1; - - /* SetLinestyle(1); takes too long */ - /* Problems with Suns on very large radii && linestyle */ - SetLinestyle(0); - - /* Now plot all the arc sets. Go as high as 5 times the radius that - * will fit on the screen. The base magnitude is one more than - * the least magnitude that will fit... - */ - if (i > 20) - basemag = mag; - else - basemag = mag + 1; - /* Go back one order of magnitude and have a closer look */ - mag -= 2; - j *= 10; - while (mag < 20) { - i = j * pow(10.0, (double) mag) * pixperunit / 2; - if (i / 5 > gr_radius + ((xoff > 0) ? xoff : - xoff)) - break; - rnorm[k] = j * pow(10.0, (double) (mag - basemag)); - dphi[k] = 2.0 * atan(rnorm[k]); - ir[k] = pixperunit * (1 + cos(dphi[k])) / sin(dphi[k]); - rr[k] = pixperunit * 0.5 * (((1 - rnorm[k]) / (1 + rnorm[k])) + 1); - (void) sprintf(plab, "%g", rnorm[k]); - plen = strlen(plab); - - /* See if the label will fit on the upper xaxis */ - /* wait for some k, so we don't get fooled */ - if (k > 6) { - if ((int) (gr_radius - xoff - pixperunit + 2 * rr[k]) < - plen * gi_fntwidth + 2) - break; - } - /* See if the label will fit on the lower xaxis */ - /* First look at the leftmost circle possible*/ - if ((int) (pixperunit - 2 * rr[k] + gr_radius + xoff + - fabs((double) yoff)) < plen * gi_fntwidth + 4) { - if (j == 95) { - j = 10; - mag++; - } else { - if (j < 20) - j += 1; - else - j += 5; - } - continue; - } - /* Then look at the circles following in the viewport */ - if (k>1 && (int) 2 * (rr[k-1] - rr[k]) < plen * gi_fntwidth + 4) { - if (j == 95) { - j = 10; - mag++; - } else { - if (j < 20) - j += 1; - else - j += 5; - } - continue; - } - if (j == 95) { - j = 10; - mag++; - } else { - if (j < 20) - j += 1; - else - j += 5; - } - ki[k-1] = ir[k]; - kr[k-1] = rr[k]; - k++; - if (k == CMAX) { - printf("drawsmithgrid: grid too complex\n"); - break; - } - } - k--; - - /* Now adjust the clipping radii */ - for (i = 0; i < k; i++) - ks[i] = ki[i]; - for (i = k-1, j = k-1; i >= 0; i -= 2, j--) { - ki[i] = ks[j]; - if (i > 0) - ki[i-1] = ks[j]; - } - for (i = 0; i < k; i++) - ks[i] = kr[i]; - for (i = k-1, j = k-1; (i >= 0) && (dphi[i] > M_PI / 2); i -= 2, j--) { - kr[i] = ks[j]; - if (i > 0) - kr[i-1] = ks[j]; - } - for ( ; i >= 0; i--, j--) - kr[i] = ks[j]; - - if ((yoff > - gr_radius) && (yoff < gr_radius)) { - zheight = gr_radius * cos(asin((double) yoff / gr_radius)); - zheight = (zheight > 0) ? zheight : - zheight; - } else { - zheight = gr_radius; - } - for (ki[k] = kr[k] = (double) 0; k > 0; k--) { - (void) sprintf(plab, "%g", rnorm[k]); - (void) sprintf(nlab, "-%g", rnorm[k]); - arcset(graph, rr[k], kr[k], ir[k], ki[k], pixperunit, - gr_radius, gr_xcenter, gr_ycenter, - xoff, yoff, plab, nlab, - (int) (0.5 + RAD_TO_DEG * (M_PI - dphi[k])), - (int) (0.5 + RAD_TO_DEG * (M_PI + dphi[k])), - gr_xcenter - zheight, - gr_xcenter + zheight); - } - if (mag == 20) { - fprintf(cp_err, "smithgrid: Internal Error: screwed up\n"); - return; - } - - SetLinestyle(0); - - Arc(gr_xcenter, gr_ycenter, gr_radius, 0.0, 0.0); -/* - if ((xoff > - gr_radius) && (xoff < gr_radius)) { - zheight = gr_radius * sin(acos((double) xoff / gr_radius)); - if (zheight < 0) - zheight = - zheight; - DrawLine(gr_xcenter + xoff, gr_ycenter - zheight, - gr_xcenter + xoff, gr_ycenter + zheight); - } - */ - if ((yoff > - gr_radius) && (yoff < gr_radius)) { - zheight = gr_radius * cos(asin((double) yoff / gr_radius)); - if (zheight < 0) - zheight = - zheight; - DrawLine(gr_xcenter - zheight, gr_ycenter + yoff, - gr_xcenter + zheight, gr_ycenter + yoff); - Text("0", gr_xcenter + zheight + gi_fntwidth, gr_ycenter + yoff - - gi_fntheight / 2); - Text("o", gr_xcenter + zheight + gi_fntwidth * 2, gr_ycenter + yoff); - Text("180", gr_xcenter - zheight - gi_fntwidth * 5, gr_ycenter - + yoff - gi_fntheight / 2); - Text("o", gr_xcenter - zheight - gi_fntwidth * 2, gr_ycenter + yoff); - } - -/* (void) sprintf(buf, "e%d", basemag); */ - (void) sprintf(buf, "e%d", 0); - Text(buf, gr_xcenter + gr_radius, gr_ycenter - gr_radius); - - Update(); - return; -} - -/* Draw one arc set. The arcs should have radius rad. The outermost circle is - * described by (centx, centy) and maxrad, and the distance from the right side - * of the bounding circle to the logical center of the other circles in pixels - * is xoffset (positive brings the negative plane into the picture). - * plab and nlab are the labels to put on the positive and negative X-arcs, - * respectively... If the X-axis isn't on the screen, then we have to be - * clever... - */ - -static void -arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, double radoff, int maxrad, int centx, int centy, int xoffset, int yoffset, char *plab, char *nlab, int pdeg, int ndeg, int pxmin, int pxmax) -{ - double aclip; - double angle = atan2((double) iprevrad, (double) rad); - double iangle = atan2((double) prevrad, (double) irad); - int x, xlab, ylab; - - /* Let's be lazy and just draw everything -- we won't get called too - * much and the circles get clipped anyway... - */ - SetColor(18); - - cliparc((double) (centx + xoffset + radoff - rad), - (double) (centy + yoffset), rad, 2*angle, - 2 * M_PI - 2 * angle, centx, centy, maxrad, 0); - - - /* These circles are not part of the smith chart - * Let's draw them anyway - */ - cliparc((double) (centx + xoffset + radoff + rad), - (double) (centy + yoffset), rad, M_PI + 2 * angle, - M_PI - 2 * angle, centx, centy, maxrad, 0); - - /* Draw the upper and lower circles. */ - SetColor(19); - aclip = cliparc((double) (centx + xoffset + radoff), - (double) (centy + yoffset + irad), irad, - (double) (M_PI * 1.5 + 2 * iangle), - (double) (M_PI * 1.5 - 2 * iangle), centx, centy, maxrad, 1); - if ((aclip > M_PI / 180) && (pdeg > 1)) { - xlab = centx + xoffset + radoff + irad * cos(aclip); - ylab = centy + yoffset + irad * (1 + sin(aclip)); - if ((ylab - gr_ycenter) > graph->fontheight) { - SetColor(1); - adddeglabel(graph, pdeg, xlab, ylab, - gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter); -/* - ylab = centy + yoffset - irad * (1 + sin(aclip)); - adddeglabel(graph, ndeg, xlab, ylab, - gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter); - */ - SetColor(19); - } - } - aclip = cliparc((double) (centx + xoffset + radoff), - (double) (centy + yoffset - irad), irad, - (double) (M_PI / 2 + 2 * iangle), - (double) (M_PI / 2 - 2 * iangle), centx, centy, maxrad, - (iangle == 0)?2:0); - if ((aclip >= 0 && aclip < 2*M_PI - M_PI/180) && (pdeg < 359)) { - xlab = centx + xoffset + radoff + irad * cos(aclip); - ylab = centy + yoffset + irad * (sin(aclip) - 1); - SetColor(1); - adddeglabel(graph, ndeg, xlab, ylab, - gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter); - SetColor(19); - } - - /* Now toss the labels on... */ - SetColor(1); - - x = centx + xoffset + (int)radoff - 2 * (int)rad - - gi_fntwidth * strlen(plab) - 2; - if ((x > pxmin) && (x < pxmax)) { - if ((yoffset > - gr_radius) && (yoffset < gr_radius)) - Text(plab, x, centy + yoffset - gi_fntheight - 1); - else - Text(plab, x, gr_ymargin - 3 * gi_fntheight - 2); - } -/* - x = centx + xoffset + (int) radoff + 2 * (int)rad - - gi_fntwidth * strlen(nlab) - 2; - if ((x > gr_xmargin) && (x < gi_maxx)) - Text(nlab, x, centy + yoffset - gi_fntheight - 1); - */ - - return; -} - -/* This routine draws an arc and clips it to a circle. It's hard to figure - * out how it works without looking at the piece of scratch paaper I have - * in front of me, so let's hope it doesn't break... - * Converted to all doubles for CRAYs - */ - -static double -cliparc(double cx, double cy, double rad, double start, double end, int iclipx, int iclipy, int icliprad, int flag) -{ - double clipx, clipy, cliprad; - double sclip, eclip; - double x, y, tx, ty, dist; - double alpha, theta, phi, a1, a2, d, l; - bool in; - - clipx = (double) iclipx; - clipy = (double) iclipy; - cliprad = (double) icliprad; - x = cx - clipx; - y = cy - clipy; - dist = sqrt((double) (x * x + y * y)); - - if (!rad || !cliprad) - return(-1); - if (dist + rad < cliprad) { - /* The arc is entirely in the boundary. */ - Arc((int)cx, (int)cy, (int)rad, start, end); - return(flag?start:end); - } else if ((dist - rad >= cliprad) || (rad - dist >= cliprad)) { - /* The arc is outside of the boundary. */ - return(-1); - } - /* Now let's figure out the angles at which the arc crosses the - * circle. We know dist != 0. - */ - if (x) - phi = atan2((double) y, (double) x); - else if (y > 0) - phi = M_PI * 1.5; - else - phi = M_PI / 2; - if (cx > clipx) - theta = M_PI + phi; - else - theta = phi; - - alpha = (double) (dist * dist + rad * rad - cliprad * cliprad) / - (2 * dist * rad); - - /* Sanity check */ - if (alpha > 1.0) - alpha = 0.0; - else if (alpha < -1.0) - alpha = M_PI; - else - alpha = acos(alpha); - - a1 = theta + alpha; - a2 = theta - alpha; - while (a1 < 0) - a1 += M_PI * 2; - while (a2 < 0) - a2 += M_PI * 2; - while (a1 >= M_PI * 2) - a1 -= M_PI * 2; - while (a2 >= M_PI * 2) - a2 -= M_PI * 2; - - tx = cos(start) * rad + x; - ty = sin(start) * rad + y; - d = sqrt((double) tx * tx + ty * ty); - in = (d > cliprad) ? FALSE : TRUE; - - /* Now begin with start. If the point is in, draw to either end, a1, - * or a2, whichever comes first. - */ - d = M_PI * 3; - if ((end < d) && (end > start)) - d = end; - if ((a1 < d) && (a1 > start)) - d = a1; - if ((a2 < d) && (a2 > start)) - d = a2; - if (d == M_PI * 3) { - d = end; - if (a1 < d) - d = a1; - if (a2 < d) - d = a2; - } - - if (in) { - if (start > d) { - double tmp; - tmp = start; - start = d; - d = tmp; - } - Arc((int)cx, (int)cy, (int)rad, start, d); - sclip = start; - eclip = d; - } - if (d == end) - return(flag?sclip:eclip); - if (a1 != a2) - in = in ? FALSE : TRUE; - - /* Now go from here to the next point. */ - l = d; - d = M_PI * 3; - if ((end < d) && (end > l)) - d = end; - if ((a1 < d) && (a1 > l)) - d = a1; - if ((a2 < d) && (a2 > l)) - d = a2; - if (d == M_PI * 3) { - d = end; - if (a1 < d) - d = a1; - if (a2 < d) - d = a2; - } - - if (in) { - Arc((int)cx, (int)cy, (int)rad, l, d); - sclip = l; - eclip = d; - } - if (d == end) - return(flag?sclip:eclip); - in = in ? FALSE : TRUE; - - /* And from here to the end. */ - if (in) { - Arc((int)cx, (int)cy, (int)rad, d, end); - /* special case */ - if (flag != 2) { - sclip = d; - eclip = end; - } - } - return(flag%2?sclip:eclip); -} diff --git a/src/frontend/grid.h b/src/frontend/grid.h deleted file mode 100644 index 44db7c411..000000000 --- a/src/frontend/grid.h +++ /dev/null @@ -1,18 +0,0 @@ -/************* - * Header file for grid.c - * 1999 E. Rouat - ************/ - -#ifndef GRID_H_INCLUDED -#define GRID_H_INCLUDED - -typedef enum { x_axis, y_axis } Axis; - -void gr_fixgrid(GRAPH *graph, double xdelta, double ydelta, int xtype, int ytype); -void gr_redrawgrid(GRAPH *graph); -void drawlingrid(GRAPH *graph, char *units, int spacing, int nsp, double dst, double lmt, - double hmt, bool onedec, int mult, double mag, int digits, Axis axis); -void drawloggrid(GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, - int pp, Axis axis); - -#endif diff --git a/src/frontend/nutctab.c b/src/frontend/nutctab.c deleted file mode 100644 index e8286291c..000000000 --- a/src/frontend/nutctab.c +++ /dev/null @@ -1,369 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Table of available commands. Note that they're sorted so that the commands - * that appear in the spiceinit file are at the top. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftehelp.h" -#include "nutctab.h" - - -/* Bool fields: stringargs, spiceonly, major */ - -struct comm nutcp_coms[] = { - { "let", com_let, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - arg_let, - "varname = expr : Assign vector variables." } , - { "reshape", com_reshape, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - arg_let, - "vector ... [ shape ] : change the dimensions of a vector." } , - { "define", com_define, FALSE, FALSE, TRUE, - { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[[func (args)] stuff] : Define a user-definable function." } , - { "set", com_set, FALSE, FALSE, TRUE, - { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, - arg_set, - "[option] [option = value] ... : Set a variable." } , - { "alias", com_alias, FALSE, FALSE, FALSE, - { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, - (int (*)()) NULL, - "[[word] alias] : Define an alias." } , - { "deftype", com_dftype, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "spec name pat ... : Redefine vector and plot types.\n" } , - { "plot", com_plot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_BEGINNING | E_HASPLOTS, 1, LOTS, - arg_plot, - "expr ... [vs expr] [xl xlo xhi] [yl ylo yhi] : Plot things." }, - { "display", com_display, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS, - arg_display, - ": Display vector status." } , - { "destroy", com_destroy, FALSE, FALSE, FALSE, - { 0400, 0400, 0400, 0400 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[plotname] ... : Throw away all the data in the plot." } , - { "setplot", com_splot, FALSE, FALSE, TRUE, - { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[plotname] : Change the current working plot." } , - { "setcirc", NULL, FALSE, TRUE, FALSE, - { 04, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[circuit name] : Change the current circuit." } , - { "setscale", com_setscale, FALSE, FALSE, FALSE, - { 040000, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[vecname] : Change default scale of current working plot." } , - { "transpose", com_transpose, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Perform matrix transposition on multi-D vectors." } , - { "xgraph", com_xgraph, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file plotargs : Send plot to Xgraph-11." } , - { "hardcopy", com_hardcopy, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file plotargs : Produce hardcopy plots." } , - { "asciiplot", com_asciiplot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "plotargs : Produce ascii plots." } , - { "write", com_write, FALSE, FALSE, TRUE, - { 1, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file expr ... : Write data to a file." } , - { "compose", com_compose, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "var parm=val ... : Compose a vector." } , - { "unlet", com_unlet, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Undefine vectors." } , - { "print", com_print, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, - arg_print, - "[col] expr ... : Print vector values." } , - { "load", com_load, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS, - arg_load, - "file ... : Load in data." } , - { "cross", com_cross, FALSE, FALSE, TRUE, - { 040000, 0, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "vecname number [ vector ... ] : Make a vector in a strange way." } , - { "undefine", com_undefine, FALSE, FALSE, FALSE, - { 010000, 010000, 010000, 010000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[func ...] : Undefine a user-definable function." } , - { "op", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.op line args] : Determine the operating point of the circuit." } , - { "tran", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.tran line args] : Do a transient analysis." } , - { "ac", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.ac line args] : Do an ac analysis." } , - { "dc", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.dc line args] : Do a dc analysis." } , - { "pz", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.pz line args] : Do a pole / zero analysis." } , - { "sens", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.ac line args] : Do a sensitivity analysis." } , - { "disto", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.disto line args] : Do an distortion analysis." } , - { "noise", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.noise line args] : Do a noise analysis." } , - { "listing", NULL, FALSE, TRUE, TRUE, - { 0100, 0100, 0100, 0100 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[logical] [physical] [deck] : Print the current circuit." } , - { "edit", NULL, FALSE, TRUE, TRUE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[filename] : Edit a spice deck and then load it in." } , - { "dump", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print a dump of the current circuit." } , - { "fourier", com_fourier, FALSE, FALSE, TRUE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "fund_freq vector ... : Do a fourier analysis of some data." } , - { "show", NULL, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devspecs ... : parmspecs ... : Print out device parameters." } , - { "alter", NULL, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter device parameters." } , - { "altermod", NULL, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter model parameters." } , - { "resume", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue after a stop." } , - { "state", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "(unimplemented) : Print the state of the circuit." }, - { "stop", NULL, FALSE, TRUE, FALSE, - { 04200, 04200, 04200, 04200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stop args] : Set a breakpoint." } , - { "trace", NULL, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Trace a node." } , - { "save", NULL, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Save a spice output." } , - { "iplot", NULL, FALSE, TRUE, TRUE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Incrementally plot a node." } , - { "status", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print the current breakpoints and traces." } , - { "delete", NULL, FALSE, TRUE, FALSE, - { 020, 020, 020, 020 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [break number ...] : Delete breakpoints and traces." } , - { "step", NULL, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Iterate number times, or one." } , - { "reset", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Terminate a simulation after a breakpoint (formerly 'end')." } , - { "run", NULL, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[rawfile] : Run the simulation as specified in the input file." } , -#ifdef notdef - { "aspice", com_aspice, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, 2, - (int (*)()) NULL, - "file [outfile] : Run a spice job asynchronously." } , - { "jobs", com_jobs, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report on asynchronous spice jobs." } , - { "rspice", com_rspice, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[input file] : Run a spice job remotely." } , -#endif - { "bug", com_bug, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report a %s bug." } , - { "newhelp", com_ahelp, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : help." }, - { "tutorial", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_BEGINNING, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "help", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "oldhelp", com_help, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : Print help." } , - { "quit", com_quit, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_BEGINNING, 0, 0, - (int (*)()) NULL, - ": Quit %s." } , - { "source", nutcom_source, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file : Source a %s file." } , - { "shift", com_shift, FALSE, FALSE, FALSE, - { 020000, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[var] [number] : Shift argv or the named list var to the left." } , - { "unset", com_unset, FALSE, FALSE, FALSE, - { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Unset a variable." } , - { "unalias", com_unalias, FALSE, FALSE, FALSE, - { 02, 02, 02, 02 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "word ... : Undefine an alias." } , - { "history", com_history, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[-r] [number] : Print command history." } , - { "echo", com_echo, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stuff ...] : Print stuff." } , - { "shell", com_shell, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[args] : Fork a shell, or execute the command." } , - { "rusage", com_rusage, FALSE, FALSE, FALSE, - { 02000, 02000, 02000, 02000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[resource ...] : Print current resource usage." } , - { "cd", com_chdir, FALSE, FALSE, FALSE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[directory] : Change working directory." } , - { "version", com_version, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[number] : Print the version number." } , - { "diff", com_diff, FALSE, FALSE, FALSE, - { 0400, 0400, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "plotname plotname [vec ...] : 'diff' two plots." } , - { "rehash", com_rehash, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Rebuild the unix command database." } , - { "while", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "repeat", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0}, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Repeat number times, or forever." } , - { "dowhile", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "foreach", NULL, FALSE, FALSE, FALSE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "variable value ... : Do once for each value." } , - { "if", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute if the condition is TRUE." } , - { "else", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Goes with if." } , - { "end", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": End a block." } , - { "break", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Break out of a block." } , - { "continue", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue a loop." } , - { "label", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Create someplace to go to." } , - { "goto", NULL, FALSE, FALSE, FALSE, - { 0100000, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Go to a label." } , - { "cdump", com_cdump, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Dump the current control structures." } , - { "settype", com_stype, FALSE, FALSE, FALSE, - { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "type vec ... : Change the type of a vector." } , - { "strcmp", com_strcmp, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, - (int (*)()) NULL, - "varname s1 s2 : Set $varname to strcmp(s1, s2)." } , - { "linearize", NULL, FALSE, TRUE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - " [ vec ... ] : Convert plot into one with linear scale." } , - - { 0, NULL, FALSE, FALSE, FALSE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - NULL } - -} ; - diff --git a/src/frontend/nutctab.h b/src/frontend/nutctab.h deleted file mode 100644 index f94f5b947..000000000 --- a/src/frontend/nutctab.h +++ /dev/null @@ -1,12 +0,0 @@ -/************* - * Header file for nutctab.c - * 1999 E. Rouat - ************/ - -#ifndef NUTCTAB_H_INCLUDED -#define NUTCTAB_H_INCLUDED - - - - -#endif diff --git a/src/frontend/plot5.c b/src/frontend/plot5.c deleted file mode 100644 index 4a1e7de85..000000000 --- a/src/frontend/plot5.c +++ /dev/null @@ -1,180 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" -#include "ftegraph.h" -#include "ftedev.h" -#include "fteinput.h" -#include "plot5.h" - -static FILE *plotfile; - -#define putsi(a) putc((char) (a), plotfile); \ - putc((char) ((a) >> 8), plotfile) - -#define SOLID 0 -static char *linestyle[] = { "solid", "dotted", "longdashed", "shortdashed", - "dotdashed" }; -static int currentlinestyle = SOLID; - - -extern void gr_relinestyle (GRAPH *graph); -extern void internalerror (char *message); - -int -Plt5_Init(void) -{ - - dispdev->numlinestyles = 4; - dispdev->numcolors = 2; - - /* arbitrary */ - dispdev->width = 1000; - dispdev->height = 1000; - - return(0); - -} - -int -Plt5_NewViewport(GRAPH *graph) -{ - - if (!(plotfile = fopen(graph->devdep, "w"))) { - graph->devdep = (char *) NULL; - perror(graph->devdep); - return(1); - } - - if (graph->absolute.width) { - - /* hardcopying from the scree, - ie, we are passed a copy of an existing graph */ - putc('s', plotfile); - putsi(0); - putsi(0); - putsi(graph->absolute.width); - putsi(graph->absolute.height); - - /* re-scale linestyles */ - gr_relinestyle(graph); - - } else { - /* scale space */ - putc('s', plotfile); - putsi(0); - putsi(0); - putsi(dispdev->width); - putsi(dispdev->height); - - /* reasonable values, used in gr_ for placement */ - graph->fontwidth = 12; - graph->fontheight = 24; - - graph->absolute.width = dispdev->width; - graph->absolute.height = dispdev->height; - - } - - /* set to NULL so graphdb doesn't incorrectly de-allocate it */ - graph->devdep = (char *) NULL; - - return(0); - -} - -void -Plt5_Close(void) -{ - - /* in case Plt5_Close is called as part of an abort, - w/o having reached Plt5_NewViewport */ - if (plotfile) - fclose(plotfile); - -} - -void -Plt5_Clear(void) -{ - - /* do nothing */ - -} - -void -Plt5_DrawLine(int x1, int y1, int x2, int y2) -{ - - putc('l', plotfile); - putsi(x1); - putsi(y1); - putsi(x2); - putsi(y2); - -} - -/* ARGSUSED */ /* until some code gets written */ -void -Plt5_Arc(int x0, int y0, int radius, double theta1, double theta2) -{ - - -} - -void -Plt5_Text(char *text, int x, int y) -{ - - int savedlstyle; - - /* set linestyle to solid - or may get funny color text on some plotters */ - savedlstyle = currentlinestyle; - Plt5_SetLinestyle(SOLID); - - /* move to (x, y) */ - putc('m', plotfile); - putsi(x); - putsi(y); - - /* use the label option */ - fprintf(plotfile, "t%s\n", text); - - /* restore old linestyle */ - Plt5_SetLinestyle(savedlstyle); - -} - -int -Plt5_SetLinestyle(int linestyleid) -{ - - if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { - internalerror("bad linestyleid"); - return 0; - } - putc('f', plotfile); - fprintf(plotfile, "%s\n", linestyle[linestyleid]); - currentlinestyle = linestyleid; - return 0; -} - -/* ARGSUSED */ -void -Plt5_SetColor(int colorid) -{ - - /* do nothing */ - -} - -void -Plt5_Update(void) -{ - - fflush(plotfile); - -} - diff --git a/src/frontend/plot5.h b/src/frontend/plot5.h deleted file mode 100644 index 4b4e68528..000000000 --- a/src/frontend/plot5.h +++ /dev/null @@ -1,20 +0,0 @@ -/************* - * Header file for plot5.c - * 1999 E. Rouat - ************/ - -#ifndef PLOT5_H_INCLUDED -#define PLOT5_H_INCLUDED - -int Plt5_Init(void); -int Plt5_NewViewport(GRAPH *graph); -void Plt5_Close(void); -void Plt5_Clear(void); -void Plt5_DrawLine(int x1, int y1, int x2, int y2); -void Plt5_Arc(int x0, int y0, int radius, double theta1, double theta2); -void Plt5_Text(char *text, int x, int y); -int Plt5_SetLinestyle(int linestyleid); -void Plt5_SetColor(int colorid); -void Plt5_Update(void); - -#endif diff --git a/src/frontend/plotcurv.c b/src/frontend/plotcurv.c deleted file mode 100644 index d52896561..000000000 --- a/src/frontend/plotcurv.c +++ /dev/null @@ -1,364 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Curve plotting routines and general (non-graphics) plotting things. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "ftegraph.h" -#include "ftedbgra.h" -#include "plotcurv.h" - - -static void plotinterval(struct dvec *v, double lo, double hi, register double *coeffs, - int degree, bool rotated); - - -/* Plot the vector v, with scale xs. If we are doing curve-fitting, then - * do some tricky stuff. - */ - -void -ft_graf(struct dvec *v, struct dvec *xs, bool nostart) -{ - int degree, gridsize, length; - register int i, j, l; - double *scratch, *result, *gridbuf, *mm; - register double *xdata, *ydata; - bool rot, increasing; - double dx, dy, lx = 0, ly = 0; - int dir; - - /* if already started, use saved degree */ - if (nostart) { - degree = currentgraph->degree; - } else { - if (!cp_getvar("polydegree", VT_NUM, (char *) °ree)) - degree = 1; - currentgraph->degree = degree; - } - if (degree > v->v_length) - degree = v->v_length; - if (degree < 1) { - fprintf(cp_err, "Error: polydegree is %d, can't plot...\n", - degree); - return; - } - - if (!cp_getvar("gridsize", VT_NUM, (char *) &gridsize)) - gridsize = 0; - if ((gridsize < 0) || (gridsize > 10000)) { - fprintf(cp_err, "Error: bad grid size %d\n", gridsize); - return; - } - if (gridsize && xs) { - if( isreal(xs) ) { - increasing = (xs->v_realdata[0] < xs->v_realdata[1]); - for (i = 0; i < xs->v_length - 1; i++) - if (increasing != (xs->v_realdata[i] < - xs->v_realdata[i + 1])) { - fprintf(cp_err, - "Warning: scale not monotonic, gridsize not relevant.\n"); - gridsize = 0; - break; - } - } else { - increasing = (realpart (&xs->v_compdata[0]) < - realpart( &xs->v_compdata[1])); - for (i = 0; i < xs->v_length - 1; i++) - if (increasing != (realpart( &xs->v_compdata[i]) < - realpart( &xs->v_compdata[i + 1]))) { - fprintf(cp_err, - "Warning: scale not monotonic, gridsize not relevant.\n"); - gridsize = 0; - break; - } - } - } - - if (!nostart) - gr_start(v); - - /* Do the one value case */ - - if (!xs) { - for (i = 0; i < v->v_length; i++) { - -/* We should do the one - point case too! - * Important for pole-zero for example - */ - if( v->v_length == 1 ) { - j = 0; - } else { - j = i-1; - if( i == 0 ) - continue; - } - - if (isreal(v)) { - /* This isn't good but we may as well do - * something useful. - */ - gr_point(v, v->v_realdata[i], - v->v_realdata[i], - v->v_realdata[j], - v->v_realdata[j], (j==i ? 1 : i)); - } else { - gr_point(v, realpart(&v->v_compdata[i]), - imagpart(&v->v_compdata[i]), - realpart(&v->v_compdata[j]), - imagpart(&v->v_compdata[j]), (j==i ? 1 : i)); - } - } - gr_end(v); - return; - } - - xs->v_flags |= VF_PERMANENT; - - /* First check the simple case, where we don't have to do any - * interpolation. - */ - if ((degree == 1) && (gridsize == 0)) { - dir = 0; - for (i = 0, j = v->v_length; i < j; i++) { - dx = isreal(xs) ? xs->v_realdata[i] : - realpart(&xs->v_compdata[i]); - dy = isreal(v) ? v->v_realdata[i] : - realpart(&v->v_compdata[i]); - if ((i == 0 || (dir > 0 ? lx > dx : dir < 0 ? lx < dx : 0)) - && xs->v_plot->pl_scale == xs) - { - gr_point(v, dx, dy, lx, ly, 0); - } else { - gr_point(v, dx, dy, lx, ly, i); - if (!dir) - dir = lx > dx ? -1 : lx < dx ? 1 : 0; - } - lx = dx; - ly = dy; - } - if (v->v_length == 1) - gr_point(v, dx, dy, lx, ly, 1); - gr_end(v); - return; - } - - if (gridsize < degree + 1) - gridsize = 0; - - if (gridsize) { - /* This is done quite differently from what we do below... */ - gridbuf = (double *) tmalloc(gridsize * sizeof (double)); - result = (double *) tmalloc(gridsize * sizeof (double)); - if (isreal(v)) - ydata = v->v_realdata; - else { - ydata = (double *) tmalloc(v->v_length * - sizeof (double)); - for (i = 0; i < v->v_length; i++) - ydata[i] = realpart(&v->v_compdata[i]); - } - if (isreal(xs)) - xdata = xs->v_realdata; - else { - xdata = (double *) tmalloc(xs->v_length * - sizeof (double)); - for (i = 0; i < xs->v_length; i++) - xdata[i] = realpart(&xs->v_compdata[i]); - } - - mm = ft_minmax(xs, TRUE); - dx = (mm[1] - mm[0]) / gridsize; - if (increasing) - for (i = 0, dy = mm[0]; i < gridsize; i++, dy += dx) - gridbuf[i] = dy; - else - for (i = 0, dy = mm[1]; i < gridsize; i++, dy -= dx) - gridbuf[i] = dy; - if (!ft_interpolate(ydata, result, xdata, v->v_length, gridbuf, - gridsize, degree)) { - fprintf(cp_err, "Error: can't put %s on gridsize %d\n", - v->v_name, gridsize); - return; - } - /* Now this is a problem. There's no way that we can - * figure out where to put the tic marks to correspond with - * the actual data... - */ - for (i = 0; i < gridsize; i++) - gr_point(v, gridbuf[i], result[i], gridbuf[i ? (i - 1) - : i], result[i ? (i - 1) : i], -1); - gr_end(v); - tfree(gridbuf); - tfree(result); - if (!isreal(v)) - tfree(ydata); - if (!isreal(xs)) - tfree(xdata); - return; - } - - /* We need to do curve fitting now. First get some scratch - * space - */ - scratch = (double *) tmalloc((degree + 1) * (degree + 2) * - sizeof (double)); - result = (double *) tmalloc((degree + 1) * sizeof (double)); - xdata = (double *) tmalloc((degree + 1) * sizeof (double)); - ydata = (double *) tmalloc((degree + 1) * sizeof (double)); - - - /* Plot the first degree segments... */ - if (isreal(v)) - bcopy((char *) v->v_realdata, (char *) ydata, - (degree + 1) * sizeof (double)); - else - for (i = 0; i <= degree; i++) - ydata[i] = realpart(&v->v_compdata[i]); - if (isreal(xs)) - bcopy((char *) xs->v_realdata, (char *) xdata, - (degree + 1) * sizeof (double)); - else - for (i = 0; i <= degree; i++) - xdata[i] = realpart(&xs->v_compdata[i]); - - rot = FALSE; - while (!ft_polyfit(xdata, ydata, result, degree, scratch)) { - /* Rotate the coordinate system 90 degrees and try again. - * If it doesn't work this time, bump the interpolation - * degree down by one... - */ - if (ft_polyfit(ydata, xdata, result, degree, scratch)) { - rot = TRUE; - break; - } - if (--degree == 0) { - fprintf(cp_err, "plotcurve: Internal Error: ack...\n"); - return; - } - } - - /* Plot this part of the curve... */ - for (i = 0; i < degree; i++) - if (rot) - plotinterval(v, ydata[i], ydata[i + 1], result, degree, - TRUE); - else - plotinterval(v, xdata[i], xdata[i + 1], result, degree, - FALSE); - - /* Now plot the rest, piece by piece... l is the - * last element under consideration. - */ - length = v->v_length; - for (l = degree + 1; l < length; l++) { - - /* Shift the old stuff by one and get another value. */ - for (i = 0; i < degree; i++) { - xdata[i] = xdata[i + 1]; - ydata[i] = ydata[i + 1]; - } - if (isreal(v)) - ydata[i] = v->v_realdata[l]; - else - ydata[i] = realpart(&v->v_compdata[l]); - if (isreal(xs)) - xdata[i] = xs->v_realdata[l]; - else - xdata[i] = realpart(&xs->v_compdata[l]); - - rot = FALSE; - while (!ft_polyfit(xdata, ydata, result, degree, scratch)) { - if (ft_polyfit(ydata, xdata, result, degree, scratch)) { - rot = TRUE; - break; - } - if (--degree == 0) { - fprintf(cp_err, - "plotcurve: Internal Error: ack...\n"); - return; - } - } - if (rot) - plotinterval(v, ydata[degree - 1], ydata[degree], - result, degree, TRUE); - else - plotinterval(v, xdata[degree - 1], xdata[degree], - result, degree, FALSE); - } - tfree(scratch); - tfree(xdata); - tfree(ydata); - tfree(result); - gr_end(v); - return; -} - -#define GRANULARITY 10 - -static void -plotinterval(struct dvec *v, double lo, double hi, register double *coeffs, int degree, bool rotated) -{ - double incr, dx, dy, lx, ly; - register int i; - int steps; - - /* - fprintf(cp_err, "plotinterval(%s, %G, %G, [ ", v->v_name, lo, hi); - for (i = 0; i <= degree; i++) - fprintf(cp_err, "%G ", coeffs[i]); - fprintf(cp_err, "], %d, %s)\n\r", degree, rotated ? "TRUE" : "FALSE"); - */ - - /* This is a problem -- how do we know what granularity to use? If - * the guy cares about this he will use gridsize. - */ - if (!cp_getvar("polysteps", VT_NUM, (char *) &steps)) - steps = GRANULARITY; - - incr = (hi - lo) / (double) (steps + 1); - dx = lo + incr; - lx = lo; - ly = ft_peval(lo, coeffs, degree); - for (i = 0; i <= steps; i++, dx += incr) { - dy = ft_peval(dx, coeffs, degree); - if (rotated) - gr_point(v, dy, dx, ly, lx, -1); - else - gr_point(v, dx, dy, lx, ly, -1); - lx = dx; - ly = dy; - /* fprintf(cp_err, "plot (%G, %G)\n\r", dx, dy); */ - } - return; -} - -#ifdef notdef - -static void -printmat(name, mat, m, n) - char *name; - double *mat; -{ - int i, j; - - printf("\n\r=== Matrix: %s ===\n\r", name); - for (i = 0; i < m; i++) { - printf(" | "); - for (j = 0; j < n; j++) - printf("%G ", mat[i * n + j]); - printf("|\n\r"); - } - printf("===\n\r"); - return; -} - -#endif - diff --git a/src/frontend/plotcurv.h b/src/frontend/plotcurv.h deleted file mode 100644 index 5f466cc6d..000000000 --- a/src/frontend/plotcurv.h +++ /dev/null @@ -1,12 +0,0 @@ -/************* - * Header file for plotcurv.c - * 1999 E. Rouat - ************/ - -#ifndef PLOTCURV_H_INCLUDED -#define PLOTCURV_H_INCLUDED - -void ft_graf(struct dvec *v, struct dvec *xs, bool nostart); - - -#endif diff --git a/src/frontend/spcmdtab.c b/src/frontend/spcmdtab.c deleted file mode 100644 index 482441e96..000000000 --- a/src/frontend/spcmdtab.c +++ /dev/null @@ -1,381 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Table of available commands. Note that they're sorted so that the commands - * that appear in the spiceinit file are at the top. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftehelp.h" - - -/* Bool fields: stringargs, spiceonly, major */ - -struct comm spcp_coms[] = { - - { "let", com_let, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - arg_let, - "varname = expr : Assign vector variables." } , - { "reshape", com_reshape, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - arg_let, - "vector ... [ shape ] : change the dimensions of a vector." } , - { "define", com_define, FALSE, FALSE, TRUE, - { 010000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[[func (args)] stuff] : Define a user-definable function." } , - { "set", com_set, FALSE, FALSE, TRUE, - { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 0, LOTS, - arg_set, - "[option] [option = value] ... : Set a variable." } , - { "alias", com_alias, FALSE, FALSE, FALSE, - { 02, 04, 04, 04 }, E_ADVANCED, 0, LOTS, - (int (*)()) NULL, - "[[word] alias] : Define an alias." } , - { "deftype", com_dftype, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, LOTS, - (int (*)()) NULL, - "spec name pat ... : Redefine vector and plot types.\n" } , - { "plot", com_plot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_BEGINNING | E_HASPLOTS, 1, LOTS, - arg_plot, - "expr ... [vs expr] [xl xlo xhi] [yl ylo yhi] : Plot things." }, - { "display", com_display, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 0, LOTS, - arg_display, - ": Display vector status." } , - { "destroy", com_destroy, FALSE, FALSE, FALSE, - { 0400, 0400, 0400, 0400 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[plotname] ... : Throw away all the data in the plot." } , - { "setplot", com_splot, FALSE, FALSE, TRUE, - { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[plotname] : Change the current working plot." } , - { "setcirc", com_scirc, FALSE, TRUE, FALSE, - { 04, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[circuit name] : Change the current circuit." } , - { "setscale", com_setscale, FALSE, FALSE, FALSE, - { 040000, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[vecname] : Change default scale of current working plot." } , - { "transpose", com_transpose, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Perform matrix transposition on multi-D vectors." } , - { "xgraph", com_xgraph, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file plotargs : Send plot to Xgraph-11." } , - { "hardcopy", com_hardcopy, FALSE, FALSE, TRUE, - { 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file plotargs : Produce hardcopy plots." } , - { "asciiplot", com_asciiplot, FALSE, FALSE, TRUE, - { 041000, 041000, 041000, 041000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "plotargs : Produce ascii plots." } , - { "write", com_write, FALSE, FALSE, TRUE, - { 1, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "file expr ... : Write data to a file." } , - { "compose", com_compose, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "var parm=val ... : Compose a vector." } , - { "unlet", com_unlet, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Undefine vectors." } , - { "print", com_print, FALSE, FALSE, TRUE, - { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, - arg_print, - "[col] expr ... : Print vector values." } , - { "load", com_load, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_BEGINNING | E_NOPLOTS, 1, LOTS, - arg_load, - "file ... : Load in data." } , - { "cross", com_cross, FALSE, FALSE, TRUE, - { 040000, 0, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "vecname number [ vector ... ] : Make a vector in a strange way." } , - { "undefine", com_undefine, FALSE, FALSE, FALSE, - { 010000, 010000, 010000, 010000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[func ...] : Undefine a user-definable function." } , - { "op", com_op, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.op line args] : Determine the operating point of the circuit." } , - { "tf", com_tf, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.tran line args] : Do a transient analysis." } , - { "tran", com_tran, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.tran line args] : Do a transient analysis." } , - { "ac", com_ac, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.ac line args] : Do an ac analysis." } , - { "dc", com_dc, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.dc line args] : Do a dc analysis." } , - { "pz", com_pz, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.pz line args] : Do a pole / zero analysis." } , - { "sens", com_sens, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.sens line args] : Do a sensitivity analysis." } , - { "disto", com_disto, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.disto line args] : Do an distortion analysis." } , - { "noise", com_noise, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[.noise line args] : Do a noise analysis." } , - { "listing", com_listing, FALSE, TRUE, TRUE, - { 0100, 0100, 0100, 0100 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[logical] [physical] [deck] : Print the current circuit." } , - { "edit", com_edit, FALSE, TRUE, TRUE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[filename] : Edit a spice deck and then load it in." } , - { "dump", com_dump, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print a dump of the current circuit." } , - { "fourier", com_fourier, FALSE, FALSE, TRUE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "fund_freq vector ... : Do a fourier analysis of some data." } , - { "spec", com_spec, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 4, LOTS, - (int (*)()) NULL, - "start_freq stop_freq step_freq vector ... : Create a frequency domain plot." } , - { "show", com_show, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devices ... : parameters ... : Print out device summary." } , - { "showmod", com_showmod, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "models ... : parameters ... : Print out model summary." } , - { "alter", com_alter, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter device parameters." } , - { "altermod", com_altermod, FALSE, TRUE, FALSE, - { 040, 040, 040, 040 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "devspecs : parmname value : Alter model parameters." } , - { "resume", com_resume, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue after a stop." } , - { "state", com_state, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "(unimplemented) : Print the state of the circuit." }, - { "stop", com_stop, FALSE, TRUE, FALSE, - { 04200, 04200, 04200, 04200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stop args] : Set a breakpoint." } , - { "trace", com_trce, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Trace a node." } , - { "save", com_save, FALSE, TRUE, FALSE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Save a spice output." } , - { "iplot", com_iplot, FALSE, TRUE, TRUE, - { 0200, 0200, 0200, 0200 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [node ...] : Incrementally plot a node." } , - { "status", com_sttus, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print the current breakpoints and traces." } , - { "delete", com_delete, FALSE, TRUE, FALSE, - { 020, 020, 020, 020 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[all] [break number ...] : Delete breakpoints and traces." } , - { "step", com_step, FALSE, TRUE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Iterate number times, or one." } , - { "reset", com_rset, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Terminate a simulation after a breakpoint (formerly 'end')." } , - { "run", com_run, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[rawfile] : Run the simulation as specified in the input file." } , - { "aspice", com_aspice, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, 2, - (int (*)()) NULL, - "file [outfile] : Run a spice job asynchronously." } , - { "jobs", com_jobs, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report on asynchronous spice jobs." } , - { "rspice", com_rspice, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[input file] : Run a spice job remotely." } , - { "bug", com_bug, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Report a %s bug." } , - { "where", com_where, FALSE, TRUE, TRUE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Print last non-converging node or device" } , - { "newhelp", com_ahelp, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : help." }, - { "tutorial", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_BEGINNING, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "help", com_ghelp, FALSE, FALSE, TRUE, - { 023010, 023010, 023010, 023010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[subject] ... : Hierarchical documentation browser." } , - { "oldhelp", com_help, FALSE, FALSE, TRUE, - { 010, 010, 010, 010 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[command name] ... : Print help." } , - { "quit", com_quit, FALSE, FALSE, TRUE, - { 0, 0, 0, 0 }, E_BEGINNING, 0, 0, - (int (*)()) NULL, - ": Quit %s." } , - { "source", com_source, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "file : Source a %s file." } , - { "shift", com_shift, FALSE, FALSE, FALSE, - { 020000, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[var] [number] : Shift argv or the named list var to the left." } , - { "unset", com_unset, FALSE, FALSE, FALSE, - { 020000, 020000, 020000, 020000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "varname ... : Unset a variable." } , - { "unalias", com_unalias, FALSE, FALSE, FALSE, - { 02, 02, 02, 02 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "word ... : Undefine an alias." } , - { "history", com_history, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 2, - (int (*)()) NULL, - "[-r] [number] : Print command history." } , - { "echo", com_echo, FALSE, FALSE, FALSE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[stuff ...] : Print stuff." } , - { "shell", com_shell, FALSE, FALSE, TRUE, - { 1, 1, 1, 1 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[args] : Fork a shell, or execute the command." } , - { "rusage", com_rusage, FALSE, FALSE, FALSE, - { 02000, 02000, 02000, 02000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[resource ...] : Print current resource usage." } , - { "cd", com_chdir, FALSE, FALSE, FALSE, - { 1, 0, 0, 0 }, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[directory] : Change working directory." } , - { "version", com_version, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "[number] : Print the version number." } , - { "diff", com_diff, FALSE, FALSE, FALSE, - { 0400, 0400, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - "plotname plotname [vec ...] : 'diff' two plots." } , - { "rehash", com_rehash, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Rebuild the unix command database." } , - { "while", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "repeat", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0}, E_DEFHMASK, 0, 1, - (int (*)()) NULL, - "[number] : Repeat number times, or forever." } , - { "dowhile", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute while the condition is TRUE." } , - { "foreach", NULL, FALSE, FALSE, FALSE, - { 0, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "variable value ... : Do once for each value." } , - { "if", NULL, FALSE, FALSE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS, - (int (*)()) NULL, - "condition : Execute if the condition is TRUE." } , - { "else", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Goes with if." } , - { "end", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": End a block." } , - { "break", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Break out of a block." } , - { "continue", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Continue a loop." } , - { "label", NULL, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Create someplace to go to." } , - { "goto", NULL, FALSE, FALSE, FALSE, - { 0100000, 0, 0, 0 }, E_DEFHMASK, 1, 1, - (int (*)()) NULL, - "word : Go to a label." } , - { "cdump", com_cdump, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, - (int (*)()) NULL, - ": Dump the current control structures." } , - { "settype", com_stype, FALSE, FALSE, FALSE, - { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, - (int (*)()) NULL, - "type vec ... : Change the type of a vector." } , - { "strcmp", com_strcmp, FALSE, FALSE, FALSE, - { 0, 0, 0, 0 }, E_DEFHMASK, 3, 3, - (int (*)()) NULL, - "varname s1 s2 : Set $varname to strcmp(s1, s2)." } , - { "linearize", com_linearize, FALSE, TRUE, FALSE, - { 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - " [ vec ... ] : Convert plot into one with linear scale." } , - { 0, NULL, FALSE, FALSE, FALSE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, LOTS, - (int (*)()) NULL, - NULL } -}; - diff --git a/src/frontend/x11.c b/src/frontend/x11.c deleted file mode 100644 index 9753dea85..000000000 --- a/src/frontend/x11.c +++ /dev/null @@ -1,1090 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jeffrey M. Hsu -**********/ - -/* - X11 drivers. -*/ - - -#include "ngspice.h" - -#ifndef X_DISPLAY_MISSING - -# include -# include /* PN */ -# include /* PN */ - - -# include "ftegraph.h" -# include "ftedbgra.h" -# include "ftedev.h" -# include "fteinput.h" -# include "cpdefs.h" -# include "ftedefs.h" - -/* Added X11/ prefix to the next includes - ER */ - -# include -# include -# include -# include -# include -# include -# include -# include -# include - -#include "x11.h" - -static void linear_arc(int x0, int y0, int radius, double theta1, double theta2); - - -# ifdef DEBUG -extern int _Xdebug; -# endif - - -#define RAD_TO_DEG (180.0 / M_PI) - -/* X dependent default parameters */ -#define DEF_FONT "10x14" -#define NUMLINESTYLES 8 -#define MW_LINEWIDTH 2 /* MW. I want larger lines */ -#define NXPLANES 5 /* note: What is this used for? */ -#define BOXSIZE 30 /* initial size of bounding box for zoomin */ - -typedef struct x11info { - Window window; - int isopen; - Widget shell, form, view, buttonbox, buttons[2]; - XFontStruct *font; - GC gc; - int lastx, lasty; /* used in X_DrawLine */ - int lastlinestyle; /* used in X_DrawLine */ -} X11devdep; - -#define DEVDEP(g) (*((X11devdep *) (g)->devdep)) - -static void linear_arc(int x0, int y0, int radius, double theta1, double theta2); -static Display *display; -static GC xorgc; -static char *xlinestyles[NUMLINESTYLES] = { /* test patterns XXX */ - "\001\001\001\001", /* solid */ - "\001\002\001\002", /* dots */ - "\007\007\007\007", /* longdash */ - "\003\003\003\003", /* shortdash */ - "\007\002\002\002", /* dots longdash */ - "\003\002\001\002", /* dots shortdash */ - "\003\003\007\003", /* short/longdash */ -}; - -static Widget toplevel; -static Bool noclear = False; -static GRAPH *lasthardcopy; /* graph user selected */ -static int X11_Open = 0; -static int numdispplanes; - - -extern void internalerror (char *message); -extern void externalerror (char *message); -void initlinestyles (void); -void initcolors (GRAPH *graph); -extern void PushGraphContext (GRAPH *graph); -extern void SetColor (int colorid); -extern void Text (char *text, int x, int y); -extern void SaveText (GRAPH *graph, char *text, int x, int y); -extern void PopGraphContext (void); -void slopelocation (GRAPH *graph, int x0, int y0); -void zoomin (GRAPH *graph); -void X_ScreentoData (GRAPH *graph, int x, int y, double *fx, double *fy); -extern int DestroyGraph (int id); -extern void gr_redraw (GRAPH *graph); -extern void gr_resize (GRAPH *graph); - -int -X11_Init(void) -{ - - char buf[512]; - char *displayname; - - XGCValues gcvalues; - - /* grrr, Xtk forced contortions */ - char *argv[2]; - int argc = 2; - - if (cp_getvar("display", VT_STRING, buf)) { - displayname = buf; - } else if (!(displayname = getenv("DISPLAY"))) { - internalerror("Can't open X display."); - return (1); - } - -# ifdef DEBUG - _Xdebug = 1; -# endif - - argv[0] = "ngspice"; - argv[1] = displayname; -/* - argv[2] = "-geometry"; - argv[3] = "=1x1+2+2"; -*/ - - /* initialize X toolkit */ - toplevel = XtInitialize("ngspice", "Nutmeg", NULL, 0, &argc, argv); - - display = XtDisplay(toplevel); - - X11_Open = 1; - - /* "invert" works better than "xor" for B&W */ - - /* xor gc should be a function of the pixels that are written on */ - gcvalues.function = GXxor; - gcvalues.line_width = 1; - gcvalues.foreground = 1; - gcvalues.background = 0; - - xorgc = XCreateGC(display, DefaultRootWindow(display), - GCLineWidth | GCFunction | GCForeground | GCBackground, - &gcvalues); - - /* set correct information */ - dispdev->numlinestyles = NUMLINESTYLES; - dispdev->numcolors = NUMCOLORS; - - dispdev->width = DisplayWidth(display, DefaultScreen(display)); - dispdev->height = DisplayHeight(display, DefaultScreen(display)); - - /* we don't want non-fatal X errors to call exit */ - XSetErrorHandler(errorhandler); - - numdispplanes = DisplayPlanes(display, DefaultScreen(display)); - - return (0); - -} - -void -errorhandler(Display *display, XErrorEvent *errorev) -{ - XGetErrorText(display, errorev->error_code, ErrorMessage, 1024); - externalerror(ErrorMessage); -} - -/* Recover from bad NewViewPort call. */ -#define RECOVERNEWVIEWPORT() free((char *) graph);\ - graph = (GRAPH *) NULL; - /* need to do this or else DestroyGraph will free it again */ - -/* NewViewport is responsible for filling in graph->viewport */ -int -X11_NewViewport(GRAPH *graph) -{ - - char fontname[513]; /* who knows . . . */ - char *p, *q; - Cursor cursor; - XSetWindowAttributes w_attrs; - XGCValues gcvalues; - static Arg formargs[ ] = { - { XtNleft, (XtArgVal) XtChainLeft }, - { XtNresizable, (XtArgVal) TRUE } - }; - static Arg bboxargs[ ] = { - { XtNfromHoriz, (XtArgVal) NULL }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtChainRight }, - { XtNright, (XtArgVal) XtChainRight } - }; - static Arg buttonargs[ ] = { - { XtNlabel, (XtArgVal) NULL }, - { XtNfromVert, (XtArgVal) NULL }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtRubber }, - { XtNright, (XtArgVal) XtRubber }, - { XtNresizable, (XtArgVal) TRUE } - }; - static Arg viewargs[] = { - { XtNresizable, (XtArgVal) TRUE }, - { XtNwidth, (XtArgVal) 300 }, - { XtNheight, (XtArgVal) 300 }, - { XtNright, (XtArgVal) XtChainRight } - }; - int trys; - - graph->devdep = calloc(1, sizeof(X11devdep)); - - /* set up new shell */ - DEVDEP(graph).shell = XtCreateApplicationShell("shell", - topLevelShellWidgetClass, NULL, 0); - - /* set up form widget */ - DEVDEP(graph).form = XtCreateManagedWidget("form", - formWidgetClass, DEVDEP(graph).shell, formargs, XtNumber(formargs)); - - /* set up viewport */ - DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass, - DEVDEP(graph).form, viewargs, XtNumber(viewargs)); - XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, - handlebuttonev, graph); - XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, - handlekeypressed, graph); - XtAddEventHandler(DEVDEP(graph).view, StructureNotifyMask, FALSE, - resize, graph); - XtAddEventHandler(DEVDEP(graph).view, ExposureMask, FALSE, - redraw, graph); - - /* set up button box */ - XtSetArg(bboxargs[1], XtNfromHoriz, DEVDEP(graph).view); - DEVDEP(graph).buttonbox = XtCreateManagedWidget("buttonbox", - boxWidgetClass, DEVDEP(graph).form, bboxargs, XtNumber(bboxargs)); - - /* set up buttons */ - XtSetArg(buttonargs[0], XtNlabel, "quit"); - XtSetArg(bboxargs[1], XtNfromVert, NULL); - DEVDEP(graph).buttons[0] = XtCreateManagedWidget("quit", - commandWidgetClass, DEVDEP(graph).buttonbox, - buttonargs, 1); - XtAddCallback(DEVDEP(graph).buttons[0], XtNcallback, killwin, graph); - - XtSetArg(buttonargs[0], XtNlabel, "hardcopy"); - XtSetArg(bboxargs[1], XtNfromVert, DEVDEP(graph).buttons[0]); - DEVDEP(graph).buttons[1] = XtCreateManagedWidget("hardcopy", - commandWidgetClass, DEVDEP(graph).buttonbox, - buttonargs, 1); - XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, hardcopy, graph); - - /* set up fonts */ - if (!cp_getvar("font", VT_STRING, fontname)) { - (void) strcpy(fontname, DEF_FONT); - } - - for (p = fontname; *p && *p <= ' '; p++) - ; - if (p != fontname) { - for (q = fontname; *p; *q++ = *p++) - ; - *q = 0; - } - - trys = 1; - while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) { - sprintf(ErrorMessage, "can't open font %s", fontname); - strcpy(fontname, "fixed"); - if (trys > 1) { - internalerror(ErrorMessage); - RECOVERNEWVIEWPORT(); - return(1); - } - trys += 1; - } - - graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing - - DEVDEP(graph).font->min_bounds.lbearing + 1; - graph->fontheight = DEVDEP(graph).font->max_bounds.ascent + - DEVDEP(graph).font->max_bounds.descent + 1; - - XtRealizeWidget(DEVDEP(graph).shell); - - DEVDEP(graph).window = XtWindow(DEVDEP(graph).view); - DEVDEP(graph).isopen = 0; - w_attrs.bit_gravity = ForgetGravity; - XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity, - &w_attrs); - /* have to note font and set mask GCFont in XCreateGC, p.w.h. */ - gcvalues.font = DEVDEP(graph).font->fid; - gcvalues.line_width = MW_LINEWIDTH; - gcvalues.cap_style = CapNotLast; - gcvalues.function = GXcopy; - DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window, - GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues); - - /* should absolute.positions really be shell.pos? */ - graph->absolute.xpos = DEVDEP(graph).view->core.x; - graph->absolute.ypos = DEVDEP(graph).view->core.y; - graph->absolute.width = DEVDEP(graph).view->core.width; - graph->absolute.height = DEVDEP(graph).view->core.height; - - initlinestyles(); - initcolors(graph); - - /* set up cursor */ - cursor = XCreateFontCursor(display, XC_left_ptr); - XDefineCursor(display, DEVDEP(graph).window, cursor); - - return (0); -} - -static void -initlinestyles(void) -{ - - int i; - - if (numdispplanes > 1) { - /* Dotted lines are a distraction when we have colors. */ - for (i = 2; i < NUMLINESTYLES; i++) { - xlinestyles[i] = xlinestyles[0]; - } - } - -} - -static void -initcolors(GRAPH *graph) -{ - int i; - static char *colornames[] = { "black", /* white */ - "white", "red", "blue", - "orange", "green", "pink", - "brown", "khaki", "plum", - "orchid", "violet", "maroon", - "turquoise", "sienna", "coral", - "cyan", "magenta", "gold", - "yellow", "" - }; - - XColor visualcolor, exactcolor; - char buf[BSIZE_SP], colorstring[BSIZE_SP]; - int xmaxcolors = NUMCOLORS; /* note: can we get rid of this? */ - - if (numdispplanes == 1) { - /* black and white */ - xmaxcolors = 2; - graph->colors[0] = DEVDEP(graph).view->core.background_pixel; - if (graph->colors[0] == WhitePixel(display, DefaultScreen(display))) - graph->colors[1] = BlackPixel(display, DefaultScreen(display)); - else - graph->colors[1] = WhitePixel(display, DefaultScreen(display)); - - } else { - if (numdispplanes < NXPLANES) - xmaxcolors = 1 << numdispplanes; - - for (i = 0; i < xmaxcolors; i++) { - (void) sprintf(buf, "color%d", i); - if (!cp_getvar(buf, VT_STRING, colorstring)) - (void) strcpy(colorstring, colornames[i]); - if (!XAllocNamedColor(display, - DefaultColormap(display, DefaultScreen(display)), - colorstring, &visualcolor, &exactcolor)) { - (void) sprintf(ErrorMessage, - "can't get color %s\n", colorstring); - externalerror(ErrorMessage); - graph->colors[i] = i ? BlackPixel(display, - DefaultScreen(display)) - : WhitePixel(display, DefaultScreen(display)); - continue; - } - graph->colors[i] = visualcolor.pixel; - - - /* MW. I don't need this, everyone must know what he is doing - if (i > 0 && - graph->colors[i] == DEVDEP(graph).view->core.background_pixel) { - graph->colors[i] = graph->colors[0]; - } */ - - } - /* MW. Set Beackgroound here */ - XSetWindowBackground(display, DEVDEP(graph).window, graph->colors[0]); - -/* if (graph->colors[0] != DEVDEP(graph).view->core.background_pixel) { - graph->colors[0] = DEVDEP(graph).view->core.background_pixel; - } */ - } - - for (i = xmaxcolors; i < NUMCOLORS; i++) { - graph->colors[i] = graph->colors[i + 1 - xmaxcolors]; - } -} - -/* This routine closes the X connection. - It is not to be called for finishing a graph. */ -void -X11_Close(void) -{ - XCloseDisplay(display); -} - -void -X11_DrawLine(int x1, int y1, int x2, int y2) -{ - - if (DEVDEP(currentgraph).isopen) - XDrawLine(display, DEVDEP(currentgraph).window, - DEVDEP(currentgraph).gc, - x1, currentgraph->absolute.height - y1, - x2, currentgraph->absolute.height - y2); - - -} - - -void -X11_Arc(int x0, int y0, int radius, double theta1, double theta2) -{ - - int t1, t2; - - if (!cp_getvar("x11lineararcs", VT_BOOL, (char *) &t1)) { - linear_arc(x0, y0, radius, theta1, theta2); - } - - if (DEVDEP(currentgraph).isopen) { - if (theta1 >= theta2) - theta2 = 2 * M_PI + theta2; - t1 = 64 * (180.0 / M_PI) * theta1; - t2 = 64 * (180.0 / M_PI) * theta2 - t1; - if (t2 == 0) - return; - XDrawArc(display, DEVDEP(currentgraph).window, DEVDEP(currentgraph).gc, - x0 - radius, - currentgraph->absolute.height - radius - y0, - 2 * radius, 2 * radius, t1, t2); -# ifdef notdef - printf("at %d, %d, %g %g x %d :: (%d, %d)\n", - x0, y0, theta1, theta2, radius, t1, t2); - printf("skip\n"); - XSync(display, 0); - printf("XDrawArc(%d, %d, %d, %d, %d, %d)\n", x0 - radius, - currentgraph->absolute.height - radius - y0, - 2 * radius, 2 * radius, t1, t2); -# endif - } -} - -/* note: x and y are the LOWER left corner of text */ -void -X11_Text(char *text, int x, int y) -{ - -/* We specify text position by lower left corner, so have to adjust for - X11's font nonsense. */ - - if (DEVDEP(currentgraph).isopen) - XDrawString(display, DEVDEP(currentgraph).window, - DEVDEP(currentgraph).gc, x, - currentgraph->absolute.height - - (y + DEVDEP(currentgraph).font->max_bounds.descent), - text, strlen(text)); - - /* note: unlike before, we do not save any text here */ - -} - - -int -X11_DefineColor(int colorid, double red, double green, double blue) -{ - internalerror("X11_DefineColor not implemented."); - return(0); -} - - -void -X11_DefineLinestyle(int linestyleid, int mask) -{ - internalerror("X11_DefineLinestyle not implemented."); -} - -void -X11_SetLinestyle(int linestyleid) -{ - XGCValues values; - - if (currentgraph->linestyle != linestyleid) { - -# ifdef notdef - switch (linestyleid %3) { - case 0: - values.line_style = LineSolid; - break; - case 1: - values.line_style = LineOnOffDash; - break; - case 2: - values.line_style = LineDoubleDash; - break; - } -# endif - if ((linestyleid == 0 || numdispplanes > 1) && linestyleid != 1) { - /* solid if linestyle 0 or if has color, allow only one - * dashed linestyle */ - values.line_style = LineSolid; - } else { - values.line_style = LineOnOffDash; - } - XChangeGC(display, DEVDEP(currentgraph).gc, GCLineStyle, &values); - - currentgraph->linestyle = linestyleid; - XSetDashes(display, DEVDEP(currentgraph).gc, 0, - xlinestyles[linestyleid], 4); - } -} - -void -X11_SetColor(int colorid) -{ - - currentgraph->currentcolor = colorid; - XSetForeground(display, DEVDEP(currentgraph).gc, - currentgraph->colors[colorid]); - -} - -void -X11_Update(void) -{ - - if (X11_Open) - XSync(display, 0); - -} - -void -X11_Clear(void) -{ - - if (!noclear) /* hack so exposures look like they're handled nicely */ - XClearWindow(display, DEVDEP(currentgraph).window); - -} - -void -handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata) -{ - - XKeyEvent *keyev = (XKeyPressedEvent *) calldata; - GRAPH *graph = (GRAPH *) clientdata; - char text[4]; - int nbytes; - - nbytes = XLookupString(keyev, text, 4, NULL, NULL); - if (!nbytes) return; - /* write it */ - PushGraphContext(graph); - text[nbytes] = '\0'; - SetColor(1); - Text(text, keyev->x, graph->absolute.height - keyev->y); - /* save it */ - SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y); - /* warp mouse so user can type in sequence */ - XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, - keyev->x + XTextWidth(DEVDEP(graph).font, text, nbytes), - keyev->y); - PopGraphContext(); - -} - -# ifdef notdef -void -keyhandler(clientdata, source, id) -caddr_t clientdata; -int *source; -XtInputId id; -{ - -# ifdef notdef - KEYwaiting = TRUE; -# endif - -} -# endif - -void -handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata) -{ - - XButtonEvent *buttonev = (XButtonEvent *) calldata; - - switch (buttonev->button) { - case Button1: - slopelocation((GRAPH *) clientdata, buttonev->x, buttonev->y); - break; - case Button3: - zoomin((GRAPH *) clientdata); - break; - } - -} - -# ifdef notdef -handlemotionev(w, clientdata, calldata) -Widget w; -caddr_t clientdata, calldata; -{ - - XMotionEvent *motionev = (XMotionEvent *) calldata; - - switch -} -# endif - -void -slopelocation(GRAPH *graph, int x0, int y0) - - /* initial position of mouse */ -{ - - int x1, y1; - int x, y; - Window rootwindow, childwindow; - int rootx, rooty; - unsigned int state; - double fx0, fx1, fy0, fy1; - double angle; - - x1 = x0; - y1 = y0; - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, &childwindow, - &rootx, &rooty, &x, &y, &state); - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); - while (state & Button1Mask) { - if (x != x1 || y != y1) { - XDrawLine(display, DEVDEP(graph).window, xorgc, - x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, - x0, y1, x1, y1); - x1 = x; - y1 = y; - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); - } - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, - &childwindow, &rootx, &rooty, &x, &y, &state); - } - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); - - X_ScreentoData(graph, x0, y0, &fx0, &fy0); - X_ScreentoData(graph, x1, y1, &fx1, &fy1); - - /* print it out */ - if (x1 == x0 && y1 == y0) { /* only one location */ - fprintf(stdout, "\nx0 = %g, y0 = %g\n", fx0, fy0); - if (graph->grid.gridtype == GRID_POLAR - || graph->grid.gridtype == GRID_SMITH - || graph->grid.gridtype == GRID_SMITHGRID) - { - angle = RAD_TO_DEG * atan2( fy0, fx0 ); - fprintf(stdout, "r0 = %g, a0 = %g\n", - sqrt( fx0*fx0 + fy0*fy0 ), - (angle>0)?angle:(double) 360+angle); - } - - - } else { /* need to print info about two points */ - fprintf(stdout, "\nx0 = %g, y0 = %g x1 = %g, y1 = %g\n", - fx0, fy0, fx1, fy1); - fprintf(stdout, "dx = %g, dy = %g\n", fx1-fx0, fy1 - fy0); - if (x1 != x0 && y1 != y0) { - /* add slope info if both dx and dy are zero, - because otherwise either dy/dx or dx/dy is zero, - which is uninteresting - */ - fprintf(stdout, "dy/dx = %g dx/dy = %g\n", - (fy1-fy0)/(fx1-fx0), (fx1-fx0)/(fy1-fy0)); - } - } - - return; - -} - -/* should be able to do this by sleight of hand on graph parameters */ -void -zoomin(GRAPH *graph) -{ -/* note: need to add circular boxes XXX */ - - int x0, y0, x1, y1; - double fx0, fx1, fy0, fy1, ftemp; - char buf[BSIZE_SP]; - char buf2[128]; - char *t; - wordlist *wl; - int dummy; - - Window rootwindow, childwindow; - int rootx, rooty; - unsigned int state; - int x, y, upperx, uppery, lowerx, lowery; - - /* open box and get area to zoom in on */ - - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, - &childwindow, &rootx, &rooty, &x0, &y0, &state); - - x = lowerx = x1 = x0 + BOXSIZE; - y = lowery = y1 = y0 + BOXSIZE; - upperx = x0; - uppery = y0; - - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); - -/* note: what are src_x, src_y, src_width, and src_height for? XXX */ - XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, x1, y1); - - while (state & Button3Mask) { - if (x != x1 || y != y1) { - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); - x1 = x; - y1 = y; - /* figure out upper left corner */ - /* remember X11's (and X10's) demented coordinate system */ - if (y0 < y1) { - uppery = y0; - upperx = x0; - lowery = y1; - lowerx = x1; - } else { - uppery = y1; - upperx = x1; - lowery = y0; - lowerx = x0; - } - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); - } - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, - &childwindow, &rootx, &rooty, &x, &y, &state); - } - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); - - X_ScreentoData(graph, x0, y0, &fx0, &fy0); - X_ScreentoData(graph, x1, y1, &fx1, &fy1); - - if (fx0 > fx1) { - ftemp = fx0; - fx0 = fx1; - fx1 = ftemp; - } - if (fy0 > fy1) { - ftemp = fy0; - fy0 = fy1; - fy1 = ftemp; - } - - strncpy(buf2, graph->plotname, sizeof(buf2)); - if ((t =strchr(buf2, ':'))) - *t = 0; - - if (!eq(plot_cur->pl_typename, buf2)) { - (void) sprintf(buf, -"setplot %s; %s xlimit %.20e %.20e ylimit %.20e %.20e; setplot $curplot\n", - buf2, graph->commandline, fx0, fx1, fy0, fy1); - } else { - (void) sprintf(buf, "%s xlimit %e %e ylimit %e %e\n", - graph->commandline, fx0, fx1, fy0, fy1); - } - - /* hack for Gordon Jacobs */ - /* add to history list if plothistory is set */ - if (cp_getvar("plothistory", VT_BOOL, (char *) &dummy)) { - wl = cp_parse(buf); - (void) cp_addhistent(cp_event++, wl); - } - - (void) cp_evloop(buf); - -} - -void -hardcopy(Widget w, caddr_t client_data, caddr_t call_data) -{ - - lasthardcopy = (GRAPH *) client_data; - com_hardcopy(NULL); - -} - -void -killwin(Widget w, caddr_t client_data, caddr_t call_data) -{ - - GRAPH *graph = (GRAPH *) client_data; - - /* Iplots are done asynchronously */ - DEVDEP(graph).isopen = 0; - DestroyGraph(graph->graphid); - XtDestroyWidget(DEVDEP(graph).shell); - -} - -/* call higher gr_redraw routine */ -void -redraw(Widget w, caddr_t client_data, caddr_t call_data) -{ - - GRAPH *graph = (GRAPH *) client_data; - XExposeEvent *pev = (XExposeEvent *) call_data; - XEvent ev; - XRectangle rects[30]; - int n = 1; - - DEVDEP(graph).isopen = 1; -# ifdef notdef - /* if there is a resize, let the resize routine handle the exposures */ - if (XCheckWindowEvent(display, DEVDEP(graph).window, - (long) StructureNotifyMask, &ev)) { - resize(w, client_data, &ev); - return; - } -# endif - - rects[0].x = pev->x; - rects[0].y = pev->y; - rects[0].width = pev->width; - rects[0].height = pev->height; - - /* XXX */ - /* pull out all other expose regions that need to be redrawn */ - while (n < 30 && XCheckWindowEvent(display, DEVDEP(graph).window, - (long) ExposureMask, &ev)) { - pev = (XExposeEvent *) &ev; - rects[n].x = pev->x; - rects[n].y = pev->y; - rects[n].width = pev->width; - rects[n].height = pev->height; - n++; - } - XSetClipRectangles(display, DEVDEP(graph).gc, 0, 0, - rects, n, Unsorted); - - noclear = True; - gr_redraw(graph); - noclear = False; - - XSetClipMask(display, DEVDEP(graph).gc, None); - -} - -void -resize(Widget w, caddr_t client_data, caddr_t call_data) -{ - - GRAPH *graph = (GRAPH *) client_data; - XEvent ev; - - /* pull out all other exposure events - Also, get rid of other StructureNotify events on this window. */ - - while (XCheckWindowEvent(display, DEVDEP(graph).window, - (long) /* ExposureMask | */ StructureNotifyMask, &ev)) - ; - - XClearWindow(display, DEVDEP(graph).window); - graph->absolute.width = w->core.width; - graph->absolute.height = w->core.height; - gr_resize(graph); - -} - -# ifdef notdef -/* stolen from CP/lexical.c */ - -/* A special 'getc' so that we can deal with ^D properly. There is no way for - * stdio to know if we have typed a ^D after some other characters, so - * don't use buffering at all... - */ -static int inchar(fp) - FILE *fp; -{ - - char c; - int i; - extern int errno; - -# ifdef HAS_TERMREAD - if (cp_interactive && !cp_nocc) { - i = read((int) fileno(fp), &c, 1); - if (i == 0) - return (EOF); - else if (i == -1) { - perror("read"); - return (EOF); - } else - return ((int) c); - } -# endif - c = getc(fp); - return ((int) c); -} -# endif - -void -X11_Input(REQUEST *request, RESPONSE *response) -{ - - XEvent ev; - int nfds, readfds; - - switch (request->option) { - case char_option: - - nfds = ConnectionNumber(display) > fileno(request->fp) ? - ConnectionNumber(display) : - fileno(request->fp); - - while (1) { - - /* first read off the queue before doing the select */ - while (XtPending()) { - XtNextEvent(&ev); - XtDispatchEvent(&ev); - } - - readfds = 1 << fileno(request->fp) | - 1 << ConnectionNumber(display); - - /* block on ConnectionNumber and request->fp */ - /* PN: added fd_set * casting */ - select(nfds + 1, (fd_set *)&readfds, (fd_set *) NULL, (fd_set *) NULL, NULL); - - /* handle X events first */ - if (readfds & (1 << ConnectionNumber(display))) { - /* handle ALL X events */ - while (XtPending()) { - XtNextEvent(&ev); - XtDispatchEvent(&ev); - } - } - - if (readfds & (1 << fileno(request->fp))) { - response->reply.ch = inchar(request->fp); - goto out; - } - - } - break; - - case click_option: - /* let's fake this */ - response->reply.graph = lasthardcopy; - break; - - case button_option: - /* sit and handle events until get a button selection */ - internalerror("button_option not implemented"); - response->option = error_option; - return; - break; - - case checkup_option: - /* first read off the queue before doing the select */ - while (XtPending()) { - XtNextEvent(&ev); - XtDispatchEvent(&ev); - } - break; - - default: - internalerror("unrecognized input type"); - response->option = error_option; - return; - break; - } - -out: - if (response) - response->option = request->option; - return; - -} - -static -void -X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) -{ - double lmin, lmax; - - if (graph->grid.gridtype == GRID_XLOG - || graph->grid.gridtype == GRID_LOGLOG) - { - lmin = log10(graph->datawindow.xmin); - lmax = log10(graph->datawindow.xmax); - *fx = exp(((x - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.width + lmin) - * M_LN10); - } else { - *fx = (x - graph->viewportxoff) * graph->aspectratiox + - graph->datawindow.xmin; - } - - if (graph->grid.gridtype == GRID_YLOG - || graph->grid.gridtype == GRID_LOGLOG) - { - lmin = log10(graph->datawindow.ymin); - lmax = log10(graph->datawindow.ymax); - *fy = exp(((graph->absolute.height - y - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.height + lmin) - * M_LN10); - } else { - *fy = ((graph->absolute.height - y) - graph->viewportyoff) - * graph->aspectratioy + graph->datawindow.ymin; - } - -} - - -static void -linear_arc(int x0, int y0, int radius, double theta1, double theta2) - /* x coordinate of center */ - /* y coordinate of center */ - /* radius of arc */ - /* initial angle ( +x axis = 0 rad ) */ - /* final angle ( +x axis = 0 rad ) */ - /* - * Notes: - * Draws an arc of radius and center at (x0,y0) beginning at - * angle theta1 (in rad) and ending at theta2 - */ -{ - int x1, y1, x2, y2; - int s = 60; - double dphi, phi; - - x2 = x0 + (int) (radius * cos(theta1)); - y2 = y0 + (int) (radius * sin(theta1)); - - while(theta1 >= theta2) - theta2 += 2 * M_PI; - dphi = (theta2 - theta1) / s; - - if ((theta1 + dphi) == theta1) { - theta2 += 2 * M_PI; - dphi = (theta2 - theta1) / s; - } - - - for(phi = theta1 + dphi; phi < theta2; phi += dphi) { - x1 = x2; - y1 = y2; - x2 = x0 + (int)(radius * cos(phi)); - y2 = y0 + (int)(radius * sin(phi)); - X11_DrawLine(x1,y1,x2,y2); - } - - x1 = x2; - y1 = y2; - x2 = x0 + (int)(radius * cos(theta2)); - y2 = y0 + (int)(radius * sin(theta2)); - X11_DrawLine(x1,y1,x2,y2); -} - -#else -int x11_dummy_symbol; -/* otherwise, some linkers get upset */ -#endif /* X_DISPLAY_MISSING */ diff --git a/src/frontend/x11.h b/src/frontend/x11.h deleted file mode 100644 index f9a6f1d5e..000000000 --- a/src/frontend/x11.h +++ /dev/null @@ -1,37 +0,0 @@ -/************* - * Header file for x11.c - * 1999 E. Rouat - ************/ - -#ifndef X11_H_INCLUDED -#define X11_H_INCLUDED - -int X11_Init(void); -void errorhandler(Display *display, XErrorEvent *errorev); -int X11_NewViewport(GRAPH *graph); -void initlinestyles(void); -void initcolors(GRAPH *graph); -void X11_Close(void); -void X11_DrawLine(int x1, int y1, int x2, int y2); -void X11_Arc(int x0, int y0, int radius, double theta1, double theta2); -void X11_Text(char *text, int x, int y); -int X11_DefineColor(int colorid, double red, double green, double blue); -void X11_DefineLinestyle(int linestyleid, int mask); -void X11_SetLinestyle(int linestyleid); -void X11_SetColor(int colorid); -void X11_Update(void); -void X11_Clear(void); -void handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata); -void handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata); -void slopelocation(GRAPH *graph, int x0, int y0); -void zoomin(GRAPH *graph); -void hardcopy(Widget w, caddr_t client_data, caddr_t call_data); -void killwin(Widget w, caddr_t client_data, caddr_t call_data); -void redraw(Widget w, caddr_t client_data, caddr_t call_data); -void resize(Widget w, caddr_t client_data, caddr_t call_data); -void X11_Input(REQUEST *request, RESPONSE *response); -void X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy); - - - -#endif diff --git a/src/frontend/xgraph.c b/src/frontend/xgraph.c deleted file mode 100644 index 266b1f6f3..000000000 --- a/src/frontend/xgraph.c +++ /dev/null @@ -1,166 +0,0 @@ -/********** -Copyright 1992 Regents of the University of California. All rights reserved. -Author: 1992 David A. Gates, U. C. Berkeley CAD Group -**********/ - -/* - * Xgraph-11 plots. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "fteparse.h" -#include "xgraph.h" - - -#define XG_MAXVECTORS 64 - -void -ft_xgraph(double *xlims, double *ylims, char *filename, char *title, char *xlabel, char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype, struct dvec *vecs) -{ - - FILE *file; - struct dvec *v, *scale; - double xval, yval; - int i, numVecs, linewidth; - bool xlog, ylog, nogrid, markers; - char buf[BSIZE_SP], pointstyle[BSIZE_SP], *text; - - /* Sanity checking. */ - for ( v = vecs, numVecs = 0; v; v = v->v_link2 ) { - numVecs++; - } - if (numVecs == 0) { - return; - } else if (numVecs > XG_MAXVECTORS) { - fprintf( cp_err, "Error: too many vectors for Xgraph.\n" ); - return; - } - if (!cp_getvar("xbrushwidth", VT_NUM, &linewidth)) - linewidth = 1; - if (linewidth < 1) linewidth = 1; - - if (!cp_getvar("pointstyle", VT_STRING, pointstyle)) { - markers = FALSE; - } else { - if (cieq(pointstyle,"markers")) { - markers = TRUE; - } else { - markers = FALSE; - } - } - - - /* Make sure the gridtype is supported. */ - switch (gridtype) { - case GRID_LIN: - nogrid = xlog = ylog = FALSE; - break; - case GRID_XLOG: - xlog = TRUE; - nogrid = ylog = FALSE; - break; - case GRID_YLOG: - ylog = TRUE; - nogrid = xlog = FALSE; - break; - case GRID_LOGLOG: - xlog = ylog = TRUE; - nogrid = FALSE; - break; - case GRID_NONE: - nogrid = TRUE; - xlog = ylog = FALSE; - break; - default: - fprintf( cp_err, "Error: grid type unsupported by Xgraph.\n" ); - return; - } - - /* Open the output file. */ - if (!(file = fopen(filename, "w"))) { - perror(filename); - return; - } - - /* Set up the file header. */ - if (title) { - text = cp_unquote(title); - fprintf( file, "TitleText: %s\n", text ); - tfree(text); - } - if (xlabel) { - text = cp_unquote(xlabel); - fprintf( file, "XUnitText: %s\n", text ); - tfree(text); - } - if (ylabel) { - text = cp_unquote(ylabel); - fprintf( file, "YUnitText: %s\n", text ); - tfree(text); - } - if (nogrid) { - fprintf( file, "Ticks: True\n" ); - } - if (xlog) { - fprintf( file, "LogX: True\n" ); - if (xlims) { - fprintf( file, "XLowLimit: % e\n", log10(xlims[0]) ); - fprintf( file, "XHighLimit: % e\n", log10(xlims[1]) ); - } - } else { - if (xlims) { - fprintf( file, "XLowLimit: % e\n", xlims[0] ); - fprintf( file, "XHighLimit: % e\n", xlims[1] ); - } - } - if (ylog) { - fprintf( file, "LogY: True\n" ); - if (ylims) { - fprintf( file, "YLowLimit: % e\n", log10(ylims[0]) ); - fprintf( file, "YHighLimit: % e\n", log10(ylims[1]) ); - } - } else { - if (ylims) { - fprintf( file, "YLowLimit: % e\n", ylims[0] ); - fprintf( file, "YHighLimit: % e\n", ylims[1] ); - } - } - fprintf( file, "LineWidth: %d\n", linewidth ); - fprintf( file, "BoundBox: True\n" ); - if (plottype == PLOT_COMB) { - fprintf( file, "BarGraph: True\n" ); - fprintf( file, "NoLines: True\n" ); - } else if (plottype == PLOT_POINT) { - if (markers) { - fprintf( file, "Markers: True\n" ); - } else { - fprintf( file, "LargePixels: True\n" ); - } - fprintf( file, "NoLines: True\n" ); - } - - /* Write out the data. */ - for ( v = vecs; v; v = v->v_link2 ) { - scale = v->v_scale; - if (v->v_name) { - fprintf( file, "\"%s\"\n", v->v_name ); - } - for ( i = 0; i < scale->v_length; i++ ) { - xval = isreal(scale) ? - scale->v_realdata[i] : realpart(&scale->v_compdata[i]); - yval = isreal(v) ? - v->v_realdata[i] : realpart(&v->v_compdata[i]); - fprintf( file, "% e % e\n", xval, yval ); - } - fprintf( file, "\n" ); - } - (void) fclose( file ); - (void) sprintf( buf, "xgraph %s &", filename ); - (void) system( buf ); - - - return; -} diff --git a/src/frontend/xgraph.h b/src/frontend/xgraph.h deleted file mode 100644 index 47cdc18c3..000000000 --- a/src/frontend/xgraph.h +++ /dev/null @@ -1,16 +0,0 @@ -/************* - * Header file for xgraph.c - * 1999 E. Rouat - ************/ - -#ifndef XGRAPH_H_INCLUDED -#define XGRAPH_H_INCLUDED - -void ft_xgraph(double *xlims, double *ylims, char *filename, char *title, - char *xlabel, char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype, - struct dvec *vecs); - - - - -#endif diff --git a/src/help.c b/src/help.c deleted file mode 100644 index 12ac354eb..000000000 --- a/src/help.c +++ /dev/null @@ -1,114 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * The main routine for the help system in stand-alone mode. - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include "hlpdefs.h" - - - -#ifndef X_DISPLAY_MISSING -Widget toplevel; -#endif - -FILE *cp_in, *cp_out, *cp_err; -char *Spice_Exec_Dir = NGSPICEBINDIR; -char *Spice_Lib_Dir = NGSPICEDATADIR; -char *Def_Editor = "vi"; -int AsciiRawFile = 0; - -char *Bug_Addr = ""; -char *Spice_Host = ""; -char *Spiced_Log = ""; - -/* dummy declaration so CP.a doesn't pull in lexical.o and other objects */ -bool cp_interactive = FALSE; - -char *hlp_filelist[] = { "ngspice", 0 }; - -int -main(int ac, char **av) -{ - wordlist *wl = NULL; - -#ifndef X_DISPLAY_MISSING - char *displayname; - /* grrr, Xtk forced contortions */ - char *argv[2]; - int argc = 2; - char buf[512]; -#endif - - ivars( ); - - cp_in = stdin; - cp_out = stdout; - cp_err = stderr; - -#ifndef X_DISPLAY_MISSING - - if (cp_getvar("display", VT_STRING, buf)) { - displayname = buf; - } else if (!(displayname = getenv("DISPLAY"))) { - fprintf(stderr, "Can't open X display."); - goto out; - } - - argv[0] = "nutmeg"; - argv[1] = displayname; - /* initialize X toolkit */ - toplevel = XtInitialize("nutmeg", "Nutmeg", NULL, 0, &argc, argv); - -#endif - -out: - if (ac > 1) - wl = wl_build(av + 1); - hlp_main(Help_Path, wl); - -#ifndef X_DISPLAY_MISSING - if (hlp_usex) { - printf("Hit control-C when done.\n"); /* sigh */ - XtMainLoop(); - } -#endif - - exit(EXIT_NORMAL); -} - -void -fatal(char *s) -{ - fprintf(stderr, "fatal error: %s\n", s); - exit(1); -} - -/* There is a conflict witj another cp_printword in cp/quote.c -static void -cp_printword(s) - char *s; -{ - printf("%s", s); - return; -} - -*/ - -bool -cp_getvar(char *n, int t, char *r) -{ - return (FALSE); -} - -char * -cp_tildexpand(char *s) -{ - return tilde_expand(s); -} diff --git a/src/hlp/ChangeLog b/src/hlp/ChangeLog deleted file mode 100644 index d6163fa49..000000000 --- a/src/hlp/ChangeLog +++ /dev/null @@ -1,32 +0,0 @@ -1999-08-12 Emmanuel Rouat - - * x11disp.c: made a cast to (XtCallbackProc) when necessary - - * readhelp.c: sanitised the code slighly - - * *.c: changed functions from K&R into ANSI using protoize - -1999-08-08 Emmanuel Rouat - - * xdisplay.c: removed all X10 related code - - * Makefile.am (DEFS): removed -DWANT_MFB (don't need it) - -1999-08-03 Emmanuel Rouat - - * readhelp.c: HAVE_SYS_DIR_H and HAVE_DIRENT_H instead of - HAS_BSDDIRS and HAS_SYSVDIRS. - -1999-07-31 Emmanuel Rouat - - * Makefile.am: added @X_CFLAGS@ in INCLUDES list and removed unused LIBS - - -28-07-1999 emmanuel.rouat@wanadoo.fr (Manu Rouat) - - * help.c: - * provide.c: - * x11disp.c: changed HAS_X11 define to X_DISPLAY_MISSING, which is supplied - by autoconf in config.h - - * removed -DWANT_X11 in Makefile.am \ No newline at end of file diff --git a/src/hlp/Makefile.am b/src/hlp/Makefile.am deleted file mode 100644 index e2871d998..000000000 --- a/src/hlp/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LIBRARIES = libhlp.a - -libhlp_a_SOURCES = \ - help.c \ - provide.c \ - readhelp.c \ - textdisp.c \ - xdisplay.c \ - x11disp.c - - - -INCLUDES = -I$(top_srcdir)/src/include @X_CFLAGS@ - - -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/hlp/help.c b/src/hlp/help.c deleted file mode 100644 index 603b4c99e..000000000 --- a/src/hlp/help.c +++ /dev/null @@ -1,171 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -Modified 1999 Emmanuel Rouat -**********/ - -/* - * The main entry point for the help system. - */ - -#include -#include "ngspice.h" -#include "cpstd.h" -#include "hlpdefs.h" -#include "suffix.h" - -char *hlp_directory; -extern char *hlp_filelist[]; -int hlp_ftablesize = 0; - -void -hlp_main(char *path, wordlist *wl) -{ - topic *top; - fplace *place; - - hlp_directory = path; - - if (wl) { - while (wl) { - if (!(place = findglobalsubject(wl->wl_word))) { - fprintf(stderr, "Error: No such topic: %s\n", - wl->wl_word); - wl = wl->wl_next; - continue; - } - if (!(top = hlp_read(place))) { - fprintf(stderr, "Error: can't read topic\n"); - wl = wl->wl_next; - continue; - } - hlp_provide(top); - wl = wl->wl_next; - } - } else { - if (!(place = findglobalsubject("main"))) { - fprintf(stderr, "Error: no main topic\n"); - return; - } - if (!(top = hlp_read(place))) { - fprintf(stderr, "Error: can't read topic\n"); - return; - } - hlp_provide(top); - } - -#ifdef X_DISPLAY_MISSING - hlp_free(); -#endif - - return; -} - -fplace * -findglobalsubject(char *subject) -{ - - fplace *place; - char **dict; - long fpos; - - place = 0; - for (dict = hlp_filelist; *dict && **dict; dict++) { - fpos = findsubject(*dict, subject); - if (fpos != -1) { - place = (fplace *) tmalloc(sizeof(fplace)); - place->fpos = fpos; - place->filename = copy(*dict); - place->fp = hlp_fopen(*dict); - break; - } - } - return(place); -} - -/* see if file is on filelist */ -bool -hlp_approvedfile(char *filename) -{ - char **s; - - for (s = hlp_filelist; *s && **s; s++) { - if (cieq(*s, filename)) return(TRUE); - } - return(FALSE); -} - -/* keep file pointers on top level files so we don't always have to do - fopen's */ -FILE *hlp_fopen(char *filename) -{ - static struct { - char filename[BSIZE_SP]; - FILE *fp; - } hlp_ftable[32]; - int i; - char buf[BSIZE_SP]; - - for (i=0; i < hlp_ftablesize; i++) { - if (cieq(filename, hlp_ftable[i].filename)) { - return(hlp_ftable[i].fp); - } - } - - /* not already in table */ - strcpy(buf, hlp_directory); /* set up pathname */ - strcat(buf, DIR_PATHSEP); - strcat(buf, filename); - strcat(buf, ".txt"); - hlp_pathfix(buf); - if (!(hlp_ftable[hlp_ftablesize].fp = fopen(buf, "r"))) { - perror(buf); - return (NULL); - } - - strcpy(hlp_ftable[hlp_ftablesize].filename, filename); - hlp_ftablesize++; - - return(hlp_ftable[hlp_ftablesize - 1].fp); - -} - -/* ARGSUSED */ -void -hlp_pathfix(char *buf) -{ - char *s, *t, *u, bufx[1025]; - char *dir_pathsep; - extern char *cp_tildexpand( ); - - dir_pathsep = DIR_PATHSEP; - - if (!buf) - return; - - s = cp_tildexpand(buf); - if (sizeof(DIR_PATHSEP) == 2) { - if (*dir_pathsep != '/') { - for (t = s; *t; t++) { - if (*t == '/') - *t = *dir_pathsep; - } - } else - strcpy(buf, s); - } else { - /* For vms; this probably doesn't work, but neither did the old code */ - for (s = bufx, t = buf; *t; t++) { - if (*t == '/') - for (u = DIR_PATHSEP; *u; u++) { - *s++ = *u; - } - else - *s++ = *t; - } - *s = 0; - strcpy(buf, s); - } - if (s) - tfree(s); - return; -} diff --git a/src/hlp/provide.c b/src/hlp/provide.c deleted file mode 100644 index 7afcdf301..000000000 --- a/src/hlp/provide.c +++ /dev/null @@ -1,145 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -Modified 1999 Emmanuel Rouat -**********/ - -/* - * faustus@cad.berkeley.edu, ucbvax!faustus - * Permission is granted to modify and re-distribute this code in any manner - * as long as this notice is preserved. All standard disclaimers apply. - * - * Toss the help window up on the screen, and deal with the graph... - */ - -#include -#include "ngspice.h" -#include "cpstd.h" -#include "hlpdefs.h" -#include "suffix.h" - -bool hlp_usex = FALSE; - -void -hlp_provide(topic *top) -{ - toplink *res; - topic *parent, *newtop; - - if (!top) - return; - -#ifndef X_DISPLAY_MISSING - if (getenv("DISPLAY") || hlp_displayname) - hlp_usex = TRUE; -#endif - - top->xposition = top->yposition = 0; - if (hlp_usex) { - if (!hlp_xdisplay(top)) { - fprintf(stderr, "Couldn't open X display.\n"); - return; - } - } else { - if (!hlp_tdisplay(top)) { - fprintf(stderr, "Couldn't display text\n"); - return; - } - } - -#ifndef X_DISPLAY_MISSING /* X11 does this asynchronously */ - if (hlp_usex) return; -#endif - - for (;;) { - if (hlp_usex) - res = hlp_xhandle(&parent); - else - res = hlp_thandle(&parent); - if (!res && !parent) { - /* No more windows. */ - hlp_killfamily(top); - if (hlp_usex) hlp_xclosedisplay(); /* need to change - display pointer back J.H. */ - return; - } - if (res) { - /* Create a new window... */ - if (hlp_usex) - hlp_xwait(parent, TRUE); - if (!(newtop = hlp_read(res->place))) { - fprintf(stderr, "Internal error: bad link\n"); - hlp_xwait(parent, FALSE); - continue; - } - if (hlp_usex) - hlp_xwait(parent, FALSE); - newtop->next = parent->children; - parent->children = newtop; - newtop->parent = parent; - newtop->xposition = parent->xposition + 50; - newtop->yposition = parent->yposition + 50; - if (hlp_usex) { - if (!hlp_xdisplay(newtop)) { - fprintf(stderr, "Couldn't open win\n"); - return; - } - } else { - if (!hlp_tdisplay(newtop)) { - fprintf(stderr, "Couldn't display\n"); - return; - } - } - } else { - /* Blow this one and its descendants away. */ - hlp_killfamily(parent); - hlp_fixchildren(parent); - if (parent == top) - return; - } - } - -} - -void -hlp_fixchildren(topic *parent) -{ - - topic *pa; - - if (parent->parent) { - if (parent->parent->children == parent) - parent->parent->children = - parent->next; - else { - for (pa = parent->parent->children; - pa->next; pa = pa->next) - if (pa->next == parent) - break; - if (!pa->next) { - fprintf(stderr, "bah...\n"); - } - pa->next = pa->next->next; - } - } -} - -/* Note that this doesn't actually free the data structures, just gets - * rid of the window. - */ - -void -hlp_killfamily(topic *top) -{ - topic *ch; - - for (ch = top->children; ch; ch = ch->next) - hlp_killfamily(ch); - if (hlp_usex) - hlp_xkillwin(top); - else - hlp_tkillwin(top); - top->children = NULL; - return; -} - diff --git a/src/hlp/readhelp.c b/src/hlp/readhelp.c deleted file mode 100644 index 029992bd7..000000000 --- a/src/hlp/readhelp.c +++ /dev/null @@ -1,338 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -Modified 1999 Emmanuel Rouat -**********/ - - - -#include -#include "ngspice.h" -#include "cpstd.h" -#include "hlpdefs.h" - -#ifdef notdef - -# ifdef HAVE_SYS_DIR_H -# include -# include -# include -# else -# ifdef HAVE_DIRENT_H -# include -# include -# ifndef direct -# define direct dirent -# endif -# endif -# endif - - -#endif - -#include "suffix.h" - -static char *getsubject(fplace *place); -static toplink *getsubtoplink(char **ss); -extern void sortlist(toplink **tlp), tlfree(toplink *tl); -extern int sortcmp(toplink **tlp1, toplink **tlp2); - -static topic *alltopics = NULL; - -static fplace *copy_fplace(fplace *place); - -topic * -hlp_read(fplace *place) -{ - char buf[BSIZE_SP]; - topic *top = alloc(topic); - toplink *topiclink; - toplink *tl, *tend = NULL; - wordlist *wl, *end = NULL; - int i, fchanges; - char *s; - bool mof; - - if (!place) - return 0; - - top->place = copy_fplace(place); - - /* get the title */ - if (!place->fp) place->fp = hlp_fopen(place->filename); - if (!place->fp) return(NULL); - fseek(place->fp, place->fpos, 0); - (void) fgets(buf, BSIZE_SP, place->fp); /* skip subject */ - (void) fgets(buf, BSIZE_SP, place->fp); - for (s = buf; *s && (*s != '\n'); s++) - ; - *s = '\0'; - top->title = copy(&buf[7]); /* don't copy "TITLE: " */ - - /* get the text */ - /* skip to TEXT: */ - while (fgets(buf, BSIZE_SP, place->fp)) { - if (!strncmp("TEXT: ", buf, 6)) break; - if ((*buf = '\0') || - !strncmp("SEEALSO: ", buf, 9) || - !strncmp("SUBTOPIC: ", buf, 10)) { - /* no text */ - top->text = NULL; - goto endtext; - } - } - mof = TRUE; - while (mof && !strncmp("TEXT: ", buf, 6)) { - for (s = &buf[6], fchanges = 0; *s && (*s != '\n'); s++) - if (((s[0] == '\033') && s[1]) || - ((s[0] == '_') && (s[1] == '\b'))) - fchanges++; - *s = '\0'; - wl = alloc(wordlist); - wl->wl_word = copy(&buf[6]); - if (end) - end->wl_next = wl; - else - top->text = wl; - wl->wl_prev = end; - end = wl; - top->numlines++; - if ((i = strlen(&buf[6]) - fchanges) > top->maxcols) - top->maxcols = i; - mof = fgets(buf, BSIZE_SP, place->fp) == NULL ? FALSE : TRUE; - } -endtext: - - /* get subtopics */ - while(mof && !strncmp("SUBTOPIC: ", buf, 10)) { - s = &buf[10]; - /* process tokens within line, updating pointer */ - while (*s) { - if ((topiclink = getsubtoplink(&s))) { - if (tend) - tend->next = topiclink; - else - top->subtopics = topiclink; - tend = topiclink; - } - } - mof = fgets(buf, BSIZE_SP, place->fp) == NULL ? FALSE : TRUE; - } - - /* get see alsos */ - tend = NULL; - while(mof && !strncmp("SEEALSO: ", buf, 9)) { - s = &buf[9]; - /* process tokens within line, updating pointer */ - while (*s) { - if ((topiclink = getsubtoplink(&s))) { - if (tend) - tend->next = topiclink; - else - top->seealso = topiclink; - tend = topiclink; - } - } - mof = fgets(buf, BSIZE_SP, place->fp) == NULL ? FALSE : TRUE; - } - - /* Now we have to fill in the subjects - for the seealsos and subtopics. */ - for (tl = top->seealso; tl; tl = tl->next) - tl->description = getsubject(tl->place); - for (tl = top->subtopics; tl; tl = tl->next) - tl->description = getsubject(tl->place); - - sortlist(&top->seealso); - /* sortlist(&top->subtopics); It looks nicer if they - are in the original order */ - - top->readlink = alltopics; - alltopics = top; - - return (top); -} - -/* *ss is of the form filename:subject */ -static toplink *getsubtoplink(char **ss) -{ - toplink *tl; - char *tmp, *s, *t; - char subject[BSIZE_SP]; - - if (!**ss) return(NULL); - - s = *ss; - - tl = alloc(toplink); - if ((tmp =strchr(s, ':'))) { - tl->place = alloc(fplace); - tl->place->filename = strncpy( - calloc(1, (unsigned) (sizeof (char) * (tmp - s + 1))), - s, (tmp - s)); - tl->place->filename[tmp - s] = '\0'; - strtolower(tl->place->filename); - - /* see if filename is on approved list */ - if (!hlp_approvedfile(tl->place->filename)) { - tfree(tl->place); - tfree(tl); - /* skip up to next comma or newline */ - while (*s && *s != ',' && *s != '\n') s++; - while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++; - *ss = s; - return(NULL); - } - - tl->place->fp = hlp_fopen(tl->place->filename); - for (s = tmp + 1, t = subject; *s && *s != ',' && *s != '\n'; s++) { - *t++ = *s; - } - *t = '\0'; - tl->place->fpos = findsubject(tl->place->filename, subject); - if (tl->place->fpos == -1) { - tfree(tl->place); - tfree(tl); - while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++; - *ss = s; - return(NULL); - } - } else { - fprintf(stderr, "bad filename:subject pair %s\n", s); - /* skip up to next free space */ - while (*s && *s != ',' && *s != '\n') s++; - while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++; - *ss = s; - tfree(tl->place); - tfree(tl); - return(NULL); - } - while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++; - *ss = s; - return(tl); -} - -/* returns a file position, -1 on error */ -long -findsubject(char *filename, char *subject) -{ - - FILE *fp; - char buf[BSIZE_SP]; - struct hlp_index indexitem; - - if (!filename) { - return -1; - } - - /* open up index for filename */ - sprintf(buf, "%s%s%s.idx", hlp_directory, DIR_PATHSEP, filename); - hlp_pathfix(buf); - if (!(fp = fopen(buf, "rb"))) { - perror(buf); - return(-1); - } - - while(fread((char *) &indexitem, sizeof (struct hlp_index), 1, fp)) { - if (!strncmp(subject, indexitem.subject, 64)) { - fclose(fp); - return(indexitem.fpos); - } - } - - fclose(fp); - return(-1); - -} - -static char * -getsubject(fplace *place) -{ - char buf[BSIZE_SP], *s; - - if (!place->fp) place->fp = hlp_fopen(place->filename); - if (!place->fp) return(NULL); - - fseek(place->fp, place->fpos, 0); - (void) fgets(buf, BSIZE_SP, place->fp); - for (s = buf; *s && (*s != '\n'); s++) - ; - *s = '\0'; - return (copy(&buf[9])); /* don't copy "SUBJECT: " */ -} - -static - void sortlist(toplink **tlp) -{ - toplink **vec, *tl; - int num = 0, i; - - for (tl = *tlp; tl; tl = tl->next) - num++; - if (!num) - return; - vec = (toplink **) tmalloc(sizeof (toplink *) * num); - for (tl = *tlp, i = 0; tl; tl = tl->next, i++) - vec[i] = tl; - (void) qsort((char *) vec, num, sizeof (toplink *), sortcmp); - *tlp = vec[0]; - for (i = 0; i < num - 1; i++) - vec[i]->next = vec[i + 1]; - vec[i]->next = NULL; - tfree(vec); - return; -} - -static int -sortcmp(toplink **tlp1, toplink **tlp2) -{ - return (strcmp((*tlp1)->description, (*tlp2)->description)); -} - -void -hlp_free(void) -{ - topic *top, *nt = NULL; - - for (top = alltopics; top; top = nt) { - nt = top->readlink; - tfree(top->title); - tfree(top->place); - wl_free(top->text); - tlfree(top->subtopics); - tlfree(top->seealso); - tfree(top); - } - alltopics = NULL; - return; -} - -static -void tlfree(toplink *tl) -{ - toplink *nt = NULL; - - while (tl) { - tfree(tl->description); - tfree(tl->place->filename); - tfree(tl->place); - /* Don't free the button stuff... */ - nt = tl->next; - tfree(tl); - tl = nt; - } - return; -} - -static fplace * -copy_fplace(fplace *place) -{ - fplace *newplace; - - newplace = (fplace *) malloc(sizeof(fplace)); - newplace->filename = copy(place->filename); - newplace->fpos = place->fpos; - newplace->fp = place->fp; - - return(newplace); -} diff --git a/src/hlp/textdisp.c b/src/hlp/textdisp.c deleted file mode 100644 index 556a50dae..000000000 --- a/src/hlp/textdisp.c +++ /dev/null @@ -1,201 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - - -/* - * faustus@cad.berkeley.edu, ucbvax!faustus - * Permission is granted to modify and re-distribute this code in any manner - * as long as this notice is preserved. All standard disclaimers apply. - * - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "hlpdefs.h" -#include "suffix.h" - -static topic *curtop; -static bool quitflag; - -static void putline(char *s); -static int putstuff(toplink *tl, int base); - -int hlp_width = 72; - -bool -hlp_tdisplay(topic *top) -{ - wordlist *wl; - int i = 0; - - curtop = top; - - out_init(); - out_printf("\n\t%s\n", top->title); - for (wl = top->text; wl; wl = wl->wl_next) - putline(wl->wl_word); - if (top->subtopics) { - out_printf("\tSub-Topics:\n\n"); - i = putstuff(top->subtopics, 0); - } - if (top->seealso) { - out_printf("\n\tSee Also:\n\n"); - (void) putstuff(top->seealso, i); - } - out_printf("\n"); - return (TRUE); -} - -toplink * -hlp_thandle(topic **parent) -{ - char buf[BSIZE_SP], *s; - toplink *tl; - int num; - - quitflag = FALSE; - if (!curtop) { - *parent = NULL; - return (NULL); - } - for (;;) { - fprintf(cp_out, "Selection (`?' for help): "); - (void) fflush(cp_out); - if (!fgets(buf, BSIZE_SP, cp_in)) { - clearerr(stdin); - quitflag = TRUE; - *parent = NULL; - return (NULL); - } - - for (s = buf; *s && isspace(*s); s++) - ; - switch (*s) { - case '?': - fprintf(cp_out, -"\nType the number of a sub-topic or see also, or one of:\n\ -\tr\tReprint the current topic\n\ -\tp or CR\tReturn to the previous topic\n\ -\tq\tQuit help\n\ -\t?\tPrint this message\n\n"); - continue; - - case 'r': - (void) hlp_tdisplay(curtop); - continue; - - case 'q': - quitflag = TRUE; - *parent = NULL; - return (NULL); - - case 'p': - case '\n': - case '\r': - case '\0': - *parent = curtop; - return (NULL); - } - if (!isdigit(*s)) { - fprintf(cp_err, "Invalid command\n"); - continue; - } - num = atoi(s); - if (num <= 0) { - fprintf(cp_err, "Bad choice.\n"); - continue; - } - for (tl = curtop->subtopics; tl; tl = tl->next) - if (--num == 0) - break; - if (num) { - for (tl = curtop->seealso; tl; tl = tl->next) - if (--num == 0) - break; - } - if (num) { - fprintf(cp_err, "Bad choice.\n"); - continue; - } - *parent = curtop; - return (tl); - } -} - -/* ARGSUSED */ -void -hlp_tkillwin(topic *top) -{ - if (curtop) - curtop = curtop->parent; - if (curtop && !quitflag) - (void) hlp_tdisplay(curtop); - return; -} - -/* This has to rip out the font changes from the lines... */ - -static void -putline(char *s) -{ - char buf[BSIZE_SP]; - int i = 0; - - while (*s) { - if (((*s == '\033') && s[1]) || - ((*s == '_') && (s[1] == '\b'))) - s += 2; - else - buf[i++] = *s++; - } - buf[i] = '\0'; - out_printf("%s\n", buf); - return; -} - -/* Figure out the number of columns we can use. Assume an entry like - * nn) word -- add 5 characters to the width... - */ - -static int -putstuff(toplink *tl, int base) -{ - int maxwidth = 0, ncols, nrows, nbuts = 0, i, j, k; - toplink *tt; - - for (tt = tl; tt; tt = tt->next) { - if (strlen(tt->description) + 5 > maxwidth) - maxwidth = strlen(tt->description) + 5; - nbuts++; - } - ncols = hlp_width / maxwidth; - if (!ncols) { - fprintf(stderr, "Help, button too big!!\n"); - return (0); - } - if (ncols > nbuts) - ncols = nbuts; - maxwidth = hlp_width / ncols; - nrows = nbuts / ncols; - if (nrows * ncols < nbuts) - nrows++; - - for (i = 0; i < nrows; i++) { - for (tt = tl, j = 0; j < i; j++, tt = tt->next) - ; - for (j = 0; j < ncols; j++) { - if (tt) - out_printf("%2d) %-*s ", base + j * nrows + i + - 1, maxwidth - 5, tt->description); - for (k = 0; k < nrows; k++) - if (tt) - tt = tt->next; - - } - out_printf("\n"); - } - return (nbuts); -} - diff --git a/src/hlp/x11disp.c b/src/hlp/x11disp.c deleted file mode 100644 index d3a42d1f6..000000000 --- a/src/hlp/x11disp.c +++ /dev/null @@ -1,299 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: Jeffrey M. Hsu -Modified 1999 Emmanuel Rouat -**********/ - -#include -#include "ngspice.h" - -#ifndef X_DISPLAY_MISSING - -#include "cpstd.h" -#include "hlpdefs.h" -#include -#include -#include -#include -#include -#include -#include -#include - -static bool started = FALSE; -static topic *topics = NULL; -void newtopic(Widget w, caddr_t client_data, caddr_t call_data), delete(Widget w, caddr_t client_data, caddr_t call_data), quit(Widget w, caddr_t client_data, caddr_t call_data); -static void sputline(char *buf, char *s); - -/* Create a new window... */ -bool -hlp_xdisplay(topic *top) -{ - - toplink *tl; - handle *hand; - - wordlist *wl; - char *buf; - - static Arg titleargs[] = { - { XtNtop, (XtArgVal) XtChainTop }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtChainLeft }, - { XtNright, (XtArgVal) XtChainLeft }, - { XtNwidth, (XtArgVal) 650 }, - }; - - static Arg formargs[ ] = { - { XtNtop, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNbottom, (XtArgVal) XtChainBottom }, - }; - Arg htextargs[7]; -/* Arg vportargs[5]; */ - static Arg bboxargs[ ] = { - { XtNtop, (XtArgVal) XtChainBottom }, - { XtNtop, (XtArgVal) XtChainBottom }, - { XtNtop, (XtArgVal) XtChainBottom }, - { XtNtop, (XtArgVal) XtChainBottom }, - { XtNbottom, (XtArgVal) XtChainBottom }, - { XtNleft, (XtArgVal) XtChainLeft }, - { XtNright, (XtArgVal) XtChainLeft }, - }; - Arg buttonargs[1]; - Arg labelargs[3]; - Widget buttonwidget; - - if (!started) { /* have to init everything */ - - /* assume X toolkit already initialize */ - - started = TRUE; - - } - - top->shellwidget = XtCreateApplicationShell("shell", - topLevelShellWidgetClass, NULL, 0); - - if (!top->parent) { - top->xposition = hlp_initxpos; - top->yposition = hlp_initypos; - } else { - top->xposition = top->parent->xposition + X_INCR; - top->yposition = top->parent->yposition + Y_INCR; - } - XtSetArg(formargs[0], XtNx, top->xposition); - XtSetArg(formargs[1], XtNy, top->yposition); - top->formwidget = XtCreateManagedWidget("form", formWidgetClass, - top->shellwidget, formargs, XtNumber(formargs)); - - /* we really want a title bar widget for this, sigh */ - top->titlewidget = XtCreateManagedWidget("title", - boxWidgetClass, top->formwidget, - titleargs, XtNumber(titleargs)); - XtSetArg(labelargs[0], XtNlabel, top->title); - XtCreateManagedWidget("titlelabel", labelWidgetClass, - top->titlewidget, labelargs, 1); - XtSetArg(buttonargs[0], XtNlabel, "quit help"); - buttonwidget = XtCreateManagedWidget("quit", commandWidgetClass, - top->titlewidget, buttonargs, 1); - XtAddCallback(buttonwidget, XtNcallback, (XtCallbackProc) quit, top); - XtSetArg(buttonargs[0], XtNlabel, "delete window"); - buttonwidget = XtCreateManagedWidget("delete", commandWidgetClass, - top->titlewidget, buttonargs, XtNumber(buttonargs)); - XtAddCallback(buttonwidget, XtNcallback, (XtCallbackProc) delete, top); - -#ifdef notdef - /* enclose text string w/in a viewport widget for scrolling */ - XtSetArg(vportargs[0], XtNfromVert, top->titlewidget); - XtSetArg(vportargs[1], XtNallowResize, True); - XtSetArg(vportargs[2], XtNallowVert, True); - XtSetArg(vportargs[3], XtNallowHoriz, True); - XtSetArg(vportargs[4], XtNforceBars, True); - top->viewwidget = XtCreateManagedWidget("viewport", - viewportWidgetClass, top->formwidget, - vportargs, 5); -#endif - - buf = tmalloc(80 * top->numlines + 100); - buf[0] = '\0'; - for (wl = top->text; wl; wl = wl->wl_next) { - sputline(buf, wl->wl_word); - } - top->chartext = buf; /* make sure gets deallocated later XXX */ - XtSetArg(htextargs[0], XtNstring, top->chartext); - XtSetArg(htextargs[1], XtNallowResize, True); - XtSetArg(htextargs[2], XtNscrollHorizontal, True ); - XtSetArg(htextargs[3], XtNscrollVertical, True ); - XtSetArg(htextargs[4], XtNfromVert, top->titlewidget); - XtSetArg(htextargs[5], XtNwidth, 660); - XtSetArg(htextargs[6], XtNheight, 350); - top->textwidget = XtCreateManagedWidget("helptext", - asciiTextWidgetClass, top->formwidget, htextargs, - XtNumber(htextargs)); - - if (top->subtopics) { - XtSetArg(labelargs[0], XtNfromVert, top->textwidget); - XtSetArg(labelargs[1], XtNvertDistance, 8); - XtSetArg(labelargs[2], XtNlabel, "Subtopics: "); - top->sublabelwidget = XtCreateManagedWidget("sublabel", - labelWidgetClass, top->formwidget, labelargs, XtNumber(labelargs)); - - XtSetArg(bboxargs[0], XtNwidth, 400); - XtSetArg(bboxargs[1], XtNallowResize, True); - XtSetArg(bboxargs[2], XtNfromVert, top->sublabelwidget); - top->subboxwidget = XtCreateManagedWidget("buttonbox", - boxWidgetClass, top->formwidget, bboxargs, XtNumber(bboxargs)); - - for (tl = top->subtopics; tl; tl = tl->next) { - tl->button.text = tl->description; - tl->button.tag = tl->place; - if (!tl->button.text) - tl->button.text = ""; - - XtSetArg(buttonargs[0], XtNlabel, tl->button.text); - buttonwidget = XtCreateManagedWidget(tl->button.text, - commandWidgetClass, top->subboxwidget, buttonargs, - XtNumber(buttonargs)); - /* core leak XXX */ - hand = (handle *) calloc(1, sizeof (struct handle)); - hand->result = tl; - hand->parent = top; - XtAddCallback(buttonwidget, XtNcallback, (XtCallbackProc) newtopic, hand); - } - } - - if (top->seealso) { - if (top->subtopics) - XtSetArg(labelargs[0], XtNfromVert, top->subboxwidget); - else - XtSetArg(labelargs[0], XtNfromVert, top->textwidget); - XtSetArg(labelargs[1], XtNvertDistance, 8); - XtSetArg(labelargs[2], XtNlabel, "See also: "); - top->seelabelwidget = XtCreateManagedWidget("seelabel", - labelWidgetClass, top->formwidget, labelargs, XtNumber(labelargs)); - - XtSetArg(bboxargs[0], XtNwidth, 400); - XtSetArg(bboxargs[1], XtNallowResize, True); - XtSetArg(bboxargs[2], XtNfromVert, top->seelabelwidget); - top->seeboxwidget = XtCreateManagedWidget("buttonbox", - boxWidgetClass, top->formwidget, bboxargs, XtNumber(bboxargs)); - - for (tl = top->seealso; tl; tl = tl->next) { - tl->button.text = tl->description; - tl->button.tag = tl->place; - if (!tl->button.text) - tl->button.text = ""; - - XtSetArg(buttonargs[0], XtNlabel, tl->button.text); - buttonwidget = XtCreateManagedWidget(tl->button.text, - commandWidgetClass, top->seeboxwidget, buttonargs, 1); - hand = (handle *) calloc(1, sizeof (struct handle)); - /* core leak XXX */ - hand->result = tl; - hand->parent = top; - XtAddCallback(buttonwidget, XtNcallback, (XtCallbackProc) newtopic, hand); - } - } - - XtRealizeWidget(top->shellwidget); - - top->winlink = topics; - topics = top; - - return (TRUE); - -} - -void -newtopic(Widget w, caddr_t client_data, caddr_t call_data) -{ - topic *parent = ((handle *) client_data)->parent; - toplink *result = ((handle *) client_data)->result; - topic *newtop; - - if (!(newtop = hlp_read(result->place))) { - fprintf(stderr, "Internal error: bad link\n"); - } - - newtop->next = parent->children; - parent->children = newtop; - newtop->parent = parent; - newtop->xposition = parent->xposition + 50; - newtop->yposition = parent->yposition + 50; - if (!hlp_xdisplay(newtop)) { - fprintf(stderr, "Couldn't open win\n"); - return; - } -} - -void -delete(Widget w, caddr_t client_data, caddr_t call_data) -{ - - topic *top = (topic *) client_data; - - hlp_killfamily(top); - hlp_fixchildren(top); -} - -void -quit(Widget w, caddr_t client_data, caddr_t call_data) -{ - - topic *top = (topic *) client_data, *parent = top->parent; - - while (parent && parent->parent) parent = parent->parent; - hlp_killfamily(parent ? parent : top); -} - -void -hlp_xkillwin(topic *top) -{ - topic *last; - - if (top == topics) - topics = top->winlink; - else if (top->winlink) { /* we need this check for the - pathological case where you have two helps running, - normally hp_killfamily doesn't let this happen */ - for (last = topics; last->winlink; last = last->winlink) - if (last->winlink == top) { - last->winlink = top->winlink; - break; - } - if (!last->winlink) { - fprintf(stderr, "window not in list!!\n"); - return; - } - } - XtDestroyWidget(top->shellwidget); - return; -} - -/* rip out font changes and write at end of buffer */ -static void -sputline(char *buf, char *s) -{ - - char tmp[BSIZE_SP], *tmpp; - int i = 0; - - while (*s) { - if (((*s == '\033') && s[1]) || - ((*s == '_') && (s[1] == '\b'))) - s += 2; - else - tmp[i++] = *s++; - } - tmp[i] = '\0'; - - /* strcat can't handle long strings */ - tmpp = buf + strlen(buf); - sprintf(tmpp, "%s\n", tmp); - - return; -} - -#endif /* X_DISPLAY_MISSING */ diff --git a/src/hlp/xdisplay.c b/src/hlp/xdisplay.c deleted file mode 100644 index 6b86f85da..000000000 --- a/src/hlp/xdisplay.c +++ /dev/null @@ -1,34 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -Modified 1999 Emmanuel Rouat -**********/ - -#include -#include "ngspice.h" -#include "cpstd.h" -#include "hlpdefs.h" -#include "suffix.h" - - -char *hlp_boldfontname = BOLD_FONT; -char *hlp_regfontname = REG_FONT; -char *hlp_italicfontname = ITALIC_FONT; -char *hlp_titlefontname = TITLE_FONT; -char *hlp_buttonfontname = BUTTON_FONT; -char *hlp_displayname = NULL; -int hlp_initxpos = START_XPOS; -int hlp_initypos = START_YPOS; -int hlp_buttonstyle = BS_LEFT; - - - -#ifdef X_DISPLAY_MISSING -/* ARGSUSED */ bool hlp_xdisplay(topic *top) { return (FALSE); } -/* ARGSUSED */ void hlp_xkillwin(topic *top) { } -#endif - -/* ARGSUSED */ void hlp_xwait(topic *top, bool on) { } -void hlp_xclosedisplay(void) {} -toplink * hlp_xhandle(topic **pp) { *pp = NULL; return (NULL); } - diff --git a/src/include/arch.h b/src/include/arch.h deleted file mode 100644 index 172cb6894..000000000 --- a/src/include/arch.h +++ /dev/null @@ -1,27 +0,0 @@ -/********** -Copyright 1993 Regents of the University of California. All rights reserved. -Author: 1993 David A. Gates -**********/ -/* - */ -#ifndef ARCH -#define ARCH - -#ifdef PARALLEL_ARCH -#include "sndrcv.h" -#include "evlog.h" - -#define MT_LOAD 100 -#define MT_ACLOAD 200 -#define MT_PZLOAD 300 -#define MT_TRANAN 400 -#define MT_TRUNC 500 -#define MT_COMBINE 600 -#define MT_CONV 700 -#define MT_ASK 800 -#endif /* PARALLEL_ARCH */ - -extern int ARCHme; /* My logical process number */ -extern int ARCHsize; /* Total number of processes */ - -#endif /* ARCH */ diff --git a/src/include/ftecmath.h b/src/include/ftecmath.h deleted file mode 100644 index 1584fd704..000000000 --- a/src/include/ftecmath.h +++ /dev/null @@ -1,41 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Macros for complex mathematical functions. - */ - -/* Some defines used mainly in cmath.c. */ -#define alloc_c(len) ((complex *) tmalloc((len) * sizeof (complex))) -#define alloc_d(len) ((double *) tmalloc((len) * sizeof (double))) -#define FTEcabs(d) (((d) < 0.0) ? - (d) : (d)) -#define cph(c) (atan2(imagpart(c), (realpart(c)))) -#define cmag(c) (sqrt(imagpart(c) * imagpart(c) + realpart(c) * realpart(c))) -#define radtodeg(c) (cx_degrees ? ((c) / 3.14159265358979323846 * 180) : (c)) -#define degtorad(c) (cx_degrees ? ((c) * 3.14159265358979323846 / 180) : (c)) -#define rcheck(cond, name) if (!(cond)) { \ - fprintf(cp_err, "Error: argument out of range for %s\n", name); \ - return (NULL); } - - -#define cdiv(r1, i1, r2, i2, r3, i3) \ -{ \ - double r, s; \ - if (FTEcabs(r2) > FTEcabs(i2)) { \ - r = (i2) / (r2); \ - s = (r2) + r * (i2); \ - (r3) = ((r1) + r * (i1)) / s; \ - (i3) = ((i1) - r * (r1)) / s; \ - } else { \ - r = (r2) / (i2); \ - s = (i2) + r * (r2); \ - (r3) = (r * (r1) + (i1)) / s; \ - (i3) = (r * (i1) - (r1)) / s; \ - } \ -} - - - - diff --git a/src/include/fteconst.h b/src/include/fteconst.h deleted file mode 100644 index c36ab9e05..000000000 --- a/src/include/fteconst.h +++ /dev/null @@ -1,101 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* Vector types. */ - -#ifndef _CONSTANTS_ -#define _CONSTANTS_ - -#define SV_NOTYPE 0 -#define SV_TIME 1 -#define SV_FREQUENCY 2 -#define SV_VOLTAGE 3 -#define SV_CURRENT 4 -#define SV_OUTPUT_N_DENS 5 -#define SV_OUTPUT_NOISE 6 -#define SV_INPUT_N_DENS 7 -#define SV_INPUT_NOISE 8 -#define SV_POLE 9 -#define SV_ZERO 10 -#define SV_SPARAM 11 - -#ifdef notdef -#define SV_OUTPUT_NOISE 5 -#define SV_INPUT_NOISE 6 -#define SV_HD2 7 -#define SV_HD3 8 -#define SV_DIM2 9 -#define SV_SIM2 10 -#define SV_DIM3 11 -#define SV_POLE 12 -#define SV_ZERO 13 -#define SV_SPARAM 14 -#endif - -/* Dvec flags. */ - -#define VF_REAL (1 << 0) /* The data is real. */ -#define VF_COMPLEX (1 << 1) /* The data is complex. */ -#define VF_ACCUM (1 << 2) /* writedata should save this vector. */ -#define VF_PLOT (1 << 3) /* writedata should incrementally plot it. */ -#define VF_PRINT (1 << 4) /* writedata should print this vector. */ -#define VF_MINGIVEN (1 << 5) /* The v_minsignal value is valid. */ -#define VF_MAXGIVEN (1 << 6) /* The v_maxsignal value is valid. */ -#define VF_PERMANENT (1 << 7) /* Don't garbage collect this vector. */ - -/* Grid types. */ - -/* -#define GRID_NONE 0 -#define GRID_LIN 1 -#define GRID_LOGLOG 2 -#define GRID_XLOG 3 -#define GRID_YLOG 4 -#define GRID_POLAR 5 -#define GRID_SMITH 6 -*/ - -/* SMITHGRID is only a smith grid, SMITH transforms the data */ -typedef enum { - GRID_NONE = 0, GRID_LIN = 1, GRID_LOGLOG = 2, GRID_XLOG = 3, - GRID_YLOG = 4, GRID_POLAR = 5, GRID_SMITH = 6, GRID_SMITHGRID = 7 -} GRIDTYPE; - -/* Plot types. */ - -/* -#define PLOT_LIN 0 -#define PLOT_COMB 1 -#define PLOT_POINT 2 -*/ - -typedef enum { - PLOT_LIN = 0, PLOT_COMB = 1, PLOT_POINT = 2 -} PLOTTYPE; - -/* The types for command completion keywords. Note that these constants - * are built into cmdtab.c, so DON'T change them unless you want to - * change all of the bitmasks in cp_coms. - * Note that this is spice- and nutmeg- dependent. - */ - -#define CT_FILENAME 0 -#define CT_CKTNAMES 2 -#define CT_COMMANDS 3 -#define CT_DBNUMS 4 -#define CT_DEVNAMES 5 -#define CT_LISTINGARGS 6 -#define CT_NODENAMES 7 -#define CT_PLOT 8 -#define CT_PLOTKEYWORDS 9 -#define CT_RUSEARGS 10 -#define CT_STOPARGS 11 -#define CT_UDFUNCS 12 -#define CT_VARIABLES 13 -#define CT_VECTOR 14 -#define CT_TYPENAMES 16 - -#endif - diff --git a/src/include/ftedata.h b/src/include/ftedata.h deleted file mode 100644 index ff478cd84..000000000 --- a/src/include/ftedata.h +++ /dev/null @@ -1,72 +0,0 @@ - -/* RCS Info: $Revision$ on $Date$ - * $Source$ - * Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group - * - * Structures used for representing spice data in nutmeg. - */ - -#ifndef FTEdata_h -#define FTEdata_h - -#include "cpstd.h" /* for struct complex */ -#include "fteconst.h" - -/* A (possibly multi-dimensional) data vector. The data is represented - * internally by a 1-d array. The number of dimensions and the size - * of each dimension is recorded, along with v_length, the total size of - * the array. If the dimensionality is 0 or 1, v_length is significant - * instead of v_numdims and v_dims, and the vector is handled in the old - * manner. - */ - -#define MAXDIMS 8 - -struct dvec { - char *v_name; /* Same as so_vname. */ - int v_type; /* Same as so_vtype. */ - short v_flags; /* Flags (a combination of VF_*). */ - double *v_realdata; /* Real data. */ - complex *v_compdata; /* Complex data. */ - double v_minsignal; /* Minimum value to plot. */ - double v_maxsignal; /* Maximum value to plot. */ - GRIDTYPE v_gridtype; /* One of GRID_*. */ - PLOTTYPE v_plottype; /* One of PLOT_*. */ - int v_length; /* Length of the vector. */ - int v_rlength; /* How much space we really have. */ - int v_outindex; /* Index if writedata is building the - vector. */ - int v_linestyle; /* What line style we are using. */ - int v_color; /* What color we are using. */ - char *v_defcolor; /* The name of a color to use. */ - int v_numdims; /* How many dims -- 0 = scalar (len = 1). */ - int v_dims[MAXDIMS]; /* The actual size in each dimension. */ - struct plot *v_plot; /* The plot structure (if it has one). */ - struct dvec *v_next; /* Link for list of plot vectors. */ - struct dvec *v_link2; /* Extra link for things like print. */ - struct dvec *v_scale; /* If this has a non-standard scale... */ -} ; - -#define isreal(v) ((v)->v_flags & VF_REAL) -#define iscomplex(v) ((v)->v_flags & VF_COMPLEX) - -/* The information for a particular set of vectors that come from one - * plot. - */ - -struct plot { - char *pl_title; /* The title card. */ - char *pl_date; /* Date. */ - char *pl_name; /* The plot name. */ - char *pl_typename; /* Tran1, op2, etc. */ - struct dvec *pl_dvecs; /* The data vectors in this plot. */ - struct dvec *pl_scale; /* The "scale" for the rest of the vectors. */ - struct plot *pl_next; /* List of plots. */ - wordlist *pl_commands; /* Commands to execute for this plot. */ - struct variable *pl_env;/* The 'environment' for this plot. */ - char *pl_ccom; /* The ccom struct for this plot. */ - bool pl_written; /* Some or all of the vecs have been saved. */ - int pl_ndims; /* Number of dimensions */ -} ; - -#endif /* FTEdata_h */ diff --git a/src/include/ftegraf.h b/src/include/ftegraf.h deleted file mode 100644 index 6e5da6db1..000000000 --- a/src/include/ftegraf.h +++ /dev/null @@ -1,16 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * - * Definitions common to the various graphics modules. - */ - -#define G_NONE 0 -#define G_HCOPY 1 -#define G_TERM 2 -#define G_MFB 3 -#define G_X 4 - diff --git a/src/include/ftegraph.h b/src/include/ftegraph.h deleted file mode 100644 index f5d73e2e8..000000000 --- a/src/include/ftegraph.h +++ /dev/null @@ -1,143 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jeffrey M. Hsu -**********/ - -/* - This file contains the graph structure. -*/ - -#ifndef _GRAPH_H_ -#define _GRAPH_H_ - -#include "fteconst.h" -#include "ftedata.h" /* for struct dvec */ - -/* Device-independent data structure for plots. */ - -#define NUMCOLORS 20 - -/* list of data vectors being displayed */ -struct dveclist { - struct dvec *vector; - struct dveclist *next; -}; - -typedef struct graph { - int graphid; - struct dveclist *plotdata; /* normalized data */ - char *plotname; /* name of plot this graph is in */ - int onevalue; /* boolean variable, - true if plotting one value - against itself (real vs imaginary) */ - int degree; /* degree of polynomial interpretation */ - - int currentcolor; - int linestyle; - - struct { - int height, width; - } viewport; - int viewportxoff; /* x offset of viewport w/in graph */ - int viewportyoff; /* y offset of viewport w/in graph */ - - struct { - int xpos; /* x position of graph in screen coord */ - int ypos; /* y position of graph in screen coord */ - int width; /* width of window on screen */ - int height; /* height of window on screen */ - } absolute; - - struct { - double xmin, ymin, xmax, ymax; - } data; - - struct { - double xmin, ymin, xmax, ymax; - /* cache: width = xmax - xmin height = ymax - ymin */ - double width, height; - } datawindow; - - /* note: this int is device dependent */ - int colors[NUMCOLORS]; - - /* cache (datawindow size) / (viewport size) */ - double aspectratiox, aspectratioy; - - int ticmarks; /* mark every ticmark'th point */ - double *ticdata; - int fontwidth, fontheight; /* for use in grid */ - - PLOTTYPE plottype; /* defined in FTEconstant.h */ - struct { - GRIDTYPE gridtype; /* defined in FTEconstant.h */ - int circular; /* TRUE if circular plot area */ - union { - struct { - char units[16]; /* unit labels */ - int spacing, numspace; - double distance, lowlimit, highlimit; - int mult; - int onedec; /* a boolean */ - int hacked; /* true if hi - lo already hacked up */ - double tenpowmag; - double tenpowmagx; - int digits; - } lin; - struct { - char units[16]; /* unit labels */ - int hmt, lmt, decsp, subs, pp; - } log; - struct { - char units[16]; /* unit labels */ - int radius, center; - double mrad; - int lmt; - int hmt, mag; /* added, p.w.h. */ - } circular; /* bogus, rework when write polar grids, etc */ - } xaxis, yaxis; - int xdatatype, ydatatype; - int xsized, ysized; - double xdelta, ydelta; /* if non-zero, user-specified deltas */ - char *xlabel, *ylabel; - } grid; - - int numbuttons; /* number of buttons */ - struct { - int id; - char *message; - } *buttons; - int buttonsxoff; /* viewportxoff + x size of viewport */ - int buttonsyoff; - - struct { - int width, height; - char message[161]; /* two lines of text */ - } messagebox; - int messagexoff; - int messageyoff; - - /* characters the user typed on graph */ -/* note: think up better names */ - struct _keyed { - char *text; - int x, y; - int colorindex; /* index into colors array */ - struct _keyed *next; - } *keyed; - - /* for zoomin */ - char *commandline; - - /* Space here is allocated by NewViewport - and de-allocated by DestroyGraph. - */ - char *devdep; - -} GRAPH; - -#define NEWGRAPH (GRAPH *) calloc(1, sizeof(GRAPH)) - -#define rnd(x) (int) ((x)+0.5) - -#endif /* notdef _GRAPH_H_ */ diff --git a/src/include/ftehelp.h b/src/include/ftehelp.h deleted file mode 100644 index de368fe80..000000000 --- a/src/include/ftehelp.h +++ /dev/null @@ -1,22 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1987 Jeffrey M. Hsu -**********/ - -/* - - Defines for help. -*/ - -#define E_HASPLOTS 1 -#define E_NOPLOTS 2 -#define E_HASGRAPHS 4 -#define E_MENUMODE 8 - -#define E_BEGINNING 4096 -#define E_INTERMED 8192 -#define E_ADVANCED 16384 -#define E_ALWAYS 32768 - -/* default is intermediate level */ -#define E_DEFHMASK 8192 diff --git a/src/include/spconfig.h b/src/include/spconfig.h deleted file mode 100644 index 17ecf3dea..000000000 --- a/src/include/spconfig.h +++ /dev/null @@ -1,460 +0,0 @@ -/* - * CONFIGURATION MACRO DEFINITIONS for sparse matrix routines - * - * Author: Advising professor: - * Kenneth S. Kundert Alberto Sangiovanni-Vincentelli - * U.C. Berkeley - * - * This file contains macros for the sparse matrix routines that are used - * to define the personality of the routines. The user is expected to - * modify this file to maximize the performance of the routines with - * his/her matrices. - * - * Macros are distinguished by using solely capital letters in their - * identifiers. This contrasts with C defined identifiers which are - * strictly lower case, and program variable and procedure names which use - * both upper and lower case. - */ - - -/* - * Revision and copyright information. - * - * Copyright (c) 1985,86,87,88,89,90 - * by Kenneth S. Kundert and the University of California. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the copyright notices appear in all copies and - * supporting documentation and that the authors and the University of - * California are properly credited. The authors and the University of - * California make no representations as to the suitability of this - * software for any purpose. It is provided `as is', without express - * or implied warranty. - * - * $Date$ - * $Revision$ - */ - - -#ifndef spCONFIG_DEFS -#define spCONFIG_DEFS - - - - -#ifdef spINSIDE_SPARSE -/* - * OPTIONS - * - * These are compiler options. Set each option to one to compile that - * section of the code. If a feature is not desired, set the macro - * to NO. Recommendations are given in brackets, [ignore them]. - * - * >>> Option descriptions: - * Arithmetic Precision - * The precision of the arithmetic used by Sparse can be set by - * changing changing the spREAL macro. This macro is - * contained in the file spMatrix.h. It is strongly suggested to - * used double precision with circuit simulators. Note that - * because C always performs arithmetic operations in double - * precision, the only benefit to using single precision is that - * less storage is required. There is often a noticeable speed - * penalty when using single precision. Sparse internally refers - * to a spREAL as a RealNumber. - * REAL - * This specifies that the routines are expected to handle real - * systems of equations. The routines can be compiled to handle - * both real and complex systems at the same time, but there is a - * slight speed and memory advantage if the routines are complied - * to handle only real systems of equations. - * spCOMPLEX - * This specifies that the routines will be complied to handle - * complex systems of equations. - * EXPANDABLE - * Setting this compiler flag true (1) makes the matrix - * expandable before it has been factored. If the matrix is - * expandable, then if an element is added that would be - * considered out of bounds in the current matrix, the size of - * the matrix is increased to hold that element. As a result, - * the size of the matrix need not be known before the matrix is - * built. The matrix can be allocated with size zero and - * expanded. - * TRANSLATE - * This option allows the set of external row and column numbers - * to be non-packed. In other words, the row and column numbers - * do not have to be contiguous. The priced paid for this - * flexibility is that when TRANSLATE is set true, the time - * required to initially build the matrix will be greater because - * the external row and column number must be translated into - * internal equivalents. This translation brings about other - * benefits though. First, the spGetElement() and - * spGetAdmittance() routines may be used after the matrix has - * been factored. Further, elements, and even rows and columns, - * may be added to the matrix, and row and columns may be deleted - * from the matrix, after it has been factored. Note that when - * the set of row and column number is not a packed set, neither - * are the RHS and Solution vectors. Thus the size of these - * vectors must be at least as large as the external size, which - * is the value of the largest given row or column numbers. - * INITIALIZE - * Causes the spInitialize(), spGetInitInfo(), and - * spInstallInitInfo() routines to be compiled. These routines - * allow the user to store and read one pointer in each nonzero - * element in the matrix. spInitialize() then calls a user - * specified function for each structural nonzero in the matrix, - * and includes this pointer as well as the external row and - * column numbers as arguments. This allows the user to write - * custom matrix initialization routines. - * DIAGONAL_PIVOTING - * Many matrices, and in particular node- and modified-node - * admittance matrices, tend to be nearly symmetric and nearly - * diagonally dominant. For these matrices, it is a good idea to - * select pivots from the diagonal. With this option enabled, - * this is exactly what happens, though if no satisfactory pivot - * can be found on the diagonal, an off-diagonal pivot will be - * used. If this option is disabled, Sparse does not - * preferentially search the diagonal. Because of this, Sparse - * has a wider variety of pivot candidates available, and so - * presumably fewer fill-ins will be created. However, the - * initial pivot selection process will take considerably longer. - * If working with node admittance matrices, or other matrices - * with a strong diagonal, it is probably best to use - * DIAGONAL_PIVOTING for two reasons. First, accuracy will be - * better because pivots will be chosen from the large diagonal - * elements, thus reducing the chance of growth. Second, a near - * optimal ordering will be chosen quickly. If the class of - * matrices you are working with does not have a strong diagonal, - * do not use DIAGONAL_PIVOTING, but consider using a larger - * threshold. When DIAGONAL_PIVOTING is turned off, the following - * options and constants are not used: MODIFIED_MARKOWITZ, - * MAX_MARKOWITZ_TIES, and TIES_MULTIPLIER. - * ARRAY_OFFSET - * This determines whether arrays start at an index of zero or one. - * This option is necessitated by the fact that standard C - * convention dictates that arrays begin with an index of zero but - * the standard mathematic convention states that arrays begin with - * an index of one. So if you prefer to start your arrays with - * zero, or your calling Sparse from FORTRAN, set ARRAY_OFFSET to - * NO or 0. Otherwise, set ARRAY_OFFSET to YES or 1. Note that if - * you use an offset of one, the arrays that you pass to Sparse - * must have an allocated length of one plus the size of the - * matrix. ARRAY_OFFSET must be either 0 or 1, no other offsets - * are valid. - * spSEPARATED_COMPLEX_VECTORS - * This specifies the format for complex vectors. If this is set - * false then a complex vector is made up of one double sized - * array of RealNumber's in which the real and imaginary numbers - * are placed in the alternately array in the array. In other - * words, the first entry would be Complex[1].Real, then comes - * Complex[1].Imag, then Complex[1].Real, etc. If - * spSEPARATED_COMPLEX_VECTORS is set true, then each complex - * vector is represented by two arrays of RealNumbers, one with - * the real terms, the other with the imaginary. [NO] - * MODIFIED_MARKOWITZ - * This specifies that the modified Markowitz method of pivot - * selection is to be used. The modified Markowitz method differs - * from standard Markowitz in two ways. First, under modified - * Markowitz, the search for a pivot can be terminated early if a - * adequate (in terms of sparsity) pivot candidate is found. - * Thus, when using modified Markowitz, the initial factorization - * can be faster, but at the expense of a suboptimal pivoting - * order that may slow subsequent factorizations. The second - * difference is in the way modified Markowitz breaks Markowitz - * ties. When two or more elements are pivot candidates and they - * all have the same Markowitz product, then the tie is broken by - * choosing the element that is best numerically. The numerically - * best element is the one with the largest ratio of its magnitude - * to the magnitude of the largest element in the same column, - * excluding itself. The modified Markowitz method results in - * marginally better accuracy. This option is most appropriate - * for use when working with very large matrices where the initial - * factor time represents an unacceptable burden. [NO] - * DELETE - * This specifies that the spDeleteRowAndCol() routine - * should be compiled. Note that for this routine to be - * compiled, both DELETE and TRANSLATE should be set true. - * STRIP - * This specifies that the spStripFills() routine should be compiled. - * MODIFIED_NODAL - * This specifies that the routine that preorders modified node - * admittance matrices should be compiled. This routine results - * in greater speed and accuracy if used with this type of - * matrix. - * QUAD_ELEMENT - * This specifies that the routines that allow four related - * elements to be entered into the matrix at once should be - * compiled. These elements are usually related to an - * admittance. The routines affected by QUAD_ELEMENT are the - * spGetAdmittance, spGetQuad and spGetOnes routines. - * TRANSPOSE - * This specifies that the routines that solve the matrix as if - * it was transposed should be compiled. These routines are - * useful when performing sensitivity analysis using the adjoint - * method. - * SCALING - * This specifies that the routine that performs scaling on the - * matrix should be complied. Scaling is not strongly - * supported. The routine to scale the matrix is provided, but - * no routines are provided to scale and descale the RHS and - * Solution vectors. It is suggested that if scaling is desired, - * it only be preformed when the pivot order is being chosen [in - * spOrderAndFactor()]. This is the only time scaling has - * an effect. The scaling may then either be removed from the - * solution by the user or the scaled factors may simply be - * thrown away. [NO] - * DOCUMENTATION - * This specifies that routines that are used to document the - * matrix, such as spPrint() and spFileMatrix(), should be - * compiled. - * DETERMINANT - * This specifies that the routine spDeterminant() should be complied. - * STABILITY - * This specifies that spLargestElement() and spRoundoff() should - * be compiled. These routines are used to check the stability (and - * hence the quality of the pivoting) of the factorization by - * computing a bound on the size of the element is the matrix E = - * A - LU. If this bound is very high after applying - * spOrderAndFactor(), then the pivot threshold should be raised. - * If the bound increases greatly after using spFactor(), then the - * matrix should probably be reordered. - * CONDITION - * This specifies that spCondition() and spNorm(), the code that - * computes a good estimate of the condition number of the matrix, - * should be compiled. - * PSEUDOCONDITION - * This specifies that spPseudoCondition(), the code that computes - * a crude and easily fooled indicator of ill-conditioning in the - * matrix, should be compiled. - * MULTIPLICATION - * This specifies that the routines to multiply the unfactored - * matrix by a vector should be compiled. - * FORTRAN - * This specifies that the FORTRAN interface routines should be - * compiled. When interfacing to FORTRAN programs, the ARRAY_OFFSET - * options should be set to NO. - * DEBUG - * This specifies that additional error checking will be compiled. - * The type of error checked are those that are common when the - * matrix routines are first integrated into a user's program. Once - * the routines have been integrated in and are running smoothly, this - * option should be turned off. - * spCOMPATIBILITY - * This specifies that Sparse1.3 should be configured to be upward - * compatible from Sparse1.2. This option is not suggested for use - * in new software. Sparse1.3, when configured to be compatible with - * Sparse1.2, is not completely compatible. In particular, if - * recompiling the calling program, it is necessary to change the - * of the Sparse include files. This option will go away in future - * versions of Sparse. [0] - */ - -/* Begin options. */ -#define REAL YES -#define EXPANDABLE YES -#define TRANSLATE YES -#define INITIALIZE NO -#define DIAGONAL_PIVOTING YES -#define ARRAY_OFFSET YES -#define MODIFIED_MARKOWITZ NO -#define DELETE NO -#define STRIP NO -#define MODIFIED_NODAL YES -#define QUAD_ELEMENT NO -#define TRANSPOSE YES -#define SCALING NO -#define DOCUMENTATION YES -#define MULTIPLICATION YES -#define DETERMINANT YES -#define DETERMINANT2 YES -#define STABILITY NO -#define CONDITION NO -#define PSEUDOCONDITION NO -#define FORTRAN NO -#ifdef HAS_MINDATA -# define DEBUG NO -#else -# define DEBUG YES -#endif - -/* - * The following options affect Sparse exports and so are exported as a - * side effect. For this reason they use the `sp' prefix. The boolean - * constants YES an NO are not defined in spMatrix.h to avoid conflicts - * with user code, so use 0 for NO and 1 for YES. - */ -#endif /* spINSIDE_SPARSE */ -#define spCOMPLEX 1 -#define spSEPARATED_COMPLEX_VECTORS 1 -#define spCOMPATIBILITY 0 -#ifdef spINSIDE_SPARSE - - - - - - - -/* - * MATRIX CONSTANTS - * - * These constants are used throughout the sparse matrix routines. They - * should be set to suit the type of matrix being solved. Recommendations - * are given in brackets. - * - * Some terminology should be defined. The Markowitz row count is the number - * of non-zero elements in a row excluding the one being considered as pivot. - * There is one Markowitz row count for every row. The Markowitz column - * is defined similarly for columns. The Markowitz product for an element - * is the product of its row and column counts. It is a measure of how much - * work would be required on the next step of the factorization if that - * element were chosen to be pivot. A small Markowitz product is desirable. - * - * >>> Constants descriptions: - * DEFAULT_THRESHOLD - * The relative threshold used if the user enters an invalid - * threshold. Also the threshold used by spFactor() when - * calling spOrderAndFactor(). The default threshold should - * not be less than or equal to zero nor larger than one. [0.001] - * DIAG_PIVOTING_AS_DEFAULT - * This indicates whether spOrderAndFactor() should use diagonal - * pivoting as default. This issue only arises when - * spOrderAndFactor() is called from spFactor(). - * SPACE_FOR_ELEMENTS - * This number multiplied by the size of the matrix equals the number - * of elements for which memory is initially allocated in - * spCreate(). [6] - * SPACE_FOR_FILL_INS - * This number multiplied by the size of the matrix equals the number - * of elements for which memory is initially allocated and specifically - * reserved for fill-ins in spCreate(). [4] - * ELEMENTS_PER_ALLOCATION - * The number of matrix elements requested from the malloc utility on - * each call to it. Setting this value greater than 1 reduces the - * amount of overhead spent in this system call. On a virtual memory - * machine, its good to allocate slightly less than a page worth of - * elements at a time (or some multiple thereof). - * [For the VAX, for real only use 41, otherwise use 31] - * MINIMUM_ALLOCATED_SIZE - * The minimum allocated size of a matrix. Note that this does not - * limit the minimum size of a matrix. This just prevents having to - * resize a matrix many times if the matrix is expandable, large and - * allocated with an estimated size of zero. This number should not - * be less than one. - * EXPANSION_FACTOR - * The amount the allocated size of the matrix is increased when it - * is expanded. - * MAX_MARKOWITZ_TIES - * This number is used for two slightly different things, both of which - * relate to the search for the best pivot. First, it is the maximum - * number of elements that are Markowitz tied that will be sifted - * through when trying to find the one that is numerically the best. - * Second, it creates an upper bound on how large a Markowitz product - * can be before it eliminates the possibility of early termination - * of the pivot search. In other words, if the product of the smallest - * Markowitz product yet found and TIES_MULTIPLIER is greater than - * MAX_MARKOWITZ_TIES, then no early termination takes place. - * Set MAX_MARKOWITZ_TIES to some small value if no early termination of - * the pivot search is desired. An array of RealNumbers is allocated - * of size MAX_MARKOWITZ_TIES so it must be positive and shouldn't - * be too large. Active when MODIFIED_MARKOWITZ is 1 (true). [100] - * TIES_MULTIPLIER - * Specifies the number of Markowitz ties that are allowed to occur - * before the search for the pivot is terminated early. Set to some - * large value if no early termination of the pivot search is desired. - * This number is multiplied times the Markowitz product to determine - * how many ties are required for early termination. This means that - * more elements will be searched before early termination if a large - * number of fill-ins could be created by accepting what is currently - * considered the best choice for the pivot. Active when - * MODIFIED_MARKOWITZ is 1 (true). Setting this number to zero - * effectively eliminates all pivoting, which should be avoided. - * This number must be positive. TIES_MULTIPLIER is also used when - * diagonal pivoting breaks down. [5] - * DEFAULT_PARTITION - * Which partition mode is used by spPartition() as default. - * Possibilities include - * spDIRECT_PARTITION -- each row used direct addressing, best for - * a few relatively dense matrices. - * spINDIRECT_PARTITION -- each row used indirect addressing, best - * for a few very sparse matrices. - * spAUTO_PARTITION -- direct or indirect addressing is chosen on - * a row-by-row basis, carries a large overhead, but speeds up - * both dense and sparse matrices, best if there is a large - * number of matrices that can use the same ordering. - */ - -/* Begin constants. */ -#define DEFAULT_THRESHOLD 1.0e-3 -#define DIAG_PIVOTING_AS_DEFAULT YES -#define SPACE_FOR_ELEMENTS 6 -#define SPACE_FOR_FILL_INS 4 -#define ELEMENTS_PER_ALLOCATION 31 -#define MINIMUM_ALLOCATED_SIZE 6 -#define EXPANSION_FACTOR 1.5 -#define MAX_MARKOWITZ_TIES 100 -#define TIES_MULTIPLIER 5 -#define DEFAULT_PARTITION spAUTO_PARTITION - - - - - - -/* - * PRINTER WIDTH - * - * This macro characterize the printer for the spPrint() routine. - * - * >>> Macros: - * PRINTER_WIDTH - * The number of characters per page width. Set to 80 for terminal, - * 132 for line printer. - */ - -/* Begin printer constants. */ -#define PRINTER_WIDTH 80 - - - - - - -/* - * MACHINE CONSTANTS - * - * These numbers must be updated when the program is ported to a new machine. - */ - -/* Begin machine constants. */ - -/* - * Grab from Spice include files - */ - -#include "ngspice.h" -#define MACHINE_RESOLUTION DBL_EPSILON -#define LARGEST_REAL DBL_MAX -#define SMALLEST_REAL DBL_MIN -#define LARGEST_SHORT_INTEGER SHRT_MAX -#define LARGEST_LONG_INTEGER LONG_MAX - - -/* - * ANNOTATION - * - * This macro changes the amount of annotation produced by the matrix - * routines. The annotation is used as a debugging aid. Change the number - * associated with ANNOTATE to change the amount of annotation produced by - * the program. - */ - -/* Begin annotation definitions. */ -#define ANNOTATE NONE - -#define NONE 0 -#define ON_STRANGE_BEHAVIOR 1 -#define FULL 2 - -#endif /* spINSIDE_SPARSE */ -#endif /* spCONFIG_DEFS */ diff --git a/src/include/struct.h b/src/include/struct.h deleted file mode 100644 index 0e967765d..000000000 --- a/src/include/struct.h +++ /dev/null @@ -1,199 +0,0 @@ -/************* - * Structure definitions header file - * 1999 E. Rouat - ************/ - -/* - * This file will contain all extern structure definitions needed - * by ngspice code. (in construction) - */ - -#ifndef _STRUCT_H_ -#define _STRUCT_H_ - - -/* cpstd.h */ - -/* Doubly linked lists of words. */ - -struct wordlist { - char *wl_word; - struct wordlist *wl_next; - struct wordlist *wl_prev; -} ; - -typedef struct wordlist wordlist; - -/* Complex numbers. */ - -struct _complex { /* IBM portability... */ - double cx_real; - double cx_imag; -} ; - -typedef struct _complex complex; - - -/* - * The display device structure (ftedev.h) - */ - -typedef struct { - char *name; - int minx, miny; - int width, height; /* in screen coordinate system */ - int numlinestyles, numcolors; /* number supported */ - int (*Init)(); - int (*NewViewport)(); - int (*Close)(); - int (*Clear)(); - int (*DrawLine)(); - int (*Arc)(); - int (*Text)(); - int (*DefineColor)(); - int (*DefineLinestyle)(); - int (*SetLinestyle)(); - int (*SetColor)(); - int (*Update)(); -/* int (*NDCtoScreen)(); */ - int (*Track)(); - int (*MakeMenu)(); - int (*MakeDialog)(); - int (*Input)(); - int (*DatatoScreen)(); -} DISPDEVICE; - -extern DISPDEVICE *dispdev; - - - -/* ckt */ - - -typedef struct sCKTnode { - IFuid name; - int type; - int number; /* Number of the node */ - double ic; /* Value of the initial condition */ - double nodeset; /* Value of the .nodeset option */ - double *ptr; /* ??? */ - struct sCKTnode *next; /* pointer to the next node */ - unsigned int icGiven:1; /* FLAG ic given */ - unsigned int nsGiven:1; /* FLAG nodeset given */ -} CKTnode; - - -/* the following structure is REALLY MESSY!! */ - - -typedef struct { - GENmodel *CKThead[MAXNUMDEVS]; /* The max number of loadable devices */ - STATistics *CKTstat; /* The STATistics structure */ - double *(CKTstates[8]); /* Used as memory of past steps ??? */ - double CKTtime; /* ??? */ - double CKTdelta; /* ??? */ - double CKTdeltaOld[7]; /* Memory for ??? */ - double CKTtemp; /* Actual temperature of CKT */ - double CKTnomTemp; /* Reference temperature 27 C ? */ - double CKTvt; /* Thernmal voltage at CKTtemp */ - double CKTag[7]; /* the gear variable coefficient matrix */ -#ifdef PREDICTOR - double CKTagp[7]; /* the gear predictor variable coefficient matrix */ -#endif /*PREDICTOR*/ - int CKTorder; /* the integration method order */ - int CKTmaxOrder; /* maximum integration method order */ - int CKTintegrateMethod; /* the integration method to be used */ - SMPmatrix *CKTmatrix; /* pointer to sparse matrix */ - int CKTniState; /* internal state */ - double *CKTrhs; /* current rhs value - being loaded */ - double *CKTrhsOld; /* previous rhs value for convergence testing */ - double *CKTrhsSpare; /* spare rhs value for reordering */ - double *CKTirhs; /* current rhs value - being loaded (imag) */ - double *CKTirhsOld; /* previous rhs value (imaginary)*/ - double *CKTirhsSpare; /* spare rhs value (imaginary)*/ -#ifdef PREDICTOR - double *CKTpred; /* predicted solution vector */ - double *CKTsols[8]; /* previous 8 solutions */ -#endif /* PREDICTOR */ - double *CKTrhsOp; /* opearating point values */ - double *CKTsenRhs; /* current sensitivity rhs values */ - double *CKTseniRhs; /* current sensitivity rhs values (imag)*/ - int CKTmaxEqNum; /* And this ? */ - int CKTcurrentAnalysis; /* the analysis in progress (if any) */ - -/* defines for the value of CKTcurrentAnalysis */ -/* are in TSKdefs.h */ - - CKTnode *CKTnodes; /* ??? */ - CKTnode *CKTlastNode; /* ??? */ - int CKTnumStates; /* Number of sates effectively valid ??? */ - long CKTmode; /* Mode of operation of the circuit ??? */ - int CKTbypass; /* bypass option, how does it work ? */ - int CKTdcMaxIter; /* iteration limit for dc op. (itl1) */ - int CKTdcTrcvMaxIter; /* iteration limit for dc tran. curv (itl2) */ - int CKTtranMaxIter; /* iteration limit for each timepoint for tran*/ - /* (itl4) */ - int CKTbreakSize; /* ??? */ - int CKTbreak; /* ??? */ - double CKTsaveDelta; /* ??? */ - double CKTminBreak; /* ??? */ - double *CKTbreaks; /* List of breakpoints ??? */ - double CKTabstol; /* --- */ - double CKTpivotAbsTol; /* --- */ - double CKTpivotRelTol; /* --- */ - double CKTreltol; /* --- */ - double CKTchgtol; /* --- */ - double CKTvoltTol; /* --- */ - /* What is this define for ? */ -#ifdef NEWTRUNC - double CKTlteReltol; - double CKTlteAbstol; -#endif /* NEWTRUNC */ - double CKTgmin; /* Parallel Conductance --- */ - double CKTdelmin; /* ??? */ - double CKTtrtol; /* ??? */ - double CKTfinalTime; /* ??? */ - double CKTstep; /* ??? */ - double CKTmaxStep; /* ??? */ - double CKTinitTime; /* ??? */ - double CKTomega; /* ??? */ - double CKTsrcFact; /* ??? */ - double CKTdiagGmin; /* ??? */ - int CKTnumSrcSteps; /* ??? */ - int CKTnumGminSteps; /* ??? */ - int CKTnoncon; /* ??? */ - double CKTdefaultMosL; /* Default Channel Lenght of MOS devices */ - double CKTdefaultMosW; /* Default Channel Width of MOS devics */ - double CKTdefaultMosAD; /* Default Drain Area of MOS */ - double CKTdefaultMosAS; /* Default Source Area of MOS */ - unsigned int CKThadNodeset:1; /* ??? */ - unsigned int CKTfixLimit:1; /* flag to indicate that the limiting of - * MOSFETs should be done as in SPICE2 */ - unsigned int CKTnoOpIter:1; /* flag to indicate not to try the operating - * point brute force, but to use gmin stepping - * first */ - unsigned int CKTisSetup:1; /* flag to indicate if CKTsetup done */ - JOB *CKTcurJob; /* Next analysis to be performed ??? */ - - SENstruct *CKTsenInfo; /* the sensitivity information */ - double *CKTtimePoints; /* list of all accepted timepoints in the - current transient simulation */ - double *CKTdeltaList; /* list of all timesteps in the current - transient simulation */ - int CKTtimeListSize; /* size of above lists */ - int CKTtimeIndex; /* current position in above lists */ - int CKTsizeIncr; /* amount to increment size of above arrays - when you run out of space */ - unsigned int CKTtryToCompact:1; /* try to compact past history for LTRA - lines */ - unsigned int CKTbadMos3:1; /* Use old, unfixed MOS3 equations */ - unsigned int CKTkeepOpInfo:1; /* flag for small signal analyses */ - int CKTtroubleNode; /* Non-convergent node number */ - GENinstance *CKTtroubleElt; /* Non-convergent device instance */ - -} CKTcircuit; - - - - -#endif /* _STRUCT_H_ */ diff --git a/src/misc/string.h b/src/misc/string.h deleted file mode 100644 index c03391abf..000000000 --- a/src/misc/string.h +++ /dev/null @@ -1,33 +0,0 @@ -/************* - * Header file for string.c - * 1999 E. Rouat - ************/ - -#ifndef STRING_H_INCLUDED -#define STRING_H_INCLUDED - -int prefix(register char *p, register char *s); -char * copy(char *str); -int substring(register char *sub, register char *str); -void appendc(char *s, char c); -int scannum(char *str); -int cieq(register char *p, register char *s); -int ciprefix(register char *p, register char *s); -void strtolower(char *str); -char * gettok(char **s); - -#ifndef HAVE_INDEX - -char * index(register char *s, register char c); -char * rindex(register char *s,register char c ); - -#endif /* HAVE_INDEX */ - -#ifndef HAVE_BCOPY - -void bcopy(register char *from, register char *to, register int num); -int bzero(register char *ptr, register int num); - -#endif /* HAVE_BCOPY */ - -#endif diff --git a/src/multidec.c b/src/multidec.c deleted file mode 100644 index 6ec9e60a1..000000000 --- a/src/multidec.c +++ /dev/null @@ -1,427 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1990 Jaijeet Roychowdury -**********/ - -#include "ngspice.h" -#include -#include -#include "spmatrix.h" - -#define THRSH 0.01 -#define ABS_THRSH 0 -#define DIAG_PIVOTING 1 - -#undef DEBUG_LEVEL1 - - -extern void usage(); -extern void comments(); -extern double phi(); - -int - main (argc, argv) - int argc; - char **argv; -{ - int ch; - int errflg=0,i,j; - double l,c,ctot,r=0.0,g=0.0,k=0.0,lm=0.0,cm=0.0,len; - unsigned gotl=0,gotc=0,gotr=0,gotg=0,gotk=0,gotcm=0,gotlen=0; - unsigned gotname=0, gotnum=0; - char *name; - double **matrix, **inverse; - double *tpeigenvalues, *gammaj; - char *options; - int num, node; - char **pname, *s; - int use_opt; - char *optarg; - - pname = argv; - argv++; - argc--; - - ch = 0; - while (argc > 0) { - s = *argv++; - argc--; - while ((ch = *s++)) { - if (*s) - optarg = s; - else if (argc) - optarg = *argv; - else - optarg = NULL; - use_opt = 0; - - switch (ch) { - case 'o': - name = (char *) malloc((unsigned) (strlen(optarg)*sizeof(char))); - (void) strcpy(name,optarg); - gotname=1; - use_opt = 1; - break; - case 'l': - sscanf(optarg,"%lf",&l); - gotl=1; - use_opt = 1; - break; - case 'c': - sscanf(optarg,"%lf",&c); - gotc=1; - use_opt = 1; - break; - case 'r': - sscanf(optarg,"%lf",&r); - use_opt = 1; - gotr=1; - break; - case 'g': - sscanf(optarg,"%lf",&g); - use_opt = 1; - gotg=1; - break; - case 'k': - sscanf(optarg,"%lf",&k); - use_opt = 1; - gotk=1; - break; - case 'x': - sscanf(optarg,"%lf",&cm); - use_opt = 1; - gotcm=1; - break; - case 'L': - sscanf(optarg,"%lf",&len); - use_opt = 1; - gotlen=1; - break; - case 'n': - sscanf(optarg,"%d",&num); - use_opt = 1; - gotnum=1; - break; - case 'u': - usage(pname); - exit(1); - break; - case '-': - break; - default: - usage(pname); - exit(2); - break; - } - if (use_opt) { - if (optarg == s) - s += strlen(s); - else if (optarg) { - argc--; - argv++; - } - } - } - } - - if (errflg) { - usage(argv); - exit (2); - } - - if (gotl + gotc + gotname + gotnum + gotlen < 5) { - fprintf(stderr,"l, c, model_name, number_of_conductors and length must be specified.\n"); - fprintf(stderr,"%s -u for details.\n",pname[0]); - fflush(stdout); - exit(1); - } - - if ( (k<0.0?-k:k) >=1.0 ) { - fprintf(stderr,"Error: |k| must be less than 1.0\n"); - fflush(stderr); - exit(1); - } - - if (num == 1) { - fprintf(stdout,"* single conductor line\n"); - fflush(stdout); - exit(1); - } - - lm = l*k; - switch(num) { - - case 1: ctot = c; break; - case 2: ctot = c + cm; break; - default: ctot = c + 2*cm; break; - } - - comments(r,l,g,c,ctot,cm,lm,k,name,num,len); - - matrix = (double **) malloc((unsigned) (sizeof(double*)*(num+1))); - inverse = (double **) malloc((unsigned) (sizeof(double*)*(num+1))); - tpeigenvalues = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - - for (i=1;i<=num;i++) { - matrix[i] = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - inverse[i] = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - } - - for (i=1;i<=num;i++) { - tpeigenvalues[i] = -2.0 * cos(M_PI*i/(num+1)); - } - - for (i=1;i<=num;i++) { - for (j=1;j<=num;j++) { - matrix[i][j] = phi(i-1,tpeigenvalues[j]); - } - } - gammaj = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - - for (j=1;j<=num;j++) { - gammaj[j] = 0.0; - for (i=1;i<=num;i++) { - gammaj[j] += matrix[i][j] * matrix[i][j]; - } - gammaj[j] = sqrt(gammaj[j]); - } - - for (j=1;j<=num;j++) { - for (i=1;i<=num; i++) { - matrix[i][j] /= gammaj[j]; - } - } - - free(gammaj); - - /* matrix = M set up */ - - { - char *othermatrix; - double *rhs, *solution; - double *irhs, *isolution; - int errflg, err, singular_row, singular_col; - double *elptr; - - rhs = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - irhs = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - solution = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - isolution = (double *) malloc((unsigned) (sizeof(double)*(num+1))); - - othermatrix = spCreate(num,0,&errflg); - - for (i=1;i<=num;i++) { - for (j=1; j<=num; j++) { - elptr = spGetElement(othermatrix,i,j); - *elptr = matrix[i][j]; - } - } - -#ifdef DEBUG_LEVEL1 - (void) spPrint(othermatrix,0,1,0); -#endif - - for (i=1;i<=num;i++) rhs[i] = 0.0; - rhs[1]=1.0; - - err = - spOrderAndFactor(othermatrix,rhs,THRSH,ABS_THRSH,DIAG_PIVOTING); - - spErrorMessage(othermatrix,stderr,NULL); - - switch(err) { - - case spNO_MEMORY: - fprintf(stderr,"No memory in spOrderAndFactor\n"); - fflush(stderr); - exit(1); - case spSINGULAR: - (void) - spWhereSingular(othermatrix,&singular_row,&singular_col); - fprintf(stderr,"Singular matrix: problem in row %d and col %d\n", singular_row, singular_col); - fflush(stderr); - exit(1); -#ifdef notdef - /* For the original "sparse" interface; doesn't work with the spice3 interface - to sparse */ - case spSMALL_PIVOT: - fprintf(stderr,"* Warning: matrix is illconditioned.\n"); - fflush(stderr); - break; -#endif - default: break; - } - - for (i=1;i<=num;i++) { - for (j=1;j<=num;j++) { - rhs[j] = (j==i?1.0:0.0); - irhs[j] = 0.0; - } - (void) spSolveTransposed(othermatrix,rhs,solution, irhs, isolution); - for (j=1;j<=num;j++) { - inverse[i][j] = solution[j]; - } - } - - free(rhs); free(solution); - } - - /* inverse = M^{-1} set up */ - - fprintf(stdout,"\n"); - fprintf(stdout,"* Lossy line models\n"); - - options = (char *) malloc((unsigned) 256); - (void) strcpy(options,"rel=1.2 nocontrol"); - for (i=1;i<=num;i++) { - fprintf(stdout,".model mod%d_%s ltra %s r=%0.12g l=%0.12g g=%0.12g c=%0.12g len=%0.12g\n", - i,name,options,r,l+tpeigenvalues[i]*lm,g,ctot-tpeigenvalues[i]*cm,len); - /*i,name,options,r,l+tpeigenvalues[i]*lm,g,ctot+tpeigenvalues[i]*cm,len);*/ - } - - - fprintf(stdout,"\n"); - fprintf(stdout,"* subcircuit m_%s - modal transformation network for %s\n",name,name); - fprintf(stdout,".subckt m_%s", name); - for (i=1;i<= 2*num; i++) { - fprintf(stdout," %d",i); - } - fprintf(stdout,"\n"); - for (j=1;j<=num;j++) fprintf(stdout,"v%d %d 0 0v\n",j,j+2*num); - - for (j=1;j<=num;j++) { - for (i=1; i<=num; i++) { - fprintf(stdout,"f%d 0 %d v%d %0.12g\n", - (j-1)*num+i,num+j,i,inverse[j][i]); - } - } - - node = 3*num+1; - for (j=1;j<=num;j++) { - fprintf(stdout,"e%d %d %d %d 0 %0.12g\n", (j-1)*num+1, - node, 2*num+j, num+1, matrix[j][1]); - node++; - for (i=2; i -c\n",argv[0]); -fprintf(stderr," -r -g \n"); -fprintf(stderr," -k \n"); -fprintf(stderr," -x -o \n"); -fprintf(stderr," -n -L -u\n"); -fprintf(stderr,"Example: %s -n4 -l9e-9 -c20e-12 -r5.3 -x5e-12 -k0.7 -otest -L5.4\n\n",argv[0]); - -fprintf(stderr,"See \"Efficient Transient Simulation of Lossy Interconnect\",\n"); -fprintf(stderr,"J.S. Roychowdhury and D.O. Pederson, Proc. DAC 91 for details\n"); -fprintf(stderr,"\n"); -fflush(stderr); -} - -void -comments(r,l,g,c,ctot,cm,lm,k,name,num,len) -double r,l,g,c,ctot,cm,lm,k,len; -char *name; -int num; -{ - -fprintf(stdout,"* Subcircuit %s\n",name); -fprintf(stdout,"* %s is a subcircuit that models a %d-conductor transmission line with\n",name,num); -fprintf(stdout,"* the following parameters: l=%g, c=%g, r=%g, g=%g,\n",l,c,r,g); -fprintf(stdout,"* inductive_coeff_of_coupling k=%g, inter-line capacitance cm=%g,\n",k,cm); -fprintf(stdout,"* length=%g. Derived parameters are: lm=%g, ctot=%g.\n",len,lm,ctot); -fprintf(stdout,"* \n"); -fprintf(stdout,"* It is important to note that the model is a simplified one - the\n"); -fprintf(stdout,"* following assumptions are made: 1. The self-inductance l, the\n"); -fprintf(stdout,"* self-capacitance ctot (note: not c), the series resistance r and the\n"); -fprintf(stdout,"* parallel capacitance g are the same for all lines, and 2. Each line\n"); -fprintf(stdout,"* is coupled only to the two lines adjacent to it, with the same\n"); -fprintf(stdout,"* coupling parameters cm and lm. The first assumption implies that edge\n"); -fprintf(stdout,"* effects have to be neglected. The utility of these assumptions is\n"); -fprintf(stdout,"* that they make the sL+R and sC+G matrices symmetric, tridiagonal and\n"); -fprintf(stdout,"* Toeplitz, with useful consequences (see \"Efficient Transient\n"); -fprintf(stdout,"* Simulation of Lossy Interconnect\", by J.S. Roychowdhury and\n"); -fprintf(stdout,"* D.O Pederson, Proc. DAC 91).\n\n"); -fprintf(stdout,"* It may be noted that a symmetric two-conductor line is\n"); -fprintf(stdout,"* represented accurately by this model.\n\n"); -fprintf(stdout,"* Subckt node convention:\n"); -fprintf(stdout,"* \n"); -fprintf(stdout,"* |--------------------------|\n"); -fprintf(stdout,"* 1-----| |-----n+1\n"); -fprintf(stdout,"* 2-----| |-----n+2\n"); -fprintf(stdout,"* : | n-wire multiconductor | :\n"); -fprintf(stdout,"* : | line | :\n"); -fprintf(stdout,"* n-1-----|(node 0=common gnd plane) |-----2n-1\n"); -fprintf(stdout,"* n-----| |-----2n\n"); -fprintf(stdout,"* |--------------------------|\n\n"); -fflush(stdout); -} - -double -phi(i,arg) - int i; - double arg; -{ - double rval; - - switch (i) { - - case 0: - rval = 1.0; - break; - case 1: - rval = arg; - break; - default: - rval = arg*phi(i-1,arg) - phi(i-2,arg); - } - return rval; -} diff --git a/src/nutmeg.c b/src/nutmeg.c deleted file mode 100644 index 51b90b6df..000000000 --- a/src/nutmeg.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Configuration file for nutmeg */ -#include - -#include "conf.h" - - -/* - * Devices - */ - -#define DEVICES_USED "" -#define ANALYSES_USED "" - -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ - -#include "ngspice.h" - -#define CONFIG -#include -#include "ifsim.h" -#include "suffix.h" - -IFsimulator SIMinfo = { - "nutmeg", /* my name */ - "data analysis and manipulation program", /* more about me */ - Spice_Version, /* my version */ - NULL, /* newCircuit function */ - NULL, /* deleteCircuit function */ - NULL, /* newNode function */ /* NEEDED */ - NULL, /* groundNode function */ - NULL, /* bindNode function */ - NULL, /* findNode function */ /* NEEDED */ - NULL, /* instToNode function */ /* NEEDED */ - NULL, /* setNodeParm function */ /* NEEDED */ - NULL, /* askNodeQuest function */ /* NEEDED */ - NULL, /* deleteNode function */ /* NEEDED */ - NULL, /* newInstance function */ - NULL, /* setInstanceParm function */ - NULL, /* askInstanceQuest function */ - NULL, /* findInstance funciton */ - NULL, /* deleteInstance function */ /* to be added later */ - NULL, /* newModel function */ - NULL, /* setModelParm function */ - NULL, /* askModelQuest function */ - NULL, /* findModel function */ - NULL, /* deleteModel function */ /* to be added later */ - NULL, /* newTask function */ - NULL, /* newAnalysis function */ - NULL, /* setAnalysisParm function */ - NULL, /* askAnalysisQeust function */ - NULL, /* findAnalysis function */ - NULL, /* findTask function */ - NULL, /* deleteTask function */ - NULL, /* doAnalyses function */ - NULL, /* non-convergence message function */ - 0, - NULL, - 0, - NULL, - 0, - NULL, -}; diff --git a/src/parser/ChangeLog b/src/parser/ChangeLog deleted file mode 100644 index 4a58b0104..000000000 --- a/src/parser/ChangeLog +++ /dev/null @@ -1,95 +0,0 @@ -2000-03-11 Paolo Nenzi - - * numparse.c: as wrote in Chris Inbody patch: - In numparse.c line 17 changed the arg type of "num" - to double. This (so far :) seems to have had no adverse effect. - -2000-03-11 Paolo Nenzi - - * history.c: applied Chris Inbody patch. As he wrote: - I had some trouble running ng-spice in batch mode on a fairly repetitive job - (probably 10 - 20 commands repeated 256 times in a single session :), it was - giving me "mangled history" errors and then seg faulting. - [...] - In history.c line 425, added an exit(0) call to the else condition to prevent - seg fault upon generation of the history list error. On line 25, changed - cp_maxhistlength to 10000 vs 1000. The value of 10000 was enough to keep my - task from crashing but there may be a better way to do this,.. I didn't try - an arbitrarily high number because I'm not sure what effect it would have on - memory usage or progam size or speed. Maybe that's the best answer, just - bump the value to 1e6 or something that no one would ever approach. - -1999-09-07 Arno - - * lexical.c: read() requires #include of unistd.h. - - * modify.c: removed warning about char subscript for array. - - * unixcom.h: removed prototypes for static tryexec(), hash(). - - * var2.c: added default case to remove warning. - -1999-09-04 Emmanuel Rouat - - * *.c: added header files for .c files - -1999-08-28 Emmanuel Rouat - - * Removed all #includes of misc.h and util.h (now in spice.h) - -1999-08-27 Paolo Nenzi - - * Removed #include "suffix.h", replaced GENERIC with void and - ansified the code with protoize. - -1999-08-08 Emmanuel Rouat - - * Removed HAS_DOSDIRS and HAS_POW10 code in directory - - * Makefile.am (libcp_a_SOURCES): removed spawn.c (vms only) - -1999-08-06 Emmanuel Rouat - - * unixcom.c (cp_unixcom): - * cshpar.c: removed test on HAS_SYSTEM (always true on Unix?) - - * backq.c (backeval): changed HAS_POPEN in HAVE_POPEN - - * cshpar.c (fileexists): changed HAS_ACCESS in HAVE_ACCESS - (com_chdir): removed test on HAS_CHDIR (always true on Unix) - (com_shell): removed test on HAS_UNIX_SIGS (always true on Unix) - - * unixcom.c (cp_unixcom): changed HAS_INTSYSWAIT in HAVE_SYS_WAIT_H - -1999-08-05 Emmanuel Rouat - - * cshpar.c (com_chdir): removed HAS_GETENV tests. - - * var2.c (vareval): removed test on HAS_GETPID - - * unixcom.c: changed HAS_GETCWD in HAVE_GETCWD and HAS_GETWD into HAVE_GETWD - - * lexical.c: - * gloc.c: - * cshpar.c: changed HAS_GETPW in HAVE_PWD_H - (com_chdir): changed HAS_GETCWD in HAVE_GETCWD (and #included unistd.h) - - * std.c: changed HAS_QSORT in HAVE_QSORT - -1999-08-04 Emmanuel Rouat - - * cshpar.c: changed HAS_WAIT2(??) into HAVE_SYS_WAIT_H - -1999-08-03 Emmanuel Rouat - - * output.c: changed HAS_TERMCAP in HAVE_TERMCAP - - * unixcom.c: changed HAS_VFORK in HAVE_VORK_H - - * unixcom.c: - * complete.c: - * glob.c: HAVE_SYS_DIR_H and HAVE_DIRENT_H (instead of - HAS_BSDDIRS and HAS_SYSVDIRS) - - * cshpar.c (com_shell): changed HAS_VFORK in HAVE_VORK_H - diff --git a/src/parser/Makefile.am b/src/parser/Makefile.am deleted file mode 100644 index a92eaed35..000000000 --- a/src/parser/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -## Process this file with automake to produce Makefile.in - -noinst_LIBRARIES = libparser.a - -libparser_a_SOURCES = \ - alias.c \ - alias.h \ - backq.c \ - backq.h \ - complete.c \ - complete.h \ - cshpar.c \ - cshpar.h \ - front.c \ - front.h \ - glob.c \ - glob.h \ - history.c \ - history.h \ - input.c \ - input.h \ - lexical.c \ - lexical.h \ - modify.c \ - modify.h \ - numparse.c \ - numparse.h \ - output.c \ - output.h \ - quote.c \ - quote.h \ - std.c \ - unixcom.c \ - unixcom.h \ - variable.c \ - variable.h \ - var2.c \ - var2.h \ - wlist.c \ - wlist.h - - -INCLUDES = -I$(top_srcdir)/src/include -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/parser/alias.c b/src/parser/alias.c deleted file mode 100644 index 28682a430..000000000 --- a/src/parser/alias.c +++ /dev/null @@ -1,254 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Do alias substitution. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "alias.h" - -static wordlist *asubst(wordlist *wlist); - -struct alias *cp_aliases = NULL; - -wordlist * -cp_doalias(wordlist *wlist) -{ - int ntries; - wordlist *realw, *nwl, *nextc = NULL, *end = NULL; - wordlist *comm; - - while (wlist && eq(wlist->wl_word, cp_csep)) - wlist = wlist->wl_next; - wlist->wl_prev = NULL; - - /* The alias process is going to modify the "last" line typed, - * so save a copy of what it really is and restore it after - * aliasing is done. We have to do tricky things do get around - * the problems with ; ... - */ - realw = wl_copy(cp_lastone->hi_wlist); - comm = wlist; - do { - end = comm->wl_prev; - comm->wl_prev = NULL; - for (nextc = comm; nextc; nextc = nextc->wl_next) - if (eq(nextc->wl_word, cp_csep)) { - if (nextc->wl_prev) - nextc->wl_prev->wl_next = NULL; - break; - } - - wl_free(cp_lastone->hi_wlist); - cp_lastone->hi_wlist = wl_copy(comm); - for (ntries = 21; ntries; ntries--) { - nwl = asubst(comm); - if (nwl == NULL) - break; - if (eq(nwl->wl_word, comm->wl_word)) { - /* Just once through... */ - wl_free(comm); - comm = nwl; - break; - } else { - wl_free(comm); - comm = nwl; - } - } - - if (!ntries) { - fprintf(cp_err, "Error: alias loop.\n"); - wlist->wl_word = NULL; - return (wlist); - } - comm->wl_prev = end; - if (!end) - wlist = comm; - else - end->wl_next = comm; - while (comm->wl_next) - comm = comm->wl_next; - comm->wl_next = nextc; - if (nextc) { - nextc->wl_prev = comm; - nextc = nextc->wl_next; - comm = nextc; - } - } while (nextc); - - wl_free(cp_lastone->hi_wlist); - cp_lastone->hi_wlist = realw; - return (wlist); -} - -/* Return NULL if no alias was found. We can get away with just calling - * cp_histsubst now because the line will have gone onto the history list - * by now and cp_histsubst will look in the right place. - */ - -static wordlist * -asubst(wordlist *wlist) -{ - struct alias *al; - wordlist *wl, *w = NULL; - char *word; - - word = wlist->wl_word; - if (*word == '\\') { - wlist->wl_word++; - return (NULL); - } - for (al = cp_aliases; al; al = al->al_next) - if (eq(word, al->al_name)) - break; - if (!al) - return (NULL); - wl = cp_histsubst(wl_copy(al->al_text)); - - if (cp_didhsubst) { - /* Make sure that we have an up-to-date last history entry. */ - wl_free(cp_lastone->hi_wlist); - cp_lastone->hi_wlist = wl_copy(wl); - } else { - /* If it had no history args, then append the rest of the wl */ - for (w = wl; w->wl_next; w = w->wl_next); - w->wl_next = wl_copy(wlist->wl_next); - if (w->wl_next) - w->wl_next->wl_prev = w; - } - return (wl); -} - -/* If we use this, aliases will be in alphabetical order. */ - -void -cp_setalias(char *word, wordlist *wlist) -{ - struct alias *al, *ta; - - cp_unalias(word); - cp_addkword(CT_ALIASES, word); - if (cp_aliases == NULL) { - /* printf("first one...\n"); */ - al = cp_aliases = alloc(struct alias); - al->al_next = NULL; - al->al_prev = NULL; - } else { - /* printf("inserting %s: %s ...\n", word, wlist->wl_word); */ - for (al = cp_aliases; al->al_next; al = al->al_next) { - /* printf("checking %s...\n", al->al_name); */ - if (strcmp(al->al_name, word) > 0) - break; - } - /* The new one goes before al */ - if (al->al_prev) { - al = al->al_prev; - ta = al->al_next; - al->al_next = alloc(struct alias); - al->al_next->al_prev = al; - al = al->al_next; - al->al_next = ta; - ta->al_prev = al; - } else { - cp_aliases = alloc(struct alias); - cp_aliases->al_next = al; - cp_aliases->al_prev = NULL; - al->al_prev = cp_aliases; - al = cp_aliases; - } - } - al->al_name = copy(word); - al->al_text = wl_copy(wlist); - cp_striplist(al->al_text); - /* We can afford to not worry about the bits, because before - * the keyword lookup is done the alias is evaluated. - * Make everything file completion, just in case... - */ - cp_addcomm(word, (long) 1, (long) 1, (long) 1, (long) 1); - /* printf("word %s, next = %s, prev = %s...\n", al->al_name, - al->al_next ? al->al_next->al_name : "(none)", - al->al_prev ? al->al_prev->al_name : "(none)"); */ - return; -} - -void -cp_unalias(char *word) -{ - struct alias *al; - - cp_remkword(CT_ALIASES, word); - for (al = cp_aliases; al; al = al->al_next) - if (eq(word, al->al_name)) - break; - if (al == NULL) - return; - if (al->al_next) - al->al_next->al_prev = al->al_prev; - if (al->al_prev) - al->al_prev->al_next = al->al_next; - else { - al->al_next->al_prev = NULL; - cp_aliases = al->al_next; - } - wl_free(al->al_text); - tfree(al->al_name); - tfree(al); - cp_remcomm(word); - return; -} - -void -cp_paliases(char *word) -{ - struct alias *al; - - for (al = cp_aliases; al; al = al->al_next) - if ((word == NULL) || eq(al->al_name, word)) { - if (!word) - fprintf(cp_out, "%s\t", al->al_name); - wl_print(al->al_text, cp_out); - (void) putc('\n', cp_out); - } - return; -} - -/* The routine for the "alias" command. */ - -void -com_alias(wordlist *wl) -{ - if (wl == NULL) - cp_paliases((char *) NULL); - else if (wl->wl_next == NULL) - cp_paliases(wl->wl_word); - else - cp_setalias(wl->wl_word, wl->wl_next); - return; -} - -void -com_unalias(wordlist *wl) -{ - struct alias *al, *na; - - if (eq(wl->wl_word, "*")) { - for (al = cp_aliases; al; al = na) { - na = al->al_next; - wl_free(al->al_text); - tfree(al->al_name); - tfree(al); - } - cp_aliases = NULL; - wl = wl->wl_next; - } - while (wl != NULL) { - cp_unalias(wl->wl_word); - wl = wl->wl_next; - } - return; -} - diff --git a/src/parser/alias.h b/src/parser/alias.h deleted file mode 100644 index 446117ba9..000000000 --- a/src/parser/alias.h +++ /dev/null @@ -1,16 +0,0 @@ -/************* - * Header file for alias.c - * 1999 E. Rouat - ************/ - -#ifndef ALIAS_H_INCLUDED -#define ALIAS_H_INCLUDED - -wordlist * cp_doalias(wordlist *wlist); -void cp_setalias(char *word, wordlist *wlist); -void cp_unalias(char *word); -void cp_paliases(char *word); -void com_alias(wordlist *wl); -void com_unalias(wordlist *wl); - -#endif diff --git a/src/parser/backq.c b/src/parser/backq.c deleted file mode 100644 index 4b8afcb60..000000000 --- a/src/parser/backq.c +++ /dev/null @@ -1,116 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * - * Do backquote substitution on a word list. - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include "backq.h" - - -static wordlist *backeval(char *string); - -char cp_back = '`'; - -wordlist * -cp_bquote(wordlist *wlist) -{ - wordlist *wl, *nwl; - char *s, *t, buf[BSIZE_SP], wbuf[BSIZE_SP], tbuf[BSIZE_SP]; - int i; - - for (wl = wlist; wl; wl = wl->wl_next) { - - t = wl->wl_word; - if (!t) - continue; - i = 0; -loop: s =strchr(t, cp_back); - if (s == NULL) - continue; - while (t < s) - wbuf[i++] = *t++; - wbuf[i] = '\0'; - (void) strcpy(buf, ++s); - s = buf; - t++; - while (*s && (*s != cp_back)) { - t++; /* Get s and t past the next backquote. */ - s++; - } - /* What the heck, let "echo `foo" work... */ - *s = '\0'; - t++; /* Get past the second ` */ - if (!(nwl = backeval(buf))) { - wlist->wl_word = NULL; - return (wlist); - } - (void) strcpy(buf, wbuf); - if (nwl->wl_word) { - (void) strcat(buf, nwl->wl_word); - tfree(nwl->wl_word); - } - nwl->wl_word = copy(buf); - - (void) strcpy(tbuf, t); - wl = wl_splice(wl, nwl); - for(wlist = wl; wlist->wl_prev; wlist = wlist->wl_prev); - /* MW. We must move to the begging of new wordlist. */ - - (void) strcpy(buf, wl->wl_word); - i = strlen(buf); - (void) strcat(buf, tbuf); - tfree(wl->wl_word); - wl->wl_word = copy(buf); - t = &wl->wl_word[i]; - s = wl->wl_word; - for (i = 0; s < t; s++) - wbuf[i++] = *s; - goto loop; - } - return (wlist); -} - -/* Do a popen with the string, and then reset the file pointers so that - * we can use the first pass of the parser on the output. - */ - -static wordlist * -backeval(char *string) -{ -#ifdef HAVE_POPEN - FILE *proc, *old; - wordlist *wl; - bool intv; - extern FILE *popen(const char *, const char *); - - proc = popen(string, "r"); - if (proc == NULL) { - fprintf(cp_err, "Error: can't evaluate %s.\n", string); - return (NULL); - } - old = cp_inp_cur; - cp_inp_cur = proc; - intv = cp_interactive; - cp_interactive = FALSE; - cp_bqflag = TRUE; - wl = cp_lexer((char *) NULL); - cp_bqflag = FALSE; - cp_inp_cur = old; - cp_interactive = intv; - (void) pclose(proc); - return (wl); -#else - wordlist *wl = alloc(struct wordlist); - - wl->wl_word = copy(string); - return (wl); -#endif -} - diff --git a/src/parser/backq.h b/src/parser/backq.h deleted file mode 100644 index 98a6ce1de..000000000 --- a/src/parser/backq.h +++ /dev/null @@ -1,12 +0,0 @@ -/************* - * Header file for backq.c - * 1999 E. Rouat - ************/ - -#ifndef BACKQ_H_INCLUDED -#define BACKQ_H_INCLUDED - -wordlist * cp_bquote(wordlist *wlist); - - -#endif diff --git a/src/parser/complete.c b/src/parser/complete.c deleted file mode 100644 index 647a5e4b6..000000000 --- a/src/parser/complete.c +++ /dev/null @@ -1,690 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -Modified: 1999 Paolo Nenzi -**********/ - -/* - * Command completion code. We keep a data structure with information on each - * command, to make lookups fast. We also keep NCLASSES (which is sort of - * hardwired as 32) sets of keywords. Each command has an array of NARGS - * bitmasks (also hardwired as 4), stating whether the command takes that - * particular class of keywords in that position. Class 0 always means - * filename completion. - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include "complete.h" - - -#ifdef HAVE_SYS_DIR_H -#include -#include -#else -# ifdef HAVE_DIRENT_H -# include -# include -# ifndef direct -# define direct dirent -# endif -# endif -#endif -#ifdef HAVE_PWD_H -#include -#endif - - /* MW. We also need ioctl.h here I think */ -#include - -/* Be sure the ioctls get included in the following */ -#ifdef HAVE_SGTTY_H -#include -#else -#ifdef HAVE_TERMIO_H -#include -#else -#ifdef HAVE_TERMIOS_H -#include -#endif -#endif -#endif - - -#define CNTRL_D '\004' -#define ESCAPE '\033' -#define NCLASSES 32 - -bool cp_nocc; /* Don't do command completion. */ - - - -static struct ccom *commands = NULL; /* The available commands. */ -static struct ccom *keywords[NCLASSES]; /* Keywords. */ - - -/* static declarations */ - -static struct ccom * getccom(char *first); -static wordlist * ccfilec(char *buf); -static wordlist * ccmatch(char *word, struct ccom **dbase); -static void printem(wordlist *wl); -static wordlist * cctowl(struct ccom *cc, bool sib); -static struct ccom * clookup(register char *word, struct ccom **dd, bool pref, - bool create); -static void cdelete(struct ccom *node); - - -#ifdef TIOCSTI - -void -cp_ccom(wordlist *wlist, char *buf, bool esc) -{ - struct ccom *cc; - wordlist *a, *pmatches = NULL; - char wbuf[BSIZE_SP], *s; - int i=0; - int j, arg; - - buf = cp_unquote(copy(buf)); - cp_wstrip(buf); - if (wlist->wl_next) { /* Not the first word. */ - cc = getccom(wlist->wl_word); - if (cc && cc->cc_invalid) - cc = NULL; - arg = wl_length(wlist) - 2; - if (arg > 3) - arg = 3; - /* First filenames. */ - if (cc && (cc->cc_kwords[arg] & 1)) { - pmatches = ccfilec(buf); - s =strrchr(buf, '/'); - i = strlen(s ? s + 1 : buf); - if ((*buf == '~') && !index(buf, '/')) - i--; - } - - /* The keywords. */ - for (j = 1; j < NCLASSES; j++) { - if (cc && (cc->cc_kwords[arg] & (1 << j))) { - /* Find all the matching keywords. */ - a = ccmatch(buf, &keywords[j]); - i = strlen(buf); - if (pmatches) - pmatches = wl_append(pmatches, a); - else - pmatches = a; - } - } - wl_sort(pmatches); - } else { - pmatches = ccmatch(buf, &commands); - i = strlen(buf); - } - if (!esc) { - printem(pmatches); - wl_free(pmatches); - return; - } - - if (pmatches == NULL) { - (void) putchar('\07'); - (void) fflush(cp_out); - return; - } - if (pmatches->wl_next == NULL) { - (void) strcpy(wbuf, &pmatches->wl_word[i]); - goto found; - } - /* Now we know which words might work. Extend the command as much - * as possible, then TIOCSTI the characters out. - */ - for (j = 0;; j++, i++) { - wbuf[j] = pmatches->wl_word[i]; - for (a = pmatches->wl_next; a; a = a->wl_next) - if (a->wl_word[i] != wbuf[j]) { - (void) putchar('\07'); - (void) fflush(cp_out); - wbuf[j] = '\0'; - goto found; - } - if (wbuf[j] == '\0') - goto found; - } -found: for (i = 0; wbuf[i]; i++) - (void) ioctl(fileno(cp_in), TIOCSTI, &wbuf[i]); - wl_free(pmatches); - return; -} - -/* Figure out what the command is, given the name. Returns NULL if there - * is no such command in the command list. This is tricky, because we have - * to do a preliminary history and alias parse. (Or at least we should.) - */ - -static struct ccom * -getccom(char *first) -{ - struct alias *al; - int ntries = 21; - - /* First look for aliases. Just interested in the first word... - * Don't bother doing history yet -- that might get complicated. - */ - while (ntries-- > 0) { - for (al = cp_aliases; al; al = al->al_next) - if (eq(first, al->al_name)) { - first = al->al_text->wl_word; - break; - } - if (al == NULL) - break; - } - if (ntries == 0) { - fprintf(cp_err, "\nError: alias loop.\n"); - return (NULL); - } - return (clookup(first, &commands, FALSE, FALSE)); -} - -/* Figure out what files match the prefix. */ - -static wordlist * -ccfilec(char *buf) -{ - DIR *wdir; - char *lcomp, *dir; - struct direct *de; - wordlist *wl = NULL, *t; - struct passwd *pw; - - buf = copy(buf); /* Don't mangle anything... */ - - lcomp =strrchr(buf, '/'); - if (lcomp == NULL) { - dir = "."; - lcomp = buf; - if (*buf == cp_til) { /* User name completion... */ - buf++; - while ((pw = getpwent())) { - if (prefix(buf, pw->pw_name)) { - if (wl == NULL) { - wl = alloc(struct wordlist); - wl->wl_next = NULL; - wl->wl_prev = NULL; - } else { - t = wl; - wl = alloc(struct wordlist); - wl->wl_prev = NULL; - wl->wl_next = t; - t->wl_prev = wl; - } - wl->wl_word = copy(pw->pw_name); - } - } - (void) endpwent(); - return (wl); - } - } else { - dir = buf; - *lcomp = '\0'; - lcomp++; - if (*dir == cp_til) { - dir = cp_tildexpand(dir); - if (dir == NULL) - return (NULL); - } - } - if (!(wdir = opendir(dir))) - return (NULL); - while ((de = readdir(wdir))) - if ((prefix(lcomp, de->d_name)) && (*lcomp || - (*de->d_name != '.'))) { - if (wl == NULL) { - wl = alloc(struct wordlist); - wl->wl_next = NULL; - wl->wl_prev = NULL; - } else { - t = wl; - wl = alloc(struct wordlist); - wl->wl_next = t; - t->wl_prev = wl; - wl->wl_prev = NULL; - } - wl->wl_word = copy(de->d_name); - } - (void) closedir(wdir); - - wl_sort(wl); - return (wl); -} - -/* See what keywords or commands match the prefix. Check extra also for - * matches, if it is non-NULL. Return a wordlist which is in alphabetical - * order. Note that we have to call this once for each class. - */ - -static wordlist * -ccmatch(char *word, struct ccom **dbase) -{ - wordlist *wl; - register struct ccom *cc; - - cc = clookup(word, dbase, TRUE, FALSE); - if (cc) { - if (*word) /* This is a big drag. */ - wl = cctowl(cc, FALSE); - else - wl = cctowl(cc, TRUE); - } else - wl = NULL; - return (wl); -} - -/* Print the words in the wordlist in columns. They are already sorted... - * This is a hard thing to do with wordlists... - */ - -static void -printem(wordlist *wl) -{ - wordlist *ww; - int maxl = 0, num, i, j, k, width = 79, ncols, nlines; - - (void) putchar('\n'); - if (wl == NULL) { - return; - } - num = wl_length(wl); - for (ww = wl; ww; ww = ww->wl_next) { - j = strlen(ww->wl_word); - if (j > maxl) - maxl = j; - } - if (++maxl % 8) - maxl += 8 - (maxl % 8); - ncols = width / maxl; - if (ncols == 0) - ncols = 1; - nlines = num / ncols + (num % ncols ? 1 : 0); - for (k = 0; k < nlines; k++) { - for (i = 0; i < ncols; i++) { - j = i * nlines + k; - if (j < num) { - fprintf(cp_out, "%-*s", maxl, - wl_nthelem(j, wl)->wl_word); - } else - break; - } - (void) putchar('\n'); - } - return; -} - -#else /* if not TIOCSTI */ -void -cp_ccom(wordlist *wlist, char *buf, bool esc) -{ - return; -} -#endif - -static wordlist * -cctowl(struct ccom *cc, bool sib) -{ - wordlist *wl, *end; - - if (!cc) - return (NULL); - if (!cc->cc_invalid) { - wl = alloc(struct wordlist); - wl->wl_word = copy(cc->cc_name); - wl->wl_prev = NULL; - wl->wl_next = cctowl(cc->cc_child, TRUE); - if (wl->wl_next) - wl->wl_next->wl_prev = wl; - } else - wl = cctowl(cc->cc_child, TRUE); - if (sib) { - if (wl) { - for (end = wl; end->wl_next; end = end->wl_next) - ; - end->wl_next = cctowl(cc->cc_sibling, TRUE); - if (end->wl_next) - end->wl_next->wl_prev = wl; - } else - wl = cctowl(cc->cc_sibling, TRUE); - } - return (wl); -} - -/* We use this in com_device... */ - -wordlist * -cp_cctowl(char *stuff) -{ - return (cctowl((struct ccom *) stuff, TRUE)); -} - -/* Turn on and off the escape break character and cooked mode. */ - -void -cp_ccon(bool on) -{ -#ifdef TIOCSTI -#ifdef HAVE_SGTTY_H - static bool ison = FALSE; - struct tchars tbuf; - struct sgttyb sbuf; - - if (cp_nocc || !cp_interactive || (ison == on)) - return; - ison = on; - - /* Set the terminal up -- make escape the break character, and - * make sure we aren't in raw or cbreak mode. Hope the (void) ioctl's - * won't fail. - */ - (void) ioctl(fileno(cp_in), TIOCGETC, (char *) &tbuf); - if (on) - tbuf.t_brkc = ESCAPE; - else - tbuf.t_brkc = '\0'; - (void) ioctl(fileno(cp_in), TIOCSETC, (char *) &tbuf); - - (void) ioctl(fileno(cp_in), TIOCGETP, (char *) &sbuf); - sbuf.sg_flags &= ~(RAW|CBREAK); - (void) ioctl(fileno(cp_in), TIOCSETP, (char *) &sbuf); -#else - -# ifdef HAVE_TERMIO_H - -# define TERM_GET TCGETA -# define TERM_SET TCSETA - static struct termio sbuf; - static struct termio OS_Buf; - -# else -# ifdef HAVE_TERMIOS_H - -# define TERM_GET TCGETS -# define TERM_SET TCSETS - static struct termios sbuf; - static struct termios OS_Buf; - -# endif -# endif - -# ifdef TERM_GET - static bool ison = FALSE; - - if (cp_nocc || !cp_interactive || (ison == on)) - return; - ison = on; - - if (ison == TRUE) { - (void) ioctl(fileno(cp_in), TERM_GET, (char *) &OS_Buf); - sbuf = OS_Buf; - sbuf.c_cc[VEOF] = 0; - sbuf.c_cc[VEOL] = ESCAPE; - sbuf.c_cc[VEOL2] = CNTRL_D; - (void) ioctl(fileno(cp_in), TERM_SET, (char *) &sbuf); - } else { - (void) ioctl(fileno(cp_in), TERM_SET, (char *) &OS_Buf); - } - -# endif -#endif - -#endif - - return; -} - -/* The following routines deal with the command and keyword databases. - * Say whether a given word exists in the command database. - */ - -bool -cp_comlook(char *word) -{ - if (word && *word && clookup(word, &commands, FALSE, FALSE)) - return (TRUE); - else - return (FALSE); -} - -/* Add a command to the database, with the given keywords and filename flag. */ - -void -cp_addcomm(char *word, long int bits0, long int bits1, long int bits2, long int bits3) -{ - struct ccom *cc; - - cc = clookup(word, &commands, FALSE, TRUE); - cc->cc_invalid = 0; - cc->cc_kwords[0] = bits0; - cc->cc_kwords[1] = bits1; - cc->cc_kwords[2] = bits2; - cc->cc_kwords[3] = bits3; - return; -} - -/* Remove a command from the database. */ - -void -cp_remcomm(char *word) -{ - struct ccom *cc; - - cc = clookup(word, &commands, FALSE, FALSE); - if (cc) - cdelete(cc); - return; -} - -/* Add a keyword to the database. */ - -void -cp_addkword(int class, char *word) -{ - struct ccom *cc; - - if ((class < 1) || (class >= NCLASSES)) { - fprintf(cp_err, "cp_addkword: Internal Error: bad class %d\n", - class); - return; - } - word = copy(word); - cc = clookup(word, &keywords[class], FALSE, TRUE); - cc->cc_invalid = 0; - return; -} - -/* Remove a keyword from the database. */ - -void -cp_remkword(int class, char *word) -{ - struct ccom *cc; - - if ((class < 1) || (class >= NCLASSES)) { - fprintf(cp_err, "cp_addkword: Internal Error: bad class %d\n", - class); - return; - } - cc = clookup(word, &keywords[class], FALSE, FALSE); - if (cc) - cdelete(cc); - return; -} - -/* This routine is used when there are several keyword sets that are - * to be switched between rapidly. The return value is the old tree at - * that position, and the keyword class given is set to the argument. - */ - -char * -cp_kwswitch(int class, char *tree) -{ - char *old; - - if ((class < 1) || (class >= NCLASSES)) { - fprintf(cp_err, "cp_addkword: Internal Error: bad class %d\n", - class); - return (NULL); - } - old = (char *) keywords[class]; - keywords[class] = (struct ccom *) tree; - return (old); -} - -/* Throw away all the stuff and prepare to rebuild it from scratch... */ - - -void -cp_ccrestart(bool kwords) -{ - /* Ack. */ - return; -} - -void -throwaway(struct ccom *dbase) -{ - if (dbase->cc_child) - throwaway(dbase->cc_child); - if (dbase->cc_sibling) - throwaway(dbase->cc_sibling); - tfree(dbase); - return; -} - -/* Look up a word in the database. Because of the - * way the tree is set up, this also works for looking up all words with - * a given prefix (if the pref arg is TRUE). If create is TRUE, then the - * node is created if it doesn't already exist. - */ - -static struct ccom * -clookup(register char *word, struct ccom **dd, bool pref, bool create) -{ - register struct ccom *place = *dd, *tmpc; - int ind = 0, i; - char buf[BSIZE_SP]; - -/* printf("----- adding %s -----\n", word); */ -/* prcc(); */ - - if (!place) { - /* This is the first time we were called. */ - if (!create) - return (NULL); - else { - *dd = place = alloc(struct ccom); - ZERO(place, struct ccom); - buf[0] = *word; - buf[1] = '\0'; - place->cc_name = copy(buf); - if (word[1]) - place->cc_invalid = 1; - } - } - while (word[ind]) { - /* Walk down the sibling list until we find a node that - * matches 'word' to 'ind' places. - */ - while ((place->cc_name[ind] < word[ind]) && place->cc_sibling) - place = place->cc_sibling; - if (place->cc_name[ind] < word[ind]) { - /* This line doesn't go out that far... */ - if (create) { - place->cc_sibling = alloc(struct ccom); - ZERO(place->cc_sibling, struct ccom); - place->cc_sibling->cc_ysibling = place; - place->cc_sibling->cc_parent = place->cc_parent; - place = place->cc_sibling; - place->cc_name = tmalloc(ind + 2); - for (i = 0; i < ind + 1; i++) - place->cc_name[i] = word[i]; - place->cc_name[ind + 1] = '\0'; - place->cc_invalid = 1; - } else { - return (NULL); - } - } else if (place->cc_name[ind] > word[ind]) { - if (create) { - /* Put this one between place and its pred. */ - tmpc = alloc(struct ccom); - ZERO(tmpc, struct ccom); - tmpc->cc_parent = place->cc_parent; - tmpc->cc_sibling = place; - tmpc->cc_ysibling = place->cc_ysibling; - place->cc_ysibling = tmpc; - place = tmpc; - if (tmpc->cc_ysibling) - tmpc->cc_ysibling->cc_sibling = tmpc; - else if (tmpc->cc_parent) - tmpc->cc_parent->cc_child = tmpc; - else - *dd = place; - place->cc_name = tmalloc(ind + 2); - for (i = 0; i < ind + 1; i++) - place->cc_name[i] = word[i]; - place->cc_name[ind + 1] = '\0'; - place->cc_invalid = 1; - } else { - return (NULL); - } - } - - /* place now points to that node that matches the word for - * ind + 1 characters. - */ -/* printf("place %s, word %s, ind %d\n", place->cc_name, word, ind); */ - if (word[ind + 1]) { /* More to go... */ - if (!place->cc_child) { - /* No children, maybe make one and go on. */ - if (create) { - tmpc = alloc(struct ccom); - ZERO(tmpc, struct ccom); - tmpc->cc_parent = place; - place->cc_child = tmpc; - place = tmpc; - place->cc_name = tmalloc(ind + 3); - for (i = 0; i < ind + 2; i++) - place->cc_name[i] = word[i]; - place->cc_name[ind + 2] = '\0'; - if (word[ind + 2]) - place->cc_invalid = 1; - } else { - return (NULL); - } - } else - place = place->cc_child; - ind++; - } else - break; - } - if (!pref && !create && place->cc_invalid) { - /* This is no good, we want a real word. */ - return (NULL); - } - return (place); -} - -/* Delete a node from the tree. Returns the new tree... */ - -static void -cdelete(struct ccom *node) -{ - node->cc_invalid = 1; - free(node->cc_name); - free(node->cc_child); - free(node->cc_sibling); - free(node->cc_ysibling); - free(node->cc_parent); - return; -} - diff --git a/src/parser/complete.h b/src/parser/complete.h deleted file mode 100644 index 1399d0e39..000000000 --- a/src/parser/complete.h +++ /dev/null @@ -1,45 +0,0 @@ -/************* - * Header file for complete.c - * 1999 E. Rouat - ************/ - -#ifndef COMPLETE_H_INCLUDED -#define COMPLETE_H_INCLUDED - -/* The data structure for the commands is as follows: every node has a pointer - * to its leftmost child, where the children of a node are those of which - * the node is a prefix. This means that for a word like "ducks", there - * must be nodes "d", "du", "duc", etc (which are all marked "invalid", - * of course). This data structure is called a "trie". - */ - - - -#define NARGS 4 - -struct ccom { - char *cc_name; /* Command or keyword name. */ - long cc_kwords[NARGS]; /* What this command takes. */ - char cc_invalid; /* This node has been deleted. */ - struct ccom *cc_child; /* Left-most child. */ - struct ccom *cc_sibling;/* Right (alph. greater) sibling. */ - struct ccom *cc_ysibling;/* Left (alph. less) sibling. */ - struct ccom *cc_parent; /* Parent node. */ -} ; - - -void cp_ccom(wordlist *wlist, char *buf, bool esc); -wordlist * cp_cctowl(char *stuff); -void cp_ccon(bool on); -bool cp_comlook(char *word); -void cp_addcomm(char *word, long int bits0, long int bits1, long int bits2, - long int bits3); -void cp_remcomm(char *word); -void cp_addkword(int class, char *word); -void cp_remkword(int class, char *word); -char * cp_kwswitch(int class, char *tree); -void cp_ccrestart(bool kwords); -void throwaway(struct ccom *dbase); - - -#endif diff --git a/src/parser/cshpar.c b/src/parser/cshpar.c deleted file mode 100644 index 74eb68dee..000000000 --- a/src/parser/cshpar.c +++ /dev/null @@ -1,479 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * The main entry point for cshpar. - */ - - -#include "ngspice.h" -#include "cpdefs.h" -#include -#include "cshpar.h" - -#ifdef HAVE_SGTTY_H -#include -#else -#ifdef HAVE_TERMIO_H -#include -#else -#ifdef HAVE_TERMIOS_H -#include -#endif -#endif -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_PWD_H -#include -#endif - - -#ifdef HAVE_SYS_WAIT_H -#include -#endif - - - -/* Things go as follows: - * (1) Read the line and do some initial quoting (by setting the 8th bit), - * and command ignoring. Also deal with command completion. - * (2) Do history substitutions. (!, ^) - * (3) Do alias substitution. - * - * In front.c these things get done: - * (4) Do variable substitution. ($varname) - * (5) Do backquote substitution. (``) - * (6) Do globbing. (*, ?, [], {}, ~) - * (7) Do io redirection. - */ - - -static bool fileexists(char *name); -void fixdescriptors(void); -static void pwlist(wordlist *wlist, char *name); - -bool cp_debug = FALSE; -char cp_gt = '>'; -char cp_lt = '<'; -char cp_amp = '&'; - -FILE *cp_in; -FILE *cp_out; -FILE *cp_err; - -/* These are the fps that cp_ioreset resets the cp_* to. They are changed - * by the source routines. - */ - -FILE *cp_curin = NULL; -FILE *cp_curout = NULL; -FILE *cp_curerr = NULL; - -wordlist * -cp_parse(char *string) -{ - wordlist *wlist; - - wlist = cp_lexer(string); - - if (!string) - cp_event++; - - if (!wlist || !wlist->wl_word) - return (wlist); - - pwlist(wlist, "Initial parse"); - - wlist = cp_histsubst(wlist); - if (!wlist || !wlist->wl_word) - return (wlist); - pwlist(wlist, "After history substitution"); - if (cp_didhsubst) { - wl_print(wlist, stdout); - (void) putc('\n', stdout); - } - - /* Add the word list to the history. */ - if (*wlist->wl_word) - cp_addhistent(cp_event - 1, wlist); - - wlist = cp_doalias(wlist); - pwlist(wlist, "After alias substitution"); - - if (string && cp_lastone) { - /* Don't put this one in... */ - cp_lastone = cp_lastone->hi_prev; - if (cp_lastone) - cp_lastone->hi_next = NULL; - } - - pwlist(wlist, "Returning "); - return (wlist); -} - -static void -pwlist(wordlist *wlist, char *name) -{ - wordlist *wl; - - if (!cp_debug) - return; - fprintf(cp_err, "%s : [ ", name); - for (wl = wlist; wl; wl = wl->wl_next) - fprintf(cp_err, "%s ", wl->wl_word); - fprintf(cp_err, "]\n"); - return; -} - -/* This has to go somewhere... */ - -void -com_echo(wordlist *wlist) -{ - bool nl = TRUE; - - if (wlist && eq(wlist->wl_word, "-n")) { - wlist = wlist->wl_next; - nl = FALSE; - } - - while (wlist) { - fputs(cp_unquote(wlist->wl_word), cp_out); - if (wlist->wl_next) - fputs(" ", cp_out); - wlist = wlist->wl_next; - } - if (nl) - fputs("\n", cp_out); -} - -/* This routine sets the cp_{in,out,err} pointers and takes the io - * directions out of the command line. - */ - -wordlist * -cp_redirect(wordlist *wl) -{ - bool gotinput = FALSE, gotoutput = FALSE, goterror = FALSE; - bool app = FALSE, erralso = FALSE; - wordlist *w, *bt, *nw; - char *s; - FILE *tmpfp; - - w = wl->wl_next; /* Don't consider empty commands. */ - while (w) { - if (*w->wl_word == cp_lt) { - bt = w; - if (gotinput) { - fprintf(cp_err, - "Error: ambiguous input redirect.\n"); - goto error; - } - gotinput = TRUE; - w = w->wl_next; - if (w == NULL) { - fprintf(cp_err, - "Error: missing name for input.\n"); - return (NULL); - } - if (*w->wl_word == cp_lt) { - /* Do reasonable stuff here... */ - } else { - tmpfp = fopen(cp_unquote(w->wl_word), "r"); - if (!tmpfp) { - perror(w->wl_word); - goto error; - } else - cp_in = tmpfp; - } -#ifdef CPDEBUG - if (cp_debug) - fprintf(cp_err, "Input file is %s...\n", - w->wl_word); -#endif - bt->wl_prev->wl_next = w->wl_next; - if (w->wl_next) - w->wl_next->wl_prev = bt->wl_prev; - nw = w->wl_next; - w->wl_next = NULL; - w = nw; - wl_free(bt); - } else if (*w->wl_word == cp_gt) { - bt = w; - if (gotoutput) { - fprintf(cp_err, - "Error: ambiguous output redirect.\n"); - goto error; - } - gotoutput = TRUE; - w = w->wl_next; - if (w == NULL) { - fprintf(cp_err, - "Error: missing name for output.\n"); - return (NULL); - } - if (*w->wl_word == cp_gt) { - app = TRUE; - w = w->wl_next; - if (w == NULL) { - fprintf(cp_err, - "Error: missing name for output.\n"); - return (NULL); - } - } - if (*w->wl_word == cp_amp) { - erralso = TRUE; - if (goterror) { - fprintf(cp_err, - "Error: ambiguous error redirect.\n"); - return (NULL); - } - goterror = TRUE; - w = w->wl_next; - if (w == NULL) { - fprintf(cp_err, - "Error: missing name for output.\n"); - return (NULL); - } - } - s = cp_unquote(w->wl_word); - if (cp_noclobber && fileexists(s)) { - fprintf(stderr, "Error: %s: file exists\n", s); - goto error; - } - if (app) - tmpfp = fopen(s, "a"); - else - tmpfp = fopen(s, "w+"); - if (!tmpfp) { - perror(w->wl_word); - goto error; - } else { - cp_out = tmpfp; - out_isatty = FALSE; - } -#ifdef CPDEBUG - if (cp_debug) - fprintf(cp_err, "Output file is %s... %s\n", - w->wl_word, app ? "(append)" : ""); -#endif - bt->wl_prev->wl_next = w->wl_next; - if (w->wl_next) - w->wl_next->wl_prev = bt->wl_prev; - w = w->wl_next; - if (w) - w->wl_prev->wl_next = NULL; - wl_free(bt); - if (erralso) - cp_err = cp_out; - } else - w = w->wl_next; - } - return (wl); - -error: wl_free(wl); - return (NULL); -} - -/* Reset the cp_* FILE pointers to the standard ones. This is tricky, since - * if we are sourcing a command file, and io has been redirected from inside - * the file, we have to reset it back to what it was for the source, not for - * the top level. That way if you type "foo > bar" where foo is a script, - * and it has redirections of its own inside of it, none of the output from - * foo will get sent to stdout... - */ - -void -cp_ioreset(void) -{ - if (cp_in != cp_curin) { - if (cp_in) - (void) fclose(cp_in); - cp_in = cp_curin; - } - if (cp_out != cp_curout) { - if (cp_out) - (void) fclose(cp_out); - cp_out = cp_curout; - } - if (cp_err != cp_curerr) { - if (cp_err) - (void) fclose(cp_err); - cp_err = cp_curerr; - } - - /*** Minor bug here... */ - out_isatty = TRUE; - return; -} - -static bool -fileexists(char *name) -{ -#ifdef HAVE_ACCESS - if (access(name, 0) == 0) - return (TRUE); -#endif - return (FALSE); -} - - -/* Fork a shell. */ - -void -com_shell(wordlist *wl) -{ - char *com, *shell = NULL; - - shell = getenv("SHELL"); - if (shell == NULL) - shell = "/bin/csh"; - - cp_ccon(FALSE); - -#ifdef HAVE_VFORK_H - /* XXX Needs to switch process groups. Also, worry about suspend */ - /* Only bother for efficiency */ - pid = vfork(); - if (pid == 0) { - fixdescriptors(); - if (wl == NULL) { - (void) execl(shell, shell, 0); - _exit(99); - } else { - com = wl_flatten(wl); - (void) execl("/bin/sh", "sh", "-c", com, 0); - } - } else { - /* XXX Better have all these signals */ - svint = signal(SIGINT, SIG_DFL); - svquit = signal(SIGQUIT, SIG_DFL); - svtstp = signal(SIGTSTP, SIG_DFL); - /* XXX Sig on proc group */ - do { - r = wait((union wait *) NULL); - } while ((r != pid) && pid != -1); - (void) signal(SIGINT, (SIGNAL_FUNCTION) svint); - (void) signal(SIGQUIT, (SIGNAL_FUNCTION) svquit); - (void) signal(SIGTSTP, (SIGNAL_FUNCTION) svtstp); - } -#else - /* Easier to forget about changing the io descriptors. */ - if (wl) { - com = wl_flatten(wl); - (void) system(com); - } else - (void) system(shell); -#endif - - return; -} - - -/* Do this only right before an exec, since we lose the old std*'s. */ - -void -fixdescriptors(void) -{ - if (cp_in != stdin) - (void) dup2(fileno(cp_in), fileno(stdin)); - if (cp_out != stdout) - (void) dup2(fileno(cp_out), fileno(stdout)); - if (cp_err != stderr) - (void) dup2(fileno(cp_err), fileno(stderr)); - return; -} - - -void -com_rehash(wordlist *wl) -{ - char *s; - - if (!cp_dounixcom) { - fprintf(cp_err, "Error: unixcom not set.\n"); - return; - } - s = getenv("PATH"); - if (s) - cp_rehash(s, TRUE); - else - fprintf(cp_err, "Error: no PATH in environment.\n"); - return; -} - -void -com_chdir(wordlist *wl) -{ - char *s; - struct passwd *pw; - extern struct passwd *getpwuid(uid_t); - char localbuf[257]; - int copied = 0; - - s = NULL; - - if (wl == NULL) { - - s = getenv("HOME"); - -#ifdef HAVE_PWD_H - if (s == NULL) { - pw = getpwuid(getuid()); - if (pw == NULL) { - fprintf(cp_err, "Can't get your password entry\n"); - return; - } - s = pw->pw_dir; - } -#endif - } else { - s = cp_unquote(wl->wl_word); - copied = 1; - } - - - - if (*s && chdir(s) == -1) - perror(s); - - if (copied) - tfree(s); - -#ifdef HAVE_GETCWD - if ((s = (char *)getcwd(localbuf, sizeof(localbuf)))) - printf("Current directory: %s\n", s); - else - fprintf(cp_err, "Can't get current working directory.\n"); -#endif - - return; - -} - - - -/* This is a truly evil thing */ - -void -com_strcmp(wordlist *wl) -{ - char *var, *s1, *s2; - int i; - - var = wl->wl_word; - s1 = cp_unquote(wl->wl_next->wl_word); - s2 = cp_unquote(wl->wl_next->wl_next->wl_word); - - i = strcmp(s1, s2); - - cp_vset(var, VT_NUM, (char *) &i); - return; -} - diff --git a/src/parser/cshpar.h b/src/parser/cshpar.h deleted file mode 100644 index 735302a60..000000000 --- a/src/parser/cshpar.h +++ /dev/null @@ -1,20 +0,0 @@ -/************* - * Header file for cshpar.c - * 1999 E. Rouat - ************/ - -#ifndef CSHPAR_H_INCLUDED -#define CSHPAR_H_INCLUDED - -wordlist * cp_parse(char *string); -void com_echo(wordlist *wlist); -wordlist * cp_redirect(wordlist *wl); -void cp_ioreset(void); -void com_shell(wordlist *wl); -void fixdescriptors(void); -void com_rehash(wordlist *wl); -void com_chdir(wordlist *wl); -void com_strcmp(wordlist *wl); - - -#endif diff --git a/src/parser/front.c b/src/parser/front.c deleted file mode 100644 index 8852ec84c..000000000 --- a/src/parser/front.c +++ /dev/null @@ -1,960 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * The front-end command loop. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "front.h" - -/* Return values from doblock(). I am assuming that nobody will use these - * characters in a string. - */ - -#define NORMAL '\001' -#define BROKEN '\002' -#define CONTINUED '\003' -#define NORMAL_STR "\001" -#define BROKEN_STR "\002" -#define CONTINUED_STR "\003" - -/* Are we waiting for a command? This lets (void) signal handling be -more clever. */ - -bool cp_cwait = FALSE; -char *cp_csep = ";"; - -bool cp_dounixcom = FALSE; - - - - -#define CO_UNFILLED 0 -#define CO_STATEMENT 1 -#define CO_WHILE 2 -#define CO_DOWHILE 3 -#define CO_IF 4 -#define CO_FOREACH 5 -#define CO_BREAK 6 -#define CO_CONTINUE 7 -#define CO_LABEL 8 -#define CO_GOTO 9 -#define CO_REPEAT 10 - -/* We have to keep the control structures in a stack, so that when we do - * a 'source', we can push a fresh set onto the top... Actually there have - * to be two stacks -- one for the pointer to the list of control structs, - * and one for the 'current command' pointer... - */ - -#define CONTROLSTACKSIZE 256 /* Better be enough. */ -static struct control *control[CONTROLSTACKSIZE], *cend[CONTROLSTACKSIZE]; - - -/* static declarations */ -static char * doblock(struct control *bl, int *num); -static struct control * findlabel(char *s, struct control *ct); -static void docommand(register wordlist *wlist); -static wordlist * getcommand(char *string); -static void pwlist(wordlist *wlist, char *name); -static void dodump(struct control *cc); - - -static int stackp = 0; - -/* If there is an argument, give this to cshpar to use instead of stdin. In - * a few places, we call cp_evloop again if it returns 1 and exit (or close - * a file) if it returns 0... Because of the way sources are done, we can't - * allow the control structures to get blown away every time we return -- - * probably every time we type source at the keyboard and every time a - * source returns to keyboard input is ok though -- use ft_controlreset. - */ - -static char *noredirect[] = { "stop", NULL } ; /* Only one?? */ - - - - - -int -cp_evloop(char *string) -{ - wordlist *wlist, *ww; - struct control *x; - char *i; - int nn; - -#define newblock cend[stackp]->co_children = alloc(struct control); \ - ZERO(cend[stackp]->co_children,struct control), \ - cend[stackp]->co_children->co_parent = cend[stackp]; \ - cend[stackp] = cend[stackp]->co_children; \ - cend[stackp]->co_type = CO_UNFILLED; - - for (;;) { - wlist = getcommand(string); - if (wlist == NULL) { /* End of file or end of user input. */ - if (cend[stackp]->co_parent && !string) { - cp_resetcontrol(); - continue; - } else - return (0); - } - if ((wlist->wl_word == NULL) || (*wlist->wl_word == '\0')) { - /* User just typed return. */ - if (string) - return (1); - else { - cp_event--; - continue; - } - } - - /* Just a check... */ - for (ww = wlist; ww; ww = ww->wl_next) - if (!ww->wl_word) { - fprintf(cp_err, - "cp_evloop: Internal Error: NULL word pointer\n"); - continue; - } - - - /* Add this to the control structure list. If cend->co_type - * is CO_UNFILLED, the last line was the beginning of a - * block, and this is the unfilled first statement. - */ - if (cend[stackp] && (cend[stackp]->co_type != CO_UNFILLED)) { - cend[stackp]->co_next = alloc(struct control); - ZERO(cend[stackp]->co_next, struct control); - cend[stackp]->co_next->co_prev = cend[stackp]; - cend[stackp]->co_next->co_parent = - cend[stackp]->co_parent; - cend[stackp] = cend[stackp]->co_next; - } else if (!cend[stackp]) { - control[stackp] = cend[stackp] = alloc(struct control); - ZERO(cend[stackp], struct control); - } - - if (eq(wlist->wl_word, "while")) { - cend[stackp]->co_type = CO_WHILE; - cend[stackp]->co_cond = wlist->wl_next; - if (!cend[stackp]->co_cond) { - fprintf(stderr, - "Error: missing while condition.\n"); - } - newblock; - } else if (eq(wlist->wl_word, "dowhile")) { - cend[stackp]->co_type = CO_DOWHILE; - cend[stackp]->co_cond = wlist->wl_next; - if (!cend[stackp]->co_cond) { - fprintf(stderr, - "Error: missing dowhile condition.\n"); - } - newblock; - } else if (eq(wlist->wl_word, "repeat")) { - cend[stackp]->co_type = CO_REPEAT; - if (!wlist->wl_next) { - cend[stackp]->co_numtimes = -1; - } else { - char *s; - double *dd; - wlist = cp_variablesubst(cp_bquote( - cp_doglob(wl_copy(wlist)))); - s = wlist->wl_next->wl_word; - - dd = ft_numparse(&s, FALSE); - if (dd) { - if (*dd < 0) { - fprintf(cp_err, - "Error: can't repeat a negative number of times\n"); - *dd = 0.0; - } - cend[stackp]->co_numtimes = (int) *dd; - } else - fprintf(cp_err, - "Error: bad repeat argument %s\n", - wlist->wl_next->wl_word); - } - newblock; - } else if (eq(wlist->wl_word, "if")) { - cend[stackp]->co_type = CO_IF; - cend[stackp]->co_cond = wlist->wl_next; - if (!cend[stackp]->co_cond) { - fprintf(stderr, - "Error: missing if condition.\n"); - } - newblock; - } else if (eq(wlist->wl_word, "foreach")) { - cend[stackp]->co_type = CO_FOREACH; - if (wlist->wl_next) { - wlist = wlist->wl_next; - cend[stackp]->co_foreachvar = - copy(wlist->wl_word); - wlist = wlist->wl_next; - } else - fprintf(stderr, - "Error: missing foreach variable.\n"); - wlist = cp_doglob(wlist); - cend[stackp]->co_text = wl_copy(wlist); - newblock; - } else if (eq(wlist->wl_word, "label")) { - cend[stackp]->co_type = CO_LABEL; - if (wlist->wl_next) { - cend[stackp]->co_text = wl_copy(wlist->wl_next); - /* I think of everything, don't I? */ - cp_addkword(CT_LABEL, wlist->wl_next->wl_word); - if (wlist->wl_next->wl_next) - fprintf(cp_err, - "Warning: ignored extra junk after label.\n"); - } else - fprintf(stderr, "Error: missing label.\n"); - } else if (eq(wlist->wl_word, "goto")) { - /* Incidentally, this won't work if the values 1 and - * 2 ever get to be valid character pointers -- I - * think it's reasonably safe to assume they aren't... - */ - cend[stackp]->co_type = CO_GOTO; - if (wlist->wl_next) { - cend[stackp]->co_text = wl_copy(wlist->wl_next); - if (wlist->wl_next->wl_next) - fprintf(cp_err, - "Warning: ignored extra junk after goto.\n"); - } else - fprintf(stderr, "Error: missing label.\n"); - } else if (eq(wlist->wl_word, "continue")) { - cend[stackp]->co_type = CO_CONTINUE; - if (wlist->wl_next) { - cend[stackp]->co_numtimes = scannum(wlist-> - wl_next->wl_word); - if (wlist->wl_next->wl_next) - fprintf(cp_err, - "Warning: ignored extra junk after continue %d.\n", - cend[stackp]->co_numtimes); - } else - cend[stackp]->co_numtimes = 1; - } else if (eq(wlist->wl_word, "break")) { - cend[stackp]->co_type = CO_BREAK; - if (wlist->wl_next) { - cend[stackp]->co_numtimes = scannum(wlist-> - wl_next->wl_word); - if (wlist->wl_next->wl_next) - fprintf(cp_err, - "Warning: ignored extra junk after break %d.\n", - cend[stackp]->co_numtimes); - } else - cend[stackp]->co_numtimes = 1; - } else if (eq(wlist->wl_word, "end")) { - /* Throw away this thing. */ - if (!cend[stackp]->co_parent) { - fprintf(stderr, "Error: no block to end.\n"); - cend[stackp]->co_type = CO_UNFILLED; - } else if (cend[stackp]->co_prev) { - cend[stackp]->co_prev->co_next = NULL; - x = cend[stackp]; - cend[stackp] = cend[stackp]->co_parent; - tfree(x); - } else { - x = cend[stackp]; - cend[stackp] = cend[stackp]->co_parent; - cend[stackp]->co_children = NULL; - tfree(x); - } - } else if (eq(wlist->wl_word, "else")) { - if (!cend[stackp]->co_parent || - (cend[stackp]->co_parent->co_type != - CO_IF)) { - fprintf(stderr, "Error: misplaced else.\n"); - cend[stackp]->co_type = CO_UNFILLED; - } else { - if (cend[stackp]->co_prev) - cend[stackp]->co_prev->co_next = NULL; - else - cend[stackp]->co_parent->co_children = - NULL; - cend[stackp]->co_parent->co_elseblock = - cend[stackp]; - cend[stackp]->co_prev = NULL; - } - } else { - cend[stackp]->co_type = CO_STATEMENT; - cend[stackp]->co_text = wlist; - } - if (!cend[stackp]->co_parent) { - x = cend[stackp]; - /* We have to toss this do-while loop in here so - * that gotos at the top level will work. - */ - do { - i = doblock(x, &nn); - switch (*i) { - case NORMAL: - break; - case BROKEN: - fprintf(cp_err, - "Error: break not in loop or too many break levels given\n"); - break; - case CONTINUED: - fprintf(cp_err, - "Error: continue not in loop or too many continue levels given\n"); - break; - default: - x = findlabel(i, - control[stackp]); - if (!x) - fprintf(cp_err, - "Error: label %s not found\n", - i); - } - if (x) - x = x->co_next; - } while (x); - } - if (string) - return (1); /* The return value is irrelevant. */ - } -} - -/* Execute a block. There can be a number of return values from this routine. - * NORMAL indicates a normal termination - * BROKEN indicates a break -- if the caller is a breakable loop, - * terminate it, otherwise pass the break upwards - * CONTINUED indicates a continue -- if the caller is a continuable loop, - * continue, else pass the continue upwards - * Any other return code is considered a pointer to a string which is - * a label somewhere -- if this label is present in the block, - * goto it, otherwise pass it up. Note that this prevents jumping - * into a loop, which is good. - * Note that here is where we expand variables, ``, and globs for controls. - * The 'num' argument is used by break n and continue n. - */ - -static char * -doblock(struct control *bl, int *num) -{ - struct control *ch, *cn = NULL; - wordlist *wl; - char *i; - int nn; - - switch (bl->co_type) { - - case CO_WHILE: - while (bl->co_cond && cp_isTRUE(bl->co_cond)) { - for (ch = bl->co_children; ch; ch = cn) { - cn = ch->co_next; - i = doblock(ch, &nn); - switch (*i) { - - case NORMAL: - break; - - case BROKEN: /* Break. */ - if (nn < 2) - return (NORMAL_STR); - else { - *num = nn - 1; - return (BROKEN_STR); - } - - case CONTINUED: /* Continue. */ - if (nn < 2) { - cn = NULL; - break; - } else { - *num = nn - 1; - return (CONTINUED_STR); - } - - default: - cn = findlabel(i, bl->co_children); - if (!cn) - return (i); - } - } - } - break; - - case CO_DOWHILE: - do { - for (ch = bl->co_children; ch; ch = cn) { - cn = ch->co_next; - i = doblock(ch, &nn); - switch (*i) { - - case NORMAL: - break; - - case BROKEN: /* Break. */ - if (nn < 2) - return (NORMAL_STR); - else { - *num = nn - 1; - return (BROKEN_STR); - } - - case CONTINUED: /* Continue. */ - if (nn < 2) { - cn = NULL; - break; - } else { - *num = nn - 1; - return (CONTINUED_STR); - } - - default: - cn = findlabel(i, bl->co_children); - if (!cn) - return (i); - } - } - } while (bl->co_cond && cp_isTRUE(bl->co_cond)); - break; - - case CO_REPEAT: - while ((bl->co_numtimes > 0) || - (bl->co_numtimes == -1)) { - if (bl->co_numtimes != -1) - bl->co_numtimes--; - for (ch = bl->co_children; ch; ch = cn) { - cn = ch->co_next; - i = doblock(ch, &nn); - switch (*i) { - - case NORMAL: - break; - - case BROKEN: /* Break. */ - if (nn < 2) - return (NORMAL_STR); - else { - *num = nn - 1; - return (BROKEN_STR); - } - - case CONTINUED: /* Continue. */ - if (nn < 2) { - cn = NULL; - break; - } else { - *num = nn - 1; - return (CONTINUED_STR); - } - - default: - cn = findlabel(i, bl->co_children); - if (!cn) - return (i); - } - } - } - break; - - case CO_IF: - if (bl->co_cond && cp_isTRUE(bl->co_cond)) { - for (ch = bl->co_children; ch; ch = cn) { - cn = ch->co_next; - i = doblock(ch, &nn); - if (*i > 2) { - cn = findlabel(i, - bl->co_children); - if (!cn) - return (i); - } else if (*i != NORMAL) { - *num = nn; - return (i); - } - } - } else { - for (ch = bl->co_elseblock; ch; ch = cn) { - cn = ch->co_next; - i = doblock(ch, &nn); - if (*i > 2) { - cn = findlabel(i, - bl->co_elseblock); - if (!cn) - return (i); - } else if (*i != NORMAL) { - *num = nn; - return (i); - } - } - } - break; - - case CO_FOREACH: - for (wl = cp_variablesubst(cp_bquote(cp_doglob(wl_copy(bl-> - co_text)))); wl; wl = wl->wl_next) { - cp_vset(bl->co_foreachvar, VT_STRING, - wl->wl_word); - for (ch = bl->co_children; ch; ch = cn) { - cn = ch->co_next; - i = doblock(ch, &nn); - switch (*i) { - - case NORMAL: - break; - - case BROKEN: /* Break. */ - if (nn < 2) - return (NORMAL_STR); - else { - *num = nn - 1; - return (BROKEN_STR); - } - - case CONTINUED: /* Continue. */ - if (nn < 2) { - cn = NULL; - break; - } else { - *num = nn - 1; - return (CONTINUED_STR); - } - - default: - cn = findlabel(i, bl->co_children); - if (!cn) - return (i); - } - } - } - break; - - case CO_BREAK: - if (bl->co_numtimes > 0) { - *num = bl->co_numtimes; - return (BROKEN_STR); - } else { - fprintf(cp_err, "Warning: break %d a no-op\n", - bl->co_numtimes); - return (NORMAL_STR); - } - - case CO_CONTINUE: - if (bl->co_numtimes > 0) { - *num = bl->co_numtimes; - return (CONTINUED_STR); - } else { - fprintf(cp_err, "Warning: continue %d a no-op\n", - bl->co_numtimes); - return (NORMAL_STR); - } - - case CO_GOTO: - wl = cp_variablesubst(cp_bquote(cp_doglob( - wl_copy(bl->co_text)))); - return (wl->wl_word); - - case CO_LABEL: - /* Do nothing. */ - break; - - case CO_STATEMENT: - docommand(wl_copy(bl->co_text)); - break; - - case CO_UNFILLED: - /* There was probably an error here... */ - fprintf(cp_err, "Warning: ignoring previous error\n"); - break; - - default: - fprintf(cp_err, - "doblock: Internal Error: bad block type %d\n", - bl->co_type); - return (NORMAL_STR); - } - return (NORMAL_STR); -} -static struct control * -findlabel(char *s, struct control *ct) -{ - while (ct) { - if ((ct->co_type == CO_LABEL) && eq(s, ct->co_text->wl_word)) - break; - ct = ct->co_next; - } - return (ct); -} - -/* This blows away the control structures... */ - -void -cp_resetcontrol(void) -{ - if (cend[stackp] && cend[stackp]->co_parent) - fprintf(cp_err, "Warning: EOF before block terminated\n"); - /* We probably should free the control structures... */ - control[0] = cend[0] = NULL; - stackp = 0; - (void) cp_kwswitch(CT_LABEL, (char *) NULL); - return; -} - -/* Push or pop a new control structure set... */ - -void -cp_popcontrol(void) -{ - if (cp_debug) - fprintf(cp_err, "pop: stackp: %d -> %d\n", stackp, stackp - 1); - if (stackp < 1) - fprintf(cp_err, "cp_popcontrol: Internal Error: stack empty\n"); - else - stackp--; - return; -} - -void -cp_pushcontrol(void) -{ - if (cp_debug) - fprintf(cp_err, "push: stackp: %d -> %d\n", stackp, stackp + 1); - if (stackp > CONTROLSTACKSIZE - 2) { - fprintf(cp_err, "Error: stack overflow -- max depth = %d\n", - CONTROLSTACKSIZE); - stackp = 0; - } else { - stackp++; - control[stackp] = cend[stackp] = NULL; - } - return; -} - -/* And this returns to the top level (for use in the interrupt handlers). */ - -void -cp_toplevel(void) -{ - stackp = 0; - if (cend[stackp]) - while (cend[stackp]->co_parent) - cend[stackp] = cend[stackp]->co_parent; - return; -} - -/* Note that we only do io redirection when we get to here - we also - * postpone some other things until now. - */ - -static void -docommand(register wordlist *wlist) -{ - register char *r, *s, *t; - char *lcom; - int nargs; - register int i; - struct comm *command; - wordlist *wl, *nextc, *ee, *rwlist; - - if (cp_debug) { - printf("docommand "); - wl_print(wlist, stdout); - (void) putc('\n', stdout); - } - - /* Do all the things that used to be done by cshpar when the line - * was read... - */ - wlist = cp_variablesubst(wlist); - pwlist(wlist, "After variable substitution"); - - wlist = cp_bquote(wlist); - pwlist(wlist, "After backquote substitution"); - - wlist = cp_doglob(wlist); - pwlist(wlist, "After globbing"); - - if (!wlist || !wlist->wl_word) - return; - - /* Now loop through all of the commands given. */ - rwlist = wlist; - do { - for (nextc = wlist; nextc; nextc = nextc->wl_next) - if (eq(nextc->wl_word, cp_csep)) - break; - - /* Temporarily hide the rest of the command... */ - if (nextc && nextc->wl_prev) - nextc->wl_prev->wl_next = NULL; - ee = wlist->wl_prev; - if (ee) - wlist->wl_prev = NULL; - - if (nextc == wlist) { - /* There was no text... */ - goto out; - } - - /* And do the redirection. */ - cp_ioreset(); - for (i = 0; noredirect[i]; i++) - if (eq(wlist->wl_word, noredirect[i])) - break; - if (!noredirect[i]) { - if (!(wlist = cp_redirect(wlist))) { - cp_ioreset(); - return; - } - } - - /* Get rid of all the 8th bits now... */ - cp_striplist(wlist); - - s = wlist->wl_word; - - /* Look for the command in the command list. */ - for (i = 0; cp_coms[i].co_comname; i++) { - /* strcmp(cp_coms[i].co_comname, s) ... */ - for (t = cp_coms[i].co_comname, r = s; *t && *r; - t++, r++) - if (*t != *r) - break; - if (!*t && !*r) - break; - } - - /* Now give the user-supplied command routine a try... */ - if (!cp_coms[i].co_func && cp_oddcomm(s, wlist->wl_next)) - goto out; - - /* If it's not there, try it as a unix command. */ - if (!cp_coms[i].co_comname) { - if (cp_dounixcom && cp_unixcom(wlist)) - goto out; - fprintf(cp_err,"%s: no such command available in %s\n", - s, cp_program); - goto out; - - /* If it's there but spiceonly, and this is nutmeg, error. */ - } else if (!cp_coms[i].co_func && ft_nutmeg && - (cp_coms[i].co_spiceonly)) { - fprintf(cp_err,"%s: command available only in spice\n", - s); - goto out; - } - - /* The command was a valid spice/nutmeg command. */ - command = &cp_coms[i]; - nargs = 0; - for (wl = wlist->wl_next; wl; wl = wl->wl_next) - nargs++; - if (command->co_stringargs) { - lcom = wl_flatten(wlist->wl_next); - (*command->co_func) (lcom); - } else { - if (nargs < command->co_minargs) { - if (command->co_argfn) { - (*command->co_argfn) (wlist->wl_next, command); - } else { - fprintf(cp_err, "%s: too few args.\n", s); - } - } else if (nargs > command->co_maxargs) { - fprintf(cp_err, "%s: too many args.\n", s); - } else - (*command->co_func) (wlist->wl_next); - } - - /* Now fix the pointers and advance wlist. */ -out: wlist->wl_prev = ee; - if (nextc) { - if (nextc->wl_prev) - nextc->wl_prev->wl_next = nextc; - wlist = nextc->wl_next; - } - } while (nextc && wlist); - - wl_free(rwlist); - - /* Do periodic sorts of things... */ - cp_periodic(); - - cp_ioreset(); - return; -} - -/* Get a command. This does all the bookkeeping things like turning - * command completion on and off... - */ - -static wordlist * -getcommand(char *string) -{ - wordlist *wlist; - int i = 0, j; - static char buf[64]; - struct control *c; - - if (cp_debug) - fprintf(cp_err, "calling getcommand %s\n", - string ? string : ""); - if (cend[stackp]) { - for (c = cend[stackp]->co_parent; c; c = c->co_parent) - i++; - if (i) { - for (j = 0; j < i; j++) - buf[j] = '>'; - buf[j] = ' '; - buf[j + 1] = '\0'; - cp_altprompt = buf; - } else - cp_altprompt = NULL; - } else - cp_altprompt = NULL; - - cp_cwait = TRUE; - wlist = cp_parse(string); - cp_cwait = FALSE; - if (cp_debug) { - printf("getcommand "); - wl_print(wlist, stdout); - (void) putc('\n', stdout); - } - return (wlist); -} - -/* This is also in cshpar.c ... */ - -static void -pwlist(wordlist *wlist, char *name) -{ - wordlist *wl; - - if (!cp_debug) - return; - fprintf(cp_err, "%s : [ ", name); - for (wl = wlist; wl; wl = wl->wl_next) - fprintf(cp_err, "%s ", wl->wl_word); - fprintf(cp_err, "]\n"); - return; -} - -static int indent; - - -void -com_cdump(wordlist *wl) -{ - struct control *c; - - indent = 0; - for (c = control[stackp]; c; c = c->co_next) - dodump(c); - return; -} - -#define tab(num) for (i = 0; i < num; i++) (void) putc(' ', cp_out); - -static void -dodump(struct control *cc) -{ - int i; - struct control *tc; - - switch (cc->co_type) { - case CO_UNFILLED: - tab(indent); - fprintf(cp_out, "(unfilled)\n"); - break; - case CO_STATEMENT: - tab(indent); - wl_print(cc->co_text, cp_out); - (void) putc('\n', cp_out); - break; - case CO_WHILE: - tab(indent); - fprintf(cp_out, "while "); - wl_print(cc->co_cond, cp_out); - (void) putc('\n', cp_out); - indent += 8; - for (tc = cc->co_children; tc; tc = tc->co_next) - dodump(tc); - indent -= 8; - tab(indent); - fprintf(cp_out, "end\n"); - break; - case CO_REPEAT: - tab(indent); - fprintf(cp_out, "repeat "); - if (cc->co_numtimes != -1) - fprintf(cp_out, "%d\n", cc->co_numtimes); - else - (void) putc('\n', cp_out); - indent += 8; - for (tc = cc->co_children; tc; tc = tc->co_next) - dodump(tc); - indent -= 8; - tab(indent); - fprintf(cp_out, "end\n"); - break; - case CO_DOWHILE: - tab(indent); - fprintf(cp_out, "dowhile "); - wl_print(cc->co_cond, cp_out); - (void) putc('\n', cp_out); - indent += 8; - for (tc = cc->co_children; tc; tc = tc->co_next) - dodump(tc); - indent -= 8; - tab(indent); - fprintf(cp_out, "end\n"); - break; - case CO_IF: - tab(indent); - fprintf(cp_out, "if "); - wl_print(cc->co_cond, cp_out); - (void) putc('\n', cp_out); - indent += 8; - for (tc = cc->co_children; tc; tc = tc->co_next) - dodump(tc); - indent -= 8; - tab(indent); - fprintf(cp_out, "end\n"); - break; - case CO_FOREACH: - tab(indent); - fprintf(cp_out, "foreach %s ", cc->co_foreachvar); - wl_print(cc->co_text, cp_out); - (void) putc('\n', cp_out); - indent += 8; - for (tc = cc->co_children; tc; tc = tc->co_next) - dodump(tc); - indent -= 8; - tab(indent); - fprintf(cp_out, "end\n"); - break; - case CO_BREAK: - tab(indent); - if (cc->co_numtimes != 1) - fprintf(cp_out, "break %d\n", cc->co_numtimes); - else - fprintf(cp_out, "break\n"); - break; - case CO_CONTINUE: - tab(indent); - if (cc->co_numtimes != 1) - fprintf(cp_out, "continue %d\n", - cc->co_numtimes); - else - fprintf(cp_out, "continue\n"); - break; - case CO_LABEL: - tab(indent); - fprintf(cp_out, "label %s\n", cc->co_text->wl_word); - break; - case CO_GOTO: - tab(indent); - fprintf(cp_out, "goto %s\n", cc->co_text->wl_word); - break; - default: - tab(indent); - fprintf(cp_out, "bad type %d\n", cc->co_type); - break; - } - return; -} - diff --git a/src/parser/front.h b/src/parser/front.h deleted file mode 100644 index b261bf57d..000000000 --- a/src/parser/front.h +++ /dev/null @@ -1,40 +0,0 @@ -/************* - * Header file for front.c - * 1999 E. Rouat - ************/ - -#ifndef FRONT_H_INCLUDED -#define FRONT_H_INCLUDED - -/* Stuff to do control structures. We keep a history (seperate from the - * cshpar history, for now at least) of commands and their event numbers, - * with a block considered as a statement. In a goto, the first word in - * co_text is where to go, likewise for label. For conditional controls, - * we have to call ft_getpnames and ft_evaluate each time, since the - * dvec pointers will change... Also we should do variable and backquote - * substitution each time... - */ - -struct control { - int co_type; /* One of CO_* ... */ - wordlist *co_cond; /* if, while, dowhile */ - char *co_foreachvar; /* foreach */ - int co_numtimes; /* repeat, break & continue levels */ - wordlist *co_text; /* Ordinary text and foreach values. */ - struct control *co_parent; /* If this is inside a block. */ - struct control *co_children; /* The contents of this block. */ - struct control *co_elseblock; /* For if-then-else. */ - struct control *co_next; - struct control *co_prev; -} ; - -int cp_evloop(char *string); -void cp_resetcontrol(void); -void cp_popcontrol(void); -void cp_pushcontrol(void); -void cp_toplevel(void); -void com_cdump(wordlist *wl); - - - -#endif diff --git a/src/parser/glob.c b/src/parser/glob.c deleted file mode 100644 index e58d1f1f3..000000000 --- a/src/parser/glob.c +++ /dev/null @@ -1,97 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Expand global characters. - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include "glob.h" - -#ifdef HAVE_SYS_DIR_H -#include -#include -#else - -#ifdef HAVE_DIRENT_H -#include -#include -#ifndef direct -#define direct dirent -#endif -#endif - -#endif - -#ifdef HAVE_PWD_H -#include -#endif - - - -bool noglobs(); - -char cp_comma = ','; -char cp_til = '~'; - -/* For each word, go through two steps: expand the {}'s, and then do ?*[] - * globbing in them. Sort after the second phase but not the first... - */ - -/* MW. Now only tilde is supportef, {}*? don't work */ - -wordlist * -cp_doglob(wordlist *wlist) -{ - wordlist *wl; - char *s; - - - /* Do tilde expansion. */ - - for (wl = wlist; wl; wl = wl->wl_next) - if (*wl->wl_word == cp_til) { - s = cp_tildexpand(wl->wl_word); - if (!s) - *wl->wl_word = '\0'; /* MW. We Con't touch malloc addres */ - else - wl->wl_word = s; - } - - return (wlist); -} - -/* Expand tildes. */ - -char * -cp_tildexpand(char *string) -{ - char *result; - - result = tilde_expand(string); - - if (!result) { - if (cp_nonomatch) { - return copy(string); - } else { - return NULL; - } - } - return result; -} - - -/* Say whether the pattern p can match the string s. */ - -/* MW. Now simply compare strings */ - -bool -cp_globmatch(char *p, char *s) -{ - return(!(strcmp(p, s))); -} - diff --git a/src/parser/glob.h b/src/parser/glob.h deleted file mode 100644 index 01f73ce66..000000000 --- a/src/parser/glob.h +++ /dev/null @@ -1,14 +0,0 @@ -/************* - * Header file for glob.c - * 1999 E. Rouat - ************/ - -#ifndef GLOB_H_INCLUDED -#define GLOB_H_INCLUDED - -wordlist * cp_doglob(wordlist *wlist); -char * cp_tildexpand(char *string); -bool cp_globmatch(char *p, char *s); - - -#endif diff --git a/src/parser/history.c b/src/parser/history.c deleted file mode 100644 index 3fd80a272..000000000 --- a/src/parser/history.c +++ /dev/null @@ -1,489 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Do history substitutions. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "history.h" - - -/* static declarations */ -static wordlist * dohsubst(char *string); -static wordlist * dohmod(char **string, wordlist *wl); -static wordlist * hpattern(char *buf); -static wordlist * hprefix(char *buf); -static wordlist * getevent(int num); -static void freehist(int num); -static char * dohs(char *pat, char *str); - - -struct histent *cp_lastone = NULL; -int cp_maxhistlength = 10000; /* Chris Inbody */ -char cp_hat = '^'; -char cp_bang = '!'; -bool cp_didhsubst; - -static struct histent *histlist = NULL; -static int histlength = 0; - -/* First check for a ^ at the beginning - * of the line, and then search each word for !. Following this can be any - * of string, number, ?string, -number ; then there may be a word specifier, - * the same as csh, and then the : modifiers. For the :s modifier, - * the syntax is :sXoooXnnnX, where X is any character, and ooo and nnn are - * strings not containing X. - */ - -wordlist * -cp_histsubst(wordlist *wlist) -{ - wordlist *nwl, *w, *n; - char buf[BSIZE_SP], *s, *b; - - /* Replace ^old^new with !:s^old^new. */ - - cp_didhsubst = FALSE; - if (*wlist->wl_word == cp_hat) { - (void) sprintf(buf, "%c%c:s%s", cp_bang, cp_bang, - wlist->wl_word); - tfree(wlist->wl_word); - wlist->wl_word = copy(buf); - } - for (w = wlist; w; w = w->wl_next) { - b = w->wl_word; - for (s = b; *s; s++) - if (*s == cp_bang) { - cp_didhsubst = TRUE; - n = dohsubst(s + 1); - if (!n) { - wlist->wl_word = NULL; - return (wlist); - } - if (b < s) { - (void) sprintf(buf, "%.*s%s", s - b, b, - n->wl_word); - tfree(n->wl_word); - n->wl_word = copy(buf); - } - nwl = wl_splice(w, n); - if (wlist == w) - wlist = n; - w = nwl; - break; - } - } - return (wlist); -} - -/* Do a history substitution on one word. Figure out which event is - * being referenced, then do word selections and modifications, and - * then stick anything left over on the end of the last word. - */ - -static wordlist * -dohsubst(char *string) -{ - wordlist *wl, *nwl; - char buf[BSIZE_SP], *s, *r = NULL, *t; - - if (*string == cp_bang) { - if (cp_lastone) { - wl = cp_lastone->hi_wlist; - string++; - } else { - fprintf(cp_err, "0: event not found.\n"); - return (NULL); - } - } else { - switch(*string) { - - case '-': - wl = getevent(cp_event - scannum(++string)); - if (!wl) - return (NULL); - while (isdigit(*string)) - string++; - break; - - case '?': - (void) strcpy(buf, string + 1); - if ((s =strchr(buf, '?'))) - *s = '\0'; - wl = hpattern(buf); - if (!wl) - return (NULL); - if (s == NULL) /* No modifiers on this one. */ - return (wl_copy(wl)); - break; - - case '\0': /* Maybe this should be cp_event. */ - wl = alloc(struct wordlist); - wl->wl_word = copy("!"); - wl->wl_next = NULL; - wl->wl_prev = NULL; - cp_didhsubst = FALSE; - return (wl); - - default: - if (isdigit(*string)) { - wl = getevent(scannum(string)); - if (!wl) - return (NULL); - while (isdigit(*string)) - string++; - } else { - (void) strcpy(buf, string); - for (s = ":^$*-%"; *s; s++) { - t =strchr(buf, *s); - if (t && ((t < r) || !r)) { - r = t; - string += r - buf; - } - } - if (r) - *r = '\0'; - else - while (*string) - string++; - if ((buf[0] == '\0') && cp_lastone) - wl = cp_lastone->hi_wlist; - else - wl = hprefix(buf); - if (!wl) - return (NULL); - } - } - } - if (wl == NULL) { /* Shouldn't happen. */ - fprintf(cp_err, "Event not found.\n"); - return (NULL); - } - nwl = dohmod(&string, wl_copy(wl)); - if (!nwl) - return (NULL); - if (*string) { - for (wl = nwl; wl->wl_next; wl = wl->wl_next) - ; - (void) sprintf(buf, "%s%s", wl->wl_word, string); - tfree(wl->wl_word); - wl->wl_word = copy(buf); - } - return (nwl); -} - -static wordlist * -dohmod(char **string, wordlist *wl) -{ - wordlist *w; - char *s; - char *r = NULL, *t; - int numwords, eventlo, eventhi, i; - bool globalsubst; - -anothermod: - numwords = wl_length(wl); - globalsubst = FALSE; - eventlo = 0; - eventhi = numwords - 1; - - /* Now we know what wordlist we want. Take care of modifiers now. */ - r = NULL; - for (s = ":^$*-%"; *s; s++) { - t =strchr(*string, *s); - if (t && ((t < r) || (r == NULL))) - r = t; - } - if (!r) /* No more modifiers. */ - return (wl); - - *string = r; - if (**string == ':') - (*string)++; - - switch(**string) { - case '$': /* Last word. */ - eventhi = eventlo = numwords - 1; - break; - case '*': /* Words 1 through $ */ - if (numwords == 1) - return (NULL); - eventlo = 1; - eventhi = numwords - 1; - break; - case '-': /* Words 0 through ... */ - eventlo = 0; - if (*(*string + 1)) - eventhi = scannum(*string + 1); - else - eventhi = numwords - 1; - if (eventhi > numwords - 1) - eventhi = numwords - 1; - break; - case 'p': /* Print the command and don't execute it. - * This doesn't work quite like csh. - */ - wl_print(wl, cp_out); - (void) putc('\n', cp_out); - return (NULL); - case 's': /* Do a substitution. */ - for (w = wl; w; w = w->wl_next) { - s = dohs(*string + 1, w->wl_word); - if (s) { - tfree(w->wl_word); - w->wl_word = s; - if (globalsubst == FALSE) { - while (**string) - (*string)++; - break; - } - } - } - /* In case globalsubst is TRUE... */ - while (**string) - (*string)++; - break; - default: - if (!isdigit(**string)) { - fprintf(cp_err, "Error: %s: bad modifier.\n", - *string); - return (NULL); - } - i = scannum(*string); - if (i > eventhi) { - fprintf(cp_err, "Error: bad event number %d\n", - i); - return (NULL); - } - eventhi = eventlo = i; - while (isdigit(**string)) - (*string)++; - if (**string == '*') - eventhi = numwords - 1; - if (**string == '-') { - if (!isdigit(*(*string + 1))) - eventhi = numwords - 1; - else { - eventhi = scannum(++*string); - while (isdigit(**string)) - (*string)++; - } - } - } - /* Now change the word list accordingly and make another pass - * if there is more of the substitute left. - */ - - wl = wl_range(wl, eventlo, eventhi); - numwords = wl_length(wl); - if (**string && *++*string) - goto anothermod; - return (wl); -} - -/* Look for an event with a pattern in it... */ - -static wordlist * -hpattern(char *buf) -{ - struct histent *hi; - wordlist *wl; - - if (*buf == '\0') { - fprintf(cp_err, "Bad pattern specification.\n"); - return (NULL); - } - for (hi = cp_lastone; hi; hi = hi->hi_prev) - for (wl = hi->hi_wlist; wl; wl = wl->wl_next) - if (substring(buf, wl->wl_word)) - return (hi->hi_wlist); - fprintf(cp_err, "%s: event not found.\n", buf); - return (NULL); -} - -static wordlist * -hprefix(char *buf) -{ - struct histent *hi; - - if (*buf == '\0') { - fprintf(cp_err, "Bad pattern specification.\n"); - return (NULL); - } - for (hi = cp_lastone; hi; hi = hi->hi_prev) - if (hi->hi_wlist && prefix(buf, hi->hi_wlist->wl_word)) - return (hi->hi_wlist); - fprintf(cp_err, "%s: event not found.\n", buf); - return (NULL); -} - -/* Add a wordlist to the history list. (Done after the first parse.) Note - * that if event numbers are given in a random order that's how they'll - * show up in the history list. - */ - -void -cp_addhistent(int event, wordlist *wlist) -{ - if (cp_lastone && !cp_lastone->hi_wlist) - fprintf(cp_err, "Internal error: bad history list\n"); - if (cp_lastone == NULL) { - cp_lastone = histlist = alloc(struct histent); - cp_lastone->hi_prev = NULL; - } else { - cp_lastone->hi_next = alloc(struct histent); - cp_lastone->hi_next->hi_prev = cp_lastone; - cp_lastone = cp_lastone->hi_next; - } - cp_lastone->hi_next = NULL; - cp_lastone->hi_event = event; - cp_lastone->hi_wlist = wl_copy(wlist); - freehist(histlength - cp_maxhistlength); - histlength++; - return; -} - -/* Get a copy of the wordlist associated with an event. Error if out - * of range. - */ - -static wordlist * -getevent(int num) -{ - struct histent *hi; - - for (hi = histlist; hi; hi = hi->hi_next) - if (hi->hi_event == num) - break; - if (hi == NULL) { - fprintf(cp_err, "%d: event not found.\n", num); - return (NULL); - } - return (wl_copy(hi->hi_wlist)); -} - -/* Print out history between eventhi and eventlo. - * This doesn't remember quoting, so 'hodedo' prints as hodedo. - */ - -void -cp_hprint(int eventhi, int eventlo, bool rev) -{ - struct histent *hi; - - if (rev) { - for (hi = histlist; hi->hi_next; hi = hi->hi_next) - ; - for (; hi; hi = hi->hi_prev) - if ((hi->hi_event <= eventhi) && - (hi->hi_event >= eventlo) && - hi->hi_wlist) { - fprintf(cp_out, "%d\t", hi->hi_event); - wl_print(hi->hi_wlist, cp_out); - (void) putc('\n', cp_out); - } - } else { - for (hi = histlist; hi; hi = hi->hi_next) - if ((hi->hi_event <= eventhi) && - (hi->hi_event >= eventlo) && - hi->hi_wlist) { - fprintf(cp_out, "%d\t", hi->hi_event); - wl_print(hi->hi_wlist, cp_out); - (void) putc('\n', cp_out); - } - } - return; -} - -/* This just gets rid of the first num entries on the history list, and - * decrements histlength. - */ - -static void -freehist(int num) -{ - struct histent *hi; - - if (num < 1) - return; - histlength -= num; - hi = histlist; - while (num-- && histlist->hi_next) - histlist = histlist->hi_next; - if (histlist->hi_prev) { - histlist->hi_prev->hi_next = NULL; - histlist->hi_prev = NULL; - } else - { - fprintf(cp_err, "Internal error: history list mangled\n"); - exit(0); /* Chris Inbody */ - } - while (hi->hi_next) { - wl_free(hi->hi_wlist); - hi = hi->hi_next; - tfree(hi->hi_prev); - } - wl_free(hi->hi_wlist); - tfree(hi); - return; -} - -/* Do a :s substitution. */ - -static char * -dohs(char *pat, char *str) -{ - char schar, *s, *p, buf[BSIZE_SP]; - int i = 0, plen; - bool ok = FALSE; - - pat = copy(pat); /* Don't want to mangle anything. */ - schar = *pat++; - s =strchr(pat, schar); - if (s == NULL) { - fprintf(cp_err, "Bad substitute.\n"); - return (NULL); - } - *s++ = '\0'; - p =strchr(s, schar); - if (p) - *p = '\0'; - plen = strlen(pat) - 1; - for (i = 0; *str; str++) { - if ((*str == *pat) && prefix(pat, str) && (ok == FALSE)) { - for (p = s; *p; p++) - buf[i++] = *p; - str += plen; - ok = TRUE; - } else - buf[i++] = *str; - } - buf[i] = '\0'; - if (ok) - return (copy(buf)); - else - return (NULL); -} - -/* The "history" command. history [-r] [number] */ - -void -com_history(wordlist *wl) -{ - bool rev = FALSE; - - if (wl && eq(wl->wl_word, "-r")) { - wl = wl->wl_next; - rev = TRUE; - } - if (wl == NULL) - cp_hprint(cp_event - 1, cp_event - histlength, rev); - else - cp_hprint(cp_event - 1, cp_event - 1 - atoi(wl->wl_word), rev); - return; -} - diff --git a/src/parser/history.h b/src/parser/history.h deleted file mode 100644 index a98a3ab25..000000000 --- a/src/parser/history.h +++ /dev/null @@ -1,16 +0,0 @@ -/************* - * Header file for history.c - * 1999 E. Rouat - ************/ - -#ifndef HISTORY_H_INCLUDED -#define HISTORY_H_INCLUDED - -wordlist * cp_histsubst(wordlist *wlist); -void cp_addhistent(int event, wordlist *wlist); -void cp_hprint(int eventhi, int eventlo, bool rev); -void com_history(wordlist *wl); - - - -#endif diff --git a/src/parser/input.c b/src/parser/input.c deleted file mode 100644 index 71ff3032e..000000000 --- a/src/parser/input.c +++ /dev/null @@ -1,33 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1988 Jeffrey M. Hsu -**********/ - -/* - * Stand-alone input routine. - */ - -#include "ngspice.h" -#include "fteinput.h" -#include "input.h" - - -extern int inchar(FILE *fp); - -void -Input(REQUEST *request, RESPONSE *response) -{ - - switch (request->option) { - case char_option: - response->reply.ch = inchar(request->fp); - response->option = request->option; - break; - default: - /* just ignore, since we don't want a million error messages */ - response->option = error_option; - break; - } - return; - -} diff --git a/src/parser/input.h b/src/parser/input.h deleted file mode 100644 index 25c9f88f3..000000000 --- a/src/parser/input.h +++ /dev/null @@ -1,13 +0,0 @@ -/************* - * Header file for input.c - * 1999 E. Rouat - ************/ - -#ifndef INPUT_H_INCLUDED -#define INPUT_H_INCLUDED - - -void Input(REQUEST *request, RESPONSE *response); - - -#endif diff --git a/src/parser/lexical.c b/src/parser/lexical.c deleted file mode 100644 index 5c0d8e8b0..000000000 --- a/src/parser/lexical.c +++ /dev/null @@ -1,368 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Initial lexer. - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_PWD_H -#include -#include -#endif - - /* MW. Linux has TIOCSTI, so we include all headers here */ -#include - -#ifdef HAVE_SGTTY_H -#include -#include -#else -#ifdef HAVE_TERMIO_H -#include -#include -#else -#ifdef HAVE_TERMIOS_H -#include -#include -#endif -#endif -#endif - - -#include "fteinput.h" -#include "lexical.h" - -static void prompt(void); - - -FILE *cp_inp_cur = NULL; -int cp_event = 1; -bool cp_interactive = TRUE; -bool cp_bqflag = FALSE; -char *cp_promptstring = NULL; -char *cp_altprompt = NULL; -char cp_hash = '#'; - -static int numeofs = 0; - - -extern void Input(); - -#define ESCAPE '\033' - -/* Return a list of words, with backslash quoting and '' quoting done. - * Strings en(void) closed in "" or `` are made single words and returned, - * but with the "" or `` still present. For the \ and '' cases, the - * 8th bit is turned on (as in csh) to prevent them from being recogized, - * and stripped off once all processing is done. We also have to deal with - * command, filename, and keyword completion here. - * If string is non-NULL, then use it instead of the fp. Escape and EOF - * have no business being in the string. - */ - -#define newword cw->wl_word = copy(buf); \ - cw->wl_next = alloc(struct wordlist); \ - cw->wl_next->wl_prev = cw; \ - cw = cw->wl_next; \ - cw->wl_next = NULL; \ - bzero(buf, BSIZE_SP); \ - i = 0; - -wordlist * -cp_lexer(char *string) -{ - int c; - int i, j; - wordlist *wlist = NULL, *cw = NULL; - char buf[BSIZE_SP], linebuf[BSIZE_SP], d; - int paren; - - if (cp_inp_cur == NULL) - cp_inp_cur = cp_in; - - if (!string && cp_interactive) { - cp_ccon(TRUE); - prompt(); - } -nloop: i = 0; - j = 0; - paren = 0; - bzero(linebuf, BSIZE_SP); - bzero(buf, BSIZE_SP); - wlist = cw = alloc(struct wordlist); - cw->wl_next = cw->wl_prev = NULL; - for (;;) { - if (string) { - c = *string++; - if (c == '\0') - c = '\n'; - if (c == ESCAPE) - c = '['; - } else - c = input(cp_inp_cur); - -gotchar: - if ((c != EOF) && (c != ESCAPE)) - linebuf[j++] = c; - if (c != EOF) - numeofs = 0; - if (i == BSIZE_SP - 1) { - fprintf(cp_err, "Warning: word too long.\n"); - c = ' '; - } - if (j == BSIZE_SP - 1) { - fprintf(cp_err, "Warning: line too long.\n"); - if (cp_bqflag) - c = EOF; - else - c = '\n'; - } - if (c != EOF) - c = strip(c); /* Don't need to do this really. */ - if ((c == '\\' && DIR_TERM != '\\') || (c == '\026') /* ^V */ ) { - c = quote(string ? *string++ : input(cp_inp_cur)); - linebuf[j++] = strip(c); - } - if ((c == '\n') && cp_bqflag) - c = ' '; - if ((c == EOF) && cp_bqflag) - c = '\n'; - if ((c == cp_hash) && !cp_interactive && (j == 1)) { - if (string) - return (NULL); - while (((c = input(cp_inp_cur)) != '\n') && - (c != EOF)); - goto nloop; - } - - if ((c == '(') || (c == '[')) /* MW. Nedded by parse() */ - paren++; - else if ((c == ')') || (c == ']')) - paren--; - - switch (c) { - case ' ': - case '\t': - if (i > 0) { - newword; - } - break; - - case '\n': - if (i) { - buf[i] = '\0'; - cw->wl_word = copy(buf); - } else if (cw->wl_prev) { - cw->wl_prev->wl_next = NULL; - tfree(cw); - } else { - cw->wl_word = NULL; - } - goto done; - - case '\'': - while (((c = (string ? *string++ : - input(cp_inp_cur))) != '\'') - && (i < BSIZE_SP - 1)) { - if ((c == '\n') || (c == EOF) || (c == ESCAPE)) - goto gotchar; - else { - buf[i++] = quote(c); - linebuf[j++] = c; - } - } - linebuf[j++] = '\''; - break; - - case '"': - case '`': - d = c; - buf[i++] = d; - while (((c = (string ? *string++ : input(cp_inp_cur))) - != d) && (i < BSIZE_SP - 2)) { - if ((c == '\n') || (c == EOF) || (c == ESCAPE)) - goto gotchar; - else if (c == '\\') { - linebuf[j++] = c; - c = (string ? *string++ : - input(cp_inp_cur)); - buf[i++] = quote(c); - linebuf[j++] = c; - } else { - buf[i++] = c; - linebuf[j++] = c; - } - } - buf[i++] = d; - linebuf[j++] = d; - break; - - case '\004': - case EOF: - if (cp_interactive && !cp_nocc && - (string == NULL)) { - if (j == 0) { - if (cp_ignoreeof && (numeofs++ - < 23)) { - fputs( - "Use \"quit\" to quit.\n", - stdout); - } else { - fputs("quit\n", stdout); - cp_doquit(); - } - goto done; - } - cp_ccom(wlist, buf, FALSE); - wl_free(wlist); - (void) fputc('\r', cp_out); - prompt(); - for (j = 0; linebuf[j]; j++) -#ifdef TIOCSTI - (void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j); -#else - fputc(linebuf[j], cp_out); /* But you can't edit */ -#endif - goto nloop; - } else /* EOF during a source */ - { - if (cp_interactive) { - fputs("quit\n", stdout); - cp_doquit(); - goto done; - } else - return (NULL); - } - case ESCAPE: - if (cp_interactive && !cp_nocc) { - fputs("\b\b \b\b\r", cp_out); - prompt(); - for (j = 0; linebuf[j]; j++) -#ifdef TIOCSTI - (void) ioctl(fileno(cp_out), TIOCSTI, linebuf + j); -#else - fputc(linebuf[j], cp_out); /* But you can't edit */ -#endif - cp_ccom(wlist, buf, TRUE); - wl_free(wlist); - goto nloop; - } /* Else fall through */ - case ',': - if (paren < 1 && i > 0) { - newword; - break; - } - default: - /* We have to remember the special case $< - * here - */ - if ((cp_chars[c] & CPC_BRL) && (i > 0)) { - if ((c != '<') || (buf[i - 1] != '$')) { - newword; - } - } - buf[i++] = c; - if (cp_chars[c] & CPC_BRR) { - if ((c != '<') || (i < 2) || - (buf[i - 2] != '$')) { - newword; - } - } - } - } -done: - return (wlist); -} - -static void -prompt(void) -{ - char *s; - - if (cp_interactive == FALSE) - return; - if (cp_promptstring == NULL) - s = "-> "; - else - s = cp_promptstring; - if (cp_altprompt) - s = cp_altprompt; -#ifdef notdef - /* XXXX VMS */ - /* this is for VMS/RMS which otherwise won't output the LF - * part of the newline on the previous line if this line - * doesn't also end in newline, and most prompts don't, so... - * we force an extra line here. - */ - fprintf(cp_out,"\n"); -#endif - while (*s) { - switch (strip(*s)) { - case '!': - fprintf(cp_out, "%d", cp_event); - break; - case '\\': - if (*(s + 1)) - (void) putc(strip(*++s), cp_out); - default: - (void) putc(strip(*s), cp_out); - } - s++; - } - (void) fflush(cp_out); - return; -} - - -/* A special 'getc' so that we can deal with ^D properly. There is no way for - * stdio to know if we have typed a ^D after some other characters, so - * don't use buffering at all - */ -int -inchar(FILE *fp) -{ - - char c; - int i; - - if (cp_interactive && !cp_nocc) { - do { - i = read((int) fileno(fp), &c, 1); - } while (i == -1 && errno == EINTR); - if (i == 0 || c == '\004') - return (EOF); - else if (i == -1) { - perror("read"); - return (EOF); - } else - return ((int) c); - } else - c = getc(fp); - return ((int) c); -} - -int -input(FILE *fp) -{ - - REQUEST request; - RESPONSE response; - - request.option = char_option; - request.fp = fp; - Input(&request, &response); - return(response.reply.ch); - -} - diff --git a/src/parser/lexical.h b/src/parser/lexical.h deleted file mode 100644 index cf08fbee9..000000000 --- a/src/parser/lexical.h +++ /dev/null @@ -1,15 +0,0 @@ -/************* - * Header file for lexical.c - * 1999 E. Rouat - ************/ - -#ifndef LEXICAL_H_INCLUDED -#define LEXICAL_H_INCLUDED - - -wordlist * cp_lexer(char *string); -int inchar(FILE *fp); -int input(FILE *fp); - - -#endif diff --git a/src/parser/modify.c b/src/parser/modify.c deleted file mode 100644 index c76bea376..000000000 --- a/src/parser/modify.c +++ /dev/null @@ -1,38 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "modify.h" - - -char cp_chars[128]; - -static char *singlec = "<>;&"; - -/* Initialize stuff. */ - -void -cp_init(void) -{ - char *s, *getenv(const char *); - - bzero(cp_chars, 128); - for (s = singlec; *s; s++) - cp_chars[(int) *s] = (CPC_BRR | CPC_BRL); - cp_vset("history", VT_NUM, (char *) &cp_maxhistlength); - - cp_curin = stdin; - cp_curout = stdout; - cp_curerr = stderr; - - cp_ioreset(); - - return; -} - diff --git a/src/parser/modify.h b/src/parser/modify.h deleted file mode 100644 index db3110874..000000000 --- a/src/parser/modify.h +++ /dev/null @@ -1,13 +0,0 @@ -/************* - * Header file for modify.c - * 1999 E. Rouat - ************/ - -#ifndef MODIFY_H_INCLUDED -#define MODIFY_H_INCLUDED - - -void cp_init(void); - - -#endif diff --git a/src/parser/numparse.c b/src/parser/numparse.c deleted file mode 100644 index dd48320fa..000000000 --- a/src/parser/numparse.c +++ /dev/null @@ -1,169 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * This routine parses a number. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "ftedefs.h" -#include "numparse.h" - - -static double -pow10( double num) /* Chris Inbody */ -{ - double d = 1.0; - - while (num-- > 0) - d *= 10.0; - return (d); -} - - -bool ft_strictnumparse = FALSE; - -/* Parse a number. This will handle things like 10M, etc... If the number - * must not end before the end of the string, then whole is TRUE. - * If whole is FALSE and there is more left to the number, the argument - * is advanced to the end of the word. Returns NULL - * if no number can be found or if there are trailing characters when - * whole is TRUE. - * If ft_strictnumparse is TRUE, and whole is FALSE, the first of the - * trailing characters must be a '_'. - */ - -double * -ft_numparse(char **s, bool whole) -{ - double mant = 0.0; - int sign = 1, exsign = 1, p; - double expo = 0.0; - static double num; - char *string = *s; - - /* See if the number begins with + or -. */ - if (*string == '+') - string++; - else if (*string == '-') { - string++; - sign = -1; - } - - /* We don't want to recognise "P" as 0P, or .P as 0.0P... */ - if ((!isdigit(*string) && *string != '.') || - ((*string == '.') && !isdigit(string[1]))) - return (NULL); - - /* Now accumulate a number. Note ascii dependencies here... */ - while (isdigit(*string)) - mant = mant * 10.0 + (*string++ - '0'); - - /* Now maybe a decimal point. */ - if (*string == '.') { - string++; - p = 1; - while (isdigit(*string)) - mant += (*string++ - '0') / pow10(p++); - } - - /* Now look for the scale factor or the exponent (can't have both). */ - switch (*string) { - case 'e': - case 'E': - /* Parse another number. */ - string++; - if (*string == '+') { - exsign = 1; - string++; - } else if (*string == '-') { - exsign = -1; - string++; - } - while(isdigit(*string)) - expo = expo * 10.0 + (*string++ - '0'); - if (*string == '.') { - string++; - p = 1; - while (isdigit(*string)) - expo += (*string++ - '0') / pow10(p++); - } - expo *= exsign; - break; - case 't': - case 'T': - expo = 12.0; - string++; - break; - case 'g': - case 'G': - expo = 9.0; - string++; - break; - case 'k': - case 'K': - expo = 3.0; - string++; - break; - case 'u': - case 'U': - expo = -6.0; - string++; - break; - case 'n': - case 'N': - expo = -9.0; - string++; - break; - case 'p': - case 'P': - expo = -12.0; - string++; - break; - case 'f': - case 'F': - expo = -15.0; - string++; - break; - case 'm': - case 'M': - /* Can be either m, mil, or meg. */ - if (string[1] && string[2] && - ((string[1] == 'e') || (string[1] == 'E')) && - ((string[2] == 'g') || (string[2] == 'G'))) { - expo = 6.0; - string += 3; - } else if (string[1] && string[2] && - ((string[1] == 'i') || (string[1] == 'I')) && - ((string[2] == 'l') || (string[2] == 'L'))) { - expo = -6.0; - mant *= 25.4; - string += 3; - } else { - expo = -3.0; - string++; - } - break; - } - - if (whole && *string != '\0') { - return (NULL); - } else if (ft_strictnumparse && *string && isdigit(string[-1])) { - if (*string == '_') - while (isalpha(*string) || (*string == '_')) - string++; - else - return (NULL); - } else { - while (isalpha(*string) || (*string == '_')) - string++; - } - *s = string; - num = sign * mant * pow(10.0, expo); - if (ft_parsedb) - fprintf(cp_err, "numparse: got %e, left = %s\n", num, *s); - return (&num); -} diff --git a/src/parser/numparse.h b/src/parser/numparse.h deleted file mode 100644 index 44fd91fbc..000000000 --- a/src/parser/numparse.h +++ /dev/null @@ -1,14 +0,0 @@ -/************* - * Header file for numparse.c - * 1999 E. Rouat - ************/ - -#ifndef NUMPARSE_H_INCLUDED -#define NUMPARSE_H_INCLUDED - - -double * ft_numparse(char **s, bool whole); - - - -#endif diff --git a/src/parser/output.c b/src/parser/output.c deleted file mode 100644 index 46f80f7ac..000000000 --- a/src/parser/output.c +++ /dev/null @@ -1,336 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Routines to handle "more"d output. There are some serious system - * dependencies in here, and it isn't clear that versions of this stuff - * can be written for every possible machine... - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include "output.h" - -#ifdef HAVE_SGTTY_H -#include -#endif - -static void bufputc(char c); -static int outfn(char c); - - -#define DEF_SCRHEIGHT 24 -#define DEF_SCRWIDTH 80 - -bool out_moremode = TRUE; -bool out_isatty = TRUE; - -static int xsize, ysize; -static int xpos, ypos; -static bool noprint, nopause; - -static char *motion_chars; -static char *clear_chars; -static char *home_chars; -static char *cleol_chars; - - -/* out_printf doesn't handle double arguments correctly, so we - sprintf into this buf and call out_send w/ it */ -char out_pbuf[BSIZE_SP]; - -/* Start output... */ - -void -out_init(void) -{ -#ifdef TIOCGWINSZ - struct winsize ws; -#endif - bool moremode; - - noprint = nopause = FALSE; - - if (cp_getvar("nomoremode", VT_BOOL, (char *) &moremode)) - out_moremode = FALSE; - else - out_moremode = TRUE; - if (!out_moremode || !cp_interactive) - out_isatty = FALSE; - - if (!out_isatty) - return; - - xsize = ysize = 0; - - /* Figure out the screen size. We try, in order, TIOCGSIZE, - * tgetent(), and cp_getvar(height). Default is 24 x 80. - */ - -#ifdef TIOCGWINSZ - if (!xsize || !ysize) { - (void) ioctl(fileno(stdout), TIOCGWINSZ, (char *) &ws); - xsize = ws.ws_col; - ysize = ws.ws_row; - } -#endif - - if (!xsize) - (void) cp_getvar("width", VT_NUM, (char *) &xsize); - if (!ysize) - (void) cp_getvar("height", VT_NUM, (char *) &ysize); - - if (!xsize) - xsize = DEF_SCRWIDTH; - if (!ysize) - ysize = DEF_SCRHEIGHT; - ysize -= 2; /* Fudge room... */ - xpos = ypos = 0; - - return; -} - -/* Putc may not be buffered (sp?), so we do it ourselves. */ - -static char staticbuf[BUFSIZ]; -struct { - int count; - char *ptr; -} ourbuf = { BUFSIZ, staticbuf }; - -/* send buffer out */ -void -outbufputc(void) -{ - - if (ourbuf.count != BUFSIZ) { - fputs(staticbuf, cp_out); - bzero(staticbuf, BUFSIZ-ourbuf.count); - ourbuf.count = BUFSIZ; - ourbuf.ptr = staticbuf; - } - -} - -static void -bufputc(char c) -{ - if (--ourbuf.count >= 0) { - *ourbuf.ptr++ = c; - } else { - /* Flush and reset the buffer */ - outbufputc(); - /* and store the character. */ - ourbuf.count--; - *ourbuf.ptr++ = c; - } -} - -#ifdef NOTDEF -/* This tricky little macro + recursive routine was giving the Ultrix - * global optimizer serious fits, so it was nuked. - * The replacement above is not quite as fast, but somehow I don't think - * that will cause too many problems these days. - */ -#define bufputc(c) ( --ourbuf.count >= 0 ? ((int) \ - (*ourbuf.ptr++ = (unsigned)(c))) : fbufputc((unsigned) (c))) - -static int -fbufputc(c) -unsigned char c; -{ - - ourbuf.count = 0; - outbufputc(); - ourbuf.count = BUFSIZ; - ourbuf.ptr = staticbuf; - bufputc(c); - -} -#endif - -/* prompt for a return */ -void -promptreturn(void) -{ - char buf[16]; -moe: - fprintf(cp_out, - "\n\t-- hit return for more, ? for help -- "); - if (!fgets(buf, 16, cp_in)) { - clearerr(cp_in); - *buf = 'q'; - } - switch (*buf) { - case '\n': - break; - case 'q': - noprint = TRUE; - break; - case 'c': - nopause = TRUE; - break; - case ' ': - break; - case '?': - fprintf(cp_out, -"\nPossible responses:\n\ -\t : Print another screenful\n\ -\tq : Discard the rest of the output\n\ -\tc : Continuously print the rest of the output\n\ -\t? : Print this help message\n"); - goto moe; - default: - fprintf(cp_out, "Character %d is no good\n", *buf); - goto moe; - } - -} - -/* Print a string to the output. If this would cause the screen to scroll, - * print "more". - */ - -void -out_send(char *string) -{ - - if (noprint) - return; - if (!out_isatty || nopause) { - fputs(string, cp_out); - return; - } - while (*string) { - switch (*string) { - case '\n': - xpos = 0; - ypos++; - break; - case '\f': - ypos = ysize; - xpos = 0; - break; - case '\t': - xpos = xpos / 8 + 1; - xpos *= 8; - break; - default: - xpos++; - break; - } - while (xpos >= xsize) { - xpos -= xsize; - ypos++; - } - if (ypos >= ysize) { - outbufputc(); /* out goes buffer */ - promptreturn(); - (void) fflush(cp_out); - ypos = xpos = 0; - } - bufputc(*string); /* we need to buffer these */ - string++; - } - (void) outbufputc(); - return; -} - -/* Printf some stuff using more mode. */ - -#define MAXLEN 4096 - - -void -out_printf(char *fmt, char *s1, char *s2, char *s3, char *s4, char *s5, char *s6, char *s7, char *s8, char *s9, char *s10) -{ - char buf[MAXLEN]; - - sprintf(buf, fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10); - - out_send(buf); - return; -} - -void -term_clear(void) -{ -#ifdef HAVE_TERMCAP - if (*clear_chars) - tputs(clear_chars, 1, outfn); - else - fputs("\n", stdout); -#endif -} - -void -term_home(void) -{ -#ifdef HAVE_TERMCAP - if (*home_chars) - tputs(home_chars, 1, outfn); - else if (*motion_chars) - tputs(tgoto(motion_chars, 1, 1), 1, outfn); - else - fputs("\n", stdout); -#endif -} - -void -term_cleol(void) -{ -#ifdef HAVE_TERMCAP - if (*cleol_chars) - tputs(cleol_chars, 1, outfn); -#endif -} - -static int -outfn(char c) -{ - putc(c, stdout); - return c; -} - -void -tcap_init(void) -{ - char *s; -#ifdef HAVE_TERMCAP - char tbuf[1025]; - static char buf2[100]; - char *charbuf; - - charbuf = buf2; - - if ((s = getenv("TERM"))) { - if (tgetent(tbuf, s) != -1) { - xsize = tgetnum("co"); - ysize = tgetnum("li"); - if ((xsize <= 0) || (ysize <= 0)) - xsize = ysize = 0; - clear_chars = (char *) tgetstr("cl", &charbuf); - motion_chars = (char *) tgetstr("cm", &charbuf); - home_chars = (char *) tgetstr("ho", &charbuf); - cleol_chars = (char *) tgetstr("ce", &charbuf); - } - } -#endif - - if (!xsize) { - if ((s = getenv("COLS"))) - xsize = atoi(s); - if (xsize <= 0) - xsize = 0; - } - - if (!ysize) { - if ((s = getenv("LINES"))) - ysize = atoi(s); - if (ysize <= 0) - ysize = 0; - } -} diff --git a/src/parser/output.h b/src/parser/output.h deleted file mode 100644 index 2e709343a..000000000 --- a/src/parser/output.h +++ /dev/null @@ -1,21 +0,0 @@ -/************* - * Header file for output.c - * 1999 E. Rouat - ************/ - -#ifndef OUTPUT_H_INCLUDED -#define OUTPUT_H_INCLUDED - -void out_init(void); -void outbufputc(void); -void promptreturn(void); -void out_send(char *string); -void out_printf(char *fmt, char *s1, char *s2, char *s3, char *s4, char *s5, char *s6, - char *s7, char *s8, char *s9, char *s10); -void term_clear(void); -void term_home(void); -void term_cleol(void); -void tcap_init(void); - - -#endif diff --git a/src/parser/quote.c b/src/parser/quote.c deleted file mode 100644 index 6bf95f88c..000000000 --- a/src/parser/quote.c +++ /dev/null @@ -1,92 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * - * Various things for quoting words. If this is not ascii, quote and - * strip are no-ops, so '' and \ quoting won't work. To fix this, sell - * your IBM machine and buy a vax. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "quote.h" - - -/* Strip all the 8th bits from a string (destructively). */ - -void -cp_wstrip(char *str) -{ - char c, d; - - if (str) - while ((c = *str)) { /* assign and test */ - d = strip(c); - if (c != d) - *str = d; - str++; - } - return; -} - -/* Quote all characters in a word. */ - -void -cp_quoteword(char *str) -{ - if (str) - while (*str) { - *str = quote(*str); - str++; - } - return; -} - -/* Print a word (strip the word first). */ - -void -cp_printword(char *string, FILE *fp) -{ - char *s; - - if (string) - for (s = string; *s; s++) - (void) putc((strip(*s)), fp); - return; -} - -/* (Destructively) strip all the words in a wlist. */ - -void -cp_striplist(wordlist *wlist) -{ - wordlist *wl; - - for (wl = wlist; wl; wl = wl->wl_next) - cp_wstrip(wl->wl_word); - return; -} - -/* Remove the "" from a string. */ - -char * -cp_unquote(char *string) -{ - char *s; - int l; - if (string) { - s = copy(string); - - if (*s == '"') - s++; - - l = strlen(s) - 1; - if (s[l] == '"') - s[l] = '\0'; - return (s); - } else - return 0; -} diff --git a/src/parser/quote.h b/src/parser/quote.h deleted file mode 100644 index 5a9b659cc..000000000 --- a/src/parser/quote.h +++ /dev/null @@ -1,17 +0,0 @@ -/************* - * Header file for quote.c - * 1999 E. Rouat - ************/ - -#ifndef QUOTE_H_INCLUDED -#define QUOTE_H_INCLUDED - - -void cp_wstrip(char *str); -void cp_quoteword(char *str); -void cp_printword(char *string, FILE *fp); -void cp_striplist(wordlist *wlist); -char * cp_unquote(char *string); - - -#endif diff --git a/src/parser/std.c b/src/parser/std.c deleted file mode 100644 index 217084c12..000000000 --- a/src/parser/std.c +++ /dev/null @@ -1,22 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Standard utility routines. - * Most moved to MISC/ - */ - -#include -#include "ngspice.h" -#include "cpstd.h" - - -/* This might not be around. If not then forget about sorting. */ - -#ifndef HAVE_QSORT -#ifndef qsort -qsort() {} -#endif -#endif diff --git a/src/parser/unixcom.c b/src/parser/unixcom.c deleted file mode 100644 index 270d9bb5b..000000000 --- a/src/parser/unixcom.c +++ /dev/null @@ -1,306 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Routines to do execution of unix commands. - */ - -#include -#include "ngspice.h" -#include "cpdefs.h" -#include "unixcom.h" - -#ifdef HAVE_VFORK_H - -/* The only reason this exists is efficiency */ - -# ifdef HAVE_SYS_DIR_H -# include -# include -# else - -# ifdef HAVE_DIRENT_H -# include -# include -# ifndef direct -# define direct dirent -# endif -# endif -# endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#include -#include - - -static bool tryexec(char *name, char *argv[]); -static int hash(register char *str); - - -struct hashent { - char *h_name; - char *h_path; - struct hashent *h_next; -} ; - -#define HASHSIZE 256 - -static struct hashent *hashtab[HASHSIZE]; -static char *dirbuffer; -static int dirlength, dirpos; - -/* Create the hash table for the given search path. pathlist is a : seperated - * list of directories. If docc is TRUE, then all the commands found are - * added to the command completion lists. - */ - -void -cp_rehash(char *pathlist, bool docc) -{ - register int i; - struct hashent *hh, *ht; - char buf[BSIZE_SP], pbuf[BSIZE_SP], *curpath; - DIR *pdir; - struct direct *entry; - - /* First clear out the old hash table. */ - for (i = 0; i < HASHSIZE; i++) { - for (hh = hashtab[i]; hh; hh = ht) { - ht = hh->h_next; - /* Don't free any of the other stuff -- it is too - * strange. - */ - tfree(hh); - } - hashtab[i] = NULL; - } - - while (pathlist && *pathlist) { - /* Copy one path to buf. We have to make sure that the path - * is a full path name. - */ - if (*pathlist == '/') - i = 0; - else { -#ifdef HAVE_GETWD - (void) getwd(buf); -#else -# ifdef HAVE_GETCWD - (void) getcwd(buf, sizeof(buf)); -# else - *buf = 0; -# endif -#endif - i = strlen(buf); - } - while (*pathlist && (*pathlist != ':')) - buf[i++] = *pathlist++; - while (*pathlist == ':') - pathlist++; - buf[i] = '\0'; - - curpath = copy(buf); - if (!(pdir = opendir(curpath))) - continue; - while (entry = readdir(pdir)) { - (void) strcpy(pbuf, curpath); - (void) strcat(pbuf, "/"); - (void) strcat(pbuf, entry->d_name); - /* Now we could make sure that it is really an - * executable, but that is too slow - * (as if "we" really cared). - */ - hh = alloc(struct hashent); - hh->h_name = copy(entry->d_name); - hh->h_path = curpath; - i = hash(entry->d_name); - /* Make sure this goes at the end, with - * possible duplications of names. - */ - if (hashtab[i]) { - ht = hashtab[i]; - while (ht->h_next) - ht = ht->h_next; - ht->h_next = hh; - } else - hashtab[i] = hh; - if (docc) { - /* Add to completion hash table. */ - cp_addcomm(entry->d_name, (long) 0, (long) 0, (long) 0, - (long) 0); - } - } - closedir(pdir); - } - return; -} - -/* The return value is FALSE if no command was found, and TRUE if it was. */ - -bool -cp_unixcom(wordlist *wl) -{ - int i; - register struct hashent *hh; - register char *name; - char **argv; - char buf[BSIZE_SP]; - - if (!wl) - return (FALSE); - name = wl->wl_word; - argv = wl_mkvec(wl); - if (cp_debug) { - printf("name: %s, argv: ", name); - wl_print(wl, stdout); - printf(".\n"); - } - if (index(name, '/')) - return (tryexec(name, argv)); - i = hash(name); - for (hh = hashtab[i]; hh; hh = hh->h_next) { - if (eq(name, hh->h_name)) { - (void) sprintf(buf, "%s/%s", hh->h_path, hh->h_name); - if (tryexec(buf, argv)) - return (TRUE); - } - } - return (FALSE); -} - -static bool -tryexec(char *name, char *argv[]) -{ -# ifdef HAVE_SYS_WAIT_H - int status; -# else - union wait status; -# endif - int pid, j; - RETSIGTYPE (*svint)( ), (*svquit)( ), (*svtstp)( ); - - pid = vfork( ); - if (pid == 0) { - fixdescriptors(); - (void) execv(name, argv); - (void) _exit(120); /* A random value. */ - /* NOTREACHED */ - } else { - svint = signal(SIGINT, SIG_DFL); - svquit = signal(SIGQUIT, SIG_DFL); - svtstp = signal(SIGTSTP, SIG_DFL); - do { - j = wait(&status); - } while (j != pid); - (void) signal(SIGINT, (SIGNAL_FUNCTION) svint); - (void) signal(SIGQUIT, (SIGNAL_FUNCTION) svquit); - (void) signal(SIGTSTP, (SIGNAL_FUNCTION) svtstp); - } - if (WTERMSIG(status) == 0 && WEXITSTATUS(status) == 120) - /*if ((status.w_termsig == 0) && (status.w_retcode == 120)) */ - return (FALSE); - else - return (TRUE); -} - -static int -hash(register char *str) -{ - register int i = 0; - - while (*str) - i += *str++; - return (i % HASHSIZE); -} - -/* Debugging. */ - -void -cp_hstat(void) -{ - struct hashent *hh; - int i; - - for (i = 0; i < HASHSIZE; i++) - for (hh = hashtab[i]; hh; hh = hh->h_next) - fprintf(cp_err, "i = %d, name = %s, path = %s\n", - i, hh->h_name, hh->h_path); - return; -} - -#ifdef notdef -/*** The person who wrote this should be strung up ***/ -/* Some strange stuff... Don't ever free the dir buffer, because we keep - * pointers into it in the command hash table. - */ - -static bool -myopendir(char *path) -{ - struct stat stbuf; - int i; - - if (!path) - return (0); - if (stat(path, &stbuf)) - return (FALSE); - if ((i = open(path, O_RDONLY)) == -1) - return (0); - dirbuffer = tmalloc(stbuf.st_size); - if (read(i, dirbuffer, stbuf.st_size) != stbuf.st_size) { - fprintf(cp_err, "Error: bad read on directory %s\n", path); - return (0); - } - dirlength = stbuf.st_size; - dirpos = 0; - return (1); -} - -static char * -myreaddir(void) -{ - struct direct *dp; - - /* Advance us to the next valid directory entry. */ - for (;;) { - dp = (struct direct *) &dirbuffer[dirpos]; - if (dirpos >= dirlength) - return (NULL); - while (dp->d_ino == 0) { - dirpos += dp->d_reclen; - goto x; /* Ack... */ - } - break; -x: ; - } - dirpos += dp->d_reclen; - return (dp->d_name); -} -# endif - -#else - -void -cp_rehash(char *pathlist, bool docc) -{ } - -bool -cp_unixcom(wordlist *wl) -{ - char *s = wl_flatten(wl); - - if (system(s)) - return (FALSE); - else - return (TRUE); - -} - -#endif - diff --git a/src/parser/unixcom.h b/src/parser/unixcom.h deleted file mode 100644 index 64b15c02d..000000000 --- a/src/parser/unixcom.h +++ /dev/null @@ -1,16 +0,0 @@ -/************* - * Header file for unixcom.c - * 1999 E. Rouat - ************/ - -#ifndef UNIXCOM_H_INCLUDED -#define UNIXCOM_H_INCLUDED - - -void cp_rehash(char *pathlist, bool docc); -bool cp_unixcom(wordlist *wl); -void cp_hstat(void); - - - -#endif diff --git a/src/parser/var2.c b/src/parser/var2.c deleted file mode 100644 index 988338ed9..000000000 --- a/src/parser/var2.c +++ /dev/null @@ -1,491 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Do variable substitution. - */ - -#include "ngspice.h" -#include "cpdefs.h" -#include "var2.h" - -/* Print the values of currently defined variables. */ - - -static int vcmp(struct xxx *v1, struct xxx *v2); - -extern struct variable *variables; - -/* A variable substitution is - * indicated by a $, and the variable name is the following string of - * non-special characters. All variable values are inserted as a single - * word, except for lists, which are a list of words. - * A routine cp_usrset must be supplied by the host program to deal - * with variables that aren't used by cshpar -- it should be - * cp_usrset(var, isset), where var is a variable *, and isset is - * TRUE if the variable is being set, FALSE if unset. - * Also required is a routine cp_enqvar(name) which returns a struct - * variable *, which allows the host program to provide values for - * non-cshpar variables. - */ - -char cp_dol = '$'; - -/* Non-alphanumeric characters that may appear in variable names. < is very - * special... - */ - -#define VALIDCHARS "$-_<#?@.()[]&" - -wordlist * -cp_variablesubst(wordlist *wlist) -{ - wordlist *wl, *nwl; - char *s, *t, buf[BSIZE_SP], wbuf[BSIZE_SP], tbuf[BSIZE_SP]; - /* MW. tbuf holds curret word after wl_splice() calls free() on it */ - int i; - - for (wl = wlist; wl; wl = wl->wl_next) { - t = wl->wl_word; - i = 0; - while ((s =strchr(t, cp_dol))) { - while (t < s) - wbuf[i++] = *t++; - wbuf[i] = '\0'; - (void) strcpy(buf, ++s); - s = buf; - t++; - while (*s && (isalphanum(*s) || - strchr(VALIDCHARS, *s))) { - /* Get s and t past the end of the var name. */ - t++; - s++; - } - *s = '\0'; - nwl = vareval(buf); - if (i) { - (void) strcpy(buf, wbuf); - if (nwl) { - (void) strcat(buf, nwl->wl_word); - tfree(nwl->wl_word); - } else { - nwl = alloc(struct wordlist); - nwl->wl_next = nwl->wl_prev = NULL; - } - nwl->wl_word = copy(buf); - } - - (void) strcpy(tbuf, t); /* MW. Save t*/ - if (!(wl = wl_splice(wl, nwl))) - return (NULL); - /* This is bad... */ - for (wlist = wl; wlist->wl_prev; wlist = wlist->wl_prev) - ; - (void) strcpy(buf, wl->wl_word); - i = strlen(buf); - (void) strcat(buf, tbuf); /* MW. tbuf is used here only */ - - tfree(wl->wl_word); - wl->wl_word = copy(buf); - t = &wl->wl_word[i]; - s = wl->wl_word; - for (i = 0; s < t; s++) - wbuf[i++] = *s; - } - } - return (wlist); -} - -/* Evaluate a variable. */ - -wordlist * -vareval(char *string) -{ - struct variable *v; - wordlist *wl; - char buf[BSIZE_SP], *s; - char *oldstring = copy(string); - char *range = NULL; - int i, up, low; - - cp_wstrip(string); - if ((s =strchr(string, '['))) { - *s = '\0'; - range = s + 1; - } - - switch (*string) { - - case '$': - wl = alloc(struct wordlist); - wl->wl_next = wl->wl_prev = NULL; - - - (void) sprintf(buf, "%d", getpid()); - - wl->wl_word = copy(buf); - return (wl); - - case '<': - (void) fflush(cp_out); - if (!fgets(buf, BSIZE_SP, cp_in)) { - clearerr(cp_in); - (void) strcpy(buf, "EOF"); - } - for (s = buf; *s && (*s != '\n'); s++) - ; - *s = '\0'; - wl = cp_lexer(buf); - /* This is a hack. */ - if (!wl->wl_word) - wl->wl_word = copy(""); - return (wl); - - case '?': - wl = alloc(struct wordlist); - wl->wl_next = wl->wl_prev = NULL; - string++; - for (v = variables; v; v = v->va_next) - if (eq(v->va_name, string)) - break; - if (!v) - v = cp_enqvar(string); - wl->wl_word = copy(v ? "1" : "0"); - return (wl); - - case '#': - wl = alloc(struct wordlist); - wl->wl_next = wl->wl_prev = NULL; - string++; - for (v = variables; v; v = v->va_next) - if (eq(v->va_name, string)) - break; - if (!v) - v = cp_enqvar(string); - if (!v) { - fprintf(cp_err, "Error: %s: no such variable.\n", - string); - return (NULL); - } - if (v->va_type == VT_LIST) - for (v = v->va_vlist, i = 0; v; v = v->va_next) - i++; - else - i = (v->va_type != VT_BOOL); - (void) sprintf(buf, "%d", i); - wl->wl_word = copy(buf); - return (wl); - - case '\0': - wl = alloc(struct wordlist); - wl->wl_next = wl->wl_prev = NULL; - wl->wl_word = copy("$"); - return (wl); - } - - /* The notation var[stuff] has two meanings... If this is a real - * variable, then the [] denotes range, but if this is a strange - * (e.g, device parameter) variable, it could be anything... - */ - for (v = variables; v; v = v->va_next) - if (eq(v->va_name, string)) - break; - if (!v && isdigit(*string)) { - for (v = variables; v; v = v->va_next) - if (eq(v->va_name, "argv")) - break; - range = string; - } - if (!v) { - range = NULL; - string = oldstring; - v = cp_enqvar(string); - } - if (!v && (s = getenv(string))) { - wl = alloc(struct wordlist); - wl->wl_next = wl->wl_prev = NULL; - wl->wl_word = copy(s); - return (wl); - } - if (!v) { - fprintf(cp_err, "Error: %s: no such variable.\n", string); - return (NULL); - } - wl = cp_varwl(v); - - /* Now parse and deal with 'range' ... */ - if (range) { - for (low = 0; isdigit(*range); range++) - low = low * 10 + *range - '0'; - if ((*range == '-') && isdigit(range[1])) - for (up = 0, range++; isdigit(*range); range++) - up = up * 10 + *range - '0'; - else if (*range == '-') - up = wl_length(wl); - else - up = low; - up--, low--; - wl = wl_range(wl, low, up); - } - - return (wl); -} - - - -void -cp_vprint(void) -{ - struct variable *v; - struct variable *uv1, *uv2; - wordlist *wl; - int i, j; - char *s; - struct xxx *vars; - - cp_usrvars(&uv1, &uv2); - - for (v = uv1, i = 0; v; v = v->va_next) - i++; - for (v = uv2; v; v = v->va_next) - i++; - for (v = variables; v; v = v->va_next) - i++; - - vars = (struct xxx *) tmalloc(sizeof (struct xxx) * i); - - out_init(); - for (v = variables, i = 0; v; v = v->va_next, i++) { - vars[i].x_v = v; - vars[i].x_char = ' '; - } - for (v = uv1; v; v = v->va_next, i++) { - vars[i].x_v = v; - vars[i].x_char = '*'; - } - for (v = uv2; v; v = v->va_next, i++) { - vars[i].x_v = v; - vars[i].x_char = '+'; - } - - qsort((char *) vars, i, sizeof (struct xxx), vcmp); - - for (j = 0; j < i; j++) { - if (j && eq(vars[j].x_v->va_name, vars[j - 1].x_v->va_name)) - continue; - v = vars[j].x_v; - if (v->va_type == VT_BOOL) { -/* out_printf("%c %s\n", vars[j].x_char, v->va_name); */ - sprintf(out_pbuf, "%c %s\n", vars[j].x_char, v->va_name); - out_send(out_pbuf); - } else { - out_printf("%c %s\t", vars[j].x_char, v->va_name); - wl = vareval(v->va_name); - s = wl_flatten(wl); - if (v->va_type == VT_LIST) { - out_printf("( %s )\n", s); - } else - out_printf("%s\n", s); - } - } - - tfree(vars); - return; -} - -static int -vcmp(struct xxx *v1, struct xxx *v2) -{ - int i; - - if ((i = strcmp(v1->x_v->va_name, v2->x_v->va_name))) - return (i); - else - return (v1->x_char - v2->x_char); -} - -/* The set command. Syntax is - * set [opt ...] [opt = val ...]. Val may be a string, an int, a float, - * or a list of the form (elt1 elt2 ...). - */ - - -void -com_set(wordlist *wl) -{ - struct variable *vars; - char *s; - - if (wl == NULL) { - cp_vprint(); - return; - } - vars = cp_setparse(wl); - - /* This is sort of a hassle... */ - while (vars) { - switch (vars->va_type) { - case VT_BOOL: - s = (char *) &vars->va_bool; - break; - case VT_NUM: - s = (char *) &vars->va_num; - break; - case VT_REAL: - s = (char *) &vars->va_real; - break; - case VT_STRING: - s = vars->va_string; - break; - case VT_LIST: - s = (char *) vars->va_vlist; - break; - default: - s = (char *) NULL; - } - cp_vset(vars->va_name, vars->va_type, s); - vars = vars->va_next; - } - return; -} - -void -com_unset(wordlist *wl) -{ - register char *name; - struct variable *var, *nv; - - if (eq(wl->wl_word, "*")) { - for (var = variables; var; var = nv) { - nv = var->va_next; - cp_remvar(var->va_name); - } - wl = wl->wl_next; - } - while (wl != NULL) { - name = wl->wl_word; - cp_remvar(name); - wl = wl->wl_next; - } - return; -} - -/* Shift a list variable, by default argv, one to the left (or more if a - * second argument is given. - */ - -void -com_shift(wordlist *wl) -{ - struct variable *v, *vv; - char *n = "argv"; - int num = 1; - - if (wl) { - n = wl->wl_word; - wl = wl->wl_next; - } - if (wl) - num = scannum(wl->wl_word); - - for (v = variables; v; v = v->va_next) - if (eq(v->va_name, n)) - break; - if (!v) { - fprintf(cp_err, "Error: %s: no such variable\n", n); - return; - } - if (v->va_type != VT_LIST) { - fprintf(cp_err, "Error: %s not of type list\n", n); - return; - } - for (vv = v->va_vlist; vv && (num > 0); num--) - vv = vv->va_next; - if (num) { - fprintf(cp_err, "Error: variable %s not long enough\n", n); - return; - } - - v->va_vlist = vv; - return; -} - -/* Determine the value of a variable. Fail if the variable is unset, - * and if the type doesn't match, try and make it work... - */ - -bool -cp_getvar(char *name, int type, char *retval) -{ - struct variable *v; - - for (v = variables; v; v = v->va_next) - if (eq(name, v->va_name)) - break; - if (v == NULL) { - if (type == VT_BOOL) - * (bool *) retval = FALSE; - return (FALSE); - } - if (v->va_type == type) { - switch (type) { - case VT_BOOL: - * (bool *) retval = TRUE; - break; - case VT_NUM: { - int *i; - i = (int *) retval; - *i = v->va_num; - break; - } - case VT_REAL: { - double *d; - d = (double *) retval; - *d = v->va_real; - break; - } - case VT_STRING: { /* Gotta be careful to have room. */ - char *s; - s = cp_unquote(v->va_string); - cp_wstrip(s); - (void) strcpy(retval, s); - break; - } - case VT_LIST: { /* Funny case... */ - struct variable **tv; - tv = (struct variable **) retval; - *tv = v->va_vlist; - break; - } - default: - fprintf(cp_err, - "cp_getvar: Internal Error: bad var type %d.\n", - type); - break; - } - return (TRUE); - } else { - /* Try to coerce it.. */ - if ((type == VT_NUM) && (v->va_type == VT_REAL)) { - int *i; - i = (int *) retval; - *i = (int) v->va_real; - return (TRUE); - } else if ((type == VT_REAL) && (v->va_type == VT_NUM)) { - double *d; - d = (double *) retval; - *d = (double) v->va_num; - return (TRUE); - } else if ((type == VT_STRING) && (v->va_type == VT_NUM)) { - (void) sprintf(retval, "%d", v->va_num); - return (TRUE); - } else if ((type == VT_STRING) && (v->va_type == VT_REAL)) { - (void) sprintf(retval, "%f", v->va_real); - return (TRUE); - } - return (FALSE); - } -} - diff --git a/src/parser/var2.h b/src/parser/var2.h deleted file mode 100644 index a553639ce..000000000 --- a/src/parser/var2.h +++ /dev/null @@ -1,26 +0,0 @@ -/************* - * Header file for var2.c - * 1999 E. Rouat - ************/ - -#ifndef VAR2_H_INCLUDED -#define VAR2_H_INCLUDED - - -struct xxx { - struct variable *x_v; - char x_char; -} ; - -wordlist * cp_variablesubst(wordlist *wlist); -wordlist * vareval(char *string); -void cp_vprint(void); -void com_set(wordlist *wl); -void com_unset(wordlist *wl); -void com_shift(wordlist *wl); -bool cp_getvar(char *name, int type, char *retval); - - - - -#endif diff --git a/src/parser/variable.c b/src/parser/variable.c deleted file mode 100644 index f1d3bffa4..000000000 --- a/src/parser/variable.c +++ /dev/null @@ -1,429 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -#include "ngspice.h" -#include "cpdefs.h" -#include "fteext.h" -#include "ftedefs.h" -#include "variable.h" - - -bool cp_noglob = TRUE; -bool cp_nonomatch = FALSE; -bool cp_noclobber = FALSE; -bool cp_ignoreeof = FALSE; - -struct variable *variables = NULL; - -wordlist * -cp_varwl(struct variable *var) -{ - wordlist *wl = NULL, *w, *wx = NULL; - char buf[BSIZE_SP]; - struct variable *vt; - - switch(var->va_type) { - case VT_BOOL: - /* Can't ever be FALSE. */ - (void) sprintf(buf, "%s", var->va_bool ? "TRUE" : - "FALSE"); - break; - case VT_NUM: - (void) sprintf(buf, "%d", var->va_num); - break; - case VT_REAL: - /* This is a case where printnum isn't too good... */ - (void) sprintf(buf, "%G", var->va_real); - break; - case VT_STRING: - (void) strcpy(buf, cp_unquote(var->va_string)); - break; - case VT_LIST: /* The tricky case. */ - for (vt = var->va_vlist; vt; vt = vt->va_next) { - w = cp_varwl(vt); - if (wl == NULL) - wl = wx = w; - else { - wx->wl_next = w; - w->wl_prev = wx; - wx = w; - } - } - return (wl); - default: - fprintf(cp_err, - "cp_varwl: Internal Error: bad variable type %d\n", - var->va_type); - return (NULL); - } - wl = alloc(struct wordlist); - wl->wl_next = wl->wl_prev = NULL; - wl->wl_word = copy(buf); - return (wl); -} - -/* Set a variable. */ - -void -cp_vset(char *varname, char type, char *value) -{ - struct variable *v, *u, *w; - int i; - bool alreadythere = FALSE; - -/* for (v = variables; v; v = v->va_next) ; printf("ok while setting %s\n", - varname);*/ - varname = cp_unquote(varname); - w = NULL; - for (v = variables; v; v = v->va_next) { - if (eq(varname, v->va_name)) { - alreadythere = TRUE; - break; - } - w = v; - } - if (!v) { - v = alloc(struct variable); - v->va_name = copy(varname); - v->va_next = NULL; - } - switch (type) { - case VT_BOOL: - if (* ((bool *) value) == FALSE) { - cp_remvar(varname); - return; - } else - v->va_bool = TRUE; - break; - - case VT_NUM: - v->va_num = * (int *) value; - break; - - case VT_REAL: - v->va_real = * (double *) value; - break; - - case VT_STRING: - v->va_string = copy(value); - break; - - case VT_LIST: - v->va_vlist = (struct variable *) value; - break; - - default: - fprintf(cp_err, - "cp_vset: Internal Error: bad variable type %d.\n", - type); - return; - } - v->va_type = type; - - /* Now, see if there is anything interesting going on. We recognise - * these special variables: noglob, nonomatch, history, echo, - * noclobber, prompt, and verbose. cp_remvar looks for these variables - * too. The host program will get any others. - */ - - if (eq(varname, "noglob")) - cp_noglob = TRUE; - else if (eq(varname, "nonomatch")) - cp_nonomatch = TRUE; - else if (eq(varname, "history") && (type == VT_NUM)) - cp_maxhistlength = v->va_num; - else if (eq(varname, "history") && (type == VT_REAL)) - cp_maxhistlength = v->va_real; - else if (eq(varname, "noclobber")) - cp_noclobber = TRUE; - else if (eq(varname, "prompt") && (type == VT_STRING)) - cp_promptstring = copy(v->va_string); - else if (eq(varname, "ignoreeof")) - cp_ignoreeof = TRUE; - else if (eq(varname, "cpdebug")) { - cp_debug = TRUE; -#ifndef CPDEBUG - fprintf(cp_err, - "Warning: program not compiled with cshpar debug messages\n"); -#endif - } - - switch (i = cp_usrset(v, TRUE)) { - - case US_OK: - /* Normal case. */ - if (!alreadythere) { - v->va_next = variables; - variables = v; - } - break; - - case US_DONTRECORD: - /* Do nothing... */ - if (alreadythere) { - fprintf(cp_err, - "cp_vset: Internal Error: %s already there, but 'dont record'\n", - v->va_name); - } - break; - - case US_READONLY: - fprintf(cp_err, "Error: %s is a read-only variable.\n", - v->va_name); - if (alreadythere) - fprintf(cp_err, - "cp_vset: Internal Error: it was already there too!!\n"); - break; - - case US_SIMVAR: - if (alreadythere) { - /* somehow it got into the front-end list of variables */ - if (w) { - w->va_next = v->va_next; - } else { - variables = v->va_next; - } - } - alreadythere = FALSE; - if (ft_curckt) { - for (u = ft_curckt->ci_vars; u; u = u->va_next) - if (eq(varname, u->va_name)) { - alreadythere = TRUE; - break; - } - if (!alreadythere) { - v->va_next = ft_curckt->ci_vars; - ft_curckt->ci_vars = v; - } else { - w = u->va_next; - bcopy(v, u, sizeof(*u)); - u->va_next = w; - } - } - break; - - case US_NOSIMVAR: - /* What do you do? */ - tfree(v); - break; - - default: - fprintf(cp_err, "cp_vset: Internal Error: bad US val %d\n", i); - break; - } - - return; -} - -struct variable * -cp_setparse(wordlist *wl) -{ - char *name, *val, *s, *ss; - double *td; - struct variable *listv = NULL, *vv, *lv = NULL; - struct variable *vars = NULL; - int balance; - - while (wl) { - name = cp_unquote(wl->wl_word); - wl = wl->wl_next; - if (((wl == NULL) || (*wl->wl_word != '=')) && - strchr(name, '=') == NULL) { - vv = alloc(struct variable); - vv->va_name = copy(name); - vv->va_type = VT_BOOL; - vv->va_bool = TRUE; - vv->va_next = vars; - vars = vv; - continue; - } - if (wl && eq(wl->wl_word, "=")) { - wl = wl->wl_next; - if (wl == NULL) { - fprintf(cp_err, "Error: bad set form.\n"); - return (NULL); - } - val = wl->wl_word; - wl = wl->wl_next; - } else if (wl && (*wl->wl_word == '=')) { - val = wl->wl_word + 1; - wl = wl->wl_next; - } else if ((s =strchr(name, '='))) { - val = s + 1; - *s = '\0'; - if (*val == '\0') { - if (!wl) { - fprintf(cp_err, - "Error: %s equals what?.\n", - name); - return (NULL); - } else { - val = wl->wl_word; - wl = wl->wl_next; - } - } - } else { - fprintf(cp_err, "Error: bad set form.\n"); - return (NULL); - } - val = cp_unquote(val); - if (eq(val, "(")) { /* ) */ - /* The beginning of a list... We have to walk down - * the list until we find a close paren... If there - * are nested ()'s, treat them as tokens... - */ - balance = 1; - while (wl && wl->wl_word) { - if (eq(wl->wl_word, "(")) { /* ) ( */ - balance++; - } else if (eq(wl->wl_word, ")")) { - if (!--balance) - break; - } - vv = alloc(struct variable); - vv->va_next = NULL; - ss = cp_unquote(wl->wl_word); - td = ft_numparse(&ss, FALSE); - if (td) { - vv->va_type = VT_REAL; - vv->va_real = *td; - } else { - vv->va_type = VT_STRING; - vv->va_string = copy(ss); - } - if (listv) { - lv->va_next = vv; - lv = vv; - } else - listv = lv = vv; - wl = wl->wl_next; - } - if (balance && !wl) { - fprintf(cp_err, "Error: bad set form.\n"); - return (NULL); - } - - vv = alloc(struct variable); - vv->va_name = copy(name); - vv->va_type = VT_LIST; - vv->va_vlist = listv; - vv->va_next = vars; - vars = vv; - - wl = wl->wl_next; - continue; - } - - ss = cp_unquote(val); - td = ft_numparse(&ss, FALSE); - vv = alloc(struct variable); - vv->va_name = copy(name); - vv->va_next = vars; - vars = vv; - if (td) { - /*** We should try to get VT_NUM's... */ - vv->va_type = VT_REAL; - vv->va_real = *td; - } else { - vv->va_type = VT_STRING; - vv->va_string = copy(val); - } - } - return (vars); -} - -void -cp_remvar(char *varname) -{ - struct variable *v, *u, *lv = NULL; - bool found = TRUE; - int i; - - for (v = variables; v; v = v->va_next) { - if (eq(v->va_name, varname)) - break; - lv = v; - } - if (!v) { - /* Gotta make up a var struct for cp_usrset()... */ - v = alloc(struct variable); - ZERO(v, struct variable); - v->va_name = varname; - v->va_type = VT_NUM; - v->va_bool = 0; - found = FALSE; - } - - /* Note that 'unset history' doesn't do anything here... Causes - * trouble... - */ - if (eq(varname, "noglob")) - cp_noglob = FALSE; - else if (eq(varname, "nonomatch")) - cp_nonomatch = FALSE; - else if (eq(varname, "noclobber")) - cp_noclobber = FALSE; - else if (eq(varname, "prompt")) - cp_promptstring = ""; - else if (eq(varname, "cpdebug")) - cp_debug = FALSE; - else if (eq(varname, "ignoreeof")) - cp_ignoreeof = FALSE; - - switch (i = cp_usrset(v, FALSE)) { - - case US_OK: - /* Normal case. */ - if (found) { - if (lv) - lv->va_next = v->va_next; - else - variables = v->va_next; - } - break; - - case US_DONTRECORD: - /* Do nothing... */ - if (found) - fprintf(cp_err, - "cp_remvar: Internal Error: var %d\n", *varname); - break; - - case US_READONLY: - /* Badness... */ - fprintf(cp_err, "Error: %s is read-only.\n", - v->va_name); - if (found) - fprintf(cp_err, - "cp_remvar: Internal Error: var %d\n", *varname); - break; - - case US_SIMVAR: - lv = NULL; - if (ft_curckt) { - for (u = ft_curckt->ci_vars; u; u = u->va_next) { - if (eq(varname, u->va_name)) { - break; - } - lv = u; - } - if (u) { - if (lv) - lv->va_next = u->va_next; - else - ft_curckt->ci_vars = u->va_next; - tfree(u); - } - } - break; - - default: - fprintf(cp_err, "cp_remvar: Internal Error: US val %d\n", i); - break; - } - - tfree(v); - return; -} diff --git a/src/parser/variable.h b/src/parser/variable.h deleted file mode 100644 index 2b012ec3d..000000000 --- a/src/parser/variable.h +++ /dev/null @@ -1,17 +0,0 @@ -/************* - * Header file for variable.c - * 1999 E. Rouat - ************/ - -#ifndef VARIABLE_H_INCLUDED -#define VARIABLE_H_INCLUDED - - -wordlist * cp_varwl(struct variable *var); -void cp_vset(char *varname, char type, char *value); -struct variable * cp_setparse(wordlist *wl); -void cp_remvar(char *varname); - - - -#endif diff --git a/src/parser/wlist.c b/src/parser/wlist.c deleted file mode 100644 index 89528ca64..000000000 --- a/src/parser/wlist.c +++ /dev/null @@ -1,283 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * - * Wordlist manipulation stuff. - */ - -#include "ngspice.h" -#include "cpstd.h" -#include "wlist.h" - - -static int wlcomp(char **s, char **t); - - -/* Determine the length of a word list. */ - -int -wl_length(wordlist *wlist) -{ - register int i = 0; - register wordlist *wl; - - for (wl = wlist; wl; wl = wl->wl_next) - i++; - return (i); -} - -/* Free the storage used by a word list. */ - -void -wl_free(wordlist *wlist) -{ - wordlist *wl, *nw; - - for (wl = wlist; wl; wl = nw) { - nw = wl->wl_next; - tfree(wl->wl_word); - tfree(wl); - } - return; -} - -/* Copy a wordlist and the words. */ - -wordlist * -wl_copy(wordlist *wlist) -{ - register wordlist *wl, *nwl = NULL, *w = NULL; - - for (wl = wlist; wl; wl = wl->wl_next) { - if (nwl == NULL) { - nwl = w = alloc(struct wordlist); - w->wl_prev = NULL; - w->wl_next = NULL; - } else { - w->wl_next = alloc(struct wordlist); - w->wl_next->wl_prev = w; - w = w->wl_next; - w->wl_next = NULL; - } - w->wl_word = copy(wl->wl_word); - } - return (nwl); -} - -/* Substitute a wordlist for one element of a wordlist, and return a pointer - * to the last element of the inserted list. - */ - -wordlist * -wl_splice(wordlist *elt, wordlist *list) -{ - - if (list) - list->wl_prev = elt->wl_prev; - if (elt->wl_prev) - elt->wl_prev->wl_next = list; - if (list) { - while (list->wl_next) - list = list->wl_next; - list->wl_next = elt->wl_next; - } - if (elt->wl_next) - elt->wl_next->wl_prev = list; - tfree(elt->wl_word); - tfree(elt); - return (list); -} - -/* Print a word list. (No \n at the end...) */ - -void -wl_print(wordlist *wlist, FILE *fp) -{ - wordlist *wl; - - for (wl = wlist; wl; wl = wl->wl_next) { - cp_printword(wl->wl_word, fp); - if (wl->wl_next) - (void) putc(' ', fp); - } - return; -} - -/* Turn an array of char *'s into a wordlist. */ - -wordlist * -wl_build(char **v) -{ - wordlist *wlist, *wl = NULL, *cwl; - - while (*v) { - cwl = alloc(struct wordlist); - cwl->wl_prev = wl; - if (wl) - wl->wl_next = cwl; - else { - wlist = cwl; - cwl->wl_next = NULL; - } - cwl->wl_word = copy(*v); - wl = cwl; - v++; - } - return (wlist); -} - -char ** -wl_mkvec(wordlist *wl) -{ - int len, i; - char **v; - - len = wl_length(wl); - v = (char **) tmalloc((len + 1) * sizeof (char **)); - for (i = 0; i < len; i++) { - v[i] = copy(wl->wl_word); - wl = wl->wl_next; - } - v[i] = NULL; - return (v); -} - -/* Nconc two wordlists together. */ - -wordlist * -wl_append(wordlist *wlist, wordlist *nwl) -{ - wordlist *wl; - if (wlist == NULL) - return (nwl); - if (nwl == NULL) - return (wlist); - for (wl = wlist; wl->wl_next; wl = wl->wl_next); - wl->wl_next = nwl; - nwl->wl_prev = wl; - return (wlist); -} - -/* Reverse a word list. */ - -wordlist * -wl_reverse(wordlist *wl) -{ - wordlist *w, *t; - - for (w = wl; ; w = t) { - t = w->wl_next; - w->wl_next = w->wl_prev; - w->wl_prev = t; - if (t == NULL) - break; - } - return (w); -} - -/* Convert a wordlist into a string. */ - -char * -wl_flatten(wordlist *wl) -{ - char *buf; - wordlist *tw; - int i = 0; - - for (tw = wl; tw; tw = tw->wl_next) - i += strlen(tw->wl_word) + 1; - buf = tmalloc(i + 1); - *buf = 0; - - while (wl != NULL) { - (void) strcat(buf, wl->wl_word); - if (wl->wl_next) - (void) strcat(buf, " "); - wl = wl->wl_next; - } - return (buf); -} - -/* Return the nth element of a wordlist, or the last one if n is too big. - * Numbering starts at 0... - */ - -wordlist * -wl_nthelem(register int i, wordlist *wl) -{ - register wordlist *ww = wl; - - while ((i-- > 0) && ww->wl_next) - ww = ww->wl_next; - return (ww); -} - -void -wl_sort(wordlist *wl) -{ - register int i = 0; - register wordlist *ww = wl; - char **stuff; - - for (i = 0; ww; i++) - ww = ww->wl_next; - if (i < 2) - return; - stuff = (char **) tmalloc(i * sizeof (char *)); - for (i = 0, ww = wl; ww; i++, ww = ww->wl_next) - stuff[i] = ww->wl_word; - qsort((char *) stuff, i, sizeof (char *), wlcomp); - for (i = 0, ww = wl; ww; i++, ww = ww->wl_next) - ww->wl_word = stuff[i]; - tfree(stuff); - return; -} - -static int -wlcomp(char **s, char **t) -{ - return (strcmp(*s, *t)); -} - -/* Return a range of wordlist elements... */ - -wordlist * -wl_range(wordlist *wl, int low, int up) -{ - int i; - wordlist *tt; - bool rev = FALSE; - - if (low > up) { - i = up; - up = low; - low = i; - rev = TRUE; - } - up -= low; - while (wl && (low > 0)) { - tt = wl->wl_next; - tfree(wl->wl_word); - tfree(wl); - wl = tt; - if (wl) - wl->wl_prev = NULL; - low--; - } - tt = wl; - while (tt && (up > 0)) { - tt = tt->wl_next; - up--; - } - if (tt && tt->wl_next) { - wl_free(tt->wl_next); - tt->wl_next = NULL; - } - if (rev) - wl = wl_reverse(wl); - return (wl); -} - diff --git a/src/parser/wlist.h b/src/parser/wlist.h deleted file mode 100644 index fcd38ca02..000000000 --- a/src/parser/wlist.h +++ /dev/null @@ -1,26 +0,0 @@ -/************* - * Header file for wlist.c - * 1999 E. Rouat - ************/ - -#ifndef WLIST_H_INCLUDED -#define WLIST_H_INCLUDED - -int wl_length(wordlist *wlist); -void wl_free(wordlist *wlist); -wordlist * wl_copy(wordlist *wlist); -wordlist * wl_splice(wordlist *elt, wordlist *list); -void wl_print(wordlist *wlist, FILE *fp); -wordlist * wl_build(char **v); -char ** wl_mkvec(wordlist *wl); -wordlist * wl_append(wordlist *wlist, wordlist *nwl); -wordlist * wl_reverse(wordlist *wl); -char * wl_flatten(wordlist *wl); -wordlist * wl_nthelem(register int i, wordlist *wl); -void wl_sort(wordlist *wl); -wordlist * wl_range(wordlist *wl, int low, int up); - - - - -#endif diff --git a/src/proc2mod.c b/src/proc2mod.c deleted file mode 100644 index 447763dfa..000000000 --- a/src/proc2mod.c +++ /dev/null @@ -1,339 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -**********/ -/* convert .process file to set of .model cards */ - -#include -#include "ngspice.h" -#include -#include "inpdefs.h" -#include "suffix.h" - - -void exit(); - -#ifdef __STDC__ -void getdata(double*,int,int); -#else /* stdc */ -void getdata(); -#endif /* stdc */ - -typedef struct snmod { - struct snmod *nnext; - char *nname; - double nparms[69]; -} nmod; -typedef struct spmod { - struct spmod *pnext; - char *pname; - double pparms[69]; -} pmod; -typedef struct sdmod { - struct sdmod *dnext; - char *dname; - double dparms[10]; -} dmod; -typedef struct symod { - struct symod *ynext; - char *yname; - double yparms[10]; -} ymod; -typedef struct smmod { - struct smmod *mnext; - char *mname; - double mparms[10]; -} mmod; - -FILE *m = NULL; -FILE *p = NULL; -char *dataline; - - -int -main(void) { - char *typeline; - char *prname; - nmod *nlist=NULL,*ncur; - pmod *plist=NULL,*pcur; - dmod *dlist=NULL,*dcur; - ymod *ylist=NULL,*ycur; - mmod *mlist=NULL,*mcur; - char *filename; - - - filename = (char *)malloc(1024); - typeline = (char *)malloc(1024); - dataline = (char *)malloc(1024); - - while(p == NULL) { - printf("name of process file (input): "); - if(scanf("%s",filename)!=1) { - printf("error reading process file name\n"); - exit(1); - } - p = fopen(filename,"r"); - if(p==NULL) { - printf("can't open %s:",filename); - perror(""); - } - } - while(m == NULL) { - printf("name of .model file (output): "); - if(scanf("%s",filename)!=1) { - printf("error reading model file name\n"); - exit(1); - } - m = fopen(filename,"w"); - if(m==NULL) { - printf("can't open %s:",filename); - perror(""); - } - } - printf("process name : "); - if(scanf("%s",filename)!=1) { - printf("error reading process name\n"); - exit(1); - } - prname = filename; - if(fgets(typeline,1023,p)==NULL) { - printf("error reading input description line\n"); - exit(1); - } - INPcaseFix(typeline); - while(1) { - while(*typeline == ' ' || *typeline == '\t' || *typeline == ',' || - *typeline == '\n' ) { - typeline ++; - } - if(*typeline == 0) break; - if(strncmp("nm",typeline,2) == 0) { - ncur = (nmod *)malloc(sizeof(nmod)); - ncur->nnext = NULL; - ncur->nname = typeline; - *(typeline+3) = (char)NULL; - typeline += 4; - getdata(ncur->nparms,69,3); - ncur->nnext = nlist; - nlist = ncur; - } else if(strncmp("pm",typeline,2) == 0) { - pcur = (pmod *)malloc(sizeof(pmod)); - pcur->pnext = NULL; - pcur->pname = typeline; - *(typeline+3) = (char)NULL; - typeline += 4; - getdata(pcur->pparms,69,3); - pcur->pnext = plist; - plist = pcur; - } else if(strncmp("py",typeline,2) == 0) { - ycur = (ymod *)malloc(sizeof(ymod)); - ycur->ynext = NULL; - ycur->yname = typeline; - *(typeline+3) = (char)NULL; - typeline += 4; - getdata(ycur->yparms,10,5); - ycur->ynext = ylist; - ylist = ycur; - } else if(strncmp("du",typeline,2) == 0) { - dcur = (dmod *)malloc(sizeof(dmod)); - dcur->dnext = NULL; - dcur->dname = typeline; - *(typeline+3) = (char)NULL; - typeline += 4; - getdata(dcur->dparms,10,5); - dcur->dnext = dlist; - dlist = dcur; - } else if(strncmp("ml",typeline,2) == 0) { - mcur = (mmod *)malloc(sizeof(mmod)); - mcur->mnext = NULL; - mcur->mname = typeline; - *(typeline+3) = (char)NULL; - typeline += 4; - getdata(mcur->mparms,10,5); - mcur->mnext = mlist; - mlist = mcur; - } else { - printf(" illegal header line in process file: run terminated\n"); - printf(" error occurred while parsing %s\n",typeline); - exit(1); - } - } - for(dcur=dlist;dcur;dcur=dcur->dnext) { - fprintf(m,".model %s_%s r rsh = %g defw = %g narrow = %g\n", - prname,dcur->dname,dcur->dparms[0],dcur->dparms[8],dcur->dparms[9]); - fprintf(m,".model %s_%s c cj = %g cjsw = %g defw = %g narrow = %g\n", - prname,dcur->dname,dcur->dparms[1],dcur->dparms[2],dcur->dparms[8], - dcur->dparms[9]); - } - for(ycur=ylist;ycur;ycur=ycur->ynext) { - fprintf(m,".model %s_%s r rsh = %g defw = %g narrow = %g\n", - prname,ycur->yname,ycur->yparms[0],ycur->yparms[8],ycur->yparms[9]); - fprintf(m,".model %s_%s c cj = %g cjsw = %g defw = %g narrow = %g\n", - prname,ycur->yname,ycur->yparms[1],ycur->yparms[2],ycur->yparms[8], - ycur->yparms[9]); - } - for(mcur=mlist;mcur;mcur=mcur->mnext) { - fprintf(m,".model %s_%s r rsh = %g defw = %g narrow = %g\n", - prname,mcur->mname,mcur->mparms[0],mcur->mparms[8],mcur->mparms[9]); - fprintf(m,".model %s_%s c cj = %g cjsw = %g defw = %g narrow = %g\n", - prname,mcur->mname,mcur->mparms[1],mcur->mparms[2],mcur->mparms[8], - mcur->mparms[9]); - } - for(pcur=plist;pcur;pcur=pcur->pnext) { - for(dcur=dlist;dcur;dcur=dcur->dnext) { - fprintf(m,".model %s_%s_%s pmos level=4\n",prname,pcur->pname, - dcur->dname); - fprintf(m,"+ vfb = %g lvfb = %g wvfb = %g\n", - pcur->pparms[0],pcur->pparms[1],pcur->pparms[2]); - fprintf(m,"+ phi = %g lphi = %g wphi = %g\n", - pcur->pparms[3],pcur->pparms[4],pcur->pparms[5]); - fprintf(m,"+ k1 = %g lk1 = %g wk1 = %g\n", - pcur->pparms[6],pcur->pparms[7],pcur->pparms[8]); - fprintf(m,"+ k2 = %g lk2 = %g wk2 = %g\n", - pcur->pparms[9],pcur->pparms[10],pcur->pparms[11]); - fprintf(m,"+ eta = %g leta = %g weta = %g\n", - pcur->pparms[12],pcur->pparms[13],pcur->pparms[14]); - fprintf(m,"+ muz = %g dl = %g dw = %g\n", - pcur->pparms[15],pcur->pparms[16],pcur->pparms[17]); - fprintf(m,"+ u0 = %g lu0 = %g wu0 = %g\n", - pcur->pparms[18],pcur->pparms[19],pcur->pparms[20]); - fprintf(m,"+ u1 = %g lu1 = %g wu1 = %g\n", - pcur->pparms[21],pcur->pparms[22],pcur->pparms[23]); - fprintf(m,"+ x2mz = %g lx2mz = %g wx2mz = %g\n", - pcur->pparms[24],pcur->pparms[25],pcur->pparms[26]); - fprintf(m,"+ x2e = %g lx2e = %g wx2e = %g\n", - pcur->pparms[27],pcur->pparms[28],pcur->pparms[29]); - fprintf(m,"+ x3e = %g lx3e = %g wx3e = %g\n", - pcur->pparms[30],pcur->pparms[31],pcur->pparms[32]); - fprintf(m,"+ x2u0 = %g lx2u0 = %g wx2u0 = %g\n", - pcur->pparms[33],pcur->pparms[34],pcur->pparms[35]); - fprintf(m,"+ x2u1 = %g lx2u1 = %g wx2u1 = %g\n", - pcur->pparms[36],pcur->pparms[37],pcur->pparms[38]); - fprintf(m,"+ mus = %g lmus = %g wmus = %g\n", - pcur->pparms[39],pcur->pparms[40],pcur->pparms[41]); - fprintf(m,"+ x2ms = %g lx2ms = %g wx2ms = %g\n", - pcur->pparms[42],pcur->pparms[43],pcur->pparms[44]); - fprintf(m,"+ x3ms = %g lx3ms = %g wx3ms = %g\n", - pcur->pparms[45],pcur->pparms[46],pcur->pparms[47]); - fprintf(m,"+ x3u1 = %g lx3u1 = %g wx3u1 = %g\n", - pcur->pparms[48],pcur->pparms[49],pcur->pparms[50]); - fprintf(m,"+ tox = %g temp = %g vdd = %g\n", - pcur->pparms[51],pcur->pparms[52],pcur->pparms[53]); - fprintf(m,"+ cgdo = %g cgso = %g cgbo = %g\n", - pcur->pparms[54],pcur->pparms[55],pcur->pparms[56]); - fprintf(m,"+ xpart = %g \n", - pcur->pparms[57]); - fprintf(m,"+ n0 = %g ln0 = %g wn0 = %g\n", - pcur->pparms[60],pcur->pparms[61],pcur->pparms[62]); - fprintf(m,"+ nb = %g lnb = %g wnb = %g\n", - pcur->pparms[63],pcur->pparms[64],pcur->pparms[65]); - fprintf(m,"+ nd = %g lnd = %g wnd = %g\n", - pcur->pparms[66],pcur->pparms[67],pcur->pparms[68]); - fprintf(m,"+ rsh = %g cj = %g cjsw = %g\n", - dcur->dparms[0], dcur->dparms[1], dcur->dparms[2]); - fprintf(m,"+ js = %g pb = %g pbsw = %g\n", - dcur->dparms[3], dcur->dparms[4], dcur->dparms[5]); - fprintf(m,"+ mj = %g mjsw = %g wdf = %g\n", - dcur->dparms[6], dcur->dparms[7], dcur->dparms[8]); - fprintf(m,"+ dell = %g\n", - dcur->dparms[9]); - } - } - for(ncur=nlist;ncur;ncur=ncur->nnext) { - for(dcur=dlist;dcur;dcur=dcur->dnext) { - fprintf(m,".model %s_%s_%s nmos level=4\n",prname,ncur->nname, - dcur->dname); - fprintf(m,"+ vfb = %g lvfb = %g wvfb = %g\n", - ncur->nparms[0],ncur->nparms[1],ncur->nparms[2]); - fprintf(m,"+ phi = %g lphi = %g wphi = %g\n", - ncur->nparms[3],ncur->nparms[4],ncur->nparms[5]); - fprintf(m,"+ k1 = %g lk1 = %g wk1 = %g\n", - ncur->nparms[6],ncur->nparms[7],ncur->nparms[8]); - fprintf(m,"+ k2 = %g lk2 = %g wk2 = %g\n", - ncur->nparms[9],ncur->nparms[10],ncur->nparms[11]); - fprintf(m,"+ eta = %g leta = %g weta = %g\n", - ncur->nparms[12],ncur->nparms[13],ncur->nparms[14]); - fprintf(m,"+ muz = %g dl = %g dw = %g\n", - ncur->nparms[15],ncur->nparms[16],ncur->nparms[17]); - fprintf(m,"+ u0 = %g lu0 = %g wu0 = %g\n", - ncur->nparms[18],ncur->nparms[19],ncur->nparms[20]); - fprintf(m,"+ u1 = %g lu1 = %g wu1 = %g\n", - ncur->nparms[21],ncur->nparms[22],ncur->nparms[23]); - fprintf(m,"+ x2mz = %g lx2mz = %g wx2mz = %g\n", - ncur->nparms[24],ncur->nparms[25],ncur->nparms[26]); - fprintf(m,"+ x2e = %g lx2e = %g wx2e = %g\n", - ncur->nparms[27],ncur->nparms[28],ncur->nparms[29]); - fprintf(m,"+ x3e = %g lx3e = %g wx3e = %g\n", - ncur->nparms[30],ncur->nparms[31],ncur->nparms[32]); - fprintf(m,"+ x2u0 = %g lx2u0 = %g wx2u0 = %g\n", - ncur->nparms[33],ncur->nparms[34],ncur->nparms[35]); - fprintf(m,"+ x2u1 = %g lx2u1 = %g wx2u1 = %g\n", - ncur->nparms[36],ncur->nparms[37],ncur->nparms[38]); - fprintf(m,"+ mus = %g lmus = %g wmus = %g\n", - ncur->nparms[39],ncur->nparms[40],ncur->nparms[41]); - fprintf(m,"+ x2ms = %g lx2ms = %g wx2ms = %g\n", - ncur->nparms[42],ncur->nparms[43],ncur->nparms[44]); - fprintf(m,"+ x3ms = %g lx3ms = %g wx3ms = %g\n", - ncur->nparms[45],ncur->nparms[46],ncur->nparms[47]); - fprintf(m,"+ x3u1 = %g lx3u1 = %g wx3u1 = %g\n", - ncur->nparms[48],ncur->nparms[49],ncur->nparms[50]); - fprintf(m,"+ tox = %g temp = %g vdd = %g\n", - ncur->nparms[51],ncur->nparms[52],ncur->nparms[53]); - fprintf(m,"+ cgdo = %g cgso = %g cgbo = %g\n", - ncur->nparms[54],ncur->nparms[55],ncur->nparms[56]); - fprintf(m,"+ xpart = %g \n", - ncur->nparms[57]); - fprintf(m,"+ n0 = %g ln0 = %g wn0 = %g\n", - ncur->nparms[60],ncur->nparms[61],ncur->nparms[62]); - fprintf(m,"+ nb = %g lnb = %g wnb = %g\n", - ncur->nparms[63],ncur->nparms[64],ncur->nparms[65]); - fprintf(m,"+ nd = %g lnd = %g wnd = %g\n", - ncur->nparms[66],ncur->nparms[67],ncur->nparms[68]); - fprintf(m,"+ rsh = %g cj = %g cjsw = %g\n", - dcur->dparms[0], dcur->dparms[1], dcur->dparms[2]); - fprintf(m,"+ js = %g pb = %g pbsw = %g\n", - dcur->dparms[3], dcur->dparms[4], dcur->dparms[5]); - fprintf(m,"+ mj = %g mjsw = %g wdf = %g\n", - dcur->dparms[6], dcur->dparms[7], dcur->dparms[8]); - fprintf(m,"+ dell = %g\n", - dcur->dparms[9]); - } - } - return EXIT_NORMAL; -} - -void -getdata(vals,count,width) - double vals[]; - int count; - int width; /* maximum number of values to accept per line */ -{ - int i; - int error; - int start; - char *c; - - do { - if(fgets(dataline,1023,p)==NULL) { - printf("premature end of file getting input data line\n"); - exit(1); - } - start=0; - } while (*dataline == '*') ; - c = dataline; - for(i=0;iwidth)) { /* end of line, so read another one */ - do { - if(fgets(dataline,1023,p)==NULL) { - printf("premature end of file reading input data line \n"); - exit(1); - } - start=0; - } while (*dataline == '*') ; - c = dataline; - goto retry; - } - } -} diff --git a/src/sconvert.c b/src/sconvert.c deleted file mode 100644 index 1ff4ee425..000000000 --- a/src/sconvert.c +++ /dev/null @@ -1,440 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group -**********/ - -/* - * Main routine for sconvert. - */ - -#include "ngspice.h" -#include -#include "cpdefs.h" -#include "ftedefs.h" -#include "ftedata.h" -#include "suffix.h" - -FILE *cp_in = 0; -FILE *cp_out = 0; -FILE *cp_err = 0; -FILE *cp_curin = 0; -FILE *cp_curout = 0; -FILE *cp_curerr = 0; -int cp_maxhistlength; -bool cp_debug = FALSE; -char cp_chars[128]; -bool cp_nocc = TRUE; -bool ft_parsedb = FALSE; -struct circ *ft_curckt = NULL; - -char *cp_program = "sconvert"; - -/* doesn't get used, but some unused routine in some file references it */ -char out_pbuf[BSIZE_SP]; - -static void oldwrite(); -static struct plot *oldread(); -static char *fixdate(); - -int -main(ac, av) - char **av; -{ - char *sf, *af; - char buf[BSIZE_SP]; - char t, f; - struct plot *pl; - int i; - char *infile; - char *outfile; - FILE *fp; - cp_in = stdin; - cp_out = stdout; - cp_err = stderr; - cp_curin = stdin; - cp_curout = stdout; - cp_curerr = stderr; - - switch (ac) { - case 5: - sf = av[2]; - af = av[4]; - f = *av[1]; - t = *av[3]; - break; - - case 3: - f = *av[1]; - t = *av[2]; - /* This is a pain, but there is no choice */ - sf = infile = smktemp("scin"); - af = outfile = smktemp("scout"); - if (!(fp = fopen(infile, "w"))) { - perror(infile); - exit(EXIT_BAD); - } - while ((i = fread(buf, 1, sizeof(buf), stdin))) - (void) fwrite(buf, 1, i, fp); - (void) fclose(fp); - break; - - case 1: printf("Input file: "); - (void) fflush(stdout); - (void) fgets(buf, BSIZE_SP, stdin); - sf = copy(buf); - printf("Input type: "); - (void) fflush(stdout); - (void) fgets(buf, BSIZE_SP, stdin); - f = buf[0]; - printf("Output file: "); - (void) fflush(stdout); - (void) fgets(buf, BSIZE_SP, stdin); - af = copy(buf); - printf("Output type: "); - (void) fflush(stdout); - (void) fgets(buf, BSIZE_SP, stdin); - t = buf[0]; - break; - default: - fprintf(cp_err, - "Usage: %s fromtype fromfile totype tofile,\n", - cp_program); - fprintf(cp_err, "\twhere types are o, b, or a\n"); - fprintf(cp_err, - "\tor, %s fromtype totype, used as a filter.\n", - cp_program); - exit(EXIT_BAD); - } - switch(f) { - case 'o' : - pl = oldread(sf); - break; - - case 'b' : - case 'a' : - pl = raw_read(sf); - break; - - default: - fprintf(cp_err, "Types are o, a, or b\n"); - exit(EXIT_BAD); - } - if (!pl) - exit(EXIT_BAD); - - switch(t) { - case 'o' : - oldwrite(af, FALSE, pl); - break; - - case 'b' : - raw_write(af, pl, FALSE, TRUE); - break; - - case 'a' : - raw_write(af, pl, FALSE, FALSE); - break; - - default: - fprintf(cp_err, "Types are o, a, or b\n"); - exit(EXIT_BAD); - } - if (ac == 3) { - /* Gotta finish this stuff up */ - if (!(fp = fopen(outfile, "r"))) { - perror(outfile); - exit(EXIT_BAD); - } - while ((i = fread(buf, 1, sizeof(buf), fp))) - (void) fwrite(buf, 1, i, stdout); - (void) fclose(fp); - (void) unlink(infile); - (void) unlink(outfile); - } - exit(EXIT_NORMAL); -} - -#define tfread(ptr, siz, nit, fp) if (fread((char *) (ptr), (siz), \ - (nit), (fp)) != (nit)) { \ - fprintf(cp_err, "Error: unexpected EOF\n"); \ - return (NULL); } - -#define tfwrite(ptr, siz, nit, fp) if (fwrite((char *) (ptr), (siz), \ - (nit), (fp)) != (nit)) { \ - fprintf(cp_err, "Write error\n"); \ - return; } - -static struct plot * -oldread(name) - char *name; -{ - struct plot *pl; - char buf[BSIZE_SP]; - struct dvec *v, *end = NULL; - short nv; /* # vars */ - long np; /* # points/var. */ - long i, j; - short a; /* The magic number. */ - float f1, f2; - FILE *fp; - - if (!(fp = fopen(name, "r"))) { - perror(name); - return (NULL); - } - pl = alloc(struct plot); - tfread(buf, 1, 80, fp); - buf[80] = '\0'; - for (i = strlen(buf) - 1; (i > 1) && (buf[i] == ' '); i--) - ; - buf[i + 1] = '\0'; - pl->pl_title = copy(buf); - - tfread(buf, 1, 16, fp); - buf[16] = '\0'; - pl->pl_date = copy(fixdate(buf)); - - tfread(&nv, sizeof (short), 1, fp); - - tfread(&a, sizeof (short), 1, fp); - if (a != 4) - fprintf(cp_err, "Warning: magic number 4 is wrong...\n"); - - for (i = 0; i < nv; i++) { - v = alloc(struct dvec); - if (end) - end->v_next = v; - else - pl->pl_scale = pl->pl_dvecs = v; - end = v; - tfread(buf, 1, 8, fp); - buf[8] = '\0'; - v->v_name = copy(buf); - } - for (v = pl->pl_dvecs; v; v = v->v_next) { - tfread(&a, sizeof (short), 1, fp); - v->v_type = a; - } - - /* If the first output variable is type FREQ then there is complex - * data, otherwise the data is real. - */ - i = pl->pl_dvecs->v_type; - if ((i == SV_FREQUENCY) || (i == SV_POLE) || (i == SV_ZERO)) - for (v = pl->pl_dvecs; v; v = v->v_next) - v->v_flags |= VF_COMPLEX; - else - for (v = pl->pl_dvecs; v; v = v->v_next) - v->v_flags |= VF_REAL; - - /* Check the node indices -- this shouldn't be a problem ever. */ - for (i = 0; i < nv; i++) { - tfread(&a, sizeof(short), 1, fp); - if (a != i + 1) - fprintf(cp_err, "Warning: output %d should be %ld\n", - a, i); - } - tfread(buf, 1, 24, fp); - buf[24] = '\0'; - pl->pl_name = copy(buf); - /* Now to figure out how many points of data there are left in - * the file. - */ - i = ftell(fp); - (void) fseek(fp, (long) 0, 2); - j = ftell(fp); - (void) fseek(fp, i, 0); - i = j - i; - if (i % 8) { /* Data points are always 8 bytes... */ - fprintf(cp_err, "Error: alignment error in data\n"); - (void) fclose(fp); - return (NULL); - } - i = i / 8; - if (i % nv) { - fprintf(cp_err, "Error: alignment error in data\n"); - (void) fclose(fp); - return (NULL); - } - np = i / nv; - - for (v = pl->pl_dvecs; v; v = v->v_next) { - v->v_length = np; - if (isreal(v)) { - v->v_realdata = (double *) tmalloc(sizeof (double) - * np); - } else { - v->v_compdata = (complex *) tmalloc(sizeof (complex) - * np); - } - } - for (i = 0; i < np; i++) { - /* Read in the output vector for point i. If the type is - * complex it will be float and we want double. - */ - for (v = pl->pl_dvecs; v; v = v->v_next) { - if (v->v_flags & VF_REAL) { - tfread(&v->v_realdata[i], sizeof (double), - 1, fp); - } else { - tfread(&f1, sizeof (float), 1, fp); - tfread(&f2, sizeof (float), 1, fp); - realpart(&v->v_compdata[i]) = f1; - imagpart(&v->v_compdata[i]) = f2; - } - } - } - (void) fclose(fp); - return (pl); -} - -static void -oldwrite(name, app, pl) - char *name; - bool app; - struct plot *pl; -{ - short four = 4, k; - struct dvec *v; - float f1, f2, zero = 0.0; - char buf[80]; - int i, j, tp = VF_REAL, numpts = 0, numvecs = 0; - FILE *fp; - - if (!(fp = fopen(name, app ? "a" : "w"))) { - perror(name); - return; - } - - for (v = pl->pl_dvecs; v; v = v->v_next) { - if (v->v_length > numpts) - numpts = v->v_length; - numvecs++; - if (iscomplex(v)) - tp = VF_COMPLEX; - } - - /* This may not be a good idea... */ - if (tp == VF_COMPLEX) - pl->pl_scale->v_type = SV_FREQUENCY; - - for (i = 0; i < 80; i++) - buf[i] = ' '; - for (i = 0; i < 80; i++) - if (pl->pl_title[i] == '\0') - break; - else - buf[i] = pl->pl_title[i]; - tfwrite(buf, 1, 80, fp); - - for (i = 0; i < 80; i++) - buf[i] = ' '; - for (i = 0; i < 16; i++) - if (pl->pl_date[i] == '\0') - break; - else - buf[i] = pl->pl_date[i]; - tfwrite(buf, 1, 16, fp); - - tfwrite(&numvecs, sizeof (short), 1, fp); - tfwrite(&four, sizeof (short), 1, fp); - - for (v = pl->pl_dvecs; v; v = v->v_next) { - for (j = 0; j < 80; j++) - buf[j] = ' '; - for (j = 0; j < 8; j++) - if (v->v_name[j] == '\0') - break; - else - buf[j] = v->v_name[j]; - tfwrite(buf, 1, 8, fp); - } - - for (v = pl->pl_dvecs; v; v = v->v_next) { - j = (short) v->v_type; - tfwrite(&j, sizeof (short), 1, fp); - } - - for (k = 1; k < numvecs + 1; k++) - tfwrite(&k, sizeof (short), 1, fp); - for (j = 0; j < 80; j++) - buf[j] = ' '; - for (j = 0; j < 24; j++) - if (pl->pl_name[j] == '\0') - break; - else - buf[j] = pl->pl_name[j]; - tfwrite(buf, 1, 24, fp); - for (i = 0; i < numpts; i++) { - for (v = pl->pl_dvecs; v; v = v->v_next) { - if ((tp == VF_REAL) && isreal(v)) { - if (i < v->v_length) { - tfwrite(&v->v_realdata[i], sizeof (double), 1, fp); - } else { - tfwrite(&v->v_realdata[v->v_length - 1], sizeof (double), 1, fp); - } - } else if ((tp == VF_REAL) && iscomplex(v)) { - if (i < v->v_length) - f1 = realpart(&v->v_compdata[i]); - else - f1 = realpart(&v->v_compdata[v-> v_length - 1]); - tfwrite(&f1, sizeof (double), 1, fp); - } else if ((tp == VF_COMPLEX) && isreal(v)) { - if (i < v->v_length) - f1 = v->v_realdata[i]; - else - f1 = v->v_realdata[v->v_length - 1]; - tfwrite(&f1, sizeof (float), 1, fp); - tfwrite(&zero, sizeof (float), 1, fp); - } else if ((tp == VF_COMPLEX) && iscomplex(v)) { - if (i < v->v_length) { - f1 = realpart(&v->v_compdata[i]); - f2 = imagpart(&v->v_compdata[i]); - } else { - f1 = realpart(&v->v_compdata[v-> v_length - 1]); - f2 = imagpart(&v->v_compdata[v-> v_length - 1]); - } - tfwrite(&f1, sizeof (float), 1, fp); - tfwrite(&f2, sizeof (float), 1, fp); - } - } - } - - (void) fclose(fp); - return; -} - -static char * -fixdate(date) - char *date; -{ - char buf[20]; - int i; - - (void) strcpy(buf, date); - for (i = 17; i > 8; i--) - buf[i] = buf[i - 1]; - buf[8] = ' '; - buf[18] = '\0'; - return (copy(buf)); -} - -void cp_pushcontrol() { } -void cp_popcontrol() { } -void out_init() { } -void cp_doquit() { exit(0); } -/* ARGSUSED */ void cp_usrvars(v1, v2) struct variable **v1, **v2; { return; } -/* ARGSUSED */ int cp_evloop(s) char *s; { return (0); } -/* ARGSUSED */ void cp_ccon(o) bool o; { } -/* ARGSUSED */ char *if_errstring(c) int c; { return ("error"); } -#ifndef out_printf -/* VARARGS1 ARGSUSED */ void out_printf(fmt, args) char *fmt; { } -#endif -/* ARGSUSED */ void out_send(string) char *string; {} -/* ARGSUSED */ struct variable * cp_enqvar(word) char *word; { return (NULL); } -/* ARGSUSED */ struct dvec *vec_get(word) char *word; { return (NULL); } -/* ARGSUSED */ void cp_ccom(w, b, e) wordlist *w; char *b; bool e; { return; } -/* ARGSUSED */ int cp_usrset(v, i) struct variable *v; bool i;{return(US_OK); } - -int disptype; -void XtDispatchEvent(pev) char *pev; {} diff --git a/src/spicelib/devices/asrc/ChangeLog b/src/spicelib/devices/asrc/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/bsim2/ChangeLog b/src/spicelib/devices/bsim2/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/bsim4/B4TERMS_OF_USE b/src/spicelib/devices/bsim4/B4TERMS_OF_USE deleted file mode 100644 index 5cc4023bb..000000000 --- a/src/spicelib/devices/bsim4/B4TERMS_OF_USE +++ /dev/null @@ -1,33 +0,0 @@ - -The terms under which the software is provided are as the following. - -Software is distributed as is, completely without warranty or service -support. The University of California and its employees are not liable -for the condition or performance of the software. - -The University owns the copyright but shall not be liable for any -infringement of copyright or other proprietary rights brought by third -parties against the users of the software. - -The University of California hereby disclaims all implied warranties. - -The University of California grants the users the right to modify, copy, -and redistribute the software and documentation, both within the user's -organization and externally, subject to the following restrictions: - -1. The users agree not to charge for the University of California code - itself but may charge for additions, extensions, or support. - -2. In any product based on the software, the users agree to acknowledge - the UC Berkeley BSIM Research Group that developed the software. This - acknowledgment shall appear in the product documentation. - -3. The users agree to obey all U.S. Government restrictions governing - redistribution or export of the software. - -4. The users agree to reproduce any copyright notice which appears on - the software on any copy or modification of such made available - to others. - -Chenming Hu, and Weidong Liu -Mar. 2000 diff --git a/src/spicelib/devices/cap/ChangeLog b/src/spicelib/devices/cap/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/cccs/ChangeLog b/src/spicelib/devices/cccs/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/ccvs/ChangeLog b/src/spicelib/devices/ccvs/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/csw/ChangeLog b/src/spicelib/devices/csw/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/devsup/ChangeLog b/src/spicelib/devices/devsup/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/devsup/Makefile.am b/src/spicelib/devices/devsup/Makefile.am deleted file mode 100644 index 9c2b5051a..000000000 --- a/src/spicelib/devices/devsup/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -## Process this file with automake to produce Makefile.in - -pkglib_LTLIBRARIES = libdevsup.la - -libdevsup_la_SOURCES = devsup.c - - - -INCLUDES = -I$(top_srcdir)/src/include -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/devsup/devsup.c b/src/spicelib/devices/devsup/devsup.c deleted file mode 100644 index f01dab3ab..000000000 --- a/src/spicelib/devices/devsup/devsup.c +++ /dev/null @@ -1,427 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - - /* support routines for device models */ - -#include "ngspice.h" -#include "devdefs.h" -#include "cktdefs.h" -#include "suffix.h" - - /* DEVlimvds(vnew,vold) - * limit the per-iteration change of VDS - */ - -double -DEVlimvds(vnew,vold) - double vnew; - double vold; - -{ - - if(vold >= 3.5) { - if(vnew > vold) { - vnew = MIN(vnew,(3 * vold) +2); - } else { - if (vnew < 3.5) { - vnew = MAX(vnew,2); - } - } - } else { - if(vnew > vold) { - vnew = MIN(vnew,4); - } else { - vnew = MAX(vnew,-.5); - } - } - return(vnew); -} - - - /* DEVpnjlim(vnew,vold,vt,vcrit,icheck) - * limit the per-iteration change of PN junction voltages - */ - - -double -DEVpnjlim(vnew,vold,vt,vcrit,icheck) - - double vnew; - double vold; - double vt; - double vcrit; - int *icheck; - -{ - double arg; - - if((vnew > vcrit) && (fabs(vnew - vold) > (vt + vt))) { - if(vold > 0) { - arg = 1 + (vnew - vold) / vt; - if(arg > 0) { - vnew = vold + vt * log(arg); - } else { - vnew = vcrit; - } - } else { - vnew = vt *log(vnew/vt); - } - *icheck = 1; - } else { - *icheck = 0; - } - return(vnew); -} - - /* - * DEVfetlim(vnew,vold.vto) - * - * limit the per-iteration change of FET voltages - */ - -double -DEVfetlim(vnew,vold,vto) - double vnew; - double vold; - double vto; - -{ - double vtsthi; - double vtstlo; - double vtox; - double delv; - double vtemp; - - vtsthi = fabs(2*(vold-vto))+2; - vtstlo = vtsthi/2 +2; - vtox = vto + 3.5; - delv = vnew-vold; - - if (vold >= vto) { - if(vold >= vtox) { - if(delv <= 0) { - /* going off */ - if(vnew >= vtox) { - if(-delv >vtstlo) { - vnew = vold - vtstlo; - } - } else { - vnew = MAX(vnew,vto+2); - } - } else { - /* staying on */ - if(delv >= vtsthi) { - vnew = vold + vtsthi; - } - } - } else { - /* middle region */ - if(delv <= 0) { - /* decreasing */ - vnew = MAX(vnew,vto-.5); - } else { - /* increasing */ - vnew = MIN(vnew,vto+4); - } - } - } else { - /* off */ - if(delv <= 0) { - if(-delv >vtsthi) { - vnew = vold - vtsthi; - } - } else { - vtemp = vto + .5; - if(vnew <= vtemp) { - if(delv >vtstlo) { - vnew = vold + vtstlo; - } - } else { - vnew = vtemp; - } - } - } - return(vnew); -} - - - /* - * DEVcmeyer(vgs0,vgd0,vgb0,von0,vdsat0, - * vgs1,vgd1,vgb1,covlgs,covlgd,covlgb, - * cgs0,cgd0,cgb0, - * von,vdsat) - * - * Compute the MOS overlap capacitances as functions of the - * device terminal voltages - */ - -void -DEVcmeyer(vgs0,vgd0,vgb0,von0,vdsat0, - vgs1,vgd1,vgb1,covlgs,covlgd,covlgb, - cgs,cgd,cgb, - phi,cox,von,vdsat) -double vgs0; /* initial voltage gate-source */ -double vgd0; /* initial voltage gate-drain */ -double vgb0; /* initial voltage gate-bulk */ -double von0; -double vdsat0; -double vgs1; /* final voltage gate-source */ -double vgd1; /* final voltage gate-drain */ -double vgb1; /* final voltage gate-bulk */ -double covlgs; /* overlap capacitance gate-source */ -double covlgd; /* overlap capacitance gate-drain */ -double covlgb; /* overlap capacitance gate-bulk */ -register double *cgs; -register double *cgd; -register double *cgb; -double phi; -double cox; -double von; -double vdsat; - -{ - - - double vdb; - double vdbsat; - double vddif; - double vddif1; - double vddif2; - double vgbt; - - *cgs = 0; - *cgd = 0; - *cgb = 0; - - vgbt = vgs1-von; - if (vgbt <= -phi) { - *cgb = cox; - } else if (vgbt <= -phi/2) { - *cgb = -vgbt*cox/phi; - } else if (vgbt <= 0) { - *cgb = -vgbt*cox/phi; - *cgs = cox/(7.5e-1*phi)*vgbt+cox/1.5; - } else { - vdbsat = vdsat-(vgs1-vgb1); - vdb = vgb1-vgd1; - if (vdbsat <= vdb) { - *cgs = cox/1.5; - } else { - vddif = 2.0*vdbsat-vdb; - vddif1 = vdbsat-vdb-1.0e-12; - vddif2 = vddif*vddif; - *cgd = cox*(1.0-vdbsat*vdbsat/vddif2)/1.5; - *cgs = cox*(1.0-vddif1*vddif1/vddif2)/1.5; - } - } - - vgbt = vgs0-von0; - if (vgbt <= -phi) { - *cgb += cox; - } else if (vgbt <= -phi/2) { - *cgb += -vgbt*cox/phi; - } else if (vgbt <= 0) { - *cgb += -vgbt*cox/phi; - *cgs += cox/(7.5e-1*phi)*vgbt+cox/1.5; - } else { - vdbsat = vdsat0-(vgs0-vgb0); - vdb = vgb0-vgd0; - if (vdbsat <= vdb) { - *cgs += cox/1.5; - } else { - vddif = 2.0*vdbsat-vdb; - vddif1 = vdbsat-vdb-1.0e-12; - vddif2 = vddif*vddif; - *cgd += cox*(1.0-vdbsat*vdbsat/vddif2)/1.5; - *cgs += cox*(1.0-vddif1*vddif1/vddif2)/1.5; - } - } - - *cgs = *cgs *.5 + covlgs; - *cgd = *cgd *.5 + covlgd; - *cgb = *cgb *.5 + covlgb; -} - - - /* - * DEVqmeyer(vgs,vgd,vgb,von,vdsat,capgs,capgd,capgb,phi,cox) - * - * - * - * Compute the MOS overlap capacitances as functions of the - * device terminal voltages - */ - -/* ARGSUSED */ /* because vgb is no longer used */ -void -DEVqmeyer(vgs,vgd,vgb,von,vdsat,capgs,capgd,capgb,phi,cox) -double vgs; /* initial voltage gate-source */ -double vgd; /* initial voltage gate-drain */ -double vgb; /* initial voltage gate-bulk */ -double von; -double vdsat; -double *capgs; /* non-constant portion of g-s overlap capacitance */ -double *capgd; /* non-constant portion of g-d overlap capacitance */ -double *capgb; /* non-constant portion of g-b overlap capacitance */ -double phi; -double cox; /* oxide capactiance */ - -{ - - - double vds; - double vddif; - double vddif1; - double vddif2; - double vgst; - - - vgst = vgs-von; - if (vgst <= -phi) { - *capgb = cox/2; - *capgs = 0; - *capgd = 0; - } else if (vgst <= -phi/2) { - *capgb = -vgst*cox/(2*phi); - *capgs = 0; - *capgd = 0; - } else if (vgst <= 0) { - *capgb = -vgst*cox/(2*phi); - *capgs = vgst*cox/(1.5*phi)+cox/3; - *capgd = 0; - } else { - vds = vgs-vgd; - if (vdsat <= vds) { - *capgs = cox/3; - *capgd = 0; - *capgb = 0; - } else { - vddif = 2.0*vdsat-vds; - vddif1 = vdsat-vds/*-1.0e-12*/; - vddif2 = vddif*vddif; - *capgd = cox*(1.0-vdsat*vdsat/vddif2)/3; - *capgs = cox*(1.0-vddif1*vddif1/vddif2)/3; - *capgb = 0; - } - } - -} - -#ifdef notdef -/* XXX This is no longer used, apparently */ -void -DEVcap(ckt,vgd,vgs,vgb,covlgd,covlgs,covlgb, - capbd,capbs,cggb,cgdb,cgsb,cbgb,cbdb,cbsb, - gcggb,gcgdb,gcgsb,gcbgb,gcbdb,gcbsb, - gcdgb,gcddb,gcdsb,gcsgb,gcsdb,gcssb, - qgate,qchan,qbulk,qdrn,qsrc,xqc) - -register CKTcircuit *ckt; - double vgd; - double vgs; - double vgb; - double covlgd; - double covlgs; - double covlgb; - double capbd; - double capbs; - double cggb; - double cgdb; - double cgsb; - double cbgb; - double cbdb; - double cbsb; - double *gcggb; - double *gcgdb; - double *gcgsb; - double *gcbgb; - double *gcbdb; - double *gcbsb; - double *gcdgb; - double *gcddb; - double *gcdsb; - double *gcsgb; - double *gcsdb; - double *gcssb; - double qgate; - double qchan; - double qbulk; - double *qdrn; - double *qsrc; - double xqc; - - /* - * compute equivalent conductances - * divide up the channel charge (1-xqc)/xqc to source and drain - */ -{ - - double gcd; - double gcdxd; - double gcdxs; - double gcg; - double gcgxd; - double gcgxs; - double gcs; - double gcsxd; - double gcsxs; - double qgb; - double qgd; - double qgs; - - gcg = (cggb+cbgb)*ckt->CKTag[1]; - gcd = (cgdb+cbdb)*ckt->CKTag[1]; - gcs = (cgsb+cbsb)*ckt->CKTag[1]; - gcgxd = -xqc*gcg; - gcgxs = -(1-xqc)*gcg; - gcdxd = -xqc*gcd; - gcdxs = -(1-xqc)*gcd; - gcsxd = -xqc*gcs; - gcsxs = -(1-xqc)*gcs; - *gcdgb = gcgxd-covlgd*ckt->CKTag[1]; - *gcddb = gcdxd+(capbd+covlgd)*ckt->CKTag[1]; - *gcdsb = gcsxd; - *gcsgb = gcgxs-covlgs*ckt->CKTag[1]; - *gcsdb = gcdxs; - *gcssb = gcsxs+(capbs+covlgs)*ckt->CKTag[1]; - *gcggb = (cggb+covlgd+covlgs+covlgb)*ckt->CKTag[1]; - *gcgdb = (cgdb-covlgd)*ckt->CKTag[1]; - *gcgsb = (cgsb-covlgs)*ckt->CKTag[1]; - *gcbgb = (cbgb-covlgb)*ckt->CKTag[1]; - *gcbdb = (cbdb-capbd)*ckt->CKTag[1]; - *gcbsb = (cbsb-capbs)*ckt->CKTag[1]; - /* - * compute total terminal charges - */ - qgd = covlgd*vgd; - qgs = covlgs*vgs; - qgb = covlgb*vgb; - qgate = qgate+qgd+qgs+qgb; - qbulk = qbulk-qgb; - *qdrn = xqc*qchan-qgd; - *qsrc = (1-xqc)*qchan-qgs; - /* - * finished - */ -} -#endif - -double DEVpred(ckt,loct) - CKTcircuit *ckt; - int loct; -{ - - /* predict a value for the capacitor at loct by - * extrapolating from previous values - */ - -#ifndef NEWTRUNC - double xfact; - xfact = ckt->CKTdelta/ckt->CKTdeltaOld[1]; - return( ( (1+xfact) * *(ckt->CKTstate1+loct) ) - - ( xfact * *(ckt->CKTstate2+loct) ) ); -#endif /*NEWTRUNC*/ - -} diff --git a/src/spicelib/devices/dio/ChangeLog b/src/spicelib/devices/dio/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/disto/ChangeLog b/src/spicelib/devices/disto/ChangeLog deleted file mode 100644 index b553d15b2..000000000 --- a/src/spicelib/devices/disto/ChangeLog +++ /dev/null @@ -1,4 +0,0 @@ -1999-09-08 Arno - - * *.c: reformatted; put prototypes in distodef.h; protoized. - diff --git a/src/spicelib/devices/disto/Makefile.am b/src/spicelib/devices/disto/Makefile.am deleted file mode 100644 index 4ee2e40dd..000000000 --- a/src/spicelib/devices/disto/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -## Process this file with automake to produce Makefile.in - -pkglib_LTLIBRARIES = libdisto.la - -libdisto_la_SOURCES = \ - atander.c \ - cosderiv.c \ - cubeder.c \ - divderiv.c \ - equalder.c \ - expderiv.c \ - invderiv.c \ - multder.c \ - plusder.c \ - powderiv.c \ - sqrtder.c \ - tanderiv.c \ - timesder.c - - - -INCLUDES = -I$(top_srcdir)/src/include -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/disto/atander.c b/src/spicelib/devices/disto/atander.c deleted file mode 100644 index e850004c2..000000000 --- a/src/spicelib/devices/disto/atander.c +++ /dev/null @@ -1,80 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * AtanDeriv computes the partial derivatives of the arctangent - * function where the argument to the atan function is itself a - * function of three variables p, q, and r. - */ - -void AtanDeriv(Dderivs *new, Dderivs *old) -{ - - Dderivs temp; - - EqualDeriv(&temp, old); - - new->value = atan( temp.value); - new->d1_p = temp.d1_p / (1 + temp.value * temp.value); - new->d1_q = temp.d1_q / (1 + temp.value * temp.value); - new->d1_r = temp.d1_r / (1 + temp.value * temp.value); - new->d2_p2 = temp.d2_p2 / (1 + temp.value * temp.value) - 2 * - temp.value * new->d1_p * new->d1_p; - new->d2_q2 = temp.d2_q2 / (1 + temp.value * temp.value) - 2 * - temp.value * new->d1_q * new->d1_q; - new->d2_r2 = temp.d2_r2 / (1 + temp.value * temp.value) - 2 * - temp.value * new->d1_r * new->d1_r; - new->d2_pq = temp.d2_pq / (1 + temp.value * temp.value) - 2 * - temp.value * new->d1_p * new->d1_q; - new->d2_qr = temp.d2_qr / (1 + temp.value * temp.value) - 2 * - temp.value * new->d1_q * new->d1_r; - new->d2_pr = temp.d2_pr / (1 + temp.value * temp.value) - 2 * - temp.value * new->d1_p * new->d1_r; - new->d3_p3 = (temp.d3_p3 - temp.d2_p2 * new->d1_p * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_p * new->d1_p * temp.d1_p + temp.value * - ( new->d2_p2 * new->d1_p + new->d2_p2 * new->d1_p)); - - new->d3_q3 = (temp.d3_q3 - temp.d2_q2 * new->d1_q * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_q * new->d1_q * temp.d1_q + temp.value * - ( new->d2_q2 * new->d1_q + new->d2_q2 * new->d1_q)); - new->d3_r3 = (temp.d3_r3 - temp.d2_r2 * new->d1_r * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_r * new->d1_r * temp.d1_r + temp.value * - ( new->d2_r2 * new->d1_r + new->d2_r2 * new->d1_r)); - new->d3_p2r = (temp.d3_p2r - temp.d2_p2 * new->d1_r * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_p * new->d1_p * temp.d1_r + temp.value * - ( new->d2_pr * new->d1_p + new->d2_pr * new->d1_p)); - new->d3_p2q = (temp.d3_p2q - temp.d2_p2 * new->d1_q * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_p * new->d1_p * temp.d1_q + temp.value * - ( new->d2_pq * new->d1_p + new->d2_pq * new->d1_p)); - new->d3_q2r = (temp.d3_q2r - temp.d2_q2 * new->d1_r * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_q * new->d1_q * temp.d1_r + temp.value * - ( new->d2_qr * new->d1_q + new->d2_qr * new->d1_q)); - new->d3_pq2 = (temp.d3_pq2 - temp.d2_q2 * new->d1_p * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_q * new->d1_q * temp.d1_p + temp.value * - ( new->d2_pq * new->d1_q + new->d2_pq * new->d1_q)); - new->d3_pr2 = (temp.d3_pr2 - temp.d2_r2 * new->d1_p * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_r * new->d1_r * temp.d1_p + temp.value * - ( new->d2_pr * new->d1_r + new->d2_pr * new->d1_r)); - new->d3_qr2 = (temp.d3_qr2 - temp.d2_r2 * new->d1_q * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_r * new->d1_r * temp.d1_q + temp.value * - ( new->d2_qr * new->d1_r + new->d2_qr * new->d1_r)); - new->d3_pqr = (temp.d3_pqr - temp.d2_pq * new->d1_r * 2 * - temp.value) / (1 + temp.value * temp.value) - 2 * - (new->d1_p * new->d1_q * temp.d1_r + temp.value * - ( new->d2_pr * new->d1_q + new->d2_qr * new->d1_p)); -} diff --git a/src/spicelib/devices/disto/cosderiv.c b/src/spicelib/devices/disto/cosderiv.c deleted file mode 100644 index 1c9752619..000000000 --- a/src/spicelib/devices/disto/cosderiv.c +++ /dev/null @@ -1,87 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * CosDeriv computes the partial derivatives of the cosine - * function where the argument to the function is itself a - * function of three variables p, q, and r. - */ - -void -CosDeriv(Dderivs *new, Dderivs *old) -{ - - Dderivs temp; - - EqualDeriv(&temp, old); - - new->value = cos (temp.value); - new->d1_p = - sin(temp.value)*temp.d1_p; - new->d1_q = - sin(temp.value)*temp.d1_q; - new->d1_r = - sin(temp.value)*temp.d1_r; - new->d2_p2 = -(cos(temp.value)*temp.d1_p*temp.d1_p + - sin(temp.value)*temp.d2_p2); - new->d2_q2 = -(cos(temp.value)*temp.d1_q*temp.d1_q + - sin(temp.value)*temp.d2_q2); - new->d2_r2 = -(cos(temp.value)*temp.d1_r*temp.d1_r + - sin(temp.value)*temp.d2_r2); - new->d2_pq = -(cos(temp.value)*temp.d1_p*temp.d1_q + - sin(temp.value)*temp.d2_pq); - new->d2_qr = -(cos(temp.value)*temp.d1_q*temp.d1_r + - sin(temp.value)*temp.d2_qr); - new->d2_pr = -(cos(temp.value)*temp.d1_p*temp.d1_r + - sin(temp.value)*temp.d2_pr); - new->d3_p3 = -(sin(temp.value)*(temp.d3_p3 - temp.d1_p*temp.d1_p*temp.d1_p) - + cos(temp.value)*(temp.d1_p*temp.d2_p2 + - temp.d1_p*temp.d2_p2 - + temp.d1_p*temp.d2_p2)); - new->d3_q3 = -(sin(temp.value)*(temp.d3_q3 - temp.d1_q*temp.d1_q*temp.d1_q) - + cos(temp.value)*(temp.d1_q*temp.d2_q2 + - temp.d1_q*temp.d2_q2 - + temp.d1_q*temp.d2_q2)); - new->d3_r3 = -(sin(temp.value)*(temp.d3_r3 - temp.d1_r*temp.d1_r*temp.d1_r) - + cos(temp.value)*(temp.d1_r*temp.d2_r2 + - temp.d1_r*temp.d2_r2 - + temp.d1_r*temp.d2_r2)); - new->d3_p2r = -(sin(temp.value)*(temp.d3_p2r - - temp.d1_r*temp.d1_p*temp.d1_p) - + cos(temp.value)*(temp.d1_p*temp.d2_pr + - temp.d1_p*temp.d2_pr - + temp.d1_r*temp.d2_p2)); - new->d3_p2q = -(sin(temp.value)*(temp.d3_p2q - - temp.d1_q*temp.d1_p*temp.d1_p) - + cos(temp.value)*(temp.d1_p*temp.d2_pq + - temp.d1_p*temp.d2_pq - + temp.d1_q*temp.d2_p2)); - new->d3_q2r = -(sin(temp.value)*(temp.d3_q2r - - temp.d1_r*temp.d1_q*temp.d1_q) - + cos(temp.value)*(temp.d1_q*temp.d2_qr + - temp.d1_q*temp.d2_qr - + temp.d1_r*temp.d2_q2)); - new->d3_pq2 = -(sin(temp.value)*(temp.d3_pq2 - - temp.d1_p*temp.d1_q*temp.d1_q) - + cos(temp.value)*(temp.d1_q*temp.d2_pq + - temp.d1_q*temp.d2_pq - + temp.d1_p*temp.d2_q2)); - new->d3_pr2 = -(sin(temp.value)*(temp.d3_pr2 - - temp.d1_p*temp.d1_r*temp.d1_r) - + cos(temp.value)*(temp.d1_r*temp.d2_pr + - temp.d1_r*temp.d2_pr - + temp.d1_p*temp.d2_r2)); - new->d3_qr2 = -(sin(temp.value)*(temp.d3_qr2 - - temp.d1_q*temp.d1_r*temp.d1_r) - + cos(temp.value)*(temp.d1_r*temp.d2_qr + - temp.d1_r*temp.d2_qr - + temp.d1_q*temp.d2_r2)); - new->d3_pqr = -(sin(temp.value)*(temp.d3_pqr - - temp.d1_r*temp.d1_p*temp.d1_q) - + cos(temp.value)*(temp.d1_q*temp.d2_pr + - temp.d1_p*temp.d2_qr - + temp.d1_r*temp.d2_pq)); -} diff --git a/src/spicelib/devices/disto/cubeder.c b/src/spicelib/devices/disto/cubeder.c deleted file mode 100644 index 97c35fb3d..000000000 --- a/src/spicelib/devices/disto/cubeder.c +++ /dev/null @@ -1,89 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * CubeDeriv computes the partial derivatives of the cube - * function where the argument to the function is itself a - * function of three variables p, q, and r. - */ - -void -CubeDeriv(Dderivs *new, Dderivs *old) -{ - Dderivs temp; - - EqualDeriv(&temp, old); - - new->value = temp.value * temp.value * temp.value; - new->d1_p = 3*temp.value*temp.value*temp.d1_p; - new->d1_q = 3*temp.value*temp.value*temp.d1_q; - new->d1_r = 3*temp.value*temp.value*temp.d1_r; - new->d2_p2 = 3*(2*temp.value*temp.d1_p*temp.d1_p - + temp.value*temp.value*temp.d2_p2); - new->d2_q2 = 3*(2*temp.value*temp.d1_q*temp.d1_q - + temp.value*temp.value*temp.d2_q2); - new->d2_r2 = 3*(2*temp.value*temp.d1_r*temp.d1_r - + temp.value*temp.value*temp.d2_r2); - new->d2_pq = 3*(2*temp.value*temp.d1_p*temp.d1_q - + temp.value*temp.value*temp.d2_pq); - new->d2_qr = 3*(2*temp.value*temp.d1_q*temp.d1_r - + temp.value*temp.value*temp.d2_qr); - new->d2_pr = 3*(2*temp.value*temp.d1_p*temp.d1_r - + temp.value*temp.value*temp.d2_pr); - new->d3_p3 = 3*(2*(temp.d1_p*temp.d1_p*temp.d1_p - + temp.value*(temp.d2_p2*temp.d1_p - + temp.d2_p2*temp.d1_p - + temp.d2_p2*temp.d1_p)) - + temp.value*temp.value*temp.d3_p3); - new->d3_q3 = 3*(2*(temp.d1_q*temp.d1_q*temp.d1_q - + temp.value*(temp.d2_q2*temp.d1_q - + temp.d2_q2*temp.d1_q - + temp.d2_q2*temp.d1_q)) - + temp.value*temp.value*temp.d3_q3); - new->d3_r3 = 3*(2*(temp.d1_r*temp.d1_r*temp.d1_r - + temp.value*(temp.d2_r2*temp.d1_r - + temp.d2_r2*temp.d1_r - + temp.d2_r2*temp.d1_r)) - + temp.value*temp.value*temp.d3_r3); - new->d3_p2r = 3*(2*(temp.d1_p*temp.d1_p*temp.d1_r - + temp.value*(temp.d2_p2*temp.d1_r - + temp.d2_pr*temp.d1_p - + temp.d2_pr*temp.d1_p)) - + temp.value*temp.value*temp.d3_p2r); - new->d3_p2q = 3*(2*(temp.d1_p*temp.d1_p*temp.d1_q - + temp.value*(temp.d2_p2*temp.d1_q - + temp.d2_pq*temp.d1_p - + temp.d2_pq*temp.d1_p)) - + temp.value*temp.value*temp.d3_p2q); - new->d3_q2r = 3*(2*(temp.d1_q*temp.d1_q*temp.d1_r - + temp.value*(temp.d2_q2*temp.d1_r - + temp.d2_qr*temp.d1_q - + temp.d2_qr*temp.d1_q)) - + temp.value*temp.value*temp.d3_q2r); - new->d3_pq2 = 3*(2*(temp.d1_q*temp.d1_q*temp.d1_p - + temp.value*(temp.d2_q2*temp.d1_p - + temp.d2_pq*temp.d1_q - + temp.d2_pq*temp.d1_q)) - + temp.value*temp.value*temp.d3_pq2); - new->d3_pr2 = 3*(2*(temp.d1_r*temp.d1_r*temp.d1_p - + temp.value*(temp.d2_r2*temp.d1_p - + temp.d2_pr*temp.d1_r - + temp.d2_pr*temp.d1_r)) - + temp.value*temp.value*temp.d3_pr2); - new->d3_qr2 = 3*(2*(temp.d1_r*temp.d1_r*temp.d1_q - + temp.value*(temp.d2_r2*temp.d1_q - + temp.d2_qr*temp.d1_r - + temp.d2_qr*temp.d1_r)) - + temp.value*temp.value*temp.d3_qr2); - new->d3_pqr = 3*(2*(temp.d1_p*temp.d1_q*temp.d1_r - + temp.value*(temp.d2_pq*temp.d1_r - + temp.d2_qr*temp.d1_p - + temp.d2_pr*temp.d1_q)) - + temp.value*temp.value*temp.d3_pqr); -} diff --git a/src/spicelib/devices/disto/divderiv.c b/src/spicelib/devices/disto/divderiv.c deleted file mode 100644 index bf1f394db..000000000 --- a/src/spicelib/devices/disto/divderiv.c +++ /dev/null @@ -1,134 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * DivDeriv computes the partial derivatives of the division - * function where the arguments to the function are - * functions of three variables p, q, and r. - */ - -void -DivDeriv(Dderivs *new, Dderivs *old1, Dderivs *old2) -{ - - Dderivs num, den; - - EqualDeriv(&num, old1); - EqualDeriv(&den, old2); - - new->value = num.value / den.value; - new->d1_p = (num.d1_p - num.value * den.d1_p / den.value) / den.value; - new->d1_q = (num.d1_q - num.value * den.d1_q / den.value) / den.value; - new->d1_r = (num.d1_r - num.value * den.d1_r / den.value) / den.value; - new->d2_p2 = (num.d2_p2 - den.d1_p * new->d1_p - - new->value * den.d2_p2 - + (den.d1_p * (new->value * den.d1_p - num.d1_p) - / den.value)) / den.value; - new->d2_q2 = (num.d2_q2 - den.d1_q * new->d1_q - - new->value * den.d2_q2 - + (den.d1_q * (new->value * den.d1_q - num.d1_q) - / den.value)) / den.value; - new->d2_r2 = (num.d2_r2 - den.d1_r * new->d1_r - new->value * - den.d2_r2 + den.d1_r * (new->value * den.d1_r - - num.d1_r) / den.value) / - den.value; - new->d2_pq = (num.d2_pq - den.d1_q * new->d1_p - new->value * - den.d2_pq + den.d1_p * (new->value * den.d1_q - - num.d1_q) / den.value) / - den.value; - new->d2_qr = (num.d2_qr - den.d1_r * new->d1_q - new->value * - den.d2_qr + den.d1_q * (new->value * den.d1_r - - num.d1_r) / den.value) / - den.value; - new->d2_pr = (num.d2_pr - den.d1_r * new->d1_p - new->value * - den.d2_pr + den.d1_p * (new->value * den.d1_r - - num.d1_r) / den.value) / - den.value; - new->d3_p3 = (-den.d1_p * new->d2_p2 + num.d3_p3 -den.d2_p2 * - new->d1_p - den.d1_p * new->d2_p2 - new->d1_p * - den.d2_p2 - new->value * den.d3_p3 - + (den.d1_p * (new->d1_p * den.d1_p + - new->value * den.d2_p2 - - num.d2_p2) + - (new->value * den.d1_p - num.d1_p) * - (den.d2_p2 - den.d1_p * den.d1_p / den.value)) - / den.value) / den.value; - new->d3_q3 = (-den.d1_q * new->d2_q2 + num.d3_q3 -den.d2_q2 * - new->d1_q - den.d1_q * new->d2_q2 - new->d1_q * - den.d2_q2 - new->value * den.d3_q3 + - (den.d1_q * (new->d1_q * den.d1_q + new->value * - den.d2_q2 - num.d2_q2) + - (new->value * den.d1_q - num.d1_q) * - (den.d2_q2 - den.d1_q * den.d1_q / den.value)) / - den.value) / den.value; - new->d3_r3 = (-den.d1_r * new->d2_r2 + num.d3_r3 -den.d2_r2 * - new->d1_r - den.d1_r * new->d2_r2 - new->d1_r * - den.d2_r2 - new->value * den.d3_r3 + - (den.d1_r * (new->d1_r * den.d1_r + new->value * - den.d2_r2 - num.d2_r2) + - (new->value * den.d1_r - num.d1_r) * - (den.d2_r2 - den.d1_r * den.d1_r / den.value)) / - den.value) / den.value; - new->d3_p2r = (-den.d1_r * new->d2_p2 + num.d3_p2r -den.d2_pr * - new->d1_p - den.d1_p * new->d2_pr - new->d1_r * - den.d2_p2 - new->value * den.d3_p2r + - (den.d1_p * (new->d1_r * den.d1_p + new->value * - den.d2_pr - num.d2_pr) + - (new->value * den.d1_p - num.d1_p) * - (den.d2_pr - den.d1_p * den.d1_r / den.value)) - / den.value) / den.value; - new->d3_p2q = (-den.d1_q * new->d2_p2 + num.d3_p2q -den.d2_pq * - new->d1_p - den.d1_p * new->d2_pq - new->d1_q * - den.d2_p2 - new->value * den.d3_p2q + - (den.d1_p * (new->d1_q * den.d1_p + new->value * - den.d2_pq - num.d2_pq) + - (new->value * den.d1_p - num.d1_p) * - (den.d2_pq - den.d1_p * den.d1_q / den.value)) / - den.value) / den.value; - new->d3_q2r = (-den.d1_r * new->d2_q2 + num.d3_q2r -den.d2_qr * - new->d1_q - den.d1_q * new->d2_qr - new->d1_r * - den.d2_q2 - new->value * den.d3_q2r + - (den.d1_q * (new->d1_r * den.d1_q + new->value * - den.d2_qr - num.d2_qr) + - (new->value * den.d1_q - num.d1_q) * - (den.d2_qr - den.d1_q * den.d1_r / den.value)) / - den.value) / den.value; - new->d3_pq2 = (-den.d1_p * new->d2_q2 + num.d3_pq2 -den.d2_pq * - new->d1_q - den.d1_q * new->d2_pq - new->d1_p * - den.d2_q2 - new->value * den.d3_pq2 + - (den.d1_q * (new->d1_p * den.d1_q + new->value * - den.d2_pq - num.d2_pq) + - (new->value * den.d1_q - num.d1_q) * - (den.d2_pq - den.d1_q * den.d1_p / den.value)) / - den.value) / den.value; - new->d3_pr2 = (-den.d1_p * new->d2_r2 + num.d3_pr2 -den.d2_pr * - new->d1_r - den.d1_r * new->d2_pr - new->d1_p * - den.d2_r2 - new->value * den.d3_pr2 + - (den.d1_r * (new->d1_p * den.d1_r + new->value * - den.d2_pr - num.d2_pr) + - (new->value * den.d1_r - num.d1_r) * - (den.d2_pr - den.d1_r * den.d1_p / den.value)) / - den.value) / den.value; - new->d3_qr2 = (-den.d1_q * new->d2_r2 + num.d3_qr2 -den.d2_qr * - new->d1_r - den.d1_r * new->d2_qr - new->d1_q * - den.d2_r2 - new->value * den.d3_qr2 + - (den.d1_r * (new->d1_q * den.d1_r + new->value * - den.d2_qr - num.d2_qr) + - (new->value * den.d1_r - num.d1_r) * - (den.d2_qr - den.d1_r * den.d1_q / den.value)) / - den.value) / den.value; - new->d3_pqr = (-den.d1_r * new->d2_pq + num.d3_pqr -den.d2_qr * - new->d1_p - den.d1_q * new->d2_pr - new->d1_r * - den.d2_pq - new->value * den.d3_pqr + - (den.d1_p * (new->d1_r * den.d1_q + new->value * - den.d2_qr - num.d2_qr) + - (new->value * den.d1_q - num.d1_q) * - (den.d2_pr - den.d1_p * den.d1_r / den.value)) / - den.value) / den.value; -} diff --git a/src/spicelib/devices/disto/equalder.c b/src/spicelib/devices/disto/equalder.c deleted file mode 100644 index e0274d29c..000000000 --- a/src/spicelib/devices/disto/equalder.c +++ /dev/null @@ -1,38 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * EqualDeriv equates partial derivatives. - */ - -void -EqualDeriv(Dderivs *new, Dderivs *old) -{ - -new->value = old->value; -new->d1_p = old->d1_p; -new->d1_q = old->d1_q; -new->d1_r = old->d1_r; -new->d2_p2 = old->d2_p2 ; -new->d2_q2 = old->d2_q2 ; -new->d2_r2 = old->d2_r2 ; -new->d2_pq = old->d2_pq ; -new->d2_qr = old->d2_qr ; -new->d2_pr = old->d2_pr ; -new->d3_p3 = old->d3_p3 ; -new->d3_q3 = old->d3_q3 ; -new->d3_r3 = old->d3_r3 ; -new->d3_p2r = old->d3_p2r ; -new->d3_p2q = old->d3_p2q ; -new->d3_q2r = old->d3_q2r ; -new->d3_pq2 = old->d3_pq2 ; -new->d3_pr2 = old->d3_pr2 ; -new->d3_qr2 = old->d3_qr2 ; -new->d3_pqr = old->d3_pqr ; -} diff --git a/src/spicelib/devices/disto/expderiv.c b/src/spicelib/devices/disto/expderiv.c deleted file mode 100644 index 239312c5b..000000000 --- a/src/spicelib/devices/disto/expderiv.c +++ /dev/null @@ -1,64 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * ExpDeriv computes the partial derivatives of the exponential - * function where the argument to the function is itself a - * function of three variables p, q, and r. - */ - -void -ExpDeriv(Dderivs *new, Dderivs *old) -{ - - Dderivs temp; - - EqualDeriv(&temp, old); - new->value = exp(temp.value); - new->d1_p = new->value*temp.d1_p; - new->d1_q = new->value*temp.d1_q; - new->d1_r = new->value*temp.d1_r; - new->d2_p2 = new->value*temp.d2_p2 + temp.d1_p*new->d1_p; - new->d2_q2 = new->value*temp.d2_q2 + temp.d1_q*new->d1_q; - new->d2_r2 = new->value*temp.d2_r2 + temp.d1_r*new->d1_r; - new->d2_pq = new->value*temp.d2_pq + temp.d1_p*new->d1_q; - new->d2_qr = new->value*temp.d2_qr + temp.d1_q*new->d1_r; - new->d2_pr = new->value*temp.d2_pr + temp.d1_p*new->d1_r; - new->d3_p3 = new->value*temp.d3_p3 + temp.d2_p2*new->d1_p - + temp.d2_p2*new->d1_p - + new->d2_p2*temp.d1_p; - new->d3_q3 = new->value*temp.d3_q3 + temp.d2_q2*new->d1_q - + temp.d2_q2*new->d1_q - + new->d2_q2*temp.d1_q; - new->d3_r3 = new->value*temp.d3_r3 + temp.d2_r2*new->d1_r - + temp.d2_r2*new->d1_r - + new->d2_r2*temp.d1_r; - new->d3_p2r = new->value*temp.d3_p2r + temp.d2_p2*new->d1_r - + temp.d2_pr*new->d1_p - + new->d2_pr*temp.d1_p; - new->d3_p2q = new->value*temp.d3_p2q + temp.d2_p2*new->d1_q - + temp.d2_pq*new->d1_p - + new->d2_pq*temp.d1_p; - new->d3_q2r = new->value*temp.d3_q2r + temp.d2_q2*new->d1_r - + temp.d2_qr*new->d1_q - + new->d2_qr*temp.d1_q; - new->d3_pq2 = new->value*temp.d3_pq2 + temp.d2_q2*new->d1_p - + temp.d2_pq*new->d1_q - + new->d2_pq*temp.d1_q; - new->d3_pr2 = new->value*temp.d3_pr2 + temp.d2_r2*new->d1_p - + temp.d2_pr*new->d1_r - + new->d2_pr*temp.d1_r; - new->d3_qr2 = new->value*temp.d3_qr2 + temp.d2_r2*new->d1_q - + temp.d2_qr*new->d1_r - + new->d2_qr*temp.d1_r; - new->d3_pqr = new->value*temp.d3_pqr + temp.d2_pq*new->d1_r - + temp.d2_pr*new->d1_q - + new->d2_qr*temp.d1_p; - -} diff --git a/src/spicelib/devices/disto/invderiv.c b/src/spicelib/devices/disto/invderiv.c deleted file mode 100644 index 06d9872c9..000000000 --- a/src/spicelib/devices/disto/invderiv.c +++ /dev/null @@ -1,64 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * InvDeriv computes the partial derivatives of the 1/x - * function where the argument to the function is itself a - * function of three variables p, q, and r. - */ - -void -InvDeriv(Dderivs *new, Dderivs *old) -{ - Dderivs temp; - - EqualDeriv(&temp, old); - - new->value = 1/temp.value; - new->d1_p = -new->value*new->value*temp.d1_p; - new->d1_q = -new->value*new->value*temp.d1_q; - new->d1_r = -new->value*new->value*temp.d1_r; - new->d2_p2 = -new->value*(2*new->d1_p*temp.d1_p + new->value*temp.d2_p2); - new->d2_q2 = -new->value*(2*new->d1_q*temp.d1_q + new->value*temp.d2_q2); - new->d2_r2 = -new->value*(2*new->d1_r*temp.d1_r + new->value*temp.d2_r2); - new->d2_pq = -new->value*(2*new->d1_q*temp.d1_p + new->value*temp.d2_pq); - new->d2_qr = -new->value*(2*new->d1_r*temp.d1_q + new->value*temp.d2_qr); - new->d2_pr = -new->value*(2*new->d1_r*temp.d1_p + new->value*temp.d2_pr); - new->d3_p3 = -(2*(temp.d1_p*new->d1_p*new->d1_p + new->value*( - new->d2_p2*temp.d1_p + new->d1_p*temp.d2_p2 + - new->d1_p*temp.d2_p2)) + new->value*new->value*temp.d3_p3); - new->d3_q3 = -(2*(temp.d1_q*new->d1_q*new->d1_q + new->value*( - new->d2_q2*temp.d1_q + new->d1_q*temp.d2_q2 + - new->d1_q*temp.d2_q2)) + new->value*new->value*temp.d3_q3); - new->d3_r3 = -(2*(temp.d1_r*new->d1_r*new->d1_r + new->value*( - new->d2_r2*temp.d1_r + new->d1_r*temp.d2_r2 + - new->d1_r*temp.d2_r2)) + new->value*new->value*temp.d3_r3); - new->d3_p2r = -(2*(temp.d1_p*new->d1_p*new->d1_r + new->value*( - new->d2_pr*temp.d1_p + new->d1_p*temp.d2_pr + - new->d1_r*temp.d2_p2)) + new->value*new->value*temp.d3_p2r); - new->d3_p2q = -(2*(temp.d1_p*new->d1_p*new->d1_q + new->value*( - new->d2_pq*temp.d1_p + new->d1_p*temp.d2_pq + - new->d1_q*temp.d2_p2)) + new->value*new->value*temp.d3_p2q); - new->d3_q2r = -(2*(temp.d1_q*new->d1_q*new->d1_r + new->value*( - new->d2_qr*temp.d1_q + new->d1_q*temp.d2_qr + - new->d1_r*temp.d2_q2)) + new->value*new->value*temp.d3_q2r); - new->d3_pq2 = -(2*(temp.d1_q*new->d1_q*new->d1_p + new->value*( - new->d2_pq*temp.d1_q + new->d1_q*temp.d2_pq + - new->d1_p*temp.d2_q2)) + new->value*new->value*temp.d3_pq2); - new->d3_pr2 = -(2*(temp.d1_r*new->d1_r*new->d1_p + new->value*( - new->d2_pr*temp.d1_r + new->d1_r*temp.d2_pr + - new->d1_p*temp.d2_r2)) + new->value*new->value*temp.d3_pr2); - new->d3_qr2 = -(2*(temp.d1_r*new->d1_r*new->d1_q + new->value*( - new->d2_qr*temp.d1_r + new->d1_r*temp.d2_qr + - new->d1_q*temp.d2_r2)) + new->value*new->value*temp.d3_qr2); - new->d3_pqr = -(2*(temp.d1_p*new->d1_q*new->d1_r + new->value*( - new->d2_qr*temp.d1_p + new->d1_q*temp.d2_pr + - new->d1_r*temp.d2_pq)) + new->value*new->value*temp.d3_pqr); - -} diff --git a/src/spicelib/devices/disto/multder.c b/src/spicelib/devices/disto/multder.c deleted file mode 100644 index 68a8d5a60..000000000 --- a/src/spicelib/devices/disto/multder.c +++ /dev/null @@ -1,81 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * MultDeriv computes the partial derivatives of the multiplication - * function where the arguments to the function are - * functions of three variables p, q, and r. - */ - -void -MultDeriv(Dderivs *new, Dderivs *old1, Dderivs *old2) -{ - Dderivs temp1, temp2; - - EqualDeriv(&temp1, old1); - EqualDeriv(&temp2, old2); - - new->value = temp1.value * temp2.value; - new->d1_p = temp1.d1_p*temp2.value + temp1.value*temp2.d1_p; - new->d1_q = temp1.d1_q*temp2.value + temp1.value*temp2.d1_q; - new->d1_r = temp1.d1_r*temp2.value + temp1.value*temp2.d1_r; - new->d2_p2 = temp1.d2_p2*temp2.value + temp1.d1_p*temp2.d1_p - + temp1.d1_p*temp2.d1_p + temp1.value*temp2.d2_p2; - new->d2_q2 = temp1.d2_q2*temp2.value + temp1.d1_q*temp2.d1_q - + temp1.d1_q*temp2.d1_q + temp1.value*temp2.d2_q2; - new->d2_r2 = temp1.d2_r2*temp2.value + temp1.d1_r*temp2.d1_r - + temp1.d1_r*temp2.d1_r + temp1.value*temp2.d2_r2; - new->d2_pq = temp1.d2_pq*temp2.value + temp1.d1_p*temp2.d1_q - + temp1.d1_q*temp2.d1_p + temp1.value*temp2.d2_pq; - new->d2_qr = temp1.d2_qr*temp2.value + temp1.d1_q*temp2.d1_r - + temp1.d1_r*temp2.d1_q + temp1.value*temp2.d2_qr; - new->d2_pr = temp1.d2_pr*temp2.value + temp1.d1_p*temp2.d1_r - + temp1.d1_r*temp2.d1_p + temp1.value*temp2.d2_pr; - new->d3_p3 = temp1.d3_p3*temp2.value + temp1.d2_p2*temp2.d1_p - + temp1.d2_p2*temp2.d1_p + temp2.d2_p2*temp1.d1_p - + temp2.d2_p2*temp1.d1_p + temp1.d2_p2*temp2.d1_p - + temp2.d2_p2*temp1.d1_p + temp1.value*temp2.d3_p3; - - new->d3_q3 = temp1.d3_q3*temp2.value + temp1.d2_q2*temp2.d1_q - + temp1.d2_q2*temp2.d1_q + temp2.d2_q2*temp1.d1_q - + temp2.d2_q2*temp1.d1_q + temp1.d2_q2*temp2.d1_q - + temp2.d2_q2*temp1.d1_q + temp1.value*temp2.d3_q3; - new->d3_r3 = temp1.d3_r3*temp2.value + temp1.d2_r2*temp2.d1_r - + temp1.d2_r2*temp2.d1_r + temp2.d2_r2*temp1.d1_r - + temp2.d2_r2*temp1.d1_r + temp1.d2_r2*temp2.d1_r - + temp2.d2_r2*temp1.d1_r + temp1.value*temp2.d3_r3; - new->d3_p2r = temp1.d3_p2r*temp2.value + temp1.d2_p2*temp2.d1_r - + temp1.d2_pr*temp2.d1_p + temp2.d2_p2*temp1.d1_r - + temp2.d2_pr*temp1.d1_p + temp1.d2_pr*temp2.d1_p - + temp2.d2_pr*temp1.d1_p + temp1.value*temp2.d3_p2r; - new->d3_p2q = temp1.d3_p2q*temp2.value + temp1.d2_p2*temp2.d1_q - + temp1.d2_pq*temp2.d1_p + temp2.d2_p2*temp1.d1_q - + temp2.d2_pq*temp1.d1_p + temp1.d2_pq*temp2.d1_p - + temp2.d2_pq*temp1.d1_p + temp1.value*temp2.d3_p2q; - new->d3_q2r = temp1.d3_q2r*temp2.value + temp1.d2_q2*temp2.d1_r - + temp1.d2_qr*temp2.d1_q + temp2.d2_q2*temp1.d1_r - + temp2.d2_qr*temp1.d1_q + temp1.d2_qr*temp2.d1_q - + temp2.d2_qr*temp1.d1_q + temp1.value*temp2.d3_q2r; - new->d3_pq2 = temp1.d3_pq2*temp2.value + temp1.d2_q2*temp2.d1_p - + temp1.d2_pq*temp2.d1_q + temp2.d2_q2*temp1.d1_p - + temp2.d2_pq*temp1.d1_q + temp1.d2_pq*temp2.d1_q - + temp2.d2_pq*temp1.d1_q + temp1.value*temp2.d3_pq2; - new->d3_pr2 = temp1.d3_pr2*temp2.value + temp1.d2_r2*temp2.d1_p - + temp1.d2_pr*temp2.d1_r + temp2.d2_r2*temp1.d1_p - + temp2.d2_pr*temp1.d1_r + temp1.d2_pr*temp2.d1_r - + temp2.d2_pr*temp1.d1_r + temp1.value*temp2.d3_pr2; - new->d3_qr2 = temp1.d3_qr2*temp2.value + temp1.d2_r2*temp2.d1_q - + temp1.d2_qr*temp2.d1_r + temp2.d2_r2*temp1.d1_q - + temp2.d2_qr*temp1.d1_r + temp1.d2_qr*temp2.d1_r - + temp2.d2_qr*temp1.d1_r + temp1.value*temp2.d3_qr2; - new->d3_pqr = temp1.d3_pqr*temp2.value + temp1.d2_pq*temp2.d1_r - + temp1.d2_pr*temp2.d1_q + temp2.d2_pq*temp1.d1_r - + temp2.d2_qr*temp1.d1_p + temp1.d2_qr*temp2.d1_p - + temp2.d2_pr*temp1.d1_q + temp1.value*temp2.d3_pqr; -} diff --git a/src/spicelib/devices/disto/plusder.c b/src/spicelib/devices/disto/plusder.c deleted file mode 100644 index 5c03a4d73..000000000 --- a/src/spicelib/devices/disto/plusder.c +++ /dev/null @@ -1,39 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * PlusDeriv computes the partial derivatives of the addition - * function where the arguments to the function are - * functions of three variables p, q, and r. - */ - -void -PlusDeriv(Dderivs *new, Dderivs *old1, Dderivs *old2) -{ - new->value = old1->value + old2->value; - new->d1_p = old1->d1_p + old2->d1_p; - new->d1_q = old1->d1_q + old2->d1_q; - new->d1_r = old1->d1_r + old2->d1_r; - new->d2_p2 = old1->d2_p2 + old2->d2_p2; - new->d2_q2 = old1->d2_q2 + old2->d2_q2; - new->d2_r2 = old1->d2_r2 + old2->d2_r2; - new->d2_pq = old1->d2_pq + old2->d2_pq; - new->d2_qr = old1->d2_qr + old2->d2_qr; - new->d2_pr = old1->d2_pr + old2->d2_pr; - new->d3_p3 = old1->d3_p3 + old2->d3_p3; - new->d3_q3 = old1->d3_q3 + old2->d3_q3; - new->d3_r3 = old1->d3_r3 + old2->d3_r3; - new->d3_p2r = old1->d3_p2r + old2->d3_p2r; - new->d3_p2q = old1->d3_p2q + old2->d3_p2q; - new->d3_q2r = old1->d3_q2r + old2->d3_q2r; - new->d3_pq2 = old1->d3_pq2 + old2->d3_pq2; - new->d3_pr2 = old1->d3_pr2 + old2->d3_pr2; - new->d3_qr2 = old1->d3_qr2 + old2->d3_qr2; - new->d3_pqr = old1->d3_pqr + old2->d3_pqr; -} diff --git a/src/spicelib/devices/disto/powderiv.c b/src/spicelib/devices/disto/powderiv.c deleted file mode 100644 index 054054af0..000000000 --- a/src/spicelib/devices/disto/powderiv.c +++ /dev/null @@ -1,81 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * PowDeriv computes the partial derivatives of the x^^m - * function where the argument to the function is itself a - * function of three variables p, q, and r. m is a constant. - */ - -void -PowDeriv(Dderivs *new, Dderivs *old, double emm) -{ - Dderivs temp; - - EqualDeriv(&temp, old); - - new->value = pow(temp.value, emm); - new->d1_p = emm * new->value / temp.value * temp.d1_p; - new->d1_q = emm * new->value / temp.value * temp.d1_q; - new->d1_r = emm * new->value / temp.value * temp.d1_r; - new->d2_p2 = emm * new->value / temp.value * - ((emm-1) / temp.value * temp.d1_p * temp.d1_p + temp.d2_p2); - new->d2_q2 = emm * new->value / temp.value * - ((emm-1) / temp.value * temp.d1_q * temp.d1_q + temp.d2_q2); - new->d2_r2 = emm * new->value / temp.value * - ((emm-1) / temp.value * temp.d1_r * temp.d1_r + temp.d2_r2); - new->d2_pq = emm * new->value / temp.value * - ((emm-1) / temp.value * temp.d1_p * temp.d1_q + temp.d2_pq); - new->d2_qr = emm * new->value / temp.value * - ((emm-1) / temp.value * temp.d1_q * temp.d1_r + temp.d2_qr); - new->d2_pr = emm * new->value / temp.value * - ((emm-1) / temp.value * temp.d1_p * temp.d1_r + temp.d2_pr); - new->d3_p3 = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_p * - temp.d1_p * temp.d1_p + temp.d1_p * temp.d2_p2 + temp.d1_p * - temp.d2_p2 + temp.d1_p * temp.d2_p2) + emm * new->value / - temp.value * temp.d3_p3; - new->d3_q3 = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_q * - temp.d1_q * temp.d1_q + temp.d1_q * temp.d2_q2 + temp.d1_q * - temp.d2_q2 + temp.d1_q * temp.d2_q2) + emm * new->value / - temp.value * temp.d3_q3; - new->d3_r3 = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_r *temp.d1_r * temp.d1_r + - temp.d1_r * temp.d2_r2 + temp.d1_r * temp.d2_r2 + temp.d1_r * - temp.d2_r2) + emm * new->value / temp.value * temp.d3_r3; - new->d3_p2r = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_p * temp.d1_p * temp.d1_r + - temp.d1_p * temp.d2_pr + temp.d1_p * temp.d2_pr + temp.d1_r * - temp.d2_p2) + emm * new->value / temp.value * temp.d3_p2r; - new->d3_p2q = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_p * temp.d1_p * temp.d1_q + - temp.d1_p * temp.d2_pq + temp.d1_p * temp.d2_pq + temp.d1_q * - temp.d2_p2) + emm * new->value / temp.value * temp.d3_p2q; - new->d3_q2r = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_q * temp.d1_q * temp.d1_r + - temp.d1_q * temp.d2_qr + temp.d1_q * temp.d2_qr + temp.d1_r * - temp.d2_q2) + emm * new->value / temp.value * temp.d3_q2r; - new->d3_pq2 = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_q * temp.d1_q * temp.d1_p + - temp.d1_q * temp.d2_pq + temp.d1_q * temp.d2_pq + temp.d1_p * - temp.d2_q2) + emm * new->value / temp.value * temp.d3_pq2; - new->d3_pr2 = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_r * temp.d1_r * temp.d1_p + - temp.d1_r * temp.d2_pr + temp.d1_r * temp.d2_pr + temp.d1_p * - temp.d2_r2) + emm * new->value / temp.value * temp.d3_pr2; - new->d3_qr2 = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_r * temp.d1_r * temp.d1_q + - temp.d1_r * temp.d2_qr + temp.d1_r * temp.d2_qr + temp.d1_q * - temp.d2_r2) + emm * new->value / temp.value * temp.d3_qr2; - new->d3_pqr = emm * (emm-1) * new->value / (temp.value * temp.value) * - ((emm-2) / temp.value * temp.d1_p * temp.d1_q * temp.d1_r + - temp.d1_p * temp.d2_qr + temp.d1_q * temp.d2_pr + temp.d1_r * - temp.d2_pq) + emm * new->value / temp.value * temp.d3_pqr; -} diff --git a/src/spicelib/devices/disto/sqrtder.c b/src/spicelib/devices/disto/sqrtder.c deleted file mode 100644 index 663f62993..000000000 --- a/src/spicelib/devices/disto/sqrtder.c +++ /dev/null @@ -1,122 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * SqrtDeriv computes the partial derivatives of the sqrt - * function where the argument to the function is itself a - * function of three variables p, q, and r. - */ - -void -SqrtDeriv(Dderivs *new, Dderivs *old) -{ - - Dderivs temp; - - EqualDeriv(&temp, old); - new->value = sqrt(temp.value); - if (temp.value == 0.0) - { - new->d1_p = 0.0; - new->d1_q = 0.0; - new->d1_r = 0.0; - new->d2_p2 = 0.0; - new->d2_q2 = 0.0; - new->d2_r2 = 0.0; - new->d2_pq = 0.0; - new->d2_qr = 0.0; - new->d2_pr = 0.0; - new->d3_p3 = 0.0; - new->d3_q3 = 0.0; - new->d3_r3 = 0.0; - new->d3_p2r = 0.0; - new->d3_p2q = 0.0; - new->d3_q2r = 0.0; - new->d3_pq2 = 0.0; - new->d3_pr2 = 0.0; - new->d3_qr2 = 0.0; - new->d3_pqr = 0.0; - } else { - new->d1_p = 0.5*temp.d1_p/new->value; - new->d1_q = 0.5*temp.d1_q/new->value; - new->d1_r = 0.5*temp.d1_r/new->value; - new->d2_p2 = 0.5/new->value * (temp.d2_p2 - 0.5 * temp.d1_p * - temp.d1_p/ temp.value); - new->d2_q2 = 0.5/new->value*(temp.d2_q2 -0.5 * temp.d1_q * - temp.d1_q/ temp.value); - new->d2_r2 = 0.5/new->value*(temp.d2_r2 -0.5 * temp.d1_r * - temp.d1_r/ temp.value); - new->d2_pq = 0.5/new->value*(temp.d2_pq -0.5 * temp.d1_p * - temp.d1_q/ temp.value); - new->d2_qr = 0.5/new->value*(temp.d2_qr -0.5 * temp.d1_q * - temp.d1_r/ temp.value); - new->d2_pr = 0.5/new->value*(temp.d2_pr -0.5 * temp.d1_p * - temp.d1_r/ temp.value); - new->d3_p3 = 0.5 * - (temp.d3_p3 / new->value - 0.5 / (temp.value*new->value) * - (-1.5 / temp.value * temp.d1_p * temp.d1_p * temp.d1_p - + temp.d1_p*temp.d2_p2 - + temp.d1_p*temp.d2_p2 - + temp.d1_p*temp.d2_p2)); - new->d3_q3 = 0.5 * - (temp.d3_q3 / new->value - 0.5 / (temp.value*new->value) * - (-1.5 / temp.value * temp.d1_q * temp.d1_q * temp.d1_q - + temp.d1_q*temp.d2_q2 - + temp.d1_q*temp.d2_q2 - + temp.d1_q* temp.d2_q2)); - new->d3_r3 = 0.5 * - (temp.d3_r3 / new->value - 0.5 / (temp.value*new->value) * - (-1.5 / temp.value * temp.d1_r * temp.d1_r * temp.d1_r - + temp.d1_r*temp.d2_r2 - + temp.d1_r*temp.d2_r2 - + temp.d1_r* temp.d2_r2)); - new->d3_p2r = 0.5 * - (temp.d3_p2r / new->value - 0.5 / (temp.value*new->value) * - (-1.5 / temp.value * temp.d1_p * temp.d1_p * temp.d1_r - + temp.d1_p * temp.d2_pr - + temp.d1_p * temp.d2_pr - + temp.d1_r * temp.d2_p2)); - new->d3_p2q = 0.5 * - (temp.d3_p2q / new->value - 0.5 / (temp.value * new->value) * - (-1.5/temp.value*temp.d1_p*temp.d1_p*temp.d1_q - + temp.d1_p * temp.d2_pq - + temp.d1_p * temp.d2_pq - + temp.d1_q * temp.d2_p2)); - new->d3_q2r = 0.5 * - (temp.d3_q2r / new->value - 0.5 / (temp.value * new->value) * - (-1.5 / temp.value * temp.d1_q * temp.d1_q * temp.d1_r - + temp.d1_q*temp.d2_qr - + temp.d1_q*temp.d2_qr - + temp.d1_r* temp.d2_q2)); - new->d3_pq2 = 0.5 * - (temp.d3_pq2 / new->value - 0.5 / (temp.value * new->value) * - (-1.5 / temp.value * temp.d1_q * temp.d1_q * temp.d1_p - + temp.d1_q*temp.d2_pq - + temp.d1_q*temp.d2_pq - + temp.d1_p* temp.d2_q2)); - new->d3_pr2 = 0.5 * - (temp.d3_pr2 / new->value - 0.5 / (temp.value * new->value) * - (-1.5/temp.value * temp.d1_r * temp.d1_r * temp.d1_p - + temp.d1_r*temp.d2_pr - + temp.d1_r*temp.d2_pr - + temp.d1_p* temp.d2_r2)); - new->d3_qr2 = 0.5 * - (temp.d3_qr2 / new->value - 0.5 / (temp.value * new->value) * - (-1.5/temp.value * temp.d1_r * temp.d1_r * temp.d1_q - + temp.d1_r*temp.d2_qr - + temp.d1_r*temp.d2_qr - + temp.d1_q* temp.d2_r2)); - new->d3_pqr = 0.5 * - (temp.d3_pqr / new->value - 0.5 / (temp.value * new->value) * - (-1.5/temp.value * temp.d1_p * temp.d1_q * temp.d1_r - + temp.d1_p*temp.d2_qr - + temp.d1_q*temp.d2_pr - + temp.d1_r* temp.d2_pq)); - } -} diff --git a/src/spicelib/devices/disto/tanderiv.c b/src/spicelib/devices/disto/tanderiv.c deleted file mode 100644 index fec1f78b4..000000000 --- a/src/spicelib/devices/disto/tanderiv.c +++ /dev/null @@ -1,64 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * TanDeriv computes the partial derivatives of the tangent - * function where the argument to the function is itself a - * function of three variables p, q, and r. - */ - -void TanDeriv(new, old) -Dderivs *new, *old; -{ - -Dderivs temp; - -EqualDeriv(&temp, old); -new->value = tan(temp.value); - -new->d1_p = (1 + new->value*new->value)*temp.d1_p; -new->d1_q = (1 + new->value*new->value)*temp.d1_q; -new->d1_r = (1 + new->value*new->value)*temp.d1_r; -new->d2_p2 = (1 + new->value*new->value)*temp.d2_p2 + 2*new->value*temp.d1_p*new->d1_p; -new->d2_q2 = (1 + new->value*new->value)*temp.d2_q2 + 2*new->value*temp.d1_q*new->d1_q; -new->d2_r2 = (1 + new->value*new->value)*temp.d2_r2 + 2*new->value*temp.d1_r*new->d1_r; -new->d2_pq = (1 + new->value*new->value)*temp.d2_pq + 2*new->value*temp.d1_p*new->d1_q; -new->d2_qr = (1 + new->value*new->value)*temp.d2_qr + 2*new->value*temp.d1_q*new->d1_r; -new->d2_pr = (1 + new->value*new->value)*temp.d2_pr + 2*new->value*temp.d1_p*new->d1_r; -new->d3_p3 = (1 + new->value*new->value)*temp.d3_p3 +2*( new->value*( - temp.d2_p2*new->d1_p + temp.d2_p2*new->d1_p + new->d2_p2* - temp.d1_p) + temp.d1_p*new->d1_p*new->d1_p); -new->d3_q3 = (1 + new->value*new->value)*temp.d3_q3 +2*( new->value*( - temp.d2_q2*new->d1_q + temp.d2_q2*new->d1_q + new->d2_q2* - temp.d1_q) + temp.d1_q*new->d1_q*new->d1_q); -new->d3_r3 = (1 + new->value*new->value)*temp.d3_r3 +2*( new->value*( - temp.d2_r2*new->d1_r + temp.d2_r2*new->d1_r + new->d2_r2* - temp.d1_r) + temp.d1_r*new->d1_r*new->d1_r); -new->d3_p2r = (1 + new->value*new->value)*temp.d3_p2r +2*( new->value*( - temp.d2_p2*new->d1_r + temp.d2_pr*new->d1_p + new->d2_pr* - temp.d1_p) + temp.d1_p*new->d1_p*new->d1_r); -new->d3_p2q = (1 + new->value*new->value)*temp.d3_p2q +2*( new->value*( - temp.d2_p2*new->d1_q + temp.d2_pq*new->d1_p + new->d2_pq* - temp.d1_p) + temp.d1_p*new->d1_p*new->d1_q); -new->d3_q2r = (1 + new->value*new->value)*temp.d3_q2r +2*( new->value*( - temp.d2_q2*new->d1_r + temp.d2_qr*new->d1_q + new->d2_qr* - temp.d1_q) + temp.d1_q*new->d1_q*new->d1_r); -new->d3_pq2 = (1 + new->value*new->value)*temp.d3_pq2 +2*( new->value*( - temp.d2_q2*new->d1_p + temp.d2_pq*new->d1_q + new->d2_pq* - temp.d1_q) + temp.d1_q*new->d1_q*new->d1_p); -new->d3_pr2 = (1 + new->value*new->value)*temp.d3_pr2 +2*( new->value*( - temp.d2_r2*new->d1_p + temp.d2_pr*new->d1_r + new->d2_pr* - temp.d1_r) + temp.d1_r*new->d1_r*new->d1_p); -new->d3_qr2 = (1 + new->value*new->value)*temp.d3_qr2 +2*( new->value*( - temp.d2_r2*new->d1_q + temp.d2_qr*new->d1_r + new->d2_qr* - temp.d1_r) + temp.d1_r*new->d1_r*new->d1_q); -new->d3_pqr = (1 + new->value*new->value)*temp.d3_pqr +2*( new->value*( - temp.d2_pq*new->d1_r + temp.d2_pr*new->d1_q + new->d2_qr* - temp.d1_p) + temp.d1_p*new->d1_q*new->d1_r); - } diff --git a/src/spicelib/devices/disto/timesder.c b/src/spicelib/devices/disto/timesder.c deleted file mode 100644 index b5ca429ab..000000000 --- a/src/spicelib/devices/disto/timesder.c +++ /dev/null @@ -1,39 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1989 Jaijeet S. Roychowdhury -**********/ - -#include "ngspice.h" -#include "distodef.h" -#include "suffix.h" - -/* - * TimesDeriv computes the partial derivatives of the x*k - * function where the argument to the function is itself a - * function of three variables p, q, and r. k is a constant. - */ - -void -TimesDeriv(Dderivs *new, Dderivs *old, double k) -{ - new->value = k* old->value; - new->d1_p = k*old->d1_p; - new->d1_q = k*old->d1_q; - new->d1_r = k*old->d1_r; - new->d2_p2 = k*old->d2_p2; - new->d2_q2 = k*old->d2_q2; - new->d2_r2 = k*old->d2_r2; - new->d2_pq = k*old->d2_pq; - new->d2_qr = k*old->d2_qr; - new->d2_pr = k*old->d2_pr; - new->d3_p3 = k*old->d3_p3; - new->d3_q3 = k*old->d3_q3; - new->d3_r3 = k*old->d3_r3; - new->d3_p2r = k*old->d3_p2r; - new->d3_p2q = k*old->d3_p2q; - new->d3_q2r = k*old->d3_q2r; - new->d3_pq2 = k*old->d3_pq2; - new->d3_pr2 = k*old->d3_pr2; - new->d3_qr2 = k*old->d3_qr2; - new->d3_pqr = k*old->d3_pqr; -} diff --git a/src/spicelib/devices/ind/ChangeLog b/src/spicelib/devices/ind/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/isrc/ChangeLog b/src/spicelib/devices/isrc/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/jfet/ChangeLog b/src/spicelib/devices/jfet/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/ltra/ChangeLog b/src/spicelib/devices/ltra/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/mes/ChangeLog b/src/spicelib/devices/mes/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/mos1/ChangeLog b/src/spicelib/devices/mos1/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/mos2/ChangeLog b/src/spicelib/devices/mos2/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/mos3/ChangeLog b/src/spicelib/devices/mos3/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/res/ChangeLog b/src/spicelib/devices/res/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/sw/ChangeLog b/src/spicelib/devices/sw/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/tra/ChangeLog b/src/spicelib/devices/tra/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/urc/ChangeLog b/src/spicelib/devices/urc/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/vccs/ChangeLog b/src/spicelib/devices/vccs/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/vcvs/ChangeLog b/src/spicelib/devices/vcvs/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/spicelib/devices/vsrc/ChangeLog b/src/spicelib/devices/vsrc/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/config.sh b/tests/config.sh deleted file mode 100644 index ea8e5d0b6..000000000 --- a/tests/config.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -NGSPICE=../src/ngspice -DIFFPIPE="Analysis|CPU|memory|Date|Note" - -function spicetest () { - $NGSPICE < $srcdir/$1.cir 2>&1 | egrep -v $DIFFPIPE > $1.test - if diff -u $1.test $srcdir/$1.out; then - rm $1.test - exit 0 - fi - exit 1 -} diff --git a/tests/diffpair.sh b/tests/diffpair.sh deleted file mode 100644 index 7baba1433..000000000 --- a/tests/diffpair.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -. $srcdir/config.sh -spicetest diffpair diff --git a/tests/fourbitadder.sh b/tests/fourbitadder.sh deleted file mode 100644 index 9bb086f30..000000000 --- a/tests/fourbitadder.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -. $srcdir/config.sh -spicetest fourbitadder diff --git a/tests/resistance/respart.cir b/tests/resistance/respart.cir deleted file mode 100644 index 9355a8148..000000000 --- a/tests/resistance/respart.cir +++ /dev/null @@ -1,9 +0,0 @@ -* Resistive partition with different ratios for AC/DC (Print V(2)) - -vin 1 0 DC 1V AC 1V -r1 1 2 5K -r2 2 0 5K ac=15k - -.OP -.AC DEC 10 1 10K -.END diff --git a/tests/resistance/test1.cir b/tests/resistance/test1.cir deleted file mode 100644 index 0ae7dc5b6..000000000 --- a/tests/resistance/test1.cir +++ /dev/null @@ -1,13 +0,0 @@ -A Simple AC Run - -.OPTIONS LIST NODE POST TRANS -.OP -.AC DEC 10 1k 1Meg -.PRINT AC V(2) - -V1 1 0 DC 0 AC 1 SIN 0 1 1K 0 0 DISTOF1 0 DISTOF2 0 -R1 1 2 10k -R2 2 0 10k -C1 2 0 1n - -.END diff --git a/tests/resistor.cir b/tests/resistor.cir deleted file mode 100644 index 53d885443..000000000 --- a/tests/resistor.cir +++ /dev/null @@ -1,9 +0,0 @@ -A simple resistor with a voltage source - -R1 1 0 10k -V1 1 0 1 - -.TRAN 1ns 6ns -.PRINT TRAN I(V1) - -.END diff --git a/tests/resistor.out b/tests/resistor.out deleted file mode 100644 index 979d85e20..000000000 --- a/tests/resistor.out +++ /dev/null @@ -1,75 +0,0 @@ - -Circuit: A simple resistor with a voltage source - -Circuit: A simple resistor with a voltage source - - - A simple resistor with a voltage source --------------------------------------------------------------------------------- -Index time v1#branch --------------------------------------------------------------------------------- -0 0.000000e+00 -1.000000e-04 -1 1.200000e-12 -1.000000e-04 -2 2.400000e-12 -1.000000e-04 -3 4.800000e-12 -1.000000e-04 -4 9.600000e-12 -1.000000e-04 -5 1.920000e-11 -1.000000e-04 -6 3.840000e-11 -1.000000e-04 -7 7.680000e-11 -1.000000e-04 -8 1.536000e-10 -1.000000e-04 -9 2.736000e-10 -1.000000e-04 -10 3.936000e-10 -1.000000e-04 -11 5.136000e-10 -1.000000e-04 -12 6.336000e-10 -1.000000e-04 -13 7.536000e-10 -1.000000e-04 -14 8.736000e-10 -1.000000e-04 -15 9.936000e-10 -1.000000e-04 -16 1.113600e-09 -1.000000e-04 -17 1.233600e-09 -1.000000e-04 -18 1.353600e-09 -1.000000e-04 -19 1.473600e-09 -1.000000e-04 -20 1.593600e-09 -1.000000e-04 -21 1.713600e-09 -1.000000e-04 -22 1.833600e-09 -1.000000e-04 -23 1.953600e-09 -1.000000e-04 -24 2.073600e-09 -1.000000e-04 -25 2.193600e-09 -1.000000e-04 -26 2.313600e-09 -1.000000e-04 -27 2.433600e-09 -1.000000e-04 -28 2.553600e-09 -1.000000e-04 -29 2.673600e-09 -1.000000e-04 -30 2.793600e-09 -1.000000e-04 -31 2.913600e-09 -1.000000e-04 -32 3.033600e-09 -1.000000e-04 -33 3.153600e-09 -1.000000e-04 -34 3.273600e-09 -1.000000e-04 -35 3.393600e-09 -1.000000e-04 -36 3.513600e-09 -1.000000e-04 -37 3.633600e-09 -1.000000e-04 -38 3.753600e-09 -1.000000e-04 -39 3.873600e-09 -1.000000e-04 -40 3.993600e-09 -1.000000e-04 -41 4.113600e-09 -1.000000e-04 -42 4.233600e-09 -1.000000e-04 -43 4.353600e-09 -1.000000e-04 -44 4.473600e-09 -1.000000e-04 -45 4.593600e-09 -1.000000e-04 -46 4.713600e-09 -1.000000e-04 -47 4.833600e-09 -1.000000e-04 -48 4.953600e-09 -1.000000e-04 -49 5.073600e-09 -1.000000e-04 -50 5.193600e-09 -1.000000e-04 -51 5.313600e-09 -1.000000e-04 -52 5.433600e-09 -1.000000e-04 -53 5.553600e-09 -1.000000e-04 -54 5.673600e-09 -1.000000e-04 - -Index time v1#branch --------------------------------------------------------------------------------- -55 5.793600e-09 -1.000000e-04 -56 5.913600e-09 -1.000000e-04 -57 6.000000e-09 -1.000000e-04 - - - - diff --git a/tests/resistor.sh b/tests/resistor.sh deleted file mode 100644 index 769e37207..000000000 --- a/tests/resistor.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -. $srcdir/config.sh -spicetest resistor