bag.design.instance

This module defines classes representing various design instances.

Module Contents

Classes

SchInstance

This class represents an instance inside a schematic.

class bag.design.instance.SchInstance(db: bag.design.database.ModuleDB, inst_ptr: pybag.core.PySchInstRef, master: Optional[bag.design.module.Module] = None, prev_name: str = '', dx: int = 0, dy: int = 0)[source]

This class represents an instance inside a schematic.

Parameters:
  • db (ModuleDB) – the design database.

  • inst_ptr (PySchInstRef) – a reference to the actual schematic instance object.

property database: bag.design.database.ModuleDB[source]

the schematic database.

Type:

ModuleDB

property master: Optional[bag.design.module.Module][source]

the master object of this instance.

Type:

Optional[Module]

property master_class: Optional[Type[bag.design.module.Module]][source]

the class object of the master of this instance.

Type:

Optional[Type[Module]]

property lib_name: str[source]

the generator library name.

Type:

str

property cell_name: str[source]

the generator cell name.

Type:

str

property master_cell_name: str[source]

the cell name of the master object

Type:

str

property prev_name: str[source]

the instance name before being arrayed or renamed; empty if instance is not arrayed or renamed.

Type:

str

property dx: int[source]

the X-shift of this instance from the master location

Type:

int

property dy: int[source]

the Y-shift of this instance from the master location

Type:

int

property static: bool[source]

True if this instance points to a static/fixed schematic.

Type:

bool

property width: int[source]

the instance symbol width.

Type:

int

property height: int[source]

the instance symbol height.

Type:

int

property is_valid: bool[source]

True if this instance is valid (i.e. static or has a master.

Type:

bool

property is_primitive: bool[source]

True if this is a primitive (static or in BAG_prim) schematic instance.

Type:

bool

property should_delete: bool[source]

True if this instance should be deleted by the parent.

Type:

bool

property master_key: Optional[Any][source]

A unique key identifying the master object.

Type:

Optional[Any]

design(**kwargs: Any) None[source]

Call the design method on master.

design_model(model_params: bag.util.cache.Param) None[source]

Call design_model method on master.

change_generator(gen_lib_name: str, gen_cell_name: str, static: bool = False, keep_connections: bool = False) None[source]

Change the circuit generator responsible for producing this instance.

Parameter

gen_lib_namestr

new generator library name.

gen_cell_namestr

new generator cell name.

staticbool

True if this is actually a fixed schematic, not a generator.

keep_connectionsbool

True to keep the old connections when the instance master changed.

set_param(key: str, val: Any) None[source]

Sets the parameters of this instance.

Parameters:
  • key (str) – the parameter name.

  • val (Any) – the parameter value.

update_connection(inst_name: str, term_name: str, net_name: str) None[source]

Update connections of this schematic instance.

Parameters:
  • inst_name (str) – The instance name.

  • term_name (str) – The terminal (in other words, port) of the instance.

  • net_name (str) – The net to connect the terminal to.

check_connections()[source]

Check that the connections of this instance is valid.

This method is called by the finalize() method, and checks that the user connected every port of this instance.

get_connection(term_name: str) str[source]

Get the net name connected to the given terminal.

Parameters:

term_name (str) – the terminal name.

Returns:

net_name – the resulting net name. Empty string if given terminal is not found.

Return type:

str

connections() Mapping[str, str][source]

Convert the connections iterator method into a dictionary representation.

Returns:

connections – the connections dictionary

Return type:

Mapping[str, str]

params() Mapping[str, Union[int, float, bool, str]][source]

Convert the params iterator method into a dictionary representation.

Returns:

params – the connections dictionary

Return type:

Mapping[str, Union[int, float, bool, str]]

get_master_lib_name(impl_lib: str) str[source]

Returns the master library name.

the master library could be different than the implementation library in the case of static schematic.

Parameters:

impl_lib (str) – implementation library name.

Returns:

master_lib – the master library name.

Return type:

str