How to make a VHDL design in Ubuntu/Debian
Simulation
To stay in the Free Software spirit, the best method to simulate is to use GHDL (based on GCC).
To install it on Ubuntu you just have to type :
$ sudo apt-get install ghdl
You can find a good tutorial for using GHDL here and on the official website. It's supposed that the project tree used is this one described previously.
Analysing files:
$ ghdl -i --ieee=synopsys --warn-no-vital-generic --workdir=simu --work=work src/*.vhdl testbench/testb_file.vhd
And compile:
$ ghdl -m --ieee=synopsys --warn-no-vital-generic --workdir=simu --work=work testb_file
After that a binary file named testb_file is created; to launch simulation we just have to:
$ ./testb_file --stop-time=500ns --vcdgz=testb_file.vcdgz
The stop time option sets the simulation time and the vcdgz option will generate a gunzip compressed wave file to visualize the result.
Visualizing the result can be done with gtkwave:
$ sudo apt-get install gtkwave
We can launch it with the following command :
$ gunzip --stdout testb_file.vcdgz | gtkwave --vcd
It can be a good idea to make a Makefile instead of typing all this commands, here is a little Makefile:
# project name PROJECT=bus_led_top # vhdl files FILES = src/bus_led.vhd src/bus_led_top.vhd # testbench SIMTOP = led_top_tb SIMFILES = testbench/led_top_tb.vhd # Simu break condition GHDL_SIM_OPT = --assert-level=error #GHDL_SIM_OPT = --stop-time=500ns SIMDIR = simu SYNTHFILES = bin/bus_led_ise/netgen/synthesis GHDL_CMD = ghdl GHDL_FLAGS = --ieee=synopsys --warn-no-vital-generic VIEW_CMD = /usr/bin/gtkwave ghdl-compil : mkdir -p simu $(GHDL_CMD) -i $(GHDL_FLAGS) --workdir=simu --work=work $(SIMFILES) $(FILES) $(GHDL_CMD) -m $(GHDL_FLAGS) --workdir=simu --work=work $(SIMTOP) @mv $(SIMTOP) simu/$(SIMTOP) ghdl-run : @$(SIMDIR)/$(SIMTOP) $(GHDL_SIM_OPT) --vcdgz=$(SIMDIR)/$(SIMTOP).vcdgz ghdl-view: gunzip --stdout $(SIMDIR)/$(SIMTOP).vcdgz | $(VIEW_CMD) --vcd ghdl-clean : $(GHDL_CMD) --clean --workdir=simu
to use it, just write :
$ make ghdl-compile
to compile, then:
$ make ghdl-run
to run the design, then:
$ make ghdl-view
to launch gtkwave and visualize the results.