laygo2.interface.bag module#

This module implements interface with BAG in skill language

laygo2.interface.bag.export(db, filename, cellname=None, scale=0.001, reset_library=False, tech_library=None)[source]#

Export a laygo2.object.database.Library object to BAG2.

Parameters:
  • db (laygo2.object.database.Library) – The library database to be exported.

  • filename (str, optional) – The path of the intermediate skill script file.

  • cellname (str or List[str]) – The name(s) of cell(s) to be exported.

  • scale (float) – The scaling factor between laygo2’s integer coordinats actual physical coordinates.

  • reset_library (bool, optional) – If True, the library to export the cells is reset.

  • tech_library (str, optional) – The name of technology library to be attached to the resetted library.

Returns:

str

Return type:

The generated skill script.

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)
>>> #
>>> # Export to BAG.
>>> lib = laygo2.object.database.Library(name="mylib")
>>> lib.append(dsn)
>>> scr = laygo2.interface.bag.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)
laygo2.interface.bag.load(libname, cellname=None, il_filename='import_skill_scratch.il', yaml_filename='import_skill_scratch.yaml', scale=0.001, mpt=False)[source]#

Import virtuoso layout to a laygo2.object.database.Library object via BAG2 interface.