Skip to content

Commit

Permalink
test_virtual: Create test case for desired resolution
Browse files Browse the repository at this point in the history
Extend test_virtual() cases to show desired dependency resolution when
one core depends on a virtual VLNV and another core has an explicit
dependency on an implementing core for that virtual VLNV. The solver
should choose that one implementing core and no other.

Signed-off-by: Alexander Williams <awill@opentitan.org>
  • Loading branch information
a-will committed Jan 22, 2024
1 parent 9f98760 commit f31e1ca
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
21 changes: 21 additions & 0 deletions tests/capi2_cores/virtual/top_impl1.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CAPI=2:
# Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

name: ::top_impl1:0
filesets:
rtl:
depend:
- ::user:0
- ::impl1:0
files:
- top_impl1.sv
file_type: systemVerilogSource


targets:
default:
filesets:
- rtl
toplevel: top_impl1
21 changes: 21 additions & 0 deletions tests/capi2_cores/virtual/top_impl2.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CAPI=2:
# Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause

name: ::top_impl2:0
filesets:
rtl:
depend:
- ::user:0
- ::impl2:0
files:
- top_impl2.sv
file_type: systemVerilogSource


targets:
default:
filesets:
- rtl
toplevel: top_impl2
27 changes: 16 additions & 11 deletions tests/test_coremanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,22 @@ def test_virtual():
cm = CoreManager(Config())
cm.add_library(Library("virtual", core_dir))

root_core = cm.get_core(Vlnv("::user"))
test_vectors = {
"::top_impl1": ["::impl1:0", "::user:0", "::top_impl1:0"],
"::top_impl2": ["::impl2:0", "::user:0", "::top_impl2:0"],
}
for top_vlnv, expected_deps in test_vectors.items():
root_core = cm.get_core(Vlnv(top_vlnv))

edalizer = Edalizer(
toplevel=root_core.name,
flags=flags,
core_manager=cm,
work_root=work_root,
)
edalizer.run()
edalizer = Edalizer(
toplevel=root_core.name,
flags=flags,
core_manager=cm,
work_root=work_root,
)
edalizer.run()

deps = cm.get_depends(root_core.name, {})
deps_names = [str(c) for c in deps]
deps = cm.get_depends(root_core.name, {})
deps_names = [str(c) for c in deps]

assert deps_names == ["::impl2:0", "::user:0"]
assert deps_names == expected_deps

0 comments on commit f31e1ca

Please sign in to comment.