Simulation and runtime¶
In most system environments, it is possible to pass options while invoking a program. Contrary to most programming languages, there is no standard method in VHDL to obtain the arguments or to set the exit status.
In GHDL, it is impossible to pass parameters to your design. A later version could do it through the generic interfaces of the top entity.
However, the GHDL runtime behaviour can be modified with some options; for example, it is possible to stop simulation after a certain time.
The exit status of the simulation is
EXIT_SUCCESS (0) if the
simulation completes, or
EXIT_FAILURE (1) in case of error
(assertion failure, overflow or any constraint error).
Here is the list of the most useful options. Some debugging options are
also available, but not described here. The
--help option lists
all options available, including the debugging one.
Select the assertion level at which an assertion violation stops the simulation. LEVEL is the name from the severity_level enumerated type defined in the standard package or the
By default, only assertion violation of severity level
failurestops the simulation.
For example, if LEVEL was
warning, any assertion violation with severity level
failurewould stop simulation, but the assertion violation at the
noteseverity level would only display a message.
--assert-level=noneprevents any assertion violation from stopping simulation.
Select how the assertions from
ieeeunits are handled. POLICY can be
disablewhich disables all assertions from
disable-at-0which disables only at the start of simulation.
This option can be useful to avoid assertion messages from
Stop the simulation after
TIMEis expressed as a time value, without any space. The time is the simulation time, not the real clock time.
$ ./my_design --stop-time=10ns $ ./my_design --stop-time=ps
Stop the simulation after N delta cycles in the same current time. The default is 5000.
Display the time and delta cycle number as simulation advances.
Disable buffering on stdout, stderr and files opened in write or append mode (TEXTIO).
Do VITAL annotation on PATH with SDF file
PATH is a path of instances, separated with
/. Any separator can be used. Instances are component instantiation labels, generate labels or block labels. Currently, you cannot use an indexed name.
Specifying a delay:
--sdf=min=PATH=FILENAME --sdf=typ=PATH=FILENAME --sdf=max=PATH=FILENAME
If the option contains a type of delay, that is
max=, the annotator use respectively minimum, typical or maximum values. If the option does not contain a type of delay, the annotator uses the typical delay.
See section Backannotation, for more details.
Load VPI module.
Trace vpi calls to FILE.
Display a short description of the options accepted by the runtime library.
Filter signals to be dumped to the wave file according to the wave option file provided.
Here is a description of the wave option file format currently supported
$ version = 1.1 # Optional # Path format for signals in packages : my_pkg.global_signal_a # Path format for signals in entities : /top/sub/clk # Dump every signal named reset in first level sub entities of top /top/*/reset # Dump every signal named reset in recursive sub entities of top /top/**/reset # Dump every signal of sub2 which could be anywhere in the design except # on the top level /**/sub2/* # Dump every signal of sub3 which must be a first level sub entity of the # top level /*/sub3/* # Dump every signal of the first level sub entities of sub3 (but not # those of sub3) /**/sub3/*/*
If the wave option file doesn’t exist, creates it with all the signals of the design. Otherwise throws an error, because it won’t erase an existing file.
--vcddumps into the VCD file FILENAME the signal values before each non-delta cycle. If FILENAME is
-, then the standard output is used, otherwise a file is created or overwritten.
--vcdgzoption is the same as the –vcd option, but the output is compressed using the zlib (gzip compression). However, you can’t use the
-filename. Furthermore, only one VCD file can be written.
VCD (value change dump) is a file format defined by the verilog standard and used by virtually any wave viewer.
Since it comes from verilog, only a few VHDL types can be dumped. GHDL dumps only signals whose base type is of the following:
- types defined in the
- types defined in the
std_logic(because it is a subtype of
- any integer type
I have successfully used gtkwave to view VCD files.
Currently, there is no way to select signals to be dumped: all signals are dumped, which can generate big files.
It is very unfortunate there is no standard or well-known wave file format supporting VHDL types. If you are aware of such a free format, please mail me (Reporting bugs).
- types defined in the
Do not write date in the VCD file.
Write the waveforms into an fst file that can be displayed by gtkwave. The fst files are much smaller than VCD or GHW files, but it handles only the same signals as the VCD format.
Write the waveforms into a ghw (GHdl Waveform) file. Currently, all the signals are dumped into the waveform file, you cannot select a hierarchy of signals to be dumped.
The format of this file was defined by myself and is not yet completely fixed. It may change slightly. The
gtkwavetool can read the GHW files.
Contrary to VCD files, any VHDL type can be dumped into a GHW file.
Export hierarchy and references¶
Display the design hierarchy as a tree of instantiated design entities. This may be useful to understand the structure of a complex design. KIND is optional, but if set must be one of:
noneDo not display hierarchy. Same as if the option was not present.
instDisplay entities, architectures, instances, blocks and generates statements.
instbut also display processes.
procbut display ports and signals too. If KIND is not specified, the hierarchy is displayed with the
Stop the simulation before the first cycle. This may be used with
--disp-treeto display the tree without simulating the whole design. This option actually elaborates the design, so it will catch any bound error in port maps.
To easily navigate through your sources, you may generate cross-references. This command generates an html file for each
filegiven in the command line, with syntax highlighting and full cross-reference: every identifier is a link to its declaration. An index of the files is created too.
The set of
fileare analyzed, and then, if the analysis is successful, html files are generated in the directory specified by the
html/directory by default.
- If the option
--format=html2is specified, then the generated html files follow the HTML 2.0 standard, and colours are specified with <FONT> tags. However, colours are hard-coded.
- If the option
--format=cssis specified, then the generated html files follow the HTML 4.0 standard, and use the CSS-1 file
ghdl.cssto specify colours. This file is generated only if it does not already exist (it is never overwritten) and can be customized by the user to change colours or appearance. Refer to a generated file and its comments for more information.
- If the option
Write a report for PSL at the end of simulation. For each PSL cover and assert statements, the name, source location and whether it passed or failed is reported. The file is written using the JSON format, but is still human readable.
Outputs an XML representation of the decorated syntax tree for the input file and its dependencies. It can be used for VHDL tooling using semantic information, like style checkers, documentation extraction, complexity estimation, etc.
- The AST slightly changes from time to time (particularly when new nodes are added for new language features), so be liberal in what is allowed by your tool. Also, the XML can be quite large so consider it only during prototyping.
- Note that at this time there is no XML dump of the elaborated design.
Display signals after each cycle.
Display process name before each cycle.
Display run-time statistics.
Display signals order.
Display sources while displaying signals.
Display signal types.
Display map bw declared signals and internal signals.
Display internal signals.
Do internal checks after each process run.
Watch activity of LEVEL signals: LEVEL is
Dump Run Time Information (RTI).
GNU Debugger (GDB)¶
Debugging VHDL programs using GDB is possible only with GCC/LLVM.
GDB is a general purpose debugger for programs compiled by GCC. Currently, there is no VHDL support for GDB. It may be difficult to inspect variables or signals in GDB. However, it is still able to display the stack frame in case of error or to set a breakpoint at a specified line.
GDB can be useful to catch a runtime error, such as indexing an array beyond its bounds. All error check subprograms call the
__ghdl_fatal procedure. Therefore, to a catch runtime error, set a breakpoint like this:
(gdb) break __ghdl_fatal
When the breakpoint is hit, use the
bt command to display the stack frames.