Commit a6a21470 authored by Lucas Russo's avatar Lucas Russo Committed by Paweł Szostek

fix wrong commit files

parent 6acbfc72
<<<<<<< HEAD
misc
examples
Makefile
hdlmake.aux
hdlmake.pdf
hdlmake.log
=======
*~
*.swp
*.swap
*.odt
>>>>>>> .gitignore: add ignore files
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# 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)
# 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
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
SRC := configparser.py connection.py dep_solver.py fetch.py\
flow.py flow_altera.py global_mod.py hdlmake_kernel.py help_printer.py helper_classes.py\
__main__.py makefile_writer.py module.py msg.py path.py \
srcfile.py
PREFIX := ./
<<<<<<< HEAD
ARCH := hdlmake
=======
ARCH := hdlmake2
>>>>>>> Created new repository for hdl-make2
../$(ARCH): $(foreach src, $(SRC), $(PREFIX)$(src))
zip $(ARCH) $(SRC)
echo '#!/usr/bin/python' > ../$(ARCH)
cat $(ARCH).zip >> ../$(ARCH)
rm $(ARCH).zip
chmod +x ../$(ARCH)
clean:
rm -f $(PREFIX)*~ $(PREFIX)*pyc
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# 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)
# 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
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
<<<<<<< HEAD
=======
# Modified to allow iSim simulation by Lucas Russo (lucas.russo@lnls.br)
>>>>>>> Created new repository for hdl-make2
import os
from connection import Connection
import global_mod
import msg as p
import optparse
from module import Module
from fetch import ModulePool
def main():
parser = optparse.OptionParser()
parser.add_option("--manifest-help", action="store_true",
dest="manifest_help", help="print manifest file variables description")
<<<<<<< HEAD
parser.add_option("--make-sim", dest="make_sim", action="store_true",
default=None, help="generate a simulation Makefile")
=======
# parser.add_option("--make-sim", dest="make_sim", action="store_true",
# default=None, help="generate a simulation Makefile")
parser.add_option("--make-vsim", dest="make_vsim", action="store_true",
default=None, help="generate a ModelSim simulation Makefile")
parser.add_option("--make-isim", dest="make_isim", action="store_true",
default=None, help="generate a ISE Simulation (ISim) simulation Makefile")
>>>>>>> Created new repository for hdl-make2
parser.add_option("--make-fetch", dest="make_fetch", action="store_true",
default=None, help="generate a makefile for modules' fetching")
parser.add_option("--make-ise", dest="make_ise", action="store_true",
default=None, help="generate a makefile for local ISE synthesis")
parser.add_option("--make-remote", dest="make_remote", action="store_true",
default=None, help="generate a makefile for remote synthesis")
parser.add_option("-f", "--fetch", action="store_true", dest="fetch",
<<<<<<< HEAD
default=None, help="fetch and/or update remote modules listed in Manifet")
=======
default=None, help="fetch and/or update remote modules listed in Manifest")
>>>>>>> Created new repository for hdl-make2
parser.add_option("--clean", action="store_true", dest="clean",
default=None, help="remove all modules fetched for this one")
parser.add_option("--list", action="store_true", dest="list",
default=None, help="List all modules together with their files")
parser.add_option("--list-files", action="store_true", dest="list_files",
default=None, help="List all files in a from of a space-separated string")
parser.add_option("--ise-proj", action="store_true", dest="ise_proj",
default=None, help="create/update an ise project including list of project"
"files")
parser.add_option("-l", "--synthesize-locally", dest="local",
default=None, action="store_true", help="perform a local synthesis")
parser.add_option("-r", "--synthesize-remotelly", dest="remote",
default=None, action="store_true", help="perform a remote synthesis")
parser.add_option("--synth-server", dest="synth_server",
default=None, help="use given SERVER for remote synthesis",
metavar="SERVER")
parser.add_option("--synth-user", dest="synth_user",
default=None, help="use given USER for remote synthesis", metavar="USER")
parser.add_option("--force-ise", dest="force_ise",
default=None, type=float, help="Force given ISE version to be used in"
" synthesis,use 0 for current version", metavar="ISE")
parser.add_option("--py", dest="arbitrary_code",
default="", help="add arbitrary code to all manifests' evaluation")
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
default="false", help="verbose mode")
(options, _) = parser.parse_args()
<<<<<<< HEAD
=======
# Setting global variable (global_mod.py)
>>>>>>> Created new repository for hdl-make2
global_mod.options = options
if options.manifest_help == True:
from helper_classes import ManifestParser
ManifestParser().help()
quit()
<<<<<<< HEAD
p.vprint("LoadTopManifest")
pool = ModulePool()
top_module = Module(parent=None, url=os.getcwd(), source="local",
fetchto=".", pool=pool)
=======
# Check later if a simulatuion tool should have been specified
if options.make_isim == True:
global_mod.sim_tool = "isim"
elif options.make_vsim == True:
global_mod.sim_tool = "vsim"
p.info("Simulation tool: " + str(global_mod.sim_tool))
p.vprint("LoadTopManifest")
# Initialize empty module list
pool = ModulePool()
# Initialize top module and setting looking fot its manifest in URL (local | remote) path
top_module = Module(parent=None, url=os.getcwd(), source="local",
fetchto=".", pool=pool)
# Setting top_module as top module of design (ModulePool class)
>>>>>>> Created new repository for hdl-make2
pool.set_top_module(top_module)
if top_module.manifest == None:
p.echo("No manifest found. At least an empty one is needed")
quit()
<<<<<<< HEAD
global_mod.top_module = top_module
=======
# Setting global variable (global_mod.py)
global_mod.top_module = top_module
# Parse manifest of top_module
>>>>>>> Created new repository for hdl-make2
global_mod.top_module.parse_manifest()
global_mod.global_target = global_mod.top_module.target
ssh = Connection(ssh_user=options.synth_user,
ssh_server=options.synth_server)
from hdlmake_kernel import HdlmakeKernel
kernel = HdlmakeKernel(modules_pool=pool, connection=ssh, options=options)
options_kernel_mapping = {
"fetch" : "fetch",
<<<<<<< HEAD
"make_sim" : "generate_modelsim_makefile",
=======
# "make_sim" : "generate_modelsim_makefile",
"make_vsim" : "generate_modelsim_makefile",
"make_isim" : "generate_isim_makefile",
>>>>>>> Created new repository for hdl-make2
"ise_proj" : "generate_ise_project",
"local" : "run_local_synthesis",
"remote": "run_remote_synthesis",
"make_fetch": "generate_fetch_makefile",
"make_ise" : "generate_ise_makefile",
"make_remote" : "generate_remote_synthesis_makefile",
"list" : "list_modules",
"clean" : "clean_modules"
}
sth_chosen = False
for option, function in options_kernel_mapping.items():
try:
is_set = getattr(options, option)
if is_set:
sth_chosen = True
getattr(kernel, function)()
except Exception, unknown_error :
print unknown_error
if not sth_chosen:
kernel.run()
if __name__ == "__main__":
main()
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# 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)
# 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
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
import msg as p
class IDependable:
def __init__(self):
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 == False:
self.__create_deps()
self._dep_fixed = True
return self.__dep_provides
def set_dep_provides(self, what):
self.__dep_provides = what
dep_provides = property(get_dep_provides, set_dep_provides)
def get_dep_requires(self):
if self._dep_fixed == False:
self.__create_deps()
self._dep_fixed = True
return self.__dep_requires
def set_dep_requires(self, what):
self.__dep_requires = what
dep_requires = property(get_dep_requires, set_dep_requires)
def get_dep_depends_on(self):
return self.__dep_depends_on
def set_dep_depends_on(self, what):
self.__dep_depends_on = what
dep_depends_on = property(get_dep_depends_on, set_dep_depends_on)
def __create_deps(self):
"""Used solely for polymorphism"""
class DependencySolver:
def __init__(self):
self.entities = {};
def __lookup_post_provider(self, files, start_index, file):
requires = file.dep_requires
while True:
start_index = start_index + 1
try:
if type(files[start_index]) == type(file):
f = files[start_index]
else:
continue
except IndexError:
break
if requires:
for req in requires:
if req in f.dep_provides:
return start_index
return None
def __find_provider_vhdl_file(self, files, req):
for f in files:
if req in f.dep_provides:
return f
return None
def __find_provider_verilog_file(self, req, v_file):
from srcfile import SourceFileFactory
import os
vf_dirname = v_file.dirname
sff = SourceFileFactory()
h_file = os.path.join(vf_dirname, req)
if os.path.exists(h_file) and not os.path.isdir(h_file):
return sff.new(h_file)
inc_dirs = self.__parse_vlog_opt(v_file.vlog_opt)
for dir in inc_dirs:
dir = os.path.join(vf_dirname, dir)
if not os.path.exists(dir) or not os.path.isdir(dir):
p.warning("Include path "+dir+" doesn't exist")
continue
h_file = os.path.join(dir, req)
if os.path.exists(h_file) and not os.path.isdir(h_file):
return sff.new(h_file)
return None
<<<<<<< HEAD
def __parse_vlog_opt(self, vlog_opt):
import re
ret = []
inc_pat = re.compile(".*?\+incdir\+([^ ]+)")
while True:
m = re.match(inc_pat, vlog_opt)
if m:
ret.append(m.group(1))
vlog_opt = vlog_opt[m.end():]
else:
break
=======
#def __parse_vlog_opt(self, vlog_opt):
# import re
# ret = []
# inc_pat = re.compile(".*?\+incdir\+([^ ]+)")
# while True:
# m = re.match(inc_pat, vlog_opt)
# if m:
# ret.append(m.group(1))
# vlog_opt = vlog_opt[m.end():]
# else:
# break
# return ret
def __parse_vlog_opt(self, vlog_opt):
import re
ret = []
inc_vsim_vlog = re.compile(".*?\+incdir\+([^ ]+)")
# Either a normal (non-special) character or an escaped special character repeated >= 1 times
#unix_path = re.compile(r"([^\0 \!\$\`\&\*\(\)\+]|\\(:? |\!|\$|\`|\&|\*|\(|\)|\+))+")
# -i <unix_path> one or more times
inc_isim_vlog = re.compile(r"\s*\-i\s*((\w|/|\\ |\.|\.\.)+)\s*")
vlog_vsim_opt = vlog_opt
# Try ModelSim include format (+incdir+<path>)
while True:
vsim_inc = re.match(inc_vsim_vlog, vlog_vsim_opt)
if vsim_inc:
ret.append(vsim_inc.group(1))
vlog_vsim_opt = vlog_vsim_opt[vsim_inc.end():]
else:
break
# Could use vlog_opt directly here
# Try ISim include format (-i <path>)
if not ret:
vlog_isim_opt = vlog_opt
while True:
isim_inc = re.match(inc_isim_vlog, vlog_isim_opt)
if isim_inc:
ret.append(isim_inc.group(1))
vlog_isim_opt = vlog_isim_opt[isim_inc.end():]
else:
break
p.vprint ("Include paths are: " + ' '.join(ret))
>>>>>>> Created new repository for hdl-make2
return ret
def solve(self, fileset):
n_iter = 0
max_iter = 100
import copy
fset = fileset.filter(IDependable);
f_nondep = []
done = False
while not done and (n_iter < max_iter):
n_iter = n_iter+1
done = True
for f in fset:
if not f._dep_fixed:
idx = fset.index(f)
k = self.__lookup_post_provider(files=fset, start_index=idx, file=f);
if k:
done = False
#swap
fset[idx], fset[k] = fset[k], fset[idx]
if(n_iter == max_iter):
p.error("Maximum number of iterations reached when trying to solve the dependencies."+
"Perhaps a cyclic inter-dependency problem.");
return None
for f in fset:
if f._dep_fixed:
f_nondep.append(copy.copy(f))
del f
f_nondep.sort(key=lambda f: f.dep_index)
from srcfile import VHDLFile, VerilogFile
for f in [file for file in fset if isinstance(file, VHDLFile)]:
p.vprint(f.path)
if f.dep_requires:
for req in f.dep_requires:
pf = self.__find_provider_vhdl_file([file for file in fset if isinstance(file, VHDLFile)], req)
if not pf:
p.error("Missing dependency in file "+str(f)+": " + req[0]+'.'+req[1])
else:
p.vprint("--> " + pf.path);
if pf.path != f.path:
f.dep_depends_on.append(pf)
#get rid of duplicates by making a set from the list and vice versa
f.dep_depends_on = list(set(f.dep_depends_on))
import srcfile as sf
for f in [file for file in fset if isinstance(file, VerilogFile)]:
p.vprint(f.path)
if f.dep_requires:
for req in f.dep_requires:
pf = self.__find_provider_verilog_file(req, f)
if not pf:
p.warning("Cannot find include for file "+str(f)+": "+req)
else:
p.vprint("--> " + pf.path)
f.dep_depends_on.append(pf)
#get rid of duplicates by making a set from the list and vice versa
f.dep_depends_on = list(set(f.dep_depends_on))
newobj = sf.SourceFileSet();
newobj.add(f_nondep);
for f in fset:
try:
if not f._dep_fixed:
newobj.add(f)
except:
newobj.add(f)
for k in newobj:
p.vprint(str(k.dep_index) + " " + k.path + str(k._dep_fixed))
return newobj
This diff is collapsed.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# 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)
# 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
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
options = None
top_module = None
global_target = "''"
<<<<<<< HEAD
=======
sim_tool = None
>>>>>>> Created new repository for hdl-make2
This diff is collapsed.
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# 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)
# 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
# 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
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
import path as path_mod
import os
from configparser import ConfigParser
class Manifest:
def __init__(self, path = None, url = None):
if not isinstance(path, str):
raise ValueError("Path must be an instance of str")
if path == None and url == None:
raise ValueError("When creating a manifest a path or an URL must be given")
if path != None and url == None:
self.url = path
if path_mod.is_abs_path(path):
self.path = path
else:
raise ValueError("When creating a Manifest, path must be absolute path")
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")
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_delimiter()
self.add_option('include_dirs', default=None, help="Include dirs for Verilog sources", type = [])
self.add_type('include_dirs', type = "")
self.add_delimiter()
<<<<<<< HEAD
=======
# Modification here!
# self.add_option('sim_tool', default=None, help = "Simulation tool to be used (isim/vsim)", type = '');
>>>>>>> Created new repository for hdl-make2
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='')
self.add_option('vmap_opt', default="", help="Additional options for vmap", type='')
self.add_delimiter()
self.add_option('modules', default={}, help="List of local modules", type={})
self.add_option('target', default=None, help="What is the target architecture", type='')
self.add_option('action', default=None, help="What is the action that should be taken (simulation/synthesis)", type='')
self.add_allowed_key('modules', key="svn")
self.add_allowed_key('modules', key="git")
self.add_allowed_key('modules', key="local")
#self.add_delimiter()
self.add_option('library', default="work",
help="Destination library for module's VHDL files", type="")
self.add_option('files', default=[], help="List of files from the current module", type='')
self.add_type('files', type=[])
#self.add_option('root', default=None, type='', help="Root catalog for local modules")
def add_manifest(self, manifest):
return self.add_config_file(manifest.path)
def parse(self):
return ConfigParser.parse(self)
def print_help(self):
self.ConfigParser.print_help()
def search_for_package(self):
"""
Reads a file and looks for package clase. Returns list of packages' names
from the file
"""
import re
f = open(self.path, "r")
try:
text = f.readlines()
except UnicodeDecodeError:
return []
package_pattern = re.compile("^[ \t]*package[ \t]+([^ \t]+)[ \t]+is[ \t]*$")
ret = []
for line in text:
m = re.match(package_pattern, line)
if m != None:
ret.append(m.group(1))
f.close()
self.package = ret
This diff is collapsed.
This diff is collapsed.
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