def list_files(self): files_str = [] for m in self.modules_pool: if not m.isfetched: continue files_str.append(" ".join([f.path for f in m.files])) p.rawprint(" ".join(files_str))
def clean_modules(self): p.info("Removing fetched modules..") remove_list = [m for m in self.modules_pool if m.source in ["svn", "git"] and m.isfetched] remove_list.reverse() #we will remove modules in backward order if len(remove_list): for m in remove_list: p.rawprint("\t" + m.url + " [from: " + m.path + "]") m.remove_dir_from_disk() else: p.info("There are no modules to be removed")
def clean_modules(self): p.info("Removing fetched modules..") remove_list = [ m for m in self.modules_pool if m.source in ["svn", "git"] and m.isfetched ] remove_list.reverse() #we will remove modules in backward order if len(remove_list): for m in remove_list: p.rawprint("\t" + m.url + " [from: " + m.path + "]") m.remove_dir_from_disk() else: p.info("There are no modules to be removed")
def generate_quartus_project(self): p.info("Generating/updating Quartus project.") if not self.modules_pool.is_everything_fetched(): p.error("A module remains unfetched. " "Fetching must be done prior to makefile generation") p.rawprint(str([str(m) for m in self.modules_pool.modules if not m.isfetched])) quit() if os.path.exists(self.top_module.syn_project + ".qsf"): self.__update_existing_quartus_project() else: self.__create_new_quartus_project()
def load_xml(self, filename): f = open(filename) self.xml_doc = xml.dom.minidom.parse(f) self.xml_project = self.xml_doc.getElementsByTagName("project")[0] import sys try: self.__parse_props() except xml.parsers.expat.ExpatError: p.rawprint("Error while parsing existng file's properties:") p.rawprint(str(sys.exc_info())) quit() try: self.__parse_libs() except xml.parsers.expat.ExpatError: p.rawprint("Error while parsing existng file's libraries:") p.rawprint(str(sys.exc_info())) quit() where = self.xml_doc.documentElement self.xml_files = self.__purge_dom_node(name="files", where=where) self.xml_bindings = self.__purge_dom_node(name="bindings", where=where) try: node = where.getElementsByTagName("version")[0] self.ise = float(node.getAttribute("xil_pn:ise_version")) where.removeChild(node) except: pass f.close()
def generate_quartus_project(self): p.info("Generating/updating Quartus project.") if not self.modules_pool.is_everything_fetched(): p.error("A module remains unfetched. " "Fetching must be done prior to makefile generation") p.rawprint( str([ str(m) for m in self.modules_pool.modules if not m.isfetched ])) quit() if os.path.exists(self.top_module.syn_project + ".qsf"): self.__update_existing_quartus_project() else: self.__create_new_quartus_project()
def help(self): p.rawprint("Variables available in a manifest:") for opt in self.options: if opt == None: p.rawprint("") continue 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, "","") p.rawprint(line)
def help(self): p.rawprint("Variables available in a manifest:") for opt in self.options: if opt == None: p.rawprint("") continue 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, "", "") p.rawprint(line)
def list_modules(self): for m in self.modules_pool: if not m.isfetched: p.rawprint("#!UNFETCHED") p.rawprint(m.url + '\n') else: p.rawprint(path.relpath(m.path)) if m.source in ["svn", "git"]: p.rawprint("#" + m.url) if not len(m.files): p.rawprint(" # no files") else: for f in m.files: p.rawprint(" " + path.relpath(f.path, m.path)) p.rawprint("")
def list_modules(self): for m in self.modules_pool: if not m.isfetched: p.rawprint("#!UNFETCHED") p.rawprint(m.url+'\n') else: p.rawprint(path.relpath(m.path)) if m.source in ["svn", "git"]: p.rawprint ("#"+m.url) if not len(m.files): p.rawprint(" # no files") else: for f in m.files: p.rawprint(" " + path.relpath(f.path, m.path)) p.rawprint("")
def parse_manifest(self): if self.isparsed == True or self.isfetched == False: return if self.manifest == None: self.manifest = self.__search_for_manifest() if self.path == None: raise RuntimeError() manifest_parser = ManifestParser() # For non-top modules if (self.parent != None): manifest_parser.add_arbitrary_code( "target=\"" + str(global_mod.top_module.target) + "\"") manifest_parser.add_arbitrary_code( "action=\"" + str(global_mod.top_module.action) + "\"") # syn_device and sim_tool will be set for non-top modules manifest_parser.add_arbitrary_code( "syn_device=\"" + str(global_mod.top_module.syn_device) + "\"") manifest_parser.add_arbitrary_code("__manifest=\"" + self.path + "\"") manifest_parser.add_arbitrary_code(global_mod.options.arbitrary_code) if self.manifest == None: p.vprint("No manifest found in module " + str(self)) else: manifest_parser.add_manifest(self.manifest) p.vprint("Parsing manifest file: " + str(self.manifest)) opt_map = None try: opt_map = manifest_parser.parse() except NameError as ne: p.echo("Error while parsing {0}:\n{1}: {2}.".format( self.manifest, type(ne), ne)) quit() if (opt_map["fetchto"] != None): fetchto = path_mod.rel2abs(opt_map["fetchto"], self.path) self.fetchto = fetchto else: fetchto = self.fetchto if self.ise == None: self.ise = "13.1" if "local" in opt_map["modules"]: local_paths = self.__make_list(opt_map["modules"]["local"]) local_mods = [] for path in local_paths: if path_mod.is_abs_path(path): p.error("Found an absolute path (" + path + ") in a manifest") p.rawprint("(" + self.path + ")") quit() path = path_mod.rel2abs(path, self.path) local_mods.append( self.pool.new_module(parent=self, url=path, source="local", fetchto=fetchto)) self.local = local_mods else: self.local = [] self.vmap_opt = opt_map["vmap_opt"] self.vcom_opt = opt_map["vcom_opt"] self.vsim_opt = opt_map["vsim_opt"] self.vlog_opt = opt_map["vlog_opt"] #if self.vlog_opt == "": # self.vlog_opt = global_mod.top_module.vlog_opt #if self.vcom_opt == "": # self.vcom_opt = global_mod.top_module.vcom_opt #if self.vsim_opt == "": # self.vsim_opt = global_mod.top_module.vsim_opt # if self.vmap_opt == "": # self.vmap_opt = global_mod.top_module.vmap_opt self.library = opt_map["library"] self.include_dirs = [] if opt_map["include_dirs"] != None: if isinstance(opt_map["include_dirs"], basestring): self.include_dirs.append(opt_map["include_dirs"]) else: self.include_dirs.extend(opt_map["include_dirs"]) for dir in self.include_dirs: if path_mod.is_abs_path(dir): p.warning(self.path + " contains absolute path to an include directory: " + dir) if not os.path.exists(dir): p.warning(self.path + " has an unexisting include directory: " + dir) if opt_map["files"] == []: self.files = SourceFileSet() else: opt_map["files"] = self.__make_list(opt_map["files"]) paths = [] for path in opt_map["files"]: if not path_mod.is_abs_path(path): path = path_mod.rel2abs(path, self.path) paths.append(path) else: p.warning(path + " is an absolute path. Omitting.") if not os.path.exists(path): p.error("File listed in " + self.manifest.path + " doesn't exist: " + path + ".\nExiting.") quit() from srcfile import VerilogFile, VHDLFile self.files = self.__create_file_list_from_paths(paths=paths) for f in self.files: if isinstance(f, VerilogFile): f.vsim_opt = self.vsim_opt elif isinstance(f, VHDLFile): f.vcom_opt = self.vcom_opt if "svn" in opt_map["modules"]: opt_map["modules"]["svn"] = self.__make_list( opt_map["modules"]["svn"]) svn_mods = [] for url in opt_map["modules"]["svn"]: svn_mods.append( self.pool.new_module(parent=self, url=url, source="svn", fetchto=fetchto)) self.svn = svn_mods else: self.svn = [] if "git" in opt_map["modules"]: opt_map["modules"]["git"] = self.__make_list( opt_map["modules"]["git"]) git_mods = [] for url in opt_map["modules"]["git"]: git_mods.append( self.pool.new_module(parent=self, url=url, source="git", fetchto=fetchto)) self.git = git_mods else: self.git = [] self.target = opt_map["target"] self.action = opt_map["action"] if opt_map["syn_name"] == None and opt_map["syn_project"] != None: self.syn_name = opt_map[ "syn_project"][:-5] #cut out .xise from the end else: self.syn_name = opt_map["syn_name"] self.syn_device = opt_map["syn_device"] self.syn_grade = opt_map["syn_grade"] self.syn_package = opt_map["syn_package"] self.syn_project = opt_map["syn_project"] self.syn_top = opt_map["syn_top"] self.isparsed = True for m in self.submodules(): m.parse_manifest()
"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", "merge_cores" : "merge_cores" } sth_chosen = False import traceback 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 : p.echo("Oooops! We've got an error. Here is the appropriate info:\n") p.print_version() print(unknown_error) traceback.print_exc() if not sth_chosen: p.rawprint("No option selected. Running automatic flow") p.rawprint("To see some help, type hdlmake --help") kernel.run() if __name__ == "__main__": main()
def parse_manifest(self): if self.isparsed == True or self.isfetched == False: return if self.manifest == None: self.manifest = self.__search_for_manifest() if self.path == None: raise RuntimeError() manifest_parser = ManifestParser() # For non-top modules if(self.parent != None): manifest_parser.add_arbitrary_code("target=\""+str(global_mod.top_module.target)+"\"") manifest_parser.add_arbitrary_code("action=\""+str(global_mod.top_module.action)+"\"") # syn_device and sim_tool will be set for non-top modules manifest_parser.add_arbitrary_code("syn_device=\""+str(global_mod.top_module.syn_device)+"\"") manifest_parser.add_arbitrary_code("__manifest=\""+self.path+"\"") manifest_parser.add_arbitrary_code(global_mod.options.arbitrary_code) if self.manifest == None: p.vprint("No manifest found in module "+str(self)) else: manifest_parser.add_manifest(self.manifest) p.vprint("Parsing manifest file: " + str(self.manifest)) opt_map = None try: opt_map = manifest_parser.parse() except NameError as ne: p.echo("Error while parsing {0}:\n{1}: {2}.".format(self.manifest, type(ne), ne)) quit() if(opt_map["fetchto"] != None): fetchto = path_mod.rel2abs(opt_map["fetchto"], self.path) self.fetchto = fetchto else: fetchto = self.fetchto if self.ise == None: self.ise = "13.1" if "local" in opt_map["modules"]: local_paths = self.__make_list(opt_map["modules"]["local"]) local_mods = [] for path in local_paths: if path_mod.is_abs_path(path): p.error("Found an absolute path (" + path + ") in a manifest") p.rawprint("(" + self.path + ")") quit() path = path_mod.rel2abs(path, self.path) local_mods.append(self.pool.new_module(parent=self, url=path, source="local", fetchto=fetchto)) self.local = local_mods else: self.local = [] self.vmap_opt = opt_map["vmap_opt"] self.vcom_opt = opt_map["vcom_opt"] self.vsim_opt = opt_map["vsim_opt"] self.vlog_opt = opt_map["vlog_opt"] #if self.vlog_opt == "": # self.vlog_opt = global_mod.top_module.vlog_opt #if self.vcom_opt == "": # self.vcom_opt = global_mod.top_module.vcom_opt #if self.vsim_opt == "": # self.vsim_opt = global_mod.top_module.vsim_opt # if self.vmap_opt == "": # self.vmap_opt = global_mod.top_module.vmap_opt self.library = opt_map["library"] self.include_dirs = [] if opt_map["include_dirs"] != None: if isinstance(opt_map["include_dirs"], basestring): self.include_dirs.append(opt_map["include_dirs"]) else: self.include_dirs.extend(opt_map["include_dirs"]) for dir in self.include_dirs: if path_mod.is_abs_path(dir): p.warning(self.path + " contains absolute path to an include directory: " + dir) if not os.path.exists(dir): p.warning(self.path + " has an unexisting include directory: " + dir) if opt_map["files"] == []: self.files = SourceFileSet() else: opt_map["files"] = self.__make_list(opt_map["files"]) paths = [] for path in opt_map["files"]: if not path_mod.is_abs_path(path): path = path_mod.rel2abs(path, self.path) paths.append(path) else: p.warning(path + " is an absolute path. Omitting.") if not os.path.exists(path): p.error("File listed in " + self.manifest.path + " doesn't exist: " + path +".\nExiting.") quit() from srcfile import VerilogFile, VHDLFile self.files = self.__create_file_list_from_paths(paths=paths); for f in self.files: if isinstance(f, VerilogFile): f.vsim_opt = self.vsim_opt elif isinstance(f, VHDLFile): f.vcom_opt = self.vcom_opt if "svn" in opt_map["modules"]: opt_map["modules"]["svn"] = self.__make_list(opt_map["modules"]["svn"]) svn_mods = [] for url in opt_map["modules"]["svn"]: svn_mods.append(self.pool.new_module(parent=self, url=url, source="svn", fetchto=fetchto)) self.svn = svn_mods else: self.svn = [] if "git" in opt_map["modules"]: opt_map["modules"]["git"] = self.__make_list(opt_map["modules"]["git"]) git_mods = [] for url in opt_map["modules"]["git"]: git_mods.append(self.pool.new_module(parent=self, url=url, source="git", fetchto=fetchto)) self.git = git_mods else: self.git = [] self.target = opt_map["target"] self.action = opt_map["action"] if opt_map["syn_name"] == None and opt_map["syn_project"] != None: self.syn_name = opt_map["syn_project"][:-5] #cut out .xise from the end else: self.syn_name = opt_map["syn_name"] self.syn_device = opt_map["syn_device"]; self.syn_grade = opt_map["syn_grade"]; self.syn_package= opt_map["syn_package"]; self.syn_project = opt_map["syn_project"]; self.syn_top = opt_map["syn_top"]; self.isparsed = True for m in self.submodules(): m.parse_manifest()
def show(self): p.rawprint(self.path)
def parse(self): options = {} ret = {} 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 #now the trick: #I take the arbitrary code and parse it #the values are not important, but thanks to it I can check #if a variable came from the arbitrary code. #This is important because in the manifests only certain group #of variables is allowed. In arbitrary code all of them can be used. arbitrary_options = {} import sys try: with stdoutIO() as s: exec(self.arbitrary_code, arbitrary_options) printed = s.getvalue() if printed: print(printed) except SyntaxError as e: p.error("Invalid syntax in the arbitraty code:\n" + str(e)) quit() except: p.error("Unexpected error while parsing arbitrary code:") p.rawprint(str(sys.exc_info()[0]) + ':' + str(sys.exc_info()[1])) quit() try: with stdoutIO() as s: exec(content, options) printed = s.getvalue() if len(printed) > 0: p.info("The manifest inside " + self.config_file + " tried to print something:") for line in printed.split('\n'): 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)) quit() except: p.error("Encountered unexpected error while parsing " + self.config_file) p.rawprint(str(sys.exc_info()[0]) + ':' + str(sys.exc_info()[1])) quit() for opt_name, val in list(options.items()): #check delivered options if opt_name.startswith('__'): continue if opt_name not in self.__names(): if opt_name in arbitrary_options: continue else: #if opt_name.startswith("global_"): # continue raise NameError("Unrecognized option: " + opt_name) opt = self[opt_name] if type(val) not in opt.types: raise RuntimeError("Given option: " + str(type(val)) + " doesn't match specified types:" + str(opt.types)) ret[opt_name] = val # print("Opt_name ", opt_name) if type(val) == type(dict()): 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 pass 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 pass return ret
def parse(self): options = {} ret = {} 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 #now the trick: #I take the arbitrary code and parse it #the values are not important, but thanks to it I can check #if a variable came from the arbitrary code. #This is important because in the manifests only certain group #of variables is allowed. In arbitrary code all of them can be used. arbitrary_options = {} import sys try: with stdoutIO() as s: exec(self.arbitrary_code, arbitrary_options) printed = s.getvalue() if printed: print(printed) except SyntaxError as e: p.error("Invalid syntax in the arbitraty code:\n" + str(e)) quit() except: p.error("Unexpected error while parsing arbitrary code:") p.rawprint(str(sys.exc_info()[0])+':'+str(sys.exc_info()[1])) quit() try: with stdoutIO() as s: exec(content, options) printed = s.getvalue() if len(printed) > 0: p.info("The manifest inside " + self.config_file + " tried to print something:") for line in printed.split('\n'): 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)) quit() except: p.error("Encountered unexpected error while parsing " + self.config_file) p.rawprint(str(sys.exc_info()[0]) +':'+ str(sys.exc_info()[1])) quit() for opt_name, val in list(options.items()): #check delivered options if opt_name.startswith('__'): continue if opt_name not in self.__names(): if opt_name in arbitrary_options: continue else: #if opt_name.startswith("global_"): # continue raise NameError("Unrecognized option: " + opt_name) opt = self[opt_name] if type(val) not in opt.types: raise RuntimeError("Given option: "+str(type(val))+" doesn't match specified types:"+str(opt.types)) ret[opt_name] = val # print("Opt_name ", opt_name) if type(val) == type(dict()): 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 pass 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 pass return ret
def main(): usage = "usage: %prog [options]\n" usage += "type %prog --help to get help message" parser = optparse.OptionParser(usage=usage) parser.add_option("--manifest-help", action="store_true", dest="manifest_help", help="print manifest file variables description") 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") 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", default=None, help="fetch and/or update remote modules listed in Manifest") 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("--merge-cores=name", default=None, dest="merge_cores", 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" "files") parser.add_option("--quartus-proj", action="store_true", dest="quartus_proj", default=None, help="create/update a quartus 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") parser.add_option("--version", dest="print_version", action="store_true", default="false", help="print version id of this Hdlmake build") (options, _) = parser.parse_args() global_mod.options = options #HANDLE PROJECT INDEPENDENT OPTIONS if options.manifest_help == True: from manifest_parser import ManifestParser ManifestParser().help() quit() if options.print_version == True: p.print_version() quit() # Check later if a simulation 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") pool = ModulePool() pool.new_module(parent=None, url=os.getcwd(), source="local", fetchto=".") 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() global_mod.top_module = pool.get_top_module() 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", "make_vsim" : "generate_vsim_makefile", "make_isim" : "generate_isim_makefile", "ise_proj" : "generate_ise_project", "quartus_proj" : "generate_quartus_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", "merge_cores" : "merge_cores" } sth_chosen = False import traceback 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 : p.echo("Oooops! We've got an error. Here is the appropriate info:\n") p.print_version() print(unknown_error) traceback.print_exc()
def main(): usage = "usage: %prog [options]\n" usage += "type %prog --help to get help message" parser = optparse.OptionParser(usage=usage) parser.add_option("--manifest-help", action="store_true", dest="manifest_help", help="print manifest file variables description") 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") 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", default=None, help="fetch and/or update remote modules listed in Manifest") 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( "--merge-cores=name", default=None, dest="merge_cores", 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" "files") parser.add_option( "--quartus-proj", action="store_true", dest="quartus_proj", default=None, help="create/update a quartus 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") parser.add_option("--version", dest="print_version", action="store_true", default="false", help="print version id of this Hdlmake build") (options, _) = parser.parse_args() global_mod.options = options #HANDLE PROJECT INDEPENDENT OPTIONS if options.manifest_help == True: from manifest_parser import ManifestParser ManifestParser().help() quit() if options.print_version == True: p.print_version() quit() # Check later if a simulation 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") pool = ModulePool() pool.new_module(parent=None, url=os.getcwd(), source="local", fetchto=".") 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() global_mod.top_module = pool.get_top_module() 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", "make_vsim": "generate_vsim_makefile", "make_isim": "generate_isim_makefile", "ise_proj": "generate_ise_project", "quartus_proj": "generate_quartus_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", "merge_cores": "merge_cores" } sth_chosen = False import traceback 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: p.echo( "Oooops! We've got an error. Here is the appropriate info:\n") p.print_version() print(unknown_error) traceback.print_exc()
"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", "merge_cores": "merge_cores" } sth_chosen = False import traceback 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: p.echo( "Oooops! We've got an error. Here is the appropriate info:\n") p.print_version() print(unknown_error) traceback.print_exc() if not sth_chosen: p.rawprint("No option selected. Running automatic flow") p.rawprint("To see some help, type hdlmake --help") kernel.run() if __name__ == "__main__": main()