Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vhdl GHDL&x2B;使用gcov的代码覆盖率(Ubuntu 16.04 LTS)_Vhdl_Code Coverage_Gcov_Ghdl - Fatal编程技术网

Vhdl GHDL&x2B;使用gcov的代码覆盖率(Ubuntu 16.04 LTS)

Vhdl GHDL&x2B;使用gcov的代码覆盖率(Ubuntu 16.04 LTS),vhdl,code-coverage,gcov,ghdl,Vhdl,Code Coverage,Gcov,Ghdl,这(2005年来自Arnim Läuger)解释了工具链{GHDL+gcov}可以执行VHDL代码覆盖 问题:GCC、GCOV和GHDL的最新版本今天仍在使用吗? 以下命令失败 $ ghdl -a -Wc,-ftest-coverage -Wc,-fprofile-arcs tb_example.vhd ghdl: unknown option '-Wc,-ftest-coverage' for command '-a' 我的设置如下: $ gcc -v Using built-in spe

这(2005年来自Arnim Läuger)解释了工具链{GHDL+gcov}可以执行VHDL代码覆盖

问题:GCC、GCOV和GHDL的最新版本今天仍在使用吗?

以下命令失败

$ ghdl -a -Wc,-ftest-coverage -Wc,-fprofile-arcs tb_example.vhd 
ghdl: unknown option '-Wc,-ftest-coverage' for command '-a'
我的设置如下:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gnat/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.9.4/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure --enable-languages=ada,c,c++ --enable-dual-exceptions --enable-_cxa_atexit --enable-threads=posix --with-bugurl=URL:mailto:report@adacore.com --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch --disable-libada --enable-checking=release --disable-multilib --with-mpfr=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/mpfr_stable/install --with-gmp=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/gmp_stable/install --with-mpc=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/mpc_stable/install --with-build-time-tools=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/gcc/build/buildtools/bin --prefix=/boron.a/gnatmail/sandbox/gpl-2016/x86_64-linux/gcc/pkg --build=x86_64-pc-linux-gnu
Thread model: posix
gcc version 4.9.4 20160426 (for GNAT GPL 2016 20160515) (GCC) 

$ gcov -v
gcov (GCC) 4.9.4 20160426 (for GNAT GPL 2016 20160515)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.

$ ghdl -v
GHDL 0.34dev (20151126) [Dunoon edition]
Compiled with GNAT Version: GPL 2016 (20160515-49)
mcode code generator
Written by Tristan Gingold.

Copyright (C) 2003 - 2015 Tristan Gingold.
GHDL is free software, covered by the GNU General Public License.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat /proc/version
Linux version 4.4.0-34-generic (buildd@lgw01-20) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #53-Ubuntu SMP Wed Jul 27 16:06:39 UTC 2016
我使用Building with mcode后端程序安装了GHDL。这可能是邪恶的根源吗


谢谢你的帮助

是的,当前ghdl确实支持代码覆盖率

确保您有最新的ghdl版本,但请注意,尽管ghdl支持3个代码生成后端(LLVM、gcc及其自己的JIT编译器mcode),但当前只有gcc后端支持代码覆盖(通过gcov)。具体来说,您构建的mcode版本将无法工作

应该有适合Ubuntu的软件包——如果我没有从Debian Jessie的源代码构建说明的话,它也应该为Ubuntu服务。(如果需要,我会把它们挖出来)

检查

现在需要提供一些编译时标志

ghdl -a --std=08 -g -fprofile-arcs -ftest-coverage myfile.vhd
ghdl -a --std=08 -g -fprofile-arcs -ftest-coverage my_TB.vhd
对于细化(
-Wl,
在链接器选项之前)

您应该有一组
.gcno、.gcda
文件要用
gcov
进行后处理(或者
lcov
genhtml
,用于更漂亮的报告)

还可以在Vunit和OSVVM库下使用

分支覆盖率不太好,部分原因是VHDL的信号分配语义转换为生成的可执行文件中的许多虚假分支

在VUnit下,我不使用他们的“代码覆盖率”实验选项。 相反,我设置了相关的标志,运行vu.main()函数,捕捉其返回,并作为后处理步骤调用lcov。run.py脚本示例不完整,如下所示:

lib.add_compile_option("ghdl.flags", ["-fprofile-arcs"])
vu.set_sim_option("ghdl.flags", ["-Wl,-lgcov"])
try:
    vu.main()
except SystemExit as exc:
    all_ok = exc.code == 0

if all_ok:
    subprocess.call(["lcov", "--capture", "--directory", ".", "--output-file",  "code_coverage.info"])
    subprocess.call(["genhtml", "code_coverage.info", "--output-directory", "code_html"])

谢谢你详细的回答。非常有用。我会尝试,然后我会在这里给出反馈。我用GCC作为后端重建了它,现在它工作得很好。非常感谢。最重要的是VUnit直接将覆盖率结果包含在它生成的xml中。是否可以轻松地在VUnit xml中包含覆盖率?(目前,我有VUnit运行生成的.gcda+.gcno,但最后我必须自己运行gcov,结果不在xml中)VUnit对覆盖率的实验支持仅适用于ModelSim,尽管已经开始支持其他模拟器。@lasplund:Yes,这就是上面概述的代码覆盖率方法不使用VUnit支持的原因。当它扩展到包含GHDL时,请随意添加更新的答案。@BrianDrummond我只是想强调一下,因为以前对这种支持一直存在混淆。还应该澄清“实验性”意味着主要开发人员没有覆盖许可证,不能自己测试功能。没有打开的bug报告,因此假定它正在工作。
ghdl -e --std=08 -Wl,-lgcov -Wl,--coverage my_tb
./my_tb
lib.add_compile_option("ghdl.flags", ["-fprofile-arcs"])
vu.set_sim_option("ghdl.flags", ["-Wl,-lgcov"])
try:
    vu.main()
except SystemExit as exc:
    all_ok = exc.code == 0

if all_ok:
    subprocess.call(["lcov", "--capture", "--directory", ".", "--output-file",  "code_coverage.info"])
    subprocess.call(["genhtml", "code_coverage.info", "--output-directory", "code_html"])