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
Pass Toplevel generic to ghdl_main() #1185
Comments
@RocketRoss, I'm pretty sure this is a PEBCAK. I have intensively used this feature and it works as expected. Let's dive into it!
You need to call
The arguments that Notes:
You can set a default value for the generics in the top-level VHDL entity. This way, you don't need to provide any runtime argument. Of course, this requires you compile once for each set of params.
I think that GHDL has limited support for generic types in the CLI. I would stick to strings or integers. However:
As said, you need to pass two arguments, the first one being the path to the binary or NULL, and the second one |
Yes! A PEBCAK indeed. Forgot about the binary-path being the first argument.
Say no more!
Exactly the issue.
Indeed it did. Many thanks @umarcor 🍾
Roger dodger. VUnit was next on my list of conquests. The following is curiosity talk.
Yes, I noted that. Seems to make sense that the generics should rather fall down to be a part of the elaboration phase, because one can use generics to alter generate statements: so the final executable is still rather dynamic as it can adapt to any value for a generic??? I am curious about the backend. Does GHDL try to come up with a straight shot/flat if-else maze to mimic circuitry, or does it just wrap up the vhdl code smartly and then run through it and increment clocks at certain points. Still it is quite nice to be able to rerun a single executable with for simulation environments... |
Awesome 🎉
Do not hesitate to ask, either in the issues or in the chat!
Exactly. Tristan's point is that there are some elaboration-time optimisations that cannot be applied if elaboration is delayed to runtime. Currently what the LRM defines as "elaboration" is split between GHDL's elaboration and runtime commands. I.e.
Once again, exactly. I believe this is an unvaluable feature. Technically, together with VUnit's verification componets VHDL libs, it allows you to take a VHDL design with AXI, Wishbone or Avalon top-level interfaces and provide an "executable model" of it, so that users can evaluate/test your design in a software environment. They get either a binary or a shared library with a nice software API to write/read to/from the model. It is also possible to use GHDL to embed a hardware design as a replacement of an existing function. This is what dbhi.github.io is about. Furthermore, the "executable model" can be called as a function in Octave, so that data in the workspace is modified by the simulation at runtime. Since it is dynamic as you said, a single binary suffices to support any generics. For example, I'm using it to test a matrix multiplication core. However, because of the licensing of GRT (GPL), you NEED to allow users to access the VHDL sources that you used to generate the "executable model". Unlike verilator, which allows a similar procedure to be used for distributing obfuscated executable models, licensing in GHDL is otherwise. Actually, Tristan has considered writing a ghdlator which would provide an alternative.
The "backend" is GRT, GHDL's Runtime Library that is embedded into the generated binaries. I believe that's the part of GHDL (as a project) which ensures that execution is cycle-accurate. I'm pretty sure that it does not mimic circuitry at all. The purpose of GHDL is to be bit-accurate and cycle-accurate, but it is a compiler not a synthesiser. You can see it as "a compiler for a flavour of ADA with a companion runtime library". Except that "the flavour" is VHDL, which is arguably much more complex. Hence, it is closer to wrapping the code smartly and incrementing delta cycles at certain points. Actually, the sources of GRT are quite intuitive to read. For example, here you have Well, it WAS compiler/simulator only. In the last 12 months Tristan did a titanic effort to enable |
Thanks @umarcor for the answer. |
Description
I am not getting any valid parsing of a argc, argv pair when calling ghdl_main() in a custom main(). I noted that the documented example of 'ghdl -r --std-08 bugtest -gDEPTH=12' was a little picky, and only worked when '-g...' was at the end.
Expected behaviour
The generics default to inexplicit values (Integer = -2147483648, a default I did not specify). I want the generic to take on the value after the '=' in the '-gDEPTH=12'. I then struggled to pass a value for a std_logic generic. What are the limits of '-g'?
I also looked at passing ghdl_main all four arguments (-r, --std-08, bugtest, -gDEPTH=12) instead of just '-gDEPTH=12', and including a leading space on the arguments. No avail.
How to reproduce?
Context
$ ghdl --version
GHDL 0.36-dev (Ubuntu 0.35+git20181129+dfsg-4ubuntu1) [Dunoon edition]
Compiled with GNAT Version: 8.3.0
llvm code generator
Additional context
I'd happily dive into the repo if someone points me in the right direction.
The text was updated successfully, but these errors were encountered: