To create a native pcell, one can follow this procedure:
It is recommended that the top of the script contain a comment listing the parameters and their purposes, and explicit tests of the values that will abort the script (returning nonzero) if a value is out of range or otherwise not acceptable. Any nonzero return should have a call to AddError explaining the error. This text will be included in the system error reporting.
At this point we need to decide whether to incorporate the script into the property string itself, or to keep the script in a separate file. One consideration is that GDSII and CGX files have 16-bit record lengths, which will limit the lengths of property strings. In the present Xic release, CIF and native string lengths, and OASIS string lengths, are unlimited. There is also no limit when storing the cell in OpenAccess.
First, assume that the script is to be stored in the property string. We will use the ``long text'' feature to facilitate entering the script.
@LANG Pythonor if Tcl
@LANG TclNeither is needed for native script language.
The next step is to import the script text. This is presumed to exist in a file, though for very simple scripts an advanced user can type it in. For the script in a file, one can use the Read button of the text editor (in the File menu) to read in the script file. Then perform any last minute editing, such as removal of the variable declarations that would be redundant with the parameters.
Press the Save button in the File menu of the text editor. The text editor will disappear, and the script will have been saved in the pc_script property of the current cell.
First, if the script text is Python or Tcl, one must enter a @LANG specifier as explained above. If needed, just type in the two tokens. Next, enter a @READ directive in the form
@READ pathwhere path is a path to the file containing the script. This can be an absolute path, however it may be more convenient to just specify the file name, and set the PCellScriptPath variable to a directory where pcell script files are kept. Then, the location can change without one having to edit the property string. This completes text entry. Exit the text editor as above if it is being used, or press Enter to terminate text entry into the prompt line. The text is saved in the pc_script property of the current cell.
Optionally, one can append a directive of the form
@MD5 digestThe digest is the 32-character string obtained from the !md5 command for the script file. When included, the script will not execute unless the script file has a matching MD5 digest, which ensures that the script file accessed is the correct one and hasn't been modified.
Again, one can use the ``long text'' editor, or type directly into the prompt line. For long parameter lists, the editor would be preferred. Enter the parameter list in the format described for this property string (see 5.1.3). If using the editor, any combination of multiple lines and/or multiple specifications per line can be used. A parameter specification consists of a parameter name followed by `=' and its value, optionally followed by a colon and a constraint string (see 5.2). There must be no white space around the colon that delimits the constraint string, but the constraint string itself may contain white space, which is ignored.
Save the text if using the text editor, or press Enter if using the prompt line, when done.
Save the current cell to disk, the native format is probably most convenient. Congratulations, you have yourself a pcell!