Skip to content

Commit db8defc

Browse files
committed
WIP: Added compliance test.
1 parent b10dfa8 commit db8defc

27 files changed

Lines changed: 2452 additions & 72 deletions

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def find_all_files(directory, endings=None):
4949
"vunit.test.unit",
5050
"vunit.test.acceptance",
5151
"vunit.ui",
52+
"vunit.vc",
5253
"vunit.vivado",
5354
],
5455
package_data={"vunit": DATA_FILES},

vunit/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from vunit.vunit_cli import VUnitCLI
1515
from vunit.about import version, doc
1616
from vunit.json4vhdl import read_json, encode_json
17+
from vunit.vc.compliance_test import ComplianceTest
1718

1819
# Repository root
1920
ROOT = abspath(join(dirname(__file__), ".."))

vunit/project.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ def _find_other_vhdl_design_unit_dependencies( # pylint: disable=too-many-branc
208208
)
209209
continue
210210

211+
if ref.is_library_reference():
212+
continue
213+
211214
if ref.is_entity_reference() and ref.design_unit in library.modules:
212215
# Is a verilog module instantiation
213216
yield library.modules[ref.design_unit].source_file

vunit/source_file.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ def _find_design_units(self, design_file):
294294
"""
295295
result = []
296296
for entity in design_file.entities:
297-
generic_names = [generic.identifier for generic in entity.generics]
297+
generic_names = []
298+
for generic in entity.generics:
299+
for identifier in generic.identifier_list:
300+
generic_names.append(identifier)
298301
result.append(Entity(entity.identifier, self, generic_names))
299302

300303
for context in design_file.contexts:

vunit/test/acceptance/artificial/vhdl/run.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
# Copyright (c) 2014-2019, Lars Asplund lars.anders.asplund@gmail.com
66

77
from os.path import join, dirname
8-
from vunit import VUnit
8+
from vunit import VUnit, ComplianceTest
99

1010
root = dirname(__file__)
1111

1212
ui = VUnit.from_argv()
13+
ui.add_com()
14+
ui.add_verification_components()
15+
1316
lib = ui.add_library("lib")
1417
lib.add_source_files(join(root, "*.vhd"))
1518

@@ -90,4 +93,29 @@ def configure_tb_assert_stop_level(ui):
9093
lib.entity("tb_other_file_tests").scan_tests_from_file(
9194
join(root, "other_file_tests.vhd")
9295
)
96+
97+
test_lib = ui.add_library("test_lib")
98+
ComplianceTest(lib, "vc", "vc_pkg").add_vhdl_testbench(
99+
test_lib, join(root, "compliance_test")
100+
)
101+
ComplianceTest(lib, "vc_with_template", "vc_pkg_with_template").add_vhdl_testbench(
102+
test_lib,
103+
join(root, "compliance_test"),
104+
join(root, ".vc", "tb_vc_with_template_compliance_template.vhd"),
105+
)
106+
ComplianceTest(
107+
lib, "vc_not_supporting_sync", "vc_not_supporting_sync_pkg"
108+
).add_vhdl_testbench(test_lib, join(root, "compliance_test"))
109+
ComplianceTest(
110+
lib, "vc_not_supporting_custom_actor", "vc_not_supporting_custom_actor_pkg"
111+
).add_vhdl_testbench(test_lib, join(root, "compliance_test"))
112+
ComplianceTest(
113+
lib, "vc_not_supporting_custom_logger", "vc_not_supporting_custom_logger_pkg"
114+
).add_vhdl_testbench(test_lib, join(root, "compliance_test"))
115+
ComplianceTest(
116+
lib,
117+
"vc_not_supporting_unexpected_msg_handling",
118+
"vc_not_supporting_unexpected_msg_handling_pkg",
119+
).add_vhdl_testbench(test_lib, join(root, "compliance_test"))
120+
93121
ui.main()
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2019, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
library vunit_lib;
8+
context vunit_lib.vunit_context;
9+
context vunit_lib.com_context;
10+
context vunit_lib.vc_context;
11+
12+
library ieee;
13+
use ieee.std_logic_1164.all;
14+
15+
use work.vc_pkg.all;
16+
17+
entity vc is
18+
generic(
19+
vc_h : vc_handle_t
20+
);
21+
port(
22+
a : in std_logic;
23+
b : in std_logic := '1';
24+
c, d : in std_logic_vector(0 to 1);
25+
e : in std_logic_vector := X"00";
26+
f : inout std_logic;
27+
g : inout std_logic := '0';
28+
h, i : inout std_logic := '0';
29+
j : out std_logic;
30+
k, l : out std_logic;
31+
m : out std_logic := '1'
32+
);
33+
end entity;
34+
35+
architecture a of vc is
36+
begin
37+
controller : process
38+
variable msg : msg_t;
39+
variable msg_type : msg_type_t;
40+
begin
41+
receive(net, vc_h.p_actor, msg);
42+
43+
msg_type := message_type(msg);
44+
45+
handle_sync_message(net, msg_type, msg);
46+
47+
if vc_h.p_fail_on_unexpected_msg_type then
48+
unexpected_msg_type(msg_type, vc_h.p_logger);
49+
end if;
50+
end process;
51+
end architecture;
52+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2019, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
library vunit_lib;
8+
context vunit_lib.vunit_context;
9+
context vunit_lib.com_context;
10+
context vunit_lib.vc_context;
11+
12+
use work.vc_not_supporting_custom_actor_pkg.all;
13+
14+
entity vc_not_supporting_custom_actor is
15+
generic(
16+
vc_h : vc_not_supporting_custom_actor_handle_t
17+
);
18+
end entity;
19+
20+
architecture a of vc_not_supporting_custom_actor is
21+
begin
22+
controller : process
23+
variable msg : msg_t;
24+
variable msg_type : msg_type_t;
25+
begin
26+
receive(net, actor_vec_t'(vc_not_supporting_custom_actor_actor, vc_h.p_actor), msg);
27+
28+
msg_type := message_type(msg);
29+
30+
handle_sync_message(net, msg_type, msg);
31+
32+
if vc_h.p_fail_on_unexpected_msg_type then
33+
unexpected_msg_type(msg_type, vc_h.p_logger);
34+
end if;
35+
end process;
36+
end architecture;
37+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2019, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
library vunit_lib;
8+
context vunit_lib.vunit_context;
9+
context vunit_lib.com_context;
10+
context vunit_lib.vc_context;
11+
12+
package vc_not_supporting_custom_actor_pkg is
13+
type vc_not_supporting_custom_actor_handle_t is record
14+
p_actor : actor_t;
15+
p_logger : logger_t;
16+
p_checker : checker_t;
17+
p_fail_on_unexpected_msg_type : boolean;
18+
end record;
19+
20+
constant vc_not_supporting_custom_actor_logger : logger_t := get_logger("vc_not_supporting_custom_actor");
21+
constant vc_not_supporting_custom_actor_checker : checker_t := new_checker(vc_not_supporting_custom_actor_logger);
22+
constant vc_not_supporting_custom_actor_actor : actor_t := new_actor("vc_not_supporting_custom_actor_actor");
23+
24+
constant transaction_msg : msg_type_t := new_msg_type("transaction");
25+
26+
impure function new_vc_not_supporting_custom_actor(
27+
logger : logger_t := vc_not_supporting_custom_actor_logger;
28+
actor : actor_t := null_actor;
29+
checker : checker_t := null_checker;
30+
fail_on_unexpected_msg_type : boolean := true
31+
) return vc_not_supporting_custom_actor_handle_t;
32+
33+
procedure transaction(
34+
signal net : inout network_t;
35+
vc_h : vc_not_supporting_custom_actor_handle_t
36+
);
37+
38+
impure function as_sync(
39+
vc_h : vc_not_supporting_custom_actor_handle_t
40+
) return sync_handle_t;
41+
42+
end package;
43+
44+
package body vc_not_supporting_custom_actor_pkg is
45+
impure function new_vc_not_supporting_custom_actor(
46+
logger : logger_t := vc_not_supporting_custom_actor_logger;
47+
actor : actor_t := null_actor;
48+
checker : checker_t := null_checker;
49+
fail_on_unexpected_msg_type : boolean := true
50+
) return vc_not_supporting_custom_actor_handle_t is
51+
variable p_actor : actor_t;
52+
variable p_checker : checker_t;
53+
begin
54+
if actor = null_actor then
55+
p_actor := new_actor;
56+
else
57+
p_actor := actor;
58+
end if;
59+
60+
if checker = null_checker then
61+
if logger = vc_not_supporting_custom_actor_logger then
62+
p_checker := vc_not_supporting_custom_actor_checker;
63+
else
64+
p_checker := new_checker(logger);
65+
end if;
66+
else
67+
p_checker := checker;
68+
end if;
69+
70+
return (
71+
p_logger => logger,
72+
p_actor => p_actor,
73+
p_checker => p_checker,
74+
p_fail_on_unexpected_msg_type => fail_on_unexpected_msg_type
75+
);
76+
end;
77+
78+
procedure transaction(
79+
signal net : inout network_t;
80+
vc_h : vc_not_supporting_custom_actor_handle_t
81+
) is
82+
variable msg : msg_t;
83+
begin
84+
msg := new_msg(transaction_msg);
85+
send(net, vc_not_supporting_custom_actor_actor, msg);
86+
end procedure;
87+
88+
impure function as_sync(
89+
vc_h : vc_not_supporting_custom_actor_handle_t
90+
) return sync_handle_t is
91+
begin
92+
return vc_not_supporting_custom_actor_actor;
93+
end;
94+
95+
end package body;
96+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2019, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
library vunit_lib;
8+
context vunit_lib.vunit_context;
9+
context vunit_lib.com_context;
10+
context vunit_lib.vc_context;
11+
12+
use work.vc_not_supporting_custom_logger_pkg.all;
13+
14+
entity vc_not_supporting_custom_logger is
15+
generic(
16+
vc_h : vc_not_supporting_custom_logger_handle_t
17+
);
18+
end entity;
19+
20+
architecture a of vc_not_supporting_custom_logger is
21+
begin
22+
controller : process
23+
variable msg : msg_t;
24+
variable msg_type : msg_type_t;
25+
begin
26+
receive(net, vc_h.p_actor, msg);
27+
28+
msg_type := message_type(msg);
29+
30+
handle_sync_message(net, msg_type, msg);
31+
32+
if vc_h.p_fail_on_unexpected_msg_type then
33+
unexpected_msg_type(msg_type, vc_h.p_logger);
34+
end if;
35+
end process;
36+
end architecture;
37+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2019, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
library vunit_lib;
8+
context vunit_lib.vunit_context;
9+
context vunit_lib.com_context;
10+
context vunit_lib.vc_context;
11+
12+
package vc_not_supporting_custom_logger_pkg is
13+
type vc_not_supporting_custom_logger_handle_t is record
14+
p_actor : actor_t;
15+
p_logger : logger_t;
16+
p_checker : checker_t;
17+
p_fail_on_unexpected_msg_type : boolean;
18+
end record;
19+
20+
constant vc_not_supporting_custom_logger_logger : logger_t := get_logger("vc_not_supporting_custom_logger");
21+
constant vc_not_supporting_custom_logger_checker : checker_t := new_checker(vc_not_supporting_custom_logger_logger);
22+
23+
impure function new_vc_not_supporting_custom_logger(
24+
logger : logger_t := vc_not_supporting_custom_logger_logger;
25+
actor : actor_t := null_actor;
26+
checker : checker_t := null_checker;
27+
fail_on_unexpected_msg_type : boolean := true
28+
) return vc_not_supporting_custom_logger_handle_t;
29+
30+
impure function as_sync(
31+
vc_h : vc_not_supporting_custom_logger_handle_t
32+
) return sync_handle_t;
33+
34+
end package;
35+
36+
package body vc_not_supporting_custom_logger_pkg is
37+
impure function new_vc_not_supporting_custom_logger(
38+
logger : logger_t := vc_not_supporting_custom_logger_logger;
39+
actor : actor_t := null_actor;
40+
checker : checker_t := null_checker;
41+
fail_on_unexpected_msg_type : boolean := true
42+
) return vc_not_supporting_custom_logger_handle_t is
43+
variable p_actor : actor_t;
44+
variable p_checker : checker_t;
45+
begin
46+
if actor = null_actor then
47+
p_actor := new_actor;
48+
else
49+
p_actor := actor;
50+
end if;
51+
52+
if checker = null_checker then
53+
if logger = vc_not_supporting_custom_logger_logger then
54+
p_checker := vc_not_supporting_custom_logger_checker;
55+
else
56+
p_checker := new_checker(logger);
57+
end if;
58+
else
59+
p_checker := checker;
60+
end if;
61+
62+
return (
63+
p_logger => vc_not_supporting_custom_logger_logger,
64+
p_actor => p_actor,
65+
p_checker => p_checker,
66+
p_fail_on_unexpected_msg_type => fail_on_unexpected_msg_type
67+
);
68+
end;
69+
70+
impure function as_sync(
71+
vc_h : vc_not_supporting_custom_logger_handle_t
72+
) return sync_handle_t is
73+
begin
74+
return vc_h.p_actor;
75+
end;
76+
77+
end package body;
78+

0 commit comments

Comments
 (0)