Python » ROOM » Cell
Cell Class
Named design cell. Python counterpart of C++ room::Cell.
More…
| Import: | import room |
|---|---|
| Obtain: | db.find_cell(name) / db.get_or_create_cell(name) / db.cells() |
| C++: | room::Cell |
Notation: name() with parentheses = method (call it).
A bare name without () would mean an attribute — Cell has none of those;
use cell.name(), not cell.name.
Public API
name() | Cell name (str). |
contents() | All view bodies as list[CellContent]. |
content(view=None) | Existing view or None (C++ findContent). No arg / None: sole content when the cell has exactly one view. |
ensure_content(view="layout", dbu_per_micron=1000.0) | Get or create view (C++ getOrCreateContent). |
layout() | Shortcut for content("layout"). |
properties() | not yet exposed |
Detailed Description
A cell is a named design unit inside the library. It holds zero or more CellContent entries (layout, schematic, symbol, abstract). Names must be unique within the parent library.
Accessors match the C++ method style: call cell.name(), not cell.name.
Member documentation
name() → str
Returns the cell name (C++ Cell::name()).
Returns: Name assigned at creation or read from a file.
contents() → list[CellContent]
Returns all view data attached to this cell (C++ contents()).
Returns: List of CellContent handles (may be empty).
content(view=None) → CellContent | None
Looks up view data (C++ findContent). With no argument (or None), if the cell has exactly one content — typical for a single *.schematic.room / *.layout.room file — that body is returned. If there are zero or several views, returns None; pass an explicit view type instead.
| Parameter | Description |
|---|---|
view | Optional. None (default) = auto when unique; otherwise ViewType, int, or string ("layout", "schematic", "symbol", "abstract", "emmodel"). |
Returns: Matching content, or None.
cxt = cell.content() # sole view
cxt = cell.content("schematic") # explicit
lay = cell.layout() # layout only
ensure_content(view="layout", dbu_per_micron=1000.0) → CellContent
Returns existing view data or creates a new entry (C++ getOrCreateContent).
| Parameter | Description |
|---|---|
view | View type to retrieve or create. |
dbu_per_micron | Used only when a new content entry is created. |
layout() → CellContent | None
Convenience alias for content(ViewType.LAYOUT).
CellContent Class
One view body of a cell. Counterpart of C++ room::CellContent.
Block topology (shapes / instances / bbox) is exposed directly on this object
(there is no separate block() step in Python).
| Obtain: | cell.content(...) / cell.ensure_content(...) / cell.layout() |
|---|---|
| C++: | room::CellContent + block() |
Public API
view() | ViewType (C++ viewType()). |
dbu_per_micron() | float (C++ dbuPerMicron()). |
bbox() | Box (C++ block().bbox()). |
shapes() | Geometry list — see Shape. |
instances() | list[Instance]. |
add_rect(...) | Append a rectangle; returns index. |
add_instance(...) | Append a child placement; returns index. |
properties() / sourceInfo() / nets() | not yet exposed |
view() → ViewType
Returns the view kind of this content (C++ viewType()).
dbu_per_micron() → float
DBU per micron for layout views (C++ dbuPerMicron()). Typically 1000 for GDS imports.
bbox() → Box
Cached axis-aligned bounding box of the block (C++ block().bbox()).
shapes() → list[Rect | dict]
Geometry in this view (C++ block().shapes()). Rectangles become room.Rect; other kinds are {"type", "index"} dicts until fully decoded.
instances() → list[Instance]
Child cell placements (C++ block().instances()).
add_rect(layer_id, llx, lly, urx, ury) → int
Appends a rectangle shape. layer_id indexes into db.layers().
add_instance(cell_name, x=0, y=0, orient=Orient.R0, mag=1.0) → int
Appends a child placement referencing another cell by name.
Example
import room
db = room.open("design.room")
cell = db.find_cell("INVX1")
print(cell.name()) # 'INVX1'
layout = cell.ensure_content("layout")
print(layout.view(), layout.dbu_per_micron())
print(layout.bbox(), len(layout.shapes()), len(layout.instances()))