BaseDatabase class#
- class laygo2.object.database.BaseDatabase(name, params=None, elements=None)[source]#
Bases:
Generic
[T
]A base class that implements basic functions for various database objects, such as libraries and designs.
Public Data Attributes:
name
Name of BaseDatabase object.
params
BaseDatabase object's parameter dictionary.
elements
Element object dictionary.
noname_index
Unique identifier index for unnamed objects.
Public Methods:
keys
()Keys of elements.
items
()Key-object pairs of elements.
__getitem__
(pos)Return the object corresponding to pos.
__setitem__
(key, item)Add key/object pair.
append
(item)Add physical object to BaseDatabase without taking any further actions.
__iter__
()Element-mapped direct iterator function.
__str__
()Return str(self).
summarize
()Get object information summary.
__init__
(name[, params, elements])BaseDatabase class constructor function.
Inherited from
Generic
__class_getitem__
Parameterizes a generic class.
__init_subclass__
Function to initialize subclasses.
- __init__(name, params=None, elements=None)[source]#
BaseDatabase class constructor function.
- Parameters:
- Return type:
laygo2.object.BaseDatabase
Example
>>> import laygo2 >>> base = laygo2.object.database.BaseDatabase(name='mycell') >>> print(base) <laygo2.object.database.BaseDatabase object> name: mycell, params: None elements: {}>
- append(item)[source]#
Add physical object to BaseDatabase without taking any further actions.
- Parameters:
item (laygo2.object.physical.PhysicalObject) – Physical object to be added.
- Returns:
List of item name and item ([item.name, item]).
- Return type:
Example
>>> import laygo2 >>> from laygo2.object.database import BaseDatabase >>> from laygo2.object.physical import Rect, Pin, Instance, Text >>> # Create a design >>> dsn = Design(name="mycell", libname="genlib") >>> # Create layout objects >>> r0 = Rect(xy=[[0, 0], [100, 100]], layer=["M1", "drawing"]) >>> p0 = Pin(xy=[[0, 0], [50, 50]], layer=["M1", "pin"], name="P") >>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0]) >>> t0 = Text(xy=[[50, 50], [100, 100]], layer=["text", "drawing"], text="T") >>> dsn.append(r0) >>> dsn.append(p0) >>> dsn.append(i0) >>> dsn.append(t0) >>> print(dsn) <laygo2.object.database.BaseDatabase object at 0x0000024C6C2EF010> name: mycell, params: None elements: { 'NoName_0': <laygo2.object.physical.Rect object at 0x0000024C6C230F40>, 'P': <laygo2.object.physical.Pin object at 0x0000024C6C2EFF40>, 'I0': <laygo2.object.physical.Instance object at 0x0000024C6C2EFDC0>, 'NoName_1': <laygo2.object.physical.Text object at 0x0000024C6C2EF8B0>}
- items()[source]#
Key-object pairs of elements.
- Parameters:
None
- Return type:
dict_items
Example
>>> import laygo2 >>> from laygo2.object.database import BaseDatabase >>> from laygo2.object.physical import Rect, Pin, Instance, Text >>> # Create a design >>> dsn = BaseDatabase(name="mycell") >>> # Create layout objects >>> r0 = Rect(xy=[[0, 0], [100, 100]], layer=["M1", "drawing"]) >>> p0 = Pin(xy=[[0, 0], [50, 50]], layer=["M1", "pin"], name="P") >>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0]) >>> t0 = Text(xy=[[50, 50], [100, 100]], layer=["text", "drawing"], text="T") >>> dsn.append(r0) >>> dsn.append(p0) >>> dsn.append(i0) >>> dsn.append(t0) >>> print(dsn.items()) dict_items([('NoName_0', <laygo2.object.physical.Rect object at 0x0000024C6C230F40>), ('P', <laygo2.object.physical.Pin object at 0x0000024C6C2EFF40>), ('I0', <laygo2.object.physical.Instance object at 0x0000024C6C2EFDC0>), ('NoName_1', <laygo2.object.physical.Text object at 0x0000024C6C2EF8B0>)])
- keys()[source]#
Keys of elements.
Example
>>> import laygo2 >>> from laygo2.object.database import BaseDatabase >>> from laygo2.object.physical import Rect, Pin, Instance, Text >>> # Create a design >>> dsn = BaseDatabase(name="mycell") >>> # Create layout objects >>> r0 = Rect(xy=[[0, 0], [100, 100]], layer=["M1", "drawing"]) >>> p0 = Pin(xy=[[0, 0], [50, 50]], layer=["M1", "pin"], name="P") >>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0]) >>> t0 = Text(xy=[[50, 50], [100, 100]], layer=["text", "drawing"], text="T") >>> dsn.append(r0) >>> dsn.append(p0) >>> dsn.append(i0) >>> dsn.append(t0) >>> print(dsn.keys()) dict_keys(['NoName_0', 'P', 'I0', 'NoName_1'])
- elements: Dict[str, Type[PhysicalObject | T]] = None#
Element object dictionary.
Example
>>> import laygo2 >>> from laygo2.object.database import BaseDatabase >>> from laygo2.object.physical import Rect, Pin, Instance, Text >>> # Create a design. >>> dsn = BaseDatabase(name="mycell") >>> # Create layout objects. >>> r0 = Rect(xy=[[0, 0], [100, 100]], layer=["M1", "drawing"]) >>> p0 = Pin(xy=[[0, 0], [50, 50]], layer=["M1", "pin"], name="P") >>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0]) >>> t0 = Text(xy=[[50, 50], [100, 100]], layer=["text", "drawing"], text="T") >>> # Add layout objects to the design. >>> dsn.append(r0) >>> dsn.append(p0) >>> dsn.append(i0) >>> dsn.append(t0) >>> # >>> # Display elements of the design. >>> print(dsn.elements) {'NoName_0': <laygo2.object.physical.Rect object at 0x0000024C6C230F40>, 'P': <laygo2.object.physical.Pin object at 0x0000024C6C2EFF40>, 'I0': <laygo2.object.physical.Instance object at 0x0000024C6C2EFDC0>, 'NoName_1': <laygo2.object.physical.Text object at 0x0000024C6C2EF8B0>}
- Type:
- name = None#
Name of BaseDatabase object.
Example
>>> import laygo2 >>> base = laygo2.object.database.BaseDatabase(name="mycell") >>> base.name "mycell"
- Type:
- noname_index = 0#
Unique identifier index for unnamed objects.
Example
>>> import laygo2 >>> from laygo2.object.database import BaseDatabase >>> from laygo2.object.physical import Rect, Pin, Instance, Text >>> # Create a design >>> dsn = BaseDatabase(name="mycell") >>> # Create layout objects >>> r0 = Rect(xy=[[0, 0], [100, 100]], layer=["M1", "drawing"]) >>> dsn.append(r0) >>> print(base.noname_index) 0 >>> r1 = Rect(xy=[[100, 100], [200, 200]], layer=["M1", "drawing"]) >>> dsn.append(r1) >>> print(base.noname_index) 1
- Type: