def find_module(path, user_paths, instance_name=None): module_tags = vutils.get_module_tags(filename=path, user_paths=user_paths) return Module(module_tags, path, user_paths, instance_name, is_include_file=False, depth=0)
def generate_sub_slave_dict(sim_dict, debug = False): #Get sim module tags filename = utils.find_module_filename(sim_dict["name"]) filepath = utils.find_rtl_file_location(filename) sim_tags = vutils.get_module_tags(filepath) bind_dict = sim_tags["ports"] sim_tags["bind"] = {} #Go through each dictionary entry and determine the direction for signal in sim_dict["bind"]: #XXX: Don't support subset of busses yet sim_tags["bind"][signal] = {} sim_tags["bind"][signal]["loc"] = sim_dict["bind"][signal] sim_tags["bind"][signal]["direction"] = get_bind_direction(signal, sim_tags) return sim_tags
def generate_sub_module(self, invert_reset, instance_name, config_tags, module_tags = None, enable_unique_ports = True, debug = False): if module_tags is None: filepath = utils.find_rtl_file_location(config_tags["filename"], self.user_paths) module_tags = vutils.get_module_tags(filepath, user_paths = self.user_paths) #if debug: #print "Module Tags:" #utils.pretty_print_dict(module_tags) buf = "//Module %s ( %s )\n" % (module_tags["module"], instance_name) buf += "\n" prename = "" if enable_unique_ports: prename = instance_name buf += self.generate_sub_module_wires(invert_reset, prename, module_tags) buf += vutils.generate_module_port_signals(invert_reset = invert_reset, name = instance_name, prename = prename, slave_tags = config_tags, module_tags = module_tags) #Add the bindings for this modules to the bind dictionary if "bind" in config_tags: for bind in config_tags["bind"]: bname = bind if len(prename) > 0: bname = "%s_%s" % (prename, bind) self.bindings[bname] = {} self.bindings[bname] = config_tags["bind"][bind] return buf
def generate_sub_module(self, invert_reset, instance_name, config_tags, module_tags=None, enable_unique_ports=True, debug=False): if module_tags is None: filepath = utils.find_rtl_file_location(config_tags["filename"], self.user_paths) module_tags = vutils.get_module_tags(filepath, user_paths=self.user_paths) #if debug: #print "Module Tags:" #utils.pretty_print_dict(module_tags) buf = "//Module %s ( %s )\n" % (module_tags["module"], instance_name) buf += "\n" prename = "" if enable_unique_ports: prename = instance_name buf += self.generate_sub_module_wires(invert_reset, prename, module_tags) buf += vutils.generate_module_port_signals(invert_reset=invert_reset, name=instance_name, prename=prename, slave_tags=config_tags, module_tags=module_tags) #Add the bindings for this modules to the bind dictionary if "bind" in config_tags: for bind in config_tags["bind"]: bname = bind if len(prename) > 0: bname = "%s_%s" % (prename, bind) self.bindings[bname] = {} self.bindings[bname] = config_tags["bind"][bind] return buf
def _resolve_dependency_for_module(self, module_path): vpos = 0 buf = "" try: filein = open(module_path) buf = str(filein.read()) filein.close() except IOError as e: raise ModuleError("File %s not found" % module_path) buf = utils.remove_comments(buf) include_buf = buf while len(include_buf.partition("`include")[2]) > 0: ifname = include_buf.partition("`include")[2] ifname = ifname.splitlines()[0] ifname = ifname.strip() ifname = ifname.strip("\"") #self.logger.debug("Found ifname: %s" % ifname) module = None try: filename = utils.find_module_filename(ifname, self.user_paths) module_tags = vutils.get_module_tags(filename, self.user_paths) module = Module(module_tags, path = filename, user_paths = self.user_paths, instance_name = None, is_include_file = True, depth = self.depth + 1) except ModuleError: self.logger.debug("Didn't find verilog module with filename: %s" % ifname) module_tags = {} module_tags["module"] = ifname module = Module(module_tags, path = None, user_paths = self.user_paths, instance_name = None, is_include_file = True, depth = self.depth + 1) module.set_vpos(vpos) vpos + 1 include_buf = include_buf.partition("`include")[2] for n in module.get_module_graph().nodes(): #m = module.get_module_graph().node[n] #self.graph.add_node(n) #self.graph.node[n] = m #if n not in self.graph.nodes(): m = module.get_module_graph().node[n] self.graph.add_node(id(m)) self.graph.node[id(m)] = m self.graph.add_edges_from(module.get_module_graph().edges()) self.graph.add_edge(id(self), id(module)) self.logger.debug("Looking for actual modules...") module_dict = self.find_modules_within_buffer(buf.partition(")")[2]) for instance in module_dict: module_type = module_dict[instance] self.logger.info("module_type: %s" % module_type) module = None #print "Module Type: %s" % module_type try: filename = utils.find_module_filename(module_type, self.user_paths) #print "Filename: %s" % filename module_tags = vutils.get_module_tags(filename, user_paths = self.user_paths) #print "got tags..." module = Module(module_tags, path = filename, user_paths = self.user_paths, instance_name = instance, is_include_file = False, depth = self.depth + 1) except ModuleError: #self.logger.debug("Didn't find verilog module with filename :%s" % module_type) module_tags = {} module_tags["module"] = module_type module = Module(module_tags, path = None, user_paths = self.user_paths, instance_name = instance, is_include_file = False, depth = self.depth + 1) for n in module.get_module_graph().nodes(): m = module.get_module_graph().node[n] self.graph.add_node(id(m)) self.graph.node[id(m)] = m module.set_vpos(vpos) vpos + 1 #self.graph.add_nodes_from(module.get_module_graph().nodes()) self.graph.add_edges_from(module.get_module_graph().edges()) self.graph.add_edge(id(self), id(module))
def find_module(path, user_paths, instance_name = None): module_tags = vutils.get_module_tags(filename = path, user_paths = user_paths) return Module(module_tags, path, user_paths, instance_name, is_include_file = False, depth = 0)
def _resolve_dependency_for_module(self, module_path): vpos = 0 buf = "" try: filein = open(module_path) buf = str(filein.read()) filein.close() except IOError as e: raise ModuleError("File %s not found" % module_path) buf = utils.remove_comments(buf) include_buf = buf while len(include_buf.partition("`include")[2]) > 0: ifname = include_buf.partition("`include")[2] ifname = ifname.splitlines()[0] ifname = ifname.strip() ifname = ifname.strip("\"") #self.logger.debug("Found ifname: %s" % ifname) module = None try: filename = utils.find_module_filename(ifname, self.user_paths) module_tags = vutils.get_module_tags(filename, self.user_paths) module = Module(module_tags, path=filename, user_paths=self.user_paths, instance_name=None, is_include_file=True, depth=self.depth + 1) except ModuleError: self.logger.debug( "Didn't find verilog module with filename: %s" % ifname) module_tags = {} module_tags["module"] = ifname module = Module(module_tags, path=None, user_paths=self.user_paths, instance_name=None, is_include_file=True, depth=self.depth + 1) module.set_vpos(vpos) vpos + 1 include_buf = include_buf.partition("`include")[2] for n in module.get_module_graph().nodes(): #m = module.get_module_graph().node[n] #self.graph.add_node(n) #self.graph.node[n] = m #if n not in self.graph.nodes(): m = module.get_module_graph().node[n] self.graph.add_node(id(m)) self.graph.node[id(m)] = m self.graph.add_edges_from(module.get_module_graph().edges()) self.graph.add_edge(id(self), id(module)) self.logger.debug("Looking for actual modules...") module_dict = self.find_modules_within_buffer(buf.partition(")")[2]) for instance in module_dict: module_type = module_dict[instance] self.logger.info("module_type: %s" % module_type) module = None #print "Module Type: %s" % module_type try: filename = utils.find_module_filename(module_type, self.user_paths) #print "Filename: %s" % filename module_tags = vutils.get_module_tags( filename, user_paths=self.user_paths) #print "got tags..." module = Module(module_tags, path=filename, user_paths=self.user_paths, instance_name=instance, is_include_file=False, depth=self.depth + 1) except ModuleError: #self.logger.debug("Didn't find verilog module with filename :%s" % module_type) module_tags = {} module_tags["module"] = module_type module = Module(module_tags, path=None, user_paths=self.user_paths, instance_name=instance, is_include_file=False, depth=self.depth + 1) for n in module.get_module_graph().nodes(): m = module.get_module_graph().node[n] self.graph.add_node(id(m)) self.graph.node[id(m)] = m module.set_vpos(vpos) vpos + 1 #self.graph.add_nodes_from(module.get_module_graph().nodes()) self.graph.add_edges_from(module.get_module_graph().edges()) self.graph.add_edge(id(self), id(module))