laygo package

Subpackages

Submodules

laygo.BaseLayoutGenerator module

The BaseLayoutGenerator module implements classes to generate full-custom layout on physical grid. It allows designers to describe layout generation scripts in Python language and automate the layout process. BaseLayoutGenerator is not capable of handling any abstracted grid/template parameters, so all parameters should be given in real numbers

Example

For layout export, type below command in ipython console.

$ run laygo/labs/lab1_a_baselayoutgenerator_export.py
class laygo.BaseLayoutGenerator.BaseLayoutGenerator(res=0.005)[source]

Bases: object

The BaseLayoutGenerator class implements functions and variables for full-custom layout generations on physical grids.

res : float
physical grid resolution
use_array = False

boolean: True if InstanceArray is used instead of Instance. For GridLayoutGenerator2 only

res

float: physical resolution

db = {}

laygo.LayoutDB.LayoutDB: layout database

display(libname=None, cellname=None)[source]

Display DB information.

libname : str, optional
library name
cellname : str, optional
cell name
add_library(name, select=True)[source]

Create a library to work on.

name : str
library name
select : bool, optional
if True, automatically select the library to work on after creation
add_cell(name, libname=None, select=True)[source]

Create a cell to work on.

name : str
cellname
libname : str, optional
library name. If None, current selected library name is used.
select : bool, optional
if True, automatically select the cell to work on after creation.
sel_library(name)[source]

Select a library to work on.

libname : str
library name
sel_cell(cellname)[source]

Select a cell to work on.

cellname : str
cell name
add_rect(name, xy, layer, netname=None)[source]

Add a rect to selected region.

name : str
rect name
xy : np.array([[float, float], [float, float]])
xy coordinates
layer : [str, str]
layer name an purpose
laygo.LayoutObject.Rect
created Rect object
add_pin(name, netname, xy, layer)[source]

Add a pin to specified region.

name : str
pin object name
netname : str
net name
xy : np.array([[float, float], [float, float]])
xy coordinates
layer : [str, str]
layer name and purpose
laygo.LayoutObject.Pin
created Pin object
add_text(name, text, xy, layer)[source]

Add a text to specified coordinate.

name : str
pin object name
text : str
text string
xy : [float, float]
xy coordinate
layer : [layername, purpose]
layer name an purpose
laygo.LayoutObject.Text
created Text object
add_inst(name, libname, cellname, xy=None, shape=None, spacing=array([0, 0]), transform='R0', template=None)[source]

Add an instance to specified coordinate.

name : str
instance name
libname : str
cell library name (not output library name)
cellname : str
cellname
xy : np.array([float, float])
xy coordinate
shape : np.array([x0, y0]) or None
array shape parameter. If None, the instance is not considered as array
spacing : np.array([x0, y0])
array spacing parameter
transform : str
transform parameter
template : laygo.TemplateObject.TemplateObject
template handle
laygo.LayoutObject.Instance
created Instance object
get_rect(name, libname=None)[source]

Get the handle of specified rect object.

name : str
rect name
libname : str
libname. if None, self.db._plib is used
laygo.LayoutObject.Rect
Rect object pointer
get_inst(name=None, libname=None, index=array([0, 0]))[source]

Get the handle of specified instance object.

name : str, optional
instance name, if None, all instances are returned.
libname : str, optional
libname. if None, self.db._plib is used.
laygo.LayoutObject.Instance
Instance object pointer
get_pin(name, libname=None)[source]

Get the handle of speficied pin object.

name : str
pin name
libname : str, optional
libname. if None, self.db._plib is used.
laygo.LayoutObject.Pin
Pin object pointer
export_GDS(filename, libname=None, cellname=None, layermapfile='default.layermap', physical_unit=1e-09, logical_unit=0.001, pin_label_height=0.0001, text_height=0.0001, annotate_layer=['text', 'drawing'], annotate_height=0.01)[source]

Export specified cell(s) to a GDS file.

filename : str
output filename
layermapfile : str
layermap filename
physical_unit : float
physical unit for GDS export
logical_unit : float
logical unit for GDS export
pin_label_height : float
pin label height
text_height : float
text height
export_BAG(prj, libname=None, cellname=None, array_delimiter=['[', ']'], via_tech='cdsDefTechLib')[source]

Export specified cell(s) to BagProject object.

db : laygo.LayoutDB.LayoutDB
Layout db object
libname : str
name of library to be exported
cellname : list or str
name of cells to be exported
prj : BagProject
bag object to export
array_delimiter : list or str
array delimiter for multiple placements.
via_tech : str
via technology entry for BagProject. Not being used currently because instances are used for via connections.
import_GDS(filename, layermapfile='default.layermap', instance_libname=None, append=True)[source]

Import layout database from gds file.

filename : gds filename layermapfile : layermap filename instance_libname : library name of instantiated structure

laygo.LayoutDB.LayoutDB
Imported layout database
import_BAG(prj, libname, cellname=None, yamlfile='import_BAG_scratch.yaml', append=True)[source]

Import layout database from BagProject object.

prj : BagProject
bag object to export
libname : str
name of library to be exported
cellname : list or str
name of cells to be exported
yamlfile : str
scratch yaml file path
laygo.LayoutDB.LayoutDB
Imported layout database

laygo.GDSIO module

The GDSIO module implements classes and functions to export/import full-custom layout in GDSII format. Implemented by Eric Jan

Example

Refer to the bottom part of GDSIO.py for example.

class laygo.GDSIO.Library(version, name, physicalUnit, logicalUnit)[source]

Bases: object

export(stream)[source]

Export to stream

stream : stream
file stream to be written
add_structure(name)[source]

Add a structure object to library

name : str
name of structure
laygo.GDSIO.Structure
created structure object
add_boundary(strname, layer, dataType, points)[source]

Add a boundary object to specified structure

strname : str
structure name to insert the boundary object
layer : int
layer name of the boundary object
dataType : int
layer purpose of the boundary object
points : 2xn integer array list
point array of the boundary object ex) [[x0, y0], [x1, x1], …, [xn-1, yn-1], [x0, y0]]
laygo.GDSIO.Boundary
created boundary object
add_instance(strname, cellname, xy, transform='R0')[source]

Add an instance object to specified structure

strname : str
structure name to insert the instance
cellname : str
instance cellname
xy : [int, int]
instance cooridnate
transform : str
transform parameter
laygo.GDSIO.Instance
created instance object
add_instance_array(strname, cellname, n_col, n_row, xy, transform='R0')[source]

Add an instance array to specified structure

strname : str
structure name to insert the instance
cellname : str
instance cellname
n_col : int
number of columns
n_row : int
number of rows
xy : [int, int]
instance coordinate
transform : str
transform parameter
laygo.GDSIO.InstanceArray
instance array object
add_text(strname, layer, textType, xy, string, textHeight=100)[source]

Add a text object to specified structure

strname : str
structure name to insert the text object
layer : int
layer name of the text object
textType : int
layer purpose of the text object
xy : [int, int]
text coordinate
string : str
text string
textHeight : int
text height
laygo.GDSIO.Text
text object
class laygo.GDSIO.Structure(name)[source]

Bases: list

export(stream)[source]

Export to stream

stream : stream
file stream to be written
add_boundary(layer, dataType, points)[source]

Add a boundary object to structure

layer : int
layer name
dataType : int
layer purpose
points : list
layer coordinates

add_boundary(‘test’, 50, 0, [[1000, 1000], [1000, 0], [0, 0], [0, 1000], [1000, 1000]])

