Design class#

class laygo2.object.database.Design(name, params=None, elements=None, libname=None)[source]#

Bases: BaseDatabase

Class for design management function implementation.

Example

A physical (non-abstract) grid example:

>>> import laygo2
>>> from laygo2.object.database import Design
>>> 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")
>>> # Add the layout objects to the design object.
>>> dsn.append(r0)
>>> dsn.append(p0)
>>> dsn.append(i0)
>>> dsn.append(t0)
>>> print(dsn)
<laygo2.object.database.Design 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>}
    libname:genlib
    rects:{
        'NoName_0': <laygo2.object.physical.Rect object at 0x0000024C6C230F40>}
    paths:{}
    pins:{
        'P': <laygo2.object.physical.Pin object at 0x0000024C6C2EFF40>}
    texts:{
        'NoName_1': <laygo2.object.physical.Text object at 0x0000024C6C2EF8B0>}
    instances:{
        'I0': <laygo2.object.physical.Instance object at 0x0000024C6C2EFDC0>}
    virtual instances:{}
>>> #
>>> # Export to a NativeInstanceTemplate for reuse in higher levels.
>>> nt0 = dsn.export_to_template()
>>> nt0.dsn.export_to_template()
>>> print(nt0)
    <laygo2.object.template.NativeInstanceTemplate object at 0x000001CB5A9CE380>
    name: mycell,
    class: NativeInstanceTemplate,
     bbox: [[0, 0], [0, 0]],
     pins: {'P': <laygo2.object.physical.Pin object at 0x000001CB5A9CFF40>},
>>> #
>>> # Export to a skill script.
>>> lib = laygo2.object.database.Library(name="mylib")
>>> lib.append(dsn)
>>> scr = laygo2.interface.skill.export(lib, filename="myscript.il")
>>> print(scr)
; (definitions of laygo2 skill functions)
; exporting mylib__mycell
cv = _laygo2_open_layout("mylib" "mycell" "layout")
_laygo2_generate_rect(cv, list( "M1" "drawing" ), list( list( 0.0000  0.0000  ) list( 0.1000  0.1000  ) ), "None")
_laygo2_generate_pin(cv, "P", list( "M1" "pin" ), list( list( 0.0000  0.0000  ) list( 0.0500  0.0500  ) ) )
_laygo2_generate_instance(cv, "I0", "tlib", "t0", "layout", list( 0.0000  0.0000  ), "R0", 1, 1, 0, 0, nil, nil)
_laygo2_save_and_close_layout(cv)

An abstract grid example:

>>> import laygo2
>>> from laygo2.object.grid import CircularMapping as CM
>>> from laygo2.object.grid import CircularMappingArray as CMA
>>> from laygo2.object.grid import OneDimGrid, PlacementGrid, RoutingGrid
>>> from laygo2.object.template import NativeInstanceTemplate
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Instance
>>> # Placement grid construction (not needed if laygo2_tech is set up).
>>> gx  = OneDimGrid(name="gx", scope=[0, 20], elements=[0])
>>> gy  = OneDimGrid(name="gy", scope=[0, 100], elements=[0])
>>> gp  = PlacementGrid(name="test", vgrid=gx, hgrid=gy)
>>> # Routing grid construction (not needed if laygo2_tech is set up).
>>> gv = OneDimGrid(name="gv", scope=[0, 50], elements=[0])
>>> gh = OneDimGrid(name="gv", scope=[0, 100], elements=[0, 40, 60])
>>> wv = CM([10])           # vertical (xgrid) width
>>> wh = CM([20, 10, 10])   # horizontal (ygrid) width
>>> ev = CM([10])           # vertical (xgrid) extension
>>> eh = CM([10, 10, 10])   # horizontal (ygrid) extension
>>> e0v = CM([15])          # vert. extension (for zero-length wires)
>>> e0h = CM([15, 15, 15])  # hori. extension (for zero-length wires)
>>> lv = CM([['M1', 'drawing']], dtype=object)  # layer information
>>> lh = CM([['M2', 'drawing']]*3, dtype=object)
>>> plv = CM([['M1', 'pin']], dtype=object) # pin layers
>>> plh = CM([['M2', 'pin']]*3, dtype=object)
>>> xcolor = CM([None], dtype=object)  # not multipatterned
>>> ycolor = CM([None]*3, dtype=object)
>>> primary_grid = 'horizontal'
>>> tvia = NativeInstanceTemplate(libname='tlib', cellname='via0')  # via
>>> viamap = CMA(elements=[[tvia, tvia, tvia]], dtype=object)
>>> gr = laygo2.object.grid.RoutingGrid(name='mygrid', vgrid=gv, hgrid=gh,
                                        vwidth=wv, hwidth=wh,
                                        vextension=ev, hextension=eh,
                                        vlayer=lv, hlayer=lh,
                                        pin_vlayer=plv, pin_hlayer=plh,
                                        viamap=viamap, primary_grid=primary_grid,
                                        xcolor=xcolor, ycolor=ycolor,
                                        vextension0=e0v, hextension0=e0h)
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> # Create an instance
>>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0])
>>> print(inst0.xy)
[100, 100]
>>> # Place the instance
>>> dsn.place(inst=i0, grid=gp, mn=[10,10])
>>> # Routing on grid
>>> mn_list = [[0, -2], [0, 1], [2, 1], [5,1] ]
>>> route = dsn.route(grid=gr, mn=mn_list,
                      via_tag=[True, None, True, True])
