湘攸客

Virtual Jtag初探

0
阅读(2670)

老早就知道Virtual Jtag,也看了riple介绍的详细学习过程,苦于没有时间研究。这两天把VJ user guide上介绍的两个例子down下来,能够跑通,但是还没有完全理解,主要障碍在于对Tcl不熟悉。在完全掌握tcl之前那就先用VJ的简单功能吧。

关于UG上的两个例子网上可以下得到,这里我想把riple贴出来的例子重新贴一下,因为riple是用Verilog,我把它改成了vhdl,不为别的,就是想通过重复劳动尽快熟悉起来。

      QII project:15913772752706.rar

      VJ Debug文件:15913984442355.rar

看看执行效果:

第一步(sample),数据采集到9就结束循环  

通过使用脑子里还是有一个疑问,感觉使用VJ调试也就相当于串口或者nios里jtag_uart,也就是说通过VJ可以对设计施加控制激励比如模拟拨 码,或者探测设计中某一个状态比如led显示。如果速度一快VJ并不能做到实时探测或控制,就像led上变化过快我们无法看到led闪烁一样。

上面这个问题不知道能否通过在FPGA内部开辟缓存比如fifo得以改善,需要实践。

贴出VJ调试中tcl文件中对于real jtag检查的部分(注:注释最好还是用分号“;”+“#”):

# List all available programming hardwares, and select the USBBlaster.
# (Note: this example assumes only one USBBlaster connected.)
# 从命令行输出检测到的硬件(电缆)名称。
puts "Programming Hardwares(检测Jtag硬件链接):"
foreach hardware_name [get_hardware_names] {
puts $hardware_name
if { [string match "USB-Blaster*" $hardware_name] } {
set usbblaster_name $hardware_name
}
}

 

puts "\n检测到电缆硬件链接:Select JTAG chain connected to $usbblaster_name.\n";
# List all devices on the chain, and select the first device on the chain.
##### 检测下载电缆对应的jtag链路,从命令行输出检测到的器件名称。并选中第一个作为操作对象。##
puts "\n从检测到的Jtag硬件链接中选择第一个作为操作对象:Devices on the JTAG chain:"
foreach device_name [get_device_names -hardware_name $usbblaster_name] {
puts $device_name
if { [string match "@1*" $device_name] } {
set test_device $device_name
}
}
puts "\nSelect device: $test_device.\n";
# Open device#### 打开器件 ##
open_device -hardware_name $usbblaster_name -device_name $test_device
# Retrieve device id code.
# IDCODE instruction value is 6; The ID code is 32 bits long.
# IR and DR shift should be locked together to ensure that other applications will not change the instruction register before the id code value is
# shifted out while the instruction register is still holding the IDCODE instruction.
## 获得器件的jtag编号。需要先发送jtag命令--获取ID,命令值是“6”。然后读取jtag数据,得到32位的ID值。##
## 由于该步骤需要两个操作,这两个操作之间不能插入其他操作,所以需要lock一下。##
device_lock -timeout 10000
device_ir_shift -ir_value 6 -no_captured_ir_value
puts "IDCODE: 0x[device_dr_shift -length 32 -value_in_hex]"
device_unlock
#########################以上为真实JTAG检测操作############################################################


############################################################################################################
# Close device
close_device
puts "\n成功关闭器件.\n";

 

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

 

上面有段代码是读取IDCODE的,如果想要读取USERCODE,参照上述代码改写如下:

## 获得器件的USER编号。需要先发送jtag命令--获取ID,命令值是“7”。然后##读取jtag数据,得到32位的ID值。##
## 由于该步骤需要两个操作,这两个操作之间不能插入其他操作,所以需要lock一下。##
device_lock -timeout 10000
device_ir_shift -ir_value 7 -no_captured_ir_value
puts "\nUSERCODE: 0x[device_dr_shift -length 32 -value_in_hex]"
device_unlock