|
43 | 43 | from sphinx.util.i18n import search_image_for_language |
44 | 44 | from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL |
45 | 45 |
|
| 46 | +import yowasp_yosys |
| 47 | + |
46 | 48 | if False: |
47 | 49 | # For type annotation |
48 | 50 | from typing import Any, Dict, List, Tuple # NOQA |
@@ -230,9 +232,9 @@ def run(self): |
230 | 232 |
|
231 | 233 |
|
232 | 234 | def run_yosys(src, cmd): |
233 | | - ycmd = "yosys -p '{cmd}' {src}".format(src=src, cmd=cmd) |
234 | | - print("Running yosys:", ycmd) |
235 | | - subprocess.check_output(ycmd, shell=True) |
| 235 | + ycmd = ["-q", "-p", cmd, src] |
| 236 | + print("Running yosys: yosys -q -p", "'{}'".format(cmd), src) |
| 237 | + yowasp_yosys.run_yosys(ycmd) |
236 | 238 |
|
237 | 239 |
|
238 | 240 | def diagram_yosys(ipath, opath, module='top', flatten=False, yosys_script='default'): |
@@ -260,6 +262,10 @@ def diagram_yosys(ipath, opath, module='top', flatten=False, yosys_script='defau |
260 | 262 | prep -top {top} {flatten}; cd {top}; {script}; show -format {fmt} -prefix {oprefix} |
261 | 263 | """.format(top=module, flatten=flatten, fmt=oext, oprefix=oprefix, script=yosys_script_cmd).strip(), |
262 | 264 | ) |
| 265 | + # somehow yowasp_yosys fails to execute `dot` to convert the dot file to svg, |
| 266 | + # perhaps a limitation with wasm |
| 267 | + svgdata = subprocess.check_output(["dot", "-Tsvg", "{}.dot".format(oprefix)]) |
| 268 | + open("{}.svg".format(oprefix), "wb").write(svgdata) |
263 | 269 |
|
264 | 270 | assert path.exists(opath), 'Output file {} was not created!'.format(oopath) |
265 | 271 | print('Output file created: {}'.format(opath)) |
@@ -309,7 +315,7 @@ def diagram_netlistsvg(ipath, opath, module='top', flatten=False, yosys_script=' |
309 | 315 | run_yosys( |
310 | 316 | src=ipath, |
311 | 317 | cmd = """\ |
312 | | -prep -top {top} {flatten}; cd {top}; {script}; write_json {ojson} |
| 318 | +prep -top {top} {flatten}; cd {top}; {script}; write_json -compat-int {ojson} |
313 | 319 | """.format(top=module, flatten=flatten, ojson=ojson, script=yosys_script_cmd).strip()) |
314 | 320 | assert path.exists(ojson), 'Output file {} was not created!'.format(ojson) |
315 | 321 |
|
|
0 commit comments