打印

QuartusII 中 In-System Sources and Probes 的使用

[复制链接]
3894|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ifpga|  楼主 | 2013-2-25 14:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

In-SystemSources and Probes 的使用

1.      In-System Sources and Probes 的简介

In-SystemSources and Probes 是Altera提供的一种简单易用的在系统调试工具,它通过 Jtag 接口来实现。在原型设计阶段,它可以方便的用来模拟激励源。在系统中其与我们的 DesignLogic 连接如下图所示:

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image002.jpg


根据其特性,在应用中它主要可以实现以下功能:

o    创建虚拟按钮
o    为你的设计创建虚拟控制面板
o    模拟外部传感器信号
o    对系统状态进行监控


2. 接口描述

如下表所示,probe 的意思即为“探针”, 因此其 用于连接设计中的输出端口。而 source 信号用于连接设计中的输入端口,用于模拟外部输入。

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image004.jpg

3. 如何在系统中添加In-System Sources and Probes

我们以一个最简单的组合逻辑为例,其代码如下:

  
module i2o(
  
    i,
  
    o
  
);
  
  
     input   wire i;
  
     output  wire o;
  
  
    assign  o = i;
  
  
endmodule
  

在 Tools 菜单中选择MegaWizard Plug-In Manager。

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image005.png

在 IP 列表中,选择In-System Sources and Probes。

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image007.png

将 probeport 宽度设置为0 (因为我们这里只做模拟输入的试验),将 sourceport 设置为 1。生成 IP。

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image009.png

在顶层文件中完成如下两个模块的例化。其中,pjtag 即In-System Sources and Probes 模块。

  
module probe(
  
    o
  
);
  
    output  wire o;
  
  
    wire i;
  
  
    i2o uut  (
  
         .i(i),
  
         .o(o)
  
    );
  
  
    pjtag  pjtag_inst(
  
         .probe ( ),
  
         .source (i)
  
);
  
  
endmodule
  

为 o 信号分配管脚,在这里可以将 o 分配到时一个 LED 指示灯上。

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image011.png

最后,生成 .sop 文件,下载到 FPGA 中即可。

4. 如何在QuartusII 中调试

在 Tools 菜单中选择In-System Sources and Probes Editor,我们会发现source[0] 已经在下面的信号列表中,通过鼠标对 Data 进行点击即可改变 Source 的值,并且你会发现同时板子上的 LED 指示灯也会跟着变化。

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image013.png



5. 如何使用 TCL 脚本?

如果你想为自己的系统写一个自动化测试平台,这时候最好的选择就是使用 Tcl/Tk 脚本。这里不多讲,简单列出一个简单的 Tcl 脚本,使用此脚本对 LED 灯进行控制。

  
# Initialize the Tk library
  
init_tk
  
  
# initialize the JTAG
  
puts "Programming Hardware:"
  
  
foreach hardware_name [get_hardware_names] {
  
puts $hardware_name
  
}
  
  
set usb [lindex [get_hardware_names] 0]
  
set device_name [lindex [get_device_names -hardware_name $usb] 0]
  
puts $device_name
  
  
# write procedure : argument value is integer
  
  
proc write {value} {
  
global device_name  usb
  
variable full
  
  
puts "value =  $value \n"
  
  
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"
  
}        
  
  
write_source_data  -instance_index 0 -value $value
  
  
#clear transaction
  
end_insystem_source_probe
  
}
  
  
  
# Create a top level and add a title
  
toplevel .top
  
wm title .top "Hello World"
  
  
# Add widgets
  
button .top.hello -text SET   -command {write $value} -padx 10
  
checkbutton .top.led -text "switch on the led" -variable value  -padx 10 -pady 10
  
  
#pack .top.hello -padx 20 -pady 10
  
grid .top.led -row 0 -column 0
  
grid .top.hello -row 0 -column 1
  
  
  
# Without "tkwait", the script finishes at this point and the
  
# window is destroyed. The "tkwait" command prevents the
  
# script from finishing until the you close the window.
  
tkwait window .top
  

运行脚本,如下图所示:

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image015.png

最后显示显示,如下图所示:

file:///C:/Users/WYD-WORK/AppData/Local/Temp/msohtmlclip1/01/clip_image016.png



6. 参考资料
o    QuartusII Handbook Version 12.1, Volume 2, Section 3, Tcl Scripting
o    QuartusII Scripting Reference Manual
o    DesignDebugging using In-System Sources and Probes
o    Tcl/Tk 入经典







In-System Sources and Probes 的使用.pdf

613.14 KB

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:面朝大海,春暖花开! www.i-fpga.com

13

主题

909

帖子

1

粉丝