Newer
Older
This is a small [VHDL](https://en.wikipedia.org/wiki/VHDL) Crash-Course I use for teaching in the Module "Grundlagen der technischen Informatik" (GTI). This Repository contains all tasks solved in the Exercises in form of templates students can fill out on their own as well as solutions. This Project also comes with [Testbenches](https://vhdlwhiz.com/terminology/testbench/) for all tasks with which you can test the solutions as well as your own implementations.
* [Getting Started](#getting-started)
* [GHDL](#ghdl)
* [Windows/Mac](#windows/mac)
* [Linux](#linux)
* [GTKWave](#gtkwave)
* [Windows](#windows)
* [Mac](#mac)
* [Linux](#linux)
* [Usage](#general-description)
* [Usage: GHDL](#usage:-ghdl)
* [Usage: GTKWave](#usage:-gtkwave)
**If you work directly on a CIP \[RECOMMENDED\], you can skip this section**
The following section will go through how you can install a simulator as well as a wave viewer in order to test your written VHDL-Code. This tutorial will focus on [GHDL](https://github.com/ghdl/ghdl) as the Simulator being used as well as on [GTKWave](https://gtkwave.sourceforge.net/) as the wave viewer. Fell free to use other Simulators/Wave Viewer like [Xilinx Vivado](https://www.xilinx.com/products/design-tools/vivado.html) or [ModelSim](https://eda.sw.siemens.com/en-US/ic/modelsim/), but this guide will focus on the previous mentioned Open-Source Software alternatives.
First we want to install GHDL as our main simulator. For that, head over to https://github.com/ghdl/ghdl/releases/latest and download the latest release for the OS of your choice.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#### Windows/Mac
For Windows and Mac the install should be straight forward. Download the respective release and put the program inside a suitable directory (e.g. the Programs folder). After that you need to add the "bin"-folder of the release to your PATH-Variable. For this you can follow [this guide](https://medium.com/@jamexkarix583/add-bin-folder-to-the-path-772de253f579). After that you should be able to use the "ghdl" command in your terminal.
```
$ ghdl version
GHDL 3.0.0 (3.0.0.r0.g7de967c51) [Dunoon edition]
Compiled with GNAT Version: 7.5.0
mcode code generator
Written by Tristan Gingold.
Copyright (C) 2003 - 2023 Tristan Gingold.
GHDL is free software, covered by the GNU General Public License. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
#### Linux
The Linux install can be a bit tricky depending on your distribution. For this I can't really give a straight forward way of installing it, but I would advise you to check your packet managers. If GHDL is not provided in your standard packet managers, try others like SNAP. (I personally use the SNAP build on my [Manjaro](https://manjaro.org/) machine).
### GTKWave
Now that we have our Simulator up-and-running we head over to our wave viewer so that we can view our signals produced by our architecture.
#### Windows
For Windows head over to the download [here](https://sourceforge.net/projects/gtkwave/files/gtkwave-3.3.100-bin-win32/gtkwave-3.3.100-bin-win32.zip/download) and run it.
#### Mac
TODO (Unfortunately I don't have a device to test the installation on so for now you are on your own)
#### Linux
GTKWave most of the time ships with your favorite packet-manager. If you are not able to find it, you can download it manually other the download [here](https://gtkwave.sourceforge.net/gtkwave-3.3.117.tar.gz) and build it yourself.
Now that we have our software up-and-running we can continue with actually using the software. First I will go over how to simulate your VHDL-Code via GHDL and after that I will show you how you can view your own wave diagrams via GTKWave.
### Usage: GHDL
"Compiling" a VHDL simulation can mainly be divided into three separate steps. The first step ist to analyse your VHDL file as well as your testbench you want to use. For that type the following command into your terminal of choice:
```
$ ghdl -a --ieee=synopsys --std='08' <source_file.vhd> <tb_source_file.vhd>
```
The *std*-Flag as well as the *ieee*-Flags are necessary for the provided testbenches and source-files to compile because especially the testbenches are using features only presented in the VHDL-2008-Standard or higher.
After that you need to elaborate your design unit (meaning your testbench you want to run in the end) and check if any errors are still present in your unit. This shouldn't result in problems in this project though because the testbenches should (hopefully) work. For this run the following command:
```
$ ghdl -e --ieee=synopsys --std='08' <tb_source_file>
```
Notice this time you don't specify the file extension, but you still need the other two flags.
Last but not least you can finally run your simulation. For that type in following command:
```
$ ghdl -r --ieee=synopsys --std='08' <tb_source_file> --wave=<tb_source_file.ghw> --stop-time=<amount-of-time>
```
Here we have two additional flags. The *wave*-Flag specifies how the resulting wave diagram needs to be named which we can later use in GTKWave in order to view our signals. The *stop-time*-Flag just indicates for how many seconds the simulation needs to compute it's signals. *25sec* as an parameter should plenty enough for all simulations.
If you are using a Unix system (e.g. the CIP) you don't have to manually type these commands by hand. Just type
```
$ make solutions
```
if you want to run the simulations and get the waveform diagrams (located in the "wav"-folder) for the solutions and
if you want to run the simulations and get the waveform diagrams for the your own solutions (have to be located in the "templates"-folder).
Now that we have our *.ghw*-File we can use it for usage in GTKWave. This example uses the *tb_or_reduce.ghw* wave diagram you get when running the simulation for the *or_reduce* architecture and testbench, but this also works for all other VHDL-tasks. For this I would also like to advise to have a look on the official user guide of GTKWave found [here](https://gtkwave.sourceforge.net/gtkwave.pdf)
First start up GTKWave and load wave diagram file as seen in the screenshot below.
// TODO: picture1
After that you should your components structured in a hierarchal way in the "SST"-Tab. You can click on your components and select your signals you want to use from the "Signals"-Tab, as shown in the next picture.
// TODO: picture2
If you want to automatically zoom in/out so that you can see the entire simulation, click the "Zoom-fit" button on the top.
// TODO: picture3
Last but not least you can change the data-types of your signals. Just right-click on them, select the option "Data Format" and select the type you need.
// TODO: picture4
## VHDL References
// TODO: