예제 #1
0
    def do_load(self, line):
        """\
Usage : projectload <projectfilename>.xml
Load a project
        """
        try:
            self.checkargs(line, "<projectfilename>.xml")
        except PodError as error:
            print(error)
            return
        if sy.dir_exist(line):
            head, projectname = os.path.split(line)
            line = os.path.join(head, projectname, projectname + ".xml")
        if not sy.file_exist(line):
            print(PodError("File doesn't exists"))
            return
        try:
            self._project = Project(line)
        except PodError as error:
            print(error)
            return
        except IOError as error:
            print(error)
            return
        self.setPrompt("POD:" + self._project.name)
        print(DISPLAY)
예제 #2
0
 def __init__(self, parent):
     self.parent = parent
     filepath = self.parent.projectpath + "/" +\
         SIMULATIONPATH + "/simulation" + XMLEXT
     if not sy.file_exist(filepath):
         raise PodError("No simulation project found", 3)
     WrapperXml.__init__(self, file=filepath)
예제 #3
0
    def do_load(self, line):
        """\
Usage : projectload <projectfilename>.xml
Load a project
        """
        try:
            self.checkargs(line, "<projectfilename>.xml")
        except PodError as error:
            print(error)
            return
        if sy.dir_exist(line):
            head, projectname = os.path.split(line)
            line = os.path.join(head, projectname, projectname + ".xml")
        if not sy.file_exist(line):
            print(PodError("File doesn't exists"))
            return
        try:
            self._project = Project(line)
        except PodError as error:
            print(error)
            return
        except IOError as error:
            print(error)
            return
        self.setPrompt("POD:" + self._project.name)
        print(DISPLAY)
예제 #4
0
 def __init__(self, parent):
     self.parent = parent
     filepath = self.parent.projectpath + "/" +\
         SIMULATIONPATH + "/simulation" + XMLEXT
     if not sy.file_exist(filepath):
         raise PodError("No simulation project found", 3)
     WrapperXml.__init__(self, file=filepath)
예제 #5
0
 def __init__(self, project):
     self.project = project
     filepath = self.project.projectpath + "/" + \
         DRIVERSPATH + "/drivers" + XMLEXT
     if not sy.file_exist(filepath):
         raise PodError("No driver project found", 3)
     WrapperXml.__init__(self, file=filepath)
     self.bspdir = None
예제 #6
0
 def __init__(self, project):
     self.project = project
     filepath = self.project.projectpath + "/" + \
         DRIVERSPATH + "/drivers" + XMLEXT
     if not sy.file_exist(filepath):
         raise PodError("No driver project found", 3)
     WrapperXml.__init__(self, file=filepath)
     self.bspdir = None
예제 #7
0
    def load_new_instance(self, libraryname, componentname, componentversion,
                          instancename):
        """ Load a new component from library
        """
        project = self.parent
        # verify component name
        if project.name == instancename:
            raise PodError(
                "Instance name can't be " + "the same name as projectname", 0)
        # test if component exist
        if not sy.file_exist(
                project.library.library_path(libraryname) + "/" +
                componentname):
            raise PodError(
                "No component with name " + libraryname + "." + componentname,
                0)

        # test if several componentversion
        if componentversion is None:
            if len(project.get_components_versions(libraryname,
                                                   componentname)) > 1:
                raise PodError(
                    "Component version must be chosen :" + str(
                        project.get_components_versions(
                            libraryname, componentname)), 0)
            else:
                try:
                    componentversion = project.get_components_versions(
                        libraryname, componentname)[0]
                except IndexError:
                    raise PodError("No xml description of component", 0)
        if instancename is None:
            instancename =\
                componentname + "%02d" %\
                len(project.get_instances_list_of_component(componentname))

        # copy and rename directory
        sy.cp_dir(
            project.library.library_path(libraryname) + "/" + componentname,
            self.parent.projectpath + COMPONENTSPATH)
        try:
            sy.rename_dir(
                self.parent.projectpath + COMPONENTSPATH + "/" + componentname,
                self.parent.projectpath + COMPONENTSPATH + "/" + instancename)
        except PodError:  # if directory exist
            pass

        # Rename xml file
        sy.rename_file(
            self.parent.projectpath + COMPONENTSPATH + "/" + instancename +
            "/" + componentversion + XMLEXT, self.parent.projectpath +
            COMPONENTSPATH + "/" + instancename + "/" + instancename + XMLEXT)

        # load component
        self.load(instancename)
        # Connect platform connection
        self.autoconnect_pins()
