Skip to content
Draft
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
50 changes: 37 additions & 13 deletions edalize/tools/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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"]):
Expand All @@ -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(
Expand All @@ -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")
Expand All @@ -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

Expand All @@ -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":
Expand All @@ -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"
Expand Down Expand Up @@ -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 = []

Expand Down
4 changes: 2 additions & 2 deletions tests/tools/vcs/2stage_basic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/tools/vcs/2stage_minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/tools/vcs/basic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/vcs/basic/vcs.f
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-top top_module some vcs options
-top top_module some vcs options c_file.c cpp_file.cpp
2 changes: 1 addition & 1 deletion tests/tools/vcs/minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/vcs/minimal/vcs.f
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-top top_module
-top top_module c_file.c cpp_file.cpp