>>> #
>>> # Display generated design.
>>> print(dsn)
<laygo2.object.database.Design object at 0x000001C71AE3A110>
    ...
>>> #
>>> # Export to a NativeInstanceTemplate for reuse in higher levels.
>>> nt0 = dsn.export_to_template()
>>> nt0.dsn.export_to_template()
>>> print(nt0)
    ...
>>> #
>>> # Export to a skill script.
>>> lib = laygo2.object.database.Library(name="mylib")
>>> lib.append(dsn)
>>> scr = laygo2.interface.skill.export(lib, filename="myscript.il")
>>> print(scr)
    ...

An abstract template/grid example with technology setup (laygo2_tech):

>>> import laygo2
>>> import laygo2.interface
>>> import laygo2_tech_quick_start as tech  # target tech's laygo2_tech
>>> from laygo2.object.database import Design
>>> templates = tech.load_templates()
>>> mytemplate = templates['nmos']
>>> grids = tech.load_grids(templates=templates)
>>> gp = grids['placement_basic']
>>> gr = grids['routing_23_cmos']
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> # Create an instance
>>> i0 = tnmos.generate(name='MN0', params={'nf': 4})
>>> # Place the instance
>>> dsn.place(inst=i0, grid=gp, mn=[10,10])
>>> # Routing on grid
>>> mn_list = [[0, -2], [0, 1], [2, 1], [5,1] ]
>>> route = dsn.route(grid=gr, mn=mn_list,
                      via_tag=[True, None, True, True])
>>> #
>>> # Display generated design.
>>> print(dsn)
<laygo2.object.database.Design object at 0x000001C71AE3A110>
    ...
>>> #
>>> # Export to a NativeInstanceTemplate for reuse in higher levels.
>>> nt0 = dsn.export_to_template()
>>> nt0.dsn.export_to_template()
>>> print(nt0)
    ...
>>> #
>>> # Export to a skill script.
>>> lib = laygo2.object.database.Library(name="mylib")
>>> lib.append(dsn)
>>> scr = laygo2.interface.skill.export(lib, filename="myscript.il")
>>> print(scr)
    ...

Public Data Attributes:

bbox

Get design bounding box by taking union of instances' bounding boxes.

libname

cellname

rects

Dictionary containing Rectangle object affiliated with the Design object.

r

paths

pins

Dictionary having the collection of Pin objects affiliated with the Design object.

p

texts

Dictionary containing Text objects affiliated with Design object.

instances

Dictionary containing Instance objects affiliated with Design object.

i

virtual_instances

Dictionary containing VirtualInstance objects affiliated with Design object.

vi

elements

Element object dictionary.

Inherited from BaseDatabase

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:

get_libname()

set_libname(val)

get_cellname()

set_cellname(val)

get_r()

set_r(val)

get_p()

set_p(val)

get_i()

set_i(val)

get_vi()

set_vi(val)

__iter__()

Element-mapped direct iterator function.

__init__(name[, params, elements, libname])

Design class constructor function.

append(item)

Add physical object to Design without taking any further actions.

summarize()

Get object information summary.

place(inst, grid[, mn, anchor_xy])

Place instance at abstract coordinate mn on abstract grid.

route(grid, mn[, direction, via_tag])

Create wire object(s) for routing at abstract coordinate mn.

via(grid, mn[, params])

Create Via object(s) on abstract grid.

route_via_track(grid, mn, track[, via_tag])

Perform routing on the specified track with accessing wires to mn.

pin(name, grid, mn[, direction, netname, params])

Create a Pin object over the abstract coordinates specified by mn, on the specified routing grid.

export_to_template([libname, cellname])

Generate a NativeInstanceTemplate object corresponding to Design object.

get_matched_rects_by_layer(layer)

Return a list containing physical objects matched with the layer input in Design object.

Inherited from BaseDatabase

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, libname=None)[source]#

