From dab947696de74c391ce8aa803cfd71cc4d1b83bc Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 6 Sep 2021 12:22:58 +0200 Subject: [PATCH 1/3] tests/acceptance: skip user_guide example if VHDL contexts not supported --- tests/acceptance/test_external_run_scripts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/acceptance/test_external_run_scripts.py b/tests/acceptance/test_external_run_scripts.py index c162fb528..36540cc97 100644 --- a/tests/acceptance/test_external_run_scripts.py +++ b/tests/acceptance/test_external_run_scripts.py @@ -168,6 +168,10 @@ def test_vhdl_array_axis_vcs_example_project(self): def test_vhdl_axi_dma_example_project(self): self.check(str(ROOT / "examples" / "vhdl" / "axi_dma" / "run.py")) + @unittest.skipIf( + simulator_check(lambda simclass: not simclass.supports_vhdl_contexts()), + "This simulator/backend does not support VHDL contexts", + ) def test_vhdl_user_guide_example_project(self): self.check(str(ROOT / "examples" / "vhdl" / "user_guide" / "run.py"), exit_code=1) check_report( From a07a861a2e84579384c11171512433f29109c6a0 Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 6 Sep 2021 11:48:35 +0200 Subject: [PATCH 2/3] examples/vhdl/user_guide: add VHDL 1993 variant --- examples/vhdl/user_guide/vhdl1993/run.py | 20 +++++++ .../vhdl/user_guide/vhdl1993/tb_example.vhd | 48 +++++++++++++++ .../user_guide/vhdl1993/tb_example_many.vhd | 59 +++++++++++++++++++ tests/acceptance/test_external_run_scripts.py | 14 +++++ 4 files changed, 141 insertions(+) create mode 100644 examples/vhdl/user_guide/vhdl1993/run.py create mode 100644 examples/vhdl/user_guide/vhdl1993/tb_example.vhd create mode 100644 examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd diff --git a/examples/vhdl/user_guide/vhdl1993/run.py b/examples/vhdl/user_guide/vhdl1993/run.py new file mode 100644 index 000000000..4ee087cae --- /dev/null +++ b/examples/vhdl/user_guide/vhdl1993/run.py @@ -0,0 +1,20 @@ +# 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-2021, Lars Asplund lars.anders.asplund@gmail.com + +""" +VHDL User Guide +--------------- + +The most minimal VUnit VHDL project covering the basics of the :ref:`User Guide `, +adapted to be used with simulators that don't support VHDL 2008. +""" + +from pathlib import Path +from vunit import VUnit + +VU = VUnit.from_argv(vhdl_standard="93") +VU.add_library("lib").add_source_files(Path(__file__).parent / "*.vhd") +VU.main() diff --git a/examples/vhdl/user_guide/vhdl1993/tb_example.vhd b/examples/vhdl/user_guide/vhdl1993/tb_example.vhd new file mode 100644 index 000000000..36be65e78 --- /dev/null +++ b/examples/vhdl/user_guide/vhdl1993/tb_example.vhd @@ -0,0 +1,48 @@ +-- 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-2021, Lars Asplund lars.anders.asplund@gmail.com + +library vunit_lib; + +use vunit_lib.types_pkg.all; +use vunit_lib.integer_vector_ptr_pkg.all; +use vunit_lib.integer_vector_ptr_pool_pkg.all; +use vunit_lib.integer_array_pkg.all; +use vunit_lib.queue_pkg.all; +use vunit_lib.queue_pool_pkg.all; +use vunit_lib.string_ptr_pkg.all; +use vunit_lib.string_ptr_pool_pkg.all; +use vunit_lib.byte_vector_ptr_pkg.all; +use vunit_lib.dict_pkg.all; + +use vunit_lib.string_ops.all; +use vunit_lib.dictionary.all; +use vunit_lib.path.all; +use vunit_lib.print_pkg.all; +use vunit_lib.log_levels_pkg.all; +use vunit_lib.logger_pkg.all; +use vunit_lib.log_handler_pkg.all; +use vunit_lib.log_deprecated_pkg.all; +use vunit_lib.ansi_pkg.all; +use vunit_lib.checker_pkg.all; +use vunit_lib.check_pkg.all; +use vunit_lib.check_deprecated_pkg.all; +use vunit_lib.run_types_pkg.all; +use vunit_lib.run_pkg.all; +use vunit_lib.run_deprecated_pkg.all; + +entity tb_example is + generic (runner_cfg : string); +end entity; + +architecture tb of tb_example is +begin + main : process + begin + test_runner_setup(runner, runner_cfg); + report "Hello world!"; + test_runner_cleanup(runner); -- Simulation ends here + end process; +end architecture; diff --git a/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd b/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd new file mode 100644 index 000000000..f93af1c14 --- /dev/null +++ b/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd @@ -0,0 +1,59 @@ +-- 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-2021, Lars Asplund lars.anders.asplund@gmail.com + +library vunit_lib; + +use vunit_lib.types_pkg.all; +use vunit_lib.integer_vector_ptr_pkg.all; +use vunit_lib.integer_vector_ptr_pool_pkg.all; +use vunit_lib.integer_array_pkg.all; +use vunit_lib.queue_pkg.all; +use vunit_lib.queue_pool_pkg.all; +use vunit_lib.string_ptr_pkg.all; +use vunit_lib.string_ptr_pool_pkg.all; +use vunit_lib.byte_vector_ptr_pkg.all; +use vunit_lib.dict_pkg.all; + +use vunit_lib.string_ops.all; +use vunit_lib.dictionary.all; +use vunit_lib.path.all; +use vunit_lib.print_pkg.all; +use vunit_lib.log_levels_pkg.all; +use vunit_lib.logger_pkg.all; +use vunit_lib.log_handler_pkg.all; +use vunit_lib.log_deprecated_pkg.all; +use vunit_lib.ansi_pkg.all; +use vunit_lib.checker_pkg.all; +use vunit_lib.check_pkg.all; +use vunit_lib.check_deprecated_pkg.all; +use vunit_lib.run_types_pkg.all; +use vunit_lib.run_pkg.all; +use vunit_lib.run_deprecated_pkg.all; + +entity tb_example_many is + generic (runner_cfg : string); +end entity; + +architecture tb of tb_example_many is +begin + main : process + begin + test_runner_setup(runner, runner_cfg); + + while test_suite loop + + if run("test_pass") then + report "This will pass"; + + elsif run("test_fail") then + assert false report "It fails"; + + end if; + end loop; + + test_runner_cleanup(runner); + end process; +end architecture; diff --git a/tests/acceptance/test_external_run_scripts.py b/tests/acceptance/test_external_run_scripts.py index 36540cc97..48ba48548 100644 --- a/tests/acceptance/test_external_run_scripts.py +++ b/tests/acceptance/test_external_run_scripts.py @@ -183,6 +183,20 @@ def test_vhdl_user_guide_example_project(self): ], ) + def test_vhdl_user_guide_93_example_project(self): + self.check( + str(ROOT / "examples" / "vhdl" / "user_guide" / "vhdl1993" / "run.py"), + exit_code=1, + ) + check_report( + self.report_file, + [ + ("passed", "lib.tb_example.all"), + ("passed", "lib.tb_example_many.test_pass"), + ("failed", "lib.tb_example_many.test_fail"), + ], + ) + @unittest.skipUnless(simulator_supports_verilog(), "Verilog") def test_verilog_user_guide_example_project(self): self.check(str(ROOT / "examples" / "verilog" / "user_guide" / "run.py"), exit_code=1) From 3f1f3e9da22c40ac1c90e2e15165755e8f4d6ccb Mon Sep 17 00:00:00 2001 From: umarcor Date: Mon, 6 Sep 2021 11:48:35 +0200 Subject: [PATCH 3/3] examples/vhdl/user_guide/vhdl1993: clean use statements --- .../vhdl/user_guide/vhdl1993/tb_example.vhd | 26 ------------------- .../user_guide/vhdl1993/tb_example_many.vhd | 26 ------------------- 2 files changed, 52 deletions(-) diff --git a/examples/vhdl/user_guide/vhdl1993/tb_example.vhd b/examples/vhdl/user_guide/vhdl1993/tb_example.vhd index 36be65e78..f83ca2179 100644 --- a/examples/vhdl/user_guide/vhdl1993/tb_example.vhd +++ b/examples/vhdl/user_guide/vhdl1993/tb_example.vhd @@ -5,33 +5,7 @@ -- Copyright (c) 2014-2021, Lars Asplund lars.anders.asplund@gmail.com library vunit_lib; - -use vunit_lib.types_pkg.all; -use vunit_lib.integer_vector_ptr_pkg.all; -use vunit_lib.integer_vector_ptr_pool_pkg.all; -use vunit_lib.integer_array_pkg.all; -use vunit_lib.queue_pkg.all; -use vunit_lib.queue_pool_pkg.all; -use vunit_lib.string_ptr_pkg.all; -use vunit_lib.string_ptr_pool_pkg.all; -use vunit_lib.byte_vector_ptr_pkg.all; -use vunit_lib.dict_pkg.all; - -use vunit_lib.string_ops.all; -use vunit_lib.dictionary.all; -use vunit_lib.path.all; -use vunit_lib.print_pkg.all; -use vunit_lib.log_levels_pkg.all; -use vunit_lib.logger_pkg.all; -use vunit_lib.log_handler_pkg.all; -use vunit_lib.log_deprecated_pkg.all; -use vunit_lib.ansi_pkg.all; -use vunit_lib.checker_pkg.all; -use vunit_lib.check_pkg.all; -use vunit_lib.check_deprecated_pkg.all; -use vunit_lib.run_types_pkg.all; use vunit_lib.run_pkg.all; -use vunit_lib.run_deprecated_pkg.all; entity tb_example is generic (runner_cfg : string); diff --git a/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd b/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd index f93af1c14..fb85a00cd 100644 --- a/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd +++ b/examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd @@ -5,33 +5,7 @@ -- Copyright (c) 2014-2021, Lars Asplund lars.anders.asplund@gmail.com library vunit_lib; - -use vunit_lib.types_pkg.all; -use vunit_lib.integer_vector_ptr_pkg.all; -use vunit_lib.integer_vector_ptr_pool_pkg.all; -use vunit_lib.integer_array_pkg.all; -use vunit_lib.queue_pkg.all; -use vunit_lib.queue_pool_pkg.all; -use vunit_lib.string_ptr_pkg.all; -use vunit_lib.string_ptr_pool_pkg.all; -use vunit_lib.byte_vector_ptr_pkg.all; -use vunit_lib.dict_pkg.all; - -use vunit_lib.string_ops.all; -use vunit_lib.dictionary.all; -use vunit_lib.path.all; -use vunit_lib.print_pkg.all; -use vunit_lib.log_levels_pkg.all; -use vunit_lib.logger_pkg.all; -use vunit_lib.log_handler_pkg.all; -use vunit_lib.log_deprecated_pkg.all; -use vunit_lib.ansi_pkg.all; -use vunit_lib.checker_pkg.all; -use vunit_lib.check_pkg.all; -use vunit_lib.check_deprecated_pkg.all; -use vunit_lib.run_types_pkg.all; use vunit_lib.run_pkg.all; -use vunit_lib.run_deprecated_pkg.all; entity tb_example_many is generic (runner_cfg : string);