Skip to content
Snippets Groups Projects
README.md 5.92 KiB
Newer Older
maxim's avatar
maxim committed
# GTI VHDL Crash-Course
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
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.
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
* [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)
* [VHDL-References](#vhdl-references)
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
## Getting Started
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
**If you work directly on a CIP \[RECOMMENDED\], you can skip this section** 
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
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.
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
### GHDL

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.

#### 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.
Maxim Balajan's avatar
Maxim Balajan committed

## Usage

maxim's avatar
maxim committed
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 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.
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
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.
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
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.
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
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
```
$ make templates
```
if you want to run the simulations and get the waveform diagrams for the your own solutions (have to be located in the *template*-folder).
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
### Usage: GTKWave
Maxim Balajan's avatar
Maxim Balajan committed

maxim's avatar
maxim committed
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.