ParameterizedInstanceTemplate class#
- class laygo2.object.template.ParameterizedInstanceTemplate(libname, cellname, bbox_func=None, pins_func=None)[source]#
Bases:
Template
The ParameterizedInstanceTemplate class implements a template for generating instances with varying size (bounding box) and pin configurations based on input parameters, such as instances mapped to Cadence Virtuoso’s pcells or Pycells.
Public Data Attributes:
libname
The libname of the instance to be generated.
cellname
The cellname of the instance to be generated.
Inherited from
Template
name
Template name.
Public Methods:
__init__
(libname, cellname[, bbox_func, ...])Constructor of ParameterizedInstanceTemplate class.
bbox
([params])Bounding box of the template object.
pins
([params])Return pin dictionary of ParameterizedInstanceTemplate object.
generate
([name, shape, pitch, transform, ...])Generate an Instance object corresponding to the template and its input parameters.
Inherited from
Template
__init__
([name])The constructor function.
__str__
()Return a string representation of this template's information.
summarize
()Return the summary of the template information.
height
([params])int: Return the height of the template.
width
([params])int: Return the width of the template.
size
([params])int: Return the size of the template.
bbox
([params])numpy.ndarray: (Abstract method) the physical bounding box of the template.
pins
([params])dict: (Abstract method) Dictionary storing the pins of the template.
generate
([name, shape, pitch, transform, ...])instance: (Abstract method) Generate an instance from the template.
- __init__(libname, cellname, bbox_func=None, pins_func=None)[source]#
Constructor of ParameterizedInstanceTemplate class.
- Parameters:
libname (str) – The library name.
cellname (str) – The cell name of the template.
bbox_func (callable) – The function that computes the bounding box of the template from its input parameters.
pins_func (callable) – The function that returns a dictionary that contains its pin objects for its input parameters.
- Return type:
Example
>>> import numpy as np >>> from laygo2.object.template import ParameterizedInstanceTemplate >>> from laygo2.object.physical import Pin >>> # bbox computation function. >>> def pcell_bbox_func(params): return np.array([[0, 0], [100 * params["mult"], 100]]) >>> # pin generation function. >>> def pcell_pins_func(params): >>> template_pins = dict() >>> for i in range(params["mult"]): >>> template_pins["in" + str(i)] = Pin( >>> xy=[[i * 100 + 0, 0], [i * 100 + 10, 10]], >>> layer=["M1", "drawing"], >>> netname="in" + str(i), >>> ) >>> template_pins["out" + str(i)] = Pin( >>> xy=[[i * 100 + 90, 90], [i * 100 + 90, 100]], >>> layer=["M1", "drawing"], >>> netname="out" + str(i), >>> ) >>> return template_pins >>> # Create a template >>> pcell_temp = ParameterizedInstanceTemplate( >>> libname="mylib", >>> cellname="mypcelltemplate", >>> bbox_func=pcell_bbox_func, >>> pins_func=pcell_pins_func, >>> ) >>> # Generate an instance for input parameters. >>> pcell_inst_params = {"mult": 4} >>> pcell_inst = pcell_temp.generate( >>> name="mypcellinst", >>> transform="R0", >>> params=pcell_inst_params, >>> ) >>> # display >>> print(pcell_temp) <laygo2.object.template.ParameterizedInstanceTemplate object at 0x000001B1BA91D9C0> name: mypcelltemplate, class: ParameterizedInstanceTemplate, >>> print(pcell_inst) xy: [0, 0], params: {'mult': 4}, size: [400, 100], shape: None, pitch: [400, 100], transform: R0, pins: {'in0': <laygo2.object.physical.Pin object at 0x000001B1BA91FCA0>, 'out0': <laygo2.object.physical.Pin object at 0x000001B1BA91FC70>, 'in1': <laygo2.object.physical.Pin object at 0x000001B1BA91FC10>, 'out1': <laygo2.object.physical.Pin object at 0x000001B1BA91E8C0>, 'in2': <laygo2.object.physical.Pin object at 0x000001B1BA91E890>, 'out2': <laygo2.object.physical.Pin object at 0x000001B1BA91FBE0>, 'in3': <laygo2.object.physical.Pin object at 0x000001B1BA91E7D0>, 'out3': <laygo2.object.physical.Pin object at 0x000001B1BA91E710>},
- bbox(params=None)[source]#
Bounding box of the template object.
- Parameters:
params (dict) – A dictionary that contains input parameters corresponding to the bounding box to be computed.
- Returns:
numpy.ndarray – coordinates corresponding to the input parameters.
- Return type:
A 2x2 numpy array that contains the bounding box
Example
>>> import numpy as np >>> from laygo2.object.template import ParameterizedInstanceTemplate >>> from laygo2.object.physical import Pin >>> # bbox computation function. >>> def pcell_bbox_func(params): return np.array([[0, 0], [100 * params["mult"], 100]]) >>> # pin generation function. >>> def pcell_pins_func(params): >>> template_pins = dict() >>> for i in range(params["mult"]): >>> template_pins["in" + str(i)] = Pin( >>> xy=[[i * 100 + 0, 0], [i * 100 + 10, 10]], >>> layer=["M1", "drawing"], >>> netname="in" + str(i), >>> ) >>> template_pins["out" + str(i)] = Pin( >>> xy=[[i * 100 + 90, 90], [i * 100 + 90, 100]], >>> layer=["M1", "drawing"], >>> netname="out" + str(i), >>> ) >>> return template_pins >>> # Create a template >>> pcell_temp = ParameterizedInstanceTemplate( >>> libname="mylib", >>> cellname="mypcelltemplate", >>> bbox_func=pcell_bbox_func, >>> pins_func=pcell_pins_func, >>> ) >>> # Compute bbox for input parameters >>> pcell_inst_params = {"mult": 4} >>> pcell_temp.bbox(params=pcell_inst_params) array([[ 0, 0], [400, 100]])
- generate(name=None, shape=None, pitch=None, transform='R0', netmap=None, params=None)[source]#
Generate an Instance object corresponding to the template and its input parameters.
- Parameters:
name (str) – name of the instance to be generated.
shape (numpy.ndarray, optional.) – shape of the object to be generated.
pitch (numpy.ndarray, optional.) – pitch of the object to be generated.
transform (str, optional.) – transformation attribute of the entity to be generated.
netmap (dict, optional.) – dictionary containing netmap conversion information of pins.
params (dict, optional.) – dictionary having the entity attributes.
- Returns:
laygo2.object.physical.Instance
- Return type:
The generated Instance object
Example
>>> import numpy as np >>> from laygo2.object.template import ParameterizedInstanceTemplate >>> from laygo2.object.physical import Pin >>> # bbox computation function. >>> def pcell_bbox_func(params): return np.array([[0, 0], [100 * params["mult"], 100]]) >>> # pin generation function. >>> def pcell_pins_func(params): >>> template_pins = dict() >>> for i in range(params["mult"]): >>> template_pins["in" + str(i)] = Pin( >>> xy=[[i * 100 + 0, 0], [i * 100 + 10, 10]], >>> layer=["M1", "drawing"], >>> netname="in" + str(i), >>> ) >>> template_pins["out" + str(i)] = Pin( >>> xy=[[i * 100 + 90, 90], [i * 100 + 90, 100]], >>> layer=["M1", "drawing"], >>> netname="out" + str(i), >>> ) >>> return template_pins >>> # Create a template >>> pcell_temp = ParameterizedInstanceTemplate( >>> libname="mylib", >>> cellname="mypcelltemplate", >>> bbox_func=pcell_bbox_func, >>> pins_func=pcell_pins_func, >>> ) >>> # Generate an instance for input parameters. >>> pcell_inst_params = {"mult": 4} >>> pcell_inst = pcell_temp.generate( >>> name="mypcellinst", >>> transform="R0", >>> params=pcell_inst_params, >>> ) >>> # display >>> print(pcell_temp) <laygo2.object.template.ParameterizedInstanceTemplate object at 0x000001B1BA91D9C0> name: mypcelltemplate, class: ParameterizedInstanceTemplate, >>> print(pcell_inst) xy: [0, 0], params: {'mult': 4}, size: [400, 100], shape: None, pitch: [400, 100], transform: R0, pins: {'in0': <laygo2.object.physical.Pin object at 0x000001B1BA91FCA0>, 'out0': <laygo2.object.physical.Pin object at 0x000001B1BA91FC70>, 'in1': <laygo2.object.physical.Pin object at 0x000001B1BA91FC10>, 'out1': <laygo2.object.physical.Pin object at 0x000001B1BA91E8C0>, 'in2': <laygo2.object.physical.Pin object at 0x000001B1BA91E890>, 'out2': <laygo2.object.physical.Pin object at 0x000001B1BA91FBE0>, 'in3': <laygo2.object.physical.Pin object at 0x000001B1BA91E7D0>, 'out3': <laygo2.object.physical.Pin object at 0x000001B1BA91E710>},
- height(params=None)#
int: Return the height of the template.
- pins(params=None)[source]#
Return pin dictionary of ParameterizedInstanceTemplate object.
- Parameters:
params (dict) – A dictionary that contains input parameters corresponding to the pin objects to be produced.
- Returns:
dict – input parameters.
- Return type:
A dictionary that contains pin object corresponding to the
Example
>>> import numpy as np >>> from laygo2.object.template import ParameterizedInstanceTemplate >>> from laygo2.object.physical import Pin >>> # bbox computation function. >>> def pcell_bbox_func(params): return np.array([[0, 0], [100 * params["mult"], 100]]) >>> # pin generation function. >>> def pcell_pins_func(params): >>> template_pins = dict() >>> for i in range(params["mult"]): >>> template_pins["in" + str(i)] = Pin( >>> xy=[[i * 100 + 0, 0], [i * 100 + 10, 10]], >>> layer=["M1", "drawing"], >>> netname="in" + str(i), >>> ) >>> template_pins["out" + str(i)] = Pin( >>> xy=[[i * 100 + 90, 90], [i * 100 + 90, 100]], >>> layer=["M1", "drawing"], >>> netname="out" + str(i), >>> ) >>> return template_pins >>> # Create a template >>> pcell_temp = ParameterizedInstanceTemplate( >>> libname="mylib", >>> cellname="mypcelltemplate", >>> bbox_func=pcell_bbox_func, >>> pins_func=pcell_pins_func, >>> ) >>> # Compute bbox for input parameters >>> pcell_inst_params = {"mult": 4} >>> pcell_temp.pins(params=pcell_inst_params) {'in0': <laygo2.object.physical.Pin object at 0x000001B1BA91F7C0>, 'out0': <laygo2.object.physical.Pin object at 0x000001B1BA91E830>, 'in1': <laygo2.object.physical.Pin object at 0x000001B1BA91DAB0>, 'out1': <laygo2.object.physical.Pin object at 0x000001B1BA91E860>, 'in2': <laygo2.object.physical.Pin object at 0x000001B1BA91E560>, 'out2': <laygo2.object.physical.Pin object at 0x000001B1BA91E800>, 'in3': <laygo2.object.physical.Pin object at 0x000001B1BA91E770>, 'out3': <laygo2.object.physical.Pin object at 0x000001B1BA91EA40>}
- size(params=None)#
int: Return the size of the template.
- summarize()#
Return the summary of the template information.
- width(params=None)#
int: Return the width of the template.
- _abc_impl = <_abc._abc_data object>#
- _bbox = None#
- _pins = None#