bag.interface.database
This module defines DbAccess, the base class for CAD database manipulation.
Module Contents
Classes
A class that manipulates the CAD database. |
Functions
|
Given a Python dictionary, convert to sorted item list. |
|
Given instance map from DesignModule, format it for database changes. |
|
Process the given reply. |
- bag.interface.database.dict_to_item_list(table: Dict[str, Any]) List[List[str]] [source]
Given a Python dictionary, convert to sorted item list.
- Parameters:
table – a Python dictionary where the keys are strings.
- Returns:
the sorted item list representation of the given dictionary.
- Return type:
assoc_list
- bag.interface.database.format_inst_map(inst_map: Dict[str, Any]) List[List[Any]] [source]
Given instance map from DesignModule, format it for database changes.
- Parameters:
inst_map – the instance map created by DesignModule.
- Returns:
the database change instance map.
- Return type:
ans
- exception bag.interface.database.VirtuosoException(*args, **kwargs)[source]
Bases:
Exception
Exception raised when Virtuoso returns an error.
- class bag.interface.database.DbAccess(dealer: bag.interface.zmqwrapper.ZMQDealer, tmp_dir: str, db_config: Dict[str, Any], lib_defs_file: str)[source]
Bases:
bag.interface.base.InterfaceBase
,abc.ABC
A class that manipulates the CAD database.
- Parameters:
dealer (Optional[ZMQDealer]) – an optional socket that can be used to communicate with the CAD database.
tmp_dir (str) – temporary file directory for DbAccess.
db_config (Dict[str, Any]) – the database configuration dictionary.
lib_defs_file (str) – name of the file that contains generator library names.
- abstract get_exit_object() Any [source]
Returns an object to send to the server to shut it down.
Return None if this option is not supported.
- abstract get_cells_in_library(lib_name: str) List[str] [source]
Get a list of cells in the given library.
Returns an empty list if the given library does not exist.
- abstract create_library(lib_name: str, lib_path: str = '') None [source]
Create a new library if one does not exist yet.
- abstract configure_testbench(tb_lib: str, tb_cell: str) Tuple[str, List[str], Dict[str, str], Dict[str, str]] [source]
Update testbench state for the given testbench.
This method fill in process-specific information for the given testbench.
- Parameters:
- Returns:
cur_env (str) – the current simulation environment.
envs (List[str]) – a list of available simulation environments.
parameters (Dict[str, str]) – a list of testbench parameter values, represented as string.
outputs (Dict[str, str]) – a dictionary of output expressions
- abstract get_testbench_info(tb_lib: str, tb_cell: str) Tuple[List[str], List[str], Dict[str, str], Dict[str, str]] [source]
Returns information about an existing testbench.
- Parameters:
- Returns:
cur_envs (List[str]) – the current simulation environments.
envs (List[str]) – a list of available simulation environments.
parameters (Dict[str, str]) – a list of testbench parameter values, represented as string.
outputs (Dict[str, str]) – a list of testbench output expressions.
- abstract update_testbench(lib: str, cell: str, parameters: Dict[str, str], sim_envs: Sequence[str], config_rules: Sequence[List[str]], env_parameters: Sequence[List[Tuple[str, str]]]) None [source]
Update the given testbench configuration.
- Parameters:
lib (str) – testbench library.
cell (str) – testbench cell.
sim_envs (Sequence[str]) – list of enabled simulation environments.
config_rules (Sequence[List[str]]) – config view mapping rules, list of (lib, cell, view) rules.
env_parameters (Sequence[List[Tuple[str, str]]]) – list of param/value list for each simulation environment.
- abstract instantiate_layout_pcell(lib_name: str, cell_name: str, view_name: str, inst_lib: str, inst_cell: str, params: Dict[str, Any], pin_mapping: Dict[str, str]) None [source]
Create a layout cell with a single pcell instance.
- abstract create_schematics(lib_name: str, sch_view: str, sym_view: str, content_list: Sequence[Any], lib_path: str = '') None [source]
Create the given schematics in CAD database.
Precondition: the library already exists, all cellviews are writable (i.e. they have been closed already).
- Parameters:
- abstract create_layouts(lib_name: str, view: str, content_list: Sequence[Any]) None [source]
Create the given layouts in CAD database.
Precondition: the library already exists, all cellviews are writable (i.e. they have been closed already).
- abstract release_write_locks(lib_name: str, cell_view_list: Sequence[Tuple[str, str]]) None [source]
Release write locks from all the given cells.
- abstract refresh_cellviews(lib_name: str, cell_view_list: Sequence[Tuple[str, str]]) None [source]
Refresh the given cellviews in the database.
- abstract perform_checks_on_cell(lib_name: str, cell_name: str, view_name: str) None [source]
Perform checks on the given cell.
- abstract create_schematic_from_netlist(netlist: str, lib_name: str, cell_name: str, sch_view: str = '', **kwargs: Any) None [source]
Create a schematic from a netlist.
This is mainly used to create extracted schematic from an extracted netlist.
- abstract create_verilog_view(verilog_file: str, lib_name: str, cell_name: str, **kwargs: Any) None [source]
Create a verilog view for mix-signal simulation.
- abstract import_sch_cellview(lib_name: str, cell_name: str, view_name: str) None [source]
Recursively import the given schematic and symbol cellview.
- abstract import_design_library(lib_name: str, view_name: str) None [source]
Import all design templates in the given library from CAD database.
- abstract import_gds_file(gds_fname: str, lib_name: str, layer_map: str, obj_map: str, grid: bag.layout.routing.grid.RoutingGrid) None [source]
- _eval_skill(expr: str, input_files: Optional[Dict[str, Any]] = None, out_file: Optional[str] = None) str [source]
Send a request to evaluate the given skill expression.
Because Virtuoso has a limit on the input/output data (< 4096 bytes), if your input is large, you need to write it to a file and have Virtuoso open the file to parse it. Similarly, if you expect a large output, you need to make Virtuoso write the result to the file, then read it yourself. The parameters input_files and out_file help you achieve this functionality.
For example, if you need to evaluate “skill_fun(arg fname)”, where arg is a file containing the list [1 2 3], and fname is the output file name, you will call this function with:
expr = “skill_fun({arg} {fname})” input_files = { “arg”: [1 2 3] } out_file = “fname”
the bag server will then a temporary file for arg and fname, write the list [1 2 3] into the file for arg, call Virtuoso, then read the output file fname and return the result.
- Parameters:
expr – the skill expression to evaluate.
input_files – A dictionary of input files content.
out_file – the output file name argument in expr.
- Returns:
a string representation of the result.
- Return type:
result
- Raises:
VirtuosoException : – if virtuoso encounters errors while evaluating the expression.
- get_python_template(lib_name: str, cell_name: str, primitive_table: Dict[str, str]) str [source]
Returns the default Python Module template for the given schematic.
- instantiate_schematic(lib_name: str, content_list: Sequence[Any], lib_path: str = '', sch_view: str = 'schematic', sym_view: str = 'symbol') None [source]
Create the given schematics in CAD database.
- Parameters:
- instantiate_layout(lib_name: str, content_list: Sequence[Any], lib_path: str = '', view: str = 'layout') None [source]
Create a batch of layouts.
- 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.
- 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.
- export_schematic(lib_name: str, cell_name: str, out_file: str, **kwargs: Any) str [source]
Export schematic.
- async async_run_drc(lib_name: str, cell_name: str, **kwargs: Any) Tuple[bool, str] [source]
A coroutine for running DRC.
- 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, **kwargs: Any) Tuple[str, str] [source]
A coroutine for running RCX.
- async async_run_lvl(gds_file: str, ref_file: str, **kwargs: Any) Tuple[bool, str] [source]
A coroutine for running LVL with gds files.
- async async_import_layout(in_file: str, lib_name: str, cell_name: str, **kwargs: Any) str [source]
Import layout.
- async async_export_layout(lib_name: str, cell_name: str, out_file: str, **kwargs: Any) str [source]
Export layout.
- async async_export_schematic(lib_name: str, cell_name: str, out_file: str, **kwargs: Any) str [source]
- add_sch_library(lib_name: str) pathlib.Path [source]