|
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 | | - |
48 | 46 | if False: |
49 | 47 | # For type annotation |
50 | 48 | from typing import Any, Dict, List, Tuple # NOQA |
@@ -150,6 +148,8 @@ class VerilogDiagram(Directive): |
150 | 148 |
|
151 | 149 | final_argument_whitespace = False |
152 | 150 |
|
| 151 | + use_yowasp = True |
| 152 | + |
153 | 153 | option_spec = { |
154 | 154 | 'type': str, |
155 | 155 | 'module': str, |
@@ -232,9 +232,14 @@ def run(self): |
232 | 232 |
|
233 | 233 |
|
234 | 234 | def run_yosys(src, cmd): |
235 | | - ycmd = ["-q", "-p", cmd, src] |
236 | 235 | print("Running yosys: yosys -q -p", "'{}'".format(cmd), src) |
237 | | - yowasp_yosys.run_yosys(ycmd) |
| 236 | + if VerilogDiagram.use_yowasp: |
| 237 | + import yowasp_yosys |
| 238 | + ycmd = ["-q", "-p", "{}".format(cmd), src] |
| 239 | + yowasp_yosys.run_yosys(ycmd) |
| 240 | + else: |
| 241 | + ycmd = "yosys -p '{cmd}' {src}".format(src=src, cmd=cmd) |
| 242 | + subprocess.check_output(ycmd, shell=True) |
238 | 243 |
|
239 | 244 |
|
240 | 245 | def diagram_yosys(ipath, opath, module='top', flatten=False, yosys_script='default'): |
@@ -262,10 +267,12 @@ def diagram_yosys(ipath, opath, module='top', flatten=False, yosys_script='defau |
262 | 267 | prep -top {top} {flatten}; cd {top}; {script}; show -format {fmt} -prefix {oprefix} |
263 | 268 | """.format(top=module, flatten=flatten, fmt=oext, oprefix=oprefix, script=yosys_script_cmd).strip(), |
264 | 269 | ) |
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) |
| 270 | + |
| 271 | + if VerilogDiagram.use_yowasp: |
| 272 | + # somehow yowasp_yosys fails to execute `dot` to convert the dot file to svg, |
| 273 | + # which works on native yosys, perhaps a limitation with wasm |
| 274 | + svgdata = subprocess.check_output(["dot", "-Tsvg", "{}.dot".format(oprefix)]) |
| 275 | + open("{}.svg".format(oprefix), "wb").write(svgdata) |
269 | 276 |
|
270 | 277 | assert path.exists(opath), 'Output file {} was not created!'.format(oopath) |
271 | 278 | print('Output file created: {}'.format(opath)) |
|
0 commit comments