예제 #8
0
    def load_new_instance(self, libraryname, componentname,
                          componentversion, instancename):
        """ Load a new component from library
        """
        project = self.parent
        # verify component name
        if project.name == instancename:
            raise PodError("Instance name can't be " +
                           "the same name as projectname", 0)
        # test if component exist
        if not sy.file_exist(project.library.library_path(libraryname) +
                             "/" + componentname):
            raise PodError("No component with name " +
                           libraryname + "." + componentname, 0)

        # test if several componentversion
        if componentversion is None:
            if len(project.get_components_versions(libraryname,
                                                   componentname)) > 1:
                raise PodError("Component version must be chosen :" +
                               str(project.get_components_versions(
                                   libraryname, componentname)), 0)
            else:
                try:
                    componentversion = project.get_components_versions(
                        libraryname, componentname)[0]
                except IndexError:
                    raise PodError("No xml description of component", 0)
        if instancename is None:
            instancename =\
                componentname + "%02d" %\
                len(project.get_instances_list_of_component(componentname))

        # copy and rename directory
        sy.cp_dir(project.library.library_path(libraryname) +
                  "/" + componentname,
                  self.parent.projectpath + COMPONENTSPATH)
        try:
            sy.rename_dir(self.parent.projectpath +
                          COMPONENTSPATH + "/" + componentname,
                          self.parent.projectpath + COMPONENTSPATH +
                          "/" + instancename)
        except PodError:  # if directory exist
            pass

        # Rename xml file
        sy.rename_file(self.parent.projectpath +
                       COMPONENTSPATH + "/" + instancename +
                       "/" + componentversion + XMLEXT,
                       self.parent.projectpath + COMPONENTSPATH +
                       "/" + instancename + "/" + instancename + XMLEXT)

        # load component
        self.load(instancename)
        # Connect platform connection
        self.autoconnect_pins()
예제 #9
0
def generate_template():
    """ generate Template Testbench
    """
    filename = SETTINGS.projectpath + SIMULATIONPATH +\
        "/top_" + SETTINGS.active_project.name +\
        "_tb" + VHDLEXT
    clockportlist = SETTINGS.active_project.clock_ports
    if len(clockportlist) == 0:
        raise PodError("No external clock signal found", 0)
    if len(clockportlist) != 1:
        DISPLAY.msg("More than one external clock in design", 1)
    clockport = clockportlist[0]
    clockname = clockport.parent.parent.instancename +\
        "_" + clockport.name

    ###################
    # header
    out = header()
    out = out + include()
    out = out + entity()
    out = out + architecturehead()
    freq = clockport.dest_port.frequency
    clockhalfperiod = (1000 / float(freq)) / 2
    out = out + constant(clockhalfperiod)
    portlist = SETTINGS.active_project.platform.connect_ports
    out = out + signals(portlist)
    out = out + declareTop(portlist)
    out = out + beginarch()
    out = out + connectTop(portlist)

    out = out + stimulis()

    out = out + "\n"
    out = out + clock(clockname)
    out = out + "\n"
    out = out + endarch()
    #######################
    # save file
    if sy.file_exist(filename):
        DISPLAY.msg(
            "[WARNING] File exist, file renamed in " + filename + "old", 0)
        sy.rename_file(filename, filename + "old")
    try:
        afile = open(filename, "w")
    except IOError as error:
        raise error
    afile.write(out)
    afile.close()
    return filename
예제 #10
0
def generate_template():
    """ generate Template Testbench
    """
    filename = SETTINGS.projectpath + SIMULATIONPATH +\
        "/top_" + SETTINGS.active_project.name +\
        "_tb" + VHDLEXT
    clockportlist = SETTINGS.active_project.clock_ports
    if len(clockportlist) == 0:
        raise PodError("No external clock signal found", 0)
    if len(clockportlist) != 1:
        DISPLAY.msg("More than one external clock in design", 1)
    clockport = clockportlist[0]
    clockname = clockport.parent.parent.instancename +\
        "_" + clockport.name

    ###################
    # header
    out = header()
    out = out + include()
    out = out + entity()
    out = out + architecturehead()
    freq = clockport.dest_port.frequency
    clockhalfperiod = (1000 / float(freq)) / 2
    out = out + constant(clockhalfperiod)
    portlist = SETTINGS.active_project.platform.connect_ports
    out = out + signals(portlist)
    out = out + declareTop(portlist)
    out = out + beginarch()
    out = out + connectTop(portlist)

    out = out + stimulis()

    out = out + "\n"
    out = out + clock(clockname)
    out = out + "\n"
    out = out + endarch()
    #######################
    # save file
    if sy.file_exist(filename):
        DISPLAY.msg("[WARNING] File exist, file renamed in " +
                    filename + "old", 0)
        sy.rename_file(filename, filename + "old")
    try:
        afile = open(filename, "w")
    except IOError as error:
        raise error
    afile.write(out)
    afile.close()
    return filename
