laygo2.interface.magic module#
- laygo2.interface.magic.export(db, filename=None, cellname=None, libpath='./magic_layout', scale=1, reset_library=False, tech_library=None, gds_filename=None)[source]#
Export a laygo2.object.database.Library object to magic’s tcl code.
- Parameters:
db (laygo2.database.Library) – The library database to be exported.
filename (str, optional) – If specified, the generated magic(tcl) script is stored in filename.
cellname (str or List[str]) – The name(s) of cell(s) to be exported.
libpath (str) – The path where the generated magic layout is stored.
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.
gds_filename (str, optional) – If specified, export a gds file with the filename provided.
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 magic tcl. >>> lib = laygo2.object.database.Library(name="mylib") >>> lib.append(dsn) >>> scr = laygo2.interface.magic.export(lib, filename="myscript.tcl") >>> print(scr) (definitions of laygo2 tcl functions) # exporting mylib__mycell _laygo2_create_layout ./magic_layout/mylib mylib_mycell None _laygo2_generate_rect M1 { { 0.0 0.0 } { 100.0 100.0 } } ; # for the Rect object NoName_0 _laygo2_generate_pin P M1 { { 0.0 0.0 } { 50.0 50.0 } } ; # for the Pin object P _laygo2_generate_instance I0 ./magic_layout/tlib tlib_t0 { 0.0 0.0 } R0 1 1 0 0 ; # for the Instance object I0 save
- Returns:
str
- Return type:
the string object contains corresponding tcl scripts.