The Save As Device button appears in the File Menu in electrical mode only. If the current cell is suitable as a device definition, meaning that the physical part is empty and there are no subcells, then the Device Parameters panel will appear. From this panel, the default device properties can be set, and the current cell saved as a device in either a file or an updated device library.
Devices in the device library can be edited, while in electrical mode, by simply giving the device name to the Open command or equivalent, and enabling editing mode with the Enable Editing button in the Edit Menu. When saving, with either Save or Save As, the Device Parameters pop-up will appear, as it will, of course, with the Save As Device button.
The panel will also appear in the Save As command if the name of the cell or file to save has been specified as the name of the device library file (default ``device.lib''). Again, the cell must contain geometry appropriate for a device, i.e., no physical data and no subcells.
When creating a new device symbol, one can use an existing symbol from the device library as a starting point, and save under a new name. This will tend to keep the new device size and other characteristics similar to existing devices.
The remainder of this section describes the controls found in the Device Parameters panel.
The subct side-menu command is used to set the device connection points. The order of appearance on the SPICE line is the same as the numerical order in the marks shown in the subct command. The subct command creates the node properties required for electrical connection. At least one connection point is required, unless the SPICE Prefix begins with `x' or `X' (indicating a macro) in which case a connection point is not required. Thus it is possible for a macro, like a subcircuit, to connect to global nodes only.
The Device Name entry area contains the device (cell) name. This is arbitrary and can be changed, however a name must appear. This is the name by which the device is known to Xic, and the name that will appear in the device selection menu.
The SPICE Prefix is one or more characters that will be prepended to the device instance lines when a SPICE file is created. An entry in this field is usually mandatory. The pop-up will accept anything, however the first character should match the requirements of SPICE, which expects a certain key letter for each device, such as `R' for resistors (case independent). Additional characters can appear, and should be alphanumeric. An exception is the terminal device, which is not instantiated in SPICE, and must have a prefix starting with the character `@' for internal use by Xic. In Xic, the SPICE prefix for normal devices has no internal significance except as a unique identifier of that particular device, so the prefix should be unique in the device library file. The prefix is saved in a name property applied to the device.
If the current cell is not a SPICE device but rather a macro, which will instantiate a subcircuit (such as the ``opamp'' example in the supplied device.lib file) the SPICE Prefix must start with `x' or `X'.
A subcircuit added in this manner is expected to reference a .subckt macro in the model library. The name of the macro (not the file name) is given to instances of the device as a model property. A default model property can be supplied to the device. In the example, the name of the device is ``opamp'', and the model property is given as ``ua741''. There should be a file in the models subdirectories along the library search path, or an entry in the model library file, starting with ``.subckt ua741 ...'' and containing the subcircuit definition, terminated with ``.ends''. Note that subcircuits and models can be intermixed freely in the model files, but the reference names must be unique.
There is one special case: ground terminals. These have exactly one connection (a node property), and no other properties including a name property (prefix). If this matches the current cell, and a ground terminal in intended, then the SPICE Prefix should be left blank.
The Default Model and Default Value fields are optional for devices. Either one, but not both can be given, providing a default model name or default value to the device. If both are given, the Default Value entry will be ignored. These entries translate into model and value properties applied to the device. Instances will inherit which ever of these properties is given, but they can be changed on a per-instance basis.
If the device is a macro, i.e., the SPICE prefix starts with `x' or `X', then the Default Model field is mandatory and contains the name of the subcircuit that will be instantiated. This name should be found in a .subckt line in the model library.
The Default Parameters field provides a default parameter set for the device or macro. The string can be any text relevant to the device in the context of SPICE, and will appear as a param property when the device is instantiated. This property can subsequently be changed in the instances.
The Hot Spot button, and associated menu and entry area, allows a branch property to be applied to the device. The branch property allows an internal value or function to be associated with a location in the schematic symbol, which can be clicked on in the drawing to obtain the values, after a simulation. For most devices, this will yield the current through the device. The branch property is ``internal'', meaning that it can not be changed in instances by the user.
The Hot Spot button will be active when the device contains a branch property. Pressing the button will create the property.
The branch property contains the hot spot coordinates, which are marked on-screen with a white cross when the Hot Spot button is active. While the Hot Spot button is active, clicking in the drawing will move the hot spot, and the white cross, to the button-down location. The user should click to locate the hot spot where desired in the drawing. In most of the devices in the supplied device library file, the hot spot is located on the `+ ' symbol that appears near the top device terminal.
The menu contains an orientation for the hot spot data. This is needed when the returned value is a current, and indicates the actual direction of positive current flow, relative to the device symbol. Typically, the two device terminals are oriented vertically, with the `+ ' associated with the top terminal, which would imply that the orientation choice should be ``Down''. If a scalar value is returned, so that there is no orientation, the correct choice would be ``none''. This selection will set the style and orientation of the plot trace marker applied when the hot spot is clicked on in the plot and iplot (electrical side menu) commands.
The text entry provides an expression for the value to be returned. The description of the branch property in D.3 describes this. This is the string part of the property description line, and may be empty for inductors and voltage sources.
The No Physical Implementation box should be checked if the device will never have a direct correspondence to geometry in the physical layout. This is true for example for voltage and current sources. Devices with this property set will not be considered in LVS testing and will never appear in netlists extracted from physical data. The device terminals will never appear in physical layouts. This will apply a nophys property to the device.
Once all needed fields have been filled in, the device can be saved. The Save in Library button will perform the following steps:
It is critical that the first line of a device description in the device library be a comment naming the device, in the form
(Symbol: devname);When updating the library, the process looks for lines of this form. Xic will always add this line, but it may not be present if the file has been hand edited.
If, instead, it is desirable to avoid touching the device library but the user wishes to save the device, the Save as Cell File button can be used to save the device as a native cell file.
After saving, the device selection menus are updated, in case the device was saved to a location that was referenced in the device library, such as by a Directory keyword.
Warning: Be aware that it is not good to have cell files lying around that conflict with cells provided by the device library, as they can potentially cause trouble. Such files should be moved somewhere safe, at least out of the search path.