예제 #1
0
    def load_project(self, pathname):
        """ Load the  project
        """
        self.open_xml(pathname)
        components = self.get_node("components")
        # load components
        if(components):
            for node in components.get_nodes("component"):
                if node.get_attr_value("platform") is None:
                    comp = Component(self)
                else:
                    comp = Platform(self, node=self.get_node("platform"))
                try:
                    comp.load(node.get_attr_value("name"))
                except IOError:
                    self.del_subnode("components",
                                     "component",
                                     "name", node.get_attr_value("name"))
                    raise PodError("Can't open " +
                                   node.get_attr_value("name") +
                                   " directory", 0)
                else:
                    self._instanceslist.append(comp)

        # load toolchains
        toolchains = self.get_node("toolchain")
        if(toolchains):
            node = toolchains.get_node("simulation")
            if node is not None:
                self.simulation = Simulation(self, node.name)
            node = toolchains.get_node("synthesis")
            if node is not None:
                self.synthesis = synthesis_factory(self, node.name)

        # Set bus master-slave
        for masterinterface in self.interfaces_master:
            for slave in masterinterface.slaves:
                slaveinterface = slave.get_interface()
                masterinterface.alloc_mem.add_slave_interface(slaveinterface)
                slaveinterface.master = masterinterface

        # set bsp directory
        if self.get_node(nodename="bsp") is not None:
            self.bspdir = self.get_node(
                nodename="bsp").get_attr_value("directory")
        self.void = 0
예제 #2
0
    def load_project(self, pathname):
        """ Load the  project
        """
        self.open_xml(pathname)
        components = self.get_node("components")
        # load components
        if (components):
            for node in components.get_nodes("component"):
                if node.get_attr_value("platform") is None:
                    comp = Component(self)
                else:
                    comp = Platform(self, node=self.get_node("platform"))
                try:
                    comp.load(node.get_attr_value("name"))
                except IOError:
                    self.del_subnode("components", "component", "name",
                                     node.get_attr_value("name"))
                    raise PodError(
                        "Can't open " + node.get_attr_value("name") +
                        " directory", 0)
                else:
                    self._instanceslist.append(comp)

        # load toolchains
        toolchains = self.get_node("toolchain")
        if (toolchains):
            node = toolchains.get_node("simulation")
            if node is not None:
                self.simulation = Simulation(self, node.name)
            node = toolchains.get_node("synthesis")
            if node is not None:
                self.synthesis = synthesis_factory(self, node.name)

        # Set bus master-slave
        for masterinterface in self.interfaces_master:
            for slave in masterinterface.slaves:
                slaveinterface = slave.get_interface()
                masterinterface.alloc_mem.add_slave_interface(slaveinterface)
                slaveinterface.master = masterinterface

        # set bsp directory
        if self.get_node(nodename="bsp") is not None:
            self.bspdir = self.get_node(
                nodename="bsp").get_attr_value("directory")
        self.void = 0
예제 #3
0
    def __init__(self, parent, masterinterface):
        """ Init fonction
        """
        masterinstancename = masterinterface.parent.instancename
        masterinterfacename = masterinterface.name

        Component.__init__(self, parent)
        self.interfaceslist = []
        self.add_node(nodename="component")

        masterinstance = self.parent.get_instance(masterinstancename)
        masterinterface = masterinstance.get_interface(masterinterfacename)

        # Write xml description
        self.generate_xml(masterinterface)
        # Write Code for component

        masterinterface.bus.generate_intercon(self)

        DISPLAY.msg("Intercon with name : " + self.instancename + " Done")
예제 #4
0
    def __init__(self,parent,**keys):
        """ Init Component,
            __init__(self,parent,node)
            __init__(self,parent,file)
        """
        Component.__init__(self,parent)
        if "node" in keys:
            self.__initnode(keys["node"])
        elif "file" in keys:
            self.__initfile(keys["file"])
        else:
            raise Error("Keys unknown in Platform constructor",0)

        if self.getNode("interfaces") != None:
            for element in self.getNode("interfaces").getNodeList("interface"):
                self.interfaceslist.append(Interface(self,node=element))
        self.librarieslist = []
        if self.getNode("simulation") != None:
            for library in self.getNode("simulation").getNodeList("simlib"):
                self.librarieslist.append(SimulationLib(self,node=library))
예제 #5
0
    def __init__(self,masterinterface,project):
        """ Init fonction
        """
        masterinstancename = masterinterface.getParent().getInstanceName()
        masterinterfacename = masterinterface.getName()

        Component.__init__(self,project)
        self.interfaceslist = []
        self.addNode(nodename="component")

        masterinstance = self.parent.getInstance(masterinstancename)
        masterinterface = masterinstance.getInterface(masterinterfacename)

        # Write xml description
        self.generateXML(masterinterface)
        # Write Code for component

        masterinterface.getBus().generateIntercon(self)

        display.msg("Intercon with name : "+self.getInstanceName()+" Done")
예제 #6
0
    def __init__(self, parent, **keys):
        """ Init Component,
            __init__(self, parent, node)
            __init__(self, parent, file)
        """
        if "node" in keys:
            Component.__init__(self, parent, node=keys["node"])
        elif "file" in keys:
            Component.__init__(self, parent, afile=keys["file"])
        else:
            raise PodError("Keys unknown in Platform constructor", 0)

        if self.get_node("interfaces") is not None:
            for element in self.get_node("interfaces").get_nodes("interface"):
                self._interfaceslist.append(Interface(self, node=element))
        self.librarieslist = []
        if self.get_node("simulation") is not None:
            for library in self.get_node("simulation").get_nodes("simlib"):
                self.librarieslist.append(SimulationLib(self, node=library))

        self.instancename = self.name
        self.parent = parent
