### PlacementGrid.place method example Source: https://laygo2.github.io/_modules/laygo2/object/grid/placement.html This example demonstrates creating a PlacementGrid and using the place method to position an instance at specific grid coordinates. ```python >>> 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] ``` -------------------------------- ### generate method with full routing example Source: https://laygo2.github.io/_modules/laygo2/object/template/routing.html Generates a routing mesh and returns a VirtualInstance. The example shows grid construction, node creation, mesh setup, and expected output for horizontal and vertical wires. ```python def generate(self): """Generate a routing mesh. Returns ------- laygo2.object.physical.VirtualInstance: the generated routing 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.physical import Instance, Rect >>> # 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, 50], elements=[0]) >>> wv = CM([10]) # vertical (xgrid) width >>> wh = CM([10]) # horizontal (ygrid) width >>> ev = CM([10]) # vertical (xgrid) extension >>> eh = CM([10]) # horizontal (ygrid) extension >>> e0v = CM([5]) # vert. extension (for zero-length wires) >>> e0h = CM([5]) # hori. extension (for zero-length wires) >>> lv = CM([['M1', 'drawing']], dtype=object) # layer information >>> lh = CM([['M2', 'drawing']], dtype=object) >>> plv = CM([['M1', 'pin']], dtype=object) # pin layers >>> plh = CM([['M2', 'pin']], dtype=object) >>> xcolor = CM([None], dtype=object) # not multi-patterned >>> 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 = 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 node objects. >>> r0 = Rect(xy=[[45, -5], [55, 5]], layer=['M1', 'drawing'], netname = "A") >>> r1 = Rect(xy=[[95, -5], [105, 5]], layer=['M1', 'drawing'], netname = "A") >>> i0_pins = dict() >>> i0_pins['X'] = laygo2.object.physical.Pin(xy=[[45, 95], [55, 105]], >>> layer = ['M1', 'drawing'], netname = 'A') >>> i0 = laygo2.object.physical.Instance(name="I0", xy=[150,0], >>> libname="mylib", cellname="mycell", shape=[3, 2], pitch=[200,200], >>> unit_size=[100, 100], pins=i0_pins, transform='R0') >>> >>> # Create a routing mesh. >>> rm = laygo2.object.routing.RoutingMesh(grid = g) >>> rm.add_track(name = "A", index = [None, 5], netname = "A") >>> rm.add_node(r0) >>> rm.add_node(r1) >>> rm.add_node(i0) >>> rinst = rm.generate() >>> >>> # Print horizontal wire >>> print(rinst.pins["A"].xy) [[ 50 250] [200 250]] >>> # Vertical wire to r0 >>> print(rinst.native_elements["A_0_0"].xy) [[ 50 0] [ 50 250]] >>> # Vertical wire to r1 >>> print(rinst.native_elements["A_1_0"].xy) [[100 0] [100 250]] >>> # Vertical wire to i0 >>> print(rinst.native_elements["A_2_0"].xy) [[200 100] [200 250]] """ g = self.grid tr = self.tracks nds = self.nodes ``` -------------------------------- ### RoutingGrid construction and routing example Source: https://laygo2.github.io/laygo2.object.grid.RoutingGrid.html This example demonstrates constructing a RoutingGrid with OneDimGrid, CircularMapping, and CircularMappingArray, then routing a multi-point net using the route method. It shows the expected output objects (Instances and Rects) with their properties. ```python >>> 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.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 multi-patterned >>> 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) >>> # >>> # Routing on grid >>> # >>> mn_list = [[0, -2], [0, 1], [2, 1], [5,1] ] >>> route = g.route(mn=mn_list, via_tag=[True, False, True, True]) >>> for r in route: >>> print(r) name: None, class: Instance, xy: [0, -60], params: None, size: [0, 0] shape: None pitch: [0, 0] transform: R0 pins: {} name: None, class: Rect, xy: [[0, -60], [0, 40]], params: None, , layer: ['M1' 'drawing'], netname: None name: None, class: Rect, xy: [[0, 40], [100, 40]], params: None, , layer: ['M2' 'drawing'], netname: None name: None, class: Instance, xy: [100, 40], params: None, size: [0, 0] shape: None pitch: [0, 0] transform: R0 pins: {} name: None, class: Rect, xy: [[100, 40], [250, 40]], params: None, , layer: ['M2' 'drawing'], netname: None name: None, class: Instance, xy: [250, 40], params: None, size: [0, 0] shape: None pitch: [0, 0] transform: R0 pins: {} ``` -------------------------------- ### Constructor example for NativeInstanceTemplate Source: https://laygo2.github.io/_modules/laygo2/object/template/core.html Example from the __init__ docstring: creates a NativeInstanceTemplate with two pins and prints the object's info. The output expects the default repr format with object memory address. ```Python >>> from laygo2.object.physical import Pin >>> from laygo2.object.template import NativeInstanceTemplate >>> p = dict() >>> p['i'] = Pin(xy=[[0, 0], [10, 10]], layer=['M1', 'drawing'], netname='i') >>> p['o'] = Pin(xy=[[90, 90], [100, 100]], layer=['M1', 'drawing'], netname='o') >>> nt = NativeInstanceTemplate(libname='mylib', cellname='mytemp', bbox=[[0, 0], [100, 100]], pins=p) >>> print(nt) name: mytemp, class: NativeInstanceTemplate, bbox: [[0, 0], [100, 100]], pins: {'i': , 'o': }, ``` -------------------------------- ### Design class usage with laygo2_tech setup Source: https://laygo2.github.io/laygo2.object.database.Design.html Shows how to use the Design class with a technology setup (laygo2_tech). It loads templates and grids from the technology, creates a design, places an instance, routes, and exports to a template or skill script. ```python >>> 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) ... >>> # >>> # 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) ... ``` -------------------------------- ### RoutingGrid construction and route_via_track example Source: https://laygo2.github.io/laygo2.object.grid.RoutingGrid.html Example showing how to construct a RoutingGrid with OneDimGrid, CircularMapping, and CircularMappingArray, then use route_via_track to route a track. The output shows the resulting list of Rect and VirtualInstance objects. ```python >>> 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.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 multi-patterned >>> 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) >>> # Routing on grid >>> mn_list = [[0, -2], [1, 0], [2, 5], [3, 4], [4, 5], [5, 5]] >>> track = g.route_via_track(mn=mn_list, track=[None, 0]) >>> print(track) [[, ], , [, ], [, ], [, ], [, ], ] ``` -------------------------------- ### RoutingGrid pin_hlayer example Source: https://laygo2.github.io/laygo2.object.grid.RoutingGrid.html Shows how to construct a RoutingGrid with pin layers and print the pin_hlayer property. The example demonstrates creating OneDimGrids, CircularMapping for widths, extensions, layers, and viamap, then prints the resulting pin_hlayer. ```python >>> 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 >>> # 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 multi-patterned >>> 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) >>> print(g.pin_hlayer) class: CircularMapping, elements: [['M1', 'pin'], ['M1', 'pin'], ['M1', 'pin']] ``` -------------------------------- ### Initialize OneDimGrid Source: https://laygo2.github.io/laygo2.object.grid.OneDimGrid.html Example showing how to instantiate a OneDimGrid object with a name, scope, and elements. ```python >>> from laygo2.object.grid import OneDimGrid >>> g1_x = OneDimGrid(name='xgrid', scope=[0, 180], elements=[0, 35, 85, 130, 50]) >>> print(g1_x) OneDimGrid object name: xgrid, class: OneDimGrid, scope: [0, 180], elements: [0, 35, 85, 130 50] ``` -------------------------------- ### NativeInstanceTemplate class with libname example Source: https://laygo2.github.io/_modules/laygo2/object/template/core.html Starts the NativeInstanceTemplate subclass, showing the libname attribute with a doctest example that creates Pin objects and a NativeInstanceTemplate instance, then accesses nt.libname to get 'mylib'. The cellname attribute is also declared. ```python class NativeInstanceTemplate(Template): """ NativeInstanceTemplate class implements the template that generate Instance. """ libname = None """str: Library name. Example ------- >>> from laygo2.object.physical import Pin >>> from laygo2.object.template import NativeInstanceTemplate >>> p = dict() >>> p['i'] = Pin(xy=[[0, 0], [10, 10]], layer=['M1', 'drawing'], netname='i') >>> p['o'] = Pin(xy=[[90, 90], [100, 100]], layer=['M1', 'drawing'], netname='o') >>> nt = NativeInstanceTemplate(libname='mylib', cellname='mytemp', bbox=[[0, 0], [100, 100]], pins=p) >>> nt.libname 'mylib' .. image:: ../assets/img/object_template_NativeInstanceTemplate_libname.png :height: 250 """ cellname = None """str: Cell name. ``` -------------------------------- ### Run quick_start.py to generate NAND gate layout Source: https://laygo2.github.io/trial.html Commands to clone the repository, navigate to the laygo2 directory, and run the quick start script to generate a NAND gate layout. Includes an alternative method using ipython. ```bash # 1. Clone the laygo2 repository to your local machine. # 2. Navigate to the laygo2 directory. >>> cd laygo2 # 3. Run the quick start script by typing the following command: >>> python -m quick_start.py # 4. Alternatively, you can run ipython and type the following command: >>> run 'quick_start.py' ``` -------------------------------- ### Get grid width with PlacementGrid.width Source: https://laygo2.github.io/laygo2.object.grid.PlacementGrid.html Shows how to get the width of the coordinate system region using the `width` property. The example grid has an x-scope of [0, 100], so the width is 100. ```python >>> 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 ``` -------------------------------- ### Creating a Library and Design with Layout Objects Source: https://laygo2.github.io/_modules/laygo2/object/database.html This example demonstrates how to initialize a library and design, then populate the design with Rect, Path, Pin, and Instance objects. ```python # Test lib = Library(name="mylib") dsn = Design(name="mycell") lib.append(dsn) rect0 = Rect( xy=[[0, 0], [100, 100]], layer=["M1", "drawing"], name="R0", netname="net0", params={"maxI": 0.005}, ) dsn.append(rect0) rect1 = Rect( xy=[[200, 0], [300, 100]], layer=["M1", "drawing"], netname="net0", params={"maxI": 0.005}, ) dsn.append(rect1) path0 = Path( xy=[[0, 0], [0, 100]], width=10, extension=5, layer=["M1", "drawing"], netname="net0", params={"maxI": 0.005}, ) dsn.append(path0) pin0 = Pin( xy=[[0, 0], [100, 100]], layer=["M1", "pin"], netname="n0", master=rect0, params={"direction": "input"}, ) dsn.append(pin0) # text0 = Text(xy=[0, 0], layer=['text', 'drawing'], text='test', params=None) # dsn.append(text0) inst0_pins = dict() inst0_pins["in"] = Pin(xy=[[0, 0], [10, 10]], layer=["M1", "drawing"], netname="in") inst0_pins["out"] = Pin(xy=[[90, 90], [100, 100]], layer=["M1", "drawing"], netname="out") inst0 = Instance( name="I0", xy=[100, 100], libname="mylib", cellname="mycell", shape=[3, 2], pitch=[100, 100], unit_size=[100, 100], pins=inst0_pins, transform="R0", ) dsn.append(inst0) print(lib) print(dsn) ``` -------------------------------- ### Get grid height with PlacementGrid.height Source: https://laygo2.github.io/laygo2.object.grid.PlacementGrid.html Shows how to get the height of the coordinate system region using the `height` property. The example grid has a y-scope of [0, 100], so the height is 100. ```python >>> 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 ``` -------------------------------- ### Constructor example: create a Library and print it Source: https://laygo2.github.io/laygo2.object.database.Library.html Demonstrates the __init__ method of Library by creating a library named 'mylib' and printing it to show its default empty elements dictionary. ```python >>> import laygo2 >>> lib = laygo2.object.database.Library(name='mylib') >>> print(lib) name: mylib, params: None elements: {} > ``` -------------------------------- ### Get grid shape with PlacementGrid.shape Source: https://laygo2.github.io/laygo2.object.grid.PlacementGrid.html Shows how to get the two-dimensional element length of the coordinate system using the `shape` property. The example grid has 5 elements in each axis, so the shape is [5, 5]. ```python >>> 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] ``` -------------------------------- ### Create and inspect a VirtualInstance Source: https://laygo2.github.io/_modules/laygo2/object/physical.html This example demonstrates how to define pins and native elements, then instantiate a VirtualInstance. ```python >>> import laygo2 >>> vinst0_pins = dict() >>> # Pin information >>> vinst0_pins['in'] = laygo2.object.physical.Pin(xy=[[0, 0], [10, 10]], layer=['M1', 'drawing'], netname='in') >>> vinst0_pins['out'] = laygo2.object.physical.Pin(xy=[[90, 90], [100, 100]], layer=['M1', 'drawing'], netname='out') >>> # Element information >>> native_elements = dict() >>> native_elements['R0'] = laygo2.object.physical.Rect(xy=[[0, 0], [10, 10]], layer=['M1', 'drawing']) >>> native_elements['R1'] = laygo2.object.physical.Rect(xy=[[90, 90], [100, 100]], layer=['M1', 'drawing']) >>> native_elements['R2'] = laygo2.object.physical.Rect(xy=[[0, 0], [100, 100]], layer=['prBoundary', 'drawing']) >>> vinst0 = laygo2.object.physical.VirtualInstance(name='I0', libname='mylib', cellname='myvcell', xy=[500, 500], native_elements=native_elements, shape=[3, 2], pitch=[100, 100], unit_size=[100, 100], pins=vinst0_pins, transform='R0') >>> vinst0.native_elements {'R0': , 'R1': , 'R2': } ``` -------------------------------- ### Placing instances using Design.place() Source: https://laygo2.github.io/laygo2.object.database.Design.place.html This example demonstrates setting up a placement grid, creating a design, and placing both a single instance and multiple instances using the place() method. ```python >>> 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) name: mycell params: None elements: {'I0': } libname:genlib rects:{} paths:{} pins:{} texts:{} instances: {'I0': } 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) name: mycell params: None elements: {'I0': , 'I1': , 'I2': , 'I3': } libname:genlib rects:{} paths:{} pins:{} texts:{} instances: {'I0': , 'I1': , 'I2': , 'I3': } virtual instances:{} ``` -------------------------------- ### Create a Design and Place a Pin Source: https://laygo2.github.io/laygo2.object.database.Design.html This example demonstrates setting up a routing grid, initializing a Design object, and placing a pin on the grid. ```python >>> 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) name: pin, class: Pin, xy: [[0, -10], [500, 350]], params: None, , layer: ['M2' 'pin'], netname: pin, shape: None, master: None >>> print(dsn) name: mycell, params: None elements: {'pin': } libname:genlib rects:{} paths:{} pins:{'pin': } texts:{} instances:{} virtual instances:{} ``` -------------------------------- ### Get bottom_right property example Source: https://laygo2.github.io/laygo2.object.physical.PhysicalObjectGroup.html Shows how to create a PhysicalObject and access its bottom_right property, returning the bottom-right coordinate as a numpy array. ```python >>> import laygo2 >>> obj = laygo2.object.physical.PhysicalObject(xy = [[0, 0], [200, 200]]) >>> obj.bottom_right array([200, 0]) ``` -------------------------------- ### Get bottom_left property example Source: https://laygo2.github.io/laygo2.object.physical.PhysicalObjectGroup.html Shows how to create a PhysicalObject and access its bottom_left property, returning the bottom-left coordinate as a numpy array. ```python >>> import laygo2 >>> obj = laygo2.object.physical.PhysicalObject(xy = [[0, 0], [200, 200]]) >>> obj.bottom_left array([ 0, 0]) ``` -------------------------------- ### Create and Route a Design Source: https://laygo2.github.io/laygo2.object.database.Design.html This example demonstrates setting up a routing grid, creating a Design object, and performing routing on the grid. ```python >>> 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) name: mycell, params: None elements: { 'NoName_0': , 'NoName_1': , 'NoName_2': , 'NoName_3': , 'NoName_4': , 'NoName_5': } libname:genlib rects: { # wires 'NoName_1': , 'NoName_2': , 'NoName_4': } paths:{} pins:{} texts:{} instances:{ # vias 'NoName_0': , 'NoName_3': , 'NoName_5': } virtual instances:{} ``` -------------------------------- ### Get bottom property example Source: https://laygo2.github.io/laygo2.object.physical.PhysicalObjectGroup.html Shows how to create a PhysicalObject and access its bottom property, returning the bottom-center coordinate as a numpy array. ```python >>> import laygo2 >>> obj = laygo2.object.physical.PhysicalObject(xy = [[0, 0], [200, 200]]) >>> obj.top array([100, 0]) ``` -------------------------------- ### Get bbox property example Source: https://laygo2.github.io/laygo2.object.physical.PhysicalObjectGroup.html Shows how to create a PhysicalObject and access its bbox property, returning a numpy array of the bounding box coordinates. ```python >>> import laygo2 >>> obj = laygo2.object.physical.PhysicalObject(xy = [[0, 0], [200, 200]]) >>> obj.bbox array([[ 0, 0], [200, 200]]) ```