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)
......@@ -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()
......@@ -152,8 +150,9 @@ class ConfigParser(object):
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):
......@@ -229,7 +228,7 @@ 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 = {}
......@@ -237,7 +236,7 @@ class ConfigParser(object):
if self.config_file is not None:
with open(self.config_file, "r") as config_file:
content = config_file.readlines()
content = open(self.config_file, "r").readlines()
content = ''.join(content)
else:
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
......
......@@ -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,7 +37,7 @@ class ModulePool(list):
p.vprint("ModPath: " + module.path)
else:
p.printhr()
p.info("Fetching module: " + str(module) +
p.info("Fetching module: " + str(module) +\
" [parent: " + str(module.parent) + "]")
if module.source == "svn":
p.info("[svn] Fetching to " + module.fetchto)
......@@ -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
......@@ -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
#
......@@ -40,19 +40,19 @@ class _QuartusProjectProperty:
words = []
words.append(dict([(b,a) for a,b in self.t.items()])[self.command])
if self.what is None:
if self.what != None:
words.append(self.what)
if self.name is None:
if self.name != None:
words.append("-name")
words.append(self.name_type)
words.append(self.name)
if self.from_ is None:
if self.from_ != None:
words.append("-from")
words.append(self.from_)
if self.to is None:
if self.to != None:
words.append("-to")
words.append(self.to)
if self.section_id is None:
if self.section_id != None:
words.append("-section_id")
words.append(self.section_id)
return ' '.join(words)
......@@ -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)
......@@ -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,7 +59,7 @@ 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:
#if tm.sim_tool == None:
# p.error("sim_tool variable must be defined in the manifest")
# quit()
## Make distintion between isim and vsim simulators
......@@ -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)
......
......@@ -28,13 +28,13 @@ class DepRelation:
class DepFile:
def __init__(self, filename, search_path=[]):
self.rels = []
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)
self.rels.append(rel);
def satisfies(self, rels_b):
for r_mine in self.rels:
......@@ -60,12 +60,12 @@ class ParserFactory:
extension=re.match(re.compile(".+\.(\w+)$"), filename)
if(not extension):
throw ("Unecognized file format : %s" % filename)
throw ("Unecognized file format : %s" % filename);
extension = extension.group(1).lower()
if(extension in ["vhd", "vhdl"]):
return VHDLParser()
return VHDLParser();
elif(extension in ["v", "sv"]):
vp = VerilogParser()
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
......
......@@ -6,13 +6,13 @@
class VerilogPreprocessor:
# Reserved verilog preprocessor keywords. The list is certainly not full
vpp_keywords = [ "define", "line", "include", "elsif", "ifdef", "endif", "else", "undef", "timescale" ]
vpp_keywords = [ "define", "line", "include", "elsif", "ifdef", "endif", "else", "undef", "timescale" ];
# List of `include search paths
vpp_searchdir = ["."]
vpp_searchdir = ["."];
# List of macro definitions
vpp_macros = []
vpp_macros = [];
# Dictionary of files sub-included by each file parsed
vpp_filedeps = {}
......@@ -27,10 +27,10 @@ class VerilogPreprocessor:
# Simple binary stack, for nested `ifdefs evaluation
class VL_Stack:
def __init__(self):
self.stack = []
self.stack = [];
def push(self, v):
self.stack.append(v)
self.stack.append(v);
def pop(self):
return self.stack.pop()
......@@ -42,7 +42,7 @@ class VerilogPreprocessor:
self.push(not self.pop())
def __init__(self):
self.vpp_stack = self.VL_Stack()
self.vpp_stack = self.VL_Stack();
def find_macro(self, name):
for m in self.vpp_macros:
......@@ -64,10 +64,10 @@ class VerilogPreprocessor:
def degapize(self, s):
import re
lempty=re.compile("^\s*$")
cline = None
cline = None;
lines=[]
for l in s.splitlines(False):
if re.match(lempty, l) is None:
if re.match(lempty, l) != None:
continue
if l.endswith('\\'):
if cline==None:
......@@ -141,9 +141,9 @@ class VerilogPreprocessor:
last = matches[k]
if matches ["ifdef_elsif"]:
cond_true = self.find_macro(last.group(2)) is None
cond_true = self.find_macro(last.group(2)) != None
if(last.group(1)=="ifndef"):
cond_true = not cond_true
cond_true = not cond_true;
# fixme: support `elsif construct
elif(last.group(1)=="elsif"):
self.vpp_stack.pop()
......@@ -217,7 +217,7 @@ class VerilogPreprocessor:
def find_first(self, f, l):
x=filter(f, l)
if x is None:
if x != None:
return x[0]
else:
return None
......@@ -509,9 +509,9 @@ class VerilogParser:
# print("w %s b %d p %d" % (word, block_level, paren_level))
if(drop_last):
buf2 += ""
buf2 += ";";
if(not block_level and not paren_level and not drop_last):
buf2 += word + " "
buf2 += word + " ";
return buf2
......@@ -522,14 +522,14 @@ class VerilogParser:
import copy
buf= self.preproc.preprocess(filename)
f=open("preproc.v","w")
f.write(buf)
f.write(buf);
f.close()
self.preprocessed = copy.copy(buf)
includes = self.preproc.get_file_deps()
import re
m_inside_module = re.compile("(?:module|interface)\s+(\w+)\s*(?:\(.*?\))?\s*(.+?)(?:endmodule|endinterface)",re.DOTALL | re.MULTILINE)
m_instantiation = re.compile("(?:\A|\\s*)\s*(\w+)\s+(?:#\s*\(.*?\)\s*)?(\w+)\s*\(.*?\)\s*", re.DOTALL | re.MULTILINE)
m_inside_module = re.compile("(?:module|interface)\s+(\w+)\s*(?:\(.*?\))?\s*;(.+?)(?:endmodule|endinterface)",re.DOTALL | re.MULTILINE)
m_instantiation = re.compile("(?:\A|\;\s*)\s*(\w+)\s+(?:#\s*\(.*?\)\s*)?(\w+)\s*\(.*?\)\s*", re.DOTALL | re.MULTILINE)
def do_module(s):
# print("module %s" %s.group(1))
......
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