Design class constructor function.

Parameters:
  • name (str) – Design object name.

  • params (dict, optional) – Design object parameters.

  • elements (dict, optional) – Design object elements.

Return type:

laygo2.object.BaseDatabase

Example

>>> import laygo2
>>> dsn = laygo2.object.database.Design(name='dsn', libname="testlib")
>>> print(dsn)
<laygo2.object.database.Design object>  name: dsn, params: None
    elements: {}
    libname:testlib
    rects:{}
    paths:{}
    pins:{}
    texts:{}
    instances:{}
    virtual instances:{}
append(item)[source]#

Add physical object to Design without taking any further actions.

Parameters:

item (laygo2.object.physical.PhysicalObject) – The physical object to be added.

Returns:

A list containing the name of item and the item itself ([item.name, item]).

Return type:

list

Example

>>> import laygo2
>>> from laygo2.object.database import Design
>>> 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.Design 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>}
    libname:genlib
    rects:{
        'NoName_0': <laygo2.object.physical.Rect object at 0x0000024C6C230F40>}
    paths:{}
    pins:{
        'P': <laygo2.object.physical.Pin object at 0x0000024C6C2EFF40>}
    texts:{
        'NoName_1': <laygo2.object.physical.Text object at 0x0000024C6C2EF8B0>}
    instances:{
        'I0': <laygo2.object.physical.Instance object at 0x0000024C6C2EFDC0>}
    virtual instances:{}

See also

laygo2.object.database.Design.place

Place a (virtual) instance on a grid and append to the design.

laygo2.object.database.Design.route

Route on a grid and append to the design.

laygo2.object.database.Design.route_via_track

Route on a track on a grid and append.

laygo2.object.database.Design.pin

Place a pin on a grid and append to the design.

export_to_template(libname=None, cellname=None)[source]#

Generate a NativeInstanceTemplate object corresponding to Design object.

Parameters:
  • libname (str) – The library name.

  • cellname (str) – The cell name.

Returns:

laygo2.NativeInstanceTemplate

Return type:

The generated template object.

Example

>>> import laygo2
>>> from laygo2.object.database import Design
>>> 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)
>>> # Export the design to a template.
>>> nt0 = dsn.export_to_template()
>>> print(nt0)
<laygo2.object.template.NativeInstanceTemplate object at XXXX>
    name: mycell, class: NativeInstanceTemplate,
    bbox: [[0, 0], [0, 0]],
    pins: {'P': <laygo2.object.physical.Pin object at YYYY>},
>>> # Save the template into a yaml file.
>>> laygo2.interface.yaml.export_template(nt0, filename='mytemp.yaml')

See also

laygo2.interface.yaml.export_template

Export a template to a yaml file.

get_cellname()[source]#
get_i()[source]#
get_libname()[source]#
get_matched_rects_by_layer(layer)[source]#

Return a list containing physical objects matched with the layer input in Design object.

Parameters:

layer (list) – The layer information. Format is [name, purpose].

Returns:

list

Return type:

The list containing the matched Physical objects.

Example

