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

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

chanra1n12个月前 (05-21)Python2834

在工程文件夹下运行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(".xpr") :
        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['Path']
            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/309.html

分享给朋友:

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

0.Python环境的搭建

0.Python环境的搭建

   请打开网页  https://www.python.org/downloads/windows/    Windows环境下的Python        这里我选择...

1.Python基本的使用

1.Python基本的使用

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

2.Python中的基本运算

2.Python中的基本运算

我们打开Python,请你尝试输入如下算式并尝试理解有什么为什么是这样的?1+1 1+1.0 1-2 2-3.5 1*1 1*1.1 1/2 2/1 2/3 3/2 3//2 3/1.0 5/2.5我们不难得到如下结果2 2.0 -1 -1.5 1 1.1 0.5...

Python关于turtle的函数名

Python关于turtle的函数名

turtle.forward(distance)                   向当前画笔方向移动distance像素长度turtle.backward(distance)              向当前画笔相反方向移动distance像素长度turtle.right(degree)    ...

random库

random库

random()            生成一个[0.0,1.0)之间的随机小数randint(a,b)     生成一个[a,b]之间的整数uniform(a,b)     生成一个[a,b]之间的随机小数对random库的引用方法与math库一样,采用下面两种方式实现:import random...

列表作为函数参数

列表作为函数参数

列表作为函数参数,函数中可以修改原列表def multiply(values,factor):     for i in range(len(values)):        values[i]*=factor          aList=[1,2,3,4,5]  multiply(aL...