PlacementGrid class#

class laygo2.object.grid.PlacementGrid(name, vgrid, hgrid)[source]#

Bases: Grid

PlacementGrid class implements a grid for placement of Instance and VirtualInstance objects.

Public Data Attributes:

type

Type of grid.

Inherited from Grid

name

the name of the grid.

vgrid

hgrid

elements

return elements of subgrids ([_xy[0].elements, _xy[1].elements]).

phy2abs

PhyToAbsGridConverter(master=self)

abs2phy

AbsToPhyGridConverter(master=self)

xy

Two-dimensional _AbsToPhyConverter of a coordinate system.

x

One-dimensional _AbsToPhyGridConverter

y

One-dimensional _AbsToPhyGridConverter of the y-coordinate system.

v

OneDimGrid of the x-coordinate system (=self.x).

h

OneDimGrid of the y-coordinate system (=self.y).

mn

Two-dimensional _PhyToAbsConverter of a coordinate system.

m

One-dimensional _PhyToAbsConverter of the x-coordinate system.

n

One-dimensional _PhyToAbsConverter of

shape

Two-dimensional element length in a coordinate system.

range

width

Width of the region in which the coordinate system is defined.

height

Height of the region in which the coordinate system is defined.

height_vec

Return the height vector [0, h].

width_vec

Return width as a list.

Public Methods:

place(inst, mn)

Place the instance on the specified coordinate mn, on this grid.

Inherited from Grid

get_range()

set_range(value)

__init__(name, vgrid, hgrid)

Constructor function of Grid class.

__call__(other)

Call self as a function.

__getitem__(pos)

__eq__(other)

Return the physical grid coordinate that matches to other.

__lt__(other)

Return the index of the grid coordinate that is the largest but less than other.

__le__(other)

Return the index of the grid coordinate that is the largest but less than or equal to other.

__gt__(other)

Return the index of the grid coordinate that is the smallest but greater than other.

__ge__(other)

Return the index of the grid coordinate that is the smallest but greater than or equal to other.

bbox(obj)

Return the abstract grid coordinates corresponding to the 'internal' bounding box of obj.

bottom_left(obj)

Return the abstract grid coordinates corresponding to the bottom-left corner of obj.

bottom_right(obj)

Return the abstract grid coordinates corresponding to the bottom-right corner of obj.

top_left(obj)

Return the abstract grid coordinates corresponding to the top-left corner of obj.

top_right(obj)

Return the abstract grid coordinates corresponding to the top-right corner of obj.

crossing(*args)

Return the abstract grid coordinates corresponding to the crossing point of args.

overlap(*args[, type])

Return the abstract grid coordinates corresponding to the overlap of args.

union(*args)

Return the abstract grid coordinates corresponding to union of args.

center(obj)

Return the abstract grid coordinates corresponding to the center point of obj.

left(obj)

Return the abstract grid coordinates corresponding to the left point of obj.

right(obj)

Return the abstract grid coordinates corresponding to the right point of obj.

top(obj)

Return the abstract grid coordinates corresponding to the top point of obj.

bottom(obj)

Return the abstract grid coordinates corresponding to the bottom point of obj.

copy()

Make a copy of the current Grid object

vflip([copy])

Flip the grid in vertical direction.

hflip([copy])

Flip the grid in horizontal direction.

vstack(obj[, copy])

Stack grid(s) on top of the current grid in vertical direction.

hstack(obj[, copy])

Stack grid(s) on top of the current grid in horizontal direction.

__iter__()

__next__()

__str__()

Return the string representation of the object.

summarize()

Output the information of the respective grid.


__init__(name, vgrid, hgrid)#

Constructor function of Grid class.

Parameters:
  • name (str)

  • vgrid (laygo2.object.grid.OndDimGrid) – OneDimGrid object of the x-coordinate system

  • hgrid (laygo2.object.grid.OndDimGrid) – OneDimGrid object of the y-coordinate system

Return type:

