diff --git a/edalize/tools/vcs.py b/edalize/tools/vcs.py index b5d8fd4e..995c405e 100644 --- a/edalize/tools/vcs.py +++ b/edalize/tools/vcs.py @@ -65,7 +65,8 @@ def setup(self, edam): self.user_files = [] incdirs = [] - include_files = [] + rtl_include_files = [] + c_include_files = [] unused_files = self.files.copy() # Get all include dirs. Move include files to a separate list for f in self.files: @@ -76,14 +77,23 @@ def setup(self, edam): "systemVerilogSource" ): if self._add_include_dir(f, incdirs, force_slash=True): - include_files.append(f["name"]) + rtl_include_files.append(f["name"]) + unused_files.remove(f) + + elif file_type.startswith("cSource") or file_type.startswith("cppSource"): + if self._add_include_dir(f, incdirs, force_slash=True): + c_include_files.append(f["name"]) unused_files.remove(f) full64 = [] if self.tool_options.get("32bit") else ["-full64"] if self.tool_options.get("2_stage_flow"): - self._twostage_setup(edam, incdirs, include_files, unused_files, full64) + self._twostage_setup( + edam, incdirs, rtl_include_files, c_include_files, unused_files, full64 + ) else: - self._threestage_setup(edam, incdirs, include_files, unused_files, full64) + self._threestage_setup( + edam, incdirs, rtl_include_files, c_include_files, unused_files, full64 + ) self.edam = edam.copy() self.edam["files"] = unused_files @@ -106,11 +116,16 @@ def setup(self, edam): ) self.commands.set_default_target(binary_name) - def _twostage_setup(self, edam, incdirs, include_files, unused_files, full64): + def _twostage_setup( + self, edam, incdirs, rtl_include_files, c_include_files, unused_files, full64 + ): user_files = [] vlog_files = [] + + c_files = [] + has_sv = False for f in unused_files.copy(): if not "simulation" in f.get("tags", ["simulation"]): @@ -134,6 +149,9 @@ def _twostage_setup(self, edam, incdirs, include_files, unused_files, full64): ) elif file_type == "user": user_files.append(f["name"]) + elif file_type == "cSource" or file_type == "cppSource": + c_files.append(fname) + unused_files.remove(f) if f.get("define"): logger.warning( @@ -159,11 +177,14 @@ def _twostage_setup(self, edam, incdirs, include_files, unused_files, full64): self.f_files["vcs.f"] = options - self.target_files = include_files + vlog_files - self.vcs_files = vlog_files + self.target_files = rtl_include_files + c_include_files + vlog_files + c_files + self.vcs_files = vlog_files + c_files - def _threestage_setup(self, edam, incdirs, include_files, unused_files, full64): + def _threestage_setup( + self, edam, incdirs, rtl_include_files, c_include_files, unused_files, full64 + ): filegroups = [] + c_files = [] prev_fileopts = ("", "", "") # file_type, logical_name, defines for f in unused_files.copy(): lib = f.get("logical_name", "work") @@ -190,6 +211,9 @@ def _threestage_setup(self, edam, incdirs, include_files, unused_files, full64): elif file_type == "user": self.user_files.append(f["name"]) cmd = None + elif file_type == "cSource" or file_type == "cppSource": + c_files.append(f["name"]) + cmd = None else: cmd = None @@ -212,7 +236,7 @@ def _threestage_setup(self, edam, incdirs, include_files, unused_files, full64): for fg in filegroups: # Ignore empty file groups if fg[1]: - (cmd, file_type, lib, defines) = fg[0] + cmd, file_type, lib, defines = fg[0] depfiles += fg[1] options = self.tool_options.get("analysis_options", []).copy() if cmd == "vlogan": @@ -222,7 +246,7 @@ def _threestage_setup(self, edam, incdirs, include_files, unused_files, full64): options += [defines] options += ["+incdir+" + d for d in incdirs] target_file = f"{lib}.workdir/AN.DB/make.vlogan" - depfiles += include_files + depfiles += rtl_include_files elif cmd == "vhdlan": options += self.tool_options.get("vhdlan_options", []) target_file = f"{lib}.workdir/64/vhmra.sdb" @@ -252,11 +276,11 @@ def _threestage_setup(self, edam, incdirs, include_files, unused_files, full64): + ["-file", f_file, "-work", lib, "-l", logfile] + fg[1] ) - + depfiles += c_include_files self.commands.add(cmds, self.target_files, depfiles + list(self.f_files.keys())) - self.f_files["vcs.f"] = ["-top", self.toplevel] + self.tool_options.get( - "vcs_options", [] + self.f_files["vcs.f"] = ( + ["-top", self.toplevel] + self.tool_options.get("vcs_options", []) + c_files ) self.vcs_files = [] diff --git a/tests/tools/vcs/2stage_basic/Makefile b/tests/tools/vcs/2stage_basic/Makefile index 0536db20..c441dc97 100644 --- a/tests/tools/vcs/2stage_basic/Makefile +++ b/tests/tools/vcs/2stage_basic/Makefile @@ -2,8 +2,8 @@ all: design -design: vlog_incfile sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv vcs.f parameters.txt - $(EDALIZE_LAUNCHER) vcs -full64 -o design -file vcs.f -parameters parameters.txt sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv +design: vlog_incfile c_header.h c_header.h sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv c_file.c cpp_file.cpp vcs.f parameters.txt + $(EDALIZE_LAUNCHER) vcs -full64 -o design -file vcs.f -parameters parameters.txt sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv c_file.c cpp_file.cpp run: $(EDALIZE_LAUNCHER) ./design $(EXTRA_OPTIONS) and some run options diff --git a/tests/tools/vcs/2stage_minimal/Makefile b/tests/tools/vcs/2stage_minimal/Makefile index 45fa7c54..0aea5b61 100644 --- a/tests/tools/vcs/2stage_minimal/Makefile +++ b/tests/tools/vcs/2stage_minimal/Makefile @@ -2,8 +2,8 @@ all: design -design: vlog_incfile sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv vcs.f parameters.txt - $(EDALIZE_LAUNCHER) vcs -full64 -o design -file vcs.f -parameters parameters.txt sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv +design: vlog_incfile c_header.h c_header.h sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv c_file.c cpp_file.cpp vcs.f parameters.txt + $(EDALIZE_LAUNCHER) vcs -full64 -o design -file vcs.f -parameters parameters.txt sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v another_sv_file.sv c_file.c cpp_file.cpp run: $(EDALIZE_LAUNCHER) ./design $(EXTRA_OPTIONS) diff --git a/tests/tools/vcs/basic/Makefile b/tests/tools/vcs/basic/Makefile index 8cb9caa4..4d7107a5 100644 --- a/tests/tools/vcs/basic/Makefile +++ b/tests/tools/vcs/basic/Makefile @@ -2,7 +2,7 @@ all: custom_binary_name -work.workdir/AN.DB/make.vlogan work.workdir/64/vhmra.sdb libx.workdir/64/vhmra.sdb: sv_file.sv vlog_incfile vlog_file.v vlog_incfile vlog_with_define.v vlog_incfile vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file another_sv_file.sv vlog_incfile work.f work_1.f work_2.f work_3.f work_4.f libx.f work_5.f work_6.f +work.workdir/AN.DB/make.vlogan work.workdir/64/vhmra.sdb libx.workdir/64/vhmra.sdb: sv_file.sv vlog_incfile vlog_file.v vlog_incfile vlog_with_define.v vlog_incfile vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file another_sv_file.sv vlog_incfile c_header.h c_header.h work.f work_1.f work_2.f work_3.f work_4.f libx.f work_5.f work_6.f $(EDALIZE_LAUNCHER) vlogan -full64 -file work.f -work work -l work.log sv_file.sv $(EDALIZE_LAUNCHER) vlogan -full64 -file work_1.f -work work -l work_1.log vlog_file.v $(EDALIZE_LAUNCHER) vlogan -full64 -file work_2.f -work work -l work_2.log vlog_with_define.v diff --git a/tests/tools/vcs/basic/vcs.f b/tests/tools/vcs/basic/vcs.f index b40c83a1..a9619cf9 100644 --- a/tests/tools/vcs/basic/vcs.f +++ b/tests/tools/vcs/basic/vcs.f @@ -1 +1 @@ --top top_module some vcs options +-top top_module some vcs options c_file.c cpp_file.cpp diff --git a/tests/tools/vcs/minimal/Makefile b/tests/tools/vcs/minimal/Makefile index d425cc51..a639d7da 100644 --- a/tests/tools/vcs/minimal/Makefile +++ b/tests/tools/vcs/minimal/Makefile @@ -2,7 +2,7 @@ all: design -work.workdir/AN.DB/make.vlogan work.workdir/64/vhmra.sdb libx.workdir/64/vhmra.sdb: sv_file.sv vlog_incfile vlog_file.v vlog_incfile vlog_with_define.v vlog_incfile vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file another_sv_file.sv vlog_incfile work.f work_1.f work_2.f work_3.f work_4.f libx.f work_5.f work_6.f +work.workdir/AN.DB/make.vlogan work.workdir/64/vhmra.sdb libx.workdir/64/vhmra.sdb: sv_file.sv vlog_incfile vlog_file.v vlog_incfile vlog_with_define.v vlog_incfile vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file another_sv_file.sv vlog_incfile c_header.h c_header.h work.f work_1.f work_2.f work_3.f work_4.f libx.f work_5.f work_6.f $(EDALIZE_LAUNCHER) vlogan -full64 -file work.f -work work -l work.log sv_file.sv $(EDALIZE_LAUNCHER) vlogan -full64 -file work_1.f -work work -l work_1.log vlog_file.v $(EDALIZE_LAUNCHER) vlogan -full64 -file work_2.f -work work -l work_2.log vlog_with_define.v diff --git a/tests/tools/vcs/minimal/vcs.f b/tests/tools/vcs/minimal/vcs.f index 0a41b604..c0677c17 100644 --- a/tests/tools/vcs/minimal/vcs.f +++ b/tests/tools/vcs/minimal/vcs.f @@ -1 +1 @@ --top top_module +-top top_module c_file.c cpp_file.cpp