laygo.GDSIO.Boundary
generated boundary object
add_instance(cellname, xy, transform='R0')[source]

Add an instance object to structure

cellname : str
cell name
xy : [int, int]
xy coordinate
transform : str
transform parameter
laygo.GDSIO.Instance
generated instance object
add_instance_array(cellname, n_col, n_row, xy, transform='R0')[source]

Add an instance array object to structure

cellname : str
cell name
n_col : int
number of columns
n_row : int
number of rows
xy : [int, int]
xy coordinate
transform : str
transform parameter

new_lib.add_instance_array(‘test2’, ‘test’, 2, 3, [[3000, 3000], [3000 + 2 * 2000, 3000], [3000, 3000 + 3 * 3000]])

laygo.GDSIO.InstanceArray
generated instance array object
add_text(layer, textType, xy, string, textHeight=100)[source]

Add a text object to structure

layer : int
layer name
textType : int
layer purpose
xy : list
xy coordinate
string : str
text string
textHeight : int
text height
laygo.GDSIO.Text
generated text object
class laygo.GDSIO.Element[source]

Bases: object

Base class for GDSIO objects

possible_transform_parameters = {'MX': (32768, 0), 'MY': (32768, 180), 'R0': (None, None), 'R180': (0, 180), 'R270': (0, 270), 'R90': (0, 90)}

dict: transform parameter dictionary

set_transform_parameters(transform)[source]

initialize transform parameters

transform : str
transform parameter, ‘R0’ : default, no transform, ‘R90’ : rotate by 90-degree, ‘R180’ : rotate by 180-degree, ‘R270’ : rotate by 270-degree, ‘MX’ : mirror across X axis, ‘MY’ : mirror across Y axis
class laygo.GDSIO.Boundary(layer, dataType, points)[source]

Bases: laygo.GDSIO.Element

Boundary object for GDSIO

export(stream)[source]

Export to stream

stream : stream
File stream to be written
class laygo.GDSIO.Instance(sname, xy, transform='R0')[source]

Bases: laygo.GDSIO.Element

Instance object for GDSIO

export(stream)[source]

Export to stream

stream : stream
File stream to be written
class laygo.GDSIO.InstanceArray(sname, n_col, n_row, xy, transform='R0')[source]

Bases: laygo.GDSIO.Element

InstanceArray object for GDSIO

export(stream)[source]

Export to stream

stream : stream
File stream to be written
class laygo.GDSIO.Text(layer, textType, xy, string, textHeight=100)[source]

Bases: laygo.GDSIO.Element

Text object for GDSIO

export(stream)[source]

Export to stream

stream : stream
File stream to be written

laygo.GDSIOHelper module

GDSII IO Helper functions. Implemented by Eric Jan

laygo.GDSIOHelper.pack_data(tag, data)[source]

data packing function

laygo.GDSIOHelper.pack_bgn(tag)[source]

pack for begin statement

laygo.GDSIOHelper.pack_no_data(tag)[source]

pack for no data entry

laygo.GDSIOHelper.pack_optional(tag, data, stream)[source]

optional packing function

laygo.GDSIOHelper.readout(stream)[source]

gds import function to construct a dictionary

laygo.GridDB module

The GridDB module/class implements grid database management functions for GridBaseLayoutGenerator module.

class laygo.GridDB.GridDB[source]

Bases: dict

layout grid database management class

plib = None

str: current library handle

grids = None

dict: grid dictionary

display(libname=None, gridname=None)[source]

Display grid database information

libname : str, optional
library name. If None, display all libraries.
gridname : str, optional
grid name. If None, display all grids.
export_yaml(filename, libname=None)[source]

Export the grid database to a yaml file. The exported file will be used to generate actual layouts.

filename : str
filename
libname : str
library name
import_yaml(filename, libname=None)[source]

Import grid database from an external file. Parameters ———- filename : str

file name to be loaded.
libname : str, optional
library name to be imported.
merge(db)[source]

