laygo2.interface.yaml module#

This module implements interfaces with yaml files.

laygo2.interface.yaml.export_template(template, filename, mode='append')[source]#

Export a template to a yaml file.

Parameters:
  • template (laygo2.object.template.Template) – The template object to be exported.

  • filename (str) – The name of the yaml file.

  • mode (str) – If ‘append’, it adds the template entry without erasing the preexisting file.

Example

>>> import laygo2
>>> 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)
>>> laygo2.interface.yaml.export_template(nt, filename="mytemplates.yaml")
Your design was translated into YAML format.
{'mylib': {
    'mytemp': {
        'libname': 'mylib',
        'cellname': 'mytemp',
        'bbox': [[0, 0], [100, 100]],
        'pins': {
            'i': {
                'xy': [[0, 0], [10, 10]],
                'layer': ['M1', 'drawing'],
                'name': None,
                'netname': 'i'
                },
            'o': {
                'xy': [[90, 90], [100, 100]],
                'layer': ['M1', 'drawing'],
                'name': None,
                'netname': 'o'
}}}}}
laygo2.interface.yaml.import_template(filename)[source]#

Import templates from a yaml file.

Parameters:

filename (str) – The name of the yaml file.

Example

>>> import laygo2
>>> 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)
>>> laygo2.interface.yaml.export_template(nt, filename="mytemplates.yaml")
>>> # Import the template back to python.
>>> my_tlib = laygo2.interface.yaml.import_template("mytemplates.yaml")
>>> print(my_tlib)
<laygo2.object.database.TemplateLibrary object at 0x000001FE3440A410>
    name: mylib,
    params: None
    elements: {
        'mytemp': <laygo2.object.template.NativeInstanceTemplate object at 0x000001FE3440A2C0>
    }