예제 #7
0
    def __init__(self, parent, **keys):
        """ Init Component,
            __init__(self, parent, node)
            __init__(self, parent, file)
        """
        if "node" in keys:
            Component.__init__(self, parent, node=keys["node"])
        elif "file" in keys:
            Component.__init__(self, parent, afile=keys["file"])
        else:
            raise PodError("Keys unknown in Platform constructor", 0)

        if self.get_node("interfaces") is not None:
            for element in self.get_node("interfaces").get_nodes("interface"):
                self._interfaceslist.append(Interface(self, node=element))
        self.librarieslist = []
        if self.get_node("simulation") is not None:
            for library in self.get_node("simulation").get_nodes("simlib"):
                self.librarieslist.append(SimulationLib(self, node=library))

        self.instancename = self.name
        self.parent = parent
예제 #8
0
    def add_instance(self, **keys):
        """ Add a component in project

        add_instance(self, component)
        add_instance(self, libraryname, componentname)
        add_instance(self, libraryname, componentname, instancename)
        add_instance(self, libraryname, componentname, componentversion)
        add_instance(self, libraryname, componentname,
                            componentversion, instancename)
        """
        if "component" in keys:
            comp = keys["component"]
            instancename = comp.instancename
        elif ("componentname" in keys) and ("libraryname" in keys):
            componentname = keys["componentname"]
            libraryname = keys["libraryname"]
            if "instancename" in keys:
                instancename = keys["instancename"]
                # check if instancename is not <componentname><number><number>
                if re.match(r'^' + componentname + r'\d{2}$', instancename):
                    raise PodError("Instance name forbiden, " +
                                   "it's reserved for " +
                                   "automatic instance name generation :" +
                                   instancename, 0)
                # check instance availability
                for instance in self.instances:
                    if instance.name == instancename:
                        raise PodError("This instance name already exists", 0)
            else:
                instancename =\
                    componentname +\
                    "%02d" %\
                    len(self.get_instances_list_of_component(componentname))
            if "componentversion" in keys:
                componentversion = keys["componentversion"]
            else:
                componentversion = None
            # Load and create component
            if (componentname == instancename):
                raise PodError("Instance name can't be the" +
                               "same as component name", 0)
            comp = Component(self)
            comp.load_new_instance(libraryname, componentname,
                                   componentversion, instancename)
            comp.num = str(len(
                self.get_instances_list_of_component(componentname)))
        else:
            raise PodError("Key not known in add_instance", 0)

        # Add component to project
        self._instanceslist.append(comp)
        if comp.is_platform() is False:
            self.add_subnode(nodename="components",
                             subnodename="component",
                             attributename="name",
                             value=instancename)
        else:
            attrib = {"name": instancename, "platform": "true"}
            self.add_subnode(nodename="components",
                             subnodename="component",
                             attributedict=attrib)
        DISPLAY.msg("Component " + comp.name + " added as " + instancename)
        self.save()
예제 #9
0
 def getInstanceName(self):
     return Component.getName(self)
예제 #10
0
    def add_instance(self, **keys):
        """ Add a component in project

        add_instance(self, component)
        add_instance(self, libraryname, componentname)
        add_instance(self, libraryname, componentname, instancename)
        add_instance(self, libraryname, componentname, componentversion)
        add_instance(self, libraryname, componentname,
                            componentversion, instancename)
        """
        if "component" in keys:
            comp = keys["component"]
            instancename = comp.instancename
        elif ("componentname" in keys) and ("libraryname" in keys):
            componentname = keys["componentname"]
            libraryname = keys["libraryname"]
            if "instancename" in keys:
                instancename = keys["instancename"]
                # check if instancename is not <componentname><number><number>
                if re.match(r'^' + componentname + r'\d{2}$', instancename):
                    raise PodError(
                        "Instance name forbiden, " + "it's reserved for " +
                        "automatic instance name generation :" + instancename,
                        0)
                # check instance availability
                for instance in self.instances:
                    if instance.name == instancename:
                        raise PodError("This instance name already exists", 0)
            else:
                instancename =\
                    componentname +\
                    "%02d" %\
                    len(self.get_instances_list_of_component(componentname))
            if "componentversion" in keys:
                componentversion = keys["componentversion"]
            else:
                componentversion = None
            # Load and create component
            if (componentname == instancename):
                raise PodError(
                    "Instance name can't be the" + "same as component name", 0)
            comp = Component(self)
            comp.load_new_instance(libraryname, componentname,
                                   componentversion, instancename)
            comp.num = str(
                len(self.get_instances_list_of_component(componentname)))
        else:
            raise PodError("Key not known in add_instance", 0)

        # Add component to project
        self._instanceslist.append(comp)
        if comp.is_platform() is False:
            self.add_subnode(nodename="components",
                             subnodename="component",
                             attributename="name",
                             value=instancename)
        else:
            attrib = {"name": instancename, "platform": "true"}
            self.add_subnode(nodename="components",
                             subnodename="component",
                             attributedict=attrib)
        DISPLAY.msg("Component " + comp.name + " added as " + instancename)
        self.save()