Merge a GridDB object to self.db, which is the database GridLayoutGenerator is looking at. Used when importing an external file (which could be either written manually or generated from laygo & exported by calling the GridDB.export_yaml function.

db : GridDB.GridDB
Grid database to be merged.
add_library(name)[source]

Add a library to the design dictionary.

name : str
library name
add_placement_grid(name, libname=None, xy=array([0, 0]))[source]

Add a placement grid to the specified library.

name : str
name of the placement grid.
libname :
library name (if None, self.plib is used)
add_route_grid(name, libname=None, xy=array([0, 0]), xgrid=array([], dtype=float64), ygrid=array([], dtype=float64), xwidth=array([], dtype=float64), ywidth=array([], dtype=float64), xlayer=[], ylayer=[], viamap=None)[source]

Add a route grid to the specified library.

name : str
name of the route grid.
libname :
library name (if None, self.plib is used).
sel_library(libname)[source]

Select a library to work on.

libname : str
library name
get_grid(gridname)[source]

Grid object access function

gridname : str
name of the grid
GridObject.GridObject
Grid object handle
get_absgrid_coord_x(gridname, x)[source]

deprecated - use the get_absgrid_x function instead

get_absgrid_x(gridname, x)[source]

convert a x-coordinate value on the physical grid to a corresponding value on the specified grid. Parameters ———- gridname : str

abstract grid name
x : float
x coordinate value to be converted
int
x coordinate on gridname
get_absgrid_coord_y(gridname, y)[source]

deprecated - use the get_absgrid_y function instead

get_absgrid_y(gridname, y)[source]

convert a y-coordinate value on the physical grid to a corresponding value on the specified grid.

gridname : str
abstract grid name
y : float
y coordinate value to be converted
int
y coordinate on gridname
get_absgrid_coord_xy(gridname, xy)[source]

deprecated - use the get_absgrid_xy function instead

get_absgrid_xy(gridname, xy)[source]

convert a xy coordinate on the physical grid to a corresponding coordinate on the specified grid.

gridname : str
abstract grid name
xy : np.array([float, float])
xy coordinate value to be converted
np.array([int, int])
xy coordinate on gridname
get_absgrid_coord_region(gridname, xy0, xy1)[source]

deprecated - use the get_absgrid_region function instead

get_absgrid_region(gridname, xy0, xy1)[source]

convert a region on the physical grid to a corresponding region on the specified grid.

gridname : str
abstract grid name
xy0 : np.array([float, float])
lower left corner in physical grid
xy1 : np.array([float, float])
upper right corner in physical grid
np.array([[int, int], [int, int]])
region on the specified grid
get_phygrid_coord_x(gridname, x)[source]

deprecated - use the get_phygrid_x function instead

get_phygrid_x(gridname, x)[source]

convert a x coordinate on the abstract grid, specified by gridname, to a corresponding value on the physical grid.

gridname : str
abstract grid name
x : int
x coordinate value to be converted
float
x coordinate on the physical grid
get_phygrid_coord_y(gridname, y)[source]

deprecated - use the get_phygrid_y function instead

get_phygrid_y(gridname, y)[source]

convert a y coordinate on the abstract grid, specified by gridname, to a corresponding value on the physical grid.

gridname : str
abstract grid name
y : int
y coordinate value to be converted
float
y coordinate on the physical grid
get_phygrid_coord_xy(gridname, xy)[source]

deprecated - use the get_phygrid_xy function instead

get_phygrid_xy(gridname, xy)[source]

convert a xy coordinate on the abstract grid, specified by gridname, to a corresponding coordinate on the physical grid.

gridname : str
abstract grid name
xy : np.array([int, int])
xy coordinate value to be converted
np.array([float, float])
xy coordinate on the physical grid
get_route_width_xy(gridname, xy)[source]

return the width of routing wires passing xy on gridname.

gridname : str
abstract grid name
xy : np.array([int, int])
xy coordinate to get the width parameters
np.array([float, float])
width parameters on xy (xgrid(vertical), ygrid(horizontal))
get_route_layer_xy(gridname, xy)[source]

return the layers of routing wires passing xy on gridname.

gridname : str
abstract grid name
xy : np.array([int, int])
xy coordinate to get the layer information
list([[str, str], [str, str]])
layer parameters on xy coordinate (xlayer, ylayer)
get_route_xlayer_xy(gridname, xy)[source]

return the layer of vertical routing wires passing xy on gridname.

gridname : str
abstract grid name
xy : np.array([int, int])
xy coordinate to get the layer information
list([str, str])
layer parameters of xgrid on xy coordinate
get_route_ylayer_xy(gridname, xy)[source]

return the layer of horizontal routing wires passing xy on gridname.

gridname : str
abstract grid name
xy : np.array([int, int])
xy coordinate to get the layer information
list([str, str])
layer parameters of ygrid on xy coordinate
get_vianame(gridname, xy)[source]
gridname : str
abstract grid name
xy : np.array([int, int])
xy coordinate to get the layer information
str
name of via that can be placed on xy, on abstract grid specified by gridname
update_viamap(gridname, viamap)[source]

Update viamap of specified grid (used for constructgrid function) Parameters ———- gridname : str

abstract grid name
viamap : dict
dictionary that contains viamap parameters

laygo.GridLayoutGenerator module

The GridLayoutGenerator module implements classes to generate full-custom layout on ‘abstract’ grid. It allows designers to describe layout generation scripts in Python language and automate the layout process, abstracting design rules for easier implementation and process portability. All numerical parameters are given in integer numbers and they are converted to physical numbers internally and designers don’t need to deal with complex design rules in modern CMOS process. Example ——- For layout export, type below command in ipython console.

$ run laygo/labs/lab2_b_gridlayoutgenerator_layoutexercise.py
class laygo.GridLayoutGenerator.GridLayoutGenerator(physical_res=0.005, config_file=None)[source]

Bases: laygo.BaseLayoutGenerator.BaseLayoutGenerator

The GridLayoutGenerator class implements functions and variables for full-custom layout generations on abstract grids. Parameters ———- physical_res : float

physical grid resolution
config_file : str
laygo configuration file path
templates : laygo.TemplateDB.TemplateDB
template database
grids : laygo.GridDB.GridDB
grid database
layers: dict
layer dictionary. metal, pin, text, prbnd are used as keys
use_phantom = False

bool: true if phantom cells are exported (not real cells)

layers = {'metal': [], 'pin': [], 'prbnd': [], 'text': []}

dict: layer dictionary. Keys are metal, pin, text, prbnd

templates = None

laygo.TemplateDB.TemplateDB: template database

grids = None

laygo.GridDB.GridDB: grid database

place(name, templatename, gridname, xy, template_libname=None, shape=array([1, 1]), spacing=None, offset=array([0, 0]), transform='R0', annotate_text=None, libname=None)[source]

Place an instance on abstract grid. Use relplace instead Parameters ———- name : str

Name of the instance.
templatename : str
Name of the template for the instance.
gridname : str
Grid name for the instance placement.
xy : np.array([int, int]) or [int, int]
Placement coordinate on the grid, specified by gridname.
libname : str, optional
Template library name. If not specified, self.templates.plib is used.
shape : np.array([x0, y0]) or None, optional
array shape parameter. If None, the instance is not considered as array. Default is None
transform : str (‘R0’, ‘MX’, ‘MY’), optional
Transform parameter
laygo.layoutObject.Instance
generated instance
template_libname: str, optional, deprecated
Replaced with libname
spacing : np.array([int, int]), optional
Array spacing parameter for the instance. If None, the size of the instance of is used.
offset : np.array([float, float]), optional
Offset in physical coordinate.
annotate_text : str, optional
text to be annotated. Use None if no annotation is required
relplace(name=None, templatename=None, gridname=None, refinstname=None, direction='right', xy=array([0, 0]), offset=array([0, 0]), template_libname=None, shape=None, spacing=None, transform='R0', refobj=None, libname=None, cellname=None)[source]

Place an instance on abstract grid, bound from a reference object. If reference object is not specified, [0, 0]+offset is used as the reference point. Equation = xy+refobj_xy+0.5*(Mt@refobj_size+Md@(refobj_size+inst_size)-Mti@inst_size).

name : str
Name of the instance.
cellname : str
Template name (cellname) of the instance.
gridname : str
Grid name for the placement.
xy : np.array([x, y]) or [int, int], optional
Placement coordinate on the grid, specified by gridname. If not specified, [0, 0] is used.
refobj : LayoutObject.Instance, optional
Reference instance handle, if None, refinstname is used. Will be extended to support other objects.
direction : str, optional
Direction of placement, bound from refobj. For example, if the instance will be place on top of refobj, direction=’top’ is used
shape : np.array([x0, y0]) or None, optional
array shape parameter. If None, the instance is not considered as array. Default is None
transform : str (‘R0’, ‘MX’, ‘MY’)
Transform parameter. ‘R0’ is used by default.
libname : str, optional
Template library name. If not specified, self.templates.plib is used.
laygo.layoutObject.Instance
generated instance
refinstname : str, optional, deprecated
Reference instance name, if None, [0, 0] is used for the reference point.
templatename : str, deprecated
Replaced with cellname
template_libname: str, optional, deprecated
Replaced with libname
spacing : np.array([int, int]) or [int, int]
Array spacing parameter for the instance. If none, the size of the instance of is used.
offset : np.array([float, float]), optional
Placement offset in physical coordinate.

place : substrate function of relplace

via(name=None, xy=array([0, 0]), gridname=None, refobj=None, refobjindex=array([0, 0]), offset=array([0, 0]), refinstname=None, refinstindex=array([0, 0]), refpinname=None, transform='R0', overwrite_xy_phy=None, overlay=None)[source]

Place a via on abstract grid, bound from a reference object. If reference object is not specified, [0, 0]+offset is used as the reference point.

name : str
Name of the via
xy : np.array([int, int]) or [int, int]
xy coordinate of the via
gridname : str
Grid name of the via
refobj : LayoutObject.LayoutObject
Reference object(Instance/Pin/Rect) handle. If None, refinstiname is used.
overlay : LayoutObject.LayoutObject
Layout object for via placement at intersection (via will be placed at the overlaid point btn refobj and overlay) Use with refobj only. Not compatible with legacy reference parameters (refinstname)
transform : str (‘R0’, ‘MX’, ‘MY’), optional
Transform parameter for grid. Overwritten by transform of refinstname if not specified.
laygo.layoutObject.Instance
generated via instance
offset : np.array([float, float]), optional
Offset on the physical grid, bound from xy
overwrite_xy_phy : None or np.array([float, float]), optional
If specified, final xy physical coordinates are overwritten by the argument.
refobjindex : np.array([int, int]), optional, deprecated
Index of refobj if it is a mosaic instance.
refinstname : str, optional, deprecated
Reference instance name for xy. If None, origin([0,0]) is used as the reference point.
refinstindex : str, optional, deprecated
Index of refinstname if it is a mosaic instance
refpinname : str, optional, deprecated
Reference pin of refinstname for reference point of xy. If None, the origin of refinstname0 is used.
route(name=None, layer=None, xy0=array([0, 0]), xy1=array([0, 0]), gridname0=None, gridname1=None, direction='omni', refobj0=None, refobj1=None, refobjindex0=array([0, 0]), refobjindex1=array([0, 0]), refinstname0=None, refinstname1=None, refinstindex0=array([0, 0]), refinstindex1=array([0, 0]), refpinname0=None, refpinname1=None, offset0=array([0, 0]), offset1=None, transform0='R0', transform1=None, endstyle0='truncate', endstyle1='truncate', via0=None, via1=None, netname=None)[source]

Route on abstract grid, bound from reference objects. If reference objects are not specified, [0, 0]+offset is used as reference points. This function is a bit messy because originally its main arguments were refinst/refinstindex/refpinname, and switched to refobj/refobjindex, and to refobj only. At some point all the codes need to be rewritten.

name : str
Route name. If None, the name will be automatically assigned by genid.
layer : [str, str], optional
Routing layer [name, purpose]. If None, it figures out the layer from grid and coordinates
xy0 : np.array([int, int]) or [int, int]
xy coordinate for start point.
xy1 : np.array([int, int]) or [int, int]
xy coordinate for end point.
gridname0 : str
Grid name0
gridname1 : str, optional
Grid name1
direction : str, optional
Routing direction (omni, x, y, …). It will be used as the input argument of GridLayoutGenerator.Md.
refobj0 : LayoutObject.LayoutObject
Reference object(Instance/Pin/Rect) handle. If None, refinstiname0 is used.
refobj1 : LayoutObject.LayoutObject
Reference object(Instance/Pin/Rect) handle. If None, refinstiname1 is used.
transform0 : str, optional
Transform parameter for grid0. Overwritten by transform of refinstname0 if not specified.
transform1 : str, optional
Transform parameter for grid1. Overwritten by transform of refinstname1 if not specified.
endstyle0 : str (‘extend’, ‘truncate’), optional
End style of xy0 (extend the edge by width/2 if endstyle==’extend’)
endstyle1 : str (‘extend’, ‘truncate’), optional
End style of xy1 (extend the edge by width/2 if endstyle==’extend’)
via0 : None or np.array([x, y]) or np.array([[x0, y0], [x1, y1], [x2, y2], …]), optional
Offset coordinates for via placements, bound from xy0 ex) if xy0 = [1, 2], xy1 = [1, 5], via0 = [0, 2] then a via will be placed at [1, 4]
via1 : None or np.array([x, y]) or np.array([[x0, y0], [x1, y1], [x2, y2], …]), optional
Offset coordinates for via placements, bound from xy1 ex) if xy0 = [1, 2], xy1 = [1, 5], via1 = [0, 2] then a via will be placed at [1, 7]
netname : str, optional
net name of the route
laygo.layoutObject.Rect
generated route
offset0 : np.array([float, float]), optional
Coordinate offset from xy0, on the physical grid.
offset1 : np.array([float, float]), optional
Coordinate offset from xy1, on the physical grid.
refobjindex0 : np.array([int, int]), optional, deprecated
Index of refobj0 if it is a mosaic instance.
refobjindex1 : np.array([int, int]), optional, deprecated
Index of refobj1 if it is a mosaic instance.
refinstname0 : str, optional, deprecated
Reference instance name for start point. If None, origin([0,0]) is used as the reference point.
refinstname1 : str, optional, deprecated
Reference instance name for end point. If None, origin([0,0]) is used as the reference point.
refinstindex0 : np.array([int, int]), optional, deprecated
Index of refinstname0 if it is a mosaic instance.
refinstindex1 : np.array([int, int]), optional, deprecated
Index of refinstname1 if it is a mosaic instance.
refpinname0 : str, optional, deprecated
Reference pin of refinstname0 for reference point of xy0. If None, the origin of refinstname0 is used.
refpinname1 : str, optional, deprecated
Reference pin of refinstname1 for reference point of xy1. If None, the origin of refinstname1 is used.
route_vh(layerv=None, layerh=None, xy0=None, xy1=None, gridname0=None, gridname1=None, refinstname0=None, refinstname1=None, refinstindex0=array([0, 0]), refinstindex1=array([0, 0]), refpinname0=None, refpinname1=None, endstyle0=['truncate', 'truncate'], endstyle1=['truncate', 'truncate'], via0=None, via1=None, gridname=None)[source]

