bag.verification.base

This module defines Checker, an abstract base class that handles LVS/RCX.

Module Contents

Classes

Checker

A class that handles DRC/LVS/RCX/LVL.

SubProcessChecker

An implementation of Checker using SubProcessManager.

Functions

get_flow_config(→ Dict[str, Dict[str, Any]])

_process_link_files(→ List[Tuple[pathlib.Path, str]])

class bag.verification.base.Checker(tmp_dir: str)[source]

Bases: abc.ABC

A class that handles DRC/LVS/RCX/LVL.

Parameters:

tmp_dir (str) – temporary directory to save files in.

abstract get_rcx_netlists(lib_name: str, cell_name: str) List[str][source]

Returns a list of generated extraction netlist file names.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell_name

Returns:

netlists – a list of generated extraction netlist file names. The first index is the main netlist.

Return type:

List[str]

abstract async async_run_drc(lib_name: str, cell_name: str, lay_view: str = 'layout', layout: str = '', params: Optional[Dict[str, Any]] = None, run_dir: Union[str, pathlib.Path] = '', **kwargs: Any) Tuple[bool, str][source]

A coroutine for running DRC.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • lay_view (str) – layout view name. Optional.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • params (Optional[Dict[str, Any]]) – optional DRC parameter values.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • success (bool) – True if DRC succeeds.

  • log_fname (str) – DRC log file name.

abstract async async_run_lvs(lib_name: str, cell_name: str, sch_view: str = 'schematic', lay_view: str = 'layout', layout: str = '', netlist: str = '', params: Optional[Dict[str, Any]] = None, run_rcx: bool = False, run_dir: Union[str, pathlib.Path] = '', **kwargs: Any) Tuple[bool, str][source]

A coroutine for running LVS.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • sch_view (str) – schematic view name. Optional.

  • lay_view (str) – layout view name. Optional.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • netlist (str) – the CDL netlist name. If provided, will not try to call tools to generate netlist.

  • params (Optional[Dict[str, Any]]) – optional LVS parameter values.

  • run_rcx (bool) – True if extraction will be ran after LVS.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • success (bool) – True if LVS succeeds.

  • log_fname (str) – LVS log file name.

abstract async async_run_rcx(lib_name: str, cell_name: str, sch_view: str = 'schematic', lay_view: str = 'layout', layout: str = '', netlist: str = '', params: Optional[Dict[str, Any]] = None, run_dir: Union[str, pathlib.Path] = '', **kwargs: Any) Tuple[str, str][source]

A coroutine for running RCX.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • sch_view (str) – schematic view name. Optional.

  • lay_view (str) – layout view name. Optional.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • netlist (str) – the CDL netlist name. If provided, will not try to call tools to generate netlist.

  • params (Optional[Dict[str, Any]]) – optional RCX parameter values.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • netlist (str) – The RCX netlist file name. empty if RCX failed.

  • log_fname (str) – RCX log file name.

abstract async async_run_lvl(gds_file: str, ref_file: str, run_dir: Union[str, pathlib.Path] = '', **kwargs: Any) Tuple[bool, str][source]

A coroutine for running LVL with two gds files.

Parameters:
  • gds_file (str) – name of the current gds to be compared.

  • ref_file (str) – name of the reference gds file.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • success (bool) – True if LVL succeeds.

  • log_fname (str) – LVL log file name.

abstract async async_import_layout(in_file: str, lib_name: str, cell_name: str, view_name: str = 'layout', params: Optional[Dict[str, Any]] = None, **kwargs: Any) str[source]

A coroutine for importing layout.

Parameters:
  • in_file (str) – input file name.

  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – layout view name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

log_fname – log file name.

Return type:

str

abstract async async_export_layout(lib_name: str, cell_name: str, out_file: str, view_name: str = 'layout', params: Optional[Dict[str, Any]] = None, **kwargs: Any) str[source]

