Design Simulation Systems Ltd


VSPICE3

Analogue Simulation and Analysis
Signal Processing Graphics Interface
User Manual and Description

Mark Sitkowski

Introduction

This 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

  • Compiles and runs on any Unix platform with X11 graphics
  • No more than one level of pop-up menus.
  • No typing, no syntax: all functions accessed by mouse selection
  • User-transparent netlist generation from GEX drawing
  • Simultaneous display of up to 40 waveforms
  • Stimulus waveforms displayed and updated as their parameters are varied
  • Piecewise-linear stimulus can be read from Berkeley format ASCII file
  • Piecewise linear stimulus can be created from on-screen waveform
  • Digital stimulus data can be converted to piecewise linear waveform
  • Ability to read in and compare previous simulation results
  • Read in and display of ASCII data, in Berkeley format from file
  • Dump to disc of all data on screen, in Berkeley ASCII format.
  • Simulation results in Real/Imaginary or Magnitude/Phase format
  • Complex plane display of data
  • Decibels with respect to floating point reference level
  • Log/linear X-axis conversion
  • Group-delay display
  • Postscript and HPGL hardcopy
  • Simulator selectable between SPICE2G6 and SPICE3D2
  • Full SPICE polynomial capability from GEX
  • Multi-winding transformer design capability in GEX

2. DSP functions, in double-precision complex arithmetic:

  • Fast Fourier Transform in Real/Imaginary or Magnitude/Phase format
  • FFT has variable zero-fill and Hamming, Hanning, Blackman windows
  • Inverse Fast Fourier Transform in Real/Imaginary or Magnitude/Phase
  • Convolution
  • Deconvolution
  • Correlation
  • Spectral Estimation (based on either FFT or Recursive Autocorrelation),
  • Integration
  • Differentiation
  • Interpolation and decimation of data,
  • Addition
  • Subtraction
  • Multiplication
  • Division
  • All arithmetic functions accept floating point numeric constants

Some notes

  • The term 'waveform' means signal with the dc component removed. Although this does not affect the signal with respect to processing, all display manipulations ignore the dc component, so as to maximise the visibility of, say, ripple on a high voltage power supply. Interrogation of the waveform's values does, of course, give the true value. Also note that phase is always displayed in degrees.
  • In all cases where a waveform must be selected from the screen, it is possible to type its number on the command line instead of selecting with the mouse. This means that, for example, it is possible to perform an FFT on the saved result of an autocorrelation by selecting 'FFT' from the menu and typing the number reported by 'SAVE' instead of switching to the input buffer and selecting the actual waveform. This can save a small amount of time on chained waveform calculations
  • Whenever it is necessary to enter floating point numbers, these may be entered in one of two formats. Vspice3 is capable of accepting true floating-point entry (as in '20E-03'), or engineering notation, (as in '20m'). All floating point numbers must be preceded with a "#" (hash) symbol, as in "#20e-3", or #20m", to differentiate them from waveform numbers.

Environment Variables

Two environment variables need to be set:
VSPICE_HOME /full_path/to/vspice/and/GEX/executables
e.g /usr/local/bin
VSPICE_LIB /full_path/to/GEX/libraries
e.g /usr/local/analog/lib

Invocation

Vspice3 may be invoked in one of four modes.

Vspice3 drawing_name

