Beispiel #1
0
 def run(
     tests: Sequence["Test"],
     dependencies: Sequence[Union[str, Tuple[str, Mapping[str, str]]]] = [],
     include_dirs: Sequence[str] = [],
     external_libraries: Mapping[str, str] = {},
 ) -> None:
     s = set()
     for t in tests:
         msg = "模块 {} 已有测试 {}".format(t.__moduleName, t.__testName)
         assert (t.__moduleName, t.__testName) not in s, msg
         s.add((t.__moduleName, t.__testName))
     vu = VUnit.from_argv()
     for name, path in external_libraries.items():
         vu.add_external_library(name, path)
     dep = vu.add_library("dep")
     for d in dependencies:
         if isinstance(d, str):
             dep.add_source_file(d,
                                 include_dirs=include_dirs,
                                 no_parse=True)
         else:
             dep.add_source_file(d[0],
                                 include_dirs=include_dirs,
                                 no_parse=True,
                                 defines=d[1])
     lib = vu.add_library("lib")
     for t in tests:
         t.__gen()
         t.__write()
         t.__dump()
         lib.add_source_file(t.__prefix(False) + ".sv",
                             include_dirs=include_dirs)
     for t in tests:
         lib.test_bench("tb_" + t.__moduleName + "_" +
                        t.__testName).set_post_check(t.__check)
     vu.main()
Beispiel #2
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2014-2019, Lars Asplund [email protected]

from os.path import join, dirname
from vunit.verilog import VUnit

root = dirname(__file__)

ui = VUnit.from_argv()
lib = ui.add_library("lib")
lib.add_source_files(join(root, "*.sv"), defines={"DEFINE_FROM_RUN_PY": ""})


def configure_tb_with_parameter_config(ui):
    """
    Configure tb_with_parameter_config test bench
    """
    bench = lib.module("tb_with_parameter_config")
    tests = [bench.test("Test %i" % i) for i in range(5)]

    bench.set_parameter("set_parameter", "set-for-module")

    tests[1].add_config('cfg',
                        parameters=dict(config_parameter="set-from-config"))

    tests[2].set_parameter("set_parameter", "set-for-test")

    tests[3].add_config('cfg',
Beispiel #3
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2014-2015, Lars Asplund [email protected]

from os.path import join, dirname
from vunit.verilog import VUnit

root = dirname(__file__)

ui = VUnit.from_argv()
lib = ui.add_library("lib")
lib.add_source_files(join(root, "*.sv"))
ui.main()