Commit 4468bbdc authored by Tristan Gingold's avatar Tristan Gingold

isim.py: minor rewrite.

parent 27be18a6
...@@ -113,6 +113,11 @@ class ToolISim(MakefileSim): ...@@ -113,6 +113,11 @@ class ToolISim(MakefileSim):
default_options + __get_rid_of_isim_incdirs( default_options + __get_rid_of_isim_incdirs(
self.manifest_dict.get("vlog_opt", ''))) self.manifest_dict.get("vlog_opt", '')))
def _makefile_syn_file_rule(self, file_aux):
"""Generate target and prerequisites for :param file_aux:"""
self.write("{}: {} ".format(self.get_stamp_file(file_aux), file_aux.rel_path()))
self.writeln(' '.join([fname.rel_path() for fname in file_aux.depends_on]))
def _makefile_sim_compilation(self): def _makefile_sim_compilation(self):
"""Print the compile simulation target for Xilinx ISim""" """Print the compile simulation target for Xilinx ISim"""
fileset = self.fileset fileset = self.fileset
...@@ -154,67 +159,33 @@ fuse: ...@@ -154,67 +159,33 @@ fuse:
# "${XILINX_INI_PATH}/xilinxsim.ini"])) # "${XILINX_INI_PATH}/xilinxsim.ini"]))
# rules for all _primary.dat files for sv # rules for all _primary.dat files for sv
# incdir = "" # incdir = ""
objs = []
for vl_file in fileset.filter(VerilogFile).sort(): for vl_file in fileset.filter(VerilogFile).sort():
comp_obj = os.path.join(vl_file.library, vl_file.purename) self._makefile_syn_file_rule(vl_file)
objs.append(comp_obj) self.write("\t\tvlogcomp -work {lib}=.{slash}{lib}".format(
# self.write(os.path.join(vl_file.library, vl_file.purename, lib=vl_file.library, slash=shell.makefile_slash_char()))
# '.'+vl_file.purename+"_"+vl_file.extension())+': ')
# self.writeln(".PHONY: " + os.path.join(comp_obj,
# '.'+vl_file.purename+"_"+vl_file.extension()))
self.write(
os.path.join(
comp_obj,
'.' +
vl_file.purename +
"_" +
vl_file.extension(
)) +
': ')
self.write(vl_file.rel_path() + ' ')
self.writeln(
' '.join([fname.rel_path() for fname in vl_file.depends_on]))
self.write("\t\tvlogcomp -work " + vl_file.library
+ "=." + shell.makefile_slash_char() + vl_file.library)
self.write(" $(VLOGCOMP_FLAGS) ") self.write(" $(VLOGCOMP_FLAGS) ")
# if isinstance(vl_file, SVFile):
# self.write(" -sv ")
# incdir = "-i "
# incdir += " -i ".join(vl_file.include_dirs)
# incdir += " "
if vl_file.include_dirs: if vl_file.include_dirs:
self.write(' -i ') self.write(' -i ')
self.write(' '.join(vl_file.include_dirs)) self.write(' '.join(vl_file.include_dirs))
self.writeln(" $<") self.writeln(" $<")
self.write("\t\t@" + shell.mkdir_command() + " $(dir $@)") self._makefile_sim_file_touch_stamp()
self.writeln(" && " + shell.touch_command() + " $@ \n\n") self.writeln()
self.write("\n") self.write("\n")
# list rules for all _primary.dat files for vhdl # list rules for all _primary.dat files for vhdl
for vhdl_file in fileset.filter(VHDLFile).sort(): for vhdl_file in fileset.filter(VHDLFile).sort():
lib = vhdl_file.library lib = vhdl_file.library
purename = vhdl_file.purename purename = vhdl_file.purename
comp_obj = os.path.join(lib, purename)
objs.append(comp_obj)
# each .dat depends on corresponding .vhd file and its dependencies # each .dat depends on corresponding .vhd file and its dependencies
# self.write(os.path.join(lib, purename, "."+purename+"_" # self.write(os.path.join(lib, purename, "."+purename+"_"
# + vhdl_file.extension()) + ": "+ vhdl_file.rel_path()+" " # + vhdl_file.extension()) + ": "+ vhdl_file.rel_path()+" "
# + os.path.join(lib, purename, "."+purename) + '\n') # + os.path.join(lib, purename, "."+purename) + '\n')
# self.writeln(".PHONY: " + os.path.join(comp_obj, # self.writeln(".PHONY: " + os.path.join(comp_obj,
# "."+purename+"_"+ vhdl_file.extension())) # "."+purename+"_"+ vhdl_file.extension()))
self.write( self.write(self.get_stamp_file(vhdl_file)
os.path.join( + ": " + vhdl_file.rel_path() + " " + os.path.join(
comp_obj, lib, purename, "." + purename) + '\n')
"." + purename + "_" + vhdl_file.extension( self.writeln("\t\tvhpcomp $(VHPCOMP_FLAGS) -work {lib}=.{slash}{lib} $< ".format(
)) + ": " + vhdl_file.rel_path( lib=lib, slash=shell.makefile_slash_char()))
) + " " + os.path.join(
lib,
purename,
"." + purename) + '\n')
self.writeln(
' '.join(["\t\tvhpcomp $(VHPCOMP_FLAGS)",
"-work",
lib + "=." + shell.makefile_slash_char() + lib,
"$< "]))
self.writeln("\t\t@" + shell.mkdir_command() + self.writeln("\t\t@" + shell.mkdir_command() +
" $(dir $@) && " + shell.touch_command() + " $@\n") " $(dir $@) && " + shell.touch_command() + " $@\n")
self.writeln() self.writeln()
...@@ -228,14 +199,7 @@ fuse: ...@@ -228,14 +199,7 @@ fuse:
# if len(vhdl_file.depends_on) != 0: # if len(vhdl_file.depends_on) != 0:
self.write(os.path.join(lib, purename, "." + purename) + ":") self.write(os.path.join(lib, purename, "." + purename) + ":")
for dep_file in vhdl_file.depends_on: for dep_file in vhdl_file.depends_on:
if dep_file in fileset: self.write(" \\\n" + self.get_stamp_file(dep_file))
name = dep_file.purename
self.write(
" \\\n" + os.path.join(dep_file.library,
name, "." + name + "_" +
dep_file.extension()))
else:
self.write(" \\\n" + os.path.join(dep_file.rel_path()))
self.write('\n') self.write('\n')
self.writeln("\t\t@" + shell.mkdir_command() + self.writeln("\t\t@" + shell.mkdir_command() +
" $(dir $@) && " + shell.touch_command() + " $@\n") " $(dir $@) && " + shell.touch_command() + " $@\n")
...@@ -29,6 +29,7 @@ import logging ...@@ -29,6 +29,7 @@ import logging
import six import six
from ..util import shell from ..util import shell
from ..util import path as path_mod
class ToolMakefile(object): class ToolMakefile(object):
...@@ -97,6 +98,15 @@ class ToolMakefile(object): ...@@ -97,6 +98,15 @@ class ToolMakefile(object):
else: else:
return self.TOOL_INFO["linux_bin"] return self.TOOL_INFO["linux_bin"]
def get_stamp_file(self, dep_file):
"""Stamp file for source file :param file:"""
name = dep_file.purename
return os.path.join(dep_file.library, name, ".{}_{}".format(name, dep_file.extension()))
def _makefile_sim_file_touch_stamp(self):
self.write("\t\t@" + shell.mkdir_command() + " $(dir $@)")
self.writeln(" && " + shell.touch_command() + " $@ \n")
def makefile_check_tool(self, path_key): def makefile_check_tool(self, path_key):
"""Check if the binary is available in the O.S. environment""" """Check if the binary is available in the O.S. environment"""
name = self.TOOL_INFO['name'] name = self.TOOL_INFO['name']
......
...@@ -63,11 +63,6 @@ TOP_MODULE := {top_module} ...@@ -63,11 +63,6 @@ TOP_MODULE := {top_module}
self.writeln("#target for performing local simulation\n" self.writeln("#target for performing local simulation\n"
"local: sim_pre_cmd simulation sim_post_cmd\n") "local: sim_pre_cmd simulation sim_post_cmd\n")
def get_stamp_file(self, dep_file):
"""Stamp file for source file :param file:"""
name = dep_file.purename
return os.path.join(dep_file.library, name, ".{}_{}".format(name, dep_file.extension()))
def _makefile_sim_sources_lang(self, name, klass): def _makefile_sim_sources_lang(self, name, klass):
"""Generic method to write the simulation Makefile HDL sources""" """Generic method to write the simulation Makefile HDL sources"""
fileset = self.fileset fileset = self.fileset
...@@ -104,10 +99,6 @@ TOP_MODULE := {top_module} ...@@ -104,10 +99,6 @@ TOP_MODULE := {top_module}
self.write(" \\\n{}".format(path_mod.relpath(dep_file, cwd))) self.write(" \\\n{}".format(path_mod.relpath(dep_file, cwd)))
self.writeln() self.writeln()
def _makefile_sim_file_touch_stamp(self):
self.write("\t\t@" + shell.mkdir_command() + " $(dir $@)")
self.writeln(" && " + shell.touch_command() + " $@ \n")
def _makefile_sim_dep_files(self): def _makefile_sim_dep_files(self):
"""Print dummy targets to handle file dependencies""" """Print dummy targets to handle file dependencies"""
for file_aux in self.fileset.sort(): for file_aux in self.fileset.sort():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment