Skip to content

Commit

Permalink
vcs: Fix rebuilds after errors
Browse files Browse the repository at this point in the history
  • Loading branch information
olofk committed Dec 6, 2024
1 parent 4c0bfca commit f23e0cf
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 41 deletions.
35 changes: 20 additions & 15 deletions edalize/tools/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,40 +107,48 @@ def setup(self, edam):
full64 = [] if self.tool_options.get("32bit") else ["-full64"]
self.commands = EdaCommands()
self.f_files = {}
self.workdirs = []
target_files = []
for lib, files in libs.items():
cmds = {}
depfiles = []
has_vlog = False
# Group into individual commands
for (cmd, fname, defines) in files:
if not (cmd, defines) in cmds:
cmds[(cmd, defines)] = []
cmds[(cmd, defines)].append(fname)
depfiles.append(fname)
if cmd == "vlogan":
has_vlog = True
commands = [["mkdir", "-p", lib]]
i = 1
i = 0
f_files = {}
for (cmd, defines), fnames in cmds.items():
depfiles = fnames.copy()
options = []
if cmd == "vlogan":
if has_sv:
options.append("-sverilog")
options += self.tool_options.get("vlogan_options", [])
options += [defines]
options += ["+incdir+" + d for d in incdirs]
target_file = "AN.DB/make.vlogan"
elif cmd == "vhdlan":
options += self.tool_options.get("vhdlan_options", [])
f_file = f"{lib}.{i}.f"
target_file = "64/vhmra.sdb"
suffix = f"_{i}" if i else ""
f_file = f"{lib}{suffix}.f"
f_files[f_file] = options
workdir = lib + suffix
self.workdirs.append(workdir)
i += 1
commands.append([cmd] + full64 + ["-f", f_file, "-work", lib] + fnames)
if has_vlog:
depfiles += include_files
self.commands.add(
commands, [lib + "/AN.DB"], depfiles + list(f_files.keys())
)
if has_vlog:
depfiles += include_files
self.commands.add(
[cmd] + full64 + ["-f", f_file, "-work", workdir] + fnames,
[workdir + "/" + target_file],
depfiles + [f_file],
)
target_files.append(workdir + "/" + target_file)
self.f_files.update(f_files)

self.edam = edam.copy()
Expand All @@ -154,9 +162,7 @@ def setup(self, edam):
+ full64
+ ["-o", self.name, "-file", "vcs.f", "-parameters", "parameters.txt"],
[self.name],
[x + "/AN.DB" for x in libs.keys()]
+ user_files
+ ["vcs.f", "parameters.txt"],
target_files + user_files + ["vcs.f", "parameters.txt"],
)

self.commands.add(
Expand All @@ -166,11 +172,10 @@ def setup(self, edam):
[self.name],
)
self.commands.set_default_target(self.name)
self.libs = libs.keys()

def write_config_files(self):
s = "WORK > DEFAULT\nDEFAULT : ./work\n"
for lib in self.libs:
for lib in self.workdirs:
if lib != "work":
s += f"{lib} : ./{lib}\n"
self.update_config_file("synopsys_sim.setup", s)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_tool_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def test_tool_vcs(tool_fixture):
tf.compare_config_files(
[
"synopsys_sim.setup",
"libx.1.f",
"libx.f",
"vcs.f",
"work.1.f",
"work.2.f",
"work.3.f",
"work.f",
"work_1.f",
"work_2.f",
"parameters.txt",
]
)
Expand All @@ -38,11 +38,11 @@ def test_tool_vcs_minimal(tool_fixture):
tf.compare_config_files(
[
"synopsys_sim.setup",
"libx.1.f",
"libx.f",
"vcs.f",
"work.1.f",
"work.2.f",
"work.3.f",
"work.f",
"work_1.f",
"work_2.f",
"parameters.txt",
]
)
20 changes: 11 additions & 9 deletions tests/tools/vcs/basic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

all: design

work/AN.DB: sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v vhdl_file.vhd vhdl2008_file another_sv_file.sv vlog_incfile work.1.f work.2.f work.3.f
$(EDALIZE_LAUNCHER) mkdir -p work
$(EDALIZE_LAUNCHER) vlogan -full64 -f work.1.f -work work sv_file.sv vlog_file.v vlog05_file.v another_sv_file.sv
$(EDALIZE_LAUNCHER) vlogan -full64 -f work.2.f -work work vlog_with_define.v
$(EDALIZE_LAUNCHER) vhdlan -full64 -f work.3.f -work work vhdl_file.vhd vhdl2008_file
work/AN.DB/make.vlogan: sv_file.sv vlog_file.v vlog05_file.v another_sv_file.sv vlog_incfile work.f
$(EDALIZE_LAUNCHER) vlogan -full64 -f work.f -work work sv_file.sv vlog_file.v vlog05_file.v another_sv_file.sv

