bag.core
This is the core bag module.
Module Contents
Classes
The main bag controller class. |
- class bag.core.BagProject[source]
The main bag controller class.
This class mainly stores all the user configurations, and issue high level bag commands.
- property tech_info: bag.layout.tech.TechInfo[source]
the TechInfo object.
- Type:
- property grid: bag.layout.routing.grid.RoutingGrid[source]
the global routing grid object.
- Type:
- property sim_access: bag.simulation.base.SimAccess[source]
- property em_sim_access: Optional[bag.simulation.base.EmSimAccess][source]
- import_sch_cellview(lib_name: str, cell_name: str, view_name: str = 'schematic') None [source]
Import the given schematic and symbol template into Python.
This import process is done recursively.
- import_design_library(lib_name: str, view_name: str = 'schematic') None [source]
Import all design templates in the given library from CAD database.
- get_cells_in_library(lib_name: str) Sequence[str] [source]
Get a list of cells in the given library.
Returns an empty list if the given library does not exist.
- make_template_db(log_file: str, impl_lib: str, **kwargs: Any) bag.layout.template.TemplateDB [source]
Create and return a new TemplateDB instance.
- make_module_db(log_file: str, impl_lib: str, **kwargs: Any) bag.design.database.ModuleDB [source]
Create and return a new ModuleDB instance.
- make_dsn_db(root_dir: pathlib.Path, log_file: str, impl_lib: str, sch_db: Optional[bag.design.database.ModuleDB] = None, lay_db: Optional[bag.layout.template.TemplateDB] = None, **kwargs: Any) bag.simulation.cache.DesignDB [source]
- make_sim_db(dsn_dir: pathlib.Path, log_file: str, impl_lib: str, dsn_options: Optional[Mapping[str, Any]] = None, **kwargs: Any) bag.simulation.cache.SimulationDB [source]
- get_root_path(root_dir: Union[str, pathlib.Path], use_sim_path: bool = True) pathlib.Path [source]
- static get_dut_class_info(specs: Mapping[str, Any]) Tuple[bool, Optional[Type[bag.layout.template.TemplateBase]], Optional[Type[bag.design.module.Module]]] [source]
Returns information about the DUT generator class.
- Parameters:
specs (Param) – The generator specs.
- Returns:
is_lay (bool) – True if the DUT generator is a layout generator, False if schematic generator.
lay_cls (Optional[Type[TemplateBase]]) – The DUT layout generator class, if applicable. If schematic generator, then evaluates to None.
sch_cls (Optional[Type[Module]]) – The DUT schematic generator class. If sch_class is not specified in specs, then evaluates to None.
- generate_cell(specs: Dict[str, Any], raw: bool = False, gen_lay: bool = True, gen_sch: bool = True, run_drc: bool = False, run_lvs: bool = False, run_rcx: bool = False, lay_db: Optional[bag.layout.template.TemplateDB] = None, sch_db: Optional[bag.design.database.ModuleDB] = None, gen_lef: bool = False, cv_info_out: Optional[List[pybag.core.PySchCellViewInfo]] = None, sim_netlist: bool = False, flat: bool = False, gen_hier: bool = False, gen_model: bool = False, mismatch: bool = False, gen_shell: bool = False, export_lay: bool = False, gen_netlist: bool = False) str [source]
Generate layout/schematic of a given cell from specification file.
- Parameters:
specs (Dict[str, Any]) –
the specification dictionary. Some non-obvious parameters:
- paramsDict[str, Any]
If layout generator is given, this is the layout parameters. Otherwise this is the schematic parameters.
- netlist_filestr
If not empty, we will create a netlist file with this name (even if raw = False). if sim_netlist is True, this will be a simulation netlist.
- model_filestr
the behavioral model filename if gen_model = True.
- gds_filestr
override the default GDS layout file name. Note that specifying this entry does not mean a GDS file will be created, you must set raw = True or gen_gds = True.
- rcx_paramsOptional[Dict[str, Any]]
Extra rcx parameters that users can override.
raw (bool) – True to generate GDS and netlist files instead of OA cellviews.
gen_lay (bool) – True to generate layout.
gen_sch (bool) – True to generate schematics.
run_drc (bool) – True to run DRC.
run_lvs (bool) – True to run LVS.
run_rcx (bool) – True to run RCX.
lay_db (Optional[TemplateDB]) – the layout database.
sch_db (Optional[ModuleDB]) – the schematic database.
gen_lef (bool) – True to create LEF file.
cv_info_out (Optional[List[PySchCellViewInfo]] = None) – If given cellview information objects will be appended to this list.
sim_netlist (bool) – True to return a simulation netlist.
flat (bool) – True to generate flat netlist.
gen_hier (bool) – True to write the system verilog modeling hierarchy in a yaml file.
gen_model (bool) – True to generate behavioral models
mismatch (bool) – True to add mismatch voltages
gen_shell (bool) – True to generate verilog shell file.
export_lay (bool) – True to export layout file even in non-raw mode.
gen_netlist (bool) – True to generate netlist even in non-raw mode.
- Returns:
rcx_netlist – the extraction netlist. Empty on error or if extraction is not run.
- Return type:
- extract_cell(lib_name: str, cell_name: str, extract_type: Optional[str], extract_corner: Optional[str]) None [source]
- replace_dut_in_wrapper(params: Mapping[str, Any], dut_lib: str, dut_cell: str) Mapping[str, Any] [source]
- simulate_cell(specs: Dict[str, Any], extract: bool = True, gen_tb: bool = True, simulate: bool = True, mismatch: bool = False, raw: bool = True, lay_db: Optional[bag.layout.template.TemplateDB] = None, sch_db: Optional[bag.design.database.ModuleDB] = None) str [source]
Generate and simulate a single design.
This method only works for simulating a single cell (or a wrapper around a single cell). If you need to simulate multiple designs together, use simulate_config().
- Parameters:
specs (Dict[str, Any]) –
the specification dictionary. Important entries are:
- use_netliststr
If specified, use this netlist file as the DUT netlist, and only generate the testbench and simulation netlists. If specified but the netlist does not exist, or the PySchCellViewInfo yaml file does not exist in the same directory, we will still generate the DUT, but the resulting netlist/PySchCellViewInfo object will be saved to this location
extract (bool) – True to generate extracted netlist.
gen_tb (bool) –
True to generate the DUT/testbench/simulation netlists.
If False, we will simply grab the final simulation netlist and simulate it. This means you can quickly simulate a previously generated netlist with manual modifications.
simulate (bool) –
True to run simulation.
If False, we will only generate the netlists.
mismatch (bool) – If True mismatch voltage sources are added to the netlist and simulation is done with those in place
raw (bool) – True to generate GDS and netlist files instead of OA cellviews.
lay_db (Optional[TemplateDB]) – the layout database.
sch_db (Optional[ModuleDB]) – the schematic database.
- Returns:
sim_result – simulation result file name.
- Return type:
- measure_cell(specs: Mapping[str, Any], extract: bool = False, force_sim: bool = False, force_extract: bool = False, gen_cell: bool = False, gen_cell_dut: bool = False, gen_cell_tb: bool = False, fake: bool = False, log_level: pybag.enum.LogLevel = LogLevel.DEBUG) None [source]
- measure_cell_old(specs: Dict[str, Any], gen_dut: bool = True, load_from_file: bool = False, extract: bool = True, mismatch: bool = False, sch_db: Optional[bag.design.database.ModuleDB] = None, cv_info_list: Optional[List[pybag.core.PySchCellViewInfo]] = None) Dict[str, Any] [source]
Generate and simulate a single design.
This method only works for simulating a single cell (or a wrapper around a single cell). If you need to simulate multiple designs together, use simulate_config().
- Parameters:
specs (Dict[str, Any]) –
the specification dictionary. Important entries are:
- use_netliststr
If specified, use this netlist file as the DUT netlist, and only generate the testbench and simulation netlists.
gen_dut (bool) – True to generate DUT.
load_from_file (bool) – True to load from file.
extract (bool) – True to run extracted simulation.
mismatch (bool) – If True mismatch voltage sources are added to the netlist and simulation is done with those in place
sch_db (Optional[ModuleDB]) – the schematic database.
cv_info_list (Optional[List[PySchCellViewInfo]]) – Optional cellview information objects.
- Returns:
meas_result – measurement results dictionary.
- Return type:
Dict[str, Any]
- run_em_cell(specs: Mapping[str, Any], force_sim: bool = False, log_level: pybag.enum.LogLevel = LogLevel.DEBUG) None [source]
- create_library(lib_name: str, lib_path: str = '') None [source]
Create a new library if one does not exist yet.
- instantiate_schematic(lib_name: str, content_list: Sequence[Any], lib_path: str = '') None [source]
Create the given schematic contents in CAD database.
NOTE: this is BAG’s internal method. To create schematics, call batch_schematic() instead.
- instantiate_layout_pcell(lib_name: str, cell_name: str, inst_lib: str, inst_cell: str, params: Dict[str, Any], pin_mapping: Optional[Dict[str, str]] = None, view_name: str = 'layout') None [source]
Create a layout cell with a single pcell instance.
- Parameters:
lib_name (str) – layout library name.
cell_name (str) – layout cell name.
inst_lib (str) – pcell library name.
inst_cell (str) – pcell cell name.
params (Dict[str, Any]) – the parameter dictionary.
pin_mapping (Optional[Dict[str, str]]) – the pin renaming dictionary.
view_name (str) – layout view name, default is “layout”.
- instantiate_layout(lib_name: str, content_list: Sequence[Any], lib_path: str = '', view: str = 'layout') None [source]
Create a batch of layouts.
- release_write_locks(lib_name: str, cell_view_list: Sequence[Tuple[str, str]]) None [source]
Release write locks from all the given cells.
- refresh_cellviews(lib_name: str, cell_view_list: Sequence[Tuple[str, str]]) None [source]
Refresh the given cellviews in the database.
- perform_checks_on_cell(lib_name: str, cell_name: str, view_name: str) None [source]
Perform checks on the given cell.
- run_drc(lib_name: str, cell_name: str, **kwargs: Any) Tuple[bool, str] [source]
Run DRC on the given cell.
- run_lvs(lib_name: str, cell_name: str, **kwargs: Any) Tuple[bool, str] [source]
Run LVS on the given cell.
- run_rcx(lib_name: str, cell_name: str, params: Optional[Mapping[str, Any]] = None, **kwargs: Any) Tuple[str, str] [source]
run RC extraction on the given cell.
- Parameters:
- Returns:
netlist (str) – The RCX netlist file name. empty if RCX failed.
log_fname (str) – RCX log file name.
- generate_lef(impl_lib: str, impl_cell: str, verilog_path: pathlib.Path, lef_path: pathlib.Path, run_path: pathlib.Path, options: Dict[str, Any]) bool [source]
- import_layout(in_file: str, lib_name: str, cell_name: str, **kwargs: Any) str [source]
import layout.
- export_layout(lib_name: str, cell_name: str, out_file: str, **kwargs: Any) str [source]
export layout.
- batch_export_layout(info_list: Sequence[Tuple[Any, Ellipsis]]) Optional[Sequence[str]] [source]
Export layout of all given cells
- Parameters:
info_list –
list of cell information. Each element is a tuple of:
- lib_namestr
library name.
- cell_namestr
cell name.
- out_filestr
layout output file name.
- view_namestr
layout view name. Optional.
- paramsOptional[Dict[str, Any]]
optional export parameter values.
- Returns:
results – If task is cancelled, return None. Otherwise, this is a list of log file names.
- Return type:
Optional[Sequence[str]]
- async async_run_lvs(lib_name: str, cell_name: str, **kwargs: Any) Tuple[bool, str] [source]
A coroutine for running LVS.
- async async_run_rcx(lib_name: str, cell_name: str, params: Optional[Dict[str, Any]] = None) Tuple[str, str] [source]
A coroutine for running RCX.
- create_schematic_from_netlist(netlist: str, lib_name: str, cell_name: str, sch_view: Optional[str] = None, **kwargs: Any) None [source]
Create a schematic from a netlist.
This is mainly used to create extracted schematic from an extracted netlist.