-
Notifications
You must be signed in to change notification settings - Fork 9
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
Previous work and future ideas #1
Comments
Hi! I am the co-writer of the (still unreleased) GHDL backend for SpinalHDL (SpinalHDL/SpinalHDL#146) To write the support, one of the most useful reference I found is a master thesis about Clash co-simulation integration . The SpinalHDL GHDL integration is mostly based on it. I think it is a very well written work. |
Hi @bellaz89! As you see, this repository was created a few days ago, and we've been busy uploading all the initial content/examples. I wanted to let it settle down a bit before pinging you explicitly. Anyway, since you already came by (thanks!), let's go ahead: Although @RocketRoss and myself are currently focused on uploading content related to VHPIDIRECT and the C interface, I acknowledge that most (if not all) non-trivial existing projects do use VPI instead. To name a few: the Clash integration you refed, your own VPIInteropREPL (for SpinalHDL), cocotb (for Python), MyHDL, ACMIX (for SystemC), etc. In fact, that's why section https://ghdl.github.io/ghdl-cosim/vpi/examples/index.html exists. That's where we'd like to add resources related to VPI. As far as I am aware, there is little to none VPI-specific content in the main docs. Link, compile and load options are explained, but there are no further explanations or examples. Furthermore, to be honest, I am not sure about sections "Wrapping a simulation", "Linking objects files" and "Dynamic loading" being exclusive to VHPIDIRECT/Cinterface. Those might be common to any co-simulation approach with GHDL. Hence, it would be awesome if you wanted to contribute a PR with an initial version of section VPI, where you added a brief description of VPIInteropREPL, along with any other reference that you might consider relevant. I think that the point now is to have info gathered, rather than having very detailed explanations. In the long term, it'd be interesting to know whether VPIInteropREPL can be used with cocotb or MyHDL too, or if execution models are too different. Refs:
|
Hi! :) Right now VPIInteropREPL is a bit out of date because I am continuing the development on SpinalHDL's ghdl branch. Once It is finished, that code can be used to update VPIInteropREPL. Since the wrapper interface is created using SWIG, it could be possible to add the support of several languages (Python/Octave/Ruby/Tcl.. etc for example). |
Very interested in expanding my knowledge to cover VPI, will be looking to make some time for an investigation once the current VHPI PRs are completed |
Recent bugfixes/enhancements in the GHDL-VPI interface resulted in the addition of several VPI usage examples in GHDL testbenches directory:
These tests and in particular the last one, are a good starting point to develop VPI based co-simulation code and can be added to documentation as examples since they are quite simple to understand. |
@bellaz89, actually, there are other several examples in the testsuite: # grep -l -r ./testsuite/ -e "vpi-compile"
./testsuite/gna/issue1226/testsuite.sh
./testsuite/gna/issue1228/testsuite.sh
./testsuite/gna/issue1233/testsuite.sh
./testsuite/gna/issue1256/testsuite.sh
./testsuite/gna/issue450/testsuite.sh
./testsuite/gna/issue531/testsuite.sh
./testsuite/gna/issue98/testsuite.sh By the same token: # grep -l -r ./testsuite/ -e "VHPIDIRECT"
./testsuite/gna/bug021/sim_pkg.vhd
./testsuite/gna/bug026/xb.vhd
./testsuite/gna/bug092/t.vhdl
./testsuite/gna/bug092/t2.vhdl
./testsuite/gna/bug097/tb.vhdl
./testsuite/gna/issue1229/pkg.vhdl
./testsuite/gna/issue1252/pkg.vhdl
./testsuite/gna/issue152/ax_wb_pli_pkg.vhdl
./testsuite/gna/issue797/pkg_c.vhdl |
Hi, I know the existence of these examples and I used them as a reference to write the SpinalHDL-GHDL bindings. However, until now, there were no examples of how to ask GHDL to advance the simulation time through VPI. Believe me, it is very difficult to find a simple example on how to do that on the internet, and understand it from cocotb is quite a challenge. Therefore, since I wrote these three reproducers (1226,1233, 1256), and given that from what I understand the ghdl-cosim aim is to document/give example on GHDL foreign programming interface, I thought that It would be very helpful to point you to these three testbenches. I think that including them in the documentation could help many people to avoid wasting their time trying to understand how to advance the GHDL simulation time with VPI like I did :P. BTW I think I will write some PR :) Edit: |
@bellaz89, the point is that there are dozens of undocumented and independent examples about VHPIDIRECT and/or VPI. All the references in this issue contain one or multiple examples of different complexity. Some are simpler, others are frameworks, but almost each of them has features which are very difficult to find on the internet. Each of them is likely to be very useful for a subset of users. The purpose of this repo is not only to gather references (to make them easier to find), but also to explain them (to make them easier to understand), and to have a fine-grained test suite (to find issues in different platforms/backends). For gathering only, this issue exists. On top of that, explaining implies thinking about a coherent and easy-going path that takes any new user from zero to the most complex examples. With "zero" I mean "no knowledge about co-simulation with GHDL". Users are expected to be familiar with, VHDL, GHDL, C and GCC.
I believe this is a very interesting example. Precisely, this is currently not possible/documented with VHPIDIRECT/Cinterface. Hence, it is one of the motivations to recommend using VPI instead. However, ATM there is absolutely no documentation about VPI. Not a single line. Before introducing any of the examples you propose, I believe that at least one should exist about how to do nothing other than building and running a simulation with an VPI module. For instance, a very relevant difference compared to VHPIDIRECT is that VPI needs
I will have a look! |
Hi! Yes, sorry, I realize I was a bit unclear in my first message about why I think these references are valuable for me. That's why after thinking about that I opened a PR to explicitly give a set of examples that can be understood with basic programming/VHDL skills and that covers the most basic use of VPI one can do.
I fully agree that giving full and free documentation that covers many aspects/usage of VPI is something that would be very nice to have. However, this is going to take much more effort than giving a basic set of examples because VPI is a complex API with many details I am not aware of. So I think that this can be taken as a long term task that can be updated from time to time (also because my job doesn't allow me to spend a lot of time on hobby projects... so I can't give a 100% assurance that I will be able to follow it). Even if just giving an organized basic set of VPI examples couldn't be enough for complete newcomers, they may be still valuable for people that have knowledge above basic skills but find it hard to understand how to make VPI work in practice. Thank you for reviewing my PR! |
In fact, as you saw after I reviewed your PR, I believe that the set of examples that you proposed is nice and more than enough. I'm not expecting/requesting any more than that. Let's just make a little effort for the "story" to be easier to understand/follow.
This repo is not "a tutorial about VPI", but "a tutorial about using VPI with GHDL". Anything which is related to GHDL or VPI only does not belong in here. However, we need to acknowledge/reference it. For example: VPI (and VHPI) are complex APIs. Compared to VHPIDIRECT, these provide advanced features, at the cost of having to learn/understand many more details. Since this is the user and reference manual for GHDL, it does not contain an introduction to VPI/VHPI. Thus, the reader should have at least a basic knowledge of them. A good knowledge of the reference manuals (usually called LRM) is a plus. Please read X, Y and Z if you are not familiar with VPI/VHPI yet. The one-liner introduction to VPI is that C header
Writing the docs is an exercise for us to learn too. We need to point which details we are not sure about. We will either find the answer or add some note/warning acknowledging that we don't know it. Nonetheless, if questions arise while we write the examples, new users are likely to ask the same questions in the future.
I believe it is a mid-term task. If we open the door to adding examples with sources that are partially inconsistent, and we allow to contribute them without proper documentation, there is a serious risk that those will never be completed. It is ok to keep PRs open and to enhance them as spare time allows to. When they are merged, we need to assume that the content might not be updated in weeks, months or years.
I think that people with skills slightly above the basic will have no issues with finding either this thread or the open PRs. They don't really need the docs. We can make it more explicit by adding some note either to the site or to the README: This repository was created recently and multiple existing examples are not published yet. See issue #1 and the list of open Pull Requests for on-going work. By the same token, we can add "Contributing guidelines", to suggest potential contributors different levels of commitment:
|
Hi, I just found this repository and I would like to advertise my solution to VHDL/Verilog cosimulation using GHDL and Verilator. I find it very convenient and it might be useful to others as well. Perhaps a link to this code generator (or even the code generator itself) could be integrated into this repository to make people aware of it. |
Thank you for the message. This is an interesting way to do
cosimulation with verilog!
Do not hesitate to create a pull-request to add a reference to your
project in the README.
|
This repository was created by merging the following resources:
using/Foreign.rst
andexamples/README.rst
(doc: split 'Interfacing to other languages' to ghdl/ghdl-cosim ghdl#1216).In fact,
#1
in the commit history corresponds to umarcor#1 or ghdl/ghdl-systemc-fosdem16#1.This issue is just a placeholder for consistency and to acknowledge the references.
Refs:
Ideas:
-o
(it applies to all commands that perform a link, so:-e
,--elab-run
,--link
,-c
,-m
...) (Update documentation ghdl#1290)systemc
, March 26, 2020 7:04 PM and mixing VHDL-2008 with other standards? ghdl#908.printf
as an alternative to suoto/hdl_string_format?Examples:
Existing 'Quick Start' examples are based on vhpidirect. However, there are some features which are used there and not shown in the examples yet.ghdl.free.fr/site/uploads/Main/vhpidirect.zipThe text was updated successfully, but these errors were encountered: