Skip to content

Commit 3196462

Browse files
author
Sebastien Bourdeauducq
committedDec 12, 2013
add support for Verilog include paths
1 parent adda930 commit 3196462

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed
 

‎mibuild/generic_platform.py

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def __init__(self, device, io, default_crg_factory=None, name=None):
148148
name = self.__module__.split(".")[-1]
149149
self.name = name
150150
self.sources = []
151+
self.verilog_include_paths = []
151152
self.finalized = False
152153

153154
def request(self, *args, **kwargs):
@@ -195,6 +196,9 @@ def add_source_dir(self, path):
195196
if language is not None:
196197
self.add_source(os.path.join(root, filename), language)
197198

199+
def add_verilog_include_path(self, path):
200+
self.verilog_include_paths.append(os.path.abspath(path))
201+
198202
def _resolve_signals(self, vns):
199203
# resolve signal names in constraints
200204
sc = self.constraint_manager.get_sig_constraints()

‎mibuild/xilinx_ise.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _build_ucf(named_sc, named_pc):
7070
r += "\n" + "\n\n".join(named_pc)
7171
return r
7272

73-
def _build_xst_files(device, sources, build_name, xst_opt):
73+
def _build_xst_files(device, sources, vincpaths, build_name, xst_opt):
7474
prj_contents = ""
7575
for filename, language in sources:
7676
prj_contents += language + " work " + filename + "\n"
@@ -81,13 +81,19 @@ def _build_xst_files(device, sources, build_name, xst_opt):
8181
-top top
8282
{xst_opt}
8383
-ofn {build_name}.ngc
84-
-p {device}""".format(build_name=build_name, xst_opt=xst_opt, device=device)
84+
-p {device}
85+
""".format(build_name=build_name, xst_opt=xst_opt, device=device)
86+
for path in vincpaths:
87+
xst_contents += "-vlgincdir " + path + "\n"
8588
tools.write_to_file(build_name + ".xst", xst_contents)
8689

87-
def _run_yosys(device, sources, build_name):
90+
def _run_yosys(device, sources, vincpaths, build_name):
8891
ys_contents = ""
92+
incflags = ""
93+
for path in vincpaths:
94+
incflags += " -I" + path
8995
for filename, language in sources:
90-
ys_contents += "read_{} {}\n".format(language, filename)
96+
ys_contents += "read_{}{} {}\n".format(language, incflags, filename)
9197

9298
if device[:2] == "xc":
9399
archcode = device[2:4]
@@ -212,10 +218,10 @@ def build(self, fragment, build_dir="build", build_name="top",
212218
tools.write_to_file(v_file, v_src)
213219
sources = self.sources + [(v_file, "verilog")]
214220
if mode == "xst":
215-
_build_xst_files(self.device, sources, build_name, self.xst_opt)
221+
_build_xst_files(self.device, sources, self.verilog_include_paths, build_name, self.xst_opt)
216222
isemode = "xst"
217223
else:
218-
_run_yosys(self.device, sources, build_name)
224+
_run_yosys(self.device, sources, self.verilog_include_paths, build_name)
219225
isemode = "edif"
220226
ngdbuild_opt += "-p " + self.device
221227

0 commit comments

Comments
 (0)
Please sign in to comment.