laygo2.object.grid.Grid

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> print(g2)
<laygo2.object.grid.Grid object> name: test, class: Grid, scope: [[0, 0], [100, 100]], elements: [array([ 0, 10, 20, 40, 50]), array([10, 20, 40, 50, 60])
_get_hgrid()#
_get_vgrid()#
_set_hgrid(value)#
_set_vgrid(value)#
bbox(obj)#

Return the abstract grid coordinates corresponding to the ‘internal’ bounding box of obj.

See also

_PhyToAbsGridConverter.bbox

bottom(obj)#

Return the abstract grid coordinates corresponding to the bottom point of obj.

bottom_left(obj)#

Return the abstract grid coordinates corresponding to the bottom-left corner of obj.

See also

_PhyToAbsGridConverter.bottom_left

bottom_right(obj)#

Return the abstract grid coordinates corresponding to the bottom-right corner of obj.

See also

_PhyToAbsGridConverter.bottom_right

center(obj)#

Return the abstract grid coordinates corresponding to the center point of obj.

Parameters:

obj (laygo2.object.physical.PhysicalObject) – The object of which center coordinate is computed.

See also

laygo2.object.grid._PhyToAbsGridConverter.center

copy()#

Make a copy of the current Grid object

Returns:

laygo2.object.grid.Grid

Return type:

the copied Grid object.

crossing(*args)#

Return the abstract grid coordinates corresponding to the crossing point of args.

See also

laygo2.object.grid._PhyToAbsGridConverter.crossing

get_range()#
hflip(copy=True)#

Flip the grid in horizontal direction.

Parameters:

copy (optional, boolean) – If True, make a copy and flip the copied grid (default). If False, flip the current grid object.

Returns:

laygo2.object.grid.Grid

Return type:

the flipped Grid object.

hstack(obj, copy=True)#

Stack grid(s) on top of the current grid in horizontal direction.

left(obj)#

Return the abstract grid coordinates corresponding to the left point of obj.

overlap(*args, type='bbox')#

Return the abstract grid coordinates corresponding to the overlap of args.

See also

laygo2.object.grid._PhyToAbsGridConverter.overlap

place(inst, mn)[source]#

Place the instance on the specified coordinate mn, on this grid.

Parameters:
Returns:

  • laygo2.object.physical.Instance or

  • laygo2.object.physical.VirtualInstance – The placed instance.

Example

>>> import laygo2
>>> from laygo2.object.grid import OneDimGrid, PlacementGrid
>>> 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 an instance
>>> #
>>> i0 = Instance(libname="tlib", cellname="t0", name="I0", xy=[0, 0])
>>> print(inst0.xy)
[100, 100]
>>> #
>>> # Place the created instance
>>> #
>>> g.place(inst=i0, mn=[10,10])
>>> # Print parameters of the placed instance.
>>> print(i0.xy)
[200, 1000]
right(obj)#

Return the abstract grid coordinates corresponding to the right point of obj.

set_range(value)#
summarize()#

Output the information of the respective grid.

Parameters:

None

Return type:

str

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.summarize()
<laygo2.object.grid.Grid object> name: test, class: Grid, scope: [[0, 0], [100, 100]], elements: [array([ 0, 10, 20, 40, 50]), array([10, 20, 40, 50, 60])
top(obj)#

Return the abstract grid coordinates corresponding to the top point of obj.

top_left(obj)#

Return the abstract grid coordinates corresponding to the top-left corner of obj.

See also

_PhyToAbsGridConverter.top_left

top_right(obj)#

Return the abstract grid coordinates corresponding to the top-right corner of obj.

See also

_PhyToAbsGridConverter.top_right

union(*args)#

Return the abstract grid coordinates corresponding to union of args.

See also

laygo2.object.grid._PhyToAbsGridConverter.union

vflip(copy=True)#

Flip the grid in vertical direction.

Parameters:

copy (optional, boolean) – If True, make a copy and flip the copied grid (default). If False, flip the current grid object.

Returns:

laygo2.object.grid.Grid

Return type:

the flipped Grid object.

vstack(obj, copy=True)#

Stack grid(s) on top of the current grid in vertical direction.

_xy = None#

the list contains the 1d-grid objects for x and y axes.

Type:

List[OneDimGrid]

abs2phy = None#

AbsToPhyGridConverter(master=self)

property elements#

return elements of subgrids ([_xy[0].elements, _xy[1].elements]).

Type:

list

property h#

OneDimGrid of the y-coordinate system (=self.y).

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.h
g1_y
Type:

OneDimGrid

property height#

Height of the region in which the coordinate system is defined.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.height
100
Type:

numpy.int32

property height_vec#

Return the height vector [0, h].

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.height_vec
[0, 100]
Type:

numpy.ndarray

property hgrid#
property m#

One-dimensional _PhyToAbsConverter of the x-coordinate system.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.n[40]
2
>>> g2.n(40)
2
>>> g2.n <  40
760
>>> g2.n <= 40
810
>>> g2.n >  40
820
>>> g2.n >= 40
810
Type:

_PhyToAbsGridConverter

property mn#

Two-dimensional _PhyToAbsConverter of a coordinate system.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.mn[40,40]
[3, 2]
>>> g2.mn([40, 40])
[3, 2]
>>> g2.mn <  [40,40]
[750, 760]
>>> g2.mn <= [40,40]
[800, 810]
>>> g2.mn >  [40,40]
[810, 820]
>>> g2.mn >= [40,40]
[800, 810]
Type:

laygo2._PhyToAbsGridConverter

property n#
One-dimensional _PhyToAbsConverter of

the y-coordinate system.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.n[40]
2
>>> g2.n(40)
2
>>> g2.n <  40
760
>>> g2.n <= 40
810
>>> g2.n >  40
820
>>> g2.n >= 40
810
Type:

_PhyToAbsGridConverter

name = None#

the name of the grid.

Type:

str

phy2abs = None#

PhyToAbsGridConverter(master=self)

property range#
property shape#
Two-dimensional element length in a coordinate system.

length of x-axis elements, length of y-axis elements

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.shape
[5, 5]
Type:

numpy.ndarray

type = 'placement'#

Type of grid. Should be ‘placement’ for placement grids.

property v#

OneDimGrid of the x-coordinate system (=self.x).

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.v
g1_x
Type:

OneDimGrid

property vgrid#
property width#
Width of the region in which the coordinate system is defined.

x scope

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.width
100
Type:

numpy.int32

property width_vec#
Return width as a list.

length of the respective axis and zero

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.width_vec
[100, 0]
Type:

numpy.ndarray

property x#
One-dimensional _AbsToPhyGridConverter

of the x-coordinate system.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.x[10]
200
>>> g2.x <  10
[0]
>>> g2.x <= 10
[1]
>>> g2.x >  10
[2]
>>> g2.x >= 10
[1]
Type:

_AbsToPhyGridConverter

property xy#

Two-dimensional _AbsToPhyConverter of a coordinate system.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.xy[10,10]
[200 210]
>>> g2.xy([10, 10])
[200 210]
>>> g2.xy < [10,10]
[0,-1]
>>> g2.xy <= [10,10]
[1,0]
>>> g2.xy > [10,10]
[2,1]
>>> g2.xy >= [10,10]
[1,0]
Type:

_AbsToPhyGridConverter

property y#

One-dimensional _AbsToPhyGridConverter of the y-coordinate system.

Example

>>> from laygo2.object.grid import OneDimGrid, Grid
>>> g1_x = OneDimGrid(name='xgrid', scope=[0, 100], elements=[0, 10, 20, 40, 50 ])
>>> g1_y = OneDimGrid(name='ygrid', scope=[0, 100], elements=[10, 20, 40, 50, 60 ])
>>> g2   = Grid(name="test", vgrid = g1_x, hgrid = g1_y )
>>> g2.y[10]
210
>>> g2.y <  10
[-1]
>>> g2.y <= 10
[0]
>>> g2.y >  10
[1]
>>> g2.y >= 10
[0]
Type:

_AbsToPhyGridConverter