>>> dsn    = laygo2.object.Design(name='dsn', libname="testlib")
>>> rect0  = laygo2.object.Rect(xy=[[0, 0], [100, 100]], layer=[‘M1’, ‘drawing’]……)
>>> pin0   = laygo2.object.Pin(xy=[[0, 0], [100, 100]], layer=[‘M1’, ‘pin’]……)
>>> inst0  = laygo2.object.Instance(name=‘I0’, xy=[100, 100]……)
>>> vinst0_pins[‘in’]  = laygo2.object.physical.Pin(xy=[[0, 0], [10, 10]], layer=[‘M1’,’drawing’]……)
>>> vinst0_pins[‘out’] = laygo2.object.physical.Pin(xy=[[90, 90], [100, 100]], layer=[‘M1’, drawing’] ……)
>>> vinst0 = laygo2.object.physical.VirtualInstance(name=‘VI0’, ……)
>>> text0  = laygo2.object.physical.Text(xy=[[ 0, 0], [100,100 ]], layer=[‘text’, ‘drawing’]……)
>>> dsn.append(rect0)
>>> dsn.append(pin0)
>>> dsn.append(inst0)
>>> dsn.append(vinst0)
>>> dsn.append(text0)
>>> print( dsn.get_matchedrects_by_layer( [“M1”, “drawing”] )
[<laygo2.object.physical.Rect object>,
 <laygo2.object.physical.Pin object>,
 <laygo2.object.physical.Pin object>,
 <laygo2.object.physical.Rect object>]
get_p()[source]#
get_r()[source]#
get_vi()[source]#
items()#

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()#

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'])
pin(name, grid, mn, direction=None, netname=None, params=None)[source]#

Create a Pin object over the abstract coordinates specified by mn, on the specified routing grid.

Parameters:
  • name (str) – Pin name.

  • mn (numpy.ndarray) – Abstract coordinates for generating Pin.

  • direction (str, optional.) – Direction.

  • netname (str, optional.) – Net name of Pin.

  • params (dict, optional) – Pin attributes.

Returns:

laygo2.physical.Pin

Return type:

The generated pin object.

Example

>>> import laygo2
>>> from laygo2.object.grid import CircularMapping as CM
>>> from laygo2.object.grid import CircularMappingArray as CMA
>>> from laygo2.object.grid import OneDimGrid, RoutingGrid
>>> from laygo2.object.template import NativeInstanceTemplate
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Instance
>>> # Routing grid construction (not needed if laygo2_tech is set up).
>>> gv = OneDimGrid(name="gv", scope=[0, 50], elements=[0])
>>> gh = OneDimGrid(name="gv", scope=[0, 100], elements=[0, 40, 60])
>>> wv = CM([10])           # vertical (xgrid) width
>>> wh = CM([20, 10, 10])   # horizontal (ygrid) width
>>> ev = CM([10])           # vertical (xgrid) extension
>>> eh = CM([10, 10, 10])   # horizontal (ygrid) extension
>>> e0v = CM([15])          # vert. extension (for zero-length wires)
>>> e0h = CM([15, 15, 15])  # hori. extension (for zero-length wires)
>>> lv = CM([['M1', 'drawing']], dtype=object)  # layer information
>>> lh = CM([['M2', 'drawing']]*3, dtype=object)
>>> plv = CM([['M1', 'pin']], dtype=object) # pin layers
>>> plh = CM([['M2', 'pin']]*3, dtype=object)
>>> xcolor = CM([None], dtype=object)  # Not multipatterned
>>> ycolor = CM([None]*3, dtype=object)
>>> primary_grid = 'horizontal'
>>> tvia = NativeInstanceTemplate(libname='tlib', cellname='via0')  # via
>>> viamap = CMA(elements=[[tvia, tvia, tvia]], dtype=object)
>>> g = laygo2.object.grid.RoutingGrid(name='mygrid', vgrid=gv, hgrid=gh,
                                       vwidth=wv, hwidth=wh,
                                       vextension=ev, hextension=eh,
                                       vlayer=lv, hlayer=lh,
                                       pin_vlayer=plv, pin_hlayer=plh,
                                       viamap=viamap, primary_grid=primary_grid,
                                       xcolor=xcolor, ycolor=ycolor,
                                       vextension0=e0v, hextension0=e0h)
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> ###############
>>> # Place a pin #
>>> ###############
>>> mn = [[0, 0], [10, 10]]
>>> pin = dsn.pin(name="pin", grid=g, mn=mn)
>>> print(pin)
<laygo2.object.physical.Pin object at 0x0000028DABE3AB90>
    name: pin,
    class: Pin,
    xy: [[0, -10], [500, 350]],
    params: None, , layer: ['M2' 'pin'], netname: pin, shape: None,
    master: None
>>> print(dsn)
<laygo2.object.database.Design object at 0x0000028DABE3A110> name: mycell, params: None
    elements: {'pin': <laygo2.object.physical.Pin object at
    0x0000028DABE3AB90>}
    libname:genlib
    rects:{}
    paths:{}
    pins:{'pin': <laygo2.object.physical.Pin object at 0x0000028DABE3AB90>}
    texts:{}
    instances:{}
    virtual instances:{}
place(inst, grid, mn=[0, 0], anchor_xy=None)[source]#

Place instance at abstract coordinate mn on abstract grid.

Parameters:
Returns:

Placed instance(s) (list if multiple).

Return type:

laygo2.object.physical.Instance or laygo2.object.physical.VirtualInstance or list(laygo2.object.physical.Instance)

Example

>>> import laygo2
>>> from laygo2.object.grid import OneDimGrid, PlacementGrid
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Instance
>>> # Create a grid (not needed if laygo2_tech is set up).
>>> gx  = OneDimGrid(name="gx", scope=[0, 20], elements=[0])
>>> gy  = OneDimGrid(name="gy", scope=[0, 100], elements=[0])
>>> g   = PlacementGrid(name="test", vgrid=gx, hgrid=gy)
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> # Create an instance
>>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0])
>>> print(inst0.xy)
[100, 100]
>>> ######################
>>> # Place the instance #
>>> ######################
>>> dsn.place(inst=i0, grid=g, mn=[10,10])
>>> # Print parameters of the placed instance.
>>> print(i0.xy)
[200, 1000]
>>> print(dsn)
<laygo2.object.database.Design object at 0x000002803D4C0F40>
    name: mycell
    params: None
    elements:
        {'I0': <laygo2.object.physical.Instance object at
                0x000002803D57F010>}
    libname:genlib
    rects:{}
    paths:{}
    pins:{}
    texts:{}
    instances:
        {'I0': <laygo2.object.physical.Instance object at 0x000002803D57F010>}
    virtual instances:{}