Vertical-horizontal route function Parameters ———- layerv : [str, str]

Vertical route layer name and purpose
layerh : [str, str]
Horizontal route layer name and purpose
xy0 : np.array([int, int])
First coordinate
xy1 : np.array([int, int])
Second coordinate
gridname : str, optional
(Obsolete) Grid name. Use gridname0 instead
gridname0 : str
Gridname for xy0
gridname1 : str, optional
Gridname for xy1. If None, gridname0 is used
refinstname0 : str, optional
Reference instance name for xy0
refinstname1 : str, optional
Reference instance name for xy1
refinstindex0 : str, optional
Reference instance index for xy0
refinstindex1 : str, optional
Reference instance index for xy1
refpinname0 : str, optional
Reference pin name for xy0
refpinname1 : str, optional
Reference pin name for xy1
via0 : np.array([x0, y0], [x1, y1], …), optional
Via attach coordinates. Offsets from xy0
via1 : np.array([x0, y0], [x1, y1], …), optional
Via attach coordinates. Offsets from xy1
[laygo.layoutObject.Rect, laygo.layoutObject.Rect]
generated routes (vertical, horizontal)
route_hv(layerh=None, layerv=None, xy0=None, xy1=None, gridname0=None, gridname1=None, refinstname0=None, refinstname1=None, refinstindex0=array([0, 0]), refinstindex1=array([0, 0]), refpinname0=None, refpinname1=None, endstyle0=['truncate', 'truncate'], endstyle1=['truncate', 'truncate'], via0=None, via1=None, gridname=None)[source]

Horizontal-vertical route function Parameters ———- layerh : [str, str]

Horizontal route layer name and purpose
layerv : [str, str]
Vertical route layer name and purpose
xy0 : np.array([int, int])
First coordinate
xy1 : np.array([int, int])
Second coordinate
gridname : str
(Obsolete) Grid name. Use gridname0 instead
gridname0 : str
Gridname for xy0
gridname1 : str, optional
Gridname for xy1. If None, gridname0 is used
refinstname0 : str, optional
Reference instance name for xy0
refinstname1 : str, optional
Reference instance name for xy1
refinstindex0 : str, optional
Reference instance index for xy0
refinstindex1 : str, optional
Reference instance index for xy1
refpinname0 : str, optional
Reference pin name for xy0
refpinname1 : str, optional
Reference pin name for xy1
via0 : np.array([x0, y0], [x1, y1], …), optional
Via attach coordinates. Offsets from xy0
via1 : np.array([x0, y0], [x1, y1], …), optional
Via attach coordinates. Offsets from xy1
[laygo.layoutObject.Rect, laygo.layoutObject.Rect]
generated routes (horizontal, vertical)
route_vhv(layerv0=None, layerh=None, xy0=[0, 0], xy1=[0, 0], track_y=0, gridname0=None, layerv1=None, gridname1=None, extendl=0, extendr=0, gridname=None)[source]

Vertical-horizontal-vertical route function Parameters ———- layerv0 : [str, str]

