Skip to content

fennecfox38/VHDLtraining

Repository files navigation

VHDL Examples

How to set up Development Environment

1. GHDL

ghdl in apt repository will no longer be updated.

Download sourcecode and build to use latest ghdl.

$ git clone https://github.com/ghdl/ghdl.git
$ sudo apt install gnat
$ cd ghdl
$ mkdir build
$ cd build
$ ../configure --prefix=/usr/local
$ make
$ sudo make install

GTKWAVE is available in apt repository.

$ sudo apt install gtkwave

How to compile and simulate

1. Manually

The following set of command lines is available for the project that consists of files design.vhd and testbench.vhd

$ ghdl -a design.vhd
$ ghdl -a testbench.vhd
$ ghdl -e TestBench
$ ghdl -r TestBench --vcd==TestBench.vcd
$ gtkwave TestBench.vcd

2. Bulid Automation by Makefile

Install 'make' from apt repository by executing sudo apt install make (included in the package 'build-essential')

Then, make the file named "Makefile" in the project directory and fill it as below.

GHDL = ghdl
WAVE = gtkwave
STD = --std=08              # to use VHDL08 (Default is VHDL93)
SRCS = $(notdir $(wildcard *.vhd))
TARGET = TestBench
STOP = --stop-time=32ns     # Set time to stop (Leave it empty if unnecessary)

$(TARGET).vcd: $(SRCS)
	$(GHDL) -a $(STD) $(SRCS)
	$(GHDL) -e $(STD) $(TARGET)
	$(GHDL) -r $(STD) $(TARGET) --vcd=$(TARGET).vcd $(STOP)

wave: $(TARGET).vcd
	$(WAVE) $(TARGET).vcd

clean:
	rm *.cf $(TARGET).vcd

Then it can be compiled and simulated by the command make and see the simulated result by the command make wave

Initialize by the command make clean if corrupted.

Other options

1. VSCode

VHDL Extension helps user to set up VHDL development environment in VSCode.

VHDL Formatter Extension makes VHDL file prettier. (formatting)

It still requires GHDL to compile and simulate .vhd file.

Simulated result (.vcd file) can be openned by WaveTrace Extension

3. ModelSim - Intel FPGA Edition