A coroutine for exporting layout.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – layout view name.

  • out_file (str) – output file name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

log_fname – log file name.

Return type:

str

abstract async async_export_schematic(lib_name: str, cell_name: str, out_file: str, view_name: str = 'schematic', params: Optional[Dict[str, Any]] = None, **kwargs: Any) str[source]

A coroutine for exporting schematic.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – schematic view name.

  • out_file (str) – output file name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

log_fname – log file name.

Return type:

str

render_file_template(temp_name: str, params: Dict[str, Any]) str[source]

Returns the rendered content from the given template file.

render_string_template(content: str, params: Dict[str, Any]) str[source]

Returns the rendered content from the given template string.

class bag.verification.base.SubProcessChecker(tmp_dir: str, max_workers: int, cancel_timeout: float, mgr_class: Type[bag.concurrent.core.SubProcessManager] = SubProcessManager, mgr_kwargs: Optional[Dict[str, Any]] = None)[source]

Bases: Checker, abc.ABC

An implementation of Checker using SubProcessManager.

Parameters:
  • tmp_dir (str) – temporary file directory.

  • max_workers (int) – maximum number of parallel processes.

  • cancel_timeout (float) – timeout for cancelling a subprocess.

  • mgr_class (Type[SubProcessManager]) – class for subprocess manager. Default is SubProcessManager.

  • mgr_kwargs (Optional[Dict[str, Any]]) – constructor arguments for subprocess manager class. If None, no arguments are passed in. Default is None.

abstract setup_drc_flow(lib_name: str, cell_name: str, lay_view: str = 'layout', layout: str = '', params: Optional[Dict[str, Any]] = None, run_dir: Union[str, pathlib.Path] = '') Sequence[bag.concurrent.core.FlowInfo][source]

This method performs any setup necessary to configure a DRC subprocess flow.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • lay_view (str) – layout view name.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • params (Optional[Dict[str, Any]]) – optional DRC parameter values.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

flow_info – the DRC flow information list. Each element is a tuple of:

argsUnion[str, Sequence[str]]

command to run, as string or list of string arguments.

logstr

log file name.

envOptional[Dict[str, str]]

environment variable dictionary. None to inherit from parent.

cwdOptional[str]

working directory path. None to inherit from parent.

vfunSequence[Callable[[Optional[int], str], Any]]

a function to validate if it is ok to execute the next process. The output of the last function is returned. The first argument is the return code, the second argument is the log file name.

Return type:

Sequence[FlowInfo]

abstract setup_lvs_flow(lib_name: str, cell_name: str, sch_view: str = 'schematic', lay_view: str = 'layout', layout: str = '', netlist: str = '', params: Optional[Dict[str, Any]] = None, run_rcx: bool = False, run_dir: Union[str, pathlib.Path] = '') Sequence[bag.concurrent.core.FlowInfo][source]

This method performs any setup necessary to configure a LVS subprocess flow.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • sch_view (str) – schematic view name.

  • lay_view (str) – layout view name.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • netlist (str) – the CDL netlist name. If provided, will not try to call tools to generate netlist.

  • params (Optional[Dict[str, Any]]) – optional LVS parameter values.

  • run_rcx (bool) – True if extraction will follow LVS.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

flow_info – the LVS flow information list. Each element is a tuple of:

argsUnion[str, Sequence[str]]

command to run, as string or list of string arguments.

logstr

log file name.

envOptional[Dict[str, str]]

environment variable dictionary. None to inherit from parent.

cwdOptional[str]

working directory path. None to inherit from parent.

vfunSequence[Callable[[Optional[int], str], Any]]

a function to validate if it is ok to execute the next process. The output of the last function is returned. The first argument is the return code, the second argument is the log file name.

Return type:

Sequence[FlowInfo]

