Skip to content

Commit 4e93e76

Browse files
daniellimwsrw1nkler
authored andcommitted
Use yowasp_yosys instead of yosys from conda
Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
1 parent c65e8e3 commit 4e93e76

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dependencies:
1111
- pip
1212
- python=3.7
1313
- sphinx
14-
- yosys
1514
- pip: # Packages installed from PyPI
1615
- -r file:requirements.txt
1716
- -r file:docs/requirements.txt

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ setuptools
22
docutils
33
sphinx
44

5+
yowasp-yosys>=0.9.post4547.dev9
6+
57
# Needed to upload to PyPi
68
twine
79

sphinxcontrib_verilog_diagrams/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
from sphinx.util.i18n import search_image_for_language
4444
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
4545

46+
import yowasp_yosys
47+
4648
if False:
4749
# For type annotation
4850
from typing import Any, Dict, List, Tuple # NOQA
@@ -230,9 +232,9 @@ def run(self):
230232

231233

232234
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)
236238

237239

238240
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
260262
prep -top {top} {flatten}; cd {top}; {script}; show -format {fmt} -prefix {oprefix}
261263
""".format(top=module, flatten=flatten, fmt=oext, oprefix=oprefix, script=yosys_script_cmd).strip(),
262264
)
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)
263269

264270
assert path.exists(opath), 'Output file {} was not created!'.format(oopath)
265271
print('Output file created: {}'.format(opath))
@@ -309,7 +315,7 @@ def diagram_netlistsvg(ipath, opath, module='top', flatten=False, yosys_script='
309315
run_yosys(
310316
src=ipath,
311317
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}
313319
""".format(top=module, flatten=flatten, ojson=ojson, script=yosys_script_cmd).strip())
314320
assert path.exists(ojson), 'Output file {} was not created!'.format(ojson)
315321

0 commit comments

Comments
 (0)