ParameterizedInstanceTemplate class#
- class laygo2.object.template.ParameterizedInstanceTemplate(libname, cellname, bbox_func=None, pins_func=None)[source]#
Bases:
laygo2.object.template.core.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.
Notes
(Korean) ParameterizedInstanceTemplate 클래스는 입력 파라미터에 따라 크기와 pin 정보가 가변하는 인스턴스를 생성하는 템플릿을 구현한다.
Public Data Attributes:
The libname of the instance to be generated.
The cellname of the instance to be generated.
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__
(libname, cellname[, bbox_func, ...])Constructor of ParameterizedInstanceTemplate class.
__str__
()Return a string representation of this template's information.
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])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.
- __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>},
Notes
(Korean) ParameterizedInstanceTemplate 클래스의 생성자함수.
- 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]])
Notes
(Korean) ParameterizedInstanceTemplate 객체의 bbox.
- 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>},
Notes
(Korean) 템플릿으로부터 입력 파라미터에 따른 Instance 객체 생성.
- 파라미터
name(str): 생성할 인스턴스의 이름.
shape(numpy.ndarray): (optional) 생성할 객체의 배열 shape.
pitch(numpy.ndarray): (optional) 생성할 객체 간의 간격.
params(dict) : 개체의 속성이 담긴 dictionary.
transform(str): 생성할 개체의 변환 속성.
- 반환값
laygo2.Instance: 생성된 객체
- 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>}
Notes
(Korean) ParameterizedInstanceTemplate 객체의 pin dictionary 반환.
- 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#