If Vspice3 is invoked with a drawing name as a command line argument, it looks for two files: either 'name.netlist' or 'name.ckt'.

  • If it fails to find either, it will look for the drawing directory, and start GSP, the high-speed netlister, which will generate 'name.ckt'. This file is a bare netlist, with no simulation commands, and Vspice3 then starts its graphics, but no simulator runs, since commands need to be generated for it. The user is prompted to set up the simulation, from the 'SETUP' menu, before attempting to run.
  • After the simulation has been set up, 'name.ckt' is deleted, and 'name.netlist' is created, which contains the complete netlist, with all simulation commands in place.
  • If the .TRAN command has a starting time of other than zero, then there will be a delay, which could be quite long, before graphical data appears. This is because SPICE still has to perform the simulation up to the starting time. This is, however, faster than simulating 'live'.
  • The waveforms requested by .PRINT or .PLOT cards will be the ones to be graphically displayed, although the interface file does actually store every node in the circuit.
  • SPICE will only read an input line of 133 characters, so, in the event of wishing to plot the full 40 waveforms that Vspice3 is capable of, it will be necessary to input a minimum of 255 characters. This can be done either with a very long input line, or by entry of multiple .PLOT or .PRINT statements.
  • Although SPICE will ignore all requests for prints/plots of more than eight variables, Vspice3 will still plot them all, since it has access to all node voltages and currents.
  • Additionally, the format of the .PRINT statement will be analysed when an AC analysis is to be performed. If the format is v(xx) or i(xx), magnitude/phase is plotted. If it is vr(xx) or ir(xx), real/imaginary is displayed. The form of the AC analysis directive also determines whether a linear or logarithmic scale will be used for the frequency axis.
  • If 'name.netlist' exists, it is assumed to be complete, and the simulator is started. A binary file, called 'name.bin', in Berkeley 'old binary' format is created by the simulator, which is read by the front end, and graphical results plotted.
  • This file is not removed on termination, permitting the plotting of voltages and currents not originally specified, re-reading for comparison with other data and, of course, archiving.
  • Since there is no synchronised connection between Vspice3 and the simulator (like a Unix pipe or socket), both can run independently at full speed. The display can, therefore, be paused for measurements, waveform positioning etc without pausing the simulator. Pressing a mouse-button (Sun) or the spacebar (Apollo) gives access to all menu functions.
  • When Vspice3 detects the end of a simulation, all waveforms are automatically scaled and separated, such that each waveform occupies an equal area of the screen. The menu and mouse are enabled, and the waveforms may be manipulated.

Vspice3 -b name

This option permits the re-viewing 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 current-measuring voltage source.

Vspice3 -a name

If 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 ..YdataN
All numbers should be in floating point format (e.g 1.2e-3) 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.

vspice3

The user interface starts up, and the mode of operation may be selected from a pop-up menu situated under the main menu-bar 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 pop-up, since the simulator is started immediately that 'OK' is selected.


Button and Menu Functions

Buffer Toggle

A 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 BUF

Displays the current contents of the processing buffer.

INPT BUF

Displays the current contents of the input buffer.


