Devices can be either primitive devices as used by SPICE, or subcircuit macros. If the device represents a subcircuit macro, the name of the subcircuit is given as a model property, and that subcircuit must exist in one of the model library files. For example, a device named ``opamp'' could be added to the device library file. Then the user would set the model property to something like ``ua741'' which would have a subcircuit definition somewhere in the model library files (perhaps in a directory containing SPICE models obtained from a semiconductor manufacturer).
There are four classes of device in the device library file. First are the terminals, including the gnd device and the vcc device. The second class of device is the sources, including voltage and current sources, and dependent sources. These have no physical counterparts. The third class consists of the devices with physical counterparts, such as resistors and semiconductor devices. The fourth class is the subcircuit macros, which actually introduce a subcircuit into the SPICE output.
The first line of the file must be in the form
(Library filename);This is the signature used in all library files.
Comment lines, which are ignored when the file is parsed, begin with the `#' character, and can appear anywhere outside of the device definitions except on the first line. Lines containing only white space are ignored.
The device library file handles ``global properties''. These properties appear at the beginning of the file, after the initial line but before the symbol definitions. The syntax is
Property number stringwhere Property appears literally, number is an integer, and the rest of the line constitutes the string. There can be any number of these lines.
Presently, there are two global properties recognized. The first is number 20, the LibSave property. The string consists of a SPICE key letter for a device (such as `R' for a resistor), followed by the name of a parameter known to SPICE for that device. While a SPICE deck is being created, and if this property was given, each device in the circuit that is keyed by that letter will trigger the addition of a line in the SPICE file in the form
.save @name[param]The name is the name of the device, and the param is the parameter name given in the property. This construct forms a vector name which the directive ensures will be saved during simulation, and thus be available for output. This is the means by which device parameter data are made available by default in SPICE runs initiated from SPICE output generated by Xic. WRspice and other SPICE3-derivative simulators will recognize this form, however only WRspice will actually save the vector in interactive mode. SPICE3 ignores .save lines, except in batch mode.
This property is used in the supplied device.lib file, for current sources and the ``c'' (current) parameter. The branch property for current sources references ``@name[c]'', so that it is important to ensure that this vector is saved. Thus, the appropriate global property is
Property 20 I cThis will produce lines in the SPICE output like
.save @isource[c]for a current source named isource.
The second property recognized is 21, the GlobalNode property. This is used for providing a default node name for the last node listed in a SPICE output device line. This allows the use of a three-node MOS device, with the substrate node connected automatically. The feature is enabled by adding the following property line at the top of the device library file:
Property 21 device_name num_nodes node_name
The parameters are:
device_name: name of device (e.g., nmos) num_nodes: number of nodes expected by SPICE node_name: name of node to be added
For example,
Property 21 nmos 4 NSUB
A Property line should be added for each device which has a default node. The respective device descriptions in the device library file should also be modified to remove the substrate mode. The supplied device.lib file contains MOS models with this feature included, and also standard models.
Using the example above, a SPICE output deck will contain lines like
M1 1 2 3 NSUB ...Also, there will be a line added at the top of the deck:
.global NSUBThis line tells WRspice to not modify this node name during subcircuit expansion. The user must explicitly add a connection to the global node, usually to a voltage source. This can be accomplished in Xic by placing a ``vcc'' terminal, and modifying the terminal name to the node name (NSUB).
The rest of the file consists of multiple concatenated device specifications. There is no physical representation, and the resolution as shown (and as in the supplied device.lib file) is 100 units, unlike symbol files which use 1000 units per ``micron''. However, the (RESOLUTION 1000); comment can appear, which indicates 1000 units per ``micron'', as in ordinary cells. Each device has the following format:
(Symbol symname);
5 property;
5 ... ;
9 symname;
DS 0 1 1;
L SCED;
geometry ...
more layers/geometry ...
DF;
E
The format is extended CIF, as used in the electrical description of symbol files. The first line is a CIF comment stating the device name, e.g., for a capacitor one might have
(Symbol cap);This line signals the beginning of a device definition to the function that automatically updates the device library file after a device is edited (see A.5.1), so must appear as shown for that feature to work correctly.
This is followed by property specification lines, which begin with the number `5', and a cell name definition, which begins with the number `9'. The property lines can occur in any order. Technically, the property lines are optional, however the name line is mandatory. All lines in the symbol specification parts of the file must end with a semicolon (;), except for the symbol termination line ``E''. While the device is being parsed, the `;' is actually taken to be the line terminator, so that logical lines can span several printed lines.
The name line begins with `9' in the first column, followed by the symbol name (space separated), and ending with a semicolon (without space). This line actually defines the name of the device, as known to Xic. The property lines define the device terminals and other parameters through the property mechanism. Each line begins with `5' in the first column, followed by the property number, followed by other data, and finally terminated with a semicolon. Refer to properties description (Appendix B) for information about properties and their syntax. If the device represents a subcircuit macro, the name property must be keyed with the character `x' or `X'.
After the property lines comes a CIF define symbol directive:
DS 0 1 1;The next line is a directive to use the SCED layer, which is the active layer in the drawing:
L SCED;The drawing in the cell should be on this layer to visually match the other elements, however there is no real requirement for this. There are additional layers in the default technology which can be used, typically for highlighting. The geometry used in a device has no electrical significance, i.e., no connectivity, and exists for visual purposes only.
The devices in the supplied device.lib file use 100 units per internal ``micron'' for historical reasons. Be advised that if a (RESOLUTION 1000); line appears at the top of the device definition, 1000 units will be assumed for the device. Devices that are edited by Xic or added through Xic editing will use 1000 units.
After the geometry comes the CIF directive to end symbol definition:
DF;The last line of the device definition contains the single character
Ewhich indicates the end of the device symbol definition. Note that in this case there is no terminating semicolon.
As an example, here is a sample library entry for a resistor:
# resistor (Symbol res); 5 10 -1 0 0 0 + 0 0 0; 5 10 -1 1 0 -1000 - 0 0 0; 5 11 R 0; 5 15 -100 -100 0 -1 "<v>/<value>"; 9 res; DS 0 1 1; L SCED; W 0 0 -1000 0 -750 -100 -700 100 -600 -100 -500 100 -400 -100 -300 0 -250 0 0; L ETC1; W 0 -100 -75 -100 -125; W 0 -125 -100 -75 -100; DF; E
The property lines (lines beginning with `5') represent two node definitions, a name, and a branch, in that order. The `W' line (wire) following the SCED layer declaration represents the path used to render the resistor schematic symbol. The other two `W' lines, following the ETC1 layer declaration, represents a `+' mark used to distinguish the positive end of the resistor, and the target upon which the user clicks to obtain the resistor current, in conjunction with the branch property.
The device library file can be viewed or edited from within Xic through the Edit command. If ``device.lib'' (or the actual file name) is given in response to the cell-to-edit prompt, a text editing window displaying the file appears. Actually, the current device library file is first copied to the current directory (if it is not already there), and the copy is opened for editing. After saving changes and quitting the text editor, the internal device database is rebuilt from the device library file in the current directory.
Devices from the library can also be edited graphically, and devices added, from within Xic. This will be described in the following section.
The vcc device is a special non-physical object used for tying different parts of the circuit together without a wire, and for assigning node names. One can rename the vcc device to other names in the device library file. The default terminal name is the name given to the device. It is important that the name property begin with the character `@'. A call to the vcc device is hard-coded in the Source SPICE command (among others) device placement code, so the supplied vcc device should not be removed from the device library file. The name label of the terminal can be modified. Nodes with an attached terminal with the same name label are tied together in the SPICE output.
There are two special layers added to the layer table: NODE, and TERM. The label associated with vcc type terminals use the NODE layer. The TERM layer is normally invisible, and is intended to be used for a vcc terminal device to be used for node naming, but is invisible after placement (except for the label).