コード例 #1
0
ファイル: __init__.py プロジェクト: LudwigCRON/reflow
def run_sim(files, params):
    # update global variables
    Config.add_configs(os.path.join(TOOLS_DIR, "tools.config"))
    DEFAULT_TMPDIR = utils.get_tmp_folder("sim")
    WAVE_FORMAT = Config.iverilog.get("format")
    WAVE = os.path.join(DEFAULT_TMPDIR, "run.%s" % WAVE_FORMAT)
    # prepare scripts
    flags = prepare(files, params)
    compile(*flags)
    relog.step("Running simulation")
    VVP_FLAGS = []
    if "SIM_FLAGS" in params:
        for flag in params["SIM_FLAGS"]:
            tf = transform_flags(flag)
            if tf and tf[:2] in ("-m", "-M"):
                VVP_FLAGS.append(tf)
    VVP_FLAGS = " ".join(VVP_FLAGS)
    executor.sh_exec(
        "vvp -i %s %s -%s" % (EXE, VVP_FLAGS, WAVE_FORMAT),
        SIM_LOG,
        MAX_TIMEOUT=300,
        SHOW_CMD=True,
    )
    # move the dumpfile to TMPDIR
    if os.path.exists(WAVE):
        os.remove(WAVE)
    if os.path.exists("./dump.%s" % WAVE_FORMAT):
        os.rename("./dump.%s" % WAVE_FORMAT, WAVE)
    return relog.get_stats(SIM_LOG)
コード例 #2
0
def run(asc: str):
    relog.step("Running simulation")
    os.makedirs(DEFAULT_TMPDIR, exist_ok=True)
    # use the appropriate program
    # depending on the platform
    log = asc.replace(".asc", ".log")
    if sys.platform == "darwin":
        ltspice = "/Applications/LTspice.app/Contents/MacOS/LTspice"
    elif sys.platform == "unix" or "linux" in sys.platform:
        ltspice = 'wine64 "%s"' % utils.wine.locate("XVIIx64.exe")
        # to speed up wine
        # wine reg add 'HKEY_CURRENT_USER\Software\Wine\Direct3D' /v MaxVersionGL /t REG_DWORD /d 0x30003 /f
        # winetricks orm=backbuffer glsl=disable for NVIDIA driver
        # do not allow the WM to decorate window
        window_path = io.StringIO()
        executor.sh_exec("winepath -w '%s'" % asc,
                         window_path,
                         NOERR=True,
                         NOOUT=True)
        asc = utils.normpath(window_path.getvalue().strip())
    else:
        ltspice = "XVIIx64.exe"
    # start the simulation
    gen = executor.ish_exec('%s -Run "%s"' % (ltspice, asc),
                            SIM_LOG,
                            MAX_TIMEOUT=300,
                            NOERR=True)
    proc = next(gen)
    # watch the log file to determine when
    # the simulation ends
    sim_done = watch_log(log)
    if proc:
        proc.kill()
    return 0, not sim_done  # relog.get_stats(SIM_LOG)
コード例 #3
0
ファイル: __init__.py プロジェクト: LudwigCRON/reflow
def run_lint(files, params):
    Config.add_config(os.path.join(TOOLS_DIR, "tools.config"))
    WAVE_FORMAT = Config.xcellium.get("format")
    DEFAULT_TMPDIR = utils.get_tmp_folder("lint")
    SRCS = os.path.join(DEFAULT_TMPDIR, "srcs.list")
    PARSER_LOG = os.path.join(DEFAULT_TMPDIR, "parser.log")
    SIM_LOG = os.path.join(DEFAULT_TMPDIR, "sim.log")
    WAVE = os.path.join(DEFAULT_TMPDIR, "run.%s" % WAVE_FORMAT)
    # generate scripts
    gen = prepare(files, params)
    flags = " ".join(chain([gen, "-hal"], Config.ncsim.get("flags").split()))
    # lint
    executor.sh_exec("xrun %s -f %s" % (flags, SRCS),
                     PARSER_LOG,
                     MAX_TIMEOUT=300)
コード例 #4
0
ファイル: __init__.py プロジェクト: LudwigCRON/reflow
def compile(generation, flags):
    # create the executable sim
    relog.step("Compiling files")
    # remove inherited timescale flags
    try:
        executor.sh_exec(
            "iverilog -g%s %s -o %s -c %s" % (generation, flags, EXE, SRCS),
            PARSER_LOG,
            MAX_TIMEOUT=20,
            SHOW_CMD=True,
        )
    # ignore return code error
    # as message is already displayed in stdout
    # and in the log file
    except subprocess.CalledProcessError:
        pass