MAIN MENU BAR

    The horizontal menu bar is at the top of the frame selects the following functions:

  • QUIT
  • Exits gracefully, deleting temporary files and directories in /tmp, created by deletions, group and cut-and-paste operations.

  • FILE
  • 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 zero-padded 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 subsequently-introduced 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.

  • RUN
  • The popup which appears permits:

    • Restarting another simulation ("From netlist")
    • Selecting between SPICE2G6 and Spice3d2 ("SPICE2G6")

    • 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 non-linear 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 rate-of-change detector, which varies the scale factor more for a faster-changing 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 Cntl-C 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.

    • Reading in previous simulation results ("From binary")

    • 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.

    • Reading in ASCII file waveform data ("From ASCII")

    • 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.

  • SETUP
  • 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 .ckt. Such a netlist contains no simulation commands, and will not run. It is necessary to invoke the SETUP function to specify the analysis parameters and the nodes to be plotted. Some users prefer to specify the circuit stimulus on the schematic, in which case, the circuit will run as is. However, if a stumulus has not been specified this way, one may be added to the netlist from the SETUP menu, leaving a clean schematic.

  • HARDCOPY
  • Prompts for selection of either a PostScript laser plotter or of a Hewlett-Packard HPGL pen-plotter. 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 sub-process 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.

  • ANNOTATE
  • 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.

  • DELETE
  • Removes waveform selected by mouse from display and prompts for 'y' to continue. Typing anything other than a lower-case 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 re-use.

  • XFIT
  • Redisplays the data to fit exactly in the x-axis. All data currently in the buffers is displayed for every waveform. When the stored waveforms are a mixture of real-time 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.

  • YFIT
  • 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.

  • MEASURE
  • Prints the node number, value of x-parameter and value of the y- parameter in floating point format. If the file 'name.xref' exists, Vspice3 will have read it on start-up 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:

    • FFT
    • On log-scaled FFT's, the y-scale is in dB with respect to the highest peak and the x-scale is in hertz, while on linear-scaled FFT's, y-scale is in peak volts. Phase is in degrees, and group delay is in seconds. Note, however, that with large amounts of zero-filling, the fact that many zero-valued phase points will be interpolated, will result in the derivative of phase changing often and abruptly.

    • Differentiation:
    • Y-scale is volts/second per division, x-scale is seconds.

    • Convolution, Deconvolution, Correlation, Integration:
    • Y-scale is volts, x-scale 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.

  • SETUP
  • 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.

    • TRANSIENT
    • 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 user-defined 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.

    • AC ANALYSIS
    • 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.

    • DC ANALYSIS
    • 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.

    • NOISE
    • 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.

    • DISTO
    • 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.

    • SENS
    • 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.

    • PLOT
    • Selects the nodes to be graphically displayed during the analysis, and inserts a .PRINT statement in the netlist. A push-button 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.

    • STIMULUS
    • Selects the input stimulus waveforms. Functions available are the full SPICE waveform set of DC, Sine, Pulse, Exponential, Piecewise-Linear and Single-frequency 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 piecewise-linear 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.

    • ALTER
    • 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'.

    • SET NODE
    • The popup requests the node number and new value. The .nodeset card is entered into the netlist.

    • COMPILE
    • Re-invokes GSP, the high-speed 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 hard-coded 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.

    • OPTIONS
    • 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.

    • POLE-ZERO
    • To perform a pole-zero analysis, the netlist must contain a source with the property 'ac ', just as for a regular ac analysis.

      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 batch-mode, since a live pole-zero analysis would be meaningless.

      In each pole-zero analysis, Spice3 is required to calculate both poles and zeros. Occasionally, the simulator will fail to converge when searching for a non-existent 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.

    • SCHEMATIC
    • 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.

    • MENU1
    • Selects the Basic Functions Menu

    • PROCESS
    • Selects the DSP Post-Processing functions menu.

