Skip to content

Commit 3f454bc

Browse files
committed
Fixed workdir for ghdl in template creation
1 parent 18972c4 commit 3f454bc

File tree

8 files changed

+27
-12
lines changed

8 files changed

+27
-12
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ Tada! We have simulated. As an exercise, try to just change the tool variable to
136136

137137
Now it's time to create an FPGA image instead
138138

139-
140139
As you have seen, Edalize is an award-winning tool for interfacing EDA tools, so
141140

142141
**Edalize it, don't criticize it!**

edalize/ghdl.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def configure_main(self):
9696

9797
libraries = collections.OrderedDict()
9898
library_options = "--work={lib} --workdir=./{lib}"
99+
top_workdir_options = "--workdir=./{lib}"
99100
ghdlimport = ""
100101
vhdl_sources = ""
101102

@@ -114,6 +115,11 @@ def configure_main(self):
114115
libraries[top[0]] = []
115116
top_libraries = library_options.format(lib=top[0])
116117

118+
top_workdir = ""
119+
if len(top) > 1:
120+
libraries[top[0]] = []
121+
top_workdir = top_workdir_options.format(lib=top[0])
122+
117123
top_unit = top[-1]
118124

119125
for f in src_files:
@@ -155,6 +161,7 @@ def configure_main(self):
155161
"make_libraries_directories": make_libraries_directories,
156162
"ghdlimport": ghdlimport,
157163
"top_libraries": top_libraries,
164+
"top_workdir": top_workdir,
158165
},
159166
)
160167

edalize/templates/ghdl/Makefile.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TOPLEVEL = {{ toplevel }}
44
TOPLEVEL_LIBS = {{ top_libraries }}
55
ANALYZE_OPTIONS = {{ analyze_options }}
66
RUN_OPTIONS = {{ run_options }}
7-
7+
TOP_WORKDIR = {{ top_workdir }}
88
VHDL_SOURCES = {{ vhdl_sources }}
99

1010
all: work-obj{{ standard }}.cf
@@ -13,7 +13,7 @@ run: $(TOPLEVEL)
1313
$(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS)
1414

1515
$(TOPLEVEL): $(VHDL_SOURCES) work-obj{{ standard }}.cf
16-
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)
16+
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL)
1717

1818
$(TOPLEVEL).v: $(VHDL_SOURCES) work-obj{{ standard }}.cf
1919
$(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)

tests/edalize_common.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
import shutil
55

66
import pytest
7+
import logging
78

89
from edalize.edatool import get_edatool
910

11+
logger = logging.getLogger('Edalize')
12+
logger.setLevel (logging.INFO)
1013

1114
tests_dir = os.path.dirname(__file__)
1215

@@ -136,9 +139,15 @@ def compare_files(ref_dir, work_root, files):
136139
if "GOLDEN_RUN" in os.environ:
137140
shutil.copy(generated_file, reference_file)
138141

142+
139143
with open(reference_file) as fref, open(generated_file) as fgen:
140-
assert fref.read() == fgen.read(), f
144+
if fref.read() != fgen.read():
145+
logger.info(f"{fref}")
146+
logger.info(f"{fgen}")
147+
141148

149+
with open(reference_file) as fref, open(generated_file) as fgen:
150+
assert fref.read() == fgen.read(), f
142151

143152
def get_flow(name):
144153
return getattr(import_module("edalize.flows.{}".format(name)), name.capitalize())

tests/test_ghdl/test01/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TOPLEVEL = top_module
44
TOPLEVEL_LIBS =
55
ANALYZE_OPTIONS = some analyze_options -P./libx
66
RUN_OPTIONS = a few run_options
7-
7+
TOP_WORKDIR =
88
VHDL_SOURCES = vhdl_file.vhd vhdl_lfile vhdl2008_file
99

1010
all: work-obj08.cf
@@ -13,7 +13,7 @@ run: $(TOPLEVEL)
1313
$(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS)
1414

1515
$(TOPLEVEL): $(VHDL_SOURCES) work-obj08.cf
16-
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)
16+
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL)
1717

1818
$(TOPLEVEL).v: $(VHDL_SOURCES) work-obj08.cf
1919
$(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)

tests/test_ghdl/test02/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TOPLEVEL = top_module
44
TOPLEVEL_LIBS =
55
ANALYZE_OPTIONS = some analyze_options -P./libx
66
RUN_OPTIONS = a few run_options
7-
7+
TOP_WORKDIR =
88
VHDL_SOURCES = vhdl_file.vhd vhdl_lfile
99

1010
all: work-obj93.cf
@@ -13,7 +13,7 @@ run: $(TOPLEVEL)
1313
$(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS)
1414

1515
$(TOPLEVEL): $(VHDL_SOURCES) work-obj93.cf
16-
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)
16+
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL)
1717

1818
$(TOPLEVEL).v: $(VHDL_SOURCES) work-obj93.cf
1919
$(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)

tests/test_ghdl/test03/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TOPLEVEL = top_module
44
TOPLEVEL_LIBS =
55
ANALYZE_OPTIONS = --ieee=synopsys -P./libx
66
RUN_OPTIONS = a few run_options
7-
7+
TOP_WORKDIR =
88
VHDL_SOURCES = vhdl_file.vhd vhdl_lfile
99

1010
all: work-obj08.cf
@@ -13,7 +13,7 @@ run: $(TOPLEVEL)
1313
$(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS)
1414

1515
$(TOPLEVEL): $(VHDL_SOURCES) work-obj08.cf
16-
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)
16+
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL)
1717

1818
$(TOPLEVEL).v: $(VHDL_SOURCES) work-obj08.cf
1919
$(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)

tests/test_ghdl/test04/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TOPLEVEL = vhdl_lfile
44
TOPLEVEL_LIBS = --work=libx --workdir=./libx
55
ANALYZE_OPTIONS = some analyze_options -P./libx
66
RUN_OPTIONS = a few run_options
7-
7+
TOP_WORKDIR = --workdir=./libx
88
VHDL_SOURCES = vhdl_file.vhd vhdl_lfile vhdl2008_file
99

1010
all: work-obj08.cf
@@ -13,7 +13,7 @@ run: $(TOPLEVEL)
1313
$(EDALIZE_LAUNCHER) ghdl -r $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL) $(RUN_OPTIONS) $(EXTRA_OPTIONS)
1414

1515
$(TOPLEVEL): $(VHDL_SOURCES) work-obj08.cf
16-
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)
16+
$(EDALIZE_LAUNCHER) ghdl -m $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOP_WORKDIR) $(TOPLEVEL)
1717

1818
$(TOPLEVEL).v: $(VHDL_SOURCES) work-obj08.cf
1919
$(EDALIZE_LAUNCHER) ghdl --synth --out=verilog $(STD) $(ANALYZE_OPTIONS) $(TOPLEVEL_LIBS) $(TOPLEVEL)

0 commit comments

Comments
 (0)