Skip to content

huettern/ghdl-coverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ghdl-coverage

This repository aims to use ghdl to simulate VHDL code and report code coverage.

Code Coverage Metrics:

  • Statement Coverage -> "Lines"
  • Branch Coverage -> "Branches"
  • Condition Coverage
  • Expression Coverage
  • Toggle Coverage
  • Finite State Machine (FSM) Coverage
  • Toggle Coverage

Setup

Requirements

apt install gnat build-essential libmpc-dev flex bison libz-dev lcov

Download and install ghdl and gcc

# Download ghdl
wget https://github.com/ghdl/ghdl/archive/v0.35.tar.gz
tar -xvzf v0.35.tar.gz
cd ghdl-0.35/
mkdir build
cd build
# Download gcc 7.2 sources
wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-7.2.0/gcc-7.2.0.tar.gz
tar -xvf gcc-7.2.0.tar.gz
# Configure and build first gcc then ghdl
../configure --with-gcc=gcc-7.2.0  --prefix=/usr/local
make copy-sources
mkdir gcc-objs; cd gcc-objs
../gcc-7.2.0/configure --prefix=/usr/local --enable-languages=c,vhdl \
 --disable-bootstrap --disable-lto --disable-multilib --disable-libssp \
 --disable-libgomp --disable-libquadmath
make -j4 && make install MAKEINFO=true
make ghdllib
make install

Usage

Change the PROJECT variable in Makefile to the project you want to run and then run

make

Output is stored in the build directory.

Projects

Name Description Coverage Report
adder A simple full adder adder
fifo_8i_32o 8 to 32 bit FiFo fifo_8i_32o

Manual

Full adder example from here using code from here

cd projects/full_adder
ghdl -a -Wc,-fprofile-arcs -Wc,-ftest-coverage adder.vhd
ghdl -a adder_tb.vhd
ghdl -e -Wl,-lgcov adder_tb
ghdl -r adder_tb
# Generate code coverage report using gcov
gcov -s $PWD adder.vhd
# Generate code coverage report using lcov
lcov -c -d . -o adder_tb.info
genhtml -o html adder_tb.info

About

ghdl code coverage tutorial and scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published