symbiflow / sphinxcontrib-hdl-diagrams Goto Github PK
View Code? Open in Web Editor NEWSphinx Extension which generates various types of diagrams from Verilog code.
Home Page: https://sphinxcontrib-hdl-diagrams.rtfd.io
License: Apache License 2.0
Sphinx Extension which generates various types of diagrams from Verilog code.
Home Page: https://sphinxcontrib-hdl-diagrams.rtfd.io
License: Apache License 2.0
This functionality should have better testing.
For example RTLIL or nMigen.
https://readthedocs.org/projects/skywater-pdk/builds/14408706/
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/registry.py", line 429, in load_extension
mod = import_module(extname)
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinxcontrib_hdl_diagrams/__init__.py", line 45, in <module>
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
ImportError: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/util/osutil.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/application.py", line 237, in __init__
self.setup_extension(extension)
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/application.py", line 393, in setup_extension
self.registry.load_extension(self, extname)
File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/registry.py", line 432, in load_extension
raise ExtensionError(__('Could not import extension %s') % extname,
sphinx.errors.ExtensionError: Could not import extension sphinxcontrib_hdl_diagrams (exception: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/util/osutil.py))
Extension error:
Could not import extension sphinxcontrib_hdl_diagrams (exception: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/util/osutil.py))
Using GHDL as a frontend for Yosys allows synthesising VHDL, Verilog and/or mixed language designs. See https://im-tomu.github.io/fomu-workshop/mixed-hdl.html. It'd be interesting to test whether this extension supports those cases, and to enhance it otherwise.
I have added the CODECOV_TOKEN
to travis-ci, so it should work if you upload the code coverage data stuff?
I think it is just adding;
after_success:
- bash <(curl -s https://codecov.io/bash)
See https://github.com/codecov/example-python for more information?
@whitequark has been looking at how to get Yosys onto PyPi in a nice way to enable https://github.com/nmigen/nmigen
See if we can also [optional] use that package for diagram generation rather than the system or conda provided Yosys.
I believe the line numbers should still be accurate even though the license header is skipped.
https://sphinxcontrib-verilog-diagrams.readthedocs.io/en/latest/#single-dff
The output at https://sphinxcontrib-verilog-diagrams.readthedocs.io/en/latest/#id3 should start counting from 19.
https://travis-ci.com/github/SymbiFlow/sphinxcontrib-verilog-diagrams/builds/172946780
Checking dist/sphinxcontrib_verilog_diagrams-0.0.post79-py3-none-any.whl: FAILED
`long_description` has syntax errors in markup and would not be rendered on PyPI.
line 81: Warning: Bullet list ends without a blank line; unexpected unindent.
Checking dist/sphinxcontrib-verilog-diagrams-0.0.post79.tar.gz: FAILED
`long_description` has syntax errors in markup and would not be rendered on PyPI.
line 81: Warning: Bullet list ends without a blank line; unexpected unindent.
Guess we should figure out how to test for that in a pull request?
Should we change this to contain the ISC License, like all the code files in this repository?
The README says this can be installed using pip install sphinxcontrib-verilog-diagrams
but this package is still not on PyPi.
This repository is still using Travis but everything else has moved to using GitHub actions.
Good example of using this library is the https://github.com/SymbiFlow/python-symbiflow-v2x/tree/master/docs repository.
Allow providing a skin file to netlistsvg.
Should support;
Manual publishing is a pain.
In #20 @daniellimws added functionality to skip the license when including a verilog file.
It appears we didn't add documentation at all?
We should put;
https://readthedocs.org/projects/sphinxcontrib-verilog-diagrams/builds/11085867/
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
ERROR: Command syntax error: Unknown option or option in arguments.
> write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json
> ^
Running yosys: yosys -p 'prep -top top ; cd top; show -format svg -prefix /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-68-verilog-dff' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v
Output file created: /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-68-verilog-dff.svg
Running yosys: yosys -p 'prep -top top ; cd top; show -format svg -prefix /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-88-verilog-dff' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v
Output file created: /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-88-verilog-dff.svg
Running yosys: yosys -p 'prep -top top ; cd top; write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v
/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/deprecation.py:52: RemovedInSphinx40Warning: sphinx.builders.html.DirectoryHTMLBuilder is deprecated. Check CHANGES for Sphinx API modifications.
return getattr(self._module, name)
/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/readthedocs_ext/readthedocs.py:14: RemovedInSphinx40Warning: sphinx.builders.html.SingleFileHTMLBuilder is deprecated. Check CHANGES for Sphinx API modifications.
from sphinx.builders.html import (DirectoryHTMLBuilder, SingleFileHTMLBuilder,
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280, in build_main
app.build(args.force_all, filenames)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/application.py", line 348, in build
self.builder.build_update()
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299, in build_update
len(to_build))
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 361, in build
self.write(docnames, list(updated_docnames), method)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 535, in write
self._write_serial(sorted(docnames))
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 545, in _write_serial
self.write_doc(docname, doctree)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 597, in write_doc
self.docwriter.write(doctree, destination)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/writers/__init__.py", line 78, in write
self.translate()
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/writers/html.py", line 71, in translate
self.document.walkabout(visitor)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
if child.walkabout(visitor):
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
if child.walkabout(visitor):
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
if child.walkabout(visitor):
[Previous line repeated 2 more times]
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 206, in walkabout
visitor.dispatch_visit(self)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/util/docutils.py", line 468, in dispatch_visit
method(node)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 338, in html_visit_verilog_diagram
render_diagram_html(self, node, node['code'], node['options'])
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 309, in render_diagram_html
fname, outfn = render_diagram(self, code, options, format)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 291, in render_diagram
verilog_path, outfn, module=options['module'], flatten=options['flatten'])
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 261, in diagram_netlistsvg
""".format(top=module, flatten=flatten, ojson=ojson).strip())
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 202, in run_yosys
subprocess.check_output(ycmd, shell=True)
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'yosys -p 'prep -top top ; cd top; write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v' returned non-zero exit status 1.
Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'yosys -p 'prep -top top ; cd top; write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v' returned non-zero exit status 1.
The full traceback has been saved in /tmp/sphinx-err-5duhsu2j.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
OS_TYPE=Linux CPU_TYPE=x86_64
'name: sphinxcontrib-verilog-diagrams' 'sphinxcontrib-verilog-diagrams'
source /home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/env/conda/bin/activate sphinxcontrib-verilog-diagrams && cd docs; make html
make[1]: Entering directory '/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs'
Running Sphinx v3.1.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d4b290>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853dbe5d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d619d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d059d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d1d850>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d05490>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d05410>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853da37d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d3bed0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853ccf2d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853ccf390>
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:38: WARNING: Error in "code-block" directive:
maximum 1 argument(s) allowed, 7 supplied.
.. code-block:: python
extensions = [
...,
'sphinxcontrib_verilog_diagrams',
]
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:84: WARNING: Title underline too short.
Verilog Code Block (with license header)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:106: WARNING: Title underline too short.
Verilog Code Block (without license header)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:106: WARNING: Title underline too short.
Verilog Code Block (without license header)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The sphinx extension now has a bunch of contributions from different people like @daniellimws -- we should change setup.py
to be something like "SymbiFlow Authors" (or whatever is used in the copyright statement) and have the email go to the symbiflow mailing list at https://lists.librecores.org/listinfo/symbiflow
There is a lot of examples at https://sphinxcontrib-verilog-diagrams.readthedocs.io/en/latest/
Link to it from the README file.
Maybe add a screenshot too.
Diagram
-------
.. hdl-diagram:: fiddlybob.v
:type: netlistsvg
:module: fiddlybob
fiddlybob.v:
module fiddlybob(
input thistextiscropped,
input moretextthatiscropped,
input moretextthatiscroppedNot,
output evenmoretextthatiscropped,
output [63:0] ididnotexpectthistexttobecropped,
);
wire _evenmoretextthatiscropped_T_2 = ididnotexpectthistexttobecropped[0] != moretextthatiscroppedNot;
assign evenmoretextthatiscropped = thistextiscropped & (~moretextthatiscropped | _evenmoretextthatiscropped_T_2);
endmodule
Result, cropped text:
Currently the documentation is not using the material theme like other SymbiFlow projects.
I've changed my local setup to use the material theme for readthedocs, but the code block with line numbers looks awkward.
@mithro What do you think?
During diagram generation you might want to do some type of techmapping or similar.
There appears to be some problem with the dependency tracking.
The workaround is to delete the build folder.
There is some dependency code, but I can't seem to get it to work:
on this page, line numbers don't land where they should:
Firefox, 79.0 Unbutu
https://sphinxcontrib-hdl-diagrams.readthedocs.io/en/latest/examples/comb-full-adder.html
With the new name change.
I'm having problems installing the plugin:
$ pip3 install --user sphinxcontrib-verilog-diagrams
ERROR: Could not find a version that satisfies the requirement sphinxcontrib-verilog-diagrams (from versions: none)
ERROR: No matching distribution found for sphinxcontrib-verilog-diagrams
Your builds will stop working soon!
"build.image" config key is deprecated and it will be removed soon. Read our blog post to know how to migrate to new key "build.os" and ensure your project continues building successfully.
However, our .readthedocs.yml
file doesn't have a build.image
config key?
In the bottom right hand corner of the docs is a link to a non-existent "sphinx_symbiflow_theme" repo.
I assume this comes from the theme at https://github.com/SymbiFlow/sphinx_materialdesign_theme ?
See https://opensource.google/docs/releasing/licenses/
Put the following license header at the top;
Copyright 2020 The SymbiFlow Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This module use to be called sphinxcontrib-verilog-diagrams
but is now called sphinxcontrib-hdl-diagrams
.
We should setup a redirect from the old package name to the new package name.
#13 did not account for the fact that older versions of yosys do not have the -compat-int
option for write_json
. This causes this extension to fail when an older version of yosys is used (in particular the version of yosys currently present on conda does not have this option).
The version of yosys should be checked to determine whether the -compat_int
options should be added to write_json
.
YosysHQ/yosys@20ce411 is the commit that introduced this option.
Currently only a single source file can be selected. It would be useful to have support for multiple source files.
Like:
.. hdl-diagram:: file.v file2.v file3.v
:type: XXXXX
:module: XXXX
:skin: XXXX
:yosys_script: XXXX
:flatten:
rst
documentation format is used heavily in the rest of this module and this module adds directives to rst
. It probably makes sense for the README to also be in rst
format too.
After fixing the issue around yosys
no longer being found in the symbiflow conda channel the next error seems to be;
Ran pip subprocess with arguments:
[u'/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-hdl-diagrams/conda/84/bin/python', '-m', 'pip', 'install', '-U', '-r', '/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-hdl-diagrams/checkouts/84/tmpZZLQXZ.requirements.txt']
Pip subprocess output:
Collecting sphinx_symbiflow_theme
Cloning http://github.com/SymbiFlow/sphinx_symbiflow_theme.git (to revision master) to /tmp/pip-install-m16aspc3/sphinx-symbiflow-theme_91a02a04c565470ca1d94cfad52b790e
Pip subprocess error:
Running command git clone --filter=blob:none --quiet http://github.com/SymbiFlow/sphinx_symbiflow_theme.git /tmp/pip-install-m16aspc3/sphinx-symbiflow-theme_91a02a04c565470ca1d94cfad52b790e
warning: redirecting to https://github.com/SymbiFlow/sphinx_symbiflow_theme.git/
WARNING: Did not find branch or tag 'master', assuming revision or ref.
Running command git checkout -q master
error: pathspec 'master' did not match any file(s) known to git.
error: subprocess-exited-with-error
× git checkout -q master did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× git checkout -q master did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.