def extend(config): """ Precondition: cwd= <dsn_name>/script Output: dictionary { keys=main, dep, tb, other values=list of path files} """ config['rootPath'] = os.path.abspath('..').replace('\\', '/') config['dsnName'] = os.path.split(config['rootPath'])[1] allSrc = [] for i in ['../src', '../TestBench', '../script', '../resource']: allSrc += structure.search(directory = i, ignoreDir = hdlGlobals.ignoreRepoDir) config['allSrc'] = allSrc mainSrcUncopied = structure.search(directory = aldecPath+'/src', onlyExt = hdlGlobals.hdlFileExt, ignoreDir = hdlGlobals.ignoreRepoDir) config['srcUncopied'] = mainSrcUncopied config['TestBenchSrc'] = structure.search(directory='../TestBench', ignoreDir = hdlGlobals.ignoreRepoDir) config['netlistSrc'] = structure.search(directory = aldecPath + '/src', onlyExt = '.sedif .edn .edf .edif .ngc'.split()) config['filesToCompile'] = config['mainSrc'] + config['depSrc'] + config['TestBenchSrc'] + mainSrcUncopied #TODO: refactor me #add cores src (ignore other folders) to project navigator path = os.path.abspath(os.getcwd()) pathAsList = path.replace('\\', '/').split('/') if pathAsList[-3] == 'cores': repoPath = '/'.join(pathAsList[:-3]) else: repoPath = '/'.join(pathAsList[:-2]) config['repoPath'] = repoPath # print repoPath repoSrc = [] for root, dirs, files in os.walk(repoPath): if config['dsnName'] in dirs: dirs.remove(config['dsnName']) for i in ['aldec', 'synthesis', 'implement', '.svn', '.git', 'TestBench', 'script', 'resource']: if i in dirs: dirs.remove(i) for f in files: if 'src' in root+'/'+f: repoSrc.append(os.path.abspath(root+'/'+f).replace('\\', '/')) config['repoSrc'] = repoSrc config['build'] = build.load()
def cleanAldec(): if not {'resource', 'script', 'src', 'TestBench'}.issubset(os.listdir(os.getcwd()+'/..')): return cl = structure.search(directory = aldecPath, ignoreDir = ['implement', 'synthesis', 'src']) for i in cl: if os.path.isdir(i): shutil.rmtree(i) else: os.remove(i)
def getFullPathToUcf(iUcf): # could be # empty # valid full path # wrong name\path # just name without extension # name with extension if not iUcf: return False if os.path.exists(iUcf): return os.path.abspath(iUcf).replace('\\', '/') if os.path.splitext(iUcf)[1] == '.ucf': ucfFiles = glob.glob(iUcf) # pattern = iUcf if os.path.splitext(iUcf)[1] == '.ucf' else iUcf+'.ucf' else: ucfFiles = structure.search(directory='../src', onlyExt = ['.ucf']) print ucfFiles if ucfFiles: return ucfFiles[0].replace('\\', '/')
def run(config): log.info("Implementation stage...") implPath = os.path.abspath(implementPath) + "/" synPath = os.path.abspath(synthesisPath) + "/" clean(implPath) top = os.path.join(synPath, config["top"] + ".edf") progressBar.run() cnt = 50 while not os.path.exists(top) or not cnt: cnt -= 1 time.sleep(1) progressBar.stop() if not cnt: log.error("Cant find netlist, try sythesis step first.") sys.exit(1) ucfSymplicity = structure.search(synPath, onlyExt=".ucf", ignoreDir=hdlGlobals.ignoreRepoDir) ucf = ucfSymplicity[0] or config["ucf"] for i in config.get("depNetlist", []): shutil.copyfile(i, implPath + os.path.split(i)[1]) shutil.copyfile(ucf, implPath + config["top"] + ".ucf") shutil.copyfile(top, implPath + config["top"] + ".edf") os.chdir(implPath) while not os.path.exists(config["top"] + ".edf"): print "cant find file: ", config["top"] time.sleep(0.1) try: subprocess.check_call( ("{xflow} -implement balanced.opt" " -config bitgen.opt {netlist}.edf").format( xflow=toolchain.Tool().get("ise_xflow"), netlist=config["top"] ) ) except subprocess.CalledProcessError as e: log.error(e) sys.exit() bit2mcs(config) log.info("Implementation done")
def run(): src = os.path.dirname(__file__) fake_repo = os.path.join(src,'fake_repo') dst_fake_repo = os.path.join(os.getcwd(),'fake_repo') if os.path.exists(dst_fake_repo): shutil.rmtree(dst_fake_repo) shutil.copytree(fake_repo, 'fake_repo') fake_repo_gold = os.path.join(src, 'fake_repo_gold') scripts = structure.search(dst_fake_repo, iOnly=['kungfu.py']) for s in scripts: startTest = time.clock() # path / fake_repo / dsn / script / kungfu.py pathAsList = s.replace('\\', '/').split('/') scriptFolder = '/'.join(pathAsList[:-1]) os.chdir(scriptFolder) subprocess.call('python kungfu.py -tb') dsnName = pathAsList[-3] res = diff(fake_repo_gold+'/'+dsnName, dst_fake_repo+'/'+dsnName) pprint.pprint(res) print 'TEST____________', 'FAILED' if any(res.values()) else 'PASSED' print 'Run time ', time.clock()-startTest
def copyNetlists(): netLists = structure.search(directory = '../src', onlyExt = '.sedif .edn .edf .edif .ngc'.split(), ignoreDir = ['.git', '.svn', 'aldec']) for i in netLists: shutil.copyfile(i, aldecPath+'/src/'+os.path.split(i)[1])