《基于“矿板”低成本学习FPGA》使用ILA内部逻辑分析仪分析LED工程的信号
一.
前言
前面创建了
LED
工程进行简单的测试,本文继续分享下使用
ILA
进行在线信号抓取分析。
二.
添加
ILA IP
ILA
即内部逻辑分析仪。使用该
IP
结合
JTAG
仿真器可以方便的进行在线信号分析。
PROJECT MANAGER-> IP Catalog
搜索
ILA
,双击
ILA(Integrated Logic Analyzer)
设置需要探测的信号个数,和采样深度
三.
例化
ILA IP
在
led.v
的
module led
中例化
ILA
module led
(
input sys_clk, //system clock 50MHZ on board
input rst_n, //reset low active
output reg[2:0] led //LED use of control the LED signal on board
);
reg [31:0] timer;
//==============================
//cle counter : from 0 to 4 sec
//==============================
always @(posedge sys_clk or negedge rst_n)
begin
if(~rst_n)
timer <= 32'd0; //when the reset signal valid,time counter clearing
else if(timer == 32'd149_999_999) //4 seconds count(50M * 4 - 1 = 199_999_999)
timer <= 32'd0; //count done,clearing the time counter
else
timer <= timer + 1'b1; //timer counter = timer counter + 1
end
//==============================
//LED control
//==============================
always @(posedge sys_clk or negedge rst_n)
begin
if(~rst_n)
led <= 3'b111;
else if(timer == 32'd49_999_999)
led <= 3'b011;
else if(timer == 32'd99_999_999)
led <= 3'b110;
else if(timer == 32'd149_999_999)
led <= 3'b101;
end
ila_0 u_ila(
.clk(sys_clk),
.probe0(rst_n),
.probe1(led[0]),
.probe2(led[1]),
.probe3(led[2])
);
endmodule
四.
测试
综合实现,下载
bit
文件
此时会有个
ltx
文件
Ila
选项卡下可以看到信号
由于时间太长,不便于仿真,可以将闪烁的时间间隔减小
module led
(
input sys_clk, //system clock 50MHZ on board
input rst_n, //reset low active
output reg[2:0] led //LED use of control the LED signal on board
);
reg [31:0] timer;
//==============================
//cle counter : from 0 to 4 sec
//==============================
always @(posedge sys_clk or negedge rst_n)
begin
if(~rst_n)
timer <= 32'd0; //when the reset signal valid,time counter clearing
else if(timer == 32'd15) //4 seconds count(50M * 4 - 1 = 199_999_999)
timer <= 32'd0; //count done,clearing the time counter
else
timer <= timer + 1'b1; //timer counter = timer counter + 1
end
//==============================
//LED control
//==============================
always @(posedge sys_clk or negedge rst_n)
begin
if(~rst_n)
led <= 3'b111;
else if(timer == 32'd5)
led <= 3'b011;
else if(timer == 32'd10)
led <= 3'b110;
else if(timer == 32'd15)
led <= 3'b101;
end
ila_0 u_ila(
.clk(sys_clk),
.probe0(rst_n),
.probe1(led[0]),
.probe2(led[1]),
.probe3(led[2])
);
endmodule
可以看到依次间隔
6
个时钟依次点亮
五.
总结
以上分享了使用内部逻辑分析仪
ILA
进行在线信号抓取分析,该方式无需外部逻辑分析仪,方面进行信号的抓取分析,比较方便。