コード例 #5
0
ファイル: __init__.py プロジェクト: LudwigCRON/reflow
def run_sim(files, params):
    Config.add_config(os.path.join(TOOLS_DIR, "tools.config"))
    WAVE_FORMAT = Config.ncsim.get("format")
    DEFAULT_TMPDIR = utils.get_tmp_folder("sim")
    SRCS = os.path.join(DEFAULT_TMPDIR, "srcs.list")
    PARSER_LOG = os.path.join(DEFAULT_TMPDIR, "parser.log")
    SIM_LOG = os.path.join(DEFAULT_TMPDIR, "sim.log")
    WAVE = os.path.join(DEFAULT_TMPDIR, "run.%s" % WAVE_FORMAT)
    # generate scripts
    gen = prepare(files, params)
    flags = " ".join(chain([gen], Config.ncsim.get("flags").split()))
    # run simulation
    relog.step("Running simulation")
    executor.sh_exec("irun %s -f %s" % (flags, SRCS),
                     PARSER_LOG,
                     MAX_TIMEOUT=300)
コード例 #6
0
ファイル: __init__.py プロジェクト: LudwigCRON/reflow
def run(raw: str):
    relog.step("Open waveforms")
    os.makedirs(DEFAULT_TMPDIR, exist_ok=True)
    # use the appropriate program
    # depending on the platform
    if sys.platform == "darwin":
        ltspice = "/Applications/LTspice.app/Contents/MacOS/LTspice"
    elif sys.platform == "unix" or "linux" in sys.platform:
        ltspice = 'wine64 "%s"' % utils.wine.locate("XVIIx64.exe")
        window_path = io.StringIO()
        executor.sh_exec("winepath -w '%s'" % raw,
                         window_path,
                         NOERR=True,
                         NOOUT=True)
        raw = window_path.getvalue().strip().replace("\\", "/")
    else:
        ltspice = "XVIIx64.exe"
    # start the simulation
    print(raw)
    executor.sh_exec("%s %s" % (ltspice, raw), SIM_LOG, NOERR=True)
    return 0, 0  # relog.get_stats(SIM_LOG)
コード例 #7
0
def main(format: str = "vcd"):
    relog.step("Search waveforms")
    vcd_path = None
    view = None
    for path in Path(DEFAULT_TMPDIR).rglob("**/*.%s" % format):
        vcd_path = path
        break
    relog.info(vcd_path)
    for path in Path(os.path.dirname(DEFAULT_TMPDIR)).rglob("**/*.gtkw"):
        view = path
        break
    relog.info("loading view %s" % view)
    # define what to open
    file_to_read = view if view else vcd_path
    relog.step("Open waveforms")
    if sys.platform == "linux" or sys.platform == "linux2":
        # linux
        executor.sh_exec("gtkwave '%s'" % file_to_read,
                         MAX_TIMEOUT=-1,
                         SHELL=False)
    elif sys.platform == "darwin":
        # OS X
        executor.sh_exec("open -a gtkwave '%s'" % file_to_read,
                         MAX_TIMEOUT=-1,
                         SHELL=False)
    elif sys.platform == "win32":
        # Windows...
        executor.sh_exec("gtkwave '%s'" % file_to_read,
                         MAX_TIMEOUT=-1,
                         SHELL=False)
    else:
        relog.error("Unknown operating system")
    return (0, 0)
コード例 #8
0
def main(files, PARAMS):
    # top module
    top = "tb"
    if os.path.isfile(PARAMS["TOP_MODULE"]):
        top, _, _, _ = verilog.find_modules(PARAMS["TOP_MODULE"])[0]
    # generate script to load files and add parameters
    n_i = prepare(files, PARAMS)
    # scoring
    relog.step("Scoring simulations")
    for k in range(n_i):
        COV_K_DATABASE = COV_DATABASE.replace(".cdd", "_%d.cdd" % k)
        executor.sh_exec(
            "covered score -f %s -o %s" % (SCORE_SCRIPT % k, COV_K_DATABASE),
            COV_LOG,
            mode="a+",
            MAX_TIMEOUT=300,
            SHOW_CMD=True,
        )
    # register dbs
    with open(DB_LIST, "w+") as list:
        list.writelines(
            [COV_DATABASE.replace(".cdd", "_%d.cdd" % k) for k in range(n_i)])
    # merging into first db
    if n_i > 1:
        relog.step("Merging")
        executor.sh_exec(
            "covered merge -f %s" % DB_LIST,
            COV_LOG,
            "a+",
            MAX_TIMEOUT=240,
            SHOW_CMD=True,
        )
    # reporting
    relog.step("Generating report")
    executor.sh_exec("covered report -m ltcfram -d s %s" %
                     COV_DATABASE.replace(".cdd", "_0.cdd"),
                     COV_REPORT,
                     MAX_TIMEOUT=30,
                     SHOW_CMD=False)
    return relog.get_stats(COV_LOG)
コード例 #9
0
def run():
    relog.step("Running synthesis")
    executor.sh_exec("yosys %s" % SYNTH_SCRIPT, SYNTH_LOG, MAX_TIMEOUT=300)
コード例 #10
0
def run(cwd,
        batch,
        sim_only: bool = False,
        cov_only: bool = False,
        lint_only: bool = False):
    N = len(batch.sections())
    TMP_DIR = utils.get_tmp_folder()
    # create directory for simulation
    for k, rule in enumerate(batch):
        if batch.has_option(rule, "__path__"):
            relog.info(f"[{k}/{N}] Run simulation {rule}")
            p = utils.normpath(os.path.join(cwd, batch.get(rule, "__path__")))
            s = eval(batch.get(rule, "__sim_type__"))
            o = utils.normpath(os.path.join(TMP_DIR, rule))
            l = utils.normpath(os.path.join(o, "Sources.list"))
            b = utils.normpath(os.path.join(p, "Batch.list"))
            os.makedirs(o, exist_ok=True)
            if not os.path.exists(b):
                # create the Sources.list
                with open(l, "w+") as fp:
                    path = batch.get(rule, "__path__")
                    dedent = "".join(["../"] * (2 + path.count("/")))
                    fp.write("%s\n" %
                             utils.normpath(os.path.join(dedent, path)))
                    for option in batch.options(rule):
                        if not option.startswith("__"):
                            values = batch.get(rule, option, raw=True)
                            if "[" in values:
                                values = eval(values)
                                fp.write(f"{option}={' '.join(values)}\n")
                            else:
                                fp.write(f"{option}={values}\n")
            # select which simulations should be performed
            batch_options = [
                "sim",
                "cov" if cov_only else "",
                "lint" if lint_only else "",
            ]
            sim_only, cov_only, lint_only = (
                sim_only and not cov_only and not lint_only,
                cov_only and not sim_only and not lint_only,
                lint_only and not cov_only and not sim_only,
            )
            if not sim_only and not cov_only and not lint_only:
                sim_only, cov_only, lint_only = True, True, True
            # run the simulations
            run_path = utils.normpath(os.getenv("REFLOW") + "/envs/bin/run")
            if os.path.exists(b):
                for batch_option in batch_options:
                    if batch_option:
                        executor.sh_exec(
                            "python3 '%s' batch %s" % (run_path, batch_option),
                            CWD=p,
                            ENV=os.environ.copy(),
                        )
            else:
                if sim_only and s in [SimType.SIMULATION, SimType.ALL]:
                    executor.sh_exec(
                        "python3 '%s' sim" % run_path,
                        CWD=o,
                        ENV=os.environ.copy(),
                        SHELL=True,
                    )
                if cov_only and s in [SimType.COVERAGE, SimType.ALL]:
                    executor.sh_exec(
                        "python3 '%s' cov" % run_path,
                        CWD=o,
                        ENV=os.environ.copy(),
                        SHELL=True,
                    )
                if lint_only and s in [SimType.LINT, SimType.ALL]:
                    executor.sh_exec(
                        "python3 '%s' lint" % run_path,
                        CWD=o,
                        ENV=os.environ.copy(),
                        SHELL=True,
                    )
コード例 #11
0
ファイル: verilator.py プロジェクト: LudwigCRON/reflow
     fp.write("+verilog2001ext+v\n")
     fp.write("+1800-2017ext+sv\n")
     for file in FILES:
         fp.write("%s\n" % file)
 # estimate appropriate flags
 assertions = "--assert" if any(["ASSERT" in m for m in MIMES]) else ""
 # create the executable sim
 relog.step("Compiling files")
 # run the simulation
 if "--lint-only" not in sys.argv:
     relog.step("Running simulation")
     executor.sh_exec(
         "perl %s %s --vpi -cc --trace --threads 4 -O3 -Wall -f \"%s\" -exe %s" % (
             verilator,
             assertions,
             SRCS,
             EXE
         ),
         PARSER_LOG,
         MAX_TIMEOUT=300
     )
     # move the dumpfile to TMPDIR
     if os.path.exists(WAVE):
         os.remove(WAVE)
     if os.path.exists("./dump.vcd"):
         os.rename("./dump.vcd", WAVE)
 # linting files
 else:
     relog.step("Linting files")
     executor.sh_exec(
         "perl %s --lint-only -Wall -f %s" % (verilator, SRCS),
         PARSER_LOG,