python/src/liberate.py
def _run_liberate(
    candidates: Sequence[Netlist],
    tcl_script: str,
    liberate_dir: str,
    netlist_dir: str,
    liberate_log: str,
    out_dir: str,
    ldb_name: str,
    liberate_cmd: str = LIBERATE_DEFAULT_CMD,
) -> LiberateCompletedProcess:
    """Run Cadence Liberate

    characterizes SPICE (.sp) files and generate Liberty library (.lib or .ldb)
    """

    # TODO: Run setup script before

    if not os.path.isfile(tcl_script):
        raise FileNotFoundError(tcl_script)
    if not os.path.isdir(liberate_dir):
        raise NotADirectoryError(liberate_dir)
    if shutil.which(liberate_cmd) is None:
        error(
            f"'{liberate_cmd}' does not appear to be an executable, "
            + "did you forget to source the setup script?"
        )
        sys.exit()

    if not os.path.isdir(out_dir):
        info(f"Creating output directory {out_dir}")
        os.mkdir(out_dir)

    if not os.path.isdir(netlist_dir):
        info(f"Creating netlist working directory {netlist_dir}")
        os.mkdir(netlist_dir)

    for netlist in candidates:
        netlist_file = File(os.path.join(netlist_dir, netlist.cell_name + ".sp"))
        netlist.persist(netlist_file)

    cell_names = ",".join(tuple(netlist.cell_name for netlist in candidates))

    info("Running liberate.")
    with open(
        file=liberate_log,
        mode="w",
    ) as log_file:  # TODO: use MockFile interface
        r: subprocess.Popen = subprocess.Popen(
            args=[liberate_cmd, tcl_script],
            stderr=subprocess.STDOUT,
            stdout=log_file,
            text=True,
            env={
                **os.environ,
                "NETLIST_DIR": netlist_dir,
                "OUT_DIR": out_dir,
                "CELL_NAMES": cell_names,
                "LDB_NAME": ldb_name,
                "LIBERATE_DIR": liberate_dir,
            },
        )
        _waiting_animation(complete_condition=r.poll)
    # Convert to CompletedProcess so we can check the return code
    results: subprocess.CompletedProcess = subprocess.CompletedProcess(
        args=r.args,
        returncode=r.returncode,
        stdout=r.stdout,
        stderr=r.stderr,
    )
    results.check_returncode()

    return LiberateCompletedProcess(
        args=results.args, returncode=results.returncode, stdout=results.stdout
    )
Run Cadence Liberate

    characterizes SPICE (.sp) files and generate Liberty library (.lib or .ldb)
    
Run Cadence Liberate
characterizes SPICE (.sp) files and generate Liberty library (.lib or .ldb)
Run Cadence Liberate characterizes SPICE ( . sp ) files and generate Liberty library ( . lib or . ldb )
def _run_liberate(
    candidates: Sequence[Netlist],
    tcl_script: str,
    liberate_dir: str,
    netlist_dir: str,
    liberate_log: str,
    out_dir: str,
    ldb_name: str,
    liberate_cmd: str = LIBERATE_DEFAULT_CMD,
) -> LiberateCompletedProcess:
    if not os.path.isfile(tcl_script):
        raise FileNotFoundError(tcl_script)
    if not os.path.isdir(liberate_dir):
        raise NotADirectoryError(liberate_dir)
    if shutil.which(liberate_cmd) is None:
        error(
            f"'{liberate_cmd}' does not appear to be an executable, "
            + "did you forget to source the setup script?"
        )
        sys.exit()
    if not os.path.isdir(out_dir):
        info(f"Creating output directory {out_dir}")
        os.mkdir(out_dir)
    if not os.path.isdir(netlist_dir):
        info(f"Creating netlist working directory {netlist_dir}")
        os.mkdir(netlist_dir)
    for netlist in candidates:
        netlist_file = File(os.path.join(netlist_dir, netlist.cell_name + ".sp"))
        netlist.persist(netlist_file)
    cell_names = ",".join(tuple(netlist.cell_name for netlist in candidates))
    info("Running liberate.")
    with open(
        file=liberate_log,
        mode="w",
    ) as log_file:  
        r: subprocess.Popen = subprocess.Popen(
            args=[liberate_cmd, tcl_script],
            stderr=subprocess.STDOUT,
            stdout=log_file,
            text=True,
            env={
                **os.environ,
                "NETLIST_DIR": netlist_dir,
                "OUT_DIR": out_dir,
                "CELL_NAMES": cell_names,
                "LDB_NAME": ldb_name,
                "LIBERATE_DIR": liberate_dir,
            },
        )
        _waiting_animation(complete_condition=r.poll)
    results: subprocess.CompletedProcess = subprocess.CompletedProcess(
        args=r.args,
        returncode=r.returncode,
        stdout=r.stdout,
        stderr=r.stderr,
    )
    results.check_returncode()
    return LiberateCompletedProcess(
        args=results.args, returncode=results.returncode, stdout=results.stdout
    )
def _run_liberate ( candidates : Sequence [ Netlist ] , tcl_script : str , liberate_dir : str , netlist_dir : str , liberate_log : str , out_dir : str , ldb_name : str , liberate_cmd : str = LIBERATE_DEFAULT_CMD , ) -> LiberateCompletedProcess : if not os . path . isfile ( tcl_script ) : raise FileNotFoundError ( tcl_script ) if not os . path . isdir ( liberate_dir ) : raise NotADirectoryError ( liberate_dir ) if shutil . which ( liberate_cmd ) is None : error ( f"'{liberate_cmd}' does not appear to be an executable, " + "did you forget to source the setup script?" ) sys . exit ( ) if not os . path . isdir ( out_dir ) : info ( f"Creating output directory {out_dir}" ) os . mkdir ( out_dir ) if not os . path . isdir ( netlist_dir ) : info ( f"Creating netlist working directory {netlist_dir}" ) os . mkdir ( netlist_dir ) for netlist in candidates : netlist_file = File ( os . path . join ( netlist_dir , netlist . cell_name + ".sp" ) ) netlist . persist ( netlist_file ) cell_names = "," . join ( tuple ( netlist . cell_name for netlist in candidates ) ) info ( "Running liberate." ) with open ( file = liberate_log , mode = "w" , ) as log_file : r : subprocess . Popen = subprocess . Popen ( args = [ liberate_cmd , tcl_script ] , stderr = subprocess . STDOUT , stdout = log_file , text = True , env = { ** os . environ , "NETLIST_DIR" : netlist_dir , "OUT_DIR" : out_dir , "CELL_NAMES" : cell_names , "LDB_NAME" : ldb_name , "LIBERATE_DIR" : liberate_dir , } , ) _waiting_animation ( complete_condition = r . poll ) results : subprocess . CompletedProcess = subprocess . CompletedProcess ( args = r . args , returncode = r . returncode , stdout = r . stdout , stderr = r . stderr , ) results . check_returncode ( ) return LiberateCompletedProcess ( args = results . args , returncode = results . returncode , stdout = results . stdout )
Run Cadence Liberate
characterizes SPICE (.sp) files and generate Liberty library (.lib or .ldb)
Run Cadence Liberate characterizes SPICE ( . sp ) files and generate Liberty library ( . lib or . ldb )
"""Run Cadence Liberate

    characterizes SPICE (.sp) files and generate Liberty library (.lib or .ldb)
    """ # TODO: Run setup script before # TODO: use MockFile interface # Convert to CompletedProcess so we can check the return code
candidates
Sequence[Netlist]
tcl_script
str
liberate_dir
str
netlist_dir
str
liberate_log
str
out_dir
str
ldb_name
str
liberate_cmd
str