Intel® Quartus® Prime Pro Edition用户指南: 调试工具

ID 683819
日期 9/30/2019
Public
文档目录

6.5. In-System Sources and Probes Editor的Tcl界面

为了支持自动化,In-System Sources and Probes Editor以Tcl命令的形式支持本章中描述的过程步骤。运行quartus_stp时,默认包含In-System Sources and Probes Editor的Tcl package。

In-System Sources and Probes Editor的Tcl界面提供了一个设计调试的强大平台。Tcl界面 对于调试需要切换多组控制输入的设计特别有用。您可以将多个命令与Tcl脚本结合使用以定义一个定制命令集。

表 21.  In-System Sources and Probes Tcl命令
命令 参数 说明
start_insystem_source_probe -device_name <device name>
-hardware_name <hardware name> 打开一个包含指定硬件的器件的句柄。

在开始任何传输之前,请调用此命令。

get_insystem_source_probe_instance_info -device_name <device name>
-hardware_name <hardware name> 返回设计中的所有ALTSOURCE_PROBE实例。返回的每个记录均采用以下格式:

{<instance Index>, <source width>, <probe width>, <instance name>}

read_probe_data -instance_index <instance_index>-value_in_hex (optional) 检索探针的当前值。

返回一个字符串,该字符串指定每个探针的状态,其中MSB为最左边的位。

read_source_data -instance_index <instance_index>-value_in_hex (optional) 检索源的当前值。

返回一个字符串,该字符串指定每个源的状态,其中MSB为最左边的位。

write_source_data -instance_index <instance_index>
-value <value>
-value_in_hex (optional) 设置来源的值。

一个二进制字符串被发送到源端口,其中MSB作为最左边的位。

end_insystem_source_probe None 释放JTAG链。

所有传输完成后,发出此命令。

该示例显示了Tcl脚本的摘录,其中包含控制设计的ALTSOURCE_PROBE实例的过程,如下图所示。该示例设计包含一个具有ALTSOURCE_PROBE实例的DCFIFO,以读取和写入DCFIFO。在设计中添加了一组控制复用器,以控制输入管脚和ALTSOURCE_PROBE实例之间的DCFIFO数据流。脉冲发生器被添加到读取请求和写入请求控制行,以确保对单个样本进行读取或写入。在下面的示例中与脚本一起使用时,ALTSOURCE_PROBE实例通过执行单个样本写入和读取操作并报告满和空状态标志(full and empty status flags)的状态,从而提供对FIFO内容的可见性。

在调试情况下使用Tcl脚本可以清空或预加载设计中的FIFO。例如,您可以使用此功能预加载FIFO,以匹配Signal Tap logic analyzer中设置的触发条件。
图 83. 由Tcl脚本控制的DCFIFO示例设计


## Setup USB hardware  - assumes only USB Blaster is installed and
## an FPGA is the only device in the JTAG chain
set usb [lindex [get_hardware_names] 0]
set device_name [lindex [get_device_names -hardware_name $usb] 0]
## write procedure :  argument value is integer
proc write {value} {
global device_name usb
variable full
start_insystem_source_probe -device_name $device_name -hardware_name $usb
#read full flag
set full [read_probe_data -instance_index 0]
if {$full == 1} {end_insystem_source_probe
return "Write Buffer Full"
}
##toggle select line, drive value onto port, toggle enable
##bits 7:0 of instance 0 is S_data[7:0]; bit 8 = S_write_req;
##bit 9 = Source_write_sel
##int2bits is custom procedure that returns a bitstring from an integer     ## argument
write_source_data -instance_index 0 -value /[int2bits [expr 0x200 | $value]]
write_source_data -instance_index 0 -value [int2bits [expr 0x300 | $value]]
##clear transaction
write_source_data -instance_index 0 -value 0
end_insystem_source_probe
}
proc read {} {
global device_name usb
variable empty
start_insystem_source_probe -device_name $device_name -hardware_name $usb
##read empty flag : probe port[7:0] reads FIFO output; bit 8 reads empty_flag
set empty [read_probe_data -instance_index 1]
if {[regexp {1........} $empty]} { end_insystem_source_probe
return "FIFO empty" }
## toggle select line for read transaction
## Source_read_sel = bit 0; s_read_reg = bit 1
## pulse read enable on DC FIFO
write_source_data -instance_index 1 -value 0x1 -value_in_hex
write_source_data -instance_index 1 -value 0x3 -value_in_hex
set x [read_probe_data -instance_index 1 ]
end_insystem_source_probe
return $x
}