Python » ROOM » Database
Database Class
Root object of a ROOM design. Python counterpart of C++
room::Database.
Also hosts the library API (see Lib).
More…
| Import: | import room |
|---|---|
| Factories: | room.open, room.create, room.from_gds, … |
| C++: | room::Database |
Notation: names with () are methods (call them).
Names without () are attributes / properties (read or assign, do not call).
Example: cell.name() vs db.lib_name = "stdcells".
Factories
Database.create() / room.create() | Empty in-memory database. |
Database.open(path) / room.open(path) | Load .room. |
from_gds / from_qucs / from_xschem / from_oas | Import foreign formats. |
Attributes (no parentheses)
version | Format version string (read/write). C++ version() / setVersion. |
generator | Creating tool name (read/write). |
technology | PDK / technology id (read/write). |
lib_name | Library name (read/write). C++ lib().name(). |
file_view | ViewType (read/write). |
Methods (call with parentheses)
cells() | list[Cell] — C++ lib().cells(). |
cell_names() | List of cell name strings. |
layers() | list[Layer] — C++ lib().layers(). |
find_cell(name) | Cell | None. |
get_or_create_cell(name) | Create if missing. |
add_layer(...) | Append layer; returns index. |
summary_cell_count() / summary_primary_cell() | Header summary. |
info() | Summary dict. |
save(path, view="layout") | Write .room. |
to_gds / to_qucs / to_xschem / to_oas | Export. |
close() | Free handle (with supported). |
Detailed Description
A Database holds file metadata and one library of cells.
Library operations that live on db.lib() in C++ are methods/attributes of
Database in Python (see Lib).
Member documentation
Database.create() / room.create() → Database
Empty database. Default version is "1.0", lib_name is "default".
Database.open(path) / room.open(path) → Database
Loads a .room file (C++ loadFromFile). Path strings are strip()’d so accidental leading/trailing spaces (e.g. from paste) do not break open. Import/export helpers apply the same normalization.
version: str
Attribute (no call). Maps to C++ version() / setVersion. Assign with db.version = "1.0".
generator: str
Attribute. Creating tool name.
technology: str
Attribute. Technology / PDK identifier.
lib_name: str
Attribute. Library name (C++ lib().name()). Not db.name() — that would be ambiguous with cell names.
file_view: ViewType
Attribute. Primary view kind written into the file summary.
cells() → list[Cell]
Method. All cells (C++ lib().cells()). Call as db.cells().
cell_names() → list[str]
Method. Equivalent to [c.name() for c in db.cells()].
layers() → list[Layer]
Method. Shared layer table (C++ lib().layers()).
find_cell(name) → Cell | None
Method. Exact-name lookup (C++ findCell).
get_or_create_cell(name) → Cell
Method. Return existing cell or create an empty one.
add_layer(layer_num, data_type=0, name="", purpose=...) → int
Method. Append a layer; returns index usable as layer_id in add_rect.
info() → dict
Method. Convenience summary for printing / JSON.
save(path, view="layout")
Method. Write .room (C++ saveToFile).
Example
import room
with room.open("design.room") as db:
print(db.lib_name) # attribute — no ()
print(db.cell_names()) # method — with ()
cell = db.find_cell(db.cell_names()[0])
print(cell.name()) # method — with ()
print(cell.layout().bbox())