MENU 1 - MAIN MENU

  • V-EXPAND
  • The command line prompts for two mouse selections. The portion to be expanded should be bracketed top and bottom by two mouse-button 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.

  • H-EXPAND
  • The command line prompts for two mouse selections. The portion to be expanded should be bracketed left and right by two mouse-button 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 x-axis information until it finds two data points corresponding to the mouse positions. It then scans y-axis data in opposite directions inward from these positions until it finds two data points corresponding to the selected waveform lying between the y-positions 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 x-axis expansion of all waveforms currently stored in the buffers. Three printouts at screen left, centre and right, give the x-axis starting value, scale in seconds or hertz per division, and final value respectively, of the displayed waveforms.

  • PAN
  • Useable on expanded waveforms only, will reposition the waveform in the x-direction, such that the mouse entry becomes the new screen centre. Three printouts at screen left, centre and right, give the x-axis 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 time-increment, 'PAN' may appear not to operate correctly for highly-expanded waveforms. This may be corrected by using the incremental interpolator, with a step-size equal to or less than the sample rate used for the analysis.

  • MOVE
  • The first mouse entry selects the waveform to be moved in the y-direction and the second entry determines the position of the bottom of the waveform. Any points which would be outside the display area are suppressed.

  • RESIZE
  • 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.

  • USCALE
  • Prompts for a common Y-scale factor. All waveforms are then displayed using this factor, and positioned such that their troughs are aligned with the bottom of the screen.

  • RSCALE
  • Rescales all waveforms currently in buffer relative to the reference waveform selected by the mouse. The y-scale 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.

  • ADD NODE
  • 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 re-specify the nodes to be plotted. The display can then be re-read from the binary file via the RUN popup.

  • INTERPOLATE
  • Prompts for selection of either incremental or mid-point interpolation of all waveforms. Selection of 'Lagrange', or 'Linear', interpolates existing data by a factor of 2:1, calculating the mid-point value according to the appropriate algorithm; the time or frequency axis is also interpolated. Selection of 'Incrmntal' will prompt for an x-axis increment and, effectively, re-sample the data at the increment selected. Whereas mid-point interpolation will always yield approximately twice the number of points present in the original data-set (all of the original values plus the newly-calculated 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.
    Caution:
    SPICE does NOT use a uniform timestep throughout the analysis. This becomes finer at changes of slope, and coarser during flat portions of the waveform. Performing interpolation on such waveoforms could trash them rather badly. The solution is to use the incremental interpolator to linearise the timebase.

  • X-Y PLOT
  • 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 X-Y 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.

  • POLAR
  • Performs a polar plot of Real versus Imaginary in the complex plane or, if the data is non-complex frequency-domain 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.

  • GROUP DELAY
  • 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'.

  • LOG-X
  • X-axis 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 right-hand 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.

  • 20LOG-Y
  • The waveform is selected, either by mouse or number, and a zero-dB 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 one-way 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.

  • DELTA X
  • The printout along the prompt bar displays the difference in value between the two points selected by the mouse. Selection of delta-x 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.

  • DELTA Y
  • When using this command, some care should be exercised with the first mouse-selection, 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.

  • PROCESS
  • Accesses DSP Post-Processing Menu


DIGITAL SIGNAL PROCESSING MENU

As 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 re-use 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.

  • FFT
  • 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 zero-filled to the nearest binary number above the number of data points in the input data, and then automatically zero-filled by a factor of two over and above this number.

    A pushbutton in the pop-up 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 zero-filled 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:

    • Hamming
    • Hanning
    • Blackman
    • Rectangular

  • IFT
  • 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.

  • REFDAMPC
  • Prompts for two waveforms representing impedance plots versus frequency, or for one waveform and one floating-point constant. The waveforms may be complex or real. From these waveforms, the reflection damping coefficient is calculated.
    This function is only there, because one user asked for it. Nobody else has ever used it...

  • CONVOLVE
  • Performs the convolution of the two waveforms selected by the mouse. Self-convolution may be performed by selecting the same waveform twice. The number of points in the final waveform is (2n-1), 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.

  • DECONVOLVE
  • 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.

  • CORRELATE
  • Performs the correlation of the two waveforms selected by the mouse. Auto-correlation may be performed by selecting the same waveform twice. The number of points in the final waveform is (2n-1), 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.

  • DIFFERENTIATE
  • Differentiates the waveform selected by the mouse, using a two-point algorithm.

  • INTEGRATE
  • 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.

  • CALC
  • 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.

    • ADD
    • Performs the algebraic sum of the two waveforms selected by the mouse, analogous to additive mixing.

    • SUBTRACT
    • 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.

    • MULTIPLY
    • 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.

    • DIVIDE
    • 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.

    • INVERT
    • Inverts the selected waveform, by multiplying each point by -1.00, in double precision arithmetic.

  • RL/IMAG
  • Will convert a waveform to its real and imaginary components.

  • MAG/PHASE
  • Will convert a real/imaginary waveform to mag/phase Traps exist to stop you doing it twice.

  • SAVE WFM
  • 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.

  • MENU1
  • Selects the main menu.


ALGORITHMS

All mathematical functions performed by Vspice3 are performed in double-precision 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 re-reading 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 log-scaled frequency plots.

Fast Fourier Transform

The algorithm employed is a 'C' implementation of the classical Cooley-Tukey method, employing a decimation-in-time approach, with all arithmetic performed in complex double precision. The optimum radix-2 pass length is automatically determined, using the zero fill technique. The user may also optionally zero-fill to any number up to 65536. This improves the on-screen 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, zero-filling 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 side-lobes 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 zero-fill. 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 zero-filled 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 7-9 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 y-scale 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 zero-filled signal. The phase of points on the sidelobes caused by the rectangular window, and subsequently revealed by zero-filling 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 data-train is finite.

The harmonic resolution of an FFT depends on a number of factors, and the following information may be of use:

Sample Rate

Sampling a given data-set 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 zero-filling, 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, zero-filling 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 Time

For 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 Width

The final influence on resolution is the mainlobe width of the window. It is analogous to the I.F bandwidth of a swept front-end spectrum analyser, and is the limiting factor on all spectrum measurements. Refer to the table above for the trade-off 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 end-time
    Tstart = the simulation start time
         W = 2, 4, 4 or 6 for rectangular,Hamming,Hanning      
             and Blackman, respectively.

The reason for the factor of 0.5 is that only half of the spectrum is plotted.

Caveat 1

Occasionally, 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 y-axis (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 2

Some results of transient analyses produce FFT's which are patently garbage.

The reason is the variable step-time used by SPICE during the analysis. With the timebase essentially frequency-modulated, the FFT produces a result which is numerically incorrect. The solution is to use the incremental interpolator to linearise the timebase.

Inverse Fourier Transform

The above algorithm is again employed for the IFT, to enable the reconstruction of time-domain data from frequency-domain 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 x-axis. 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 zero-fill. b) Multiply the two transforms together, arithmetic will be complex. c) Then perform the IFT.

