Skip to content

Commit

Permalink
check repair: include dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Jan 19, 2024
1 parent 2cb81d6 commit 1e2152e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions benchmarks/yosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def _require_yosys():
r = subprocess.run(["yosys", "-version"], check=False, stdout=subprocess.PIPE)
assert r.returncode == 0, f"failed to find yosys {r}"

def _read_sources(sources: list, top: str) -> list:
read_cmd = [f"read_verilog {src.resolve()}" for src in sources]
def _read_sources(sources: list, top: str, include: Path = None) -> list:
if include is None:
read_cmd = [f"read_verilog {src.resolve()}" for src in sources]
else:
read_cmd = [f"read_verilog -I{include.resolve()} {src.resolve()}" for src in sources]
if top is not None:
read_cmd += [f"hierarchy -top {top}"]
return read_cmd
Expand All @@ -69,10 +72,10 @@ def to_btor(working_dir: Path, btor_name: Path, sources: list, top: str = None,
assert btor_name.exists()
return btor_name

def to_gatelevel_netlist(working_dir: Path, output: Path, sources: list, top: str = None, logfile = None, script_out: Path = None):
def to_gatelevel_netlist(working_dir: Path, output: Path, sources: list, top: str = None, logfile = None, script_out: Path = None, include: Path = None):
_check_exists(working_dir, sources)
_require_yosys()
yosys_cmd = _read_sources(sources, top) + ["synth", f"write_verilog {output.resolve()}"]
yosys_cmd = _read_sources(sources, top, include) + ["synth", f"write_verilog {output.resolve()}"]
_run_yosys(working_dir, yosys_cmd, logfile=logfile, script_out=script_out)
assert output.exists()
return output
Expand Down
2 changes: 1 addition & 1 deletion scripts/check_repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def check_repair(conf: Config, working_dir: Path, logfile, project: Project, rep
try:
with open(working_dir / f"{repair_filename.stem}.synthesis.log", 'w') as gate_level_logfile:
to_gatelevel_netlist(working_dir, gate_level, [repair_filename] + other_sources, top=benchmark.design.top,
logfile=gate_level_logfile, script_out=gate_level_script)
logfile=gate_level_logfile, script_out=gate_level_script, include=benchmark.design.directory)
synthesis_success = True
except subprocess.CalledProcessError:
synthesis_success = False
Expand Down

0 comments on commit 1e2152e

Please sign in to comment.