libx/AN.DB: vhdl_lfile libx.1.f
$(EDALIZE_LAUNCHER) mkdir -p libx
$(EDALIZE_LAUNCHER) vhdlan -full64 -f libx.1.f -work libx vhdl_lfile
work_1/AN.DB/make.vlogan: vlog_with_define.v vlog_incfile work_1.f
$(EDALIZE_LAUNCHER) vlogan -full64 -f work_1.f -work work_1 vlog_with_define.v

design: work/AN.DB libx/AN.DB user_file vcs.f parameters.txt
work_2/64/vhmra.sdb: vhdl_file.vhd vhdl2008_file vlog_incfile work_2.f
$(EDALIZE_LAUNCHER) vhdlan -full64 -f work_2.f -work work_2 vhdl_file.vhd vhdl2008_file

libx/64/vhmra.sdb: vhdl_lfile libx.f
$(EDALIZE_LAUNCHER) vhdlan -full64 -f libx.f -work libx vhdl_lfile

design: work/AN.DB/make.vlogan work_1/AN.DB/make.vlogan work_2/64/vhmra.sdb libx/64/vhmra.sdb user_file vcs.f parameters.txt
$(EDALIZE_LAUNCHER) vcs -full64 -o design -file vcs.f -parameters parameters.txt

run: design
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/tools/vcs/basic/synopsys_sim.setup
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
WORK > DEFAULT
DEFAULT : ./work
work_1 : ./work_1
work_2 : ./work_2
libx : ./libx
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 11 additions & 9 deletions tests/tools/vcs/minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

all: design

work/AN.DB: sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v vhdl_file.vhd vhdl2008_file another_sv_file.sv vlog_incfile work.1.f work.2.f work.3.f
$(EDALIZE_LAUNCHER) mkdir -p work
$(EDALIZE_LAUNCHER) vlogan -full64 -f work.1.f -work work sv_file.sv vlog_file.v vlog05_file.v another_sv_file.sv
$(EDALIZE_LAUNCHER) vlogan -full64 -f work.2.f -work work vlog_with_define.v
$(EDALIZE_LAUNCHER) vhdlan -full64 -f work.3.f -work work vhdl_file.vhd vhdl2008_file
work/AN.DB/make.vlogan: sv_file.sv vlog_file.v vlog05_file.v another_sv_file.sv vlog_incfile work.f
$(EDALIZE_LAUNCHER) vlogan -full64 -f work.f -work work sv_file.sv vlog_file.v vlog05_file.v another_sv_file.sv

libx/AN.DB: vhdl_lfile libx.1.f
$(EDALIZE_LAUNCHER) mkdir -p libx
$(EDALIZE_LAUNCHER) vhdlan -full64 -f libx.1.f -work libx vhdl_lfile
work_1/AN.DB/make.vlogan: vlog_with_define.v vlog_incfile work_1.f
$(EDALIZE_LAUNCHER) vlogan -full64 -f work_1.f -work work_1 vlog_with_define.v

design: work/AN.DB libx/AN.DB user_file vcs.f parameters.txt
work_2/64/vhmra.sdb: vhdl_file.vhd vhdl2008_file vlog_incfile work_2.f
$(EDALIZE_LAUNCHER) vhdlan -full64 -f work_2.f -work work_2 vhdl_file.vhd vhdl2008_file

libx/64/vhmra.sdb: vhdl_lfile libx.f
$(EDALIZE_LAUNCHER) vhdlan -full64 -f libx.f -work libx vhdl_lfile

design: work/AN.DB/make.vlogan work_1/AN.DB/make.vlogan work_2/64/vhmra.sdb libx/64/vhmra.sdb user_file vcs.f parameters.txt
$(EDALIZE_LAUNCHER) vcs -full64 -o design -file vcs.f -parameters parameters.txt

run: design
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/tools/vcs/minimal/synopsys_sim.setup
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
WORK > DEFAULT
DEFAULT : ./work
work_1 : ./work_1
work_2 : ./work_2
libx : ./libx
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f23e0cf

Please sign in to comment.