add sim_opt 'ghdl.elab_e' to run 'ghdl -e' instead of 'ghdl --elab-run --no-run' by umarcor · Pull Request #467 · VUnit/vunit
The reason the elab_fail test bench fails is because it has a generic for which no value is specified.
Generics are typically evaluated at elaboration time in simulators. Other simulators do this check at elaboration when loading the top level. This is the use case that the--elaborateflag is for, to run a fast check to ensure the design elaborates. If we change this for GHDL it would be inconsistent with other simulators so it makes me reluctant to change it.
I did not know that other simulators do check generics at elaboration. I wonder why GHDL is not consistent.
Is there any requirement for this PR to be accepted other than "GHDL should evaluate generics at -e"? If this is the single issue, I would suggest asking politely to @tgingold to add generics as an elaboration option, as long as it is ok with the standard.
Currently VUnit offers two stages of running a test bench, elaborate only or full test run. What would be the stage in-between expressed in the terms of the VHDL-standard? Run only the first delta cycle? Is this what -r --no-run does?
When the top-level of the binary is GHDL, existing two options behave as expected: elaborate generates the binary and the default executes it. The fact that --elaborate does not only do that, but it also executes the design until cycle 0, is negligible because nothing is done before or after the simulation. It helps at keeping consistency, as you explained.
However, when the simulation is wrapped, there is no option in VUnit to just check if the design can be compiled and build the binary. --compile will analyse all the VHDL sources and generate the objects. --elaborate will create the binary and it will execute it.
I believe that, in terms of the VHDL standard, this stage is the output of the elaboration. Ideally, I do not want to run until the first delta cycle, I don't want to execute the binary at all.
Also if we add a new stage it needs to be implemented for all simulators so it becomes more work.
If there is no requirement other than evaluating generics during elaboration, this PR will eventually be valid, so ignore the following paragraphs. Otherwise, if --elaborate will be kept as --elab-run --no-run:
I don't think that the new option needs to be added for all simulators. This is only required for the simulators that allow to build an executable binary which includes some VHDL sources/objects and some C sources/objects. What do you think about --build as the name for a new option?
On the one hand, this is only supported by GHDL for now, so the implementation in other simulators would be an error telling that it is a not supported arg.
On the other hand, although some other simulators supported by VUnit allow to combine VHDL and C sources (e.g. https://gitlab.com/reds-public/fss), I don't know if any of them allows to generate an independent executable binary. If it is not the case, this would always be a GHDL-only flag.
There are two ways to solve this on the user-side:
1. Do not run any checks when the '--no-run' argument is found in the argv
2. Detect --elaborate flag in run.py and do not substitute GHDL main in this case
I'd rather call ghdl -e or gcc explicitly from run.py. Almost all the compilation objects are located in vunit_out/ghdl/libraries, so it is not difficult to generate the command. It is just misleading to me the execution result when VUnit --elaborate is used with GHDL.