10 class YosysError(Exception):
14 def convert(*args
, strip_src
=False, **kwargs
):
16 popen
= subprocess
.Popen([os
.getenv("YOSYS", "yosys"), "-q", "-"],
17 stdin
=subprocess
.PIPE
,
18 stdout
=subprocess
.PIPE
,
19 stderr
=subprocess
.PIPE
,
21 except FileNotFoundError
as e
:
22 if os
.getenv("YOSYS"):
23 raise YosysError("Could not find Yosys in {} as specified via the YOSYS environment "
24 "variable".format(os
.getenv("YOSYS"))) from e
26 raise YosysError("Could not find Yosys in PATH. Place `yosys` in PATH or specify "
27 "path explicitly via the YOSYS environment variable") from e
31 attr_map
.append("-remove src")
33 il_text
= rtlil
.convert(*args
, **kwargs
)
34 verilog_text
, error
= popen
.communicate("""
35 # Convert nMigen's RTLIL to readable Verilog.
45 write_verilog -norename
46 """.format(il_text
, " ".join(attr_map
)))
48 raise YosysError(error
.strip())