abstract setup_rcx_flow(lib_name: str, cell_name: str, sch_view: str = 'schematic', lay_view: str = 'layout', layout: str = '', netlist: str = '', params: Optional[Dict[str, Any]] = None, run_dir: Union[str, pathlib.Path] = '') Sequence[bag.concurrent.core.FlowInfo][source]

This method performs any setup necessary to configure a RCX subprocess flow.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • sch_view (str) – schematic view name

  • lay_view (str) – layout view name

  • layout (str) – layout netlist

  • netlist (str) – schematic netlist

  • params (Optional[Dict[str, Any]]) – optional RCX parameter values.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

flow_info – the RCX flow information list. Each element is a tuple of:

argsUnion[str, Sequence[str]]

command to run, as string or list of string arguments.

logstr

log file name.

envOptional[Dict[str, str]]

environment variable dictionary. None to inherit from parent.

cwdOptional[str]

working directory path. None to inherit from parent.

vfunSequence[Callable[[Optional[int], str], Any]]

a function to validate if it is ok to execute the next process. The output of the last function is returned. The first argument is the return code, the second argument is the log file name.

Return type:

Sequence[FlowInfo]

setup_lvl_flow(gds_file: str, ref_file: str, run_dir: Union[str, pathlib.Path] = '') Sequence[bag.concurrent.core.FlowInfo][source]

This method performs any setup necessary to configure a LVL subprocess flow.

Parameters:
  • gds_file (str) – name of the current gds to be compared.

  • ref_file (str) – name of the reference gds file.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

flow_info – the LVL flow information list. Each element is a tuple of:

argsUnion[str, Sequence[str]]

command to run, as string or list of string arguments.

logstr

log file name.

envOptional[Dict[str, str]]

environment variable dictionary. None to inherit from parent.

cwdOptional[str]

working directory path. None to inherit from parent.

vfunSequence[Callable[[Optional[int], str], Any]]

a function to validate if it is ok to execute the next process. The output of the last function is returned. The first argument is the return code, the second argument is the log file name.

Return type:

Sequence[FlowInfo]

abstract setup_import_layout(in_file: str, lib_name: str, cell_name: str, view_name: str = 'layout', params: Optional[Dict[str, Any]] = None) bag.concurrent.core.ProcInfo[source]

This method performs any setup necessary to import layout.

Parameters:
  • in_file (str) – input file name.

  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – layout view name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

  • args (Union[str, Sequence[str]]) – command to run, as string or list of string arguments.

  • log (str) – log file name.

  • env (Optional[Dict[str, str]]) – environment variable dictionary. None to inherit from parent.

  • cwd (Optional[str]) – working directory path. None to inherit from parent.

abstract setup_export_layout(lib_name: str, cell_name: str, out_file: str, view_name: str = 'layout', params: Optional[Dict[str, Any]] = None) bag.concurrent.core.ProcInfo[source]

This method performs any setup necessary to export layout.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • out_file (str) – output file name.

  • view_name (str) – layout view name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

  • args (Union[str, Sequence[str]]) – command to run, as string or list of string arguments.

  • log (str) – log file name.

  • env (Optional[Dict[str, str]]) – environment variable dictionary. None to inherit from parent.

  • cwd (Optional[str]) – working directory path. None to inherit from parent.

abstract setup_export_schematic(lib_name: str, cell_name: str, out_file: str, view_name: str = 'schematic', params: Optional[Dict[str, Any]] = None) bag.concurrent.core.ProcInfo[source]

This method performs any setup necessary to export schematic.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • out_file (str) – output file name.

  • view_name (str) – layout view name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

  • args (Union[str, Sequence[str]]) – command to run, as string or list of string arguments.

  • log (str) – log file name.

  • env (Optional[Dict[str, str]]) – environment variable dictionary. None to inherit from parent.

  • cwd (Optional[str]) – working directory path. None to inherit from parent.

async async_run_drc(lib_name: str, cell_name: str, lay_view: str = 'layout', layout: str = '', params: Optional[Dict[str, Any]] = None, run_dir: Union[str, pathlib.Path] = '', subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) Tuple[bool, str][source]

