Skip to content

Commit 13fa6f8

Browse files
committed
Created
0 parents  commit 13fa6f8

File tree

13 files changed

+970
-0
lines changed

13 files changed

+970
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Compiled Object files
2+
*.slo
3+
*.lo
4+
*.o
5+
*.obj
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Compiled Dynamic libraries
12+
*.so
13+
*.dylib
14+
*.dll
15+
16+
# Fortran module files
17+
*.mod
18+
19+
# Compiled Static libraries
20+
*.lai
21+
*.la
22+
*.a
23+
*.lib
24+
25+
# Verilator/simulator temporaries
26+
*.dmp
27+
*.log
28+
*.csrc
29+
*.vcd
30+
obj_*
31+
logs
32+
33+
# Executables
34+
*.exe
35+
*.out
36+
*.app
37+
*.gcda
38+
*.gcov
39+
*.gcno
40+
*qmake_gcov
41+
*.pro.user

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: cpp
2+
dist: focal
3+
os: linux
4+
compiler: gcc
5+
#cache: ccache
6+
7+
services:
8+
- docker
9+
10+
# This uses the latest version of Verilator, you may prefer :stable
11+
# We run make from inside the container, overriding default entry point (Verilator binary itself)
12+
# You may prefer to build install Verilator from git locally (slower but avoids docker)
13+
script:
14+
- docker run -ti -v ${PWD}:/work --user $(id -u):$(id -g) -e CCACHE_DIR=/work/.ccache --entrypoint make verilator/verilator:latest
15+
16+
after_success:
17+
- bash <(curl -s https://codecov.io/bash)

Codecov.png

1.24 KB
Loading

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
######################################################################
2+
#
3+
# DESCRIPTION: Make Verilator model and run coverage
4+
#
5+
# This calls the object directory makefile. That allows the objects to
6+
# be placed in the "current directory" which simplifies the Makefile.
7+
#
8+
# This file is placed under the Creative Commons Public Domain, for
9+
# any use, without warranty, 2020 by Wilson Snyder.
10+
# SPDX-License-Identifier: CC0-1.0
11+
#
12+
######################################################################
13+
14+
ifneq ($(words $(CURDIR)),1)
15+
$(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)')
16+
endif
17+
18+
# This example started with the Verilator example files.
19+
# Please see those examples for commented sources, here:
20+
# https://github.com/verilator/verilator/tree/master/examples
21+
22+
######################################################################
23+
# Set up variables
24+
25+
# If $VERILATOR_ROOT isn't in the environment, we assume it is part of a
26+
# package install, and verilator is in your path. Otherwise find the
27+
# binary relative to $VERILATOR_ROOT (such as when inside the git sources).
28+
ifeq ($(VERILATOR_ROOT),)
29+
VERILATOR = verilator
30+
VERILATOR_COVERAGE = verilator_coverage
31+
else
32+
export VERILATOR_ROOT
33+
VERILATOR = $(VERILATOR_ROOT)/bin/verilator
34+
VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage
35+
endif
36+
37+
VERILATOR_FLAGS =
38+
# Generate C++ in executable form
39+
VERILATOR_FLAGS += -cc --exe
40+
# Generate makefile dependencies (not shown as complicates the Makefile)
41+
#VERILATOR_FLAGS += -MMD
42+
# Optimize
43+
VERILATOR_FLAGS += -Os -x-assign 0
44+
# Warn abount lint issues; may not want this on less solid designs
45+
VERILATOR_FLAGS += -Wall
46+
# Make waveforms
47+
#VERILATOR_FLAGS += --trace
48+
# Check SystemVerilog assertions
49+
VERILATOR_FLAGS += --assert
50+
# Generate coverage analysis
51+
VERILATOR_FLAGS += --coverage
52+
# Run make to compile model, with as many CPUs as are free
53+
VERILATOR_FLAGS += --build -j
54+
# Run Verilator in debug mode
55+
#VERILATOR_FLAGS += --debug
56+
# Add this trace to get a backtrace in gdb
57+
#VERILATOR_FLAGS += --gdbbt
58+
59+
# Input files for Verilator
60+
VERILATOR_INPUT = -f input.vc top.v sim_main.cpp
61+
62+
######################################################################
63+
64+
# Create annotated source
65+
VERILATOR_COV_FLAGS += --annotate logs/annotated
66+
# A single coverage hit is considered good enough
67+
VERILATOR_COV_FLAGS += --annotate-min 1
68+
# Create LCOV info
69+
VERILATOR_COV_FLAGS += --write-info logs/coverage.info
70+
# Input file from Verilator
71+
VERILATOR_COV_FLAGS += logs/coverage.dat
72+
73+
######################################################################
74+
default: run
75+
76+
run:
77+
@echo
78+
@echo "-- Verilator coverage example"
79+
80+
@echo
81+
@echo "-- VERILATE ----------------"
82+
$(VERILATOR) $(VERILATOR_FLAGS) $(VERILATOR_INPUT)
83+
84+
@echo
85+
@echo "-- RUN ---------------------"
86+
@rm -rf logs
87+
@mkdir -p logs
88+
obj_dir/Vtop
89+
90+
@echo
91+
@echo "-- COVERAGE ----------------"
92+
@rm -rf logs/annotated
93+
$(VERILATOR_COVERAGE) $(VERILATOR_COV_FLAGS)
94+
95+
@echo
96+
@echo "-- DONE --------------------"
97+
98+
99+
######################################################################
100+
# Other targets
101+
102+
show-config:
103+
$(VERILATOR) -V
104+
105+
maintainer-copy::
106+
clean mostlyclean distclean maintainer-clean::
107+
-rm -rf obj_dir logs *.log *.dmp *.vpd core

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# travis_verilator_gcov
2+
3+
[![Travis CI logo](TravisCI.png)](https://travis-ci.org)
4+
![Whitespace](Whitespace.png)
5+
[![Codecov logo](Codecov.png)](https://www.codecov.io)
6+
![Whitespace](Whitespace.png)
7+
[![Verilator logo](verilator_56x48-min.png)](https://verilator.org)
8+
9+
[![Build Status](https://travis-ci.org/verilator/example-systemverilog.svg?branch=master)](https://travis-ci.org/verilator/example-systemverilog)
10+
[![codecov.io](https://codecov.io/github/verilator/example-systemverilog/coverage.svg?branch=master)](https://codecov.io/github/verilator/example-systemverilog?branch=master)
11+
12+
This GitHub is part of [the SystemVerilog Verilator Codecov Tutorial](https://github.com/verilator/example-systemverilog).
13+
14+
The goal of this project is to demonstrate a SystemVerilog project with:
15+
* Verilator
16+
* C++ compiler: `g++`
17+
* Travis-CI running Docker
18+
* Code coverage with `verilator_coverage` (note: it should show the code coverage is below 100%)
19+
* Code coverage published in CodeCov.
20+
21+
We are happy to help if you have any questions. Please contact email our Support at [[email protected]](mailto:[email protected])

TravisCI.png

5.29 KB
Loading

Whitespace.png

129 Bytes
Loading

build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
qmake travis_qmake_gcc_cpp11_gcov.pro
3+
make

input.vc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// This file typically lists flags required by a large project, e.g. include directories
2+
+libext+.v+.sv+.vh+.svh -y .

0 commit comments

Comments
 (0)