<font color="#FF8000">作者:OpenS_Lee</font>
<strong>1背景知识</strong>
在我们的FPGA设计项目中,硬件的诊断和校验可能会占去超过30%—40%的FPGA开发时间,FPGA的debug也是FPGA设计中重要的一环。掌握并灵活运用FPGA设计工具的debug功能也是加快FPGA设计的关键。
<strong>1.1 ILA(Integrated Logic Analyzer)</strong>
FPGA设计中的信号连接到ILA核的时钟和探针输入如图1。这些信号附加到探针输入,以设计速度采样,并使用片上块RAM(BRAM)存储。核参数指定探针的数量、跟踪样本深度和每个探针输入的宽度。使用与FPGA的JTAG接口连接的自动实例化调试核心集线器与ILA核进行通信。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图1 ILA Core"></center>
<p align="center"><strong>图1 ILA Core</strong></p>
<strong>1.2 VIO (Virtual Input/Output core)</strong>
VIO核是一个可定制的核,可以实时监控和驱动内部FPGA信号。不像ILA核,不需要片上或片外RAM。
VIO核有两种类型的信号:
. Input probes
.Output probes
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图2 VIO Block Diagram" width="670"></center>
<p align="center"><strong>图2 VIO Block Diagram</strong></p>
<strong>2 ila 和 vio在工程中使用</strong>
我们使用uart工程来做示例。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图3 uart示例模块图" width="670"></center>
<p align="center"><strong>图3 uart示例模块图</strong></p>
如图3所示,整个串口工程包括波特率时钟产生模块,串口接收模块和串口发送模块。我们将使用ila IP对uart_rx模块的接收数据进行debug,使用vio IP对uart_tx模块进行debug。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt=""></center>
我们使用Ila将对 rx_data的接收数据进行实时观测,以此来判断程序是否正确。
<strong>2.1 ila IP和vio IP的创建</strong>
Ila IP的创建,首先打开 IP Catalog如图4。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图4 IP Catalog" width="670"></center>
<p align="center"><strong>图4 IP Catalog</strong></p>
搜索ila如图5。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图5 ila ip" width="670"></center>
<p align="center"><strong>图5 ila ip</strong></p>
双击打开ila IP ,相关参数设置如图6。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图6 ila IP参数设置" width="670"></center>
<p align="center"><strong>图6 ila IP参数设置</strong></p>
Ila IP的探头位宽设置如图7。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图7 Ila IP位宽的设置" width="670"></center>
<p align="center"><strong>图7 Ila IP位宽的设置</strong></p>
Vio的设置如图8和图9。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图8 探头个数的设置" width="670"></center>
<p align="center"><strong>图8 探头个数的设置</strong></p>
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图9 探头数据位宽和初始化值的设置" width="670"></center>
<p align="center"><strong>图9 探头数据位宽和初始化值的设置</strong></p>
对Ila IP 和 vio IP的例化。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt=""></center>
然后我们综合实现完成后下载程序如图10。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图10 programming FPGA"></center>
<p align="center"><strong>图10 programming FPGA</strong></p>
<strong>2.2 ila 和vio对uart的实时数据采集</strong>
Ila的调试,我们使用rx_done 信号作为触发信号,设置触发条件等于1,如图11所示。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图11 触发条件的设置" width="670"></center>
<p align="center"><strong>图11 触发条件的设置</strong></p>
我们使用串口工具发送数据,触发以后我们可以观测到FPGA内部rx_data接收完成后的数据如图12。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图12 ila IP 观测到FPGA内部信号的变化" width="670"></center>
<p align="center"><strong>图12 ila IP 观测到FPGA内部信号的变化</strong></p>
Vio的调试,点击+号,添加三个数据端口如图所示13。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图13 vio观测端口的设置" width="670"></center>
<p align="center"><strong>图13 vio观测端口的设置</strong></p>
当tx_en 为1时将tx_data上的数据从FPGA内部发送到串口工具上,如图14所示。
<center><img src="http://xilinx.eetrend.com/files-eetrend-xilinx/article/201808/13235-384…; alt="图14 通过vio将数据从FPGA内部发送到串口工具" width="670"></center>
<p align="center"><strong>图14 通过vio将数据从FPGA内部发送到串口工具</strong></p>
学会对FPGA内部信号的debug是FPGA设计过程中重要的一环。Vivado的debug相对于ISE更为简单,更加易用。
视频演示:
<iframe frameborder="0" width="640" height="498" src="https://v.qq.com/iframe/player.html?vid=u1345l58hmi&tiny=0&auto=0" allowfullscreen></iframe>
需要得到本实验原工程的同学可以请联系:<a href="https://mp.weixin.qq.com/s?__biz=MzUyODUwMDExOQ==&mid=2247484450&idx=1&…; <span id="profileBt">FPGA开源工作室</span> </a>