Convolution

The algorithm employed is one of the so-called '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 X-axis is actually time) by performing an FFT, with rectangular window and fairly heavy zero-filling.

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.

Deconvolution

Non-complex waveforms are deconvolved by a high-speed serial division algorithm, the inverse of the convolution algorithm. Again, this approach was taken as being faster than the division of FFT's (for non-complex 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 time-shifted in the X-axis, to bring the response into the centre. Deconvolution cannot estimate this time-shift.

Correlation and Autocorrelation

The 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 y-axis. Accordingly, cross-correlation takes longer to perform, as per the following table:

 Sequence length     Autocorrelation    Cross-correlation    
 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 self-windowing (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 5-8 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 6-8 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 Spectrum

The 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.

Interpolation

With the exception of Incremental Interpolation, the algorithms mentioned below are fixed to perform a mid-point 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 time-domain 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 zero-filling 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) Lagrange

Performs a 2:1 interpolation of all waveforms currently saved, using the Lagrange Four-Point Algorithm:

  f(n+p) = -p(p-1)(p-2).f(n-1)/3! + (p**2 -1)(p-2).f(n)/2!
           -p(p+1)(p-2).f(n+1)/2! + p(p**2 -1).f(n+2)/3!

where p is a fractional interpolation coefficient, set at 0.5

The resulting sequence length is actually 2n-2 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 non-existent anyway), so that square waves tend to sag in the middle a bit. However, on grossly under-sampled sine waves, the algorithm performs excellently, actually reducing distortion with each iteration.

b) Sinc

The algorithm is a simplification of the sinc interpolation algorithm, permitted by the fact that a mid-point is sought, of the form:

    f(n+p) = xf.(f(n) + (sin[PI * 0.5(f(n+1) + f(n))]) / PI

where xf is a normalising factor.

Unlike the Lagrange algorithm, a certain amount of mid-band 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 well-defined transition points and maximum distortion on under-sampled sine waves. Resulting sequence-length is 2n-1.

c) Linear

Simple interpolation of the form:

       f(n+p) = p.[f(n+1) - f(n)] + f(n)

where p is a fractional interpolation coefficient, set at 0.5

Distortion is mainly second harmonic, and does not rise with successive iterations. Being basically a sophisticated dot-joiner, this algorithm performs best on waveforms with straight edges and well-defined corners.

d) Incremental

This 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 user-defined 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 x-axis 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 high-frequency components which would otherwise be missed. The algorithm operates on all waveforms currently stored, overwriting the original data and re-defining the x-axis. 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 x-axis point being computed lies between the values being pointed to. This sets the fractional coefficient which is then used to operate on the y-axis 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 time-domain data. Hence, saving it in an ASCII file will result in the sweep variable being called 'TIME'.

KNOWN BUGS AND OMISSIONS

1. 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 mid-screen for the original waveforms, and tends to select the double-length 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 in the window in which you started Vspice3.

6. Log X-scale sometimes has too many decades.

The bug goes away if the binary file is re-read, indicating that, while the simulator was running, the file pointer into the results file was doing something strange.