本文整理汇总了Python中vunit.project.Project.get_source_files_in_order方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_source_files_in_order方法的具体用法?Python Project.get_source_files_in_order怎么用?Python Project.get_source_files_in_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vunit.project.Project
的用法示例。
在下文中一共展示了Project.get_source_files_in_order方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VUnit
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_source_files_in_order [as 别名]
#.........这里部分代码省略.........
"""
self._configuration.set_generic(name, value, scope=create_scope())
def set_sim_option(self, name, value):
"""
Globally set simulation option
:param name: |simulation_options|
:param value: The value of the simulation option
:example:
.. code-block:: python
prj.set_sim_option("ghdl.flags", ["--no-vital-checks"])
"""
self._configuration.set_sim_option(name, value, scope=create_scope())
def set_compile_option(self, name, value):
"""
Globally set compile option
:param name: |compile_option|
:param value: The value of the compile option
:example:
.. code-block:: python
prj.set_compile_option("ghdl.flags", ["--no-vital-checks"])
"""
for source_file in self._project.get_source_files_in_order():
source_file.set_compile_option(name, value)
def add_compile_option(self, name, value):
"""
Globally add compile option
:param name: |compile_option|
:param value: The value of the compile option
"""
for source_file in self._project.get_source_files_in_order():
source_file.add_compile_option(name, value)
def set_pli(self, value):
"""
Globally Set pli
:param value: A list of PLI object file names
"""
self._configuration.set_pli(value, scope=create_scope())
def disable_ieee_warnings(self):
"""
Globally disable ieee warnings
"""
self._configuration.disable_ieee_warnings(scope=create_scope())
def get_source_file(self, file_name, library_name=None):
"""
Get a source file
:param file_name: The name of the file as a relative or absolute path
:param library_name: The name of a specific library to search if not all libraries
示例2: TestProject
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_source_files_in_order [as 别名]
#.........这里部分代码省略.........
end architecture;
""")
self.project.add_library("libcomp1", "work_path")
comp1 = self.add_source_file("libcomp1", "comp1.vhd", """\
entity foo is
end entity;
architecture arch of foo is
begin
end architecture;
""")
self.project.add_library("libcomp2", "work_path")
comp2 = self.add_source_file("libcomp2", "comp2.vhd", """\
entity foo2 is
end entity;
architecture arch of foo2 is
begin
end architecture;
""")
self.assert_has_component_instantiation("top.vhd", "foo")
self.assert_has_component_instantiation("top.vhd", "foo2")
self.assert_compiles(comp1, before=top)
self.assert_compiles(comp2, before=top)
def test_get_dependencies_in_compile_order_without_target(self):
self.create_dummy_three_file_project()
deps = self.project.get_dependencies_in_compile_order()
self.assertEqual(len(deps), 3)
self.assertTrue(deps[0] == self.project.get_source_files_in_order()[0])
self.assertTrue(deps[1] == self.project.get_source_files_in_order()[1])
self.assertTrue(deps[2] == self.project.get_source_files_in_order()[2])
def test_get_dependencies_in_compile_order_with_target(self):
self.create_dummy_three_file_project()
deps = self.project.get_dependencies_in_compile_order(
target_files=[self.project.get_source_files_in_order()[1]])
self.assertEqual(len(deps), 2)
self.assertTrue(deps[0] == self.project.get_source_files_in_order()[0])
self.assertTrue(deps[1] == self.project.get_source_files_in_order()[1])
# To test that indirect dependencies are included
deps = self.project.get_dependencies_in_compile_order(
target_files=[self.project.get_source_files_in_order()[2]])
self.assertEqual(len(deps), 3)
self.assertTrue(deps[0] == self.project.get_source_files_in_order()[0])
self.assertTrue(deps[1] == self.project.get_source_files_in_order()[1])
self.assertTrue(deps[2] == self.project.get_source_files_in_order()[2])
def test_compiles_same_file_into_different_libraries(self):
pkgs = []
second_pkgs = []
self.project.add_library("lib", "lib_path")
other_pkg = self.add_source_file("lib", "other_pkg.vhd", """
package other_pkg is
end package other_pkg;
""")
for lib in ["lib1", "lib2"]:
self.project.add_library(lib, lib + "_path")
pkgs.append(self.add_source_file(lib, "pkg.vhd", """
示例3: TestProject
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_source_files_in_order [as 别名]
#.........这里部分代码省略.........
end architecture;
""")
self.project.add_library("libcomp1", "work_path")
self.add_source_file("libcomp1", "comp1.vhd", """\
entity foo is
end entity;
architecture arch of foo is
begin
end architecture;
""")
self.project.add_library("libcomp2", "work_path")
self.add_source_file("libcomp2", "comp2.vhd", """\
entity foo2 is
end entity;
architecture arch of foo2 is
begin
end architecture;
""")
self.assert_has_component_instantiation("top.vhd", "foo")
self.assert_has_component_instantiation("top.vhd", "foo2")
self.assert_compiles("comp1.vhd", before="top.vhd")
self.assert_compiles("comp2.vhd", before="top.vhd")
def test_get_dependencies_in_compile_order_without_target(self):
self.create_dummy_three_file_project(False)
deps = self.project.get_dependencies_in_compile_order(target=None)
self.assertEqual(len(deps), 3)
self.assertTrue(deps[0] == self.project.get_source_files_in_order()[0])
self.assertTrue(deps[1] == self.project.get_source_files_in_order()[1])
self.assertTrue(deps[2] == self.project.get_source_files_in_order()[2])
def test_get_dependencies_in_compile_order_with_target(self):
self.create_dummy_three_file_project(False)
deps = self.project.get_dependencies_in_compile_order(target=self.project.get_source_files_in_order()[1].name)
self.assertEqual(len(deps), 2)
self.assertTrue(deps[0] == self.project.get_source_files_in_order()[0])
self.assertTrue(deps[1] == self.project.get_source_files_in_order()[1])
# To test that indirect dependencies are included
deps = self.project.get_dependencies_in_compile_order(target=self.project.get_source_files_in_order()[2].name)
self.assertEqual(len(deps), 3)
self.assertTrue(deps[0] == self.project.get_source_files_in_order()[0])
self.assertTrue(deps[1] == self.project.get_source_files_in_order()[1])
self.assertTrue(deps[2] == self.project.get_source_files_in_order()[2])
def test_has_verilog_module(self):
self.project.add_library("lib", "lib_path")
self.add_source_file("lib", "module.v", """\
module name;
endmodule
""")
library = self.project.get_library("lib")
modules = library.get_modules()
self.assertEqual(len(modules), 1)
def test_finds_verilog_package_dependencies(self):
self.project.add_library("lib", "lib_path")
self.add_source_file("lib", "pkg.sv", """\
package pkg;
endpackage
示例4: VUnit
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_source_files_in_order [as 别名]
#.........这里部分代码省略.........
"""
if not self._project.has_library(library_name):
raise KeyError(library_name)
return self._create_library_facade(library_name)
def _create_library_facade(self, library_name):
"""
Create a Library object to be exposed to users
"""
return LibraryFacade(library_name, self, self._project, self._configuration)
def set_generic(self, name, value):
"""
Globally set generic
"""
self._configuration.set_generic(name.lower(), value, scope=create_scope())
def set_parameter(self, name, value):
"""
Globally set parameter
"""
self.set_generic(name, value)
def set_sim_option(self, name, value):
"""
Globally set simulation option
"""
self._configuration.set_sim_option(name, value, scope=create_scope())
def set_compile_option(self, name, value):
"""
Globally set compile option
"""
for source_file in self._project.get_source_files_in_order():
source_file.set_compile_option(name, value)
def set_pli(self, value):
"""
Globally set pli
"""
self._configuration.set_pli(value, scope=create_scope())
def disable_ieee_warnings(self):
"""
Globally disable ieee warnings
"""
self._configuration.disable_ieee_warnings(scope=create_scope())
def add_source_files(self, # pylint: disable=too-many-arguments
pattern, library_name, preprocessors=None, include_dirs=None, allow_empty=False):
"""
Add source files matching wildcard pattern to library
"""
file_names = glob(pattern)
if (not allow_empty) and len(file_names) == 0:
raise ValueError(("Pattern %r did not match any file. "
"Use allow_empty=True to avoid exception,") % pattern)
return FileSetFacade(source_files=[
self.add_source_file(file_name, library_name, preprocessors, include_dirs)
for file_name in file_names])
def add_source_file(self, file_name, library_name, preprocessors=None, include_dirs=None):
"""
Add source file to library