VSPICE3
IntroductionThis interface has been designed to represent an enhancement of the usual functionality found in analogue simulator user interfaces. In addition to the simulator setup functions and the graphical display facilities, the following additional features have been included: 1. Basic Functions
2. DSP functions, in doubleprecision complex arithmetic:
Some notes
Environment Variables
Two environment variables need to be set:
InvocationVspice3 may be invoked in one of four modes. Vspice3 drawing_nameIf Vspice3 is invoked with a drawing name as a command line argument, it looks for two files: either 'name.netlist' or 'name.ckt'.
Vspice3 b nameThis option permits the reviewing of a previous simulation by re reading the binary file 'name.bin'. Vspice3 searches the file 'name.netlist' for .PLOT and .PRINT commands to determine which signals to plot initially but, once the display appears, any voltage or current may be plotted on demand. If the name.netlist file does not exist, Vspice3 will prompt for the numbers of nodes to be plotted or, if a plot of current is required, for the name of the currentmeasuring voltage source.Vspice3 a nameIf data are available in ASCII format, as a result, for example, of data capture by a digital storage scope or other logging device, or even of manual generation, they may be presented to Vspice3 by entering the values in a file in the Berkeley ASCII file format presented below. This is the same format used by the 'wfms' test waveform generator supplied with this package. Namely:TITLE Comment Comment No. of columns No. of lines of data X_axis_variable ('TIME','FREQ',node_number / vsource_name) Y_variable_1 Y_variable_2 Y_variable_N Xcode (1=TIME, 2=FREQ, 3=DC) Ycode1 (3=voltage, 4=current) Ycode2 (3=voltage, 4=current) YcodeN (3=voltage, 4=current) Xdata Ydata1 Ydata2 ..YdataN Xdata Ydata1 Ydata2 ..YdataN Xdata Ydata1 Ydata2 ..YdataN Xdata Ydata1 Ydata2 ..YdataN Xdata Ydata1 Ydata2 ..YdataNAll numbers should be in floating point format (e.g 1.2e3) to conserve space in the columns, and columns should be separated by spaces. No blank lines should be inserted except the two near the top, which may be used for comments. More than eight signals may be specified, as long as the line length does not exceed 255 characters. Digital signals, for example, need only one character ('1' or '0') per column, and many more than eight may be accommodated. The function generator 'wfms', supplied with vspice3, creates a file 'wfms.asc' in the above format for test purposes. The file contains a timebase, two sines of different frequencies, cosine, square, sawtooth, sinc and pink noise functions. It also contains a unit impulse for checking the Inverse Fourier Transform (which will produce a real cosine and imaginary sine). Additionally, the file contains the impulse response of a bandpass filter, for checking the FFT.
vspice3The user interface starts up, and the mode of operation may be selected from a popup menu situated under the main menubar item 'RUN'. The modes are the same as from the command line, namely: from netlist, binary file or ASCII file. If it is desired to change simulators, from SPICE2G6 to Spice3, for example, this should be done before accessing this popup, since the simulator is started immediately that 'OK' is selected. Button and Menu FunctionsBuffer ToggleA pushbutton located at the lower right of the graph frame selects between the two waveform buffers, its legend switching to reflect the one currently displayed, as follows.
PROC BUFDisplays the current contents of the processing buffer.INPT BUFDisplays the current contents of the input buffer.
MAIN MENU BAR
Exits gracefully, deleting temporary files and directories in /tmp, created by deletions, group and cutandpaste operations.
The ASCII file read function enables more ASCII data to be read into the internal data structures. The file should be in the Berkeley format but, since the first column will also be displayed, it need not contain a sweep variable. This maximises the amount of data read from a 255 character Unix line. Ideally, the number of data points in the new data should be the same as that comprising the waveforms already displayed but, if the two are different, the new data will either be zeropadded or truncated depending on whether there are fewer or more points, respectively. The ability to read in as many ASCII files as required is especially useful when wishing to compare two sets of simulation results (see 'SAVE') or, perhaps, when there is a need to convolve a circuit's impulse response with an input waveform, so as to determine the subsequentlyintroduced distortion etc. The only limit on the amount of extra data read in is that the total number of displayed waveforms should not exceed forty, (unless, of course, the dynamic memory allocation runs out of core). The ASCII file dump function will dump the first ten waveforms on screen to the named file. If the process buffer is being displayed, it can write a single waveform including, if such exists, the phase/imaginary part. No phase or imaginary information is written from the input buffer, just the first ten magnitude/real waveforms Dumping a waveform from the process buffer is the preferred way of generating a stimulus waveform for a subsequent simulation. Note, however, that SPICE will not accept a PWL stimulus containing more than 512 points, so if it is necessary to use a longer waveform, use the decimation function incorporated in the interpolator. By sampling at a coarse rate, the number of points in the waveform are reduced but, of course, so are the fine details.
The popup which appears permits: Checks are carried out to ensure netlist compatibility and, if the selected simulator is incompatible, the other one is started (blindly). Although the two are broadly compatible, Spice3D2 has voltage/current controlled switches and also handles nonlinear dependent sources in a different manner, such that it will not accept a 'POLY(n)' definition. The other differences are that Spice3d2 is not useable for a NOISE or DISTO analysis. The reason is that the output is presented more as a table than a graph, and is not, at this time, plottable. It is wise to consider the analyses to be performed at the time of creation of the drawing, and to bear in mind the differences in the two simulators. If Spice3D2 is essential, the netlist can be rewritten and all 'POLY' statements changed to the new equation format. Before the simulation starts, vspice3 attempts to read the file name/spice.xref. From this, it reads the signal names corresponding to the node numbers it has been asked to plot in .plot or .print statements. When the results are plotted, each signal name is printed near the lower left corner of the corresponding trace. As the simulation proceeds, signals are plotted at the highest scale factor possible, and autoscaled in both X and Y. This gives maximum visibility to small features on each waveform, which might be otherwise missed. Whenever the signals reach full screen width, the horizontal axis scale factor is divided by two, and the screen redrawn. The vertical scaling algorithm attempts to divide up the graph area equally between all the waveforms, and then to keep them all approximately the same size. There is a rateofchange detector, which varies the scale factor more for a fasterchanging waveform than for one which changes slowly. With each X axis rescale, all waveforms are reassigned an equal portion of the graph area, in case one or other has grown in the interim. Vspice3 reads the simulator commands from the netlist to determine the length of the simulation. It then reads the binary file created by the simulator. If the simulator aborts before the binary file has been opened, vspice3 stops reading and returns to command mode. However, if the simulation begins, and the simulator aborts before the end of the run ("internal timestep too small..") vspice3 has no way of knowing this. It will be necessary to type CntlC in the shelltool to kill the process. Simulator diagnostics can then be read from the file name.out  where 'name' is the generic design name.
Vspice3 reads the binary file containing the previous simulation results to the end, and displays the waveforms specified by the ".print" or ".plot" statement found in the netlist. If none exists, it attempts to plot v(1) and, if this fails, plots nothing.
The file read is assumed to be generated by software, and therefore to be 'correct by construction', so no syntax errors are checked for. When creating the file by hand from instrumentation data, make sure that the two comment lines are inserted, and that the number of rows/columns is the actual number, not one less. The file 'wfms.asc' is syntactically correct, and may be used as a model. The source code for its generation is located at adt/manuals/wfms.c, and may serve as a template for the generation of such files. It should be noted that all of the above functions clear all internal data structures, and start afresh. Thus, all screen data is lost and overwritten with the new waveforms.
Displays the SETUP menu which appears at the right side of the screen, displacing the main menu, and enabling selection of the type of analysis, the nodes traced, and the circuit stimuli.
When a netlist is generated by GSP, it is placed in a file called
Prompts for selection of either a PostScript laser plotter or of a HewlettPackard HPGL penplotter. The entire graph area is converted to PostScript from internally stored data  this is not a screen dump  and all currently valid notes are also printed. Signal names stored alongside each waveform are not hardcopied, on the basis that the user may wish to otherwise annotate the hardcopy. If PostScript is selected, then the routine will perform hardcopy of all waveforms currently stored. If the waveform is the result of signal processing then only it will be printed, so if it is necessary to hardcopy just one waveform, perform a trivial operation, such as multiplying it by unity, or adding zero, and hardcopy the result. The PostScript hardcopy creates a file called 'spice.plot' in the format required by the psplot.vspice PostScript driver. This file is converted to PostScript format, and sent to the port /dev/ttya. If it is required to preview the hardcopy, it may be saved by performing the conversion by hand, and redirecting the results to a file. This file may be displayed with the Sun utility 'pageview' or GNU's 'ghostscript'. Type 'psplot.vspice spice.plot > file.ps' where 'file' is any name. Then type 'pageview h 11.7 w 8.27 left', and adjust the shape of the resulting window to fit the A4 plot in it. The creation of two shell scripts containing the above will save you some typing. If the HP plotter is selected, all waveforms will be printed in colour. The colour of the background grid and text is pen no.1, the other pens being selected sequentially for each subsequent colour. When plotting the results of an AC analysis, each waveform and its associated phase are plotted in the same colour, the phase being displayed as a dotted line. The default scale is 10, but may be changed in response to the prompt. On a 7580B plotter, a scale factor of 15 nearly fills a 23 x 32 sheet. A file named 'spice.plot' is produced, from which HPGL is produced by a utility called hpplot. The HPGL output is directed to the port /dev/ttya, so if the plotter is not connected here, it may be necessary to run hpplot by hand, and possibly save the output in an ASCII file, as described above for PostScript. All hardcopy operations are performed as background processes so as not to hold up further work. On a pitifully small system, Unix may not be able to start the subprocess necessary to perform a hardcopy, in which case a message is printed, and you should try again later. Note: The PostScript scale factors are set to fill an A4 sheet with the Vspice3 window at its default size. Changing the size of the window will change the size of the plot.
A prompt ('Enter note:') appears, and text may be entered for annotation of the display on the screen. Up to 80 characters per line may be entered and, when the carriage return is typed, the note attaches itself to the mouse cursor. It may be placed anywhere on the screen, and will appear in that position when hardcopied, either in Postscript or HP format. This fact should be borne in mind, since notes placed outside the grid will affect the scaling. Any Vspice3 function which clears the screen (e.g XFIT) will delete all notes from internal buffers, thus providing a means of correcting mistakes or of producing differently annotated versions of the same display. Although the screen area outside the grid is not cleared, this also applies to notes placed here. Core memory for notes is dynamically allocated in 80 byte segments, so the only restriction to the number of notes is the amount of RAM available. Note that the font used is a standard X11 font, whose size does not change with scaling. Accordingly, the text will always stay one size, even if the scale factor (HP plotter only) is changed.
Removes waveform selected by mouse from display and prompts for 'y' to continue. Typing anything other than a lowercase y aborts the command and redisplays the waveform. If deletion is confirmed, all waveforms are rescaled to use up the space left by the deleted waveform, the buffer entry for the waveform is cleared and the core memory made available for reuse.
Redisplays the data to fit exactly in the xaxis. All data currently in the buffers is displayed for every waveform. When the stored waveforms are a mixture of realtime waveforms and convolutions, correlations etc, it should be borne in mind that the timebases are different, and that any relative timings are illusory. XFIT does not redisplay signal names relating to waveforms, on the basis that the user may wish to annotate the display otherwise. On the other hand, YFIT does.
Divides the screen height by the number of waveforms and scales all waveforms to occupy the same height. Waveforms are positioned, in order of buffer number, starting at the top of the screen, to the centre of their allocated space. This is invoked automatically at the end of each simulation, or when waveforms are read in from a file. All signal names are redisplayed at the lower left of each waveform.
Prints the node number, value of xparameter and value of the y parameter in floating point format. If the file 'name.xref' exists, Vspice3 will have read it on startup and entered the signal names corresponding to the node numbers being plotted into its internal data structures. In these circumstances, 'MEASURE' will report the name of the signal instead of the node number. In the event of an ASCII input file, the signal names will have been read directly from the file. For AC analyses, the values printed are for frequency, magnitude, phase and group delay, or frequency, real and imaginary, depending on how the analysis was specified. Care must be taken when using this command on the results of signal processing, as shown below:
Yscale is volts/second per division, xscale is seconds.
Yscale is volts, xscale is seconds. Buffers are allocated in the order in which node numbers are specified in .PLOT/.PRINT commands in the netlist. The values printed are those of the nearest sample point.
Changes the right hand menubar so it displays all the available analyses. All the major analysis functions are selectable from this menu. All parameters are settable whether a drawing exists or not, since the popups which prompt for mouse entries all fill in dialog boxes, which can equally be filled in by hand. Thus simulation can be performed from old netlists, created by hand. Sets up all parameters of a transient analysis. There are four parameters to be entered. The starting time ("START"), defaults to zero, but can be any other value. Note, however, that the simulator still performs a simulation starting at time zero, but the data is not saved. This results in a delay before any waveforms appear on the screen. The stopping time ("STOP"), sets the value of the last time point calculated in the analysis, while the step time ("STEP") determines the time increment used for the simulation. The maximum number of data points which Vspice3 can store has been set at 16,384, and there is a check performed to ensure that (STOP  START) / STEP does not exceed this. However, since the simulator uses a variable time step while simulating, this may not always be an adequate safeguard. An important parameter is the maximum time step, TMAX. As was mentioned above, the simulator varies its time step during simulation. If, at a given point, convergence is not achieved with the userdefined time step, SPICE will divide the timestep by a factor of 8 and try again. It will repeat this a number of times set by the variable ITL4, before giving up ("Internal timestep too small..."). This is why ITL4 is a useful first line of defence against misconvergence. Its default is 10, so a value of 100 will determine whether your problem is permanent or not. If, however, the time point converges within the number of iterations set by the variable ITL3 (default is 4), then the timestep is doubled. This means that if not much is happening in your circuit, the simulation runs at its fastest possible speed whereas, if there are a lot of glitches and overshoots, the simulation will slow down to calculate them with maximum resolution. This is where TMAX comes in. If a simulation converges too easily, it is possible to get waveforms with a very ragged appearance, and no amount of adjustment of STEP will improve them. Setting TMAX to a reasonble value will prevent the simulator from increasing the timestep above this value. On the popup, the default value is STEP, which is, perhaps, a little extreme. If left at this value, most simulations will run very slowly, but accurately. For an initial simulation, it may be preferable to backspace over the value, and to leave it blank, or enter a zero. If this gives an unacceptable waveform, then enter a value equal to or greater than TSTEP.
Sets up all parameters of an AC analysis. START is the starting frequency, in Hz, and CANNOT BE ZERO. Its default is 1Hz. STOP is the highest frequency calculated, and should not be higher than around 50GHz, since the simulator loses accuracy, due to roundoff and truncation errors above this frequency. STEP sets the number of points calculated. This number is determined by the setting of the pushbutton which defaults to "DECADE". At the default setting, the number of points entered will be calculated per decade. If "LINEAR" is selected, then the number of points entered will be the total number calculated over the entire frequency range (STOP  START). Linear frequency sweeps may subsequently be converted to logarithmic by use of LOG X, on the main menu.
Sets up all parameters of a DC analysis. START, STOP, and STEP all have the obvious meanings, but it is worth noting that when performing an analysis which sweeps a voltage (or current) from a negative value to a positive value, START must be less positive than STOP, or problems will ensue.
Sets up all parameters of SPICE2G6 Noise Analysis. At present, only SPICE2G6 can be used for live noise simulations. Spice3d2 outputs the results in a different format, and this can not be displayed graphically at this time.
Sets up all parameters of SPICE2G6 Distortion Analysis. At present, only SPICE2G6 can be used for live distortion simulations. Spice3d2 outputs the results in a different format, and this can not be displayed graphically at this time.
Sets up all parameters of SPICE2G6 Sensitivity Analysis. At present, only SPICE2G6 can be used for sensitivity simulations. Spice3d2 outputs the results in a different format, and this can not be displayed as a complete table at this time.
Selects the nodes to be graphically displayed during the analysis, and inserts a .PRINT statement in the netlist. A pushbutton determines voltage or current is plotted, while another sets real/imaginary or mag/phase, for an AC analysis. As each node is selected on the schematic, the text entry box has its number, in SPICE format, printed in it. This text may be edited by hand, in the event of an error.
Selects the input stimulus waveforms. Functions available are the full SPICE waveform set of DC, Sine, Pulse, Exponential, PiecewiseLinear and Singlefrequency FM,, and each one has its own setup menu. The waveform itself is displayed in the graphics window. As each parameter of each waveform is varied, the displayed waveform is redrawn to reflect the changes, thus avoiding mistakes such as pulsewidth greater than period, etc. The parameter which does not vary on the sinewave is time offset, and a constant number of cycles is displayed, irrespective of the frequency. If the piecewiselinear waveform is selected, a file name must be entered of a file in Berkeley ASCII file format. Vspice3 will read the second column of the file (assuming the first column to be the timebase) and display it. No manipulation is possible.
The popup requests the name and new value of the component to be changed. The netlist is altered, and a new analysis may be commenced. It is possible to change, not just component values, but source and controlled source parameters. However, it is inadvisable to change polynomials without a knowledge of the node numbers of the controlling nodes. This is because the compiler is not invoked, but the netlist is run 'as is'.
The popup requests the node number and new value. The .nodeset card is entered into the netlist.
Reinvokes GSP, the highspeed netlist generator. It is essential that GSP be located in the directory './adt/tools/analog'  whether via a soft link or otherwise  since this path is hardcoded into Vspice3. It is also necessary that GSP should know its path to its libraries, so if these are located in other than './adt/lib', there should be a vspice.cmd file, with this information in it.
Sets up most of the common .OPTIONS functions. It should be borne in mind that Spice3d2 does not support: LIMPTS, ITL5, METHOD, MAXORD, LVLTIM and a few others. There are no ill effects, as the simulator prints an error message and continues.
To perform a polezero analysis, the netlist must contain a source with
the property 'ac The popup which appears prompts for an input port and an output port. Probing the schematic causes node numbers with the correct syntax to be entered in the dialogue boxes. Vspice3 will assume that the nodes are referred to ground. Plot instructions are not necessary with this analysis, since Spice3d2 will automatically find and plot every pole and zero available. The simulator runs only in batchmode, since a live polezero analysis would be meaningless. In each polezero analysis, Spice3 is required to calculate both poles and zeros. Occasionally, the simulator will fail to converge when searching for a nonexistent pole or zero. In such a case, the netlist may be be edited, and the request 'cur pz' changed to 'cur pol' or cur zer' whichever is more likely to succeed.
Starts the GEX graphics editor, and displays the schematic, for the purpose of probing nodes and components. If GEX is already running, a message points out this fact but, if the last instance of GEX to run was terminated by any means other than selecting QUIT, it will not have the window manager of its termination. In such a case, GEX will have to be started manually, in another window.
Selects the Basic Functions Menu
Selects the DSP PostProcessing functions menu.
MENU 1  MAIN MENU
The command line prompts for two mouse selections. The portion to be expanded should be bracketed top and bottom by two mousebutton presses. The vertical separation of the two mouse entries will determine the segment which will vertically fill the screen, If expansion is required for a derived waveform, such as an FFT, waveform selection is unnecessary, since there is only one waveform in the screen buffer.
The command line prompts for two mouse selections. The portion to be expanded should be bracketed left and right by two mousebutton presses. The horizontal separation of the two mouse entries will determine the segment which will horizontally fill the screen,The algorithm first scans the array containing xaxis information until it finds two data points corresponding to the mouse positions. It then scans yaxis data in opposite directions inward from these positions until it finds two data points corresponding to the selected waveform lying between the ypositions of the mouse; this should uniquely identify a feature on, say, one edge of a pulse, not present on the other edge. If expansion is required for a derived waveform, such as an FFT, waveform selection is unnecessary, since there is only one waveform in the screen buffer. This feature performs xaxis expansion of all waveforms currently stored in the buffers. Three printouts at screen left, centre and right, give the xaxis starting value, scale in seconds or hertz per division, and final value respectively, of the displayed waveforms.
Useable on expanded waveforms only, will reposition the waveform in the xdirection, such that the mouse entry becomes the new screen centre. Three printouts at screen left, centre and right, give the xaxis starting value, scale in seconds or hertz per division, and final value respectively, of the displayed waveform. If the waveforms displayed are the result of a transient analysis, performed with a variable timeincrement, 'PAN' may appear not to operate correctly for highlyexpanded waveforms. This may be corrected by using the incremental interpolator, with a stepsize equal to or less than the sample rate used for the analysis.
The first mouse entry selects the waveform to be moved in the ydirection and the second entry determines the position of the bottom of the waveform. Any points which would be outside the display area are suppressed.
The first mouse entry selects the waveform, which is removed from the display. The next two entries determine the new height and position, the lower of the two determining the latter. The waveform values are unaltered. This function may be used to bring a vertically expanded waveform back to its original or any other, smaller, size. If the waveform is difficult to select using the mouse, typing its number instead may be preferable.
Prompts for a common Yscale factor. All waveforms are then displayed using this factor, and positioned such that their troughs are aligned with the bottom of the screen.
Rescales all waveforms currently in buffer relative to the reference waveform selected by the mouse. The yscale factor, which is now common to all displayed waveforms, is printed at the top right of the display, and will appear in both forms of hardcopy.This command only works on data saved in the input buffers, since the processing buffer only ever contains a single waveform. Care should be taken when choosing the reference waveform, since any points on other waveforms which would lie outside the display area are suppressed. If the waveform is difficult to select using the mouse, typing its number instead may be preferable. The most useful application of this function is that of plotting families of curves, such as transistor output characteristics. First, RESIZE the largest curve, and fill the display with it, making sure that the bottom of the curve is on the display baseline. Then select RSCALE, and use this curve as the reference. All the other curves will then align themselves on the baseline, and scale themselves relative to the largest.
This function is only useful when no drawing exists, and the simulation was performed from a netlist, but it is desired to plot a node not specified in the netlist's .PLOT/.PRINT command. Obviously, a binary file, in Berkeley format, must contain the simulation data. The command prompts for SPICE node number of required node, or name of voltage source measuring current. It then extracts the appropriate data from the binary file, and adds another waveform to the display. If a drawing is available, it is preferable to select PLOT from the SETUP menu, and respecify the nodes to be plotted. The display can then be reread from the binary file via the RUN popup.
Prompts for selection of either incremental or midpoint interpolation
of all waveforms. Selection of 'Lagrange', or 'Linear', interpolates
existing data by a factor of 2:1, calculating the midpoint value
according to the appropriate algorithm; the time or frequency axis is
also interpolated. Selection of 'Incrmntal' will prompt for an xaxis
increment and, effectively, resample the data at the increment selected.
Whereas midpoint interpolation will always yield approximately twice the
number of points present in the original dataset (all of the original
values plus the newlycalculated ones), Incremental interpolation can
result in fewer points or more, depending on the value of the increment.
As a safety precaution, the final number of points is calculated in advance
and, if less than 65536, permission to continue is sought or, if more, the
routine aborts.
The command line prompts for two waveforms to be selected, either by mouse or, by typing in the number of the waveform. The command then performs an XY plot of the first versus the second waveform. The plot is purely for display purposes, and no measurements or scaling functions can be applied to it. Hardcopy to PostScript or HP plotter is, however available. When plotting hysteresis loops of magnetic materials, it may be necessary to invert one or other waveform to get the loop orientation correct.
Performs a polar plot of Real versus Imaginary in the complex plane or, if the data is noncomplex frequencydomain data, then a series of vectors is drawn, showing magnitude and phase at each frequency point. The origin of the axes always represents the point 0,0 and the maximum positive and negative values of real and imaginary waveforms are printed at the tenth division on each axis, to which they are scaled. The low frequency end of each plot is marked with an 'X'. Vectors are scaled to whichever axis they fit. A warning is issued if the frequency axis is logarithmic, and the plot is abandoned if the waveform is neither complex nor magnitude/phase data. The plot is purely for display purposes, and no measurements or scaling functions can be applied to it. Hardcopy to PostScript or HP plotter is, however available.
Prompts for selection of a wveform, either by mouse or, by typing in its number. If the waveform has a phase component, this function performs a plot of group delay across the frequency band, and the result is stored in the process buffer, with the original waveform unchanged. The actual group delay replaces the phase characteristic, with the magnitude remaining unchanged. This supplements the existing spot readout of group delay by 'Measure'.
Xaxis log scaling is performed by decade. If this is invoked on the results say, of a DC analysis which starts at zero, e.g a plot of transistor gain characteristics, then the waveforms will not extend to the origin, due to the impossibility of calculating 'Log 0'. Also, if the data does not fill an integral number of decades, the waveforms will not reach the righthand side of the display. When the horizontal expand feature is used, the grid scaling reverts to twenty linear lines on the expanded waveform when the expansion is less than a decade. This is more useful than being left with, perhaps, one or two grid lines of a log grid. Selecting this function a second time causes the horizontal scale to revert to linear.
The waveform is selected, either by mouse or number, and a zerodB reference level is entered. This latter may be achieved either by mouse selection or numerical entry. The selected waveform is then scaled in dB with respect to the reference, (20log{V/Vref}). This is a oneway operation, as the original data is overwritten. To preserve the original waveform, perform a trivial processing operation (such as multiplying by one, or adding zero) and use the 'SAVE' function.
The printout along the prompt bar displays the difference in value between the two points selected by the mouse. Selection of deltax requires no waveform to be specified, since the horizontal axis is common. The prompt bar displays the time difference between two points selected by the mouse or, if the horizontal scale is frequency, the frequency difference.
When using this command, some care should be exercised with the first mouseselection, since this also selects the waveform which is to be measured. The printout along the prompt bar displays the difference in value between the two points selected by the mouse.
Accesses DSP PostProcessing Menu
DIGITAL SIGNAL PROCESSING MENUAs a rule, all functions on the main menu may be used on the results of operations performed by this menu, whether the result is saved or not. The results of all computations are stored in a separate buffer and may be accessed at any time by selecting the PROC BUF pushbutton. To reuse a waveform for subsequent computation, 'SAVE' must be selected, which copies the waveform into the input buffer. The maximum number of points that each of the algorithms below will handle is such that the result must not exceed 65536. Specifically, both convolution and correlation produce (2n 1) points, while FFT and spectrum calculations produce the nearest binary multiple; e.g 200 points will have 56 zeros tagged onto the end, producing 256. Note, however, that since the upper half of an FFT is the complex conjugate (reflection) of the lower half, only the lower half is plotted on screen. A false timebase is manufactured for the display of the above waveforms, and in order that they themselves might be processed.
Performs a forward Fast Fourier Transform on waveform selected by mouse. Displays magnitude/real as solid, green spectral lines, and phase (degrees)/imaginary as a red, dotted line. Each may be in a different colour on a HP plotter, depending on the pen positions in the turret. The waveform is zerofilled to the nearest binary number above the number of data points in the input data, and then automatically zerofilled by a factor of two over and above this number. A pushbutton in the popup permits the selection of either Real/Imaginary or Magnitude/Phase computation, while a second pushbutton selects whether the Y scale is linear or in dB with respect to the peak value of the waveform. A third pushbutton sets the zerofilled length of the result. The last pushbutton selects the shape of the window function by which the routine will multiply the input data. The four windows provided are those most commonly used, namely:
Performs Inverse Fourier Transform on waveform selected by mouse. A popup permits the selection of either Real/Imaginary or Magnitude/Phase computation. When performing an IFT on a frequency sweep to obtain the impulse response, the frequency axis should be linear, not log, to produce a realistic display. Also, for the IFT of any waveform to be accurate, the number of points should be a binary multiple; in cases where this is not the case, the value of the last data point is copied into all subsequent locations, which gives better results than the appending of zeros.
Prompts for two waveforms representing impedance plots versus frequency,
or for one waveform and one floatingpoint constant. The waveforms
may be complex or real. From these waveforms, the reflection damping
coefficient is calculated.
Performs the convolution of the two waveforms selected by the mouse. Selfconvolution may be performed by selecting the same waveform twice. The number of points in the final waveform is (2n1), where n is the number of points in the longer of the two waveforms. This can lead to a few aberrations if such a waveform is saved. For cosmetic reasons, all waveforms in the input buffer are displayed as if they were the same length but, when a waveform selection is made on such a mixed timebase, if the selection point is on the right half of the screen, only the double length waveforms will be found. Therefore, if one or more convolutions, correlations, or fourier transforms have been saved, all selections should be made from the left side of the display.
Deconvolves the first waveform selected with the second. The number of data points in the resulting waveform is equal to that in the shorter of the two input waveforms.
Performs the correlation of the two waveforms selected by the mouse. Autocorrelation may be performed by selecting the same waveform twice. The number of points in the final waveform is (2n1), where n is the number of points in the longer of the two waveforms. This can lead to a few aberrations if such a waveform is saved. For cosmetic reasons, all waveforms in the input buffer are displayed as if they were the same length but, when a waveform selection is made on such a mixed timebase, if the selection point is on the right half of the screen, only the double length waveforms will be found. Therefore, if one or more convolutions, correlations, or fourier transforms have been saved, all selections should be made from the left side of the display.
Differentiates the waveform selected by the mouse, using a twopoint algorithm.
Integrates the waveform selected by the mouse, using Simpson's Rule which, for sampled data, is the most acurate algorithm. It is also the inverse of the differentiation algorithm, thus the two algorithms are fully reversible.
The popup permits selection of the four arithmetic functions, ADD, SUBTRACT, MULTIPLY, DIVIDE and the INVERT function, which is included for convenience. In all cases except this latter, constants may be entered by typing a "#" followed by the number (no spaces) in integer or floating point format. If the waveform is complex, the constant operates on the real part only, since its imaginary part is zero. Thus, inverting a complex waveform only inverts the real part. Only one of the entries may be a constant, and the function returns an error message if two are entered.
Performs the algebraic sum of the two waveforms selected by the mouse, analogous to additive mixing.
Subtracts the second waveform selected by the mouse from the first. Note that whatever the order of the two entries, it is always the constant that is subtracted from the waveform, and not vice versa.
Multiplies together the two waveforms selected by the mouse. If the input waveforms are sinusoids, this is equivalent to suppressed carrier modulation. Either the signal or the carrier may be recovered by dividing the result by the other.
Divides the first waveform selected by the mouse by the second. If the first waveform is a modulated carrier, as described above, dividing by the carrier yields the signal, and vice versa. Note that whatever the order of the two entries, it is always the waveform that is divided by the constant, and not vice versa.
Inverts the selected waveform, by multiplying each point by 1.00, in double precision arithmetic.
Will convert a waveform to its real and imaginary components.
Will convert a real/imaginary waveform to mag/phase Traps exist to stop you doing it twice.
Saves the waveform produced by any of the above commands in the first available buffer. Unless this is done, the waveform will be lost as soon as another processing command is executed. Note that the FFT, ONVOLVE and CORRELATE commands all produce waveforms containg more data points than you started with, so certain adjustments are made when these are saved. In cases where the waveform comprises either real/imaginary, or magnitude/ phase components, both are saved.
Selects the main menu.
ALGORITHMSAll mathematical functions performed by Vspice3 are performed in doubleprecision and, where either waveform is in real/imaginary format, all calculations are complex, and the results are saved and displayed as such. This permits the plotting of complex impedance and power from AC analyses which display voltage and current. Note that SPICE only logs real and imaginary values in the binary file, so an analysis originally performed with magnitude/phase plotted, may be subsequently displayed as real/imaginary by editing the simulator command file and rereading the binary file with the B or b option to Vspice3. Additionally, all interpolation is performed on both real and imaginary components, where appropriate, to assist in the determination of impulse response from complex logscaled frequency plots. Fast Fourier TransformThe algorithm employed is a 'C' implementation of the classical CooleyTukey method, employing a decimationintime approach, with all arithmetic performed in complex double precision. The optimum radix2 pass length is automatically determined, using the zero fill technique. The user may also optionally zerofill to any number up to 65536. This improves the onscreen resolution of the display, by providing the frequency points which would not otherwise be plotted; it does not increase resolution beyond that defined by the input data, which is a function of the sample speed if the data comes from a digitiser, or of computing increment if it comes from SPICE. Another benefit is that anomalous spectra, taken from waveforms which have an integral number of cycles, are correctly displayed. For most normal applications, zerofilling to either 512 or 1024 is recommended, unless there are more than this number of data points in the input data. Four windows are provided, with the following characteristics:
Hamming
Wh = 0.54  (0.46 cos(2(PI.n/N)) Main lobe width: 4/N Sidelobe attenuation: 53dB Hanning
Wh = 0.5(1  cos(2(PI.n/N)) Main lobe width: 4/N Sidelobe attenuation: 44dB Blackman
Wb = 0.42  (0.5 cos(2(PI.n/N) + (0.08 cos(4(PI.n/N)) Main lobe width: 6/N Sidelobe attenuation: 74dB Rectangular
Raw data Main lobe width: 2/N Sidelobe attenuation: 21dB Each window has characteristics which are useful on different sets of input data, and the choice must be made in the light of this. Basically, the first three of the above windows provide a lowering of the sidelobes associated with the effective convolution of the input data with a rectangular function, at the expense of harmonic main lobe width. This means that very small sidebands are brought into view, but that they tend to broaden. The enclosed Figs 5 to 9 represent the FFT of a 2MHz pure sine wave, and may be viewed on the 'pageview' Sun utility. Fig 5 uses a rectangular window, and no zerofill. It may be seen that not enough points have been calculated to truly show the shapes of all the features, and that there are many sidelobes of relatively large amplitude close to the main lobe. Fig 6 uses a Hamming window, and has been zerofilled by a ratio of 8:1, to a total of 8192 points. It may be seen that the shapes of all features are now clearly outlined. Figs 79 show the effect of Hanning and Blackman windows respectively. It may be seen that the rectangular window displays the spectral line with the best resolution, but with the sidelobes masking possible low level harmonics across the spectrum. The Hamming and Hanning windows increase the width of the spectral line (possibly masking harmonics very close to it) but virtually eliminating the effect of the sidelobes. The Blackman window produces the greatest sidelobe attenuation, but produces the broadest spectral line. Use of windows causes amplitude errors across the band of approximately 5%, and this fact should be borne in mind when making amplitude measurements. Maximum size of FFT is such that the result will not exceed 65536 data points. The FFT may be invoked on any time domain waveform generated either as a result of a transient analysis, or as a result of previous computation. The logarithmic yscale is calculated as dB down on the largest spectral component, so if another reference is required, plot on a linear scale, and change to a log scale manually  from the menu. Phase is displayed in degrees, and care should be taken when interpreting harmonic phases of a heavily zerofilled signal. The phase of points on the sidelobes caused by the rectangular window, and subsequently revealed by zerofilling is zero, and tends to give a zigzag appearance to what was originally a smooth curve. This does not represent an error, but is a function of the fact that the duration of the datatrain is finite. The harmonic resolution of an FFT depends on a number of factors, and the following information may be of use: Sample RateSampling a given dataset at a higher rate does not increase the resolution in the frequency axis, it increases the range of the frequency axis, thus effectively compressing the existing spectrum towards the origin, and reducing the number of frequency points calculated per spectral line. If anything, it reduces the resolution. The situation can be partially remedied by zerofilling, which increases the number of frequency points calculated per spectral line, but only to the extent of seeing, as accurately as possible, the spectral components already there. Conversely, sampling at a lower rate spreads the spectrum to the right and decreases the range of the frequency axis, sometimes bringing to light double peaks in the spectrum, where harmonics are merging together. Again, zerofilling will maximise the information present and, indeed, this technique is used as a crude 'zoom' in some laboratory instruments. In the case of the SPICE simulator, the above is equivalent to a transient analysis over a fixed time interval, with the computing interval variable. Observation TimeFor a given sampling rate, increasing the observation time will increase the harmonic resolution in direct proportion. This is equivalent to increasing the time over which a transient analysis is performed, while maintaining the computing interval constant, at a value which satisfies the Nyquist Criterion (yes, even SPICE produces aliasing if this is not satisfied  try it). If it is known in advance that there will be frequencies present in the results which are close together, then do a simulation over as long a simulated time interval as is practical. Mainlobe WidthThe final influence on resolution is the mainlobe width of the window. It is analogous to the I.F bandwidth of a swept frontend spectrum analyser, and is the limiting factor on all spectrum measurements. Refer to the table above for the tradeoff between dynamic range and resolution of various windows. In summary, the overall resolution of an FFT measurement is given by:
Rfft = 0.5(mainlobe width)(sampling frequency) Hertz = 0.5(W/N)(N/(Tfinal  Tstart)) Hertz = 0.5(W) / (Tfinal  Tstart) Hertz where: N = the number of data points Tfinal = the simulation endtime Tstart = the simulation start time W = 2, 4, 4 or 6 for rectangular,Hamming,Hanning and Blackman, respectively.
Caveat 1Occasionally, the FFT may appear to give the wrong result as, for example, when the FFT of the sinc function supplied with the 'wfms' function generator is plotted. It must be borne in mind that some functions need both a real and an imaginary time axis in order to produce the expected spectrum, and the sinc function is of this type. What actually gets calculated is the FFT of a sinc convolved with a Heaviside function (unit step), and it is this which gets displayed. If this problem arises, the solution is to mirror the function about its yaxis (which will also give twice the number of data points, resulting in the spectrum being shifted left) and to run the FFT on this new waveform.
Caveat 2Some results of transient analyses produce FFT's which are patently garbage. The reason is the variable steptime used by SPICE during the analysis. With the timebase essentially frequencymodulated, the FFT produces a result which is numerically incorrect. The solution is to use the incremental interpolator to linearise the timebase.
Inverse Fourier TransformThe above algorithm is again employed for the IFT, to enable the reconstruction of timedomain data from frequencydomain plots. The result is scaled to reflect true amplitude. If it is desired to perform the IFT on the results of an AC analysis, to determine the impulse response, Incremental Interpolation should be employed to linearise the xaxis. If this latter spans several decades of frequency, care should be taken over the selection of a suitable interpolation increment. The number of points resulting will be given by (to the nearest integer):
n = [F(final)  F(start)] / F(increment) As an example, a frequency response plot from 500Hz to 5MHz, interpolated with an increment of 5kHz will give
(5,000,000  500) / 5000 = 794 data points If it is desired to perform convolution/deconvolution by the multiplication/ division of FFT's, the following procedure should be followed. a) Perform the FFT's with real/imaginary output, no window or zerofill. b) Multiply the two transforms together, arithmetic will be complex. c) Then perform the IFT.
ConvolutionThe algorithm employed is one of the socalled 'Fast Convolution Algorithms' which entails the generation of a serial product of the terms of a polynomial. It was chosen because it can produce results in typically half of time taken to convolve by multiplication of FFT's. The number of points produced in the output waveform is the sum of those in the two input waveforms. Convolution of the impulse response of a system with a waveform yields the waveform resulting from the action of the system on the original waveform  a form of filtering. The impulse response can be obtained by setting the system's input voltage to DC 1, and performing a transient analysis with the UIC flag set. Alternatively, setting the input voltage to a step (with PWL, PULSE etc) will produce the step response, which can be differentiated to produce the impulse response. The frequency response can also be derived from the impulse response, by taking its Fourier transform. The test waveform generator "wfms" includes the impulse response (with complex conjugate) of an FIR bandpass filter. The frequency response can be viewed (artificial frequency axis, since the Xaxis is actually time) by performing an FFT, with rectangular window and fairly heavy zerofilling. By convolving this impulse response with, say, the square wave, saving the resulting waveform, and performing an FFT on it, a spectrum truncated to the passband of the filter can be obtained.
DeconvolutionNoncomplex waveforms are deconvolved by a highspeed serial division algorithm, the inverse of the convolution algorithm. Again, this approach was taken as being faster than the division of FFT's (for noncomplex data), and ensures that the convolution algorithm is reversible. However, since the result contains only magnitude information, for accurate results, the input data should be complex, and deconvolution should be performed by division of FFT's. Note that all deconvolution methods assume that both waveforms which were originally convolved had the same starting time. If either started at a time other than zero, the results will be inaccurate, since there is no way of retrospectively knowing the time difference. Deconvolution applied to the example used above produces the wrong answer for a just this reason. The FIR impulse is displayed as real+complex conjugate, but is timeshifted in the Xaxis, to bring the response into the centre. Deconvolution cannot estimate this timeshift.
Correlation and AutocorrelationThe correlation algorithm is derived from the convolution algorithm, but it should be noted that 'A' correlated with 'B' does not produce the same results as 'B' correlated with 'A', whereas convolution is symmetrical. The number of points produced in the output waveform is the sum of those in the two input waveforms. The algorithm takes advantage of the fact that autocorrelation is always a function symmetrical about its central value. Hence, if it detected that autocorrelation is to be performed, only half of the total number of points is calculated, the remainder being obtained by mirroring the function about the yaxis. Accordingly, crosscorrelation takes longer to perform, as per the following table:
Sequence length Autocorrelation Crosscorrelation 64 0.6 ms 0.8 ms 128 1.2 ms 2.0 ms 256 4.0 ms 7.5 ms 512 15 ms 29 ms 1024 55 ms 2 s In cases where a spectrum is known to contain several closely grouped harmonics, it will help their resolution to perform and save the autocorrelation of the input waveform, and then to take its FFT. Each autocorrelation improves the resolution by, effectively, doubling the observation time of the waveform (see formula above), but the penalty is computation time (see table above). Since the autocorrelation function is selfwindowing (from the FFT's standpoint) and, therefore, inherently cancels out sidelobes, it is not advisable to use any window other than rectangular, since the amplitude distortion introduced could be considerable. The enclosed Figs 58 show the results of repeated autocorrelation on a spectrum consisting of 64 samples of four sine waves additively mixed: 500kHz, 955kHz, 1MHz and 2MHz. Figure 5 shows an FFT performed on the raw data, with the poor resolution of the 955kHz and 1MHz spectral lines, and the high sidelobe levels. Figures 68 show a progressive but fairly dramatic decrease in sidelobe levels and improvement in resolution. Note the amplitude distortion caused by roundoff and truncation errors.
Power SpectrumThe power spectrum may be derived by taking the square of the modulus of the Fourier Transform, and contains no phase information. If this multiplication is actually performed, there will be a phase member displayed, but it is meaningless, and should be disregarded. The alternative spectrum estimation is performed by successive autocorrelation as described above.
InterpolationWith the exception of Incremental Interpolation, the algorithms mentioned below are fixed to perform a midpoint interpolation only. The advantage of performing an interpolation is that the sampling rate (from the point of view of an FFT) is doubled, effectively doubling the timedomain resolution, permitting a slightly better sinusoidal resolution in the frequency domain without the distortion introduced by successive autocorrelation. However, the spectrum is compressed towards the origin, as one might expect, so some heavy zerofilling will probably be necessary in most cases. See the above discussion on harmonic resolution of the FFT for more detail. Of the algorithms described below, only Incremental Interpolation is currently available, the others having been temporarily disabled.
a) LagrangePerforms a 2:1 interpolation of all waveforms currently saved, using the Lagrange FourPoint Algorithm:
f(n+p) = p(p1)(p2).f(n1)/3! + (p**2 1)(p2).f(n)/2! p(p+1)(p2).f(n+1)/2! + p(p**2 1).f(n+2)/3! The resulting sequence length is actually 2n2 points, the first point being lost. The interpolation technique is such that harmonics higher than twice the sampling frequency are suppressed (Mr Nyquist says that they are nonexistent anyway), so that square waves tend to sag in the middle a bit. However, on grossly undersampled sine waves, the algorithm performs excellently, actually reducing distortion with each iteration.
b) SincThe algorithm is a simplification of the sinc interpolation algorithm, permitted by the fact that a midpoint is sought, of the form: f(n+p) = xf.(f(n) + (sin[PI * 0.5(f(n+1) + f(n))]) / PI Unlike the Lagrange algorithm, a certain amount of midband distortion is introduced (mainly second harmonic) which, fortunately, does not increase with successive iterations (it actually decreases slightly). This algorithm produces negligible distortion on square waves with welldefined transition points and maximum distortion on undersampled sine waves. Resulting sequencelength is 2n1. c) LinearSimple interpolation of the form:
f(n+p) = p.[f(n+1)  f(n)] + f(n) Distortion is mainly second harmonic, and does not rise with successive iterations. Being basically a sophisticated dotjoiner, this algorithm performs best on waveforms with straight edges and welldefined corners.
d) IncrementalThis is basically the same algorithm as that used by SPICE 2G.6 to produce output at the intervals specified by the user. SPICE only uses the userdefined computing increment until it has to calculate a transition; then it uses a variable computing step internally, and only linearises the data for the purpose of outputting it. When Vspice3 runs, it reads the raw data produced by SPICE and, accordingly, the xaxis is not always linear. This is irrelevant for all computations except the FFT, where it gives rise to modulation of the frequency axis (visible as bright lines on the display). When this occurs, the data should be linearised using this algorithm. The increment used may be the original computing increment (a good place to start) or, alternatively, it may be much finer, so as to better define highfrequency components which would otherwise be missed. The algorithm operates on all waveforms currently stored, overwriting the original data and redefining the xaxis. It performs a linear interpolation with a variable fractional coefficient on every individual data point. A pair of pointers is set up for each computation such that the value of the xaxis point being computed lies between the values being pointed to. This sets the fractional coefficient which is then used to operate on the yaxis data. The algorithm is as above ('Linear') with the coefficient defined as:
p = [f(n+p)  f(n)] / [f(n+1)  f(n)] When used to linearise a logarithmic frequency plot, all phase information is deleted, on the assumption that an IFT will be done to determine impulse response (its presence would produce a grossly erroneous IFT). If the IFT is saved and an FFT performed on it, the phase information is recovered. The log graticule is replaced by a linear one and, for convenience, the data is treated as timedomain data. Hence, saving it in an ASCII file will result in the sweep variable being called 'TIME'.
KNOWN BUGS AND OMISSIONS1. Saving certain waveforms gives strange results Both the autocorrelation function and the convolution function produce waveforms which are twice the length of the original. If these are saved, the timebase is extrapolated to double its original length. When the input buffer is refreshed, for any reason, waveforms are drawn as if they filled the screen. Accordingly, the display actually has waveforms with mixed timebases so, when an attempt is made to select a waveform, the search algorithm finds no data after midscreen for the original waveforms, and tends to select the doublelength ones. 2. Attempts to process the result of processing without first saving the waveform succeed, with strange results. This is because the selection algorithm expects the target waveform to be in input buffer, and not the processing buffer. Accordingly, when invoked, it searches for a waveform occupying the selected coordinates. If none match, it selects waveform 1. 4. Waveform manipulation of Process Buffer needs waveform selected. Since there's only one waveform, it shouldn't be necessary to select it. We will solve this. 5. If the simulator crashes, the interface jams
The routine which talks to the simulator sits in a tight loop,
waiting for data. On Sun3 and Apollo, hitting the spacebar/mouse
buttons would interrupt this loop. This hasn't been implemented
on X11 yet. Try 6. Log Xscale sometimes has too many decades. The bug goes away if the binary file is reread, indicating that, while the simulator was running, the file pointer into the results file was doing something strange.
