尝试使用Python让verilog编写过程变得简单
1、对于规范verilog代码模块头部
module int_freq
#(
parameter N = 3,//must be odd number
parameter N_WIDTH = 3 //传递形参,可在调用模块时配置
)
(
input rst_n,
input clk_in,
output clk_out
);
...........
module
2、使用Python提取模块头部
my_f = open('int_freq.v', 'rb')
head_module_list=[]
while True:
word=my_f.readline()
head_module_list.append(word[0:len(word)-2])'''读取末尾有\r\n'''
word=word.lstrip()'''去除左边的空字符'''
if word[0:2]==");" or len(word)==0:
break
for i in range(0,len(head_module_list)):
print head_module_list[i],"\n"''''可对head_module_list操作以修改成为接口代码(待更新)'''
my_f.close
截取效果