From 4919acf33ea37466cd464bfed6d22e4e906fc74a Mon Sep 17 00:00:00 2001 From: ST de Feber Date: Fri, 4 Oct 2024 12:42:32 +0200 Subject: [PATCH] Fixed workdir for ghdl in template creation --- edalize/ghdl.py | 8 +++++++- edalize/templates/ghdl/Makefile.j2 | 4 ++-- tests/test_ghdl/test01/Makefile | 4 ++-- tests/test_ghdl/test02/Makefile | 4 ++-- tests/test_ghdl/test03/Makefile | 4 ++-- tests/test_ghdl/test04/Makefile | 4 ++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/edalize/ghdl.py b/edalize/ghdl.py index 0d103e5e2..319eac4e9 100644 --- a/edalize/ghdl.py +++ b/edalize/ghdl.py @@ -96,6 +96,7 @@ def configure_main(self): libraries = collections.OrderedDict() library_options = "--work={lib} --workdir=./{lib}" + top_workdir_options = "--workdir=./{lib}" ghdlimport = "" vhdl_sources = "" @@ -114,6 +115,11 @@ def configure_main(self): libraries[top[0]] = [] top_libraries = library_options.format(lib=top[0]) + top_workdir = "" + if len(top) > 1: + libraries[top[0]] = [] + top_workdir = top_workdir_options.format(lib=top[0]) + top_unit = top[-1] for f in src_files: @@ -154,7 +160,7 @@ def configure_main(self): "run_options": " ".join(run_options), "make_libraries_directories": make_libraries_directories, "ghdlimport": ghdlimport, - "top_libraries": top_libraries, + "top_workdir": top_workdir, }, ) diff --git a/edalize/templates/ghdl/Makefile.j2 b/edalize/templates/ghdl/Makefile.j2 index 19ece63e7..0ed11a01e 100644 --- a/edalize/templates/ghdl/Makefile.j2 +++ b/edalize/templates/ghdl/Makefile.j2 @@ -4,7 +4,7 @@ TOPLEVEL = {{ toplevel }} TOPLEVEL_LIBS = {{ top_libraries }} ANALYZE_OPTIONS = {{ analyze_options }} RUN_OPTIONS = {{ run_options }} - +TOP_WORKDIR = {{ top_workdir }} VHDL_SOURCES = {{ vhdl_sources }} all: work-obj{{ standard }}.cf @@ -13,7 +13,7 @@ run: $(TOPLEVEL) $(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS) $(TOPLEVEL): $(VHDL_SOURCES) work-obj{{ standard }}.cf - $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) + $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL) $(TOPLEVEL).v: $(VHDL_SOURCES) work-obj{{ standard }}.cf $(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) diff --git a/tests/test_ghdl/test01/Makefile b/tests/test_ghdl/test01/Makefile index a87c77542..86caf1689 100644 --- a/tests/test_ghdl/test01/Makefile +++ b/tests/test_ghdl/test01/Makefile @@ -4,7 +4,7 @@ TOPLEVEL = top_module TOPLEVEL_LIBS = ANALYZE_OPTIONS = some analyze_options -P./libx RUN_OPTIONS = a few run_options - +TOP_WORKDIR = VHDL_SOURCES = vhdl_file.vhd vhdl_lfile vhdl2008_file all: work-obj08.cf @@ -13,7 +13,7 @@ run: $(TOPLEVEL) $(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS) $(TOPLEVEL): $(VHDL_SOURCES) work-obj08.cf - $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) + $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL) $(TOPLEVEL).v: $(VHDL_SOURCES) work-obj08.cf $(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) diff --git a/tests/test_ghdl/test02/Makefile b/tests/test_ghdl/test02/Makefile index c5664afb7..a10a2e8e1 100644 --- a/tests/test_ghdl/test02/Makefile +++ b/tests/test_ghdl/test02/Makefile @@ -4,7 +4,7 @@ TOPLEVEL = top_module TOPLEVEL_LIBS = ANALYZE_OPTIONS = some analyze_options -P./libx RUN_OPTIONS = a few run_options - +TOP_WORKDIR = VHDL_SOURCES = vhdl_file.vhd vhdl_lfile all: work-obj93.cf @@ -13,7 +13,7 @@ run: $(TOPLEVEL) $(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS) $(TOPLEVEL): $(VHDL_SOURCES) work-obj93.cf - $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) + $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL) $(TOPLEVEL).v: $(VHDL_SOURCES) work-obj93.cf $(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) diff --git a/tests/test_ghdl/test03/Makefile b/tests/test_ghdl/test03/Makefile index 6027d9edd..948766628 100644 --- a/tests/test_ghdl/test03/Makefile +++ b/tests/test_ghdl/test03/Makefile @@ -4,7 +4,7 @@ TOPLEVEL = top_module TOPLEVEL_LIBS = ANALYZE_OPTIONS = --ieee=synopsys -P./libx RUN_OPTIONS = a few run_options - +TOP_WORKDIR = VHDL_SOURCES = vhdl_file.vhd vhdl_lfile all: work-obj08.cf @@ -13,7 +13,7 @@ run: $(TOPLEVEL) $(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS) $(TOPLEVEL): $(VHDL_SOURCES) work-obj08.cf - $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) + $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL) $(TOPLEVEL).v: $(VHDL_SOURCES) work-obj08.cf $(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) diff --git a/tests/test_ghdl/test04/Makefile b/tests/test_ghdl/test04/Makefile index 82b22784d..6b5020b71 100644 --- a/tests/test_ghdl/test04/Makefile +++ b/tests/test_ghdl/test04/Makefile @@ -4,7 +4,7 @@ TOPLEVEL = vhdl_lfile TOPLEVEL_LIBS = --work=libx --workdir=./libx ANALYZE_OPTIONS = some analyze_options -P./libx RUN_OPTIONS = a few run_options - +TOP_WORKDIR = --workdir=./libx VHDL_SOURCES = vhdl_file.vhd vhdl_lfile vhdl2008_file all: work-obj08.cf @@ -13,7 +13,7 @@ run: $(TOPLEVEL) $(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS) $(TOPLEVEL): $(VHDL_SOURCES) work-obj08.cf - $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) + $(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL) $(TOPLEVEL).v: $(VHDL_SOURCES) work-obj08.cf $(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)