New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python support for Verilated designs #1489
Comments
Original Redmine Comment
VM_ means the variable is defined in the Makefile. VL_ means defined elsewhere.
I can see that this might be useful but expect it would rarely be used so
Agreed, this should be fixed.
The VPI probably isn't that useful. Allowing DPI calls from Verilog into
I assume you mean the calls needed to save coverage. I would think so. |
Original Redmine Comment I've rebased this work onto master, added a couple of minor fixes and added coverage support here: #3 The CPU usage bug is fixed here: #1 In any case it's not really related to the python support, so it shouldn't be a blocker IMHO. I think that covers all the outstanding issues? It's working well for me in it's current state, I assume the same is true for Maarten?. I'm hoping we can get this in so I don't have to rebase it anymore :). |
Original Redmine Comment I have added DPI support for Python in a pydpi branch. |
Original Redmine Comment I'm getting confused by all the layers. Do you propose
Or 1. cmake, 2. python no pydpi, 3. pydpi? If you want to add pydpi separately, file a separate bug and we'll get Anyhow here's combined feedback: First, this is cool. Once we get this merged, I'd love to see a conference I saw some merge conflicts with trunk. Patrick's comment suggested he had
To match other examples, think should be called make_python, and cmake_python.
Generate a Python module for the design by creating a wrapper using
Thanks for making a relatively complete DPI test. Please move it into (Please also make sure anything tested in examples is also in test_regress,
Please indent the directives appropriately. Why do you need to undef VL_PRINTF?
Why being removed?
Based on my experience with Verilog-Perl, expect that the includes & ldflags
I need to review these more closely. Please use // comments instead of /**/ style, unless this breaks pybind (really?).
Ok, I guess having this is reasonable and cleaner than how it was
What needs memory?
All caps seem ugly unless that's a standard.
Also too much for me to review at the moment. There's a lot of code here, please see if there's any overlap with the
Good stuff. indetStr should have been killed a while ago. I pushed this.
Need to think about this, what did it fix? If you have any other
Normally yes, this would be the exactly correct naming for a new flag's
Please have this test (or some python test) that writes a VCD have the perl
Then run the test with "--gold" once to make the golden file.
Add copyright to top of all new files please. We have a new feature in #� to do protection of modules. I think |
Original Redmine Comment Note examples have been renamed, see last msg in #�. |
Original Redmine Comment I've just pushed a new version to github that should address the above issues. I've stripped out the unrelated formatting and spelling changes, perhaps you/Maarten can deal with pulling those separately. My preference would be to merge PR #3 over at github that includes python + cmake, then Maarten can do his pydpi patch separately on top of master, because Maarten has suggested over on Github that pydpi isn't ready yet, and it's a significant amount of extra code. Alternatively, we could just merge cmake instead, and Maarten could merge the fixes I've made into his branch and submit his pydpi branch when it's ready. Your comment RE incorrect flags and python is exactly why I prefer to outsource that can of worms to pybind11's CMake module. Maarten: The python gmake support was missing a rule to actually build the module. I've added one in so the example works now, perhaps you've made edits to verilated.mk instead of verilated.mk.inc at some point, or something's gone missing in a git merge? |
Original Redmine Comment Patrick Stewart wrote:
In Wilson Snyder wrote:
As Patrick Stewart proposed, let's first finish cmake and basic python support.
I agree with with Patrick Stewarts view on this.
Nice. I just want to comment that performance wise, it would be interesting to check the difference in performance (if any) between cpython and pypy because the GIL of cpython will trash multithreading. (This is more applicable to pydpi)
I added these
I did not find a
This should be in a separate commit in my (now rebased) pydpi branch.
Nice philosophical question. What needs memory? Anyway, This C file is only generated when using the gmake make system because using cmake, this file is generated using cmake (in
I simply copied the __ALL suffix from the lines below it.
Let's postpone pydpi until after merging of cmake and python. Basically, the big changes in the pydpi branch is converting c types to python types and vice versa. I use information from the ast to convert to the correct types.
If I remember correctly, it was to fix the output of the VPREFIX_py.h file. |
Original Redmine Comment
The PREFIX__PYTHON target was set as default, but it was empty. The cpp files were all added including the generated one, but there was no rule to link them together into a module either in verilated.mk.inc or V3EmitMk.cpp as far as I could see. I added a rule in verilated.mk.inc to get it done. |
Original Redmine Comment I've updated the pull request on top of master now that CMake is merged. I think I've addressed the outstanding issues from here and github. I've also lifted the requirement to set PYBIND11_ROOT when it's installed. |
Original Redmine Comment Review comments:
s/verilator/Verilator/ The front of the document talks about converting to C++/SystemC. Perhaps should
This needs a bit of rewording, as doesn't read well and not sure if you're
Perhaps
Add spaces to show ifdef levels (ignoring the Guard):
Fix caps and "p" suffix:
Also this seems separatable, please make a separate patch for this and I'll
Use $(PYTHON3_CONFIG) and default-define it as python3-config.
Let's rename __Python. I'd rename my __ALL but too late.
I don't see why this is made in the cmake file. I would have expected
I presume pybind requires C++11? We need to document that requirement.
if (VL_UNLIKELY(...)) Please check all other if statements for appropriate places for LIKELY/UNLIKELY.
VlCallback
Does pybind11 expect execption saftey?
PyVlCallback
Why does python need access to the lock primitives? This seems something
Doc is a cut and paste error, check others too. Perhaps make a function that declares the property Can we have a process to extract this documentation and post it somewhere or make a PDF/HTML?
s/python/Python/
Space to show ifdef levels.
Should always be included first.
fmtp. Likewise other places need "p" suffix.
This assumes a platform-specific bit packing endinness.
Use VL_PY_IN/OUT/INOUT to match VL_IN/OUT/INOUT. Break up the long lines. I need to study this file a bit more too.
Shouldn't need to have changed these lines.
I think --lint-only --python should do linting only.
Move this into notify().
I suspect we'll get more python tests. Perhaps driver.pl should build
The vcd check needs to be inside the if(). If the if() fails, print a skip() message.
s/ :/ :/ |
Author Name: Maarten De Braekeleer
Original Redmine Issue: 1489 from https://www.veripool.org
Original Assignee: Maarten De Braekeleer
I've improved the patchset by Patrick Stewart (proposed in #�) to add Python support for Verilated designs.
It has support for both make and cmake as make system.
It includes examples and a regression test.
The Python support has a hard dependency on pybind11. The examples and test will be skipped when the environment variable PYBIND11_ROOT is not set.
The patches are based on the cmake patches in #� and can be found at:
https://github.com/madebr/verilator/tree/python
I've got some questions:
the Python compile definition is VL_PYTHON. Is this ok? Because some variables have a VM_ prefix and some VL_.
the Python bindings allow users to set and read ports. It is currently not possible to fetch metadata of modules. Would that be useful? I know how to get the width of ports but is it possible to get parameters of modules?
After importing a Verilated Python module with threads support, when the python interpreter is idle, the cpu usage rises to the number of threads that was passed to verilator. I think this behavior is rather undesirable. The cpu usage should only rise when the computations start and lower again when it is finished.
Python does not have ani VPI/DPI support, is that needed? Or is that SystemC only?
Would support for verilator_coverage be useful?
The text was updated successfully, but these errors were encountered: