当前位置:首页 > Python > 正文内容

(原创)使用Python提取XISE工程的RTL代码

chanra1n1年前 (2023-05-21)Python3152

在工程文件夹下运行Python程序即可

#Author       : /
#Description  : 从Vivado的项目文件夹中提取rtl文件,用于LEDA调试
#Time         : 20220805
#Verision     : 0.1
#CopyRights   : myfpga.cn All Right Reservers. 

import os
import shutil
import xml.etree.ElementTree as ET
for temp_file in os.listdir():
    if temp_file.endswith(".xise") :
        prj_name_temp = os.path.splitext(temp_file)
        prj_name = prj_name_temp[0]
        os.mkdir(prj_name+'_rtl')
        tree = ET.ElementTree(file=temp_file)
        root = tree.getroot()
        for elem in tree.iter(tag='file'):
            file_path = elem.attrib['xil_pn:name']
            #file_path = file_path.replace('$PSRCDIR','./'+prj_name+'.srcs')
            if(file_path.endswith(".v") or file_path.endswith(".vh") or file_path.endswith(".vhd") or file_path.endswith(".vhdl") or file_path.endswith(".sv")
            or file_path.endswith(".V") or file_path.endswith(".VH") or file_path.endswith(".VHD") or file_path.endswith(".VHDL") or file_path.endswith(".SV")):
                #print(file_path)
                try:
                    shutil.copyfile(file_path,prj_name+'_rtl/'+os.path.basename(file_path))
                except:
                    print('ERROR:'+prj_name+'_rtl/'+os.path.basename(file_path))


扫描二维码推送至手机访问。

版权声明:本文由我的FPGA发布,如需转载请注明出处。

本文链接:https://myfpga.cn/index.php/post/310.html

分享给朋友:

“(原创)使用Python提取XISE工程的RTL代码” 的相关文章

1.Python基本的使用

1.Python基本的使用

我们打开python或者通过运行python也可以,请复制如下代码,然后按下Enter键,看看会发生什么?print('\n'.join([''.join([('MyFpga'[(x-y) % len('MyFpga'...

math库的使用

math库的使用

math库包括4个数学常数math.pi      圆周率math.e       自然对数math.inf     正无穷大,负无穷大为-math.infmath.nan     非浮点数标记math库常用函数math.cell(x)      向上取整,返回不小于x的最小整数math.facto...

  索引运算符【】

索引运算符【】

选择字符串的子序列语法【start:finish】        start:子序列开始位置的索引值        finish:子序列结束位置的下一个字符的索引值如果不提供start或者finish,默认start为第一个字符,finish为最后一个字符。例如>>>my_str=...

(原创)使用Python对任意网站图片进行爬取,仅用于学习

(原创)使用Python对任意网站图片进行爬取,仅用于学习

import os import time import argparse import requests import re import io from urllib.parse import ...

(原创)使用Python递归获取网页内的所有URL,并进行清洗

(原创)使用Python递归获取网页内的所有URL,并进行清洗

import argparse import time from urllib.parse import urljoin, urlparse from selenium import webdriver...

(原创)使用Python自动对子文件夹中的图片文件进行重命名

(原创)使用Python自动对子文件夹中的图片文件进行重命名

为了解决Python深度学习的时候,经常遇到的文件名问题import os # 获取指定目录下的所有子文件夹 def get_subfolders(path):     subfolders = []...