Quickly create projects with FPGA

Table of contents

One cause

two steps


One cause

It is too slow to manually create a new file by yourself, so it is convenient and easy to use a python script to quickly generate a script file

two steps

Create a new text document:

Import the following content, save the suffix as .py

import os

dir_name = input("请输入主文件夹工程的名字:\n")
os.mkdir(dir_name)
os.chdir(dir_name) #进入创建主文件夹的工程

#创建在主文件夹内创建四个子文件夹,分别是 doc prj rtl tb ip
#doc:一般存放波形文件
#prj:存放quartus的工程
#rtl:存放rtl代码 .v文件
#tb:存放仿真文件
#ip:存放调用的IP核
my_dirlist = ["doc","prj","rtl","tb","ip"]
file_detial = "module "+dir_name+"(\n\n);\n"+"endmodule\n"
file_tb_detial = "`timescale 1ns/1ns\n"+"module "+dir_name+"_tb();\n\n"+"endmodule\n"
for i in my_dirlist:
    os.mkdir(i)

    print(i,"文件夹创建成功")
    if(i == "rtl"):
        os.chdir(i)
        file = open(dir_name + ".v","w") #创建文件
        file.write(file_detial)
        file.close()
        print(dir_name + ".v","文件创建成功")
        os.chdir("../")  #回到上级目录
    
    elif(i == "tb"):
        os.chdir(i)
        file_tb = open(dir_name + "_tb.v","w") #创建文件
        file_tb.write(file_tb_detial)
        file_tb.close()
        print(dir_name + "_tb.v","文件创建成功")
        os.chdir("../")


    

OK,

Where you want to run, just drag and run the py file and enter your file name.

 

 

 Convenient and fast!

Guess you like

Origin blog.csdn.net/qq_52445967/article/details/126194145