[stextbox id=”grey”]
$ make build
make -j -C obj_dir -f Vhalfadder.mk Vhalfadder
make[1]: Entering directory `/home/guest/halfadder/obj_dir’
g++ -I. -MMD -I/usr/share/verilator/include \
-I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf \
-DVM_TRACE=1 -DVM_COVERAGE=0 \
-c -o main.o ../main.cpp
g++ -I. -MMD -I/usr/share/verilator/include \
-I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf \
-DVM_TRACE=1 -DVM_COVERAGE=0 \
-c -o verilated.o /usr/share/verilator/include/
verilated.cpp
g++ -I. -MMD -I/usr/share/verilator/include \
-I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf \
-DVM_TRACE=1 -DVM_COVERAGE=0 -c -o verilated_vcd_c.o \
/usr/share/verilator/include/verilated_vcd_c.cpp
/usr/bin/perl /usr/share/verilator/bin/verilator_includer \
Vhalfadder.cpp > Vhalfadder__ALLcls.cpp
/usr/bin/perl /usr/share/verilator/bin/verilator_includer \
Vhalfadder__Trace.cpp Vhalfadder__Syms.cpp \
Vhalfadder__Trace__Slow.cpp > Vhalfadder__ALLsup.cpp
g++ -I. -MMD -I/usr/share/verilator/include \
-I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf \
-DVM_TRACE=1 -DVM_COVERAGE=0 \
-c -o Vhalfadder__ALLcls.o Vhalfadder__ALLcls.cpp
g++ -I. -MMD -I/usr/share/verilator/include \
-I/usr/share/verilator/include/vltstd -DVL_PRINTF=printf \
-DVM_TRACE=1 -DVM_COVERAGE=0 \
-c -o Vhalfadder__ALLsup.o Vhalfadder__ALLsup.cpp
Archiving Vhalfadder__ALL.a …
ar r Vhalfadder__ALL.a Vhalfadder__ALLcls.o Vhalfadder__
ALLsup.o
ar: creating Vhalfadder__ALL.a
ranlib Vhalfadder__ALL.a
g++ main.o verilated.o verilated_vcd_c.o Vhalfadder__ALL.a \
-o Vhalfadder -lm -lstdc++ 2>&1 | c++filt
make[1]: Leaving directory `/home/guest/halfadder/obj_dir’
You can test the code with the following:
$ make test
./obj_dir/Vhalfadder
[/stextbox]
This produces counter.vcd file, which can be viewed in GTKWave. A screenshot of the waveform is shown in Fig. 1.
Download source code: click here
Install GTKwave before viewing the waveform.
You may also refer to Verilator manual at www.veripool.org/projects/verilator/wiki/Manual-verilator for more options and examples.
Shakthi Kannan is MS in information technology from Rochester Institute of Technology, Rochester, New York, the USA. Currently, he is working as senior engineer (R&D) at Manufacturing System Insights, Chennai. He is a software enthusiast who blogs at shakthimaan.com