Coverage for hdl_registers/test/functional/simulation/test_generated_vhdl_package.py: 100%
21 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-29 22:03 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-29 22:03 +0000
1# --------------------------------------------------------------------------------------------------
2# Copyright (c) Lukas Vik. All rights reserved.
3#
4# This file is part of the hdl_registers project, a HDL register generator fast enough to be run
5# in real time.
6# https://hdl-registers.com
7# https://gitlab.com/hdl_registers/hdl_registers
8# --------------------------------------------------------------------------------------------------
10# Standard libraries
11from pathlib import Path
13# Third party libraries
14from tsfpga.examples.example_env import get_hdl_modules
15from vunit import VUnit
17# First party libraries
18from hdl_registers import HDL_REGISTERS_DOC
19from hdl_registers.parser import from_toml
21THIS_FOLDER = Path(__file__).parent.resolve()
24def test_running_simulation(tmp_path):
25 """
26 Run the testbench .vhd file that is next to this file. Contains assertions on the
27 VHDL package generated from the example TOML file. Shows that the file can be compiled and
28 that (some of) the information is correct.
29 """
30 register_list = from_toml(
31 module_name="example",
32 toml_file=HDL_REGISTERS_DOC / "sphinx" / "files" / "regs_example.toml",
33 )
34 register_list.create_vhdl_package(output_path=tmp_path)
36 vunit_proj = VUnit.from_argv(
37 argv=["--minimal", "--num-threads", "4", "--output-path", str(tmp_path)]
38 )
40 library = vunit_proj.add_library(library_name="example")
41 library.add_source_file(THIS_FOLDER / "tb_generated_vhdl_package.vhd")
42 library.add_source_file(tmp_path / "example_regs_pkg.vhd")
44 for module in get_hdl_modules():
45 vunit_library = vunit_proj.add_library(library_name=module.library_name)
46 for hdl_file in module.get_simulation_files(include_tests=False):
47 vunit_library.add_source_file(hdl_file.path)
49 try:
50 vunit_proj.main()
51 except SystemExit as exception:
52 assert exception.code == 0