>>> # When placing multiple instances by wrapping them with a list:
>>> i1 = Instance(libname="tlib", cellname="t1", name="I1", xy=[0, 0])
>>> i2 = Instance(libname="tlib", cellname="t2", name="I2", xy=[0, 0])
>>> i3 = Instance(libname="tlib", cellname="t3", name="I3", xy=[0, 0])
>>> dsn.place(inst= [i1, i2, i3], grid=g, mn=[10,10])
>>> print(dsn)
<laygo2.object.database.Design object at 0x000002803D4C0F40>
    name: mycell
    params: None
    elements:
        {'I0': <laygo2.object.physical.Instance object at
                0x000002803D57F010>,
         'I1': <laygo2.object.physical.Instance object at
                0x000002803D57F011>,
         'I2': <laygo2.object.physical.Instance object at
                0x000002803D57F012>,
         'I3': <laygo2.object.physical.Instance object at
                0x000002803D57F013>
                }
    libname:genlib
    rects:{}
    paths:{}
    pins:{}
    texts:{}
    instances:
        {'I0': <laygo2.object.physical.Instance object at 0x000002803D57F010>,
         'I1': <laygo2.object.physical.Instance object at 0x000002803D57F011>,
         'I2': <laygo2.object.physical.Instance object at 0x000002803D57F012>,
         'I3': <laygo2.object.physical.Instance object at 0x000002803D57F013>
        }
    virtual instances:{}

See also

laygo2.object.grid.PlacementGrid.place

place a (virtual) instance on the grid.

route(grid, mn, direction=None, via_tag=None)[source]#

Create wire object(s) for routing at abstract coordinate mn.

Parameters:
  • grid (laygo2.object.grid.RoutingGrid) – Placement grid for wire placement.

  • mn (list(numpy.ndarray)) – List containing two or more mn coordinates to be connected.

  • direction (str, optional.) – None or “vertical” or “horizontal”. The direction of the routing object.

  • via_tag (list(Boolean), optional.) – The list containing switches deciding whether to place via at the edges.

Returns:

The generated routing object(s). Check the example code in laygo2.object.grid.RoutingGrid.route for details.

Return type:

laygo2.object.physical.Rect or list

Example

>>> import laygo2
>>> from laygo2.object.grid import CircularMapping as CM
>>> from laygo2.object.grid import CircularMappingArray as CMA
>>> from laygo2.object.grid import OneDimGrid, RoutingGrid
>>> from laygo2.object.template import NativeInstanceTemplate
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Instance
>>> # Routing grid construction (not needed if laygo2_tech is set up).
>>> gv = OneDimGrid(name="gv", scope=[0, 50], elements=[0])
>>> gh = OneDimGrid(name="gv", scope=[0, 100], elements=[0, 40, 60])
>>> wv = CM([10])           # vertical (xgrid) width
>>> wh = CM([20, 10, 10])   # horizontal (ygrid) width
>>> ev = CM([10])           # vertical (xgrid) extension
>>> eh = CM([10, 10, 10])   # horizontal (ygrid) extension
>>> e0v = CM([15])          # vert. extension (for zero-length wires)
>>> e0h = CM([15, 15, 15])  # hori. extension (for zero-length wires)
>>> lv = CM([['M1', 'drawing']], dtype=object)  # layer information
>>> lh = CM([['M2', 'drawing']]*3, dtype=object)
>>> plv = CM([['M1', 'pin']], dtype=object) # pin layers
>>> plh = CM([['M2', 'pin']]*3, dtype=object)
>>> xcolor = CM([None], dtype=object)  # not multipatterned
>>> ycolor = CM([None]*3, dtype=object)
>>> primary_grid = 'horizontal'
>>> tvia = NativeInstanceTemplate(libname='tlib', cellname='via0')  # via
>>> viamap = CMA(elements=[[tvia, tvia, tvia]], dtype=object)
>>> g = laygo2.object.grid.RoutingGrid(name='mygrid', vgrid=gv, hgrid=gh,
                                       vwidth=wv, hwidth=wh,
                                       vextension=ev, hextension=eh,
                                       vlayer=lv, hlayer=lh,
                                       pin_vlayer=plv, pin_hlayer=plh,
                                       viamap=viamap, primary_grid=primary_grid,
                                       xcolor=xcolor, ycolor=ycolor,
                                       vextension0=e0v, hextension0=e0h)
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> #################
>>> # Route on grid #
>>> #################
>>> mn_list = [[0, -2], [0, 1], [2, 1], [5,1] ]
>>> route = dsn.route(grid=g, mn=mn_list,
                      via_tag=[True, None, True, True])
