\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename GHDL.info
@documentencoding UTF-8
@ifinfo
@*Generated by Sphinx 1.6.5.@*
@end ifinfo
@settitle GHDL Documentation
@defindex ge
@paragraphindent 0
@exampleindent 4
@finalout
@dircategory Miscellaneous
@direntry
* GHDL: (GHDL.info). VHDL simulator.
@end direntry
@definfoenclose strong,`,'
@definfoenclose emph,`,'
@c %**end of header
@copying
@quotation
GHDL 0.36-dev, Dec 15, 2017
Tristan Gingold and contributors
Copyright @copyright{} 2015-2017, Tristan Gingold and contributors
@end quotation
@end copying
@titlepage
@title GHDL Documentation
@insertcopying
@end titlepage
@contents
@c %** start of user preamble
@c %** end of user preamble
@ifnottex
@node Top
@top GHDL Documentation
@insertcopying
@end ifnottex
@c %**start of body
@anchor{index doc}@anchor{0}
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@c # This file provides the following shields: travis-ci appveyor release
@c # license mailing gitter issues-new issues-open issues-closed issues-pr
@c # issues-pr-closed github gh-logo
@c # Use http://b64.io/ to encode any image to base64. Then replace `/` with
@c # `%2F` and `+` with `%2B` (or use http://meyerweb.com/eric/tools/dencoder/).
@c # Beware that `?logo=data:image/png;base64,` must also be converted to
@c # percent encoding so that the URL is properly parsed.
__________________________________________________________________
This manual is the user and reference manual for GHDL. It does not contain an
introduction to VHDL. Thus, the reader should have at least a basic knowledge
of VHDL. A good knowledge of VHDL language reference manual (usually called
LRM) is a plus.
This document was generated on Dec 15, 2017 - 06:26.
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@menu
* About GHDL::
* Contributing::
* Copyrights | Licenses::
* Quick Start Guide::
* Invoking GHDL::
* Simulation and runtime::
* Releases and sources::
* Building GHDL from Sources::
* Precompile Vendor Primitives::
* Command Reference::
* Coding Style::
* Implementation of VHDL::
* Implementation of VITAL::
* Roadmap | Future Improvements::
* Meta::
* Index: Index<2>.
* Index::
@detailmenu
--- The Detailed Node Listing ---
About GHDL
* What is VHDL?::
* What is GHDL?::
* Who uses GHDL?::
Contributing
* Reporting bugs::
* Requesting enhancements::
* Improving the documentation::
* Fork@comma{} modify and pull-request: Fork modify and pull-request.
* Related interesting projects::
Copyrights | Licenses
* GNU GPLv2::
* CC-BY-SA::
* List of Contributors::
Quick Start Guide
* The ‘Hello world’ program::
* The heartbeat program::
* A full adder::
* Starting with a design::
Invoking GHDL
* Design building commands::
* Design rebuilding commands::
* Options::
* Warnings::
* Diagnostics Control::
* Library commands::
* VPI build commands::
* IEEE library pitfalls::
Design building commands
* Analysis [-a]::
* Elaboration [-e]::
* Run [-r]::
* Elaborate and run [--elab-run]::
* Check syntax [-s]::
* Analyze and elaborate [-c]::
Design rebuilding commands
* Import [-i]::
* Make [-m]::
* Generate Makefile [--gen-makefile]::
* Generate dependency file command [--gen-depends]::
Library commands
* Directory [--dir]::
* Clean [--clean]::
* Remove [--remove]::
* Copy [--copy]::
VPI build commands
* compile [--vpi-compile]::
* link [--vpi-link]::
* cflags [--vpi-cflags]::
* ldflags [--vpi-ldflags]::
* include dir [--vpi-include-dir]::
* library dir [--vpi-library-dir]::
Simulation and runtime
* Simulation options::
* Export waveforms::
* Export hierarchy and references::
* Debugging::
Debugging
* GNU Debugger (GDB): GNU Debugger GDB.
Releases and sources
* Downloading pre-built packages::
* Downloading Source Files::
Downloading Source Files
* Downloading from GitHub::
* Downloading via git clone::
Downloading via git clone
* On Linux::
* On OS X::
* On Windows::
Building GHDL from Sources
* Directory Structure::
* mcode Backend::
* LLVM Backend::
* GCC Backend::
mcode Backend
* mcode Backend on GNU/Linux with GCC/GNAT::
* mcode Backend on Windows with GNAT GPL::
* mcode Backend on Windows with GCC/GNAT (MinGW): mcode Backend on Windows with GCC/GNAT MinGW.
mcode Backend on Windows with GNAT GPL
* Requirements::
* Scripts and Parameters::
Scripts and Parameters
* compile.ps1: compile ps1.
LLVM Backend
* LLVM Backend on GNU/Linux with GCC/GNAT::
* LLVM Backend on Windows with GCC/GNAT (MinGW): LLVM Backend on Windows with GCC/GNAT MinGW.
GCC Backend
* GCC Backend on GNU/Linux with GCC/GNAT::
* GCC Backend on Windows with GCC/GNAT (MinGW): GCC Backend on Windows with GCC/GNAT MinGW.
Precompile Vendor Primitives
* Supported Vendors Libraries::
* Supported Simulation and Verification Libraries::
* Script Configuration::
* Compiling on Linux::
* Compiling on Windows::
* Configuration Files::
Configuration Files
* For Linux; config.sh: For Linux config sh.
* For Windows; config.psm1: For Windows config psm1.
* Selectable Options for the Bash Scripts;: Selectable Options for the Bash Scripts.
* Selectable Options for the PowerShell Scripts;: Selectable Options for the PowerShell Scripts.
Command Reference
* Environment variables::
* Misc commands::
* File commands::
* GCC/LLVM only commands::
* Options: Options<2>.
* Passing options to other programs::
Misc commands
* Help [-h]::
* Display config [--disp-config]::
* Display standard [--disp-standard]::
* Version [--version]::
File commands
* Pretty print [--pp-html]::
* Find [-f]::
* Chop [--chop]::
* Lines [--lines]::
GCC/LLVM only commands
* Bind [--bind]::
* Link [--link]::
* List link [--list-link]::
Implementation of VHDL
* VHDL standards::
* PSL implementation::
* Source representation::
* Library database::
* Top entity::
* Using vendor libraries::
* Interfacing to other languages::
Interfacing to other languages
* Foreign declarations::
* Restrictions on foreign declarations::
* Linking with foreign object files::
* Starting a simulation from a foreign program::
* Linking with Ada::
* Using GRT from Ada::
Implementation of VITAL
* VITAL packages::
* VHDL restrictions for VITAL::
* Backannotation::
* Negative constraint calculation::
Meta
* General guidelines to edit the documentation::
* Guidelines to edit section ‘Building’::
* Documentation configuration::
* CSS::
* Dist::
@end detailmenu
@end menu
@node About GHDL,Contributing,Top,Top
@anchor{about ghdl-documentation}@anchor{1}@anchor{about doc}@anchor{2}@anchor{about about-ghdl}@anchor{3}
@chapter About GHDL
@menu
* What is VHDL?::
* What is GHDL?::
* Who uses GHDL?::
@end menu
@node What is VHDL?,What is GHDL?,,About GHDL
@anchor{about intro-vhdl}@anchor{4}@anchor{about what-is-vhdl}@anchor{5}
@section What is @cite{VHDL}?
VHDL@footnote{https://en.wikipedia.org/wiki/VHDL} is an acronym for Very High Speed Integrated Circuit (VHSIC@footnote{https://en.wikipedia.org/wiki/VHSIC}) Hardware Description Language (HDL@footnote{https://en.wikipedia.org/wiki/HDL}), which is a programming language used to describe a logic circuit by function, data flow behavior, or structure.
Although VHDL was not designed for writing general purpose programs, VHDL @emph{is} a programming language, and you can write any algorithm with it. If you are able to write programs, you will find in VHDL features similar to those found in procedural languages such as @cite{C}, @cite{Python}, or @cite{Ada}. Indeed, VHDL derives most of its syntax and semantics from Ada. Knowing @cite{Ada} is an advantage for learning VHDL (it is an advantage in general as well).
However, VHDL was not designed as a general purpose language but as an @cite{HDL}. As the name implies, VHDL aims at modeling or documenting electronics systems. Due to the nature of hardware components which are always running, VHDL is a highly concurrent language, built upon an event-based timing model.
Like a program written in any other language, a VHDL program can be executed. Since VHDL is used to model designs, the term @emph{simulation} is often used instead of @cite{execution}, with the same meaning. At the same time, like a design written in another @cite{HDL}, a set of VHDL sources can be transformed with a @emph{synthesis tool} into a netlist, that is, a detailed gate-level implementation.
The development of VHDL started in 1983 and the standard is named IEEE@footnote{https://www.ieee.org/} @cite{1076}. Four revisions exist: 1987@footnote{http://ieeexplore.ieee.org/document/26487/}, 1993@footnote{http://ieeexplore.ieee.org/document/392561/}, 2002@footnote{http://ieeexplore.ieee.org/document/1003477/} and 2008@footnote{http://ieeexplore.ieee.org/document/4772740/}. The standardization is handled by the VHDL Analysis and Standardization Group (VASG/P1076@footnote{http://www.eda-twiki.org/vasg/}).
@node What is GHDL?,Who uses GHDL?,What is VHDL?,About GHDL
@anchor{about what-is-ghdl}@anchor{6}@anchor{about intro-ghdl}@anchor{7}
@section What is GHDL?
@cite{GHDL} is a shorthand for @cite{G Hardware Design Language} (currently, @cite{G} has no meaning). It is a VHDL compiler that can execute (nearly) any VHDL program. GHDL is @emph{not} a synthesis tool: you cannot create a netlist with GHDL (yet).
Unlike some other simulators, GHDL is a compiler: it directly translates a VHDL file to machine code, without using an intermediary language such as @cite{C} or @cite{C++}. Therefore, the compiled code should be faster and the analysis time should be shorter than with a compiler using an intermediary language.
GHDL can use multiple back-ends, i.e. code generators, (GCC@footnote{http://gcc.gnu.org/}, LLVM@footnote{http://llvm.org/} or x86@footnote{https://en.wikipedia.org/wiki/X86-64}/i386@footnote{https://en.wikipedia.org/wiki/Intel_80386} only, a built-in one) and runs on GNU/Linux@footnote{https://en.wikipedia.org/wiki/Linux_distribution}, Windows@footnote{https://en.wikipedia.org/wiki/Microsoft_Windows} ™ and macOS@footnote{https://en.wikipedia.org/wiki/MacOS} ™ , both on x86 and on x86_64.
The current version of GHDL does not contain any graphical viewer: you cannot see signal waves. You can still check the behavior of your design with a test bench. Moreover, the current version can produce a GHW@footnote{http://ghdl.readthedocs.io/en/latest/using/Simulation.html?highlight=GHW#cmdoption-wave}, VCD@footnote{https://en.wikipedia.org/wiki/Value_change_dump} or @cite{FST} files which can be viewed with a waveform viewer@footnote{https://en.wikipedia.org/wiki/Waveform_viewer}, such as GtkWave@footnote{http://gtkwave.sourceforge.net/}.
GHDL aims at implementing VHDL as defined by IEEE 1076@footnote{http://ieeexplore.ieee.org/document/4772740/}. It supports the 1987@footnote{http://ieeexplore.ieee.org/document/26487/}, 1993@footnote{http://ieeexplore.ieee.org/document/392561/} and 2002@footnote{http://ieeexplore.ieee.org/document/1003477/} revisions and, partially, the latest, 2008@footnote{http://ieeexplore.ieee.org/document/4772740/}. PSL@footnote{https://en.wikipedia.org/wiki/Property_Specification_Language} is also partially supported.
Several third party projects are supported: VUnit@footnote{https://vunit.github.io/}, OSVVM@footnote{http://osvvm.org/}, cocotb@footnote{https://github.com/potentialventures/cocotb} (through the VPI interface@footnote{https://en.wikipedia.org/wiki/Verilog_Procedural_Interface}), …
@node Who uses GHDL?,,What is GHDL?,About GHDL
@anchor{about intro-who}@anchor{8}@anchor{about who-uses-ghdl}@anchor{9}
@section Who uses GHDL?
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@c # This file provides the following shields: travis-ci appveyor release
@c # license mailing gitter issues-new issues-open issues-closed issues-pr
@c # issues-pr-closed github gh-logo
@c # Use http://b64.io/ to encode any image to base64. Then replace `/` with
@c # `%2F` and `+` with `%2B` (or use http://meyerweb.com/eric/tools/dencoder/).
@c # Beware that `?logo=data:image/png;base64,` must also be converted to
@c # percent encoding so that the URL is properly parsed.
@node Contributing,Copyrights | Licenses,About GHDL,Top
@anchor{contribute contributing}@anchor{a}@anchor{contribute doc}@anchor{b}@anchor{contribute intro-contributing}@anchor{c}
@chapter Contributing
The first step might be to use GHDL and explore it’s possibilities in an own project. If you are new to VHDL, see the
@ref{d,,Quick Start Guide} for an introduction. Furthermore, we encourage you to read @ref{e,,Invoking GHDL}, where the most
commonly used options are explained. You can also check the complete @ref{f,,Command Reference}.
If you are more familiar with GHDL, you might start asking yourself how it works internally. Then, you might find
@ref{10,,Implementation of VHDL} and @ref{11,,Implementation of VITAL} interesting.
While using GHDL, you might find flaws, such as bugs, missing features, typos in the documentation or topics which are
still not covered. In order to improve GHDL, we welcome bug reports, suggestions and contributions for any aspect of
GHDL. Either if it’s a bug or an enhancement, have a look at the and to see
if someone already told us about it. You might find a solution there.
If you found no information on your topic, please, report so that we are aware! You can reach us through various ways:
or open a .
@cartouche
@quotation Hint
Since the development of GHDL started fifteen years ago, multiple platforms have been used as a support for both distribution and getting feedback. However, the development is now centralized in github.
@end quotation
@end cartouche
@cartouche
@quotation Tip
How To Ask Questions The Smart Way@footnote{www.catb.org/~esr/faqs/smart-questions.html}
@end quotation
@end cartouche
@menu
* Reporting bugs::
* Requesting enhancements::
* Improving the documentation::
* Fork@comma{} modify and pull-request: Fork modify and pull-request.
* Related interesting projects::
@end menu
@node Reporting bugs,Requesting enhancements,,Contributing
@anchor{contribute reporting-bugs}@anchor{12}@anchor{contribute id1}@anchor{13}
@section Reporting bugs
@cartouche
@quotation Tip
@itemize *
@item
If the compiler crashes, this is a bug. Reliable tools never crash.
@item
If the compiler emits an error message for a perfectly valid input or does not emit an error message for an invalid input, this may be a bug.
@item
If the executable created from your VHDL sources crashes, this may be a bug at runtime or the code itself may be wrong. However, since VHDL has a notion of pointers, an erroneous VHDL program (using invalid pointers for example) may crash.
@item
If a compiler message is not clear enough, please tell us. The error messages can be improved, but we have not enough experience with them.
@end itemize
@end quotation
@end cartouche
Please, report issues of this kind through , as this allows us to categorize issues into groups and
assign developers to them. You can track the issue’s state and see how it’s getting solved.
@cartouche
@quotation Important
To make it easier, please elaborate a @cite{Minimum (non) Working Example} (MWE@footnote{https://en.wikipedia.org/wiki/Minimal_Working_Example}) prior to sending the report, so that the possible bug source is isolated. Shall the MWE compile and run, it is a good idea to make it look like a test and make an assert statement should finish the execution; the severity level @cite{note} indicates success, while a severity level @cite{failure} indicates failure.
Then, please include enough information for the maintainers to reproduce the problem. This includes:
@itemize *
@item
Operating system and version of GHDL (you can get it with @code{ghdl --version}).
@item
Whether you have built GHDL from sources (provide short SHA of the used commit) or used the binary distribution (tell which release/tag).
@itemize *
@item
If you cannot compile, please report which compiler you are using and the version.
@end itemize
@item
Content of the input files which make the MWE
@item
Description of the problem:
@itemize *
@item
Comment explaining whether the MWE should compile or not; if yes, whether or not is should run until the assertion.
@item
What you expected to happen and what you actually get. If you know the LRM well enough, please specify the paragraph which might be not well implemented.
@item
Samples of any log.
@item
Anything else that you think would be helpful.
@end itemize
@end itemize
@end quotation
@end cartouche
@cartouche
@quotation Note
If you don’t know the LRM, be aware that an issue claimed as bug report may be rejected because there is no bug according to it. GHDL aims at implementing VHDL as defined in IEEE 1076@footnote{http://ieeexplore.ieee.org/document/4772740/}. However, some other tools allow constructs which do not fully follow the standard revisions. Therefore, comparisons with other VHDL is not a solid argument. Some of them are supported by GHDL (see @ref{14,,IEEE library pitfalls}), but any such enhancement will have very low priority.
@end quotation
@end cartouche
@node Requesting enhancements,Improving the documentation,Reporting bugs,Contributing
@anchor{contribute requesting-enhancements}@anchor{15}@anchor{contribute id2}@anchor{16}
@section Requesting enhancements
All enhancements and feature requests are welcome. Please open a new issue@footnote{https://github.com/ghdl/ghdl/issues/new} to report any, so you can track the request’s status and implementation. Depending on the complexity of the request, you may want to chat on Gitter@footnote{https://gitter.im/ghdl/ghdl1}, to polish it before opening an issue.
@node Improving the documentation,Fork modify and pull-request,Requesting enhancements,Contributing
@anchor{contribute improving-the-documentation}@anchor{17}
@section Improving the documentation
If you found a mistake in the documentation, please send a comment. If you didn’t understand some parts of this manual,
please tell us. English is not our mother tongue, so this documentation may not be well-written.
Likewise, rewriting part of the documentation or missing content (such as, examples) is a good way to improve it. Since
it automatically is built from @cite{reStructuredText} and @cite{Markdown} sources, you can fork, modify and request the
maintainers to pull your copy. See @ref{18,,Fork@comma{} modify and pull-request}.
@node Fork modify and pull-request,Related interesting projects,Improving the documentation,Contributing
@anchor{contribute pull-request}@anchor{18}@anchor{contribute fork-modify-and-pull-request}@anchor{19}
@section Fork, modify and pull-request
@cartouche
@quotation Tip
@itemize *
@item
Before starting any modification, you might want to have a look at and , to check which other contributions are being made or have been made. If you observe that the modifications you are about to start might conflict with any other, please or open a to coordinate.
@item
See section @ref{1a,,Directory Structure} to faster find the location of the sources you need to modify, and/or to know where to place new ones.
@end itemize
@end quotation
@end cartouche
Contributing source code/documentation via Git@footnote{https://git-scm.com/} is very easy. Although we don’t provide direct
write access to our repositories, the project is hosted at GitHub, which follows a fork, edit and pull-request
flow@footnote{https://help.github.com/articles/github-flow/} . That is:
@enumerate
@item
Make a copy (fork@footnote{https://help.github.com/articles/fork-a-repo/}) of the project.
@item
Do the changes you wish (edit, add, rename, move and/or delete).
@item
When you think that the changes are ready to be merged, you notify the maintainers by opening a Pull Request@footnote{https://help.github.com/articles/creating-a-pull-request/} (PR).
@item
The maintainers will review the proposed changes and will reply in the corresponding thread if any further modification is required. If so, you can keep adding commits to the same branch, and the PR will be automatically updated.
@item
Last, the maintainers will merge your branch. You will be notified, the PR will be closed, and you’ll be allowed to delete the branch, if you want.
@end enumerate
@cartouche
@quotation Tip
@itemize *
@item
It is recommended to read A successful Git branching model@footnote{http://nvie.com/posts/a-successful-git-branching-model/} for a reference on how maintainers expect to handle multiple branches. However, our actual model is not as exhaustive as explained there.
@item
Some commit messages can automatically close@footnote{https://help.github.com/articles/closing-issues-via-commit-messages/} issues. This is a very useful feature, which you are not required to use. However beware that using @cite{fix} anywhere in the commit message can have side effects. If you closed any issue unexpectedly, just reply to it (even if it’s closed) so that maintainers can check it.
@item
It is recommended to read @ref{1b,,Coding Style} before contributing modifications to Ada sources.
@end itemize
@end quotation
@end cartouche
@node Related interesting projects,,Fork modify and pull-request,Contributing
@anchor{contribute related-interesting-projects}@anchor{1c}
@section Related interesting projects
If you have an interesting project, please send us feedback or get listed on our @ref{8,,Who uses GHDL?} page.
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@c # This file provides the following shields: travis-ci appveyor release
@c # license mailing gitter issues-new issues-open issues-closed issues-pr
@c # issues-pr-closed github gh-logo
@c # Use http://b64.io/ to encode any image to base64. Then replace `/` with
@c # `%2F` and `+` with `%2B` (or use http://meyerweb.com/eric/tools/dencoder/).
@c # Beware that `?logo=data:image/png;base64,` must also be converted to
@c # percent encoding so that the URL is properly parsed.
@node Copyrights | Licenses,Quick Start Guide,Contributing,Top
@anchor{licenses copyrights-licenses}@anchor{1d}@anchor{licenses doc}@anchor{1e}@anchor{licenses intro-copyrights}@anchor{1f}
@chapter Copyrights | Licenses
@itemize -
@item
The GHDL front-end, package @code{std.textio} and the runtime library, @code{grt}, are given under @ref{20,,GNU GPLv2}.
@item
The documentation is given under @ref{21,,CC-BY-SA}.
@end itemize
@cartouche
@quotation Warning
As a consequence of the runtime copyright, you are not allowed to distribute an executable produced by GHDL without the VHDL sources. To my mind, this is not a real restriction, since it is pointless to distribute VHDL executable. Please, send a comment (@ref{15,,Requesting enhancements}) if you don’t like this policy.
@end quotation
@end cartouche
@itemize -
@item
The following packages are copyrighted by third parties (see corresponding sources for more information):
@quotation
@itemize -
@item
These from library @code{ieee} are copyrighted by Institute of Electrical and Electronics Engineers (IEEE)@footnote{https://www.ieee.org} :
@quotation
@itemize -
@item
@code{numeric_bit} and @code{numeric_std}: the source files may be distributed without change, except as permitted by the standard; these may not be sold or distributed for profit. [see also IEEE 1076.3@footnote{http://ieeexplore.ieee.org/document/592543/} ]
@item
@code{std_logic_1164}, @code{Math_Real} and @code{Math_Complex}
@item
@code{VITAL_Primitives}, @code{VITAL_Timing} and @code{VITAL_Memory} [see also IEEE 1076.4@footnote{http://ieeexplore.ieee.org/document/954750/} ]
@end itemize
@end quotation
@item
The following sources may be used and distributed without restriction, provided that the copyright statements are not removed from the files and that any derivative work contains the copyright notice.
@quotation
@itemize -
@item
@code{synopsys} directory: @code{std_logic_arith}, @code{std_logic_signed}, @code{std_logic_unsigned} and @code{std_logic_textio} are copyrighted by Synopsys@comma{} Inc.@footnote{https://www.synopsys.com/}
@item
@code{mentor} directory: @code{std_logic_arith} is copyrighted by Mentor Graphics@footnote{https://www.mentor.com}
@end itemize
@end quotation
@end itemize
@end quotation
@end itemize
@menu
* GNU GPLv2::
* CC-BY-SA::
* List of Contributors::
@end menu
@node GNU GPLv2,CC-BY-SA,,Copyrights | Licenses
@anchor{licenses lic-gplv2}@anchor{20}@anchor{licenses gnu-gplv2}@anchor{22}
@section GNU GPLv2
GHDL is copyright © 2002 - 2017 Tristan Gingold.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but @strong{WITHOUT ANY WARRANTY}; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License@footnote{https://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for more details.
@node CC-BY-SA,List of Contributors,GNU GPLv2,Copyrights | Licenses
@anchor{licenses lic-cc-by-sa}@anchor{21}@anchor{licenses cc-by-sa}@anchor{23}
@section CC-BY-SA
This is a free documentation; you can redistribute it and/or modify it under the terms of the Creative Commons Attribution-ShareAlike 4.0@footnote{https://creativecommons.org/licenses/by-sa/4.0/} license. You are free to @strong{share} (copy and redistribute the material in any medium or format) and/or @strong{adapt} (remix, transform, and build upon the material for any purpose, even commercially). We cannot revoke these freedoms as long as you follow the these terms:
@itemize -
@item
@strong{Attribution}: you must provide the name of the creator and attribution parties (more info@footnote{https://wiki.creativecommons.org/wiki/License_Versions#Detailed_attribution_comparison_chart}), a copyright notice, a license notice, a disclaimer notice, a link to the material, a link to the license and indicate if changes were made (see marking guide@footnote{https://wiki.creativecommons.org/wiki/Best_practices_for_attribution#This_is_a_good_attribution_for_material_you_modified_slightly} and more info@footnote{https://wiki.creativecommons.org/wiki/License_Versions#Modifications_and_adaptations_must_be_marked_as_such} ). You may do so in any reasonable manner, but not in any way that suggests we endorses you or your use.
@item
@strong{ShareAlike}: if you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
@item
No additional restrictions: you may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
@end itemize
See CC-BY-SA-4.0 Legal Code@footnote{https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt} for more details.
@node List of Contributors,,CC-BY-SA,Copyrights | Licenses
@anchor{licenses lic-contributors}@anchor{24}@anchor{licenses list-of-contributors}@anchor{25}
@section List of Contributors
@multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
@headitem
Contributor @footnote{
In alphabetical order.
}
@tab
Role
@item
Baggett, Jonas
@tab
signal selection
@item
Bertram, Felix
@tab
VPI interface
@item
Davis, Brian
@tab
Windows Mcode builds
@item
Drummond, Brian
@tab
GCC 4.8.2 update, OSVVM port, some bugfixes
@item
Gingold, Tristan @footnote{
Maintainer.
}
@tab
@strong{Sole author of GHDL as a whole}
@item
Jensen, Adam
@tab
FreeBSD builds
@item
Koch, Markus
@tab
vendor pre-compile script for Lattice (GNU/Linux)
@item
Koontz, David
@tab
Mac OSX builds, LRM compliance work, bugfix analyses
@item
Lehmann, Patrick
@tab
Windows compile scripts, vendor library pre-compile scripts (win+lin), building in MinGW, AppVeyor integration.
@item
Martinez-Corral, Unai
@tab
Docker builds, Travis-CI & Docker, adapt/fix RTD theme
@item
van Rantwijk, Joris
@tab
Debian packaging
@end multitable
Only those who made substantial contributions are shown in the table above, but many others contributed with minor patches. You can find a list at
With apologies to anyone who ought to be either on this table or in the GitHub contributor list, but isn’t. Thanks also to all those who have reported bugs and support issues, and often patches and testcases to either the late gna! website or sourceforge.net/p/ghdl-updates/tickets@footnote{https://sourceforge.net/p/ghdl-updates/tickets/} .
__________________________________________________________________
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Quick Start Guide,Invoking GHDL,Copyrights | Licenses,Top
@anchor{using/QuickStartGuide quick-start-guide}@anchor{26}@anchor{using/QuickStartGuide using-quickstart}@anchor{d}@anchor{using/QuickStartGuide doc}@anchor{27}
@chapter Quick Start Guide
In this chapter, you will learn how to use @cite{GHDL} by working on a few examples.
@menu
* The ‘Hello world’ program::
* The heartbeat program::
* A full adder::
* Starting with a design::
@end menu
@node The ‘Hello world’ program,The heartbeat program,,Quick Start Guide
@anchor{using/QuickStartGuide the-hello-world-program}@anchor{28}
@section The @cite{‘Hello world’} program
To illustrate the large purpose of @cite{VHDL}, here is a commented @cite{‘Hello world’} program which saved in a file named @code{hello.vhdl}:
@example
-- Hello world program.
use std.textio.all; -- Imports the standard textio package.
-- Defines a design entity, without any ports.
entity hello_world is
end hello_world;
architecture behaviour of hello_world is
begin
process
variable l : line;
begin
write (l, String'("Hello world!"));
writeline (output, l);
wait;
end process;
end behaviour;
@end example
@cartouche
@quotation Tip
@itemize *
@item
Both @code{.vhdl} and @code{.vhd} extensions are used for VHDL source files, while @code{.v} is used for Verilog.
@item
Unless you use especial characters, either @cite{UTF-8} or @cite{ISO-8859-1} encodings can be used. However, if you do, the latter should be used. The standard defines ASCII (7-bit encoding) or ISO Latin-1 (ISO-8859-1) as default. However, GHDL has a relaxing option, @ref{29,,--mb-comments} (multi byte), to allow UTF-8 or other encodings in comments.
@end itemize
@end quotation
@end cartouche
@itemize -
@item
First, you have to compile the file; this is called @cite{analysis} of a design file in @cite{VHDL} terms. Run @code{ghdl -a hello.vhdl} in the @cite{shell}. This command creates or updates a file @code{work-obj93.cf}, which describes the library @code{work}.
@item
Then, run @code{ghdl -e hello_world} in the @cite{shell}. Option @ref{2a,,-e} means @emph{elaborate}, which is used to build a design, with the @code{hello_world} entity at the top of the hierarchy.
@item
Last, you can directly launch the simulation running @code{ghdl -r hello_world} in the @cite{shell}. The result of the simulation will be shown on screen:
@end itemize
@example
Hello world!
@end example
@cartouche
@quotation Hint
If a GCC/LLVM variant of @cite{GHDL} is used:
@itemize *
@item
@cite{Analysis} generates a file, @code{hello.o}, which is the object file corresponding to your @cite{VHDL} program. This is not created with mcode.
@item
The elaboration step is compulsory after the analysis and prior to launching the simulation; This wil generate an executable binary named @code{hello_world}.
@item
As a result, @ref{2b,,-r} is just a passthrough to the binary generated in the @cite{elaboration}. Therefore, the executable can be run directly, @code{./hello_world}. See @ref{2b,,-r} for more informartion.
@end itemize
@end quotation
@end cartouche
@cartouche
@quotation Hint
@ref{2a,,-e} can be bypassed with mcode, since @ref{2b,,-r} actually elaborates the design and saves it on memory before running the simulation. But you can still use it to check for some elaboration problems.
@end quotation
@end cartouche
@node The heartbeat program,A full adder,The ‘Hello world’ program,Quick Start Guide
@anchor{using/QuickStartGuide the-heartbeat-program}@anchor{2c}
@section The @cite{heartbeat} program
@example
entity heartbeat is
port ( clk: out std_logic; )
end hearbeat;
architecture behaviour of hello_world is
begin
-- Clock process definition
clk_process: process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
end behaviour;
@end example
@node A full adder,Starting with a design,The heartbeat program,Quick Start Guide
@anchor{using/QuickStartGuide a-full-adder}@anchor{2d}
@section A full adder
VHDL is generally used for hardware design. This example starts with a full adder@footnote{https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder} described in a file named @code{adder.vhdl}:
@example
entity adder is
-- `i0`, `i1` and the carry-in `ci` are inputs of the adder.
-- `s` is the sum output, `co` is the carry-out.
port (i0, i1 : in bit; ci : in bit; s : out bit; co : out bit);
end adder;
architecture rtl of adder is
begin
-- This full-adder architecture contains two concurrent assignment.
-- Compute the sum.
s <= i0 xor i1 xor ci;
-- Compute the carry.
co <= (i0 and i1) or (i0 and ci) or (i1 and ci);
end rtl;
@end example
You can analyze this design file, @code{ghdl -a adder.vhdl}, and try to execute the @cite{adder} design. But this is useless, since nothing externally visible will happen. In order to check this full adder, a @emph{testbench} has to be run. This testbench is very simple, since the adder is also simple: it checks exhaustively all inputs. Note that only the behaviour is tested, timing constraints are not checked. A file named @code{adder_tb.vhdl} contains the testbench for the adder:
@example
-- A testbench has no ports.
entity adder_tb is
end adder_tb;
architecture behav of adder_tb is
-- Declaration of the component that will be instantiated.
component adder
port (i0, i1 : in bit; ci : in bit; s : out bit; co : out bit);
end component;
-- Specifies which entity is bound with the component.
for adder_0: adder use entity work.adder;
signal i0, i1, ci, s, co : bit;
begin
-- Component instantiation.
adder_0: adder port map (i0 => i0, i1 => i1, ci => ci,
s => s, co => co);
-- This process does the real job.
process
type pattern_type is record
-- The inputs of the adder.
i0, i1, ci : bit;
-- The expected outputs of the adder.
s, co : bit;
end record;
-- The patterns to apply.
type pattern_array is array (natural range <>) of pattern_type;
constant patterns : pattern_array :=
(('0', '0', '0', '0', '0'),
('0', '0', '1', '1', '0'),
('0', '1', '0', '1', '0'),
('0', '1', '1', '0', '1'),
('1', '0', '0', '1', '0'),
('1', '0', '1', '0', '1'),
('1', '1', '0', '0', '1'),
('1', '1', '1', '1', '1'));
begin
-- Check each pattern.
for i in patterns'range loop
-- Set the inputs.
i0 <= patterns(i).i0;
i1 <= patterns(i).i1;
ci <= patterns(i).ci;
-- Wait for the results.
wait for 1 ns;
-- Check the outputs.
assert s = patterns(i).s
report "bad sum value" severity error;
assert co = patterns(i).co
report "bad carry out value" severity error;
end loop;
assert false report "end of test" severity note;
-- Wait forever; this will finish the simulation.
wait;
end process;
end behav;
@end example
As usual, you should analyze the design, @code{ghdl -a adder_tb.vhdl}.
@cartouche
@quotation Hint
Then, if required, elaborate the testbench: @code{ghdl -e adder_tb}. You do not need to specify which object files are required, since GHDL knows them and automatically adds them.
@end quotation
@end cartouche
Now, it is time to run the testbench, @code{ghdl -r adder_tb}, and check the result on screen:
@example
adder_tb.vhdl:52:7:(assertion note): end of test
@end example
If your design is rather complex, you’d like to inspect signals. Signal values can be dumped using multiple formats (see section ‘@ref{2e,,Export waveforms}’ for more information). The resulting file can be read with a wave viewer such as GtkWave@footnote{http://gtkwave.sourceforge.net/}.
As explained in the manual@footnote{http://gtkwave.sourceforge.net/gtkwave.pdf}, GtkWave @emph{‘relies on a post-mortem approach through the use of dumpfiles’}. Therefore, you should first simulate your design and dump a waveform file, say VCD: @code{ghdl -r adder_tb --vcd=adder.vcd}. Then, you can view the dump: @code{gtkwave adder.vcd}.
See section ‘@ref{2f,,Simulation options}’, for more details on other runtime options.
@node Starting with a design,,A full adder,Quick Start Guide
@anchor{using/QuickStartGuide starting-with-a-design}@anchor{30}
@section Starting with a design
Unless you are only studying VHDL, you will work with larger designs than the ones of the previous examples. Let’s see how to analyze and run a bigger design, such as the DLX model suite written by Peter Ashenden which is distributed under the terms of the GNU General Public License. A copy is kept on ghdl.free.fr/dlx.tar.gz@footnote{http://ghdl.free.fr/dlx.tar.gz} .
@itemize -
@item
First, untar the sources: @code{tar zxvf dlx.tar.gz}.
@end itemize
@cartouche
@quotation Hint
In order not to pollute the sources with the library, it is a good idea to create a @code{work/} subdirectory for the @cite{WORK} library. To any GHDL commands, we will add the @code{--workdir=work} option, so that all files generated by the compiler (except the executable) will be placed in this directory.
@example
$ cd dlx
$ mkdir work
@end example
@end quotation
@end cartouche
@itemize *
@item
Then, we will run the @code{dlx_test_behaviour} design. We need to analyze all the design units for the design hierarchy, in the correct order. GHDL provides an easy way to do this, by importing the sources, @code{ghdl -i --workdir=work *.vhdl}.
@item
GHDL knows all the design units of the DLX, but no one have been analyzed. Run the make option, @code{ghdl -m --workdir=work dlx_test_behaviour}, which analyzes and elaborates a design. This creates many files in the @code{work/} directory, and (GCC/LLVM only) the @code{dlx_test_behaviour} executable in the current directory.
@end itemize
@cartouche
@quotation Hint
The simulation needs to have a DLX program contained in the file @code{dlx.out}. This memory image will be loaded in the DLX memory. Just take one sample: @code{cp test_loop.out dlx.out}.
@end quotation
@end cartouche
@itemize *
@item
Now, you can run the test suite: @code{ghdl -r --workdir=work dlx_test_behaviour}. The test bench monitors the bus and displays each instruction executed. It finishes with an assertion of severity level note:
@example
dlx-behaviour.vhdl:395:11:(assertion note): TRAP instruction
encountered, execution halted
@end example
@item
Last, since the clock is still running, you have to manually stop the program with the @code{C-c} key sequence. This behavior prevents you from running the test bench in batch mode. However, you may force the simulator to stop when an assertion above or equal a certain severity level occurs. To do so, call run with this option instead: @code{ghdl -r --workdir=work dlx_test_behaviour --assert-level=note`}. With this option, the program stops just after the previous message:
@example
dlx-behaviour.vhdl:395:11:(assertion note): TRAP instruction
encountered, execution halted
error: assertion failed
@end example
@end itemize
@cartouche
@quotation Tip
If you want to make room on your hard drive, you can either:
@itemize *
@item
Clean the design library with the GHDL command @code{ghdl --clean --workdir=work}. This removes the executable and all the object files. If you want to rebuild the design at this point, just do the make command as shown above.
@item
Remove the design library with the GHDL command @code{ghdl --remove --workdir=work}. This removes the executable, all the object files and the library file. If you want to rebuild the design, you have to import the sources again, and to make the design.
@item
Remove the @code{work/} directory: @code{rm -rf work}. Only the executable is kept. If you want to rebuild the design, create the @code{work/} directory, import the sources, and make the design.
@end itemize
@end quotation
@end cartouche
@cartouche
@quotation Warning
Sometimes, a design does not fully follow the VHDL standards. For example it uses the badly engineered @code{std_logic_unsigned} package. GHDL supports this VHDL dialect through some options: @code{--ieee=synopsys -fexplicit}. See section ‘@ref{14,,IEEE library pitfalls}’, for more details.
@end quotation
@end cartouche
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Invoking GHDL,Simulation and runtime,Quick Start Guide,Top
@anchor{using/InvokingGHDL using-invoking}@anchor{e}@anchor{using/InvokingGHDL doc}@anchor{31}@anchor{using/InvokingGHDL invoking-ghdl}@anchor{32}
@chapter Invoking GHDL
The form of the @code{ghdl} command is @code{ghdl command [options...]}. There are multiple available commands, but these general rules apply:
@itemize *
@item
The first argument selects the command. The options are used to slightly modify the action.
@item
No option is allowed before the command. Except for the run command, no option is allowed after a filename or a unit name.
@end itemize
@cartouche
@quotation Hint
If the number of options is large and the command line length is beyond the system limit, you can use a response file. An argument that starts with a @code{@@} is considered as a response file; it is replaced by arguments read from the file (separated by blanks and end of line).
@end quotation
@end cartouche
@cartouche
@quotation Hint
Only the most common commands and options are shown here. For most advanced and experimental features see section @ref{f,,Command Reference}.
@end quotation
@end cartouche
@cartouche
@quotation Warning
During analysis and elaboration GHDL may read the @code{std} and @code{ieee} files. The location of these files is based on the prefix, which is (in priority order):
@quotation
@itemize *
@item
the @code{--PREFIX} command line option
@item
the
@geindex GHDL_PREFIX
@geindex environment variable; GHDL_PREFIX
@ref{33,,GHDL_PREFIX} environment variable
@item
a built-in default path. It is a hard-coded path on GNU/Linux, and it corresponds to the value of the @code{HKLM\Software\Ghdl\Install_Dir} registry entry on Windows.
@end itemize
You should use the @ref{34,,--disp-config} command to display and debug installation problems.
@end quotation
@end quotation
@end cartouche
@menu
* Design building commands::
* Design rebuilding commands::
* Options::
* Warnings::
* Diagnostics Control::
* Library commands::
* VPI build commands::
* IEEE library pitfalls::
@end menu
@node Design building commands,Design rebuilding commands,,Invoking GHDL
@anchor{using/InvokingGHDL design-building-commands}@anchor{35}
@section Design building commands
The mostly used commands of GHDL are those to analyze and elaborate a design.
@geindex cmd analysis
@menu
* Analysis [-a]::
* Elaboration [-e]::
* Run [-r]::
* Elaborate and run [--elab-run]::
* Check syntax [-s]::
* Analyze and elaborate [-c]::
@end menu
@node Analysis [-a],Elaboration [-e],,Design building commands
@anchor{using/InvokingGHDL analysis-a}@anchor{36}
@subsection Analysis [@code{-a}]
@geindex ghdl command line option; -a <[options...] file...>
@anchor{using/InvokingGHDL cmdoption-ghdl-a}@anchor{37}
@deffn {Option} @w{-}a <[options...] file...>
@end deffn
Analyzes/compiles one or more files, and creates an object file for each source file. Any argument starting with a dash is an option, the others are filenames. No options are allowed after a filename argument. GHDL analyzes each filename in the given order, and stops the analysis in case of error (remaining files are not analyzed).
See GHDL_options, for details on the GHDL options. For example, to produce debugging information such as line numbers, use: @code{ghdl -a -g my_design.vhdl}.
@geindex cmd elaboration
@node Elaboration [-e],Run [-r],Analysis [-a],Design building commands
@anchor{using/InvokingGHDL elaboration-e}@anchor{38}
@subsection Elaboration [@code{-e}]
@geindex ghdl command line option; -e <[options...] primary_unit [secondary_unit]>
@anchor{using/InvokingGHDL cmdoption-ghdl-e}@anchor{2a}
@deffn {Option} @w{-}e <[options...] primary_unit [secondary_unit]>
@end deffn
Re-analyzes all the configurations, entities, architectures and package declarations, and creates the default configurations and the default binding indications according to the LRM rules. It also generates the list of objects files required for the executable. Then, it links all these files with the runtime library. The actual elaboration is performed at runtime.
@itemize *
@item
The elaboration command, @ref{2a,,-e}, must be followed by a name of either:
@quotation
@itemize *
@item
a configuration unit
@item
an entity unit
@item
an entity unit followed by a name of an architecture unit
@end itemize
@end quotation
@end itemize
Name of the units must be a simple name, without any dot. You can select the name of the @cite{WORK} library with the @code{--work=NAME} option, as described in GHDL_options. See section ‘@ref{39,,Top entity}’, for the restrictions on the root design of a hierarchy.
@itemize *
@item
If the GCC/LLVM backend was enabled during the compilation of GHDL, the elaboration command creates an executable containing the code of the VHDL sources, the elaboration code and simulation code to execute a design hierarchy. The executable is created in the current directory and the the filename is the name of the primary unit, or for the later case, the concatenation of the name of the primary unit, a dash, and the name of the secondary unit (or architecture). Option @code{-o} followed by a filename can override the default executable filename.
@item
If mcode is used, this command elaborates the design but does not generate anything. Since the run command also elaborates the design, this con be skipped.
@end itemize
@geindex cmd run
@node Run [-r],Elaborate and run [--elab-run],Elaboration [-e],Design building commands
@anchor{using/InvokingGHDL run-r}@anchor{3a}
@subsection Run [@code{-r}]
@geindex ghdl command line option; -r <[options...] primary_unit [secondary_unit] [simulation_options...]>
@anchor{using/InvokingGHDL cmdoption-ghdl-r}@anchor{2b}
@deffn {Option} @w{-}r <[options...] primary_unit [secondary_unit] [simulation_options...]>
@end deffn
Runs/simulates a design. The options and arguments are the same as for the elaboration command.
@itemize *
@item
GGC/LLVM: simply, the filename of the executable is determined and it is executed. Options are ignored. You may also directly execute the program. The executable must be in the current directory.
@item
mcode: the design is elaborated and the simulation is launched. As a consequence, you must use the same options used during analysis.
@end itemize
This command exists for three reasons:
@itemize *
@item
You are using GCC/LLVM, but you don’t need to create the executable program name.
@item
It is coherent with the @ref{37,,-a} and @ref{2a,,-e} commands.
@item
It works with mcode implementation, where the executable code is generated in memory.
@end itemize
See section ‘@ref{3b,,Simulation and runtime}’, for details on options.
@geindex cmd elaborate and run
@node Elaborate and run [--elab-run],Check syntax [-s],Run [-r],Design building commands
@anchor{using/InvokingGHDL elaborate-and-run-elab-run}@anchor{3c}
@subsection Elaborate and run [@code{--elab-run}]
@geindex ghdl command line option; --elab-run <[elab_options...] primary_unit [secondary_unit] [run_options...]>
@anchor{using/InvokingGHDL cmdoption-ghdl-elab-run}@anchor{3d}
@deffn {Option} @w{-}@w{-}elab@w{-}run <[elab_options...] primary_unit [secondary_unit] [run_options...]>
@end deffn
Acts like the elaboration command (see @ref{2a,,-e}) followed by the run command (see @ref{2b,,-r}).
@geindex cmd checking syntax
@node Check syntax [-s],Analyze and elaborate [-c],Elaborate and run [--elab-run],Design building commands
@anchor{using/InvokingGHDL check-syntax-s}@anchor{3e}
@subsection Check syntax [@code{-s}]
@geindex ghdl command line option; -s <[options] files>
@anchor{using/InvokingGHDL cmdoption-ghdl-s}@anchor{3f}
@deffn {Option} @w{-}s <[options] files>
@end deffn
Analyze files but do not generate code. This command may be used to check the syntax of files. It does not update the library.
@geindex cmd analyze and elaborate
@node Analyze and elaborate [-c],,Check syntax [-s],Design building commands
@anchor{using/InvokingGHDL analyze-and-elaborate-c}@anchor{40}
@subsection Analyze and elaborate [@code{-c}]
@geindex ghdl command line option; -c <[options] file... - primary_unit [secondary_unit]>
@anchor{using/InvokingGHDL cmdoption-ghdl-c}@anchor{41}
@deffn {Option} @w{-}c <[options] file... @w{-} primary_unit [secondary_unit]>
@end deffn
@cartouche
@quotation Hint
With GCC/LLVM, @ref{2a,,-e} should be used, and @ref{2b,,-r} with mcode.
@end quotation
@end cartouche
The files are first parsed, and then a elaboration is performed, which drives an analysis. Effectively, analysis and elaboration are combined, but there is no explicit call to @ref{37,,-a}. With GCC/LLVM, code is generated during the elaboration. With mcode, the simulation is launched after the elaboration.
All the units of the files are put into the @cite{work} library. But, the work library is neither read from disk nor saved. Therefore, you must give all the files of the @cite{work} library your design needs.
The advantages over the traditional approach (analyze and then elaborate) are:
@itemize *
@item
The compilation cycle is achieved in one command.
@item
Since the files are only parsed once, the compilation cycle may be faster.
@item
You don’t need to know an analysis order.
@item
This command produces smaller executable, since unused units and subprograms do not generate code.
@end itemize
@cartouche
@quotation Hint
However, you should know that currently most of the time is spent in code generation and the analyze and elaborate command generate code for all units needed, even units of @code{std} and @code{ieee} libraries. Therefore, according to the design, the time for this command may be higher than the time for the analyze command followed by the elaborate command.
@end quotation
@end cartouche
@cartouche
@quotation Warning
This command is still under development. In case of problems, you should go back to the traditional way.
@end quotation
@end cartouche
@node Design rebuilding commands,Options,Design building commands,Invoking GHDL
@anchor{using/InvokingGHDL design-rebuilding-commands}@anchor{42}
@section Design rebuilding commands
Analyzing and elaborating a design consisting in several files can be tricky, due to dependencies. GHDL has a few commands to rebuild a design.
@geindex cmd importing files
@menu
* Import [-i]::
* Make [-m]::
* Generate Makefile [--gen-makefile]::
* Generate dependency file command [--gen-depends]::
@end menu
@node Import [-i],Make [-m],,Design rebuilding commands
@anchor{using/InvokingGHDL import-i}@anchor{43}
@subsection Import [@code{-i}]
@geindex ghdl command line option; -i <[options] file...>
@anchor{using/InvokingGHDL cmdoption-ghdl-i}@anchor{44}
@deffn {Option} @w{-}i <[options] file...>
@end deffn
All the files specified in the command line are scanned, parsed and added in the libraries but as not yet analyzed. No object files are created. It’s purpose is to localize design units in the design files. The make command will then be able to recursively build a hierarchy from an entity name or a configuration name.
@cartouche
@quotation Hint
@itemize *
@item
Note that all the files are added to the work library. If you have many libraries, you must use the command for each library.
@item
Since the files are parsed, there must be correct files. However, since they are not analyzed, many errors are tolerated by this command.
@end itemize
@end quotation
@end cartouche
See @ref{45,,-m}, to actually build the design.
@geindex cmd make
@node Make [-m],Generate Makefile [--gen-makefile],Import [-i],Design rebuilding commands
@anchor{using/InvokingGHDL make-m}@anchor{46}
@subsection Make [@code{-m}]
@geindex ghdl command line option; -m <[options] primary [secondary]>
@anchor{using/InvokingGHDL cmdoption-ghdl-m}@anchor{45}
@deffn {Option} @w{-}m <[options] primary [secondary]>
@end deffn
Analyze automatically outdated files and elaborate a design. The primary unit denoted by the @code{primary} argument must already be known by the system, either because you have already analyzed it (even if you have modified it) or because you have imported it. A file may be outdated because it has been modified (e.g. you just have edited it), or because a design unit contained in the file depends on a unit which is outdated. This rule is of course recursive.
@itemize *
@item
With option @ref{47,,--bind}, GHDL will stop before the final linking step. This is useful when the main entry point is not GHDL and you’re linking GHDL object files into a foreign program.
@item
With option @ref{48,,-f} (force), GHDL analyzes all the units of the work library needed to create the design hierarchy. Not outdated units are recompiled. This is useful if you want to compile a design hierarchy with new compilation flags (for example, to add the @emph{-g} debugging option).
@end itemize
The make command will only re-analyze design units in the work library. GHDL fails if it has to analyze an outdated unit from another library.
The purpose of this command is to be able to compile a design without prior knowledge of file order. In the VHDL model, some units must be analyzed before others (e.g. an entity before its architecture). It might be a nightmare to analyze a full design of several files, if you don’t have the ordered list of file. This command computes an analysis order.
The make command fails when a unit was not previously parsed. For example, if you split a file containing several design units into several files, you must either import these new files or analyze them so that GHDL knows in which file these units are.
The make command imports files which have been modified. Then, a design hierarchy is internally built as if no units are outdated. Then, all outdated design units, using the dependencies of the design hierarchy, are analyzed. If necessary, the design hierarchy is elaborated.
This is not perfect, since the default architecture (the most recently analyzed one) may change while outdated design files are analyzed. In such a case, re-run the make command of GHDL.
@geindex cmd generate makefile
@node Generate Makefile [--gen-makefile],Generate dependency file command [--gen-depends],Make [-m],Design rebuilding commands
@anchor{using/InvokingGHDL generate-makefile-gen-makefile}@anchor{49}
@subsection Generate Makefile [@code{--gen-makefile}]
@geindex ghdl command line option; --gen-makefile <[options] primary [secondary]>
@anchor{using/InvokingGHDL cmdoption-ghdl-gen-makefile}@anchor{4a}
@deffn {Option} @w{-}@w{-}gen@w{-}makefile <[options] primary [secondary]>
@end deffn
This command works like the make command (see @ref{45,,-m}), but only a makefile is generated on the standard output.
@geindex --gen-depends command
@node Generate dependency file command [--gen-depends],,Generate Makefile [--gen-makefile],Design rebuilding commands
@anchor{using/InvokingGHDL generate-dependency-file-command-gen-depends}@anchor{4b}
@subsection Generate dependency file command [@code{--gen-depends}]
@geindex ghdl command line option; --gen-depends <[options] primary [secondary]>
@anchor{using/InvokingGHDL cmdoption-ghdl-gen-depends}@anchor{4c}
@deffn {Option} @w{-}@w{-}gen@w{-}depends <[options] primary [secondary]>
@end deffn
Generate a Makefile containing only dependencies to build a design unit.
This command works like the make and gen-makefile commands (see @ref{45,,-m}), but instead of a full makefile only dependencies without rules are generated on the standard output.
Theses rules can then be integrated in another Makefile.
@node Options,Warnings,Design rebuilding commands,Invoking GHDL
@anchor{using/InvokingGHDL options}@anchor{4d}
@section Options
@geindex IEEE 1164
@geindex 1164
@geindex IEEE 1076.3
@geindex 1076.3
@cartouche
@quotation Hint
Besides the options described below, @cite{GHDL} passes any debugging options (those that begin with -g@footnote{http://poc-library.readthedocs.io/en/release/References/CmdRefs/PoC.html#cmdoption-poc-py-xsim-g}) and optimizations options (those that begin with -O@footnote{https://docs.python.org/3.6/using/cmdline.html#cmdoption-o} or @ref{48,,-f}) to @cite{GCC}. Refer to the @cite{GCC} manual for details.
@end quotation
@end cartouche
@geindex WORK library
@geindex ghdl command line option; --work<=NAME>
@anchor{using/InvokingGHDL cmdoption-ghdl-work}@anchor{4e}
@deffn {Option} @w{-}@w{-}work<=NAME>
Specify the name of the @code{WORK} library. Analyzed units are always placed in the library logically named @code{WORK}. With this option, you can set its name. By default, the name is @code{work}.
@cite{GHDL} checks whether @code{WORK} is a valid identifier. Although being more or less supported, the @code{WORK} identifier should not be an extended identifier, since the filesystem may prevent it from correctly working (due to case sensitivity or forbidden characters in filenames).
@cite{VHDL} rules forbid you to add units to the @code{std} library. Furthermore, you should not put units in the @code{ieee} library.
@end deffn
@geindex ghdl command line option; --workdir<=DIR>
@anchor{using/InvokingGHDL cmdoption-ghdl-workdir}@anchor{4f}
@deffn {Option} @w{-}@w{-}workdir<=DIR>
Specify the directory where the @code{WORK} library is located. When this option is not present, the @code{WORK} library is in the current directory. The object files created by the compiler are always placed in the same directory as the @code{WORK} library.
Use option @code{-P} to specify where libraries other than @code{WORK} are placed.
@end deffn
@geindex ghdl command line option; --std<=STD>
@anchor{using/InvokingGHDL cmdoption-ghdl-std}@anchor{50}
@deffn {Option} @w{-}@w{-}std<=STD>
Specify the standard to use. By default, the standard is @code{93c}, which means VHDL-93 accepting VHDL-87 syntax. For details on @code{STD} values see section ‘@ref{51,,VHDL standards}’.
@end deffn
@geindex ghdl command line option; --ieee<=VER>
@anchor{using/InvokingGHDL cmdoption-ghdl-ieee}@anchor{52}
@deffn {Option} @w{-}@w{-}ieee<=VER>
@geindex ieee library
@geindex synopsys library
@geindex mentor library
Select the @code{IEEE} library to use. @code{VER} must be one of:
@table @asis
@item none
Do not supply an @cite{IEEE} library. Any library clause with the @code{IEEE}
identifier will fail, unless you have created by your own a library with
the @cite{IEEE} name.
@item standard
Supply an @cite{IEEE} library containing only packages defined by
@code{ieee} standards. Currently, there are the multivalue logic system
packages @code{std_logic_1164} defined by IEEE 1164, the synthesis
packages , @code{numeric_bit} and @code{numeric_std} defined by IEEE
1076.3, and the @code{vital} packages @code{vital_timing} and
@code{vital_primitives}, defined by IEEE 1076.4. The version of these
packages is defined by the VHDL standard used. See section ‘@ref{53,,VITAL packages}’,
for more details.
@item synopsys
Supply the former packages and the following additional packages:
@code{std_logic_arith}, @code{std_logic_signed},
@code{std_logic_unsigned}, @code{std_logic_textio}.
These packages were created by some companies, and are popular. However
they are not standard packages, and have been placed in the @cite{IEEE}
library without the permission from the @code{ieee}.
@item mentor
Supply the standard packages and the following additional package:
@code{std_logic_arith}. The package is a slight variation of a definitely
not standard but widely mis-used package.
@end table
To avoid errors, you must use the same @cite{IEEE} library for all units of
your design, and during elaboration.
@end deffn
@geindex ghdl command line option; -P
@anchor{using/InvokingGHDL cmdoption-ghdl-p-directory}@anchor{54}
@deffn {Option} @w{-}P
Add @cite{DIRECTORY} to the end of the list of directories to be searched for
library files. A library is searched in @cite{DIRECTORY} and also in
@cite{DIRECTORY/LIB/vVV} (where @cite{LIB} is the name of the library and @cite{VV}
the vhdl standard).
The @cite{WORK} library is always searched in the path specified by the
@code{--workdir} option, or in the current directory if the latter
option is not specified.
@end deffn
@geindex ghdl command line option; -fexplicit
@anchor{using/InvokingGHDL cmdoption-ghdl-fexplicit}@anchor{55}
@deffn {Option} @w{-}fexplicit
When two operators are overloaded, give preference to the explicit declaration.
This may be used to avoid the most common pitfall of the @code{std_logic_arith}
package. See section ‘@ref{14,,IEEE library pitfalls}’, for an example.
@end deffn
@cartouche
@quotation Warning
This option is not set by default. I don’t think this option is a good feature, because it breaks the encapsulation rule. When set, an operator can be silently overridden in another package. You’d better fix your design and use the @code{numeric_std} package.
@end quotation
@end cartouche
@geindex ghdl command line option; -frelaxed-rules
@anchor{using/InvokingGHDL cmdoption-ghdl-frelaxed-rules}@anchor{56}
@deffn {Option} @w{-}frelaxed@w{-}rules
Within an object declaration, allow to reference the name (which references the hidden declaration). This ignores the error in the following code:
@example
package pkg1 is
type state is (state1, state2, state3);
end pkg1;
use work.pkg1.all;
package pkg2 is
constant state1 : state := state1;
end pkg2;
@end example
Some code (such as Xilinx packages) have such constructs, which are valid.
(The scope of the @code{state1} constant start at the @cite{constant} word. Because the constant @code{state1} and the enumeration literal @code{state1} are homograph, the enumeration literal is hidden in the immediate scope of the constant).
This option also relaxes the rules about pure functions. Violations result in warnings instead of errors.
@end deffn
@geindex ghdl command line option; -fpsl
@anchor{using/InvokingGHDL cmdoption-ghdl-fpsl}@anchor{57}
@deffn {Option} @w{-}fpsl
Enable parsing of PSL assertions within comments. See section ‘@ref{58,,PSL implementation}’ for more details.
@end deffn
@geindex ghdl command line option; --no-vital-checks
@anchor{using/InvokingGHDL cmdoption-ghdl-no-vital-checks}@anchor{59}
@deffn {Option} @w{-}@w{-}no@w{-}vital@w{-}checks
@end deffn
@geindex ghdl command line option; --vital-checks
@anchor{using/InvokingGHDL cmdoption-ghdl-vital-checks}@anchor{5a}
@deffn {Option} @w{-}@w{-}vital@w{-}checks
Disable or enable checks of restriction on VITAL units. Checks are enabled by default.
Checks are performed only when a design unit is decorated by a VITAL attribute. The VITAL attributes are @code{VITAL_Level0} and @code{VITAL_Level1}, both declared in the @code{ieee.VITAL_Timing} package.
Currently, VITAL checks are only partially implemented. See section ‘@ref{5b,,VHDL restrictions for VITAL}’ for more details.
@end deffn
@geindex ghdl command line option; --PREFIX<=PATH>
@anchor{using/InvokingGHDL cmdoption-ghdl-prefix}@anchor{5c}
@deffn {Option} @w{-}@w{-}PREFIX<=PATH>
Use @code{PATH} as the prefix path to find commands and pre-installed (@code{std} and @code{ieee}) libraries.
@end deffn
@geindex ghdl command line option; -v
@anchor{using/InvokingGHDL cmdoption-ghdl-v}@anchor{5d}
@deffn {Option} @w{-}v
Be verbose. For example, for analysis, elaboration and make commands, GHDL displays the commands executed.
@end deffn
@node Warnings,Diagnostics Control,Options,Invoking GHDL
@anchor{using/InvokingGHDL warnings}@anchor{5e}
@section Warnings
Some constructions are not erroneous but dubious. Warnings are diagnostic messages that report such constructions. Some warnings are reported only during analysis, others during elaboration.
@cartouche
@quotation Hint
You could disable a warning by using the @code{--warn-no-XXX} or @code{-Wno-XX} instead of @code{--warn-XXX} or @code{-WXXX}.
@end quotation
@end cartouche
@geindex ghdl command line option; --warn-reserved
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-reserved}@anchor{5f}
@deffn {Option} @w{-}@w{-}warn@w{-}reserved
Emit a warning if an identifier is a reserved word in a later VHDL standard.
@end deffn
@geindex ghdl command line option; --warn-default-binding
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-default-binding}@anchor{60}
@deffn {Option} @w{-}@w{-}warn@w{-}default@w{-}binding
During analyze, warns if a component instantiation has neither configuration specification nor default binding. This may be useful if you want to detect during analyze possibly unbound component if you don’t use configuration. See section ‘@ref{51,,VHDL standards}’ for more details about default binding rules.
@end deffn
@geindex ghdl command line option; --warn-binding
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-binding}@anchor{61}
@deffn {Option} @w{-}@w{-}warn@w{-}binding
During elaboration, warns if a component instantiation is not bound (and not explicitly left unbound). Also warns if a port of an entity is not bound in a configuration specification or in a component configuration. This warning is enabled by default, since default binding rules are somewhat complex and an unbound component is most often unexpected.
However, warnings are even emitted if a component instantiation is inside a generate statement. As a consequence, if you use the conditional generate statement to select a component according to the implementation, you will certainly get warnings.
@end deffn
@geindex ghdl command line option; --warn-library
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-library}@anchor{62}
@deffn {Option} @w{-}@w{-}warn@w{-}library
Warns if a design unit replaces another design unit with the same name.
@end deffn
@geindex ghdl command line option; --warn-vital-generic
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-vital-generic}@anchor{63}
@deffn {Option} @w{-}@w{-}warn@w{-}vital@w{-}generic
Warns if a generic name of a vital entity is not a vital generic name. This
is set by default.
@end deffn
@geindex ghdl command line option; --warn-delayed-checks
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-delayed-checks}@anchor{64}
@deffn {Option} @w{-}@w{-}warn@w{-}delayed@w{-}checks
Warns for checks that cannot be done during analysis time and are postponed to elaboration time. This is because not all procedure bodies are available during analysis (either because a package body has not yet been analysed or because @cite{GHDL} doesn’t read not required package bodies).
These are checks for no wait statement in a procedure called in a sensitized process and checks for pure rules of a function.
@end deffn
@geindex ghdl command line option; --warn-body
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-body}@anchor{65}
@deffn {Option} @w{-}@w{-}warn@w{-}body
Emit a warning if a package body which is not required is analyzed. If a package does not declare a subprogram or a deferred constant, the package does not require a body.
@end deffn
@geindex ghdl command line option; --warn-specs
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-specs}@anchor{66}
@deffn {Option} @w{-}@w{-}warn@w{-}specs
Emit a warning if an all or others specification does not apply.
@end deffn
@geindex ghdl command line option; --warn-unused
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-unused}@anchor{67}
@deffn {Option} @w{-}@w{-}warn@w{-}unused
Emit a warning when a subprogram is never used.
@end deffn
@geindex ghdl command line option; --warn-error
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-error}@anchor{68}
@deffn {Option} @w{-}@w{-}warn@w{-}error
When this option is set, warnings are considered as errors.
@end deffn
@geindex ghdl command line option; --warn-nested-comment
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-nested-comment}@anchor{69}
@deffn {Option} @w{-}@w{-}warn@w{-}nested@w{-}comment
Emit a warning if a @code{/*} appears within a block comment (vhdl 2008).
@end deffn
@geindex ghdl command line option; --warn-parenthesis
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-parenthesis}@anchor{6a}
@deffn {Option} @w{-}@w{-}warn@w{-}parenthesis
Emit a warning in case of weird use of parenthesis
@end deffn
@geindex ghdl command line option; --warn-runtime-error
@anchor{using/InvokingGHDL cmdoption-ghdl-warn-runtime-error}@anchor{6b}
@deffn {Option} @w{-}@w{-}warn@w{-}runtime@w{-}error
Emit a warning in case of runtime error that is detected during
analysis.
@end deffn
@node Diagnostics Control,Library commands,Warnings,Invoking GHDL
@anchor{using/InvokingGHDL diagnostics-control}@anchor{6c}
@section Diagnostics Control
@geindex ghdl command line option; -fcolor-diagnostics
@anchor{using/InvokingGHDL cmdoption-ghdl-fcolor-diagnostics}@anchor{6d}
@deffn {Option} @w{-}fcolor@w{-}diagnostics
@end deffn
@geindex ghdl command line option; -fno-color-diagnostics
@anchor{using/InvokingGHDL cmdoption-ghdl-fno-color-diagnostics}@anchor{6e}
@deffn {Option} @w{-}fno@w{-}color@w{-}diagnostics
Control whether diagnostic messages are displayed in color. The default is on when the standard output is a terminal.
@end deffn
@geindex ghdl command line option; -fdiagnostics-show-option
@anchor{using/InvokingGHDL cmdoption-ghdl-fdiagnostics-show-option}@anchor{6f}
@deffn {Option} @w{-}fdiagnostics@w{-}show@w{-}option
@end deffn
@geindex ghdl command line option; -fno-diagnostics-show-option
@anchor{using/InvokingGHDL cmdoption-ghdl-fno-diagnostics-show-option}@anchor{70}
@deffn {Option} @w{-}fno@w{-}diagnostics@w{-}show@w{-}option
Control whether the warning option is displayed at the end of warning messages, so that user can easily know how to disable it.
@end deffn
@node Library commands,VPI build commands,Diagnostics Control,Invoking GHDL
@anchor{using/InvokingGHDL library-commands}@anchor{71}
@section Library commands
@anchor{using/InvokingGHDL create-a-library}@anchor{72}
@geindex create your own library
A new library is created implicitly, by compiling entities (packages etc.) into it: @code{ghdl -a --work=my_custom_lib my_file.vhd}.
A library’s source code is usually stored and compiled into its own directory, that you specify with the @code{--workdir} option: @code{ghdl -a --work=my_custom_lib --workdir=my_custom_libdir my_custom_lib_srcdir/my_file.vhd}. See also the @code{-P} command line option.
Furthermore, GHDL provides a few commands which act on a library:
@geindex cmd library directory
@menu
* Directory [--dir]::
* Clean [--clean]::
* Remove [--remove]::
* Copy [--copy]::
@end menu
@node Directory [--dir],Clean [--clean],,Library commands
@anchor{using/InvokingGHDL directory-dir}@anchor{73}
@subsection Directory [@code{--dir}]
@geindex ghdl command line option; --dir <[options] [libs]>
@anchor{using/InvokingGHDL cmdoption-ghdl-dir}@anchor{74}
@deffn {Option} @w{-}@w{-}dir <[options] [libs]>
@end deffn
Displays the content of the design libraries (by default the @code{work} library). All options are allowed, but only a few are meaningful: @code{--work}, @code{--workdir} and --std@footnote{http://poc-library.readthedocs.io/en/release/References/CmdRefs/PoC.html#cmdoption-poc-py-xsim-std}.
@geindex cmd library clean
@node Clean [--clean],Remove [--remove],Directory [--dir],Library commands
@anchor{using/InvokingGHDL clean-clean}@anchor{75}
@subsection Clean [@code{--clean}]
@geindex ghdl command line option; --clean <[options]>
@anchor{using/InvokingGHDL cmdoption-ghdl-clean}@anchor{76}
@deffn {Option} @w{-}@w{-}clean <[options]>
@end deffn
Try to remove any object, executable or temporary file it could have created. Source files are not removed. The library is kept.
@geindex cmd library remove
@node Remove [--remove],Copy [--copy],Clean [--clean],Library commands
@anchor{using/InvokingGHDL remove-remove}@anchor{77}
@subsection Remove [@code{--remove}]
@geindex ghdl command line option; --remove <[options]>
@anchor{using/InvokingGHDL cmdoption-ghdl-remove}@anchor{78}
@deffn {Option} @w{-}@w{-}remove <[options]>
@end deffn
Do like the clean command but remove the library too. Note that after removing a design library, the files are not
known anymore by GHDL.
@geindex cmd library copy
@node Copy [--copy],,Remove [--remove],Library commands
@anchor{using/InvokingGHDL copy-copy}@anchor{79}
@subsection Copy [@code{--copy}]
@geindex ghdl command line option; --copy <--work=name [options]>
@anchor{using/InvokingGHDL cmdoption-ghdl-copy}@anchor{7a}
@deffn {Option} @w{-}@w{-}copy <@w{-}@w{-}work=name [options]>
@end deffn
Make a local copy of an existing library. This is very useful if you want to add unit to the @code{ieee} library:
@example
ghdl --copy --work=ieee --ieee=synopsys
ghdl -a --work=ieee numeric_unsigned.vhd
@end example
@node VPI build commands,IEEE library pitfalls,Library commands,Invoking GHDL
@anchor{using/InvokingGHDL vpi-build-commands}@anchor{7b}
@section VPI build commands
These commands simplify the compile and the link of a user vpi module. They are all wrapper: the arguments are in fact a whole command line that is executed with additional switches. Currently a unix-like compiler (like @cite{cc}, @cite{gcc} or @cite{clang}) is expected: the additional switches use their syntax. The only option is @cite{-v} which displays the
command before its execution.
@geindex cmd VPI compile
@menu
* compile [--vpi-compile]::
* link [--vpi-link]::
* cflags [--vpi-cflags]::
* ldflags [--vpi-ldflags]::
* include dir [--vpi-include-dir]::
* library dir [--vpi-library-dir]::
@end menu
@node compile [--vpi-compile],link [--vpi-link],,VPI build commands
@anchor{using/InvokingGHDL compile-vpi-compile}@anchor{7c}
@subsection compile [@code{--vpi-compile}]
@geindex ghdl command line option; --vpi-compile
@anchor{using/InvokingGHDL cmdoption-ghdl-vpi-compile}@anchor{7d}
@deffn {Option} @w{-}@w{-}vpi@w{-}compile
@end deffn
Add include path to the command and execute it:
@example
ghdl --vpi-compile command
@end example
This will execute:
@example
command -Ixxx/include
@end example
For example:
@example
ghdl --vpi-compile gcc -c vpi1.c
@end example
executes:
@example
gcc -c vpi1.c -fPIC -Ixxx/include
@end example
@anchor{using/InvokingGHDL vpi-link-command}@anchor{7e}
@geindex cmd VPI link
@node link [--vpi-link],cflags [--vpi-cflags],compile [--vpi-compile],VPI build commands
@anchor{using/InvokingGHDL link-vpi-link}@anchor{7f}
@subsection link [@code{--vpi-link}]
@geindex ghdl command line option; --vpi-link
@anchor{using/InvokingGHDL cmdoption-ghdl-vpi-link}@anchor{80}
@deffn {Option} @w{-}@w{-}vpi@w{-}link
@end deffn
Add library path and name to the command and execute it:
@example
ghdl --vpi-link command
@end example
This will execute:
@example
command -Lxxx/lib -lghdlvpi
@end example
For example:
@example
ghdl --vpi-link gcc -o vpi1.vpi vpi1.o
@end example
executes:
@example
gcc -o vpi1.vpi vpi1.o --shared -Lxxx/lib -lghdlvpi
@end example
@anchor{using/InvokingGHDL vpi-cflags-command}@anchor{81}
@geindex cmd VPI cflags
@node cflags [--vpi-cflags],ldflags [--vpi-ldflags],link [--vpi-link],VPI build commands
@anchor{using/InvokingGHDL cflags-vpi-cflags}@anchor{82}
@subsection cflags [@code{--vpi-cflags}]
@geindex ghdl command line option; --vpi-cflags
@anchor{using/InvokingGHDL cmdoption-ghdl-vpi-cflags}@anchor{83}
@deffn {Option} @w{-}@w{-}vpi@w{-}cflags
@end deffn
Display flags added by @ref{7d,,--vpi-compile}.
@geindex cmd VPI ldflags
@node ldflags [--vpi-ldflags],include dir [--vpi-include-dir],cflags [--vpi-cflags],VPI build commands
@anchor{using/InvokingGHDL ldflags-vpi-ldflags}@anchor{84}
@subsection ldflags [@code{--vpi-ldflags}]
@geindex ghdl command line option; --vpi-ldflags
@anchor{using/InvokingGHDL cmdoption-ghdl-vpi-ldflags}@anchor{85}
@deffn {Option} @w{-}@w{-}vpi@w{-}ldflags
@end deffn
Display flags added by @ref{80,,--vpi-link}.
@geindex cmd VPI include dir
@node include dir [--vpi-include-dir],library dir [--vpi-library-dir],ldflags [--vpi-ldflags],VPI build commands
@anchor{using/InvokingGHDL include-dir-vpi-include-dir}@anchor{86}
@subsection include dir [@code{--vpi-include-dir}]
@geindex ghdl command line option; --vpi-include-dir
@anchor{using/InvokingGHDL cmdoption-ghdl-vpi-include-dir}@anchor{87}
@deffn {Option} @w{-}@w{-}vpi@w{-}include@w{-}dir
@end deffn
Display the include directory added by the compile flags.
@geindex cmd VPI library dir
@node library dir [--vpi-library-dir],,include dir [--vpi-include-dir],VPI build commands
@anchor{using/InvokingGHDL library-dir-vpi-library-dir}@anchor{88}
@subsection library dir [@code{--vpi-library-dir}]
@geindex ghdl command line option; --vpi-library-dir
@anchor{using/InvokingGHDL cmdoption-ghdl-vpi-library-dir}@anchor{89}
@deffn {Option} @w{-}@w{-}vpi@w{-}library@w{-}dir
@end deffn
Display the library directory added by the link flags.
@node IEEE library pitfalls,,VPI build commands,Invoking GHDL
@anchor{using/InvokingGHDL ieee-library-pitfalls}@anchor{14}@anchor{using/InvokingGHDL id1}@anchor{8a}
@section IEEE library pitfalls
When you use options @code{--ieee=synopsys} or @code{--ieee=mentor}, the @code{ieee} library contains non standard packages such as @code{std_logic_arith}. These packages are not standard because there are not described by an IEEE standard, even if they have been put in the @cite{IEEE} library. Furthermore, they are not really de-facto standard, because there are slight differences between the packages of Mentor and those of Synopsys. Furthermore, since they are not well-thought, their use has pitfalls. For example, this description has error during compilation:
@example
library ieee;
use ieee.std_logic_1164.all;
-- A counter from 0 to 10.
entity counter is
port (val : out std_logic_vector (3 downto 0);
ck : std_logic;
rst : std_logic);
end counter;
library ieee;
use ieee.std_logic_unsigned.all;
architecture bad of counter
is
signal v : std_logic_vector (3 downto 0);
begin
process (ck, rst)
begin
if rst = '1' then
v <= x"0";
elsif rising_edge (ck) then
if v = "1010" then -- Error
v <= x"0";
else
v <= v + 1;
end if;
end if;
end process;
val <= v;
end bad;
@end example
When you analyze this design, GHDL does not accept it (too long lines
have been split for readability):
@example
ghdl -a --ieee=synopsys bad_counter.vhdl
bad_counter.vhdl:13:14: operator "=" is overloaded
bad_counter.vhdl:13:14: possible interpretations are:
../../libraries/ieee/std_logic_1164.v93:69:5: implicit function "="
[std_logic_vector, std_logic_vector return boolean]
../../libraries/synopsys/std_logic_unsigned.vhdl:64:5: function "="
[std_logic_vector, std_logic_vector return boolean]
../translate/ghdldrv/ghdl: compilation error
@end example
Indeed, the @cite{“=”} operator is defined in both packages, and both are visible at the place it is used. The first declaration is an implicit one, which occurs when the @cite{std_logic_vector} type is declared and is an element to element comparison, the second one is an explicit declared function, with the semantic of an unsigned comparison.
With some analyser, the explicit declaration has priority over the implicit declaration, and this design can be analyzed without error. However, this is not the rule given by the VHDL LRM, and since GHDL follows these rules,
it emits an error.
You can force GHDL to use this rule with the @emph{-fexplicit} option (see GHDL_options for further details). However it is easy to fix this error, by using a selected name:
@example
library ieee;
use ieee.std_logic_unsigned.all;
architecture fixed_bad of counter
is
signal v : std_logic_vector (3 downto 0);
begin
process (ck, rst)
begin
if rst = '1' then
v <= x"0";
elsif rising_edge (ck) then
if ieee.std_logic_unsigned."=" (v, "1010") then
v <= x"0";
else
v <= v + 1;
end if;
end if;
end process;
val <= v;
end fixed_bad;
@end example
It is better to only use the standard packages defined by IEEE, which provides the same functionalities:
@example
library ieee;
use ieee.numeric_std.all;
architecture good of counter
is
signal v : unsigned (3 downto 0);
begin
process (ck, rst)
begin
if rst = '1' then
v <= x"0";
elsif rising_edge (ck) then
if v = "1010" then
v <= x"0";
else
v <= v + 1;
end if;
end if;
end process;
val <= std_logic_vector (v);
end good;
@end example
@geindex Math_Real
@geindex Math_Complex
@cartouche
@quotation Hint
The @code{ieee} math packages (@code{math_real} and @code{math_complex}) provided with @cite{GHDL} are fully compliant with the @cite{IEEE} standard.
@end quotation
@end cartouche
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Simulation and runtime,Releases and sources,Invoking GHDL,Top
@anchor{using/Simulation using-simulation}@anchor{3b}@anchor{using/Simulation simulation-and-runtime}@anchor{8b}@anchor{using/Simulation doc}@anchor{8c}
@chapter Simulation and runtime
@menu
* Simulation options::
* Export waveforms::
* Export hierarchy and references::
* Debugging::
@end menu
@node Simulation options,Export waveforms,,Simulation and runtime
@anchor{using/Simulation simulation-options}@anchor{2f}@anchor{using/Simulation id1}@anchor{8d}
@section Simulation options
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 generics 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 @code{EXIT_SUCCESS} (0) if the
simulation completes, or @code{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 @ref{8e,,--help} options lists
all options available, including the debugging one.
@geindex ghdl command line option; --assert-level<=LEVEL>
@anchor{using/Simulation cmdoption-ghdl-assert-level}@anchor{8f}
@deffn {Option} @w{-}@w{-}assert@w{-}level<=LEVEL>
Select the assertion level at which an assertion violation stops the
simulation. @cite{LEVEL} is the name from the @cite{severity_level}
enumerated type defined in the @cite{standard} package or the
@code{none} name.
By default, only assertion violation of severity level @code{failure}
stops the simulation.
For example, if @cite{LEVEL} was @code{warning}, any assertion violation
with severity level @code{warning}, @code{error} or @code{failure} would
stop simulation, but the assertion violation at the @code{note} severity
level would only display a message.
Option @code{--assert-level=none} prevents any assertion violation to stop
simulation.
@end deffn
@geindex ghdl command line option; --ieee-asserts<=POLICY>
@anchor{using/Simulation cmdoption-ghdl-ieee-asserts}@anchor{90}
@deffn {Option} @w{-}@w{-}ieee@w{-}asserts<=POLICY>
Select how the assertions from @code{ieee} units are
handled. @cite{POLICY} can be @code{enable} (the default),
@code{disable} which disables all assertion from @code{ieee} packages
and @code{disable-at-0} which disables only at start of simulation.
This option can be useful to avoid assertion message from
@code{ieee.numeric_std} (and other @code{ieee} packages).
@end deffn
@geindex ghdl command line option; --stop-time<=TIME>
@anchor{using/Simulation cmdoption-ghdl-stop-time}@anchor{91}
@deffn {Option} @w{-}@w{-}stop@w{-}time<=TIME>
Stop the simulation after @code{TIME}. @code{TIME} is expressed as a time
value, @emph{without} any space. The time is the simulation time, not
the real clock time.
For example:
@example
$ ./my_design --stop-time=10ns
$ ./my_design --stop-time=ps
@end example
@end deffn
@geindex ghdl command line option; --stop-delta<=N>
@anchor{using/Simulation cmdoption-ghdl-stop-delta}@anchor{92}
@deffn {Option} @w{-}@w{-}stop@w{-}delta<=N>
Stop the simulation after @cite{N} delta cycles in the same current time.
@geindex display time
@end deffn
@geindex ghdl command line option; --disp-time
@anchor{using/Simulation cmdoption-ghdl-disp-time}@anchor{93}
@deffn {Option} @w{-}@w{-}disp@w{-}time
Display the time and delta cycle number as simulation advances.
@end deffn
@geindex ghdl command line option; --unbuffered
@anchor{using/Simulation cmdoption-ghdl-unbuffered}@anchor{94}
@deffn {Option} @w{-}@w{-}unbuffered
Disable buffering on stdout, stderr and files opened in write or append mode (TEXTIO).
@end deffn
@geindex ghdl command line option; --sdf<=PATH=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-sdf}@anchor{95}
@deffn {Option} @w{-}@w{-}sdf<=PATH=FILENAME>
Do VITAL annotation on @cite{PATH} with SDF file @code{FILENAME}.
@cite{PATH} is a path of instances, separated with @code{.} or @code{/}.
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:
@example
--sdf=min=PATH=FILENAME
--sdf=typ=PATH=FILENAME
--sdf=max=PATH=FILENAME
@end example
If the option contains a type of delay, that is @code{min=},
@code{typ=} or @code{max=}, the annotator use respectively minimum,
typical or maximum values. If the option does not contain a type of delay,
the annotator use the typical delay.
See section ‘@ref{96,,Backannotation}’, for more details.
@end deffn
@geindex ghdl command line option; --vpi<=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-vpi}@anchor{97}
@deffn {Option} @w{-}@w{-}vpi<=FILENAME>
@end deffn
Load VPI module.
@geindex ghdl command line option; --vpi-trace<=FILE>
@anchor{using/Simulation cmdoption-ghdl-vpi-trace}@anchor{98}
@deffn {Option} @w{-}@w{-}vpi@w{-}trace<=FILE>
@end deffn
Trace vpi calls to FILE.
@geindex ghdl command line option; --help
@anchor{using/Simulation cmdoption-ghdl-help}@anchor{8e}
@deffn {Option} @w{-}@w{-}help
Display a short description of the options accepted by the runtime library.
@end deffn
@node Export waveforms,Export hierarchy and references,Simulation options,Simulation and runtime
@anchor{using/Simulation export-waveforms}@anchor{99}@anchor{using/Simulation export-waves}@anchor{2e}
@section Export waveforms
@geindex ghdl command line option; --read-wave-opt=
@anchor{using/Simulation cmdoption-ghdl-read-wave-opt}@anchor{9a}
@deffn {Option} @w{-}@w{-}read@w{-}wave@w{-}opt=
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
@example
$ version = 1.1 # Optional
# Path format for signals in packages :
my_pkg.global_signal_a
# Path format for signals in entities :
/top/sub/clk
# Dumps every signals named reset in first level sub entities of top
/top/*/reset
# Dumps every signals named reset in recursive sub entities of top
/top/**/reset
# Dump every signals of sub2 which could be anywhere in design except on
# top level
/**/sub2/*
# Dump every signals of sub3 which must be a first level sub entity of the
# top level
/*/sub3/*
# Dump every signals of the first level sub entities of sub3 (but not
# those of sub3)
/**/sub3/*/*
@end example
@end deffn
@geindex ghdl command line option; --write-wave-opt=
@anchor{using/Simulation cmdoption-ghdl-write-wave-opt}@anchor{9b}
@deffn {Option} @w{-}@w{-}write@w{-}wave@w{-}opt=
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.
@end deffn
@geindex ghdl command line option; --vcd<=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-vcd}@anchor{9c}
@deffn {Option} @w{-}@w{-}vcd<=FILENAME>
@end deffn
@geindex ghdl command line option; --vcdgz<=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-vcdgz}@anchor{9d}
@deffn {Option} @w{-}@w{-}vcdgz<=FILENAME>
@geindex vcd
@geindex value change dump
@geindex dump of signals
Option @code{--vcd} dumps into the VCD file @cite{FILENAME} the signal
values before each non-delta cycle. If @cite{FILENAME} is @code{-},
then the standard output is used, otherwise a file is created or
overwritten.
The @code{--vcdgz} option is the same as the @emph{–vcd} option,
but the output is compressed using the @cite{zlib} (@cite{gzip}
compression). However, you can’t use the @code{-} filename.
Furthermore, only one VCD file can be written.
@emph{VCD} (value change dump) is a file format defined
by the @cite{verilog} standard and used by virtually any wave viewer.
Since it comes from @cite{verilog}, only a few VHDL types can be dumped. GHDL
dumps only signals whose base type is of the following:
@itemize *
@item
types defined in the @code{std.standard} package:
@item
@code{bit}
@item
@code{bit_vector}
@item
types defined in the @code{ieee.std_logic_1164} package:
@item
@code{std_ulogic}
@item
@code{std_logic} (because it is a subtype of @code{std_ulogic})
@item
@code{std_ulogic_vector}
@item
@code{std_logic_vector}
@item
any integer type
@end itemize
I have successfully used @cite{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 (@ref{12,,Reporting bugs}).
@end deffn
@geindex ghdl command line option; --vcd-nodate
@anchor{using/Simulation cmdoption-ghdl-vcd-nodate}@anchor{9e}
@deffn {Option} @w{-}@w{-}vcd@w{-}nodate
Do not write date in VCD file
@end deffn
@geindex ghdl command line option; --fst<=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-fst}@anchor{9f}
@deffn {Option} @w{-}@w{-}fst<=FILENAME>
Write the waveforms into a @cite{fst}, that can be displayed by
@cite{gtkwave}. The @cite{fst} files are much smaller than VCD or
@cite{GHW} files, but it handles only the same signals as the VCD format.
@end deffn
@geindex ghdl command line option; --wave<=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-wave}@anchor{a0}
@deffn {Option} @w{-}@w{-}wave<=FILENAME>
Write the waveforms into a @cite{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 @code{gtkwave} tool can read the GHW files.
Contrary to VCD files, any VHDL type can be dumped into a GHW file.
@end deffn
@node Export hierarchy and references,Debugging,Export waveforms,Simulation and runtime
@anchor{using/Simulation export-hierarchy-and-references}@anchor{a1}
@section Export hierarchy and references
@geindex ghdl command line option; --disp-tree<[=KIND]>
@anchor{using/Simulation cmdoption-ghdl-disp-tree}@anchor{a2}
@deffn {Option} @w{-}@w{-}disp@w{-}tree<[=KIND]>
@geindex display design hierarchy
Display the design hierarchy as a tree of instantiated design entities.
This may be useful to understand the structure of a complex
design. @cite{KIND} is optional, but if set must be one of:
@itemize *
@item
none
Do not display hierarchy. Same as if the option was not present.
@item
inst
Display entities, architectures, instances, blocks and generates statements.
@item
proc
Like @code{inst} but also display processes.
@item
port
Like @code{proc} but display ports and signals too.
If @cite{KIND} is not specified, the hierarchy is displayed with the
@code{port} mode.
@end itemize
@end deffn
@geindex ghdl command line option; --no-run
@anchor{using/Simulation cmdoption-ghdl-no-run}@anchor{a3}
@deffn {Option} @w{-}@w{-}no@w{-}run
Stop the simulation before the first cycle. This may be used with @code{--disp-tree} to display the tree without simulating the whole design. This option actually elaborates the design, so it will catch any bound error in port maps.
@end deffn
@geindex ghdl command line option; --xref-html <[options] file...>
@anchor{using/Simulation cmdoption-ghdl-xref-html}@anchor{a4}
@deffn {Option} @w{-}@w{-}xref@w{-}html <[options] file...>
@end deffn
To easily navigate through your sources, you may generate cross-references. This command generates an html file for each @code{file} given in the command line, with syntax highlighting and full cross-reference: every identifier is a link to its declaration. Besides, an index of the files is created too.
The set of @code{file} are analyzed, and then, if the analysis is successful, html files are generated in the directory specified by the @code{-o} option, or @code{html/} directory by default.
@itemize *
@item
If the option @code{--format=html2} is specified, then the generated html files follow the HTML 2.0 standard, and colours are specified with @cite{} tags. However, colours are hard-coded.
@item
If the option @code{--format=css} is specified, then the generated html files follow the HTML 4.0 standard, and use the CSS-1 file @code{ghdl.css} to 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.
@end itemize
@geindex ghdl command line option; --psl-report<=FILENAME>
@anchor{using/Simulation cmdoption-ghdl-psl-report}@anchor{a5}
@deffn {Option} @w{-}@w{-}psl@w{-}report<=FILENAME>
@end deffn
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 still being human readable.
@geindex ghdl command line option; --file-to-xml
@anchor{using/Simulation cmdoption-ghdl-file-to-xml}@anchor{a6}
@deffn {Option} @w{-}@w{-}file@w{-}to@w{-}xml
@end deffn
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…
@cartouche
@quotation Warning
@itemize *
@item
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.
@item
Note that at this time there is no XML dump of the elaborated design.
@end itemize
@end quotation
@end cartouche
@geindex debugging
@node Debugging,,Export hierarchy and references,Simulation and runtime
@anchor{using/Simulation debugging}@anchor{a7}
@section Debugging
@geindex ghdl command line option; --trace-signals
@anchor{using/Simulation cmdoption-ghdl-trace-signals}@anchor{a8}
@deffn {Option} @w{-}@w{-}trace@w{-}signals
@end deffn
Display signals after each cycle.
@geindex ghdl command line option; --trace-processes
@anchor{using/Simulation cmdoption-ghdl-trace-processes}@anchor{a9}
@deffn {Option} @w{-}@w{-}trace@w{-}processes
@end deffn
Display process name before each cycle.
@geindex ghdl command line option; --stats
@anchor{using/Simulation cmdoption-ghdl-stats}@anchor{aa}
@deffn {Option} @w{-}@w{-}stats
@end deffn
Display run-time statistics.
@geindex ghdl command line option; --disp-order
@anchor{using/Simulation cmdoption-ghdl-disp-order}@anchor{ab}
@deffn {Option} @w{-}@w{-}disp@w{-}order
@end deffn
Display signals order.
@geindex ghdl command line option; --disp-sources
@anchor{using/Simulation cmdoption-ghdl-disp-sources}@anchor{ac}
@deffn {Option} @w{-}@w{-}disp@w{-}sources
@end deffn
Display sources while displaying signals.
@geindex ghdl command line option; --disp-sig-types
@anchor{using/Simulation cmdoption-ghdl-disp-sig-types}@anchor{ad}
@deffn {Option} @w{-}@w{-}disp@w{-}sig@w{-}types
@end deffn
Display signal types.
@geindex ghdl command line option; --disp-signals-map
@anchor{using/Simulation cmdoption-ghdl-disp-signals-map}@anchor{ae}
@deffn {Option} @w{-}@w{-}disp@w{-}signals@w{-}map
@end deffn
Display map bw declared signals and internal signals.
@geindex ghdl command line option; --disp-signals-table
@anchor{using/Simulation cmdoption-ghdl-disp-signals-table}@anchor{af}
@deffn {Option} @w{-}@w{-}disp@w{-}signals@w{-}table
@end deffn
Display internal signals.
@geindex ghdl command line option; --checks
@anchor{using/Simulation cmdoption-ghdl-checks}@anchor{b0}
@deffn {Option} @w{-}@w{-}checks
@end deffn
Do internal checks after each process run.
@geindex ghdl command line option; --activity<=LEVEL>
@anchor{using/Simulation cmdoption-ghdl-activity}@anchor{b1}
@deffn {Option} @w{-}@w{-}activity<=LEVEL>
@end deffn
Watch activity of LEVEL signals: LEVEL is all, min (default) or none (unsafe).
@geindex ghdl command line option; --dump-rti
@anchor{using/Simulation cmdoption-ghdl-dump-rti}@anchor{b2}
@deffn {Option} @w{-}@w{-}dump@w{-}rti
@end deffn
Dump Run Time Information (RTI).
@geindex ghdl command line option; --bootstrap
@anchor{using/Simulation cmdoption-ghdl-bootstrap}@anchor{b3}
@deffn {Option} @w{-}@w{-}bootstrap
@end deffn
Allow @code{--work=std}
@menu
* GNU Debugger (GDB): GNU Debugger GDB.
@end menu
@node GNU Debugger GDB,,,Debugging
@anchor{using/Simulation gnu-debugger-gdb}@anchor{b4}
@subsection GNU Debugger (GDB)
@geindex `__ghdl_fatal`
@cartouche
@quotation Warning
Debugging VHDL programs using @cite{GDB} is possible only with GCC/LLVM.
@end quotation
@end cartouche
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 precisely catch a runtime error, such as indexing an array beyond its bounds. All error check subprograms call the @code{__ghdl_fatal} procedure. Therefore, to catch runtime error, set a breakpoint like this:
@example
(gdb) break __ghdl_fatal
@end example
When the breakpoint is hit, use the @code{where} or @code{bt} command to display the stack frames.
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Releases and sources,Building GHDL from Sources,Simulation and runtime,Top
@anchor{getting/Releases release}@anchor{b5}@anchor{getting/Releases releases-and-sources}@anchor{b6}@anchor{getting/Releases doc}@anchor{b7}
@chapter Releases and sources
@menu
* Downloading pre-built packages::
* Downloading Source Files::
@end menu
@node Downloading pre-built packages,Downloading Source Files,,Releases and sources
@anchor{getting/Releases release-packages}@anchor{b8}@anchor{getting/Releases downloading-pre-built-packages}@anchor{b9}
@section Downloading pre-built packages
@multitable {xxxxxxxxxxxxxxxx} {xxxxxxxxxxxx} {xxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
@headitem
OS
@tab
Backend
@tab
Filesize
@tab
Downloads
@item
Ubuntu 12.04
@tab
LLVM 3.8
@tab
13.8 MiB
@tab
@item
Ubuntu 14.04
@tab
LLVM 3.5
@tab
11.9 MiB
@tab
@item
Fedora
@tab
LLVM
@tab
6.58 MiB
@tab
@item
Fedora
@tab
mcode
@tab
2.75 MiB
@tab
@item
Windows x86
@tab
mcode
@tab
5.25 MiB
@tab
@end multitable
@node Downloading Source Files,,Downloading pre-built packages,Releases and sources
@anchor{getting/Releases downloading-source-files}@anchor{ba}@anchor{getting/Releases release-sources}@anchor{bb}
@section Downloading Source Files
@menu
* Downloading from GitHub::
* Downloading via git clone::
@end menu
@node Downloading from GitHub,Downloading via git clone,,Downloading Source Files
@anchor{getting/Releases downloading-from-github}@anchor{bc}@anchor{getting/Releases release-sources-zip}@anchor{bd}
@subsection Downloading from GitHub
GHDL can be downloaded as a zip-file from GitHub. See the following table, to
choose your desired git branch.
@multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxx}
@headitem
Branch
@tab
Download Link
@item
master
@tab
zip-file
@image{_static/icons/ZIP,,,Source Code from GitHub - 'master' branch.,png}
@item
release
@tab
zip-file
@image{_static/icons/ZIP,,,Source Code from GitHub - 'release' branch.,png}
@end multitable
@node Downloading via git clone,,Downloading from GitHub,Downloading Source Files
@anchor{getting/Releases release-sources-gitclone}@anchor{be}@anchor{getting/Releases downloading-via-git-clone}@anchor{bf}
@subsection Downloading via @code{git clone}
GHDL can be downloaded (cloned) with @code{git clone} from GitHub. GitHub offers
the transfer protocols HTTPS and SSH. You should use SSH if you have a GitHub
account and have already uploaded an OpenSSH public key to GitHub, otherwise
use HTTPS if you have no account or you want to use login credentials.
The created folder @code{\ghdl} is used as @code{} in
later instructions or on other pages in this documentation.
@multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
@headitem
Protocol
@tab
GitHub Repository URL
@item
HTTPS
@tab
@indicateurl{https://github.com/ghdl/ghdl.git}
@item
SSH
@tab
@indicateurl{ssh://git@@github.com:ghdl/ghdl.git}
@end multitable
@menu
* On Linux::
* On OS X::
* On Windows::
@end menu
@node On Linux,On OS X,,Downloading via git clone
@anchor{getting/Releases on-linux}@anchor{c0}
@subsubsection On Linux
Command line instructions to clone GHDL onto a Linux machine with HTTPS
protocol:
@example
cd GitRoot
git clone "https://github.com/ghdl/ghdl.git" ghdl
cd ghdl
git remote rename origin github
@end example
Command line instructions to clone GHDL onto a Linux machine machine with SSH
protocol:
@example
cd GitRoot
git clone "ssh://git@@github.com:ghdl/ghdl.git" ghdl
cd ghdl
git remote rename origin github
@end example
@node On OS X,On Windows,On Linux,Downloading via git clone
@anchor{getting/Releases on-os-x}@anchor{c1}
@subsubsection On OS X
Please see the Linux instructions.
@node On Windows,,On OS X,Downloading via git clone
@anchor{getting/Releases on-windows}@anchor{c2}
@subsubsection On Windows
@cartouche
@quotation Note
All Windows command line instructions are intended for @code{Windows PowerShell},
if not marked otherwise. So executing the following instructions in Windows
Command Prompt (@code{cmd.exe}) won’t function or result in errors! See
the Requirements section on where to
download or update PowerShell.
@end quotation
@end cartouche
Command line instructions to clone GHDL onto a Windows machine with HTTPS
protocol:
@example
cd GitRoot
git clone "https://github.com/ghdl/ghdl.git" ghdl
cd ghdl
git remote rename origin github
@end example
Command line instructions to clone GHDL onto a Windows machine with SSH
protocol:
@example
cd GitRoot
git clone "ssh://git@@github.com:ghdl/ghdl.git" ghdl
cd ghdl
git remote rename origin github
@end example
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Building GHDL from Sources,Precompile Vendor Primitives,Releases and sources,Top
@anchor{building/Building doc}@anchor{c3}@anchor{building/Building build}@anchor{c4}@anchor{building/Building building-ghdl-from-sources}@anchor{c5}
@chapter Building GHDL from Sources
@subheading Download
GHDL can be downloaded as a zip-file@footnote{https://github.com/ghdl/ghdl/archive/master.zip}
(latest ‘master’ branch) or cloned with @code{git clone} from GitHub. GitHub
offers HTTPS and SSH as transfer protocols. See the @ref{bb,,Downloading Source Files}
page for further details. The installation directory is referred to as @code{GHDLRoot}.
@subheading Available back-ends
GHDL currently supports three different back-ends (code generators):
@itemize *
@item
mcode - built-in x86(or x86_64) code generator,
@item
GCC - Gnu Compiler Collection@footnote{http://gcc.gnu.org/}, and
@item
LLVM - Low-Level Virtual Machine@footnote{http://llvm.org/} .
@end itemize
Here is a short comparison, so that you can choose the one you want to use:
@multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
@headitem
Back-end
@tab
Pros
@tab
Cons
@item
@ref{c6,,mcode}
@tab
@itemize *
@item
Very easy to build
@item
Very quick analysis
@item
Can handle very large designs
@end itemize
@tab
@itemize *
@item
Simulation is slower
@item
x86_64/i386 only
@end itemize
@item
@ref{c7,,LLVM}
@tab
@itemize *
@item
Generated code is faster
@item
Generated code can be debugged (with @code{-g})
@item
Easier to build than GCC
@end itemize
@tab
@itemize *
@item
Build is more complex
@end itemize
@item
@ref{c8,,GCC}
@tab
@itemize *
@item
Generated code is faster (particularly with @code{-O} or @code{-O2})
@item
Generated code can be debugged (with @code{-g})
@item
Ported to many platforms (x86, x86_64, PowerPC, SPARC)
@end itemize
@tab
@itemize *
@item
Build is even more complex
@item
Analysis can take time (particularly for large units)
@item
Code coverage collection (@code{gcov}) is unique to GCC
@end itemize
@end multitable
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@menu
* Directory Structure::
* mcode Backend::
* LLVM Backend::
* GCC Backend::
@end menu
@node Directory Structure,mcode Backend,,Building GHDL from Sources
@anchor{building/Directories directory-structure}@anchor{c9}@anchor{building/Directories doc}@anchor{ca}@anchor{building/Directories build-dir-structure}@anchor{1a}
@section Directory Structure
@itemize *
@item
@code{src}: sources of GHDL, all of them in Ada.
@item
@code{libraries}: mostly third party libraries such as, @cite{ieee}, @cite{mentor},
@cite{std}, @cite{synopsys} and @cite{vital}. Except a few shell and @cite{Python} scripts, all
the content is written in VHDL.
@itemize *
@item
Vendors like Altera, Lattice and Xilinx have their own simulation libraries,
especially for FPGA primitives, soft and hard macros. These libraries can
not be shipped with GHDL, but we offer prepared compile scripts to
pre-compile the vendor libraries, if the vendor tool is present on the
computer. These are located in @code{libraries/vendor}.
See @ref{cb,,Precompile Vendor Primitives} for information on how to
use them.
@end itemize
@item
@code{dist}: scripts and auxiliar files to build GHDL in different
environments:
@itemize *
@item
@code{gcc}: header and configuration files to build GHDL with GCC (all the
platforms).
@item
@code{linux}: build and test script written in shell, and other auxiliary
files used to i) launch docker containers and ii) automate multiple builds
in Travis CI@footnote{https://travis-ci.org/}.
@item
@code{windows}:
@itemize *
@item
@code{mcode}:
@item
@code{appveyor}:
@end itemize
@end itemize
@item
@code{doc}: @cite{Markdown} and @cite{reStructuredText} sources and auxiliary files to
build the documentation with Sphinx@footnote{http://www.sphinx-doc.org}. Indeed,
Read the docs@footnote{http://readthedocs.org} (RTD) is used to automatically build
and deploy this site and/or PDF you are reading.
@item
@code{testsuite}: see section test_suites.
@item
@cite{.yml} configuration files for CI environments (@code{readthedocs},
@code{travis} and @code{appveyor}) and @cite{ignore} files for source control
management tools (@code{git} and @code{.hg}).
@item
Files for building GHDL: @code{configure} and @code{Makefile.in}.
@item
Auxiliar files for development: @code{.gdbinit} and @code{ghdl.gpr.in}
(GNAT project file).
@item
Text files: @code{COPYING.md}, @code{NEWS.md} and @code{README.md}.
@end itemize
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node mcode Backend,LLVM Backend,Directory Structure,Building GHDL from Sources
@anchor{building/mcode/index mcode-backend}@anchor{cc}@anchor{building/mcode/index build-mcode}@anchor{c6}@anchor{building/mcode/index doc}@anchor{cd}
@section mcode Backend
The mcode backend is available for all supported platforms and is also the most
simplest procedure, because it requires the least dependencies and configuration
options.
@subsubheading Requirements
@itemize *
@item
GCC (Gnu Compiler Collection)
@item
GNAT (Ada compiler for GCC)
@end itemize
@subsubheading Supported platforms
@itemize *
@item
@ref{ce,,mcode Backend on GNU/Linux with GCC/GNAT}
@item
@ref{cf,,mcode Backend on Windows with GNAT GPL}
@item
@ref{d0,,mcode Backend on Windows with GCC/GNAT (MinGW)}
@end itemize
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@menu
* mcode Backend on GNU/Linux with GCC/GNAT::
* mcode Backend on Windows with GNAT GPL::
* mcode Backend on Windows with GCC/GNAT (MinGW): mcode Backend on Windows with GCC/GNAT MinGW.
@end menu
@node mcode Backend on GNU/Linux with GCC/GNAT,mcode Backend on Windows with GNAT GPL,,mcode Backend
@anchor{building/mcode/GNULinux-GNAT build-mcode-gnulinux-gnat}@anchor{d1}@anchor{building/mcode/GNULinux-GNAT mcode-backend-on-gnu-linux-with-gcc-gnat}@anchor{d2}@anchor{building/mcode/GNULinux-GNAT doc}@anchor{ce}
@subsection mcode Backend on GNU/Linux with GCC/GNAT
On Linux, GHDL is configured by @code{configure} and build by @code{make}.
@itemize *
@item
First, GHDL needs to be configured. It is common to specify a @code{PREFIX}
(installation directory like @code{/usr/local} or @code{/opt/ghdl}). Without any
other option, @code{configure} select @cite{mcode} as backend.
@item
Next, @code{make} starts the compilation process.
@item
Finally, @code{make install} installs GHDL into the installation directory
specified by @code{PREFIX}. You may need super user privileges (@code{sudo ...}).
@end itemize
@subsubheading Example:
@example
$ cd
$ mkdir build
$ cd build
$ ../configure --prefix=PREFIX
$ make
$ make install
@end example
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node mcode Backend on Windows with GNAT GPL,mcode Backend on Windows with GCC/GNAT MinGW,mcode Backend on GNU/Linux with GCC/GNAT,mcode Backend
@anchor{building/mcode/Windows-GNATGPL build-mcode-windows-gnatgpl}@anchor{d3}@anchor{building/mcode/Windows-GNATGPL doc}@anchor{cf}@anchor{building/mcode/Windows-GNATGPL mcode-backend-on-windows-with-gnat-gpl}@anchor{d4}
@subsection mcode Backend on Windows with GNAT GPL
@menu
* Requirements::
* Scripts and Parameters::
@end menu
@node Requirements,Scripts and Parameters,,mcode Backend on Windows with GNAT GPL
@anchor{building/mcode/Windows-GNATGPL requirements}@anchor{d5}
@subsubsection Requirements
@itemize *
@item
GNAT GPL from @indicateurl{http://libre.adacore.com}
@item
PowerShell 4
@item
PowerShell Community Extensions (PSCX)
@end itemize
@node Scripts and Parameters,,Requirements,mcode Backend on Windows with GNAT GPL
@anchor{building/mcode/Windows-GNATGPL scripts-and-parameters}@anchor{d6}
@subsubsection Scripts and Parameters
@menu
* compile.ps1: compile ps1.
@end menu
@node compile ps1,,,Scripts and Parameters
@anchor{building/mcode/Windows-GNATGPL compile-ps1}@anchor{d7}
@subsubsection @cite{compile.ps1}
@example
Commands Description
--------------------------------------------------------------------
-Help Display the integrated help pages
-Clean Clean up all files and directories
-Compile Compile GHDL
-Install Install all files into a directory (xcopy deployment)
-Uninstall Uninstall all files from a directory
-Update Update files in the installation directory
-CreatePackage create an installer package
Install options:
-InstallPath Installation directory
CreatePackage options:
-Zip Create a zip-file for xcopy deployment
@end example
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node mcode Backend on Windows with GCC/GNAT MinGW,,mcode Backend on Windows with GNAT GPL,mcode Backend
@anchor{building/mcode/Windows-MinGW-GNAT mcode-backend-on-windows-with-gcc-gnat-mingw}@anchor{d8}@anchor{building/mcode/Windows-MinGW-GNAT build-mcode-windows-mingw-gnat}@anchor{d9}@anchor{building/mcode/Windows-MinGW-GNAT doc}@anchor{d0}
@subsection mcode Backend on Windows with GCC/GNAT (MinGW)
On Windows with MinGW, GHDL is configured by @code{configure} and build by @code{make}.
@itemize *
@item
First, GHDL needs to be configured. It is common to specify a @code{PREFIX}
(installation directory like @code{/usr/local} or @code{/opt/ghdl}). Without any
other option, @code{configure} select @cite{mcode} as backend.
@item
Next, @code{make} starts the compilation process.
@item
Finally, @code{make install} installs GHDL into the installation directory
specified by @code{PREFIX}.
@end itemize
@subsubheading Example:
@example
$ cd
$ mkdir build
$ cd build
$ ../configure --prefix=PREFIX
$ make
$ make install
@end example
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node LLVM Backend,GCC Backend,mcode Backend,Building GHDL from Sources
@anchor{building/llvm/index build-llvm}@anchor{c7}@anchor{building/llvm/index doc}@anchor{da}@anchor{building/llvm/index llvm-backend}@anchor{db}
@section LLVM Backend
@subsubheading Requirements
@itemize *
@item
GCC (Gnu Compiler Collection)
@item
GNAT (Ada compiler for GCC)
@item
LLVM (Low-Level-Virtual Machine) and CLANG (Compiler front-end for LLVM)
@itemize *
@item
3.5
@item
3.8
@item
3.9
@item
4.0
@item
5.0
@end itemize
@end itemize
@subsubheading Supported platforms
@itemize *
@item
@ref{dc,,LLVM Backend on GNU/Linux with GCC/GNAT}
@item
@ref{dd,,LLVM Backend on Windows with GCC/GNAT (MinGW)}
@item
Mac OS
@end itemize
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@menu
* LLVM Backend on GNU/Linux with GCC/GNAT::
* LLVM Backend on Windows with GCC/GNAT (MinGW): LLVM Backend on Windows with GCC/GNAT MinGW.
@end menu
@node LLVM Backend on GNU/Linux with GCC/GNAT,LLVM Backend on Windows with GCC/GNAT MinGW,,LLVM Backend
@anchor{building/llvm/GNULinux-GNAT llvm-backend-on-gnu-linux-with-gcc-gnat}@anchor{de}@anchor{building/llvm/GNULinux-GNAT doc}@anchor{dc}@anchor{building/llvm/GNULinux-GNAT build-llvm-gnulinux-gnat}@anchor{df}
@subsection LLVM Backend on GNU/Linux with GCC/GNAT
@cartouche
@quotation Hint
You need to install LLVM (usually depends on @code{libedit}, see #29@footnote{https://github.com/ghdl/ghdl/issues/29}). The supported versions are 3.5 till 5.0, but debugging is only supported with LLVM 3.5.
@end quotation
@end cartouche
@itemize *
@item
First configure GHDL with the proper arg @code{./configure --with-llvm-config}. If @code{llvm-config} is not in your path, you can specify it: @code{./configure --with-llvm-config=LLVM_INSTALL/bin/llvm-config}.
@item
Then, build with @code{make} and install with @code{make install}.
@end itemize
@subsubheading Example:
@example
$ cd
$ mkdir build
$ cd build
$ ../configure --with-llvm-config --prefix=PREFIX
$ make
$ make install
@end example
@cartouche
@quotation Hint
If you want to have stack backtraces on errors (like assert failure or index of out bounds), you need to configure and build @code{libbacktrace} from GCC (you don’t need to configure GCC). Then add the following arg to configure: @code{--with-backtrace-lib=/path-to-gcc-build/libbacktrace/.libs/libbacktrace.a}
@end quotation
@end cartouche
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node LLVM Backend on Windows with GCC/GNAT MinGW,,LLVM Backend on GNU/Linux with GCC/GNAT,LLVM Backend
@anchor{building/llvm/Windows-MinGW-GNAT build-llvm-windows-mingw-gnat}@anchor{e0}@anchor{building/llvm/Windows-MinGW-GNAT doc}@anchor{dd}@anchor{building/llvm/Windows-MinGW-GNAT llvm-backend-on-windows-with-gcc-gnat-mingw}@anchor{e1}
@subsection LLVM Backend on Windows with GCC/GNAT (MinGW)
On Windows with MinGW, GHDL is configured by @code{configure} and build by @code{make}.
@itemize *
@item
First, GHDL needs to be configured. It is common to specify a @code{PREFIX}
(installation directory like @code{/usr/local} or @code{/opt/ghdl}). Without any
other option, @code{configure} select @cite{mcode} as backend.
@item
Next, @code{make} starts the compilation process.
@item
Finally, @code{make install} installs GHDL into the installation directory
specified by @code{PREFIX}.
@end itemize
@subsubheading Example:
@example
$ cd
$ mkdir build
$ cd build
$ ../configure --prefix=PREFIX
$ make
$ make install
@end example
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node GCC Backend,,LLVM Backend,Building GHDL from Sources
@anchor{building/gcc/index gcc-backend}@anchor{e2}@anchor{building/gcc/index build-gcc}@anchor{c8}@anchor{building/gcc/index doc}@anchor{e3}
@section GCC Backend
@subsubheading Requirements
@itemize *
@item
GCC (Gnu Compiler Collection)
@item
GNAT (Ada compiler for GCC)
@item
GCC source files. Download and untar the sources of version 4.9.x, 5.x, 6.x or 7.x
@end itemize
@subsubheading Supported platforms
@itemize *
@item
@ref{e4,,GCC Backend on GNU/Linux with GCC/GNAT}
@item
@ref{e5,,GCC Backend on Windows with GCC/GNAT (MinGW)}
@end itemize
@cartouche
@quotation Hint
Once GCC (with GHDL) has been built once, it is possible to work on the GHDL source tree without copying it in the GCC tree. Commands are:
@example
$ make ghdl1-gcc # Build the compiler
$ make ghdl_gcc # Build the driver
$ make libs.vhdl.local_gcc # Compile the vhdl libraries
$ make grt-all # Build the GHDL runtime
$ make grt.links # Locally install the GHDL runtime
@end example
In @code{src/ortho/gcc}, create a @code{Makefile.conf} file that sets the following
variables:
@example
AGCC_GCCSRC_DIR=/path/to/gcc/sources
AGCC_GCCOBJ_DIR=/path/to/gcc/build
@end example
@end quotation
@end cartouche
@cartouche
@quotation Hint
For ppc64 (and AIX ?) platform, the object file format contains an identifier for the source language. Because gcc doesn’t know about the VHDL, gcc crashes very early. This could be fixed with a very simple change in @code{gcc/config/rs6000/rs6000.c}, @code{function rs6000_output_function_epilogue} (as of gcc 4.8):
@example
else if (! strcmp (language_string, "GNU Objective-C"))
i = 14;
else
- gcc_unreachable ();
+ i = 0;
fprintf (file, "%d,", i);
/* 8 single bit fields: global linkage (not set for C extern linkage),
@end example
@end quotation
@end cartouche
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@menu
* GCC Backend on GNU/Linux with GCC/GNAT::
* GCC Backend on Windows with GCC/GNAT (MinGW): GCC Backend on Windows with GCC/GNAT MinGW.
@end menu
@node GCC Backend on GNU/Linux with GCC/GNAT,GCC Backend on Windows with GCC/GNAT MinGW,,GCC Backend
@anchor{building/gcc/GNULinux-GNAT gcc-backend-on-gnu-linux-with-gcc-gnat}@anchor{e6}@anchor{building/gcc/GNULinux-GNAT doc}@anchor{e4}@anchor{building/gcc/GNULinux-GNAT build-gcc-gnulinux-gnat}@anchor{e7}
@subsection GCC Backend on GNU/Linux with GCC/GNAT
@cartouche
@quotation Hint
There are some dependencies for building GCC (@code{gmp}, @code{mpfr} and @code{mpc}). If you have not them installed on your system, you can either build them manually or use the @code{download_prerequisites} script provided in the GCC source tree (recommended): @code{cd /path/to/gcc/source/dir && ./contrib/download_prerequisites}.
@end quotation
@end cartouche
@itemize *
@item
First configure GHDL, specify GCC source directory and @code{PREFIX} (installation directory like @code{/usr/local} or @code{/opt/ghdl}).
@item
Next, invoke @code{make} to copy GHDL sources in the source directory.
@item
Then, configure GCC. The list of @code{--disable} configure options can be adjusted to your needs. GHDL does not require all these optional libraries and disabling them will speed-up the build.
@item
Now, build and install GCC with @code{make}.
@item
Last, build and install GHDL libraries.
@end itemize
@subsubheading Example:
@example
$ cd
$ mkdir build
$ cd build
$ ../configure --with-gcc=/path/to/gcc/source/dir --prefix=PREFIX
$ make copy-sources
$ mkdir gcc-objs; cd gcc-objs
$ /path/to/gcc/source/dir/configure --prefix=/usr/local --enable-languages=c,vhdl \
--disable-bootstrap --disable-lto --disable-multilib --disable-libssp \
--disable-libgomp --disable-libquadmath
$ make -j2 && make install
$ cd /path/to/ghdl/source/dir/build
$ make ghdllib
$ make install
@end example
@cartouche
@quotation Hint
Note that the prefix directory must be the same as the one used to configure GHDL. If you have manually built @code{gmp}/@code{mpfr}/@code{mpc} (without using the script in @code{contrib}) and if you have installed them in a non-standard directory, you may need to add @code{--with-gmp=GMP_INSTALL_DIR}.
@end quotation
@end cartouche
@cartouche
@quotation Hint
If your system gcc was configured with @code{--enable-default-pie} (check if that option appears in the output of @code{gcc -v}), you should also add it.
@end quotation
@end cartouche
@cartouche
@quotation Hint
If you don’t want to install @code{makeinfo}, do @code{make install MAKEINFO=false} instead.
@end quotation
@end cartouche
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node GCC Backend on Windows with GCC/GNAT MinGW,,GCC Backend on GNU/Linux with GCC/GNAT,GCC Backend
@anchor{building/gcc/Windows-MinGW-GNAT build-gcc-windows-mingw-gnat}@anchor{e8}@anchor{building/gcc/Windows-MinGW-GNAT doc}@anchor{e5}@anchor{building/gcc/Windows-MinGW-GNAT gcc-backend-on-windows-with-gcc-gnat-mingw}@anchor{e9}
@subsection GCC Backend on Windows with GCC/GNAT (MinGW)
@cartouche
@quotation Todo
Under investigation on how to build that beast.
@end quotation
@end cartouche
@c #
@c On Windows with MinGW, GHDL is configured by ``configure`` and build by ``make``.
@c
@c * First, GHDL needs to be configured. It is common to specify a ``PREFIX``
@c (installation directory like ``/usr/local`` or ``/opt/ghdl``). Without any
@c other option, ``configure`` select `mcode` as backend.
@c
@c * Next, ``make`` starts the compilation process.
@c
@c * Finally, ``make install`` installs GHDL into the installation directory
@c specified by ``PREFIX``.
@c
@c .. rubric:: Example:
@c
@c .. code-block:: Bash
@c
@c $ cd
@c $ mkdir build
@c $ cd build
@c $ ../configure --prefix=PREFIX
@c $ make
@c $ make install
@cartouche
@quotation Hint
The output of both GCC and LLVM is an executable file, but @cite{mcode} does not
generate any. Therefore, if using GCC/LLVM, the call with argument @code{-r} can
be replaced with direct execution of the binary. See section @ref{d,,Quick Start Guide}.
@end quotation
@end cartouche
After making your choice, you can jump to the corresponding section.
However, we suggest you to read @ref{1a,,Directory Structure} before, so that you
know where the content is placed and which temporal files are expected to be
created.
@cartouche
@quotation Hint
Since GHDL is written in @cite{Ada}, independently of the code generator you use,
the @cite{GNU Ada compiler}, @cite{GNAT GPL}, is required, 2014 (or later) for @code{x86}
(32 or 64 bits). @cite{GNAT GPL} can be downloaded anonymously from libre.adacore.com@footnote{http://libre.adacore.com/tools/gnat-gpl-edition/}.
Then, untar and run the doinstall script. Alternatively, most GNU/Linux
provide a package named @code{gcc-ada} or @code{gcc-gnat}.
@end quotation
@end cartouche
@cartouche
@quotation Hint
In these instructions, the configure script is executed in the source directory; but you can execute in a different
directory too, like this:
@quotation
@example
$ mkdir ghdl-objs
$ cd ghdl-objs
$ ../path/to/ghdl/configure ...
@end example
@end quotation
@end quotation
@end cartouche
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Precompile Vendor Primitives,Command Reference,Building GHDL from Sources,Top
@anchor{building/PrecompileVendorPrimitives precompile-vendor-primitives}@anchor{ea}@anchor{building/PrecompileVendorPrimitives getting-precompvendor}@anchor{cb}@anchor{building/PrecompileVendorPrimitives doc}@anchor{eb}
@chapter Precompile Vendor Primitives
Vendors like Altera, Lattice and Xilinx have their own simulation libraries,
especially for FPGA primitives, soft and hard macros. These libraries can not
be shipped with @emph{GHDL}, but we offer prepared compile scripts to pre-compile
the vendor libraries, if the vendor tool is present on the computer. There are
also popular simulation and verification libraries like OSVVM @footnote{
OSVVM @indicateurl{http://github.com/OSVVM/OSVVM}
}, VUnit
@footnote{
VUnit @indicateurl{https://github.com/VUnit/vunit}
} or UVVM @footnote{
UVVM @indicateurl{https://github.com/UVVM/UVVM_All}
}, which can be pre-compiled, too.
The compilation scripts are writen in the shell languages: @emph{PowerShell} for
@emph{Windows} ™ and @emph{Bash} for @emph{GNU/Linux}. The compile scripts can colorize
the GHDL warning and error lines with the help of @cite{grc/grcat} @footnote{
Generic Colourizer @indicateurl{http://kassiopeia.juls.savba.sk/~garabik/software/grc.html}
}.
@menu
* Supported Vendors Libraries::
* Supported Simulation and Verification Libraries::
* Script Configuration::
* Compiling on Linux::
* Compiling on Windows::
* Configuration Files::
@end menu
@node Supported Vendors Libraries,Supported Simulation and Verification Libraries,,Precompile Vendor Primitives
@anchor{building/PrecompileVendorPrimitives supported-vendors-libraries}@anchor{ec}
@section Supported Vendors Libraries
@itemize *
@item
Altera/Intel Quartus (13.0 or later):
@itemize *
@item
@cite{lpm}, @cite{sgate}
@item
@cite{altera}, @cite{altera_mf}, @cite{altera_lnsim}
@item
@cite{arriaii}, @cite{arriaii_pcie_hip}, @cite{arriaiigz}
@item
@cite{arriav}, @cite{arriavgz}, @cite{arriavgz_pcie_hip}
@item
@cite{cycloneiv}, @cite{cycloneiv_pcie_hip}, @cite{cycloneive}
@item
@cite{cyclonev}
@item
@cite{max}, @cite{maxii}, @cite{maxv}
@item
@cite{stratixiv}, @cite{stratixiv_pcie_hip}
@item
@cite{stratixv}, @cite{stratixv_pcie_hip}
@item
@cite{fiftyfivenm}, @cite{twentynm}
@end itemize
@item
Lattice (3.6 or later):
@itemize *
@item
@cite{ec}
@item
@cite{ecp}, @cite{ecp2}, @cite{ecp3}, @cite{ecp5u}
@item
@cite{lptm}, @cite{lptm2}
@item
@cite{machxo}, @cite{machxo2}, @cite{machxo3l}
@item
@cite{sc}, @cite{scm}
@item
@cite{xp}, @cite{xp2}
@end itemize
@item
Xilinx ISE (14.0 or later):
@itemize *
@item
@cite{unisim} (incl. @cite{secureip})
@item
@cite{unimacro}
@item
@cite{simprim} (incl. @cite{secureip})
@item
@cite{xilinxcorelib}
@end itemize
@item
Xilinx Vivado (2014.1 or later):
@itemize *
@item
@cite{unisim} (incl. @cite{secureip})
@item
@cite{unimacro}
@end itemize
@end itemize
@node Supported Simulation and Verification Libraries,Script Configuration,Supported Vendors Libraries,Precompile Vendor Primitives
@anchor{building/PrecompileVendorPrimitives supported-simulation-and-verification-libraries}@anchor{ed}
@section Supported Simulation and Verification Libraries
@itemize *
@item
OSVVM (for VHDL-2008)
@quotation
@itemize *
@item
osvvm
@end itemize
@end quotation
@item
VUnit (for VHDL-2008)
@quotation
@itemize *
@item
vunit_lib
@end itemize
@end quotation
@item
UVVM (for VHDL-2008)
@itemize *
@item
@end itemize
@end itemize
__________________________________________________________________
@node Script Configuration,Compiling on Linux,Supported Simulation and Verification Libraries,Precompile Vendor Primitives
@anchor{building/PrecompileVendorPrimitives script-configuration}@anchor{ee}
@section Script Configuration
The vendor library compile scripts need to know where the used / latest vendor
tool chain is installed. Therefore, the script implement a default installation
directory search as well as environment variable checks. If a vendor tool could
not be detected or the script choses the wrong vendor library source directory,
then it’s possible to provide the path via @cite{–source} or @cite{-Source}.
The generated output is stored relative to the current working directory. The
scripts create a sub-directory for each vendor. The default output directory can
be overwritten by the parameter @cite{–output} or @cite{-Output}.
To compile all source files with GHDL, the simulator executable is searched in
@cite{PATH}. The found default GHDL executable can be overwritten by setting the
environment variable @cite{GHDL} or by passing the parameter @cite{–ghdl} or @cite{-GHDL} to
the scripts.
If the vendor library compilation is used very often, we recommend to configure
these parameters in @cite{config.sh} or @cite{config.psm1}, so the command line can be
shortened to the essential parts.
__________________________________________________________________
@node Compiling on Linux,Compiling on Windows,Script Configuration,Precompile Vendor Primitives
@anchor{building/PrecompileVendorPrimitives compiling-on-linux}@anchor{ef}
@section Compiling on Linux
@itemize *
@item
@table @asis
@item @strong{Step 0 - Configure the scripts (optional)}
See next section for how to configure @cite{config.sh}.
@end table
@item
@strong{Step 1 - Browse to your simulation working directory}
@example
$ cd
`@w{`}`
@end example
@item
@strong{Step 2 - Start the compilation script(s)}
@example
$ /usr/local/lib/ghdl/vendors/compile-altera.sh --all
$ /usr/local/lib/ghdl/vendors/compile-lattice.sh --all
$ /usr/local/lib/ghdl/vendors/compile-xilinx-ise.sh --all
$ /usr/local/lib/ghdl/vendors/compile-xilinx-vivado.sh --all
$ /usr/local/lib/ghdl/vendors/compile-osvvm.sh --all
$ /usr/local/lib/ghdl/vendors/compile-vunit.sh --all
`@w{`}`
In most cases GHDL is installed into `/usr/local/`. The scripts are
installed into the `lib` directory.
@end example
@item
@table @asis
@item @strong{Step 3 - Viewing the result}
This creates vendor directories in your current working directory and
compiles the vendor files into them.
@end table
@example
$ ls -ahl
...
drwxr-xr-x 2 56K Nov 30 17:41 altera
drwxr-xr-x 2 56K Nov 30 17:42 lattice
drwxr-xr-x 2 56K Nov 30 17:48 osvvm
drwxr-xr-x 2 56K Nov 30 17:58 vunit
drwxr-xr-x 2 56K Nov 30 17:58 xilinx-ise
drwxr-xr-x 2 56K Nov 30 17:48 xilinx-vivado
`@w{`}`
@end example
@end itemize
__________________________________________________________________
@node Compiling on Windows,Configuration Files,Compiling on Linux,Precompile Vendor Primitives
@anchor{building/PrecompileVendorPrimitives compiling-on-windows}@anchor{f0}
@section Compiling on Windows
@itemize *
@item
@strong{Step 0 - Configure the scripts (optional)}
See next section for how to configure @cite{config.psm1}.
@item
@strong{Step 1 - Browse to your simulation working directory}
@example
PS> cd
@end example
@item
@strong{Step 2 - Start the compilation script(s)}
@example
PS> \libraries\vendors\compile-altera.ps1 -All
PS> \libraries\vendors\compile-lattice.ps1 -All
PS> \libraries\vendors\compile-xilinx-ise.ps1 -All
PS> \libraries\vendors\compile-xilinx-vivado.ps1 -All
PS> \libraries\vendors\compile-osvvm.ps1 -All
PS> \libraries\vendors\compile-vunit.ps1 -All
@end example
@item
@strong{Step 3 - Viewing the result}
This creates vendor directories in your current working directory and
compiles the vendor files into them.
@example
PS> dir
Directory: D:\temp\ghdl
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 20.11.2015 19:33 altera
d---- 20.11.2015 19:38 lattice
d---- 20.11.2015 19:38 osvvm
d---- 20.11.2015 19:45 vunit_lib
d---- 20.11.2015 19:06 xilinx-ise
d---- 20.11.2015 19:40 xilinx-vivado
@end example
@end itemize
__________________________________________________________________
@node Configuration Files,,Compiling on Windows,Precompile Vendor Primitives
@anchor{building/PrecompileVendorPrimitives configuration-files}@anchor{f1}
@section Configuration Files
@menu
* For Linux; config.sh: For Linux config sh.
* For Windows; config.psm1: For Windows config psm1.
* Selectable Options for the Bash Scripts;: Selectable Options for the Bash Scripts.
* Selectable Options for the PowerShell Scripts;: Selectable Options for the PowerShell Scripts.
@end menu
@node For Linux config sh,For Windows config psm1,,Configuration Files
@anchor{building/PrecompileVendorPrimitives for-linux-config-sh}@anchor{f2}
@subsection For Linux: @cite{config.sh}
Please open the @cite{config.sh} file and set the dictionary entries for the
installed vendor tools to the appropriate directory to your tool’s installation
directories. Use an empty string @cite{“”} for not installed tools.
@cite{config.sh}:
@example
declare -A InstallationDirectory
InstallationDirectory[AlteraQuartus]="/opt/Altera/16.0"
InstallationDirectory[LatticeDiamond]="/opt/Diamond/3.8_x64"
InstallationDirectory[OSVVM]="/home//git/GitHub/osvvm"
InstallationDirectory[VUnit]="/home//git/GitHub/vunit"
InstallationDirectory[XilinxISE]="/opt/Xilinx/14.7"
InstallationDirectory[XilinxVivado]="/opt/Xilinx/Vivado/2016.3"
@end example
@node For Windows config psm1,Selectable Options for the Bash Scripts,For Linux config sh,Configuration Files
@anchor{building/PrecompileVendorPrimitives for-windows-config-psm1}@anchor{f3}
@subsection For Windows: @cite{config.psm1}
Please open the @cite{config.psm1} file and set the dictionary entries for the
installed vendor tools to the appropriate directory to your tool’s installation
folder. Use an empty string @cite{“”} for not installed tools.
@cite{config.psm1}:
@example
$InstallationDirectory = @@@{
"AlteraQuartus" = "C:\Altera\16.0";
"LatticeDiamond" = "C:\Lattice\Diamond\3.8_x64";
"XilinxISE" = "C:\Xilinx\14.7\ISE_DS";
"XilinxVivado" = "C:\Xilinx\Vivado\2016.3";
"OSVVM" = "D:\git\GitHub\osvvm";
"VUnit" = "D:\git\GitHub\vunit"
@}
@end example
@node Selectable Options for the Bash Scripts,Selectable Options for the PowerShell Scripts,For Windows config psm1,Configuration Files
@anchor{building/PrecompileVendorPrimitives selectable-options-for-the-bash-scripts}@anchor{f4}
@subsection Selectable Options for the Bash Scripts:
@emph{First I should translate the scripts before writing the docu…}
@itemize *
@item
Common parameters to most scripts:
@example
-h --help Print the embedded help page(s).
-c --clean Cleanup directory before analyzing.
-n --no-warnings Don't show warnings. Report errors only.
-s --skip-existing Skip already compiled files (an *.o file exists).
-S --skip-largefiles Don't compile large entities like DSP and PCIe primitives.
-H --halt-on-error Stop compiling if an error occurred.
@end example
@item
@cite{compile-altera.sh}
Selectable libraries:
@example
-a --all Compile all libraries, including common libraries, packages and device libraries.
--altera Compile base libraries like 'altera' and 'altera_mf'
--max Compile device libraries for Max CPLDs
--arria Compile device libraries for Arria FPGAs
--cyclone Compile device libraries for Cyclone FPGAs
--stratix Compile device libraries for Stratix FPGAs
Compile options:
.. code-block:: raw
--vhdl93 Compile selected libraries with VHDL-93 (default).
--vhdl2008 Compile selected libraries with VHDL-2008.
@end example
@item
@cite{compile-xilinx-ise.sh}
Selectable libraries:
@example
-a --all Compile all libraries, including common libraries, packages and device libraries.
--unisim Compile the unisim primitives
--unimacro Compile the unimacro macros
--simprim Compile the simprim primitives
--corelib Compile the xilinxcorelib macros
--secureip Compile the secureip primitives
@end example
Compile options:
@example
--vhdl93 Compile selected libraries with VHDL-93 (default).
--vhdl2008 Compile selected libraries with VHDL-2008.
@end example
@item
@cite{compile-xilinx-vivado.sh}
Selectable libraries:
@example
-a --all Compile all libraries, including common libraries, packages and device libraries.
--unisim Compile the unisim primitives
--unimacro Compile the unimacro macros
--secureip Compile the secureip primitives
@end example
Compile options:
@example
--vhdl93 Compile selected libraries with VHDL-93 (default).
--vhdl2008 Compile selected libraries with VHDL-2008.
@end example
@item
@cite{compile-osvvm.sh}
Selectable libraries:
@example
-a --all Compile all.
--osvvm Compile the OSVVM library.
@end example
@item
@cite{compile-vunit.sh}
Selectable libraries:
@example
-a --all Compile all.
--osvvm Compile the VUnit library.
@end example
@item
@cite{compile-uvvm.sh}
Selectable libraries:
@example
-a --all Compile all.
--uvvm Compile the VUnit library.
@end example
@end itemize
@node Selectable Options for the PowerShell Scripts,,Selectable Options for the Bash Scripts,Configuration Files
@anchor{building/PrecompileVendorPrimitives selectable-options-for-the-powershell-scripts}@anchor{f5}
@subsection Selectable Options for the PowerShell Scripts:
@itemize *
@item
Common parameters to all scripts:
@example
-Help Print the embedded help page(s).
-Clean Cleanup directory before analyzing.
-SuppressWarnings Don't show warnings. Report errors only.
@end example
@item
@cite{compile-altera.ps1}
Selectable libraries:
@example
-All Compile all libraries, including common libraries, packages and device libraries.
-Altera Compile base libraries like 'altera' and 'altera_mf'
-Max Compile device libraries for Max CPLDs
-Arria Compile device libraries for Arria FPGAs
-Cyclone Compile device libraries for Cyclone FPGAs
-Stratix Compile device libraries for Stratix FPGAs
@end example
Compile options:
@example
-VHDL93 Compile selected libraries with VHDL-93 (default).
-VHDL2008 Compile selected libraries with VHDL-2008.
@end example
@item
@cite{compile-xilinx-ise.ps1}
Selectable libraries:
@example
-All Compile all libraries, including common libraries, packages and device libraries.
-Unisim Compile the unisim primitives
-Unimacro Compile the unimacro macros
-Simprim Compile the simprim primitives
-CoreLib Compile the xilinxcorelib macros
-Secureip Compile the secureip primitives
@end example
Compile options:
@example
-VHDL93 Compile selected libraries with VHDL-93 (default).
-VHDL2008 Compile selected libraries with VHDL-2008.
@end example
@item
@cite{compile-xilinx-vivado.ps1}
Selectable libraries:
@example
-All Compile all libraries, including common libraries, packages and device libraries.
-Unisim Compile the unisim primitives
-Unimacro Compile the unimacro macros
-Secureip Compile the secureip primitives
@end example
Compile options:
@example
-VHDL93 Compile selected libraries with VHDL-93 (default).
-VHDL2008 Compile selected libraries with VHDL-2008.
@end example
@item
@cite{compile-osvvm.ps1}
Selectable libraries:
@example
-All Compile all.
-OSVVM Compile the OSVVM library.
@end example
@item
@cite{compile-vunit.ps1}
Selectable libraries:
@example
-All Compile all.
-VUnit Compile the VUnit library.
@end example
@item
@cite{compile-uvvm.ps1}
Selectable libraries:
@example
-All Compile all.
-UVVM Compile the UVVM libraries.
@end example
@end itemize
__________________________________________________________________
@quotation
@end quotation
@c # preload commonly known graphical characters like (c)
@c This data file has been placed in the public domain.
@c Derived from the Unicode character mappings available from
@c .
@c Processed by unicode2rstsubs.py, part of Docutils:
@c .
@c # define a hard kine break for HTML
@node Command Reference,Coding Style,Precompile Vendor Primitives,Top
@anchor{references/CommandReference ref-command}@anchor{f}@anchor{references/CommandReference command-reference}@anchor{f6}@anchor{references/CommandReference doc}@anchor{f7}
@chapter Command Reference
@cartouche
@quotation Hint
The most common commands and options are shown in section @ref{e,,Invoking GHDL}. Here the advanced and experimental features are described.
@end quotation
@end cartouche
@menu
* Environment variables::
* Misc commands::
* File commands::
* GCC/LLVM only commands::
* Options: Options<2>.
* Passing options to other programs::
@end menu
@node Environment variables,Misc commands,,Command Reference
@anchor{references/CommandReference environment-variables}@anchor{f8}
@section Environment variables
@geindex environment variable; GHDL_PREFIX
@anchor{references/CommandReference envvar-GHDL_PREFIX}@anchor{33}
@deffn {Environment Variable} GHDL_PREFIX
@end deffn
@node Misc commands,File commands,Environment variables,Command Reference
@anchor{references/CommandReference misc-commands}@anchor{f9}
@section Misc commands
There are a few GHDL commands which are seldom useful.
@geindex cmd help
@menu
* Help [-h]::
* Display config [--disp-config]::
* Display standard [--disp-standard]::
* Version [--version]::
@end menu
@node Help [-h],Display config [--disp-config],,Misc commands
@anchor{references/CommandReference help-h}@anchor{fa}
@subsection Help [@code{-h}]
@geindex ghdl command line option; --help@comma{} -h
@anchor{references/CommandReference cmdoption-ghdl-help}@anchor{fb}
@deffn {Option} @w{-}@w{-}help, @w{-}h
@end deffn
Display (on the standard output) a short description of the all the commands
available. If the help switch is followed by a command switch, then options
for this later command are displayed:
@example
ghdl --help
ghdl -h
ghdl -h command
@end example
@geindex cmd display configuration
@node Display config [--disp-config],Display standard [--disp-standard],Help [-h],Misc commands
@anchor{references/CommandReference display-config-disp-config}@anchor{fc}
@subsection Display config [@code{--disp-config}]
@geindex ghdl command line option; --disp-config <[options]>
@anchor{references/CommandReference cmdoption-ghdl-disp-config}@anchor{34}
@deffn {Option} @w{-}@w{-}disp@w{-}config <[options]>
@end deffn
Display the program paths and options used by GHDL. This may be useful to track installation errors.
@geindex cmd display standard
@geindex display `@w{`}std.standard`@w{`}
@node Display standard [--disp-standard],Version [--version],Display config [--disp-config],Misc commands
@anchor{references/CommandReference display-standard-disp-standard}@anchor{fd}
@subsection Display standard [@code{--disp-standard}]
@geindex ghdl command line option; --disp-standard <[options]>
@anchor{references/CommandReference cmdoption-ghdl-disp-standard}@anchor{fe}
@deffn {Option} @w{-}@w{-}disp@w{-}standard <[options]>
@end deffn
Display the @code{std.standard} package.
@geindex cmd version
@node Version [--version],,Display standard [--disp-standard],Misc commands
@anchor{references/CommandReference version-version}@anchor{ff}
@subsection Version [@code{--version}]
@geindex ghdl command line option; --version@comma{} -v
@anchor{references/CommandReference cmdoption-ghdl-version}@anchor{100}
@deffn {Option} @w{-}@w{-}version, @w{-}v
@end deffn
Display the GHDL version and exit.
@node File commands,GCC/LLVM only commands,Misc commands,Command Reference
@anchor{references/CommandReference file-commands}@anchor{101}
@section File commands
The following commands act on one or several files. These are not analyzed, therefore, they work even if a file has semantic errors.
@geindex cmd file pretty printing
@geindex vhdl to html
@menu
* Pretty print [--pp-html]::
* Find [-f]::
* Chop [--chop]::
* Lines [--lines]::
@end menu
@node Pretty print [--pp-html],Find [-f],,File commands
@anchor{references/CommandReference pretty-print-pp-html}@anchor{102}
@subsection Pretty print [@code{--pp-html}]
@geindex ghdl command line option; --pp-html <[options] file...>
@anchor{references/CommandReference cmdoption-ghdl-pp-html}@anchor{103}
@deffn {Option} @w{-}@w{-}pp@w{-}html <[options] file...>
@end deffn
The files are just scanned and an html file, with syntax highlighting is generated on standard output. Since the files are not even parsed, erroneous files or incomplete designs can be pretty printed.
The style of the html file can be modified with the @code{--format=} option:
@itemize *
@item
By default or when the @code{--format=html2} option is specified, the output is an HTML 2.0 file, with colours set through @cite{} tags.
@item
When the @code{--format=css} option is specified, the output is an HTML 4.0 file, with colours set through a CSS file, whose name is @code{ghdl.css}. See Cross-reference_command, for more details about this CSS file.
@end itemize
@geindex cmd file find
@node Find [-f],Chop [--chop],Pretty print [--pp-html],File commands
@anchor{references/CommandReference find-f}@anchor{104}
@subsection Find [@code{-f}]
@geindex ghdl command line option; -f
@anchor{references/CommandReference cmdoption-ghdl-f}@anchor{48}
@deffn {Option} @w{-}f
@end deffn
The files are scanned, parsed and the names of design units are displayed. Design units marked with two stars are candidate to be at the apex of a design hierarchy.
@geindex cmd file chop
@node Chop [--chop],Lines [--lines],Find [-f],File commands
@anchor{references/CommandReference chop-chop}@anchor{105}
@subsection Chop [@code{--chop}]
@geindex ghdl command line option; --chop
@anchor{references/CommandReference cmdoption-ghdl-chop}@anchor{106}
@deffn {Option} @w{-}@w{-}chop
@end deffn
The provided files are read, and a file is written in the current directory for every design unit. Each filename is build according to the type:
@itemize *
@item
For an entity declaration, a package declaration or a configuration the file name is @code{NAME.vhdl}, where @cite{NAME} is the name of the design unit.
@item
For a package body, the filename is @code{NAME-body.vhdl}.
@item
Finally, for an architecture @cite{ARCH} of an entity @cite{ENTITY}, the filename is @code{ENTITY-ARCH.vhdl}.
@end itemize
Since the input files are parsed, this command aborts in case of syntax error. The command aborts too if a file to be written already exists.
Comments between design units are stored into the most adequate files.
This command may be useful to split big files, if your computer has not enough memory to compile such files. The size of the executable is reduced too.
@geindex cmd file lines
@node Lines [--lines],,Chop [--chop],File commands
@anchor{references/CommandReference lines-lines}@anchor{107}
@subsection Lines [@code{--lines}]
@geindex ghdl command line option; --lines
@anchor{references/CommandReference cmdoption-ghdl-lines}@anchor{108}
@deffn {Option} @w{-}@w{-}lines
@end deffn
Display on the standard output lines of files preceded by line number.
@node GCC/LLVM only commands,Options<2>,File commands,Command Reference
@anchor{references/CommandReference gcc-llvm-only-commands}@anchor{109}
@section GCC/LLVM only commands
@geindex cmd GCC/LLVM binding
@menu
* Bind [--bind]::
* Link [--link]::
* List link [--list-link]::
@end menu
@node Bind [--bind],Link [--link],,GCC/LLVM only commands
@anchor{references/CommandReference bind-bind}@anchor{10a}
@subsection Bind [@code{--bind}]
@geindex ghdl command line option; --bind <[options] primary_unit [secondary_unit]>
@anchor{references/CommandReference cmdoption-ghdl-bind}@anchor{47}
@deffn {Option} @w{-}@w{-}bind <[options] primary_unit [secondary_unit]>
@end deffn
Performs only the first stage of the elaboration command; the list of objects files is created but the executable is not built. This command should be used only when the main entry point is not GHDL.
@geindex cmd GCC/LLVM linking
@node Link [--link],List link [--list-link],Bind [--bind],GCC/LLVM only commands
@anchor{references/CommandReference link-link}@anchor{10b}
@subsection Link [@code{--link}]
@geindex ghdl command line option; --link <[options] primary_unit [secondary_unit]>
@anchor{references/CommandReference cmdoption-ghdl-link}@anchor{10c}
@deffn {Option} @w{-}@w{-}link <[options] primary_unit [secondary_unit]>
@end deffn
Performs only the second stage of the elaboration command: the executable is created by linking the files of the object files list. This command is available only for completeness. The elaboration command is equivalent to the bind command followed by the link command.
@geindex cmd GCC/LLVM list link
@node List link [--list-link],,Link [--link],GCC/LLVM only commands
@anchor{references/CommandReference list-link-list-link}@anchor{10d}
@subsection List link [@code{--list-link}]
@geindex ghdl command line option; --list-link
@anchor{references/CommandReference cmdoption-ghdl-list-link}@anchor{10e}
@deffn {Option} @w{-}@w{-}list@w{-}link
@end deffn
This command may be used only after a bind command. GHDL displays all the files which will be linked to create an executable. This command is intended to add object files in a link of a foreign program.
@node Options<2>,Passing options to other programs,GCC/LLVM only commands,Command Reference
@anchor{references/CommandReference options}@anchor{10f}
@section Options
@geindex ghdl command line option; --mb-comments@comma{} -C
@anchor{references/CommandReference cmdoption-ghdl-mb-comments}@anchor{29}
@deffn {Option} @w{-}@w{-}mb@w{-}comments, @w{-}C
@end deffn
Allow multi-bytes chars in a comment
@geindex ghdl command line option; --syn-binding
@anchor{references/CommandReference cmdoption-ghdl-syn-binding}@anchor{110}
@deffn {Option} @w{-}@w{-}syn@w{-}binding
@end deffn
Use synthesizer rules for component binding. During elaboration, if a component is not bound to an entity using VHDL LRM rules, try to find in any known library an entity whose name is the same as the component name.
This rule is known as synthesizer rule.
There are two key points: normal VHDL LRM rules are tried first and entities are searched only in known library. A known library is a library which has been named in your design.
This option is only useful during elaboration.
@geindex ghdl command line option; --GHDL1<=COMMAND>
@anchor{references/CommandReference cmdoption-ghdl-ghdl1}@anchor{111}
@deffn {Option} @w{-}@w{-}GHDL1<=COMMAND>
@end deffn
Use @code{COMMAND} as the command name for the compiler. If @code{COMMAND} is not a path, then it is searched in the path.
@geindex ghdl command line option; --AS<=COMMAND>
@anchor{references/CommandReference cmdoption-ghdl-as}@anchor{112}
@deffn {Option} @w{-}@w{-}AS<=COMMAND>
@end deffn
Use @code{COMMAND} as the command name for the assembler. If @code{COMMAND} is not a path, then it is searched in the path. The default is @code{as}.
@geindex ghdl command line option; --LINK<=COMMAND>
@anchor{references/CommandReference id1}@anchor{113}
@deffn {Option} @w{-}@w{-}LINK<=COMMAND>
@end deffn
Use @code{COMMAND} as the linker driver. If @code{COMMAND} is not a path, then it is searched in the path. The default is @code{gcc}.
@node Passing options to other programs,,Options<2>,Command Reference
@anchor{references/CommandReference passing-options-to-other-programs}@anchor{114}
@section Passing options to other programs
@cartouche
@quotation Warning
These options are only available with GCC/LLVM.
@end quotation
@end cartouche
For many commands, GHDL acts as a driver: it invokes programs to perform the command. You can pass arbitrary options to these programs.
Both the compiler and the linker are in fact GCC programs. See the GCC manual for details on GCC options.
@geindex ghdl command line option; -Wc@comma{}