赞
踩
将ILA观察到的波形数据捕获为CSV文件,抓10次,把文件合并,把源文件删除
运行方法:Vivado的 Tcl console 窗口输入命令
set tcl_dir F:/KLD_FPGA/Code/sim
set tcl_filename TCL_ILA_TRIG_V1.2.tcl
source $tcl_dir/$tcl_filename
- #===================================================
- # 脚本说明 V1.2
- # 功能:将ILA观察到的波形数据捕获为CSV文件,抓10次,把文件合并,把源文件删除
- # 启用了自动重新触发模式。这样可以在每次触发时重新捕获数据
- # 运行方法:Vivado的 Tcl console 窗口输入命令
- # set tcl_dir F:/KLD_FPGA/Code/sim
- # set tcl_filename TCL_ILA_TRIG_V1.2.tcl
- # source $tcl_dir/$tcl_filename
- # 注意:注意 vivado 下面的路径使用的是反斜杠 /,和 Windows 下的路径不一样
- #===================================================
-
- # ILA探针名字 hw_ila_1(u_ila_0)
- #set ila_name "u_ila_0"
- #set hw_name hw_ila_1
- # ILA所在FPGA
- #set fpga "xc7z020_1"
-
- set data_dir "F:/KLD_FPGA/Code/sim/debug"
-
- # 如果数据目录不存在,则创建目录
- if {![file exists $data_dir]} {
- file mkdir $data_dir
- }
-
- for {set i 0} {$i < 4} {incr i} {
- #显示状态,启动ILA
- puts "Initiating ILA, iteration $i"
- #运行ila
- run_hw_ila [get_hw_ilas -of_objects [get_hw_devices xc7z020_1] -filter {CELL_NAME=~"u_ila_0"}]
- #等待
- wait_on_hw_ila [get_hw_ilas -of_objects [get_hw_devices xc7z020_1] -filter {CELL_NAME=~"u_ila_0"}]
- # 上传ILA采集的数据
- set ila_data [upload_hw_ila_data [get_hw_ilas -of_objects [get_hw_devices xc7z020_1] -filter {CELL_NAME=~"u_ila_0"}]]
- # 显示ILA采集的数据
- display_hw_ila_data $ila_data
- #写入文件
- write_hw_ila_data -csv_file -force $data_dir/TCL_ILA_TRIG_$i.csv $ila_data
- #显示状态,保存完毕
- puts "Saved ILA data, iteration $i"
- }
-
-
- # 所有文件列表
- set all_csvs [glob -directory $data_dir *.csv]
-
- # 最终输出的合并文件
- set final_csv [file join $data_dir "final.csv"]
-
- # 如果存在则删除 final.csv
- if {[file exists $final_csv]} {
- file delete $final_csv
- }
-
- # 逐个追加 CSV 文件内容
- set f [open $final_csv a]
- foreach csv $all_csvs {
- set r [open $csv]
- puts $f [read $r]
- close $r
- }
- close $f
-
- # 删除原始文件(可选)
- foreach csv $all_csvs {
- file delete $csv
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。