bag.util.cache
This module defines classes used to cache existing design masters
Module Contents
Classes
A design master instance. |
|
A database of existing design masters. |
Functions
|
|
|
Attributes
- bag.util.cache.format_cell_name(cell_name: str, rename_dict: Dict[str, str], name_prefix: str, name_suffix: str, exact_cell_names: Set[str], supply_wrap_mode: pybag.enum.SupplyWrapMode) str [source]
- class bag.util.cache.DesignMaster(master_db: MasterDB, params: bag.util.immutable.Param, log_file: str, log_level: pybag.enum.LogLevel = LogLevel.DEBUG, *, key: Any = None, copy_state: Optional[Dict[str, Any]] = None)[source]
Bases:
bag.util.logging.LoggingBase
A design master instance.
This class represents a design master in the design database.
- Parameters:
master_db (MasterDB) – the master database.
params (Param) – the parameters dictionary.
log_file (str) – the log file path.
log_level (LogLevel) – the logging level.
key (Any) – If not None, the unique ID for this master instance.
copy_state (Optional[Dict[str, Any]]) – If not None, set content of this master from this dictionary.
- classmethod populate_params(table: Mapping[str, Any], params_info: Mapping[str, str], default_params: Mapping[str, Any]) bag.util.immutable.Param [source]
Fill params dictionary with values from table and default_params
- classmethod compute_unique_key(params: bag.util.immutable.Param) Any [source]
Returns a unique hashable object (usually tuple or string) that represents this instance.
- Parameters:
params (Param) – the parameters object. All default and hidden parameters have been processed already.
- Returns:
unique_id – a hashable unique ID representing the given parameters.
- Return type:
Any
- classmethod process_params(params: Mapping[str, Any]) Tuple[bag.util.immutable.Param, Any] [source]
Process the given parameters dictionary.
This method computes the final parameters dictionary from the user given one by filling in default and hidden parameter values, and also compute the unique ID of this master instance.
- Parameters:
params (Mapping[str, Any]) – the parameter dictionary specified by the user.
- Returns:
unique_id – a hashable unique ID representing the given parameters.
- Return type:
Any
- get_copy_with(new_params: bag.util.immutable.Param) MasterType [source]
Returns a copy of this master instance.
- classmethod to_immutable_id(val: Any) Any [source]
Convert the given object to an immutable type for use as keys in dictionary.
- abstract classmethod get_params_info() Mapping[str, str] [source]
Returns a dictionary from parameter names to descriptions.
- classmethod get_default_param_values() Mapping[str, Any] [source]
Returns a dictionary containing default parameter values.
Override this method to define default parameter values. As good practice, you should avoid defining default values for technology-dependent parameters (such as channel length, transistor width, etc.), but only define default values for technology-independent parameters (such as number of tracks).
- Returns:
default_params – dictionary of default parameter values.
- Return type:
Mapping[str, Any]
Returns a dictionary of hidden parameter values.
hidden parameters are parameters are invisible to the user and only used and computed internally.
- Returns:
hidden_params – dictionary of hidden parameter values.
- Return type:
Dict[str, Any]
- abstract get_master_basename() str [source]
Returns the base name to use for this instance.
- Returns:
basename – the base name for this instance.
- Return type:
- abstract get_content(output_type: pybag.enum.DesignOutput, rename_dict: Dict[str, str], name_prefix: str, name_suffix: str, shell: bool, exact_cell_names: Set[str], supply_wrap_mode: pybag.enum.SupplyWrapMode) Tuple[str, Any] [source]
Returns the content of this master instance.
- Parameters:
output_type (DesignOutput) – the output type.
name_prefix (str) – the name prefix.
name_suffix (str) – the name suffix.
shell (bool) – True if we’re just producing a shell content (i.e. just top level block).
exact_cell_names (Set[str]) – set of cell names to keep exact (don’t add prefix and suffix)
supply_wrap_mode (SupplyWrapMode) – the netlisting supply wrap mode.
- Returns:
cell_name (str) – the master cell name.
content (Any) – the master content data structure.
- class bag.util.cache.MasterDB(lib_name: str, log_file: str, prj: Optional[bag.core.BagProject] = None, name_prefix: str = '', name_suffix: str = '', log_level: pybag.enum.LogLevel = LogLevel.DEBUG)[source]
Bases:
bag.util.logging.LoggingBase
A database of existing design masters.
This class keeps track of existing design masters and maintain design dependency hierarchy.
- Parameters:
lib_name (str) – the library to put all generated templates in.
log_file (str) – the log file path.
prj (Optional[BagProject]) – the BagProject instance.
name_prefix (str) – generated master name prefix.
name_suffix (str) – generated master name suffix.
log_level (LogLevel) – the logging level.
- property prj: bag.core.BagProject[source]
- abstract property tech_info: bag.layout.tech.TechInfo[source]
the TechInfo object.
- Type:
- create_masters_in_db(output: pybag.enum.DesignOutput, lib_name: str, content_list: List[Any], top_list: List[str], supply_wrap_mode: pybag.enum.SupplyWrapMode = SupplyWrapMode.NONE, debug: bool = False, **kwargs: Any) None [source]
Create the masters in the design database.
- Parameters:
output (DesignOutput) – the output type.
lib_name (str) – library to create the designs in.
content_list (Sequence[Any]) – a list of the master contents. Must be created in this order.
top_list (List[str]) – list of top level cells.
supply_wrap_mode (SupplyWrapMode) – the supply wrapping mode.
debug (bool) – True to print debug messages
**kwargs (Any) – parameters associated with the given output type.
- new_master(gen_cls: Type[MasterType], params: Optional[Mapping[str, Any]] = None, debug: bool = False, **kwargs) MasterType [source]
Create a generator instance.
- Parameters:
- Returns:
master – the generator instance.
- Return type:
MasterType
- instantiate_master(output: pybag.enum.DesignOutput, master: DesignMaster, top_cell_name: str = '', **kwargs) None [source]
Instantiate the given master.
- Parameters:
output (DesignOutput) – the design output type.
master (DesignMaster) – the
TemplateBase
to instantiate.top_cell_name (str) – name of the top level cell. If empty, a default name is used.
**kwargs (Any) – optional arguments for batch_output().
- batch_output(output: pybag.enum.DesignOutput, info_list: Sequence[Tuple[DesignMaster, str]], debug: bool = False, rename_dict: Optional[Dict[str, str]] = None, **kwargs: Any) None [source]
create all given masters in the database.
- Parameters:
output (DesignOutput) – The output type.
info_list (Sequence[Tuple[DesignMaster, str]]) – Sequence of (master, cell_name) tuples to instantiate. Use empty string cell_name to use default names.
debug (bool) – True to print debugging messages
rename_dict (Optional[Dict[str, str]]) – optional master cell renaming dictionary.
**kwargs (Any) – parameters associated with the given output type.
- _batch_output_helper(info_dict: Dict[str, DesignMaster], master: DesignMaster, rename: Dict[str, str], rev_rename: Dict[str, str], used_names: Set[str]) None [source]
Helper method for batch_layout().
- Parameters:
info_dict (Dict[str, DesignMaster]) – dictionary from existing master cell name to master objects.
master (DesignMaster) – the master object to create.