Some code style change and minor issues solved

parent cd97a8be
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
"""The Action package provides the full set of provided user functionalities""" """The Action package provides the full set of provided user functionalities"""
from .action import Action
from .check import ActionCheck from .check import ActionCheck
from .core import ActionCore from .core import ActionCore
from .tree import ActionTree from .tree import ActionTree
...@@ -30,4 +32,3 @@ from .synthesis import ActionSynthesis ...@@ -30,4 +32,3 @@ from .synthesis import ActionSynthesis
from .simulation import ActionSimulation from .simulation import ActionSimulation
from .qsys_hw_tcl_update import QsysHwTclUpdate from .qsys_hw_tcl_update import QsysHwTclUpdate
from .action import Action
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
from __future__ import print_function from __future__ import print_function
import os import os
import logging import logging
import platform
from subprocess import PIPE, Popen from subprocess import PIPE, Popen
import sys import sys
......
...@@ -53,8 +53,9 @@ class ActionCore(Action): ...@@ -53,8 +53,9 @@ class ActionCore(Action):
def clean(self): def clean(self):
"""Delete the local copy of the fetched modules""" """Delete the local copy of the fetched modules"""
logging.info("Removing fetched modules..") logging.info("Removing fetched modules..")
remove_list = [mod_aux for mod_aux in self if remove_list = [mod_aux for mod_aux in self
mod_aux.source in [fetch.GIT, fetch.SVN] and mod_aux.isfetched] if mod_aux.source in [fetch.GIT, fetch.SVN]
and mod_aux.isfetched]
remove_list.reverse() # we will remove modules in backward order remove_list.reverse() # we will remove modules in backward order
if len(remove_list): if len(remove_list):
for mod_aux in remove_list: for mod_aux in remove_list:
......
...@@ -33,9 +33,9 @@ from hdlmake.tools import ( ...@@ -33,9 +33,9 @@ from hdlmake.tools import (
ToolIVerilog, ToolISim, ToolModelsim, ToolIVerilog, ToolISim, ToolModelsim,
ToolActiveHDL, ToolRiviera, ToolGHDL) ToolActiveHDL, ToolRiviera, ToolGHDL)
from .action import Action class ActionSimulation(
ToolIVerilog, ToolISim, ToolModelsim,
class ActionSimulation(Action): ToolActiveHDL, ToolRiviera, ToolGHDL):
"""This class contains the simulation specific methods""" """This class contains the simulation specific methods"""
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
from __future__ import print_function from __future__ import print_function
import logging import logging
import sys import sys
import os
from hdlmake.srcfile import SourceFileFactory from hdlmake.srcfile import SourceFileFactory
from hdlmake.util import path from hdlmake.util import path
...@@ -34,9 +33,9 @@ from hdlmake.tools import ( ...@@ -34,9 +33,9 @@ from hdlmake.tools import (
ToolISE, ToolPlanAhead, ToolVivado, ToolISE, ToolPlanAhead, ToolVivado,
ToolQuartus, ToolDiamond, ToolLibero) ToolQuartus, ToolDiamond, ToolLibero)
from .action import Action
class ActionSynthesis(Action): class ActionSynthesis(ToolISE, ToolPlanAhead, ToolVivado,
ToolQuartus, ToolDiamond, ToolLibero):
"""Class providing the public synthesis methods for the user""" """Class providing the public synthesis methods for the user"""
...@@ -67,7 +66,6 @@ class ActionSynthesis(Action): ...@@ -67,7 +66,6 @@ class ActionSynthesis(Action):
from string import Template from string import Template
from datetime import date from datetime import date
import getpass import getpass
today = date.today() today = date.today()
date_string = today.strftime("%Y%m%d") date_string = today.strftime("%Y%m%d")
template = Template("""library ieee; template = Template("""library ieee;
...@@ -106,7 +104,6 @@ end sdb_meta_pkg; ...@@ -106,7 +104,6 @@ end sdb_meta_pkg;
package body sdb_meta_pkg is package body sdb_meta_pkg is
end sdb_meta_pkg;""") end sdb_meta_pkg;""")
project_vhd = open("project.vhd", 'w') project_vhd = open("project.vhd", 'w')
date_std_logic_vector = [] date_std_logic_vector = []
import re import re
...@@ -118,7 +115,6 @@ end sdb_meta_pkg;""") ...@@ -118,7 +115,6 @@ end sdb_meta_pkg;""")
syn_tool_std_logic_vector = [] syn_tool_std_logic_vector = []
for digit in syn_tool_version: for digit in syn_tool_version:
syn_tool_std_logic_vector.append("{0:04b}".format(int(digit))) syn_tool_std_logic_vector.append("{0:04b}".format(int(digit)))
template.substitute( template.substitute(
repo_url=self.top_module.url, repo_url=self.top_module.url,
syn_module_name=self.top_module.manifest_dict["syn_top"], syn_module_name=self.top_module.manifest_dict["syn_top"],
...@@ -164,24 +160,18 @@ end sdb_meta_pkg;""") ...@@ -164,24 +160,18 @@ end sdb_meta_pkg;""")
tool_object = self._load_synthesis_tool() tool_object = self._load_synthesis_tool()
tool_info = tool_object.TOOL_INFO tool_info = tool_object.TOOL_INFO
tool_ctrl = tool_object.TCL_CONTROLS
path_key = tool_info['id'] + '_path' path_key = tool_info['id'] + '_path'
version_key = tool_info['id'] + '_version' version_key = tool_info['id'] + '_version'
name = tool_info['name'] name = tool_info['name']
id_value = tool_info['id'] id_value = tool_info['id']
ext_value = tool_info['project_ext']
env = self.env env = self.env
env.check_general() env.check_general()
env.check_tool(tool_object) env.check_tool(tool_object)
top_module = self.get_top_module() top_module = self.get_top_module()
if env[path_key]: if env[path_key]:
tool_path = env[path_key] tool_path = env[path_key]
else: else:
tool_path = "" tool_path = ""
if not self.env.options.force: if not self.env.options.force:
if self.env[path_key] is None: if self.env[path_key] is None:
logging.error("Can't generate the " + name + " project. " logging.error("Can't generate the " + name + " project. "
...@@ -194,19 +184,8 @@ end sdb_meta_pkg;""") ...@@ -194,19 +184,8 @@ end sdb_meta_pkg;""")
sys.exit("Exiting") sys.exit("Exiting")
logging.info("Generating project for " + name + " v. %s", logging.info("Generating project for " + name + " v. %s",
env[version_key]) env[version_key])
if (os.path.exists(self.top_module.manifest_dict["syn_project"]) or
os.path.exists(self.top_module.manifest_dict["syn_project"] + "."
+ ext_value)):
logging.info("Existing project detected: updating...")
update = True
else:
logging.info("No previous project: creating a new one...")
update = False
top_mod = self.get_top_module() top_mod = self.get_top_module()
fileset = self.build_file_set(top_mod.manifest_dict["syn_top"]) fileset = self.build_file_set(top_mod.manifest_dict["syn_top"])
sup_files = self.build_complete_file_set() sup_files = self.build_complete_file_set()
privative_files = [] privative_files = []
for file_aux in sup_files: for file_aux in sup_files:
...@@ -217,14 +196,12 @@ end sdb_meta_pkg;""") ...@@ -217,14 +196,12 @@ end sdb_meta_pkg;""")
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)
sff = SourceFileFactory() sff = SourceFileFactory()
if self.env.options.generate_project_vhd: if self.env.options.generate_project_vhd:
self._write_project_vhd(id_value, env[version_key]) self._write_project_vhd(id_value, env[version_key])
fileset.add([sff.new(path=path.rel2abs("project.vhd"), fileset.add([sff.new(path=path.rel2abs("project.vhd"),
module=self.get_module_by_path("."))]) module=self.get_module_by_path("."))])
tool_object.makefile_includes(top_module)
tool_object._print_incl_makefiles(top_module)
tool_object.makefile_syn_top(top_module, tool_path) tool_object.makefile_syn_top(top_module, tool_path)
tool_object.makefile_syn_tcl(top_module) tool_object.makefile_syn_tcl(top_module)
tool_object.makefile_syn_files(fileset) tool_object.makefile_syn_files(fileset)
......
...@@ -96,8 +96,8 @@ sim_post_cmd: ...@@ -96,8 +96,8 @@ sim_post_cmd:
def makefile_sim_clean(self): def makefile_sim_clean(self):
"""Generic method to write the simulation Makefile user clean target""" """Generic method to write the simulation Makefile user clean target"""
self._print_tool_clean() self.makefile_clean()
self._print_tool_mrproper() self.makefile_mrproper()
def makefile_sim_phony(self, top_module): def makefile_sim_phony(self, top_module):
"""Print simulation PHONY target list to the Makefile""" """Print simulation PHONY target list to the Makefile"""
......
...@@ -213,12 +213,12 @@ syn_post_bitstream_cmd: ...@@ -213,12 +213,12 @@ 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"""
self._print_tool_clean() self.makefile_clean()
self.writeln("\t\t" + path_mod.del_command() + self.writeln("\t\t" + path_mod.del_command() +
" synthesize translate map par bitstream") " synthesize translate map par bitstream")
self.writeln("\t\t" + path_mod.del_command() + self.writeln("\t\t" + path_mod.del_command() +
" tcl_synthesize tcl_translate tcl_map tcl_par tcl_bitstream") " tcl_synthesize tcl_translate tcl_map tcl_par tcl_bitstream")
self._print_tool_mrproper() self.makefile_mrproper()
def makefile_syn_phony(self): def makefile_syn_phony(self):
"""Print synthesis PHONY target list to the Makefile""" """Print synthesis PHONY target list to the Makefile"""
......
...@@ -26,13 +26,14 @@ ...@@ -26,13 +26,14 @@
import os import os
from hdlmake.util import path as path_mod from hdlmake.util import path as path_mod
from hdlmake.action import Action
class ToolMakefile(Action):
class ToolMakefile(object):
"""Class that provides the Makefile writing methods and status""" """Class that provides the Makefile writing methods and status"""
def __init__(self, filename=None): def __init__(self, filename=None):
super(ToolMakefile, self).__init__()
self._file = None self._file = None
self._initialized = False self._initialized = False
self._tool_info = {} self._tool_info = {}
...@@ -49,13 +50,13 @@ class ToolMakefile(object): ...@@ -49,13 +50,13 @@ class ToolMakefile(object):
if self._file: if self._file:
self._file.close() self._file.close()
def _print_incl_makefiles(self, top_module): def makefile_includes(self, top_module):
"""Add the included makefiles that need to be previously loaded""" """Add the included makefiles that need to be previously loaded"""
for file_aux in top_module.incl_makefiles: for file_aux in 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)
def _print_tool_clean(self): def makefile_clean(self):
"""Print the Makefile target for cleaning intermediate files""" """Print the Makefile target for cleaning intermediate files"""
self.writeln("#target for cleaning intermediate files") self.writeln("#target for cleaning intermediate files")
self.writeln("clean:") self.writeln("clean:")
...@@ -63,7 +64,7 @@ class ToolMakefile(object): ...@@ -63,7 +64,7 @@ class ToolMakefile(object):
" $(LIBS) " + ' '.join(self._clean_targets["clean"]) " $(LIBS) " + ' '.join(self._clean_targets["clean"])
self.writeln(tmp) self.writeln(tmp)
def _print_tool_mrproper(self): def makefile_mrproper(self):
"""Print the Makefile target for cleaning final files""" """Print the Makefile target for cleaning final files"""
self.writeln("#target for cleaning final files") self.writeln("#target for cleaning final files")
self.writeln("mrproper: clean") self.writeln("mrproper: clean")
......
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