这里写自定义目录标题
modelsim仿真时打印波形
在仿真时我需要临时打印一些波形到txt里
我是这样做的
proc write_sim_data {env name radix cycle file} {
set fid [open $file w]
for {set i 0} {$i <= $::now} {incr i [expr $cycle * 1000]} {
set str [exa -env $env -radix $radix -time ${i}ps {*}$name]
puts $fid $str
}
close $fid
}
write_sim_data tb_msdf_dot/msdf_dot_inst {
msdf_adder_tree_inst/inst_adder_tree_depth[5]/inst_adder_tree_width[0]/genblk1/msdf_add_0/validArray_0
msdf_adder_tree_inst/inst_adder_tree_depth[5]/inst_adder_tree_width[0]/genblk1/msdf_add_0/dataOutArray_0
} unsigned 10 waveform_mult.txt
接着在python里面,可以写一些自动化处理的脚本
def load_dot_data(path_to_file, _list):
with open(path_to_file, 'r') as f:
for line in f:
items = line.split()
if(len(items)>1):
_list.append(items[1])
result_list = []
load_dot_data("waveform_mult.txt", result_list)
print(result_list)
mi = 2.0
result=0.0
for item in result_list:
mi = mi/2
digit=0.0
if item == "0":
digit = 0.0
elif item == "2":
digit = 1.0
elif item == "3":
digit = 0.0
else:
digit = -1.0
result = result + digit*mi
print(result)