A coroutine for running DRC.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • lay_view (str) – layout view name. Optional.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • params (Optional[Dict[str, Any]]) – optional DRC parameter values.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • success (bool) – True if DRC succeeds.

  • log_fname (str) – DRC log file name.

async async_run_lvs(lib_name: str, cell_name: str, sch_view: str = 'schematic', lay_view: str = 'layout', layout: str = '', netlist: str = '', params: Optional[Dict[str, Any]] = None, run_rcx: bool = False, run_dir: Union[str, pathlib.Path] = '', subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) Tuple[bool, str][source]

A coroutine for running LVS.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • sch_view (str) – schematic view name. Optional.

  • lay_view (str) – layout view name. Optional.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • netlist (str) – the CDL netlist name. If provided, will not try to call tools to generate netlist.

  • params (Optional[Dict[str, Any]]) – optional LVS parameter values.

  • run_rcx (bool) – True if extraction will be ran after LVS.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • success (bool) – True if LVS succeeds.

  • log_fname (str) – LVS log file name.

async async_run_rcx(lib_name: str, cell_name: str, sch_view: str = 'schematic', lay_view: str = 'layout', layout: str = '', netlist: str = '', params: Optional[Dict[str, Any]] = None, run_dir: Union[str, pathlib.Path] = '', subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) Tuple[str, str][source]

A coroutine for running RCX.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • sch_view (str) – schematic view name. Optional.

  • lay_view (str) – layout view name. Optional.

  • layout (str) – the layout file name. If not empty, will not try to generate the layout file.

  • netlist (str) – the CDL netlist name. If provided, will not try to call tools to generate netlist.

  • params (Optional[Dict[str, Any]]) – optional RCX parameter values.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • netlist (str) – The RCX netlist file name. empty if RCX failed.

  • log_fname (str) – RCX log file name.

async async_run_lvl(gds_file: str, ref_file: str, run_dir: Union[str, pathlib.Path] = '', subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) Tuple[bool, str][source]

A coroutine for running LVL with two gds files.

Parameters:
  • gds_file (str) – name of the current gds to be compared.

  • ref_file (str) – name of the reference gds file.

  • run_dir (Union[str, Path]) – Defaults to empty string. The run directory, use empty string for default.

Returns:

  • success (bool) – True if LVL succeeds.

  • log_fname (str) – LVL log file name.

async async_import_layout(in_file: str, lib_name: str, cell_name: str, view_name: str = 'layout', params: Optional[Dict[str, Any]] = None, subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) str[source]

A coroutine for importing layout.

Parameters:
  • in_file (str) – input file name.

  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – layout view name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

log_fname – log file name.

Return type:

str

async async_export_layout(lib_name: str, cell_name: str, out_file: str, view_name: str = 'layout', params: Optional[Dict[str, Any]] = None, subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) str[source]

A coroutine for exporting layout.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – layout view name.

  • out_file (str) – output file name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

log_fname – log file name.

Return type:

str

async async_export_schematic(lib_name: str, cell_name: str, out_file: str, view_name: str = 'schematic', params: Optional[Dict[str, Any]] = None, subproc_options: Optional[Dict[str, Any]] = None, **kwargs: Any) str[source]

A coroutine for exporting schematic.

Parameters:
  • lib_name (str) – library name.

  • cell_name (str) – cell name.

  • view_name (str) – schematic view name.

  • out_file (str) – output file name.

  • params (Optional[Dict[str, Any]]) – optional export parameter values.

Returns:

log_fname – log file name.

Return type:

str

bag.verification.base.get_flow_config(root_dir: Dict[str, str], template: Dict[str, str], env_vars: Dict[str, Dict[str, str]], link_files: Dict[str, List[str]], params: Dict[str, Dict[str, Any]]) Dict[str, Dict[str, Any]][source]