[PV]AXI R/W/RW带宽计算的tcl脚本
AXI R/W/RW带宽计算的tcl脚本
我基于前述的axi_read_bw_per_id.tcl
脚本进行了修改,使其支持:
- 读通道(Read Channel):计算基于rvalid && rready的有效周期(已在前述实现)。
- 写通道(Write Channel):计算基于wvalid && wready的有效周期,考虑wstrb的active bytes(字节使能位计数)。
- 读写组合(Combined):分别计算读/写BW,然后求和输出总BW(假设双向接口)。
修改说明
- 新增参数:
channel
:支持"read"(只读)、"write"(只写)、"both"(读写组合,默认)。- 写通道特定:
strb_width
(wstrb宽度,与data_width匹配)。
- 逻辑扩展:
- 对于"both",脚本分别循环计算读/写(共享时间窗口),然后聚合总BW/效率。
- 写通道:用Tcl proc
count_active_strobes
计算wstrb中1的位数(active strobes),字节 = (data_width / 8) * (active_strobes / (data_width / 8))。 - per-ID支持:读用rid,写用wid(假设信号名为"wid";调整为您的设计)。
- 输出:CSV扩展为per-ID读/写/总(e.g., Read BW, Write BW, Total BW)。
- 假设:
- 读/写信号在同一scope。
- ID宽度相同;如果不同,需额外调整。
- 步进1.0ns(调整为您的clk周期以加速)。
- 运行方式:同前述,在Verdi中
source axi_rw_combined_bw.tcl
。生成CSV报告。
如果您的AXI接口有自定义信号(如非标准ID/strb),或需要优化性能(e.g., 用npi_iterate_over_transitions),请提供更多细节。
修改后的脚本示例(axi_rw_combined_bw.tcl)
# axi_rw_combined_bw.tcl - 计算AXI读/写/组合带宽 (支持per-ID, 多窗口)# 用户参数 (可修改)
set data_width 128 ;# AXI数据宽度 (位, e.g., 128=16字节/周期)
set id_width 8 ;# ID宽度 (位, e.g., 8位支持256 ID)
set strb_width [expr $data_width / 8] ;# wstrb宽度 (字节, e.g., 16 for 128-bit)
set channel "both" ;# "read" (只读), "write" (只写), "both" (读写组合)
set scope "/top/dut/axi_if" ;# AXI接口scope路径 (调整为您的设计)
set time_windows [list {0 1000} {1000 2000} {2000 3000}] ;# 多时间窗口 (ns, list of pairs)
set output_file "axi_rw_combined_bw_report.csv" ;# 输出CSV文件# Tcl proc: 计算wstrb中active bits (popcount)
proc count_active_strobes {strb_val strb_width} {set count 0for {set i 0} {$i < $strb_width} {incr i} {i