>>> # Display generated design.
>>> print(dsn)
<laygo2.object.database.Design object at 0x000001C71AE3A110>
    name: mycell, params: None
    elements: {
    'NoName_0': <laygo2.object.physical.Instance object at 0x000001C71AE3BA90>,
    'NoName_1': <laygo2.object.physical.Rect object at 0x000001C71AE3B820>,
    'NoName_2': <laygo2.object.physical.Rect object at 0x000001C71AE3ABF0>,
    'NoName_3': <laygo2.object.physical.Instance object at 0x000001C71AE3A140>,
    'NoName_4': <laygo2.object.physical.Rect object at 0x000001C71AE39DB0>,
    'NoName_5': <laygo2.object.physical.Instance object at 0x000001C71AE3AB60>}
    libname:genlib
    rects: {  # wires
    'NoName_1': <laygo2.object.physical.Rect object at 0x000001C71AE3B820>,
    'NoName_2': <laygo2.object.physical.Rect object at 0x000001C71AE3ABF0>,
    'NoName_4': <laygo2.object.physical.Rect object at 0x000001C71AE39DB0>}
    paths:{}
    pins:{}
    texts:{}
    instances:{  # vias
    'NoName_0': <laygo2.object.physical.Instance object at 0x000001C71AE3BA90>,
    'NoName_3': <laygo2.object.physical.Instance object at 0x000001C71AE3A140>,
    'NoName_5': <laygo2.object.physical.Instance object at 0x000001C71AE3AB60>}
    virtual instances:{}
_images/object_grid_RoutingGrid_route.png

See also

laygo2.object.grid.RoutingGrid.route

route wire(s) on the grid.

route_via_track(grid, mn, track, via_tag=[None, True])[source]#

Perform routing on the specified track with accessing wires to mn.

Parameters:
  • grid (laygo2.object.grid.RoutingGrid) – The placement grid where the wire is placed on.

  • mn (list(numpy.ndarray)) – list containing coordinates of the points being connected through a track

  • track (numpy.ndarray) – list containing coordinate values and direction of a track. Vertical tracks have [v, None] format, while horizontal tracks have [None, v] format (v is the coordinates of the track).

  • via_tag (list(Boolean), optional.) – The list containing switches deciding whether to place via at the edges of individual stubs.

Returns:

The list containing the generated routing objects; The last object corresponds to the routing object on the track.

Return type:

list

Example

