Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/vhdl/user_guide: add VHDL 1993 variant #737

Merged
merged 3 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/vhdl/user_guide/vhdl1993/run.py
Original file line number Diff line number Diff line change
@@ -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 <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()
22 changes: 22 additions & 0 deletions examples/vhdl/user_guide/vhdl1993/tb_example.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- 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.run_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;
33 changes: 33 additions & 0 deletions examples/vhdl/user_guide/vhdl1993/tb_example_many.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- 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.run_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;
18 changes: 18 additions & 0 deletions tests/acceptance/test_external_run_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -179,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)
Expand Down