First tests towards hierarchical behavior

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