First vertical route layer name and purpose
layerh : [str, str]
Horizontal route layer name and purpose
xy0 : np.array([int, int])
First coordinate
xy1 : np.array([int, int])
Second coordinate
track_y : int
Y-coordinate for horizontal route
gridname : str, optional
(Obsolete) Grid name. Use gridname0 instead
gridname0 : str
Gridname for xy0
layerv1 : [str, str], optional
Second vertical route layer name and purpose. If None, layer0 is used.
gridname1 : str, optional
Gridname for xy1. If None, gridname0 is used
extendl : int
Extension parameter in left direction
extendr : int
Extension parameter in right direction
[laygo.layoutObject.Rect, laygo.layoutObject.Rect, laygo.layoutObject.Rect]
generated routes (vertical, horizontal, vertical)
route_hvh(layerh0=None, layerv=None, xy0=[0, 0], xy1=[0, 0], track_x=0, gridname0=None, layerh1=None, gridname1=None, extendt=0, extendb=0, gridname=None)[source]

Horizontal-vertical-horizontal route function Parameters ———- layerh0 : [str, str]

First horizontal route layer name and purpose
layerv : [str, str]
Vertical route layer name and purpose
xy0 : np.array([int, int])
First coordinate
xy1 : np.array([int, int])
Second coordinate
track_x : int
X-coordinate for vertical route
gridname : str, optional
(Obsolete) Grid name. Use gridname0 instead
gridname0 : str
Gridname for xy0
layerh1 : [str, str], optional
Second horizontal route layer name and purpose. If None, layer0 is used.
gridname1 : str, optional
Gridname for xy1. If None, gridname0 is used
extendt : int, optional
Extension parameter in top direction
extendb : int, optional
Extension parameter in bottom direction
[laygo.layoutObject.Rect, laygo.layoutObject.Rect, laygo.layoutObject.Rect]
generated routes (horizontal, vertical, horizontal)
pin(name, layer=None, xy=None, gridname=None, netname=None, base_layer=None, refobj=None, xy0=array([0, 0]), xy1=array([0, 0]))[source]

Pin generation function. Parameters ———- name : str

pin name
layer : [str, str], optional
pin layer, if None, layer of refobj is used (assuming refobj is Rect)
xy : np.array([[int, int], [int, int]]), optional, deprecated
xy coordinate. deprecated. use xy0, xy1 instead
xy0 : np.array([[int, int]), optional
first coordinate
xy1 : np.array([[int, int]), optional
second coordinate
gridname : str
grid name
netname : str
net name. If None, pin name is used. Used when multiple pin objects are attached to the same net.
base_layer : [str, str]
base metal layer. If None, corresponding layer in metal dict is used.
refobj : LayoutObject.LayoutObject, optional
reference object handle
laygo.LayoutObject.Pin
generated Pin object

pin_from_rect : generate a Pin from a Rect boundary_pin_from_rect : generate a boundary Pin from a Rect

boundary_pin_from_rect(rect, gridname, name, layer, size=4, direction='left', netname=None)[source]

Generate a boundary Pin object from a reference Rect object Parameters ———- rect : laygo.LayoutObject.Rect

reference rect object
gridname : str
grid name
name : str
pin name
layer : [str, str]
pin layer
size : int
size of boundary pin
direction : str
specifies which side the generated Pin is placed. Possible values are ‘left’, ‘right’, ‘top’, ‘bottom’
netname : str, optional
net name. If None, pin name is used. Used when multiple pin objects are attached to the same net.
laygo.LayoutObject.Pin
generated Pin object
sel_template_library(libname)[source]

Select a template library to work on Parameters ———- libname : str

library name
sel_grid_library(libname)[source]

Select a grid library to work on Parameters ———- libname : str

library name
get_xy(obj, gridname=None, sort=False)[source]

get xy coordinate of an object on the specific coordinate Parameters ———- obj : LayoutObject.LayoutObject or TemplateObject.TemplateObject

Object to get the xy coordinates
gridname : str, optional
grid name. If None, physical grid is used
np.ndarray()
geometric paramter of the object on gridname
get_bbox(obj, gridname=None)[source]

get bounding box of an object on the specific coordinate Parameters ———- obj : LayoutObject.LayoutObject or TemplateObject.TemplateObject

Object to get the xy coordinates
gridname : str, optional
grid name. If None, physical grid is used
np.ndarray()
geometric paramter of the object on gridname
get_template_size(name, gridname=None, libname=None)[source]

get the size of a template in abstract coordinate. Same with get_template_xy

get_template(name, libname=None)[source]

Get template object handle Parameters ———- name : str

template name
libname : str, optional
library name
laygo.TemplateObject.TemplateObject
template object
get_grid(gridname)[source]

Get grid object handle Parameters ———- gridname : str

grid name
laygo.GridObject.GridObject
grid object
get_absgrid_xy(gridname, xy, refinstname=None, refinstindex=array([0, 0]), refpinname=None, refobj=None, refobjindex=None)[source]

Convert physical coordinate to abstract coordinate Parameters ———- gridname : str

abstract grid name
xy : np.array([float, float])
coordinate
refinstname : str, optional
referenence instance name
refinstname : np.array([int, int]), optional
referenence instance index
refpinname : str, optional
reference pin name
np.ndarray([int, int])
abstract coordinate
get_absgrid_region(gridname, xy0, xy1)[source]

Get regional coordinates on abstract grid Parameters ———- gridname : str

grid name
xy0 : np.array([float, float])
first xy coordinate on physical grid
xy1 : np.array([float, float])
second xy coordinate on physical grid
refinstname : str, optional
reference inst name
refpinname : str, optional
reference pin name
np.ndarray([[int, int], [int, int]])
abstract coordinates
construct_template_and_grid(db, libname, cellname=None, layer_boundary=['prBoundary', 'boundary'], layer_text=['text', 'drawing'], routegrid_prefix='route', placementgrid_prefix='placement', append=True)[source]

Construct TemplateDB and GridDB from LayoutDB. Used when generating a template and grid database from layout. Parameters ———- db : laygo.LayoutDB.LayoutDB

layout database object
libname : str
library name
cellname : str, None, optional
cell name to be registered as template. If None, all cells(structures) will be registered.
layer_boundary : [str, str], optional
layer of placement boundary. Used to find out the size of template/grid.
layer_text : [str, str], optional
layer of text objects. Used to find out Pin names (especially when netnames need to be captured).
routegrid_prefix : str, optioanl
prefix of routing grids. All layout cells starting with routegrid_prefix will be considered as routing grids.
placementgrid_prefix : str, optional
prefix of placement grids. All layout cells starting with placementgrid_prefix will be considered as placement grids.
append : True, optional
if True, the loaded template and grid database will be appended to existing database.
[laygo.TemplateDB.TemplateDB, laygo.GridDB.GridDB]
constructed template and grid databases
add_template_from_cell(libname=None, cellname=None)[source]

Register selected cell to template database Parameters ———- libname : str, optional

library name, if None, laygo.GridLayoutGenerator.db.plib is used (set by sel_library)
cellname : str, optional
cell name, if None, laygo.GridLayoutGenerator.db.pcell is used (set by sel_cell)
save_template(filename, libname=None)[source]

Save templateDB to yaml file Parameters ———- filename : str

load_template(filename, libname=None)[source]

Load templateDB from yaml file Parameters ———- filename : str libname : str, optional

save_grid(filename)[source]

Save gridDB to yaml file Parameters ———- filename : str

load_grid(filename, libname=None)[source]

Load gridDB from yaml file Parameters ———- filename : str libname : str, optional Returns ——- laygo.GridObject.GridObject

loaded grid object
pin_from_rect(name, layer, rect, gridname, netname=None)[source]

Generate a Pin object from a Rect object Parameters ———- name : str

Pin name
layer : [str, str]
Pin layer
rect : laygo.GridObject.Rect
Rect object
gridname : str
Gridname
netname : str, optional
net name. If None, pin name is used. Used when multiple pin objects are attached to the same net.
laygo.LayoutObject.Pin
generated Pin object
get_template_xy(name, gridname=None, libname=None)[source]

get the size of a template in abstract coordinate Parameters ———- name : str

template name
gridname : str, optional
grid name. If None, physical grid is used
libname : str, optional
library name. If None, GridLayoutGenerator.TemplateDB.TemplateDB.plib is uesd
np.ndarray([int, int])
size of template
get_inst_xy(name, gridname=None)[source]

Get xy coordinate values of an Instance object in abstract coordinate Parameters ———- name : str

instance name
gridname : str, optional
grid name. If None, physical grid is used
np.ndarray([int, int])
xy coordinate of instance
get_rect_xy(name, gridname, sort=False)[source]

get xy coordinate values of a Rect object in abstract coordinate Parameters ———- name : str

rect name
gridname : str
grid name
sort : bool, optional
if True, the coordinates are sorted
np.ndarray([int, int])
xy coordinates of the Rect object
get_pin_xy(name, gridname, sort=False)[source]

get xy coordinates of a Pin object in abstract coordinate Parameters ———- name : str

rect name
gridname : str
grid name
sort : bool, optional
if True, the coordinates are sorted
np.ndarray([int, int])
xy coordinates of the Pin object
get_template_pin_xy(name, pinname, gridname, libname=None)[source]

get xy cooridnate of a template pin in abstract coordinate Parameters ———- name : str

template cellname
pinname : str
template pinname
gridname : str
grid name
libname : str, optional
library name of template
np.ndarray([[int, int], [int, int]])
Template pin coordinates
get_inst_pin_xy(name, pinname, gridname, index=array([0, 0]), sort=False)[source]

Get xy coordinates of an instance pin in abstract coordinate Parameters ———- name : str

instance name if None, return all pin coordinates of all instances in dict format
pinname : str
template pinname if None, return all pin coordinates of specified instance in dict format
gridname : str
grid name

index : np.array([int, int]) Returns ——- np.ndarray([int, int])

Instance pin coordinates
get_inst_bbox(name, gridname=None, sort=False)[source]

Get a bounding box of an Instance object, on abstract grid Parameters ———- name : str

instance name
gridname : str, optional
grid name. If None, physical grid is used
sort : bool, optional
if True, the return coordinates are sorted
np.ndarray([[int, int], [int, int]])
instance bbox in abstract coordinate

laygo.GridLayoutGeneratorHelper module

GridBasedLayoutGenerator utility functions for users

laygo.GridLayoutGeneratorHelper.generate_boundary(laygen, objectname_pfix, placement_grid, devname_bottom, devname_top, devname_left, devname_right, shape_bottom=None, shape_top=None, shape_left=None, shape_right=None, transform_bottom=None, transform_top=None, transform_left=None, transform_right=None, origin=array([0, 0]))[source]

generate a boundary structure to resolve boundary design rules

laygo.GridLayoutGeneratorHelper.generate_power_rails(laygen, routename_tag, layer, gridname, netnames=['VDD', 'VSS'], direction='x', start_coord=0, end_coord=0, route_index=None, via_index=None, generate_pin=True)[source]

generate power rails

laygo.GridLayoutGeneratorHelper.generate_power_rails_from_rails_xy(laygen, routename_tag, layer, gridname, netnames=['VDD', 'VSS'], direction='x', input_rails_xy=None, generate_pin=True, overwrite_start_coord=None, overwrite_end_coord=None, offset_start_coord=None, offset_end_coord=None, overwrite_num_routes=None, overwrite_start_index=None, overwrite_end_index=None, offset_start_index=0, offset_end_index=0)[source]

generate power rails from pre-existing power rails in upper/lower layer. the pre-existing rail information is provided as xy array

laygo.GridLayoutGeneratorHelper.generate_power_rails_from_rails_rect(laygen, routename_tag, layer, gridname, netnames=['VDD', 'VSS'], direction='x', input_rails_rect=None, generate_pin=True, overwrite_start_coord=None, overwrite_end_coord=None, overwrite_num_routes=None, overwrite_start_index=None, overwrite_end_index=None, offset_start_coord=None, offset_end_coord=None, offset_start_index=0, offset_end_index=0)[source]

generate power rails from pre-existing power rails in upper/lower layer. the pre-existing rail information is provided as rect

laygo.GridLayoutGeneratorHelper.generate_power_rails_from_rails_inst(laygen, routename_tag, layer, gridname, netnames=['VDD', 'VSS'], direction='x', input_rails_instname=None, input_rails_pin_prefix=['VDD', 'VSS'], generate_pin=True, overwrite_start_coord=None, overwrite_end_coord=None, overwrite_num_routes=None, overwrite_start_index=None, overwrite_end_index=None, offset_start_coord=None, offset_end_coord=None, offset_start_index=0, offset_end_index=0)[source]

generate power rails from pre-existing power rails in upper/lower layer. the pre-existing rail information is provided as inst / pin prefix

laygo.GridLayoutGeneratorHelper.generate_grids_from_xy(laygen, gridname_input, gridname_output, xy, xy_grid_type=None)[source]

generate route grids combining a pre-existing grid and xy-array it will create a new array by copying the given grid and update part of entries from xy-lists

laygo.GridLayoutGeneratorHelper.generate_grids_from_xy_bnd(laygen, gridname_input, gridname_output, xy, xy_grid_type=None, bnd=None)[source]

generate route grids combining a pre-existing grid and xy-array it will create a new array by copying the given grid and update part of entries from xy-lists

laygo.GridLayoutGeneratorHelper.generate_grids_from_inst(laygen, gridname_input, gridname_output, instname, inst_pin_prefix=['VDD', 'VSS'], xy_grid_type=None)[source]

generate route grids combining a pre-existing grid and inst pins it will create a new array by copying the given grid and update part of entries from xy coordinates of pins

laygo.GridLayoutGeneratorHelper.generate_grids_from_template(laygen, gridname_input, gridname_output, template_name, template_libname, template_pin_prefix=['VDD', 'VSS'], xy_grid_type=None, bnd=None, offset=array([0, 0]))[source]

generate route grids combining a pre-existing grid and template pins it will create a new array by copying the given grid and update part of entries from xy coordinates of pins

laygo.GridObject module

The GridObject module and class implements a object that contains grid information for placement and route. It also provides useful functions for coordinate conversion between physical and abstract grids.

class laygo.GridObject.GridObject(name, libname, xy, _xgrid=array([0]), _ygrid=array([0]))[source]

Bases: object

Layout abstract grid class

type = 'native'

str: type of grid. can be ‘native’, ‘route’, ‘placement’

max_resolution = 10

int: maximum resolution to handle floating point numbers

height

float: height of grid

width

float: width of grid

name = None

str: name of grid

libname = None

str: library name of grid

xy = array([0, 0])

np.array([float, float]): size of grid

xgrid = array([], dtype=float64)

np.array([float, float, …]): x coordinates of grid

ygrid = array([], dtype=float64)

np.array([float, float, …]): y coordinates of grid

display()[source]

Display grid information

export_dict()[source]

Export object information in dict format

dict
grid information in dict format
add_xgrid(x)[source]

add a coordinate value to grid in x direction

x : float
value to be added
add_ygrid(y)[source]

add a coordinate value to grid in y direction

y : float
value to be added
get_xgrid()[source]

use laygo.GridObject.GridObject.xgrid instead

get_ygrid()[source]

use laygo.GridObject.GridObject.ygrid instead

get_absgrid_coord_x(x)[source]
get_absgrid_x(x)[source]

Convert a physical x coordinate to a corresponding value in abstract grid

x : float
value
int
converted value
get_absgrid_coord_y(y)[source]
get_absgrid_y(y)[source]

Convert a physical y coordinate to a corresponding value in abstract grid

y : float
value
int
converted value
get_absgrid_coord_xy(xy)[source]
get_absgrid_xy(xy)[source]

Convert a physical xy coordinate to a corresponding vector in abstract grid

xy : np.array([float, float])

np.array([int, int])

get_absgrid_coord_region(xy0, xy1)[source]
get_absgrid_region(xy0, xy1)[source]

Convert a physical regin to a corresponding region in abstract grid

xy0 : np.array([float, float])
first coordinate
xy1 : np.array([float, float])
second coordinate
np.array([[int, int], [int, int]])
converted coordinate
get_phygrid_coord_x(x)[source]
get_phygrid_x(x)[source]

Get the physical value of a abstract x coordinate

x : int
abstract coordinate value
float
physical coordinate value
get_phygrid_coord_y(y)[source]
get_phygrid_y(y)[source]

Get the physical value of a abstract y coordinate

y : int
abstract coordinate value
float
physical coordinate value
get_phygrid_coord_xy(xy)[source]
get_phygrid_xy(xy)[source]

Get the physical value of a abstract vector

xy : np.array([int, int])
abstract coordinate vector
np.array([float, float])
physical coordinate vector
class laygo.GridObject.PlacementGrid(name, libname, xy, _xgrid=array([0]), _ygrid=array([0]))[source]

Bases: laygo.GridObject.GridObject

Placement grid class

type = 'placement'
class laygo.GridObject.RouteGrid(name, libname, xy, xgrid, ygrid, xwidth, ywidth, xlayer=None, ylayer=None, viamap=None)[source]

Bases: laygo.GridObject.GridObject

Routing grid class

type = 'route'

str: type of grid. can be ‘native’, ‘route’, ‘placement’

xwidth = array([], dtype=float64)

np.array: width of xgrid

ywidth = array([], dtype=float64)

np.array: width of ygrid

xlayer = None

list: layer of xgrid

ylayer = None

list: layer of ygrid

viamap = {}

dict: via map information

get_route_width_xy(xy)[source]

Get metal width vector

xy : np.array([int, int])
coordinate
np.array([float, float])
route width vector ([xgrid, ygrid])
get_route_xlayer_xy(xy)[source]

Get route layer in xgrid direction (vertical)

xy : np.array([int, int])
coordinate
[str, str]
route layer information
get_route_ylayer_xy(xy)[source]

Get route layer in ygrid direction (horizontal)

xy : np.array([int, int])
coordinate
[str, str]
route layer information
get_vianame(xy)[source]

Get the name of via on xy

xy : np.array([int, int])
coordinate
str
cellname of via
display()[source]

Display RouteGrid information

export_dict()[source]

Export grid information in dict format

dict
Grid information
update_viamap(viamap)[source]

use laygo.GridObject.RouteGrid.viamap instead

laygo.LayoutDB module

The LayoutDB module implements layout database. The core database is constructed in dict (LayoutDB.design), and the design dict contains all layout objects (instances, rects, pins, …), instantiated as LayoutObject objects.

class laygo.LayoutDB.LayoutDB(res=0.005)[source]

Bases: dict

Layout database class

plib = None

str: current library handle

pcell = None

str: current cell handle

res_exp

int: exponent of laygo.LayoutDB.LayoutDB.res

design = None

dict: core database

res = 0.005

float: physical grid resolution

display(libname=None, cellname=None)[source]

Display the design database

libname : str, optional
library name. If none, all libraries are displayed.
cellname : str, optional
cell name. If none, all cells are displayed.
genid(type='instance', pfix='I', sfix='', max_index=100000)[source]

Generate a unique id (name) for objects

type : str
object type (instance, rect, path..)
pfix : str
prefix of the id
sfix : str
surfix of the id
max_index : int
maximum index
str
unique object id (name)
add_library(name)[source]

Add a library to the design dictionary

name : str
library name
dict
added library dictionary
add_cell(name, libname=None)[source]

Add a cell to the specified library

name : str
cell name
libname :
library name (if None, self.plib is used)
dict
added cell dictionary
sel_library(libname)[source]

Select a library to work on

libname : str
library name
sel_cell(cellname)[source]

Select a cell to work on

cellname : str
cellname
add_rect(name, xy, layer, netname=None)[source]

Add a rect to selected cell

name : str
rect name
xy : np.array([[float, float], [float, float]])
xy coordinate
layer : [str, str]
layer name and purpose
laygo.LayoutObject.Rect
added rect object
add_pin(name, netname, xy, layer)[source]

Add a pin to selected cell

name : str
pin object name
netname : str
net name
xy : [float, float]
xy coordinate
layer : [str, str]
layer name and purpose
laygo.LayoutObject.Pin
generated pin object
add_text(name, text, xy, layer)[source]

Add a pin to selected cell

name : str
pin object name
text : str
text string
xy : [float, float]
xy coordinate
layer : [str, str]
layer name and purpose
laygo.LayoutObject.Text
generated text object
add_inst(name, libname, cellname, xy=array([0, 0]), shape=None, spacing=array([0, 0]), transform='R0', template=None, use_array=False)[source]

Add an instance to the specified library and cell (_plib, _pstr)

name : str
instance name
libname : str
cell library name (not output library)
cellname : str
cell name
xy : np.array([float, float])
xy coordinate
shape : np.array([x0, y0])
array shape parameter
spacing : np.array([x0, y0])
array spacing parameter
transform : str
transform parameter
template : laygo.TemplateObject.TemplateObject
template handle
use_array : boolean
temporarily used. If true, InstanceArray is used instead of Instance (introduced for backward compatibility.)
laygo.LayoutObject.Instance
instance object
get_rect(name, libname=None)[source]

Get rect object

name : str
rect name
libname : str
libname. if None, self.db._plib is used

laygo.LayoutObject.Rect

get_inst(name=None, libname=None, index=array([0, 0]))[source]

Get instance object

name : str
instance name, if none, all instance is returned
libname : str
libname. if None, self.db._plib is used

laygo.LayoutObject.Instancce

get_pin(name, libname=None)[source]

Get pin object

name : str
pin name
libname : str
libname. if None, self.db._plib is used

laygo.LayoutObject.Pin

merge(db)[source]

Merge a LayoutDB object to self.db

db : laygo.LayoutDB.LayoutDB
layout database to be merged to self.db

laygo.LayoutIO module

The LayoutIO module implements interfaces for layout import and export. It supports BAG and GDS IO.

laygo.LayoutIO.export_GDS(db, libname, cellname, filename, layermapfile='default.layermap', physical_unit=1e-09, logical_unit=0.001, pin_label_height=0.1, pin_annotate_layer=['text', 'drawing'], text_height=0.1)[source]

Export specified cell(s) to a GDS file

db : laygo.LayoutDB.LayoutDB
design database
libname : str
name of library to be exported
cellname : list or str
name of cells to be exported
filename : str
output filename
layermapfile : str
layermap filename
physical_unit : float, optional
GDS physical unit
logical_unit : float, optional
GDS logical unit
pin_label_height : float, optional
pin label height
pin_annotate_layer : [str, str], optional
pin annotate layer name (used when pinname is different from netname)
text_height : float, optional
text height
laygo.LayoutIO.export_BAG(db, libname, cellname, prj, array_delimiter=['[', ']'], via_tech='cdsDefTechLib')[source]

Export specified cell(s) to BagProject

db : laygo.LayoutDB.LayoutDB
Layout db object
libname : str
name of library to be exported
cellname : list or str
name of cells to be exported
prj : BagProject
bag object to export
array_delimiter : list or str
array delimiter for multiple placements
via_tech : str
via technology entry for BagProject. Not being used currently because instances are used for via connections
laygo.LayoutIO.export_yaml(db, libname, cellname, filename)[source]

(Not implemented) Export specified cell(s) to a yaml file All information shown in db.display() will be saved

db : laygo.LayoutDB.LayoutDB
design database
libname : str
name of library to be exported
cellname : list or str
name of cells to be exported
filename : str
output filename
laygo.LayoutIO.import_GDS(filename=None, layermapfile='default.layermap', instance_libname=None, res=0.005)[source]

Import layout information from a gds file

filename : gds filename layermapfile : layermap filename (can be found in technology library) instance_libname : reference library name (libname of instances) res : float

physical resolution of objects
laygo.layoutDB.layoutDB
imported layout information
laygo.LayoutIO.import_BAG(prj, libname, cellname=None, yamlfile='import_BAG_scratch.yaml', res=0.005)[source]

Import layout information from BagProject object

prj : BagProject
BAG object
cellname : str
cell name to be imported (None if importing entire cells in the library)
yamlfile : str
scratch yaml file (parse_cad_layout skill function wrote layout information on the yamlfile)
res : float
physical resolution
laygo.layoutDB.layoutDB
imported layout information
laygo.LayoutIO.import_yaml(filename)[source]

(Not implemented) Import layout information from a yaml file

filename : yaml filename

layoutDB : imported layout information

laygo.LayoutObject module

The LayoutObject module implements classes for various layout objects.

class laygo.LayoutObject.LayoutObject(name, res, xy)[source]

Bases: object

Layout object class

get_xy()[source]
set_xy(value)[source]
name = None

str: Object name

res = 0.005

float: Physical grid resolution

xy

np.array([float, float]): Object xy physical coordinate

display()[source]

Display object information

class laygo.LayoutObject.Rect(name, res, xy, layer, netname)[source]

Bases: laygo.LayoutObject.LayoutObject

Rect object class

get_xy0()[source]
set_xy0(value)[source]
xy0

np.array([float, float]): lowerLeft coordinate of Rect

get_xy1()[source]
set_xy1(value)[source]
xy1

np.array([float, float]): upperRight coordinate of Rect

height

float: height of Rect

width

float: width of Rect

size

[float, float]: [width, height] of Rect

cx

float: x-center of Rect

cy

float: y-center of Rect

center

[float, float]: center coordinate of Rect

pointers = {}

dict(): pointer dictionary

layer = None

[str, str]: Rect layer

netname = None

str: net name

left = None
right = None
bottom = None
top = None
bottom_left = None
bottom_right = None
top_left = None
top_right = None
display()[source]

Display object information

class laygo.LayoutObject.Pin(name, res, xy, netname=None, layer=None, master=None)[source]

Bases: laygo.LayoutObject.LayoutObject

Pin object class

get_xy0()[source]
set_xy0(value)[source]
xy0

np.array([float, float]): lowerLeft coordinate of Pin

get_xy1()[source]
set_xy1(value)[source]
xy1

np.array([float, float]): upperRight coordinate of Pin

elements = []

elements for pins of array instance

pointers = {}

dict(): pointer dictionary

netname = None

str: net name

layer = None

[str, str]: Pin layer

master = None

LayoutObject.Instance: master instance, only for instance pins

left = None
right = None
bottom = None
top = None
bottom_left = None
bottom_right = None
top_left = None
top_right = None
display()[source]

Display object information

class laygo.LayoutObject.Text(name, res, xy, layer, text)[source]

Bases: laygo.LayoutObject.LayoutObject

Text object class

layer = None

[str, str]: Text layer

text = None

str: text body

display()[source]

Display object information

class laygo.LayoutObject.Pointer(name, res, xy, type='direction', master=None)[source]

Bases: laygo.LayoutObject.LayoutObject

Pointer class attached to other LayoutObjects

master = None

LayoutObject.Instance: master instance that the tag is attached

type = 'boundary'
class laygo.LayoutObject.Instance(name, res, xy, libname, cellname, shape=array([1, 1]), spacing=array([0, 0]), transform='R0', template=None)[source]

Bases: laygo.LayoutObject.LayoutObject

Instance object class

get_spacing()[source]
set_spacing(value)[source]
pointers = {}

dict(): pointer dictionary

xy0
xy1
bbox

[[float, float], [float, float]]: instance bounding box in physical coordinate

libname = None

str: library name

cellname = None

str: cell name

shape = array([1, 1])

np.array([int, int]): array shape

spacing

Array spacing (actually this is a pitch, but I just followed GDS’s notations)

transform = 'R0'

str: transform parameter

template = None

TemplateObject.TemplateObject: original template object

elements = None

np.array([[Instance]]): array elements

size = array([0, 0])

np.array([float, float]): instance size (valid only if its template is specified)

left = None
right = None
bottom = None
top = None
bottom_left = None
bottom_right = None
top_left = None
top_right = None
pins = None

dict(): pin dictionary

display()[source]

Display object information

laygo.TemplateDB module

The TemplateDB module/class implements template database management functions for GridBaseLayoutGenerator module.

class laygo.TemplateDB.TemplateDB[source]

Bases: dict

layout template database class

plib = None

str: current library handle

templates = None

dict: template dictionary

display(libname=None, templatename=None)[source]

Display design database

libname : str, optional
library name. If None, all libraries are displayed
templatename : str, optional
template name. If None, all templates are displayed
export_yaml(filename, libname=None)[source]

Export template database to a yaml file

filename : str
yaml file name
libname : str, optional
library name to be exported
import_yaml(filename, libname=None)[source]

Import template database from an external yaml file

filename : str
yaml file name
libname : str, optional
library name to be exported
merge(db)[source]

Merge a GridDB object to self.db

db : TemplateDB

add_library(name)[source]

Add a library to the design dictionary

name : str
library name
add_template(name, libname=None, xy=array([[0, 0], [0, 0]]), pins={})[source]

Add a template to the specified library

name : str
templatename
libname : str, optional
library name (if None, self.plib is used)
xy : np.array([[float, float], [float, float]]), optional
template bounding box coordinates
pins : dict, optional
pin dictionary
sel_library(libname)[source]

Select a library to work on

libname : str
library name
get_template(templatename, libname=None)[source]

Get a handle of template object

templatename : str
template name
libname : str
library name. If None. laygo.TemplateDB.plib is used
laygo.TemplateObject.TemplateObject
template object

laygo.TemplateObject module

Template Object

class laygo.TemplateObject.TemplateObject(name, xy, pins)[source]

Bases: object

Layout object class

height

float: template height

width

float: template width

size

np.array([float, float]): template size

name = None

str: template name

xy = array([[0, 0], [0, 0]])

np.array([[float, float], [float, float]]): template bBox

display()[source]

Display object information

export_dict()[source]

Export object information

laygo.quick_start_BAG module

Quick start script for bag flow - nand gate layout generator

laygo.quick_start_GDS module

Quick start script for bag flow - nand gate layout generator

Module contents

laygo package