def __init__(self,project):
     self.project = project
     filepath = settings.projectpath+"/"+DRIVERSPATH+"/drivers"+XMLEXT
     if not sy.fileExist(filepath):
         raise Error("No driver project found",3)
     WrapperXml.__init__(self,file=filepath)
     self.bspdir = None
Exemple #2
0
 def __init__(self,parent):
     self.parent = parent
     filepath = settings.projectpath+"/"+SYNTHESISPATH+"/synthesis"+XMLEXT
     if not sy.fileExist(filepath):
         raise Error("No synthesis project found",3)
     WrapperXml.__init__(self,file=filepath)
     # adding path for toolchain plugin
     sys.path.append(settings.path+TOOLCHAINPATH+\
             SYNTHESISPATH+"/"+self.getName())
    def loadNewInstance(self,libraryname,componentname,
                         componentversion,instancename):
        """ Load a new component from library
        """
        project = self.getParent()
        # verify component name
        if project.getName() == instancename:
          raise Error("Instance name can't be the same name as projectname",0)
        # test if component exist
        if not sy.fileExist(
                project.library.getLibraryPath(libraryname)+\
                        "/"+componentname):
            raise Error("No component with name "+\
                        libraryname+"."+componentname,0)

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

        #copy and rename directory
        sy.copyDirectory(project.library.getLibraryPath( libraryname)+\
                "/"+componentname,settings.projectpath + COMPONENTSPATH)
        try:
            sy.renameDirectory(settings.projectpath+COMPONENTSPATH+\
                    "/"+componentname,\
                    settings.projectpath + COMPONENTSPATH+"/" + instancename)
        except Error: # if directory exist
            pass
        #Rename xml file
        sy.renameFile(settings.projectpath+COMPONENTSPATH+"/"\
                +instancename+"/"+componentversion+XMLEXT,\
                settings.projectpath+COMPONENTSPATH+"/"+instancename+"/"\
                +instancename + XMLEXT)

        #load component
        self.loadInstance(instancename)
        #Connect platform connection
        self.autoconnectPin()
Exemple #4
0
def generateTemplate():
    """ generate Template Testbench
    """
    filename = settings.projectpath+SIMULATIONPATH+"/top_"+ settings.active_project.getName()+"_tb"+VHDLEXT
    clockportlist = settings.active_project.getListClockPorts()
    if len(clockportlist) == 0:
        raise Error("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.getParent().getParent().getInstanceName()+"_"+clockport.getName()

    ###################
    # header
    out = header()
    out = out + include()
    out = out + entity()
    out = out + architecturehead()
    freq = clockport.getDestinationPort().getFreq()
    clockhalfperiode= (1000/float(freq))/2
    out = out + constant(clockhalfperiode)
    portlist =  settings.active_project.getPlatform().getConnectPortsList()
    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.fileExist(filename):
        display.msg("[WARNING] File exist, file renamed in "+filename+"old",0)
        sy.renameFile(filename,filename+"old")
    try:
        file = open(filename,"w")
    except IOError, e:
        raise e
    def setHDLfile(self,hdlfilepath,istop=0,scope="both"):
        """ Add HDL file in library component
        """
        if not sy.fileExist(hdlfilepath):
            raise Error("File "+hdlfilepath+" doesn't exist")

        hdl_file_name = os.path.basename(hdlfilepath)
        if hdl_file_name in [hdlfile.getFileName()
                    for hdlfile in self.getHdl_filesList()]:
            raise Error("File "+hdlfilepath+" is already in component")

        if istop:
            topfile = self.getHDLTop()
            if topfile != None:
                raise Error("There is a top HDL file in component named "+\
                        topfile.getFileName())

        # copy file in component directory
        hdlpath = os.path.join(self.getComponentPath(),"hdl")
        sy.copyFile(hdlfilepath,hdlpath)
        # create hdl_file node
        hdl_file_object = Hdl_file(self,
                                   filename=hdl_file_name,
                                   istop=istop,
                                   scope=scope)
        if istop:
            if hdl_file_object.getEntityName() != self.getName():
                raise Error("Entity name must be the same of component name")
            # automaticaly add generics
            generic_list = hdl_file_object.getGenericsList()
            for generic in generic_list:
                self.addGeneric(generic)
                display.msg(str(Error("Generic "+generic.getName()+\
                                " added in component",2)))

        # add node in component
        self.addSubNode(nodename="hdl_files",subnode=hdl_file_object)
        filelist = self.hdl_fileslist.append(hdl_file_object)
        return filelist
Exemple #6
0
 def createComponent(self,componentname,libraryname,versionname):
     """ Creating new component 'componentname' for 
         library 'libraryname'
     """
     librarypath = settings.active_library.getLibraryPath(libraryname)
     componentpath = os.path.join(librarypath,componentname)
     # verify if component and version exist
     if sy.fileExist(os.path.join(componentpath,versionname+XMLEXT)):
             settings.active_component = None
             raise Error("Component version "+componentname+"."+versionname+\
                         " already exist")
     # make directories if component is really new
     if not sy.dirExist(componentpath):
         sy.makeDirectory(componentpath)
         sy.makeDirectory(os.path.join(componentpath,"hdl"))
         sy.makeDirectory(os.path.join(componentpath,"doc"))
         sy.makeDirectory(os.path.join(componentpath,"drivers_templates"))
     
     # create xml file
     WrapperXml.__init__(self,nodename="component")
     self.setName(componentname)
     self.saveComponent(os.path.join(componentpath,versionname))
     self.setVersionName(versionname)
        return self.completelist(line,text,listfile)

    def do_load(self,line):
        """\
Usage : projectload <projectfilename>.xml
Load a project
        """
        try:
            self.checkargs(line,"<projectfilename>.xml")
        except Error,e:
            print e
            return
        if sy.dirExist(line):
           head,projectname = os.path.split(line)
           line = os.path.join(head,projectname,projectname+".xml")
        if not sy.fileExist(line):
            print Error("File doesn't exists")
            return
        try:
                settings.active_project = Project(line)
        except Error,e:
            print e
            return
        except IOError,e:
            print e
            return
        self.setPrompt("POD:"+settings.active_project.getName())
        print display

    def complete_addcomponentslib(self, text, line, begidx, endidx):
        """ TOOD """
 def __init__(self,parent):
     self.parent = parent
     filepath = settings.projectpath+"/"+SIMULATIONPATH+"/simulation"+XMLEXT
     if not sy.fileExist(filepath):
         raise Error("No simulation project found",3)
     WrapperXml.__init__(self,file=filepath)