是否可以让 VUNIT 运行 成为基于顶级泛型的测试套件?

Is it possible to have VUNIT run a test suite based on top level generics?

我是 Vunit 的新手 - 但不是测试人员。我目前有一个设置,其中我有使用大量 OSVVM 的测试台,其中设置是通过泛型提供给测试台的,我使用 TCL 或 Pytest 运行 通过完整的测试套件进行测试。

在开始正确地研究 Vunit 之后,我发现它可能会做我想做的事情,或者至少允许我将一些用于某些测试的测试服移到 VHDL 中,但我找不到的是例如,部分测试用例差异涉及使用不同总线宽度或 sync/async 时钟进行测试的示例。

有没有办法通过 Vunit 做到这一点?如果有,有没有我可以看的例子?或者您只是希望在同一个 Vunit 测试台中实例化它们并按顺序 运行 它们?

我的基础设施很重 OSVVM,所以我不打算改变其中任何一个 - 但我正在寻找一个 运行ner 来回归 GitLab 中的测试用例。 TCL 没有削减它(主要是因为 ActiveHDL 有一个错误,它不能在 TCL 中正确捕获 运行时间异常)。

VUnit 有一个配置概念(不要与 VHDL 配置混淆),它允许您执行此操作等。你可以阅读它 here

你也可以看看下面的example.

我不确定 OSVVM heavy 是否也意味着对不同的测试使用不同的 VHDL 配置?如果是这样,您应该阅读 this

根据评论更新

假设我们有一个具有两个泛型的 UUT,一个可以是 32/64/128 位的 width 和一个布尔值 use_fifo。这是该 UUT

的虚拟(但可执行)表示
entity uut is
  generic (
    width : positive;
    use_fifo : boolean);
end entity;

architecture a of uut is
begin
  do_stuff: process
  begin
    report "Width = " & to_string(width) & ", use_fifo = " & to_string(use_fifo);
    wait;
  end process;
end architecture;

假设我们有一个测试平台,并希望 运行 使用泛型的所有组合。为此,我们将 UUT 泛型作为泛型公开给 VUnit 测试平台

library vunit_lib;
context vunit_lib.vunit_context;

entity tb_uut is
  generic (
    runner_cfg : string;
    width : positive;
    use_fifo : boolean);
end entity;

architecture tb of tb_uut is
begin
  main : process
  begin
    test_runner_setup(runner, runner_cfg);

    -- Do some testing

    test_runner_cleanup(runner);
  end process;

  uut_inst: entity work.uut
    generic map (
      width => width,
      use_fifo => use_fifo);
end architecture;

现在我们可以为代表所有通用组合的测试平台创建 VUnit 配置。这是在 运行 脚本中完成的。

from pathlib import Path
from itertools import product
from vunit import VUnit


prj = VUnit.from_argv()
root = Path(__file__).parent
lib = prj.add_library("lib")
lib.add_source_files(root / "*.vhd")

tb_uut = lib.test_bench("tb_uut")
for width, use_fifo in product([32, 64, 128], [False, True]):
    tb_uut.add_config(
        name=f"width={width}.use_fifo={use_fifo}",
        generics=dict(width=width, use_fifo=use_fifo),
    )

prj.main()

如果我们列出测试,我们将看到所有六种组合:

$ python run.py --list
lib.tb_uut.width=32.use_fifo=False
lib.tb_uut.width=32.use_fifo=True
lib.tb_uut.width=64.use_fifo=False
lib.tb_uut.width=64.use_fifo=True
lib.tb_uut.width=128.use_fifo=False
lib.tb_uut.width=128.use_fifo=True
Listed 6 tests