Set up ghdl on Ubuntu 13.04

For a study-lesson I need vhdl. Therefore I don’t want to use wine and modelsim. I like to use console and simple commands. [TOC]


First of all I needed to add a new apt-repository and install all required packages:

sudo add-apt-repository ppa:pgavin/ghdl
    sudo apt-get update
    sudo apt-get install ghdl gtkwave

ghdl contains compiler settings and is based on gcc. gtkwave is needed to display a graphical overview about testbenches. You will see an example later.


I start with a clean project tree. My setup for a project tree is:

        |- src       # all source files (.vhd, .ucf, .xcf)
        |- testbench # source files to test my design
        |- ise       # directory for xilinx web pack if needed
        |- simu      # all files generated by the simulator

Now you can edit/create a new vhdl file. If you use my project tree, you can use the following command to analyse your files:

ghdl -i --ieee=synopsys --warn-no-vital-generic --workdir=simu --work=work src/*.vhdl testbench/testb_file.vhd

To compile, use the following command:

ghdl -m --ieee=synopsys --warn-no-vital-generic --workdir=simu --work=work testb_file

After that a binary file called testb_file is created. You can launch the simulation by insert following call to command line:

./testb_file --stop-time=500ns --vcdgz=testb_file.vcd

Visualizing the result can be done with gtkwave:

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
    # vhdl files
    FILES = src/file1.vhd src/file2.vhd
    # testbench
    SIMTOP = led_top_tb
    SIMFILES = testbench/files_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-compile :
     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

     gunzip --stdout $(SIMDIR)/$(SIMTOP).vcdgz | $(VIEW_CMD) --vcd

     $(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.


You can find all settings/configurations above armadeus and lelongdunet.

comments powered by Disqus