PyCell API 

PyCell API
The PyCell™ API provides a high-level programming interface designed specifically for building nanometer cell generators. It generates layout in environments that are subject to complex design rules.Accessed as a Python extension package, the PyCell API has a large number of built-in classes for layout generation, ranging from basic geometric classes (Point, Box, etc.) and standard shape classes (Rect, Polygon, etc.) to high-level layout classes, such as Contact, ContactRing, Bar, and RoutePath. High-level objects are automatically generated using all applicable design rules. PCell designers can use either PyCell or Python built-in classes, or they can derive their own.

Aside from built-in classes, the PyCell API provides several functions that can manage complex geometric operations. What follows is a detailed discussion of two of those functions.

The Power of the API: place vs. fgPlace
The function place(obj1, EAST, obj2, 500) performs an explicit relative placement operation; obj2 is placed 500 user units to the east of obj1.

The function fgPlace(obj1, EAST, obj2) will calculate the optimal placement of obj2 to the east of obj1; fgPlace will examine all layers on which these objects are defined and apply all applicable design rules. obj1 and obj2 can be simple shapes, complex structures, or complete PyCells, and the API will place them according to the relevant rules in the technology database.

The difference between "place" and "fgPlace" is worth highlighting: "place" takes explicit instructions from the author to perform relative placement. "fgPlace" is a member of a set of FG functions which automatically perform calculation of spacing for complex process design rules.

fgPlace used to create a transistor pair—PyCell Studio code at work
The PyCell example code below, simplified for readability, builds a portion of a simple transistor. The first line creates a polysilicon gate rectangle. The next lines create source and drain contacts, and then use the fgPlace() method to place these contacts "as close as possible" to this gate rectangle.

PyCell API

The next PyCell example code shown below builds a mirrored pair of transistors. The first two lines create these transistors, the third line mirrors one transistor, and the fourth line places these transistors "as close as possible." The fifth line then connects the source and drain pins together.

PyCell API

These examples illustrate the power of the PyCell approach: separate design rule management code from code describing the intention of the layout.

All FG functions work with the PyCell engine, which applies complex process design rules of the type normally encoded in design rule decks.