>>> import laygo2
>>> from laygo2.object.grid import CircularMapping as CM
>>> from laygo2.object.grid import CircularMappingArray as CMA
>>> from laygo2.object.grid import OneDimGrid, RoutingGrid
>>> from laygo2.object.template import NativeInstanceTemplate
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Instance
>>> # Routing grid construction (not needed if laygo2_tech is set up).
>>> gv = OneDimGrid(name="gv", scope=[0, 50], elements=[0])
>>> gh = OneDimGrid(name="gv", scope=[0, 100], elements=[0, 40, 60])
>>> wv = CM([10])           # vertical (xgrid) width
>>> wh = CM([20, 10, 10])   # horizontal (ygrid) width
>>> ev = CM([10])           # vertical (xgrid) extension
>>> eh = CM([10, 10, 10])   # horizontal (ygrid) extension
>>> e0v = CM([15])          # vert. extension (for zero-length wires)
>>> e0h = CM([15, 15, 15])  # hori. extension (for zero-length wires)
>>> lv = CM([['M1', 'drawing']], dtype=object)  # layer information
>>> lh = CM([['M2', 'drawing']]*3, dtype=object)
>>> plv = CM([['M1', 'pin']], dtype=object) # pin layers
>>> plh = CM([['M2', 'pin']]*3, dtype=object)
>>> xcolor = CM([None], dtype=object)  # not multipatterned
>>> ycolor = CM([None]*3, dtype=object)
>>> primary_grid = 'horizontal'
>>> tvia = NativeInstanceTemplate(libname='tlib', cellname='via0')  # via
>>> viamap = CMA(elements=[[tvia, tvia, tvia]], dtype=object)
>>> g = laygo2.object.grid.RoutingGrid(name='mygrid', vgrid=gv, hgrid=gh,
                                       vwidth=wv, hwidth=wh,
                                       vextension=ev, hextension=eh,
                                       vlayer=lv, hlayer=lh,
                                       pin_vlayer=plv, pin_hlayer=plh,
                                       viamap=viamap, primary_grid=primary_grid,
                                       xcolor=xcolor, ycolor=ycolor,
                                       vextension0=e0v, hextension0=e0h)
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> # Do routing
>>> mn_list = [[0, -2], [1, 0], [2, 5], [3, 4], [4, 5], [5, 5]]
>>> track = dsn.route_via_track(grid=g, mn=mn_list, track=[None,0])
>>> # Display design
>>> print(dsn)
    <laygo2.object.database.Design object at 0x0000015A77C6BA60>
    name: mycell, params: None
    elements: {
    'NoName_0': <laygo2.object.physical.Rect object at 0x0000015A77C6B790>,
    'NoName_1': <laygo2.object.physical.Instance object at 0x0000015A77C6B820>,
    'NoName_2': <laygo2.object.physical.Instance object at 0x0000015A77C6B7C0>,
    'NoName_3': <laygo2.object.physical.Rect object at 0x0000015A77C6B760>,
    'NoName_4': <laygo2.object.physical.Instance object at 0x0000015A77C6A2F0>,
    'NoName_5': <laygo2.object.physical.Rect object at 0x0000015A77C6BA90>}
    libname:genlib
    rects:{
    'NoName_0': <laygo2.object.physical.Rect object at 0x0000015A77C6B790>,
    'NoName_3': <laygo2.object.physical.Rect object at 0x0000015A77C6B760>,
    'NoName_5': <laygo2.object.physical.Rect object at 0x0000015A77C6BA90>}
    paths:{}
    pins:{}
    texts:{}
    instances:{
    'NoName_1': <laygo2.object.physical.Instance object at 0x0000015A77C6B820>,
    'NoName_2': <laygo2.object.physical.Instance object at 0x0000015A77C6B7C0>,
    'NoName_4': <laygo2.object.physical.Instance object at 0x0000015A77C6A2F0>}
    virtual instances:{}
>>> print(track[-1])
    <laygo2.object.physical.Rect object at 0x0000015A77C6BA90>
    name: None,
    class: Rect,
    xy: [[0, 0], [100, 0]],
    params: None, , layer: ['M2' 'drawing'], netname: None
_images/object_grid_RoutingGrid_route_via_track.png
set_cellname(val)[source]#
set_i(val)[source]#
set_libname(val)[source]#
set_p(val)[source]#
set_r(val)[source]#
set_vi(val)[source]#
summarize()[source]#

Get object information summary.

via(grid, mn, params=None)[source]#

Create Via object(s) on abstract grid.

Parameters:

mn (list(numpy.ndarray)) – Abstract coordinate(s) that specify location(s) to insert via(s).

Returns:

The list containing the generated via objects.

Return type:

list(physical.PhysicalObject)

Example

>>> import laygo2
>>> from laygo2.object.grid import CircularMapping as CM
>>> from laygo2.object.grid import CircularMappingArray as CMA
>>> from laygo2.object.grid import OneDimGrid, RoutingGrid
>>> from laygo2.object.template import NativeInstanceTemplate
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Instance
>>> # Routing grid construction (not needed if laygo2_tech is set up).
>>> gv = OneDimGrid(name="gv", scope=[0, 50], elements=[0])
>>> gh = OneDimGrid(name="gv", scope=[0, 100], elements=[0, 40, 60])
>>> wv = CM([10])           # vertical (xgrid) width
>>> wh = CM([20, 10, 10])   # horizontal (ygrid) width
>>> ev = CM([10])           # vertical (xgrid) extension
>>> eh = CM([10, 10, 10])   # horizontal (ygrid) extension
>>> e0v = CM([15])          # vert. extension (for zero-length wires)
>>> e0h = CM([15, 15, 15])  # hori. extension (for zero-length wires)
>>> lv = CM([['M1', 'drawing']], dtype=object)  # layer information
>>> lh = CM([['M2', 'drawing']]*3, dtype=object)
>>> plv = CM([['M1', 'pin']], dtype=object) # pin layers
>>> plh = CM([['M2', 'pin']]*3, dtype=object)
>>> xcolor = CM([None], dtype=object)  # Not multipatterned
>>> ycolor = CM([None]*3, dtype=object)
>>> primary_grid = 'horizontal'
>>> tvia = NativeInstanceTemplate(libname='tlib', cellname='via0')
>>> viamap = CMA(elements=[[tvia, tvia, tvia]], dtype=object)
>>> g = laygo2.object.grid.RoutingGrid(name='mygrid', vgrid=gv, hgrid=gh,
                                       vwidth=wv, hwidth=wh,
                                       vextension=ev, hextension=eh,
                                       vlayer=lv, hlayer=lh,
                                       pin_vlayer=plv, pin_hlayer=plh,
                                       viamap=viamap, primary_grid=primary_grid,
                                       xcolor=xcolor, ycolor=ycolor,
                                       vextension0=e0v, hextension0=e0h)
