next up previous contents index
Next: Adding an Instance of Up: Parameterized Cells Previous: Xic Native PCells   Contents   Index

Creation of a Native Parameterized Cell

To create a native pcell, one can follow this procedure:

Write the script
Write a script that creates the geometry desired, in response to a set of variables that will become the parameters. The script can be authored as any other script. It should be thoroughly debugged before committing it to a parameterized cell.

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.

Create the parameterized cell
Use the Open (File menu) command to edit a new cell which will become the pcell. Add any fixed geometry to the cell that is necessary. This can be done at any time. Keep this cell as the current cell and add the properties listed below.

Add the pc_script property
Bring up the Cell Property Editor (Edit Menu). Press Add, which brings up a pop-up menu, and select pc_script in the pop-up menu. This will prompt for the property string on the prompt line.

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.

Enter property text with script
Press the ``L'' button to the left of the prompt line. This brings up the Text Editor pop-up. If the script text is Python or Tcl, a @LANG specification must appear first. Type one of the following into the editor window. For Python
@LANG Python
or if Tcl
Neither 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.

Enter property text without script
One can use the ``long text'' text editor feature, or simply type into the prompt line. Without the script, there generally isn't much to type.

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 path
where 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 digest
The 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.

Add a pc_params property
Next, we program the pcell's parameters and default values by adding a pc_params property. In the Cell Property Editor (Edit Menu), press Add, then select pc_params in the pop-up menu.

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.

Add additional properties
There are other properties that may be required, to support stretch handles (draggable edges, see 5.4) and auto-abutment (see 5.5) protocols. Text is added as for the properties we've described. This may be a second pass, after getting the basic cell working.

Save the current cell to disk, the native format is probably most convenient. Congratulations, you have yourself a pcell!

next up previous contents index
Next: Adding an Instance of Up: Parameterized Cells Previous: Xic Native PCells   Contents   Index
Stephen R. Whiteley 2022-05-28