예제 #11
0
    def select_platform(self, platformname, platformlibname):
        """ Select a platform for the project
        """
        # suppress platform if already exists
        try:
            self.del_platform()
        except PodError as error:
            if error.level < 2:
                raise error
            print(error)

        if platformlibname == "standard":
            platformdir = SETTINGS.path + PLATFORMPATH +\
                "/" + platformname + "/"
        else:
            # if not standard platform, try personnal platform
            try:
                platformdir = SETTINGS.get_platform_lib_path(platformlibname) +\
                    "/" + platformname + "/"
            except TypeError:
                # if not personnal platform, try project specific
                # platform (added with add_platforms_lib cmd)
                platformdir = ""
                for node in self.get_subnodes("platformlibs", "platformlib"):
                    apath = node.get_attr_value("path")
                    if apath.split("/")[-1] == platformlibname:
                        platformdir = apath + "/" + platformname + "/"
                if platformdir == "":
                    raise PodError("Platform name error")
        platform = Platform(self, file=platformdir + platformname + XMLEXT)

        if sy.file_exist(platformdir + SIMULATIONPATH):
            sy.copy_all_files(platformdir + SIMULATIONPATH,
                              self.projectpath + SIMULATIONPATH)
        self.add_instance(component=platform)
        self.add_node(node=platform)
        # Adding platform default components
        for component in platform.components:
            self.add_instance(libraryname=component["type"],
                              componentname=component["name"])
        self.save()
예제 #12
0
    def select_platform(self, platformname, platformlibname):
        """ Select a platform for the project
        """
        # suppress platform if already exists
        try:
            self.del_platform()
        except PodError as error:
            if error.level < 2:
                raise error
            print(error)

        if platformlibname == "standard":
            platformdir = SETTINGS.path + PLATFORMPATH +\
                "/" + platformname + "/"
        else:
            # if not standard platform, try personnal platform
            try:
                platformdir = SETTINGS.get_platform_lib_path(platformlibname) +\
                    "/" + platformname + "/"
            except TypeError:
                # if not personnal platform, try project specific
                # platform (added with add_platforms_lib cmd)
                platformdir = ""
                for node in self.get_subnodes("platformlibs", "platformlib"):
                    apath = node.get_attr_value("path")
                    if apath.split("/")[-1] == platformlibname:
                        platformdir = apath + "/" + platformname + "/"
                if platformdir == "":
                    raise PodError("Platform name error")
        platform = Platform(self, file=platformdir + platformname + XMLEXT)

        if sy.file_exist(platformdir + SIMULATIONPATH):
            sy.copy_all_files(platformdir + SIMULATIONPATH,
                              self.projectpath + SIMULATIONPATH)
        self.add_instance(component=platform)
        self.add_node(node=platform)
        # Adding platform default components
        for component in platform.components:
            self.add_instance(libraryname=component["type"],
                              componentname=component["name"])
        self.save()
예제 #13
0
    def __init__(self,
                 projectpathname,
                 void=0,
                 description="insert a description here"):
        """ create project if doesn't exist
        """
        self.void = void
        WrapperXml.__init__(self, nodename="void")
        self._instanceslist = []
        self._vhdl_version = "vhdl87"

        self.simulation = None
        self.synthesis = None
        self.driver = None

        self._library = Library(self)

        self.bspdir = None
        self.bspos = None
        if not self.void:
            if projectpathname.find(XMLEXT) >= 0:
                try:
                    self._projectpath =\
                        os.path.abspath(os.path.dirname(projectpathname))
                except IOError as error:
                    raise PodError(str(error), 0)
            else:
                self._projectpath = projectpathname
            SETTINGS.projectpath = self.projectpath
            SETTINGS.author = ""
            SETTINGS.active_project = self
            name = os.path.basename(projectpathname)
            if sy.file_exist(projectpathname):
                self.load_project(projectpathname)
            else:
                self.create_project(name)
            self.description = description

            SETTINGS.active_project = self
예제 #14
0
    def __init__(self, projectpathname, void=0,
                 description="insert a description here"):
        """ create project if doesn't exist
        """
        self.void = void
        WrapperXml.__init__(self, nodename="void")
        self._instanceslist = []
        self._vhdl_version = "vhdl87"

        self.simulation = None
        self.synthesis = None
        self.driver = None

        self._library = Library(self)

        self.bspdir = None
        self.bspos = None
        if not self.void:
            if projectpathname.find(XMLEXT) >= 0:
                try:
                    self._projectpath =\
                        os.path.abspath(os.path.dirname(projectpathname))
                except IOError as error:
                    raise PodError(str(error), 0)
            else:
                self._projectpath = projectpathname
            SETTINGS.projectpath = self.projectpath
            SETTINGS.author = ""
            SETTINGS.active_project = self
            name = os.path.basename(projectpathname)
            if sy.file_exist(projectpathname):
                self.load_project(projectpathname)
            else:
                self.create_project(name)
            self.description = description

            SETTINGS.active_project = self