Commit 9ea15a4b authored by Paweł Szostek's avatar Paweł Szostek

Revert "corrections suggested by linter"

This reverts commit 16860fb6.
parent 16860fb6
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
......@@ -68,7 +68,7 @@ def main():
default=None, help="List all files in a from of a space-separated string")
parser.add_option("--merge-cores=name", default=None, dest="merge_cores",
help="Merges entire synthesizable content of an project into a pair of VHDL/Verilog files")
help="Merges entire synthesizable content of an project into a pair of VHDL/Verilog files")
parser.add_option("--ise-proj", action="store_true", dest="ise_proj",
default=None, help="create/update an ise project including list of project"
......@@ -110,28 +110,27 @@ def main():
global_mod.options = options
#HANDLE PROJECT INDEPENDENT OPTIONS
if options.manifest_help is True:
if options.manifest_help == True:
from manifest_parser import ManifestParser
ManifestParser().help()
quit()
if options.print_version is True:
if options.print_version == True:
p.print_version()
quit()
# Check later if a simulation tool should have been specified
if options.make_isim is True:
if options.make_isim == True:
global_mod.sim_tool = "isim"
elif options.make_vsim is True:
elif options.make_vsim == True:
global_mod.sim_tool = "vsim"
p.info("Simulation tool: " + str(global_mod.sim_tool))
p.vprint("LoadTopManifest")
pool = ModulePool()
pool.new_module(parent=None, url=os.getcwd(), source="local", fetchto=".")
# Setting top_module as top module of design (ModulePool class)
if pool.get_top_module().manifest is None:
if pool.get_top_module().manifest == None:
p.rawprint("No manifest found. At least an empty one is needed")
p.rawprint("To see some help, type hdlmake --help")
quit()
......
......@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -23,7 +23,6 @@ import sys
import StringIO
import contextlib
@contextlib.contextmanager
def stdoutIO(stdout=None):
old = sys.stdout
......@@ -33,13 +32,12 @@ def stdoutIO(stdout=None):
yield stdout
sys.stdout = old
class ConfigParser(object):
"""Class for parsing python configuration files
Case1: Normal usage
>>> f = open("test.py", "w")
>>> f.write('modules = {"local":"/path/to/local", "svn":"path/to/svn"} ')
>>> f.write('modules = {"local":"/path/to/local", "svn":"path/to/svn"}; ')
>>> f.write('fetchto = ".."' )
>>> f.close()
>>> p = ConfigParser()
......@@ -145,15 +143,16 @@ class ConfigParser(object):
elif key == "default":
self.default = others["default"]
elif key == "type":
self.add_type(type_obj=others["type"])
self.add_type(type_obj=others["type"])
else:
raise ValueError("Option not recognized: " + key)
def add_type(self, type_obj):
self.types.append(type(type_obj))
def __init__(self, description=None):
if description is None:
def __init__(self, description = None):
if description != None:
if not isinstance(description, str):
raise ValueError("Description should be a string!")
self.description = description
......@@ -169,25 +168,25 @@ class ConfigParser(object):
def __getitem__(self, name):
if name in self.__names():
return [x for x in self.options if x is None and x.name == name][0]
return [x for x in self.options if x!= None and x.name == name][0]
else:
raise RuntimeError("No such option as " + str(name))
def help(self):
p.rawprint("Variables available in a manifest:")
for opt in self.options:
if opt is None:
if opt == None:
p.rawprint("")
continue
line = ' {0:15} {1:29} {2:45}{3}{4:10}'
line = ' {0:15}; {1:29}; {2:45}{3}{4:10}'
try:
tmp_def = opt.default
if tmp_def == "":
tmp_def = '""'
line = line.format(opt.name, str(opt.types), opt.help, ', default=', tmp_def)
except AttributeError: # no default value
line = line.format(opt.name, str(opt.types), opt.help, "", "")
line = line.format(opt.name, str(opt.types), opt.help,', default=', tmp_def)
except AttributeError: #no default value
line = line.format(opt.name, str(opt.types), opt.help, "","")
p.rawprint(line)
def add_option(self, name, **others):
......@@ -218,7 +217,7 @@ class ConfigParser(object):
def add_config_file(self, config_file):
if self.config_file is not None:
raise RuntimeError("Config file should be added only once")
import os
if not os.path.exists(config_file):
raise RuntimeError("Config file doesn't exists: " + config_file)
......@@ -229,16 +228,16 @@ class ConfigParser(object):
self.arbitrary_code += code + '\n'
def __names(self):
return [o.name for o in self.options if o is None]
return [o.name for o in self.options if o != None]
def parse(self):
options = {}
ret = {}
if self.config_file is not None:
with open(self.config_file, "r") as config_file:
content = config_file.readlines()
content = ''.join(content)
if self.config_file is not None:
with open(self.config_file, "r") as config_file:
content = open(self.config_file, "r").readlines()
content = ''.join(content)
else:
content = ''
content = self.arbitrary_code + '\n' + content
......@@ -275,14 +274,14 @@ class ConfigParser(object):
p.rawprint("> " + line)
#print "out:", s.getvalue()
except SyntaxError as e:
p.error("Invalid syntax in the manifest file " + self.config_file + ":\n" + str(e))
p.error("Invalid syntax in the manifest file " + self.config_file+ ":\n" + str(e))
quit()
except:
p.error("Encountered unexpected error while parsing " + self.config_file)
p.rawprint(str(sys.exc_info()[0]) + ':' + str(sys.exc_info()[1]))
p.rawprint(str(sys.exc_info()[0]) +':'+ str(sys.exc_info()[1]))
quit()
for opt_name, val in list(options.items()): # check delivered options
for opt_name, val in list(options.items()): #check delivered options
if opt_name.startswith('__'):
continue
if opt_name not in self.__names():
......@@ -301,15 +300,15 @@ class ConfigParser(object):
try:
for key in val:
if key not in self[opt_name].allowed_keys:
raise RuntimeError("Encountered unallowed key: " + key + " for options '" + opt_name + "'")
except AttributeError: # no allowed_keys member - don't perform any check
raise RuntimeError("Encountered unallowed key: " +key+ " for options '"+opt_name+"'")
except AttributeError: #no allowed_keys member - don't perform any check
pass
for opt in self.options: # set values for not listed items with defaults
for opt in self.options: #set values for not listed items with defaults
try:
if opt.name not in ret:
ret[opt.name] = opt.default
except AttributeError: # no default value in the option
except AttributeError: #no default value in the option
pass
return ret
......@@ -319,4 +318,4 @@ def _test():
doctest.testmod()
if __name__ == "__main__":
_test()
_test()
\ No newline at end of file
......@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -25,11 +25,11 @@ import msg as p
class Connection:
def __init__(self, ssh_user, ssh_server):
#if ssh_user is None:
#if ssh_user == None:
# ssh_user = os.getenv("HDLMAKE_USER")
self.ssh_user = ssh_user
#if ssh_server is None:
#if ssh_server == None:
# ssh_server = os.getenv("HDLMAKE_SERVER")
self.ssh_server = ssh_server
......@@ -37,7 +37,7 @@ class Connection:
return self.ssh_user + '@' + self.ssh_server
def __data_given(self):
return self.ssh_user is None and self.ssh_server is None
return self.ssh_user != None and self.ssh_server != None
def __check(self):
if not self.__data_given():
......@@ -57,7 +57,7 @@ class Connection:
"""
self.__check()
#create a new catalogue on remote machine
if dest_folder is None:
if dest_folder == None:
dest_folder = ''.join(random.choice(string.ascii_letters + string.digits) for x in range(8))
mkdir_cmd = 'mkdir -p ' + dest_folder
import msg as p
......
......@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
......@@ -25,16 +25,16 @@ import os.path
class IDependable:
def __init__(self):
self.dep_index = 0
self._dep_fixed = False
self.__dep_provides = []
self.__dep_requires = []
self.__dep_depends_on = []
self.dep_index = 0;
self._dep_fixed = False;
self.__dep_provides = [];
self.__dep_requires = [];
self.__dep_depends_on = [];
pass
#use proxy template here
def get_dep_provides(self):
if self._dep_fixed is False:
if self._dep_fixed == False:
self.__create_deps()
# self._dep_fixed = True
return self.__dep_provides
......@@ -44,7 +44,7 @@ class IDependable:
dep_provides = property(get_dep_provides, set_dep_provides)
def get_dep_requires(self):
if self._dep_fixed is False:
if self._dep_fixed == False:
self.__create_deps()
# self._dep_fixed = True
return self.__dep_requires
......@@ -66,7 +66,7 @@ class IDependable:
class DependencySolver:
def __init__(self):
self.entities = {}
self.entities = {};
def __lookup_post_provider(self, files, start_index, file):
requires = file.dep_requires
......@@ -235,8 +235,8 @@ class DependencySolver:
newobj = sf.SourceFileSet()
newobj.add(f_nondep)
newobj = sf.SourceFileSet();
newobj.add(f_nondep);
for f in fset:
try:
if not f._dep_fixed:
......
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -24,13 +24,12 @@ import msg as p
import path
import global_mod
class ModulePool(list):
class ModuleFetcher:
def __init__(self):
pass
def fetch_single_module(self, module):
import global_mod
new_modules = []
p.vprint("Fetching module: " + str(module))
......@@ -38,8 +37,8 @@ class ModulePool(list):
p.vprint("ModPath: " + module.path)
else:
p.printhr()
p.info("Fetching module: " + str(module) +
" [parent: " + str(module.parent) + "]")
p.info("Fetching module: " + str(module) +\
" [parent: " + str(module.parent) + "]")
if module.source == "svn":
p.info("[svn] Fetching to " + module.fetchto)
self.__fetch_from_svn(module)
......@@ -83,14 +82,14 @@ class ModulePool(list):
os.mkdir(module.fetchto)
cur_dir = os.getcwd()
if module.branch is None:
if module.branch == None:
module.branch = "master"
basename = path.url_basename(module.url)
mod_path = os.path.join(module.fetchto, basename)
if basename.endswith(".git"):
basename = basename[:-4] # remove trailing .git
basename = basename[:-4] #remove trailing .git
if module.isfetched:
update_only = True
......@@ -122,6 +121,7 @@ class ModulePool(list):
module.path = mod_path
return rval
def __init__(self, *args):
list.__init__(self, *args)
self.top_module = None
......@@ -145,7 +145,7 @@ class ModulePool(list):
return [m for m in self if m.url == url][0]
else:
if self.global_fetch: # if there is global fetch parameter (HDLMAKE_COREDIR env variable)
fetchto = self.global_fetch # screw module's particular fetchto
fetchto = self.global_fetch # screw module's particular fetchto
elif global_mod.top_module:
fetchto = global_mod.top_module.fetchto
......@@ -169,7 +169,7 @@ class ModulePool(list):
self.append(new_module)
return True
def fetch_all(self, unfetched_only=False):
def fetch_all(self, unfetched_only = False):
fetcher = self.ModuleFetcher()
fetch_queue = [m for m in self]
......@@ -185,11 +185,11 @@ class ModulePool(list):
new_modules = fetcher.fetch_single_module(cur_mod)
for mod in new_modules:
if not mod.isfetched:
p.vprint("Appended to fetch queue: " + str(mod.url))
p.vprint("Appended to fetch queue: " +str(mod.url))
self._add(mod)
fetch_queue.append(mod)
else:
p.vprint("NOT appended to fetch queue: " + str(mod.url))
p.vprint("NOT appended to fetch queue: " +str(mod.url))
def build_global_file_list(self):
from srcfile import SourceFileSet
......
......@@ -60,7 +60,7 @@ class ISEProject:
class StringBuffer(list):
def __init__(self):
self.append("")
self.__blank = re.compile("^[ \n]+$")
self.__blank = re.compile("^[ \t\n]+$")
def write(self, what):
if what == "":
......@@ -255,7 +255,7 @@ class ISEProject:
self.__output_libs(self.xml_libs)
output_file = open(filename, "w")
string_buffer = self.StringBuffer()
self.xml_doc.writexml(string_buffer, newl = "\n", addindent=" ")
self.xml_doc.writexml(string_buffer, newl = "\n", addindent="\t")
output_file.write('\n'.join(string_buffer))
output_file.close()
......@@ -292,7 +292,7 @@ class ISEProject:
class ModelsiminiReader(object):
def __init__(self, path = None):
if path is None:
if path == None:
path = self.modelsim_ini_dir() + "/modelsim.ini"
self.path = path
......@@ -316,7 +316,7 @@ class ModelsiminiReader(object):
reading_libraries = True
continue
if re.search(new_section, line):
if reading_libraries is True:
if reading_libraries == True:
#reading_libraries = False
break
else:
......@@ -336,7 +336,7 @@ class ModelsiminiReader(object):
class XilinxsiminiReader(object):
def __init__(self, path = None):
if path is None:
if path == None:
path = self.xilinxsim_ini_dir() + "/xilinxsim.ini"
self.path = path
......
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -28,34 +28,34 @@ class _QuartusProjectProperty:
"set_global_assignment": SET_GLOBAL_ASSIGNMENT}
def __init__(self, command, what=None, name=None, name_type=None, from_=None, to=None, section_id=None):
self.command = command
self.what = what
self.name = name
self.name_type = name_type
self.from_ = from_
self.to = to
self.section_id = section_id
self.command = command
self.what = what
self.name = name
self.name_type = name_type
self.from_ = from_
self.to = to
self.section_id = section_id
def emit(self):
words = []
words.append(dict([(b,a) for a,b in self.t.items()])[self.command])
if self.what is None:
words.append(self.what)
if self.name is None:
words.append("-name")
words.append(self.name_type)
words.append(self.name)
if self.from_ is None:
words.append("-from")
words.append(self.from_)
if self.to is None:
words.append("-to")
words.append(self.to)
if self.section_id is None:
words.append("-section_id")
words.append(self.section_id)
return ' '.join(words)
words = []
words.append(dict([(b,a) for a,b in self.t.items()])[self.command])
if self.what != None:
words.append(self.what)
if self.name != None:
words.append("-name")
words.append(self.name_type)
words.append(self.name)
if self.from_ != None:
words.append("-from")
words.append(self.from_)
if self.to != None:
words.append("-to")
words.append(self.to)
if self.section_id != None:
words.append("-section_id")
words.append(self.section_id)
return ' '.join(words)
class QuartusProject:
......@@ -73,7 +73,7 @@ class QuartusProject:
f.write(self.__emit_files())
f.write(self.__emit_scripts())
f.close()
f = open(self.filename+'.qpf', "w")
f = open(self.filename+'.qpf', "w");
f.write("PROJECT_REVISION = \"" + self.filename + "\"\n")
f.close()
......@@ -110,7 +110,7 @@ class QuartusProject:
def add_property(self, val):
#don't save files (they are unneeded)
if val.name_type is None and "_FILE" in val.name_type:
if val.name_type != None and "_FILE" in val.name_type:
return
self.properties.append(val)
......@@ -166,7 +166,7 @@ class QuartusProject:
i = i+1
continue
prop = QPP(command=command, what=what, name=name,
name_type=name_type, from_=from_, to=to, section_id=section_id)
name_type=name_type, from_=from_, to=to, section_id=section_id)
self.add_property(prop)
f.close()
......@@ -180,7 +180,7 @@ class QuartusProject:
for key in family_names:
if re.match(key, syn_device.upper()):
family = family_names[key]
family = family_names[key];
devstring = (syn_device +syn_package+syn_grade).upper()
QPP =_QuartusProjectProperty
......
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
......
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
......@@ -59,16 +59,16 @@ class HdlmakeKernel(object):
raise RuntimeError("Unrecognized or not specified simulation tool: "+ str(tm.use_compiler))
quit()
# Force declaration of sim_tool varible in Manifest
#if tm.sim_tool is None:
# p.error("sim_tool variable must be defined in the manifest")
# quit()
#if tm.sim_tool == None:
# p.error("sim_tool variable must be defined in the manifest")
# quit()
## Make distintion between isim and vsim simulators
#if tm.sim_tool == "vsim":
# self.generate_modelsim_makefile()
# self.generate_modelsim_makefile()
#elif tm.sim_tool == "isim":
# self.generate_isim_makefile()
# self.generate_isim_makefile()
#else:
# raise RuntimeError("Unrecognized sim tool: "+tm.sim_tool)
# raise RuntimeError("Unrecognized sim tool: "+tm.sim_tool)
elif tm.action == "synthesis":
if tm.syn_project is None:
p.error("syn_project variable must be defined in the manifest")
......@@ -127,8 +127,8 @@ class HdlmakeKernel(object):
p.echo(str([str(m) for m in self.modules_pool.modules if not m.isfetched]))
quit()
top_module = pool.get_top_module()
flist = pool.build_global_file_list()
flist_sorted = solver.solve(flist)
flist = pool.build_global_file_list();
flist_sorted = solver.solve(flist);
#self.make_writer.generate_modelsim_makefile(flist_sorted, top_module)
self.make_writer.generate_vsim_makefile(flist_sorted, top_module)
......@@ -144,8 +144,8 @@ class HdlmakeKernel(object):
p.echo(str([str(m) for m in self.modules_pool.modules if not m.isfetched]))
quit()
top_module = pool.get_top_module()
flist = pool.build_global_file_list()
flist_sorted = solver.solve(flist)
flist = pool.build_global_file_list();
flist_sorted = solver.solve(flist);
self.make_writer.generate_isim_makefile(flist_sorted, top_module)
def generate_iverilog_makefile(self):
......@@ -173,7 +173,7 @@ class HdlmakeKernel(object):
self.make_writer.generate_ise_makefile(top_mod=self.modules_pool.get_top_module(), ise_path=ise_path)
def generate_remote_synthesis_makefile(self):
if self.connection.ssh_user is None or self.connection.ssh_server is None:
if self.connection.ssh_user == None or self.connection.ssh_server == None:
p.warning("Connection data is not given. "
"Accessing environmental variables in the makefile")
p.info("Generating makefile for remote synthesis.")
......@@ -186,7 +186,7 @@ class HdlmakeKernel(object):
ise_path = self.__figure_out_ise_path()
tcl = self.__search_tcl_file()
if tcl is None:
if tcl == None:
self.__generate_tcl()
tcl = "run.tcl"
files = self.modules_pool.build_very_global_file_list()
......@@ -229,7 +229,7 @@ class HdlmakeKernel(object):
self.__create_new_quartus_project()
def __figure_out_ise_path(self):
if self.options.force_ise is None:
if self.options.force_ise != None:
if self.options.force_ise == 0:
ise = self.__check_ise_version()
else:
......@@ -247,7 +247,7 @@ class HdlmakeKernel(object):
return ise_path
def __is_xilinx_screwed(self):
if self.__check_ise_version() is None:
if self.__check_ise_version() == None:
return True
else:
return False
......@@ -387,7 +387,7 @@ class HdlmakeKernel(object):
files = self.modules_pool.build_very_global_file_list()
# tcl = self.__search_tcl_file()
# if tcl is None:
# if tcl == None:
self.__generate_tcl()
tcl = "run.tcl"
......@@ -411,7 +411,7 @@ class HdlmakeKernel(object):
os.chdir(cur_dir)
def __search_tcl_file(self, directory = None):
if directory is None:
if directory == None:
directory = "."
filenames = os.listdir(directory)
tcls = []
......@@ -438,7 +438,7 @@ class HdlmakeKernel(object):
remove_list.reverse() #we will remove modules in backward order
if len(remove_list):
for m in remove_list:
p.rawprint(" " + m.url + " [from: " + m.path + "]")
p.rawprint("\t" + m.url + " [from: " + m.path + "]")
m.remove_dir_from_disk()
else:
p.info("There are no modules to be removed")
......@@ -469,23 +469,23 @@ class HdlmakeKernel(object):
p.echo(str([str(m) for m in self.modules_pool.modules if not m.isfetched]))
quit()
flist = pool.build_global_file_list()
flist_sorted = solver.solve(flist)
flist = pool.build_global_file_list();
flist_sorted = solver.solve(flist);
# if not os.path.exists(self.options.merge_cores):
# os.makedirs(self.options.merge_cores)
base = self.options.merge_cores
f_out = open(base+".vhd", "w")
f_out.write("\n\n\n\n")
f_out.write("------------------------------ WARNING -------------------------------\n")
f_out.write("-- This code has been generated by hdlmake --merge-cores option --\n")
f_out.write("-- It is provided for your convenience, to spare you from adding --\n")
f_out.write("-- lots of individual source files to ISE/Modelsim/Quartus projects --\n")
f_out.write("-- mainly for Windows users. Please DO NOT MODIFY this file. If you --\n")
f_out.write("-- need to change something inside, edit the original source file --\n")
f_out.write("-- and re-genrate the merged version! --\n")
f_out.write("----------------------------------------------------------------------\n")
f_out.write("\n\n\n\n")
f_out.write("\n\n\n\n");
f_out.write("------------------------------ WARNING -------------------------------\n");
f_out.write("-- This code has been generated by hdlmake --merge-cores option --\n");
f_out.write("-- It is provided for your convenience, to spare you from adding --\n");
f_out.write("-- lots of individual source files to ISE/Modelsim/Quartus projects --\n");
f_out.write("-- mainly for Windows users. Please DO NOT MODIFY this file. If you --\n");
f_out.write("-- need to change something inside, edit the original source file --\n");
f_out.write("-- and re-genrate the merged version! --\n");
f_out.write("----------------------------------------------------------------------\n");
f_out.write("\n\n\n\n");
for vhdl in flist_sorted.filter(VHDLFile):
f_out.write("\n\n--- File: %s ----\n\n" % vhdl.rel_path())
......@@ -495,16 +495,16 @@ class HdlmakeKernel(object):
f_out = open(base+".v", "w")
f_out.write("\n\n\n\n")
f_out.write("////////////////////////////// WARNING ///////////////////////////////\n")
f_out.write("// This code has been generated by hdlmake --merge-cores option //\n")
f_out.write("// It is provided for your convenience, to spare you from adding //\n")
f_out.write("// lots of individual source files to ISE/Modelsim/Quartus projects //\n")
f_out.write("// mainly for Windows users. Please DO NOT MODIFY this file. If you //\n")
f_out.write("// need to change something inside, edit the original source file //\n")
f_out.write("// and re-genrate the merged version! //\n")
f_out.write("//////////////////////////////////////////////////////////////////////\n")
f_out.write("\n\n\n\n")
f_out.write("\n\n\n\n");
f_out.write("////////////////////////////// WARNING ///////////////////////////////\n");
f_out.write("// This code has been generated by hdlmake --merge-cores option //\n");
f_out.write("// It is provided for your convenience, to spare you from adding //\n");
f_out.write("// lots of individual source files to ISE/Modelsim/Quartus projects //\n");
f_out.write("// mainly for Windows users. Please DO NOT MODIFY this file. If you //\n");
f_out.write("// need to change something inside, edit the original source file //\n");
f_out.write("// and re-genrate the merged version! //\n");
f_out.write("//////////////////////////////////////////////////////////////////////\n");
f_out.write("\n\n\n\n");
for vlog in flist_sorted.filter(VerilogFile):
f_out.write("\n\n// File: %s \n\n" % vlog.rel_path())
......
This diff is collapsed.
......@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -23,12 +23,12 @@ import os
from configparser import ConfigParser
class Manifest:
def __init__(self, path=None, url=None):
def __init__(self, path = None, url = None):
if not isinstance(path, str):
raise ValueError("Path must be an instance of str")
if path is None and url is None:
if path == None and url == None:
raise ValueError("When creating a manifest a path or an URL must be given")
if path is None and url is None:
if path != None and url == None:
self.url = path
if path_mod.is_abs_path(path):
self.path = path
......@@ -37,32 +37,31 @@ class Manifest:
def __str__(self):
return self.url
def exists(self):
return os.path.exists(self.path)
class ManifestParser(ConfigParser):
def __init__(self):
ConfigParser.__init__(self, description="Configuration options description")
ConfigParser.__init__(self,description="Configuration options description")
self.add_option('fetchto', default=None, help="Destination for fetched modules", type='')
#self.add_option('root_module', default=None, help="Path to root module for currently parsed", type='')
self.add_delimiter()
self.add_option('syn_name', default=None, help="Name of the folder at remote synthesis machine", type='')
self.add_option('syn_device', default=None, help="Target FPGA device", type='')
self.add_option('syn_grade', default=None, help="Speed grade of target FPGA", type='')
self.add_option('syn_package', default=None, help="Package variant of target FPGA", type='')
self.add_option('syn_top', default=None, help="Top level module for synthesis", type='')
self.add_option('syn_project', default=None, help="Project file (.xise, .ise, .qpf)", type='')
self.add_option('syn_device', default=None, help = "Target FPGA device", type = '');
self.add_option('syn_grade', default=None, help = "Speed grade of target FPGA", type = '');
self.add_option('syn_package', default=None, help = "Package variant of target FPGA", type = '');
self.add_option('syn_top', default=None, help = "Top level module for synthesis", type = '');
self.add_option('syn_project', default=None, help = "Project file (.xise, .ise, .qpf)", type = '');
self.add_delimiter()
self.add_option('include_dirs', default=None, help="Include dirs for Verilog sources", type=[])
self.add_type('include_dirs', type="")
self.add_option('include_dirs', default=None, help="Include dirs for Verilog sources", type = [])
self.add_type('include_dirs', type = "")
self.add_delimiter()
# Modification here!
# self.add_option('sim_tool', default=None, help = "Simulation tool to be used (isim/vsim)", type = '')
# self.add_option('sim_tool', default=None, help = "Simulation tool to be used (isim/vsim)", type = '');
self.add_option('vsim_opt', default="", help="Additional options for vsim", type='')
self.add_option('vcom_opt', default="", help="Additional options for vcom", type='')
self.add_option('vlog_opt', default="", help="Additional options for vlog", type='')
......@@ -107,7 +106,7 @@ class ManifestParser(ConfigParser):
return ConfigParser.parse(self)
def print_help(self):
ConfigParser.help(self)
ConfigParser.help()
def search_for_package(self):
"""
......@@ -121,12 +120,12 @@ class ManifestParser(ConfigParser):
except UnicodeDecodeError:
return []
package_pattern = re.compile("^[ ]*package[ ]+([^ ]+)[ ]+is[ ]*$")
package_pattern = re.compile("^[ \t]*package[ \t]+([^ \t]+)[ \t]+is[ \t]*$")
ret = []
for line in text:
m = re.match(package_pattern, line)
if m is None:
if m != None:
ret.append(m.group(1))
f.close()
......
This diff is collapsed.
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -49,7 +49,7 @@ def echo(msg):
rawprint(msg)
def vprint(msg):
if global_mod.options.verbose is True:
if global_mod.options.verbose == True:
echo(msg)
def pprint(msg):
......@@ -57,7 +57,7 @@ def pprint(msg):
pp.pprint(msg)
def vpprint(msg):
if global_mod.options.verbose is True:
if global_mod.options.verbose == True:
pp = prettyprinter.PrettyPrinter(indent = 2)
pp.pprint(msg)
......
......@@ -2,70 +2,70 @@
class DepRelation:
PROVIDE = 1
USE = 2
ENTITY = 1
PACKAGE = 2
INCLUDE = 3
PROVIDE = 1
USE = 2
ENTITY = 1
PACKAGE = 2
INCLUDE = 3
def __init__(self, obj_name, direction, rel_type):
self.direction = direction
self.rel_type = rel_type
self.obj_name = obj_name
def satisfies(self, rel_b):
if(rel_b.direction == self.USE):
return True
elif(self.direction == self.PROVIDE and rel_b.rel_type == self.rel_type and rel_b.obj_name == self.obj_name):
return True
return False
def __init__(self, obj_name, direction, rel_type):
self.direction = direction
self.rel_type = rel_type
self.obj_name = obj_name
def satisfies(self, rel_b):
if(rel_b.direction == self.USE):
return True
elif(self.direction == self.PROVIDE and rel_b.rel_type == self.rel_type and rel_b.obj_name == self.obj_name):
return True
return False
def __str__(self):
dstr = { self.USE : "Use", self.PROVIDE : "Provide" }
ostr = { self.ENTITY : "entity/module", self.PACKAGE : "package", self.INCLUDE : "include/header" }
return "%s %s '%s'" % (dstr[self.direction], ostr[self.rel_type], self.obj_name)
def __str__(self):
dstr = { self.USE : "Use", self.PROVIDE : "Provide" }
ostr = { self.ENTITY : "entity/module", self.PACKAGE : "package", self.INCLUDE : "include/header" }
return "%s %s '%s'" % (dstr[self.direction], ostr[self.rel_type], self.obj_name)
class DepFile:
def __init__(self, filename, search_path=[]):
self.rels = []
self.filename = filename
parser = ParserFactory().create(self.filename, search_path)
parser.parse(self, self.filename)
def __init__(self, filename, search_path=[]):
self.rels = [];
self.filename = filename
parser = ParserFactory().create(self.filename, search_path)
parser.parse(self, self.filename)
def add_relation(self, rel):
self.rels.append(rel)
def satisfies(self, rels_b):
for r_mine in self.rels:
if not any(map(rels_b, lambda x: x.satisfies(r_mine))):
return False
def show_relations(self):
for r in self.rels:
print(str(r))
def add_relation(self, rel):
self.rels.append(rel);
def satisfies(self, rels_b):
for r_mine in self.rels:
if not any(map(rels_b, lambda x: x.satisfies(r_mine))):
return False
def show_relations(self):
for r in self.rels:
print(str(r))
class DepParser:
def __init__(self):
pass
def parse(f, filename):
pass
def __init__(self):
pass
def parse(f, filename):
pass
class ParserFactory:
def create(self, filename, search_path):
import re
from vlog_parser import VerilogParser
from vhdl_parser import VHDLParser
def create(self, filename, search_path):
import re
from vlog_parser import VerilogParser
from vhdl_parser import VHDLParser
extension=re.match(re.compile(".+\.(\w+)$"), filename)
if(not extension):
throw ("Unecognized file format : %s" % filename)
extension = extension.group(1).lower()
if(extension in ["vhd", "vhdl"]):
return VHDLParser()
elif(extension in ["v", "sv"]):
vp = VerilogParser()
for d in search_path:
vp.add_search_path(d)
return vp
extension=re.match(re.compile(".+\.(\w+)$"), filename)
if(not extension):
throw ("Unecognized file format : %s" % filename);
extension = extension.group(1).lower()
if(extension in ["vhd", "vhdl"]):
return VHDLParser();
elif(extension in ["v", "sv"]):
vp = VerilogParser();
for d in search_path:
vp.add_search_path(d)
return vp
......@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
......@@ -42,14 +42,14 @@ def url_parse(url):
"""
Check if link to a repo seems to be correct. Filter revision number and branch
"""
"""url_pat = re.compile("[ ]*([^ ]+?)[ ]*(::)?([^ @]+)?(@[ ]*(.+))?[ ]*")
"""url_pat = re.compile("[ \t]*([^ \t]+?)[ \t]*(::)?([^ \t@]+)?(@[ \t]*(.+))?[ \t]*")
url_match = re.match(url_pat, url)
if url_match is None:
if url_match == None:
p.echo("Not a correct repo url: {0}. Skipping".format(url))
url_clean = url_match.group(1)
if url_match.group(3) is None: #there is a branch
if url_match.group(3) != None: #there is a branch
branch = url_match.group(3)
if url_match.group(5) is None: #there is a revision given
if url_match.group(5) != None: #there is a revision given
rev = url_match.group(5)"""
url_clean, branch, rev = None, None, None
if "@@" in url:
......@@ -113,7 +113,7 @@ def is_abs_path(path):
return False
def relpath(p1, p2 = None):
if p2 is None:
if p2 == None:
p2 = os.getcwd()
if p1 == p2:
return '.'
......
......@@ -44,7 +44,7 @@ class File(object):
def rel_path(self, dir=None):
import path
if dir is None:
if dir == None:
dir = os.getcwd()
return path.relpath(self.path, dir)
......@@ -151,7 +151,7 @@ class VHDLFile(SourceFile):
#std_libs = flow.MODELSIM_STANDARD_LIBS
print "I/O error: ({0})".format(e.message)
p.error("Picking standard Modelsim simulation libraries. Try to fix the error.")
std_libs = flow.MODELSIM_STANDARD_LIBS
std_libs = flow.MODELSIM_STARDAND_LIBS
elif global_mod.top_module.action == "synthesis":
print("setting std libs for synthesis...")
if global_mod.top_module.target == "xilinx":
......@@ -166,7 +166,7 @@ class VHDLFile(SourceFile):
except UnicodeDecodeError:
return []
use_pattern = re.compile("^[ ]*use[ ]+([^ ]+)[ ]*.*$")
use_pattern = re.compile("^[ \t]*use[ \t]+([^; ]+)[ \t]*;.*$")
lib_pattern = re.compile("([^.]+)\.([^.]+)\.all")
use_lines = []
......@@ -180,7 +180,7 @@ class VHDLFile(SourceFile):
ret = set()
for line in use_lines:
m = re.match(lib_pattern, line)
if m is None:
if m != None:
#omit standard libraries
if (m.group(1)).lower() in std_libs:
continue
......@@ -209,14 +209,14 @@ class VHDLFile(SourceFile):
except UnicodeDecodeError:
return []
package_pattern = re.compile("^[ ]*package[ ]+([^ ]+)[ ]+is[ ]*.*$")
package_pattern = re.compile("^[ \t]*package[ \t]+([^ \t]+)[ \t]+is[ \t]*.*$")
ret = set()
for line in text:
#identifiers and keywords are case-insensitive in VHDL
line = line.lower()
m = re.match(package_pattern, line)
if m is None:
if m != None:
ret.add((self.library.lower(), m.group(1).lower()))
f.close()
......@@ -289,12 +289,12 @@ class VerilogFile(SourceFile):
text = f.readlines()
except UnicodeDecodeError:
return []
include_pattern = re.compile("^[ ]*`include[ ]+\"([^ \"]+)\".*$")
include_pattern = re.compile("^[ \t]*`include[ \t]+\"([^ \"]+)\".*$")
ret = []
for line in text:
#in Verilog and SV identifiers are case-sensitive
m = re.match(include_pattern, line)
if m is None:
if m != None:
ret.append(m.group(1))
f.close()
return ret
......@@ -365,21 +365,21 @@ class SourceFileSet(list):
for f in files:
if f not in self:
self.append(f)
except TypeError: # single file, not a list
except: # single file, not a list
if files not in self:
self.append(files)
def filter(self, src_file_type):
def filter(self, type):
out = SourceFileSet()
for f in self:
if isinstance(f, src_file_type):
if isinstance(f, type):
out.add(f)
return out
def inversed_filter(self, src_file_type):
def inversed_filter(self, type):
out = SourceFileSet()
for f in self:
if not isinstance(f, src_file_type):
if not isinstance(f, type):
out.add(f)
return out
......
This diff is collapsed.
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