>>> # Create a design
>>> dsn = Design(name="mycell", libname="genlib")
>>> ##############
>>> # Place vias #
>>> ##############
>>> mn_list = [[0, -2], [1, 0], [2, 5]]
>>> via = dsn.via(grid=g, mn=mn_list)
>>> # Display generated design.
>>> print(dsn)
<laygo2.object.database.Design object at 0x0000015A77C6A110>
name: mycell, params: None,
elements: {
'NoName_0': <laygo2.object.physical.Instance object at 0x0000015A77C6AC20>,
'NoName_1': <laygo2.object.physical.Instance object at 0x0000015A77C6AD10>,
'NoName_2': <laygo2.object.physical.Instance object at 0x0000015A77C6AD40>}
libname:genlib
rects:{}
paths:{}
pins:{}
texts:{}
instances:{
'NoName_0': <laygo2.object.physical.Instance object at 0x0000015A77C6AC20>,
'NoName_1': <laygo2.object.physical.Instance object at 0x0000015A77C6AD10>,
'NoName_2': <laygo2.object.physical.Instance object at 0x0000015A77C6AD40>}
virtual instances:{}
_images/object_grid_RoutingGrid_via.png
property bbox#

Get design bounding box by taking union of instances’ bounding boxes.

property cellname#

Design object’s cell name.

Example

>>> import laygo2
>>> dsn = laygo2.object.database.Design(name="dsn", libname="testlib")
>>> print(dsn.cellname)
“dsn”
Type:

str

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:

dict

property i#

Alias of instances.

Type:

str

instances = None#

Dictionary containing Instance objects affiliated with Design object.

Example

>>> import laygo2
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Rect, Pin, Instance, Text
>>> dsn = Design(name="dsn", libname="testlib")
>>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0])
>>> dsn.append(i0)
>>> print(dsn.instances)
{'I0': <laygo2.object.physical.Instance object>}
Type:

dict

property libname#

Design object’s library name.

Example

>>> import laygo2
>>> dsn = laygo2.object.database.Design(name="dsn", libname="testlib")
>>> print(dsn.libname)
“testlib”
Type:

str

name = None#

Name of BaseDatabase object.

Example

>>> import laygo2
>>> base = laygo2.object.database.BaseDatabase(name="mycell")
>>> base.name
"mycell"
Type:

str

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:

int

property p#

Alias of pins.

Type:

str

params = None#

BaseDatabase object’s parameter dictionary.

Example

>>> import laygo2
>>> base = laygo2.object.database.BaseDatabase(name="mycell",
               params={'ivdd': 0.001})
>>> base.params
{'ivdd': 0.001}
Type:

dict or None

paths = None#
pins = None#

Dictionary having the collection of Pin objects affiliated with the Design object.

Example

>>> import laygo2
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Rect, Pin, Instance, Text
>>> dsn = Design(name="dsn", libname="testlib")
>>> p0 = Pin(xy=[[0, 0], [50, 50]], layer=["M1", "pin"], name="P")
>>> dsn.append(p0)
>>> print(dsn.pins)
{'NoName_0': <laygo2.object.physical.Pin object>}
Type:

dict

property r#

Alias of rects.

Type:

str

rects = None#

Dictionary containing Rectangle object affiliated with the Design object.

Example

>>> import laygo2
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Rect, Pin, Instance, Text
>>> dsn = Design(name="dsn", libname="testlib")
>>> r0 = Rect(xy=[[0, 0], [100, 100]], layer=["M1", "drawing"])
>>> dsn.append(r0)
>>> print(dsn.rects)
{'R0': <laygo2.object.physical.Rect object>}
Type:

dict

texts = None#

Dictionary containing Text objects affiliated with Design object.

Example

>>> import laygo2
>>> from laygo2.object.database import Design
>>> from laygo2.object.physical import Rect, Pin, Instance, Text
>>> dsn = Design(name="dsn", libname="testlib")
>>> t0 = Text(xy=[[50, 50], [100, 100]], layer=["text", "drawing"], text="T")
>>> dsn.append(t0)
>>> print(dsn.texts)
{'NoName_1': <laygo2.object.physical.Text object>}
Type:

dict

property vi#

Alias of virtual_instances.

Type:

str

virtual_instances = None#

Dictionary containing VirtualInstance objects affiliated with Design object.

See also

instances

Type:

dict