First tests towards hierarchical behavior

parent 03455340
...@@ -112,13 +112,14 @@ def _load_syn_tool(modules_pool): ...@@ -112,13 +112,14 @@ def _load_syn_tool(modules_pool):
'quartus': ToolQuartus, 'quartus': ToolQuartus,
'diamond': ToolDiamond, 'diamond': ToolDiamond,
'libero': ToolLibero} 'libero': ToolLibero}
manifest_dict = modules_pool.get_top_module().manifest_dict for mod in modules_pool:
tool_name = manifest_dict['syn_tool'] if 'syn_tool' in mod.manifest_dict:
if tool_name in available_tools: tool_name = mod.manifest_dict['syn_tool']
return available_tools[tool_name]() if tool_name in available_tools:
else: logging.debug("Tool to be used found: %s", tool_name)
logging.error("Unknown synthesis tool: %s", tool_name) return available_tools[tool_name]()
quit() logging.error("Unknown synthesis tool: %s", tool_name)
quit()
def _load_sim_tool(modules_pool): def _load_sim_tool(modules_pool):
...@@ -145,21 +146,27 @@ def _load_sim_tool(modules_pool): ...@@ -145,21 +146,27 @@ def _load_sim_tool(modules_pool):
def _auto_pilot(modules_pool): def _auto_pilot(modules_pool):
"""Scan the design to select and run the automatic flow""" """Scan the design to select and run the automatic flow"""
for mod in modules_pool:
print(mod.action)
if mod.action is not None:
action = mod.action
logging.debug("Action to be executed found: %s", action)
break
top_mod = modules_pool.get_top_module() top_mod = modules_pool.get_top_module()
logging.info("Running automatic flow.") logging.info("Running automatic flow.")
if not top_mod.action: if not action:
logging.error("`action' manifest variable has to be specified. " logging.error("`action' manifest variable has to be specified. "
"Otherwise hdlmake doesn't know how to handle the " "Otherwise hdlmake doesn't know how to handle the "
"project.") "project.")
quit() quit()
if top_mod.action == "simulation": if action == "simulation":
sim_writer = _load_sim_tool(modules_pool) sim_writer = _load_sim_tool(modules_pool)
sim_writer.simulation_makefile(modules_pool) sim_writer.simulation_makefile(modules_pool)
elif top_mod.action == "synthesis": elif action == "synthesis":
syn_writer = _load_syn_tool(modules_pool) syn_writer = _load_syn_tool(modules_pool)
syn_writer.synthesis_project(modules_pool) syn_writer.synthesis_project(modules_pool)
# modules_pool.synthesis_makefile() # modules_pool.synthesis_makefile()
elif top_mod.action == "qsys_hw_tcl_update": elif action == "qsys_hw_tcl_update":
if not top_mod.manifest_dict["hw_tcl_filename"]: if not top_mod.manifest_dict["hw_tcl_filename"]:
logging.error("'hw_tcl_filename' manifest variable has to be " logging.error("'hw_tcl_filename' manifest variable has to be "
"specified. Otherwise hdlmake doesn't know which" "specified. Otherwise hdlmake doesn't know which"
......
...@@ -92,11 +92,16 @@ class ActionCore(Action): ...@@ -92,11 +92,16 @@ class ActionCore(Action):
def fetch(self): def fetch(self):
"""Fetch the missing required modules from their remote origin""" """Fetch the missing required modules from their remote origin"""
top_module = self.get_top_module()
logging.info("Fetching needed modules.") logging.info("Fetching needed modules.")
os.system(top_module.manifest_dict["fetch_pre_cmd"]) for mod in self:
if mod.isfetched:
if 'fetch_pre_cmd' in mod.manifest_dict:
os.system(mod.manifest_dict.get("fetch_pre_cmd", ''))
self._fetch_all() self._fetch_all()
os.system(top_module.manifest_dict["fetch_post_cmd"]) for mod in self:
if mod.isfetched:
if 'fetch_post_cmd' in mod.manifest_dict:
os.system(mod.manifest_dict.get("fetch_post_cmd", ''))
logging.info("All modules fetched.") logging.info("All modules fetched.")
def clean(self): def clean(self):
......
...@@ -384,12 +384,12 @@ types:[<type 'int'>] ...@@ -384,12 +384,12 @@ types:[<type 'int'>]
pass pass
# Set the default values for those values that were not produced # Set the default values for those values that were not produced
# by the Python exec operation. # by the Python exec operation.
for opt in self.options: #for opt in self.options:
try: # try:
if opt.name not in ret: # if opt.name not in ret:
ret[opt.name] = opt.default # ret[opt.name] = opt.default
except AttributeError: # no default value in the option # except AttributeError: # no default value in the option
pass # pass
return ret return ret
......
...@@ -51,64 +51,68 @@ class ModuleContent(ModuleCore): ...@@ -51,64 +51,68 @@ class ModuleContent(ModuleCore):
def _process_manifest_modules(self): def _process_manifest_modules(self):
"""Process the submodules required by the HDLMake module""" """Process the submodules required by the HDLMake module"""
if self.manifest_dict["fetchto"] is not None: if ("fetchto" in self.manifest_dict and
self.manifest_dict["fetchto"] is not None):
fetchto = path_mod.rel2abs(self.manifest_dict["fetchto"], fetchto = path_mod.rel2abs(self.manifest_dict["fetchto"],
self.path) self.path)
else: else:
fetchto = self.fetchto() fetchto = self.fetchto()
# Process required modules # Process required modules
if "local" in self.manifest_dict["modules"]: if "modules" in self.manifest_dict:
local_paths = path_mod.flatten_list(
self.manifest_dict["modules"]["local"])
local_mods = []
for path in local_paths:
if path_mod.is_abs_path(path):
logging.error("Found an absolute path (" + path +
") in a manifest(" + self.path + ")")
quit()
path = path_mod.rel2abs(path, self.path)
local_mods.append(self.pool.new_module(parent=self,
url=path,
source=fetch.LOCAL,
fetchto=fetchto))
self.local = local_mods
else:
self.local = []
if "svn" in self.manifest_dict["modules"]: if "local" in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["svn"] = path_mod.flatten_list( local_paths = path_mod.flatten_list(
self.manifest_dict["modules"]["svn"]) self.manifest_dict["modules"]["local"])
svn_mods = [] local_mods = []
for url in self.manifest_dict["modules"]["svn"]: for path in local_paths:
svn_mods.append(self.pool.new_module(parent=self, if path_mod.is_abs_path(path):
url=url, logging.error("Found an absolute path (" + path +
source=fetch.SVN, ") in a manifest(" + self.path + ")")
fetchto=fetchto)) quit()
self.svn = svn_mods path = path_mod.rel2abs(path, self.path)
else: local_mods.append(self.pool.new_module(parent=self,
self.svn = [] url=path,
source=fetch.LOCAL,
fetchto=fetchto))
self.local = local_mods
else:
self.local = []
if "git" in self.manifest_dict["modules"]: if "svn" in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["git"] = path_mod.flatten_list( self.manifest_dict["modules"]["svn"] = path_mod.flatten_list(
self.manifest_dict["modules"]["git"]) self.manifest_dict["modules"]["svn"])
git_mods = [] svn_mods = []
for url in self.manifest_dict["modules"]["git"]: for url in self.manifest_dict["modules"]["svn"]:
git_mods.append(self.pool.new_module(parent=self, svn_mods.append(self.pool.new_module(parent=self,
url=url, url=url,
source=fetch.GIT, source=fetch.SVN,
fetchto=fetchto)) fetchto=fetchto))
self.git = git_mods self.svn = svn_mods
else: else:
self.git = [] self.svn = []
if "git" in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["git"] = path_mod.flatten_list(
self.manifest_dict["modules"]["git"])
git_mods = []
for url in self.manifest_dict["modules"]["git"]:
git_mods.append(self.pool.new_module(parent=self,
url=url,
source=fetch.GIT,
fetchto=fetchto))
self.git = git_mods
else:
self.git = []
def _process_manifest_makefiles(self): def _process_manifest_makefiles(self):
"""Get the extra makefiles defined in the HDLMake module""" """Get the extra makefiles defined in the HDLMake module"""
# Included Makefiles # Included Makefiles
included_makefiles_aux = [] included_makefiles_aux = []
if isinstance(self.manifest_dict["incl_makefiles"], six.string_types): if "incl_makefiles" in self.manifest_dict:
included_makefiles_aux.append(self.manifest_dict["incl_makefiles"]) if isinstance(self.manifest_dict["incl_makefiles"], six.string_types):
else: # list included_makefiles_aux.append(self.manifest_dict["incl_makefiles"])
included_makefiles_aux = self.manifest_dict["incl_makefiles"][:] else: # list
included_makefiles_aux = self.manifest_dict["incl_makefiles"][:]
makefiles_paths = self._make_list_of_paths(included_makefiles_aux) makefiles_paths = self._make_list_of_paths(included_makefiles_aux)
self.incl_makefiles.extend(makefiles_paths) self.incl_makefiles.extend(makefiles_paths)
...@@ -135,8 +135,10 @@ class ModuleCore(ModuleConfig): ...@@ -135,8 +135,10 @@ class ModuleCore(ModuleConfig):
# if "top_module" in self.manifest_dict: # if "top_module" in self.manifest_dict:
# self.top_module = self.manifest_dict["top_module"] # self.top_module = self.manifest_dict["top_module"]
# Libraries # Libraries
self.library = self.manifest_dict["library"] if "library" in self.manifest_dict:
self.action = self.manifest_dict["action"].lower() self.library = self.manifest_dict["library"]
if "action" in self.manifest_dict:
self.action = self.manifest_dict["action"].lower()
def _create_file_list_from_paths(self, paths): def _create_file_list_from_paths(self, paths):
""" """
...@@ -147,9 +149,15 @@ class ModuleCore(ModuleConfig): ...@@ -147,9 +149,15 @@ class ModuleCore(ModuleConfig):
srcs = SourceFileSet() srcs = SourceFileSet()
# Check if this is the top module and grab the include_dirs # Check if this is the top module and grab the include_dirs
if self.parent is None: if self.parent is None:
include_dirs = self.manifest_dict['include_dirs'] if 'include_dirs' in self.manifest_dict:
include_dirs = self.manifest_dict['include_dirs']
else:
include_dirs = []
else: else:
include_dirs = self.top_module.manifest_dict['include_dirs'] if 'include_dirs' in self.manifest_dict:
include_dirs = self.top_module.manifest_dict['include_dirs']
else:
include_dirs = []
for path_aux in paths: for path_aux in paths:
if os.path.isdir(path_aux): if os.path.isdir(path_aux):
dir_ = os.listdir(path_aux) dir_ = os.listdir(path_aux)
......
...@@ -126,19 +126,28 @@ class Module(ModuleContent): ...@@ -126,19 +126,28 @@ class Module(ModuleContent):
include_dirs_list = self.get_include_dirs_list() include_dirs_list = self.get_include_dirs_list()
for file_aux in self.files: for file_aux in self.files:
if isinstance(file_aux, VerilogFile): if isinstance(file_aux, VerilogFile):
file_aux.vsim_opt = self.manifest_dict["vsim_opt"] if "vsim_opt" in self.manifest_dict:
file_aux.vsim_opt = self.manifest_dict["vsim_opt"]
else:
file_aux.vsim_opt = ''
file_aux.include_dirs = include_dirs_list file_aux.include_dirs = include_dirs_list
elif isinstance(file_aux, SVFile): elif isinstance(file_aux, SVFile):
file_aux.vsim_opt = self.manifest_dict["vsim_opt"] if "vsim_opt" in self.manifest_dict:
file_aux.vsim_opt = self.manifest_dict["vsim_opt"]
else:
file_aux.vsim_opt = ''
file_aux.include_dirs = include_dirs_list file_aux.include_dirs = include_dirs_list
elif isinstance(file_aux, VHDLFile): elif isinstance(file_aux, VHDLFile):
file_aux.vcom_opt = self.manifest_dict["vcom_opt"] if "vcom_opt" in self.manifest_dict:
file_aux.vcom_opt = self.manifest_dict["vcom_opt"]
else:
file_aux.vcom_opt = ''
def get_include_dirs_list(self): def get_include_dirs_list(self):
"""Private method that processes the included directory list""" """Private method that processes the included directory list"""
# Include dirs # Include dirs
include_dirs = [] include_dirs = []
if self.manifest_dict["include_dirs"] is not None: if "include_dirs" in self.manifest_dict:
if isinstance(self.manifest_dict["include_dirs"], if isinstance(self.manifest_dict["include_dirs"],
six.string_types): six.string_types):
dir_list = path_mod.compose( dir_list = path_mod.compose(
......
"""Module providing the synthesis functionality for writing Makefiles""" """Module providing the synthesis functionality for writing Makefiles"""
from __future__ import absolute_import from __future__ import absolute_import
import sys import os, sys
import logging import logging
import string import string
...@@ -41,11 +41,20 @@ class ToolSyn(ToolMakefile): ...@@ -41,11 +41,20 @@ class ToolSyn(ToolMakefile):
def synthesis_project(self, pool): def synthesis_project(self, pool):
"""Generate a project for the specific synthesis tool""" """Generate a project for the specific synthesis tool"""
_check_synthesis_manifest(pool.top_module.manifest_dict)
pool.check_all_fetched_or_quit() pool.check_all_fetched_or_quit()
manifest_project_dict = {}
for mod in pool:
manifest_project_dict.update(mod.manifest_dict)
if 'fetchto' in mod.manifest_dict:
self.repo_list.append(
os.path.abspath(
os.path.join(
mod.path,
mod.manifest_dict['fetchto'])))
_check_synthesis_manifest(manifest_project_dict)
top_module = pool.get_top_module() top_module = pool.get_top_module()
fileset = pool.build_file_set( fileset = pool.build_file_set(
top_module.manifest_dict["syn_top"], manifest_project_dict["syn_top"],
standard_libs=self._standard_libs) standard_libs=self._standard_libs)
sup_files = pool.build_complete_file_set() sup_files = pool.build_complete_file_set()
privative_files = [] privative_files = []
...@@ -57,7 +66,7 @@ class ToolSyn(ToolMakefile): ...@@ -57,7 +66,7 @@ class ToolSyn(ToolMakefile):
logging.info("Detected %d supported files that are not parseable", logging.info("Detected %d supported files that are not parseable",
len(privative_files)) len(privative_files))
fileset.add(privative_files) fileset.add(privative_files)
self.makefile_setup(top_module, fileset) self.makefile_setup(manifest_project_dict, fileset)
self.makefile_check_tool('syn_path') self.makefile_check_tool('syn_path')
self.makefile_includes() self.makefile_includes()
self.makefile_syn_top() self.makefile_syn_top()
...@@ -90,10 +99,10 @@ endif ...@@ -90,10 +99,10 @@ endif
""") """)
self.writeln(top_parameter.substitute( self.writeln(top_parameter.substitute(
tcl_interpreter=tcl_interpreter, tcl_interpreter=tcl_interpreter,
project_name=self.top_module.manifest_dict["syn_project"], project_name=self.manifest_dict["syn_project"],
project_ext=self._tool_info["project_ext"], project_ext=self._tool_info["project_ext"],
tool_path=self.top_module.manifest_dict["syn_path"], tool_path=self.manifest_dict["syn_path"],
top_module=self.top_module.manifest_dict["syn_top"])) top_module=self.manifest_dict["syn_top"]))
def makefile_syn_tcl(self): def makefile_syn_tcl(self):
"""Create the Makefile TCL dictionary for the selected tool""" """Create the Makefile TCL dictionary for the selected tool"""
...@@ -255,30 +264,30 @@ syn_post_bitstream_cmd: ...@@ -255,30 +264,30 @@ syn_post_bitstream_cmd:
""") """)
self.writeln(syn_command.substitute( self.writeln(syn_command.substitute(
syn_pre_cmd=self.top_module.manifest_dict[ syn_pre_cmd=self.manifest_dict.get(
"syn_pre_cmd"], "syn_pre_cmd", ''),
syn_post_cmd=self.top_module.manifest_dict[ syn_post_cmd=self.manifest_dict.get(
"syn_post_cmd"], "syn_post_cmd", ''),
syn_pre_synthesize_cmd=self.top_module.manifest_dict[ syn_pre_synthesize_cmd=self.manifest_dict.get(
"syn_pre_synthesize_cmd"], "syn_pre_synthesize_cmd", ''),
syn_post_synthesize_cmd=self.top_module.manifest_dict[ syn_post_synthesize_cmd=self.manifest_dict.get(
"syn_post_synthesize_cmd"], "syn_post_synthesize_cmd", ''),
syn_pre_translate_cmd=self.top_module.manifest_dict[ syn_pre_translate_cmd=self.manifest_dict.get(
"syn_pre_translate_cmd"], "syn_pre_translate_cmd", ''),
syn_post_translate_cmd=self.top_module.manifest_dict[ syn_post_translate_cmd=self.manifest_dict.get(
"syn_post_translate_cmd"], "syn_post_translate_cmd", ''),
syn_pre_map_cmd=self.top_module.manifest_dict[ syn_pre_map_cmd=self.manifest_dict.get(
"syn_pre_map_cmd"], "syn_pre_map_cmd", ''),
syn_post_map_cmd=self.top_module.manifest_dict[ syn_post_map_cmd=self.manifest_dict.get(
"syn_post_map_cmd"], "syn_post_map_cmd", ''),
syn_pre_par_cmd=self.top_module.manifest_dict[ syn_pre_par_cmd=self.manifest_dict.get(
"syn_pre_par_cmd"], "syn_pre_par_cmd", ''),
syn_post_par_cmd=self.top_module.manifest_dict[ syn_post_par_cmd=self.manifest_dict.get(
"syn_post_par_cmd"], "syn_post_par_cmd", ''),
syn_pre_bitstream_cmd=self.top_module.manifest_dict[ syn_pre_bitstream_cmd=self.manifest_dict.get(
"syn_pre_bitstream_cmd"], "syn_pre_bitstream_cmd", ''),
syn_post_bitstream_cmd=self.top_module.manifest_dict[ syn_post_bitstream_cmd=self.manifest_dict.get(
"syn_post_bitstream_cmd"])) "syn_post_bitstream_cmd", '')))
def makefile_syn_clean(self): def makefile_syn_clean(self):
"""Print the Makefile clean target for synthesis""" """Print the Makefile clean target for synthesis"""
......
...@@ -45,7 +45,7 @@ class ToolMakefile(object): ...@@ -45,7 +45,7 @@ class ToolMakefile(object):
self._hdl_files = [] self._hdl_files = []
self._supported_files = [] self._supported_files = []
self._standard_libs = [] self._standard_libs = []
self.top_module = None self.repo_list = []
self.fileset = None self.fileset = None
if filename: if filename:
self._filename = filename self._filename = filename
...@@ -56,9 +56,9 @@ class ToolMakefile(object): ...@@ -56,9 +56,9 @@ class ToolMakefile(object):
if self._file: if self._file:
self._file.close() self._file.close()
def makefile_setup(self, top_module, fileset): def makefile_setup(self, manifest_project_dict, fileset):
"""Set the Makefile configuration""" """Set the Makefile configuration"""
self.top_module = top_module self.manifest_dict = manifest_project_dict
self.fileset = fileset self.fileset = fileset
def makefile_check_tool(self, path_key): def makefile_check_tool(self, path_key):
...@@ -94,28 +94,31 @@ class ToolMakefile(object): ...@@ -94,28 +94,31 @@ class ToolMakefile(object):
bin_name = tool_info['linux_bin'] bin_name = tool_info['linux_bin']
name = tool_info['name'] name = tool_info['name']
logging.debug("Checking if " + name + " tool is available on PATH") logging.debug("Checking if " + name + " tool is available on PATH")
if self.top_module.manifest_dict[path_key] is not None: if path_key in self.manifest_dict:
if _is_in_path(bin_name, self.top_module.manifest_dict[path_key]): if _is_in_path(bin_name, self.manifest_dict[path_key]):
logging.info("%s found under HDLMAKE_%s: %s", logging.info("%s found under HDLMAKE_%s: %s",
name, path_key.upper(), name, path_key.upper(),
self.top_module.manifest_dict[path_key]) self.manifest_dict[path_key])
else: else:
logging.warning("%s NOT found under HDLMAKE_%s: %s", logging.warning("%s NOT found under HDLMAKE_%s: %s",
name, path_key.upper(), name, path_key.upper(),
self.top_module.manifest_dict[path_key]) self.manifest_dict[path_key])
self.manifest_dict[path_key] = ''
else: else:
if _check_in_system_path(bin_name): if _check_in_system_path(bin_name):
self.top_module.manifest_dict[path_key] = _get_path(bin_name) self.manifest_dict[path_key] = _get_path(bin_name)
logging.info("%s found in system PATH: %s", logging.info("%s found in system PATH: %s",
name, self.top_module.manifest_dict[path_key]) name, self.manifest_dict[path_key])
else: else:
logging.warning("%s cannnot be found in system PATH", name) logging.warning("%s cannnot be found in system PATH", name)
self.manifest_dict[path_key] = ''
def makefile_includes(self): def makefile_includes(self):
"""Add the included makefiles that need to be previously loaded""" """Add the included makefiles that need to be previously loaded"""
for file_aux in self.top_module.incl_makefiles: #for file_aux in self.top_module.incl_makefiles:
if os.path.exists(file_aux): # if os.path.exists(file_aux):
self.write("include %s\n" % file_aux) # self.write("include %s\n" % file_aux)
pass
def makefile_clean(self): def makefile_clean(self):
"""Print the Makefile target for cleaning intermediate files""" """Print the Makefile target for cleaning intermediate files"""
......
...@@ -62,18 +62,20 @@ class ToolXilinx(ToolSyn): ...@@ -62,18 +62,20 @@ class ToolXilinx(ToolSyn):
"""Create a Xilinx synthesis project by TCL""" """Create a Xilinx synthesis project by TCL"""
prop_val = 'set_property "{0}" "{1}" [{2}]' prop_val = 'set_property "{0}" "{1}" [{2}]'
prop_opt = 'set_property -name {{{0}}} -value {{{1}}} -objects [{2}]' prop_opt = 'set_property -name {{{0}}} -value {{{1}}} -objects [{2}]'
syn_device = self.top_module.manifest_dict["syn_device"] syn_device = self.manifest_dict["syn_device"]
syn_grade = self.top_module.manifest_dict["syn_grade"] syn_grade = self.manifest_dict["syn_grade"]
syn_package = self.top_module.manifest_dict["syn_package"] syn_package = self.manifest_dict["syn_package"]
syn_top = self.top_module.manifest_dict["syn_top"] syn_top = self.manifest_dict["syn_top"]
syn_properties = self.top_module.manifest_dict["syn_properties"] syn_properties = self.manifest_dict["syn_properties"]
create_new = [] create_new = []
create_new.append(self._tcl_controls["create"]) create_new.append(self._tcl_controls["create"])
synthesize_new = [] synthesize_new = []
par_new = [] par_new = []
repo_string = '{' + " ".join(self.repo_list) + '}'
properties = [ properties = [
['part', syn_device + syn_package + syn_grade, 'current_project'], ['part', syn_device + syn_package + syn_grade, 'current_project'],
['target_language', 'VHDL', 'current_project'], ['target_language', 'VHDL', 'current_project'],
['ip_repo_paths', repo_string, 'current_project'],
['top', syn_top, 'get_property srcset [current_run]']] ['top', syn_top, 'get_property srcset [current_run]']]
if not syn_properties is None: if not syn_properties is None:
properties.extend(syn_properties) properties.extend(syn_properties)
......
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