This page describes the implementation-specific features of MacSpice, further information is available in the MacSpice User's Guide and Release Notes. Broadly speaking, MacSpice is compatible with the original Berkeley Spice 3f4 as described in the Spice 3f4 User's Guide. If you want to learn Spice from scratch, refer to the Tutorials page.
Colour PostScript Hardcopy
To make the hardcopy command produce colour PostScript use:
set hcopydevtype = postscript set hcopypscolor
The variables 'hcopyheight' and 'hcopywidth' can be used to set the image height and width in points. For more details, refer to the Colour Schemes section of the Advanced Examples.
Command Line Editing
the macspice console has command and file completion, and command-line editing keystrokes. users who switch between macspice and un*x shells should feel at home.
|CTL-A||move cursor to start of line|
|CTL-B or left-arrow||move cursor back one char|
|CTL-D||delete forward from insertion point|
|CTL-D at end of line||prints a list of possible completions|
|CTL-F or right-arrow||move cursor forward one character|
|CTL-H||delete back from insertion point|
|CTL-K||delete from cursor to end of line|
|CTL-N or down-arrow||scroll down through history stack|
|CTL-P or up-arrow||scroll up through history stack|
|CTL-T||transpose two characters|
|CTL-U||delete entire line|
|TAB||automatically types the completion as far as possible|
|OPT-ESC or F5||displays a dropdown list of possible completions|
text outside the editable region can be selected and copied, but not changed. the variable 'ignoreeof' is now set by default because otherwise it is rather too easy to type ctl-d at the command prompt and lose everything. to get a list of all commands type a space followed by ctl-d at the prompt.
If the command contains history references, typing TAB will expand these.
The simulator options 'gminsteps' and 'srcsteps' control the way MacSpice searches for the DC operating point. Setting one or both of these to the value 1 will cause MacSpice to use an adaptive step-size algorithm.
During a transient analysis, Spice increases the timestep when the going is good and cuts it back when things get tough. In particular, if the ratio of 'Rejected timepoints' to 'Accepted timepoints' displayed by the command rusage all exceeds about 10% the simulation will be extremely inefficient. Using the command:
set debug = timestep
幸运飞艇超稳计划群 will make macspice print its reasons for making substantial reductions in the timestep during the run.
幸运飞艇超稳计划群 the local truncation error estimation in the original berkeley 3f5 release gave incorrect values. the algorithm has been re-developed for macspice and the default value for trtol is now 1.
MacSpice has a nodesets command that saves the state of its current analysis as a file of nodeset commands suitable for inclusion in a netlist. This is useful in cases where the operating point is difficult to find.
After a convergence failure, the command dump幸运飞艇超稳计划群 will display the node voltages and branch currents calculated by the final two interation and indicate the one(s) that failed to meet the convergence criteria.
when the cursor is positioned over a graph in a window, a help-tag displays the corresponding values. holding down the 'shift' key sets the origin for measurements of changes. double-clicking transfers the displayed value to the command line.
DC Transfer Function
In addition to voltage and current sources, the DC Transfer Function幸运飞艇超稳计划群 can sweep the value of resistors and/or circuit temperature ('temp').
The MacSpice edit command uses Apple Events to invoke a helper application and supports the ODB Editor Suite. It is strongly recommended that an ODB-compliant editor is used with MacSpice. If your favourite editor is not one of these, consider switching to the excellent . ODB allows tight integration between MacSpice and the editor. For example, MacSpice to pre-type an appropriate 'source' command in response to editor activity. If this is not required, it can be cleared by typing CTL-U (see above).
use the preferences menu to specify the helper application for the 'edit' command.
this table lists some popular editors that support odb:
File Names and Paths
MacSpice uses Unix paths to specify files and folders, hence '/' is the path separator. A path that begins with a '/' is an absolute path. In MacSpice non-absolute paths are relative to the current directory, which can be inspected and/or set with the 'cd幸运飞艇超稳计划群' command.
macspice treats the single character '#' as a pseudo-filename signalling that a file, or folder, is to be selected using a navigation services dialog box. when this mechanism is used to open files, they can be sorted by date or name and you have instant access to recently opened files or 'favourites'. drag a folder or file from the finder into navigation services and it will open and reset the default to that location.
幸运飞艇超稳计划群 a standard installation of macspice searches for files in two places that are specified in the list $sourcepath
MacSpice 1 -> echo $sourcepath . MacSpice 2 -> echo $sourcepath /Users/cdhw/Library/Application Support/MacSpice/lib/scripts
The set command can be used to change the sourcepath list, e.g.
MacSpice 3 -> set sourcepath = ( $sourcepath 'Secondary/test/' ) MacSpice 4 -> echo $sourcepath Secondary/test/
spaces and strange characters in pathnames need quote protection. bash(1) style single-, double- and backslash-quoting can be used as required.
The cd command is used to change and identify the current directory.
Used without an argument it resets the current directory to the the '
directory that was created when MacSpice was first run,
MacSpice 5 -> cd Current directory is: /Users/cdhw/Documents/MacSpice/
To change the current directory to
MacSpice 6 -> cd /Volumes/MP1/CAO/SPICE/cir/
to check the current directory without changing it use
MacSpice 7 -> cd . Current directory is: /Volumes/MP1/CAO/SPICE/cir/
The command-completion aids described above are particularly useful with cd. For a more Mac-like experience, type
MacSpice 8 -> cd #
, which will allow selection of a folder using a standard navigation dialog.
File Types and Formats
幸运飞艇超稳计划群macspice creates and opens various file types with creator code 'rtsp':
|MacSpice -> source filename||MacSpice Source File|
|RAWT||.rawt||MacSpice -> load filename||MacSpice Text Rawfile.|
|RAWB||.rawb||MacSpice -> load filename||MacSpice Binary Rawfile.|
The format of the rawfiles created by the write command is specified by the filetype variable. In addition to the standard 'ascii' and 'binary' values, MacSpice defines the filetype 'tabbed'. This is a tab-delimited format intended to facilitate import of results into other data-analysis applications.
幸运飞艇超稳计划群 binary rawfiles written by macspice (v2.9p14 onwards) include a flag with the value 'big_endian' or 'little_endian' to indicate how the binary data is to be interpreted when it is loaded. if this flag is missing, macspice assumes the data is native to the platform on which it is running.
macspice (v3.0.0 onwards) uses utf-8 encoding to read and write files and commands. earlier (carbon) versions of macspice used macroman encoding.
The base pen-thickness used to display graphs is selected automatically and
depends on the fontsize selected. This can be overridden by the Format menu.
The command '
set pensize = N'
N <= 10
is measured in points, can also be used to override the default behaviour.
Default behaviour is restored by '
set pensize = 0' or '
many of the memory leaks that affected spice 3f4 have been cured in macspice. i've paid particular attention to the frontend, for example the script:
let j = 0 while j < 10000 let j = j +1 end repeat 10000 define f(a,b) 100*b+321*a let k = f(j,j+4) undefine f end unlet j k
does not leak. this property allows industrial-strength optimisation problems to be tackled.
The memory usage indicated by rusage excludes the amounts required to create and maintain windows (these use a separate allocation zone). Commands like destroy, delcirc, unlet, etc. can be used to recover memory. Graphs make their own copy of their data at the time they are created. If you destroy vectors that are owned by a suspended simulation - don't 'resume' it, use 'delcirc' to get rid of the thing.
MacSpice includes a sophisticated optimize幸运飞艇超稳计划群 command. This uses a numerical procedure to minimize functions of several variables with optional constraints. The function may be as simple as a quadratic equation, or as complicated as the result of running a suite simulations.
The standard save command has been enhanced by defining new qualifiers 'alli' and 'allv'.
|save all||Voltage nodes and voltage source branch currents, but not semiconductor internal nodes.|
|save allv||Voltage nodes, including semiconductor internal nodes, and source branch currents.|
|save alli||Terminal currents for all semiconductor devices.|
幸运飞艇超稳计划群 the default behaviour is equivalent to 'save all'.
Spice 2 'POLY' Sources
MacSpice is able to check for new versions and update itself. The update information comes via幸运飞艇超稳计划群 a type of RSS feed known as an 'appcast'. Users have a chance to inspect release notes before deciding whether they want to update. The checks can be performed on request, by using the 'Check for Updates...' menu item, or automatically roughly once a week. Automatic updates can be switched on or off using the 'Preferences...' panel or with the defaults(1) command from the terminal. For example,
macos% defaults write uk.co.cdhw.MacSpice SUEnableAutomaticChecks -boolean yes
enables automatic checking, and setting the value to 'no' disables it.
Expressions like 'let foo = 99' work in MacSpice and incorporate index range checking. It also has a semicolon operator to facilitate construction of vectors and n幸运飞艇超稳计划群-dimensional matrices. For example, typing the commands:
|'let foo = ((11;12);(21;22))'||creates a 2×2 matrix,|
|'let bar = (foo;(31;32))'||creates a 3×2 matrix,|
|'let baz = (1;(3,4);5)'||creates a complex vector with 3 elements.|
幸运飞艇超稳计划群the ; must be protected with ()'s otherwise it will be treated as a command separator by the parser.