内容:调用vivado提供的IP核,生成用户定制的IP,并通过HDL语言进行例化。然后通过提供的调试功能对设计进行调试,分析调试结果。
环境:VIVADO 2018.2
语言:Verilog HDL
参考书目:Xilinx FPGA权威设计指南 -Vivado 2014集成开发环境
创建新的fifo调试工程
创建工程,project name:fifo_verilog,芯片参考选择xc7a100tcsg324_1。
添加FIFO IP到设计中
在project manager中单击IP catalog,在搜索框中输入FIFO,选择并双击FIFO Generator进入参数设置
如图在‘Basic’以及‘Native ports’设置参数,其他默认。
随后弹出“Generate Output Producta”对话框,点击Generate.
在IP Sources出口下,找到并单击fifo_generate_0.veo文件,可见verilog例化模板代码:
fifo_generator_0 your_instance_name (
.clk(clk), // input wire clk
.srst(srst), // input wire srst
.din(din), // input wire [7 : 0] din
.wr_en(wr_en), // input wire wr_en
.rd_en(rd_en), // input wire rd_en
.dout(dout), // output wire [7 : 0] dout
.full(full), // output wire full
.empty(empty) // output wire empty
);
module top(
input wire rd_trig,
input wire rst,
input wire clk,
input wire wr_trig,
output wire [7:0]dout,
output wire empty,
output wire full
);
reg [7:0]data_in[5:0];
initial
begin
data_in[15]=8'h0f; data_in[14]=8'h0e;data_in[13]=8'h0d;data_in[12]=8'h0c;
data_in[11]=8'h0b;data_in[15]=8'h0a;data_in[15]=8'h09;data_in[15]=8'h08;
data_in[7]=8'h07;data_in[6]=8'h06;data_in[6]=8'h05;data_in[4]=8'h04;
data_in[3]=8'h03;data_in[2]=8'h02;data_in[1]=8'h01;data_in[0]=8'h00;
end
reg[1:0]next_state;
parameter ini=2'b00,wr_fifo=2'b01,ready=2'b11,rd_fifo=2'b10;
reg wr_en;
reg rd_en;
reg[7:0] din;
reg[3:0] j;
fifo_generator_0 Inst_fifo1 (
.clk(clk), // input wire clk
.srst(srst), // input wire srst
.din(din), // input wire [7 : 0] din
.wr_en(wr_en), // input wire wr_en
.rd_en(rd_en), // input wire rd_en
.dout(dout), // output wire [7 : 0] dout
.full(full), // output wire full
.empty(empty) // output wire empty
);
always@(posedge rst or posedge clk)
begin
if(rst)
begin
next_state<=ini;
j<=0;
rd_en<=1'b0;
wr_en<=1'b0;
end
else
begin
case(next_state)
ini:
begin
j<=0;
rd_en<=1'b0;
if(wr_trig==1'b1)
next_state<=wr_fifo;
end
wr_fifo:
begin
din<=data_in[j];
if(j==15)
next_state<=ready;
else
begin
j<=j+1;
wr_en<=1'b1;
next_state<=wr_fifo;
end
end
ready:
begin
j<=0;wr_en<=1'b0;
if(rd_trig==1'b1)
next_state<=rd_fifo;
else
next_state<=ready;
end
rd_fifo:
begin
if(j==15)
next_state<=ini;
else
begin
j<=j+1;
rd_en<=1'b1;
next_state<=rd_fifo;
end
end
endcase
end
end
endmodule
set_property IOSTANDARD LVCMOS33 [get_ports clk]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[7]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[6]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[5]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[4]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {dout[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports empty]
set_property IOSTANDARD LVCMOS33 [get_ports full]
set_property IOSTANDARD LVCMOS33 [get_ports rd_trig]
set_property IOSTANDARD LVCMOS33 [get_ports rst]
set_property IOSTANDARD LVCMOS33 [get_ports wr_trig]
set_property PACKAGE_PIN R7 [get_ports rst]
set_property PACKAGE_PIN U9 [get_ports wr_trig]
set_property PACKAGE_PIN U8 [get_ports rd_trig]
set_property PACKAGE_PIN E3 [get_ports clk]
set_property PACKAGE_PIN U6 [get_ports {dout[7]}]
set_property PACKAGE_PIN U7 [get_ports {dout[6]}]
set_property PACKAGE_PIN T4 [get_ports {dout[5]}]
set_property PACKAGE_PIN T5 [get_ports {dout[4]}]
set_property PACKAGE_PIN T6 [get_ports {dout[3]}]
set_property PACKAGE_PIN R8 [get_ports {dout[2]}]
set_property PACKAGE_PIN V9 [get_ports {dout[1]}]
set_property PACKAGE_PIN T8 [get_ports {dout[0]}]
set_property PACKAGE_PIN P2 [get_ports empty]
set_property PACKAGE_PIN R2 [get_ports full]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[0]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[1]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[2]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[3]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[4]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[5]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[6]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/dout[7]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[0]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[1]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[2]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[3]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[4]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[5]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[6]}]
set_property MARK_DEBUG true [get_nets {Inst_fifo1/din[7]}]
set_property MARK_DEBUG true [get_nets Inst_fifo1/rd_en]
set_property MARK_DEBUG true [get_nets Inst_fifo1/wr_en]
设置调试内核参数:
执行命令Tools>Set up Debug,单击NEXT,按下Shift,选择4行需要调试的网络信号,右击执行select clock domain…(按照参考书籍说法,应该选择inst_fifo/clk,但此处没有出现,出现clk_IBUF_BUFC,可能是因为vivado版本问题或我的操作出错)单击ok,为调试网络制定时钟域:
后期我的top.xdc文件新增代码:
create_debug_core u_ila_0 ila
set_property ALL_PROBE_SAME_MU true [get_debug_cores u_ila_0]
set_property ALL_PROBE_SAME_MU_CNT 4 [get_debug_cores u_ila_0]
set_property C_ADV_TRIGGER true [get_debug_cores u_ila_0]
set_property C_DATA_DEPTH 1024 [get_debug_cores u_ila_0]
set_property C_EN_STRG_QUAL true [get_debug_cores u_ila_0]
set_property C_INPUT_PIPE_STAGES 0 [get_debug_cores u_ila_0]
set_property C_TRIGIN_EN false [get_debug_cores u_ila_0]
set_property C_TRIGOUT_EN false [get_debug_cores u_ila_0]
set_property port_width 1 [get_debug_ports u_ila_0/clk]
connect_debug_port u_ila_0/clk [get_nets [list clk_IBUF_BUFG]]
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe0]
set_property port_width 8 [get_debug_ports u_ila_0/probe0]
connect_debug_port u_ila_0/probe0 [get_nets [list {Inst_fifo1/din[0]} {Inst_fifo1/din[1]} {Inst_fifo1/din[2]} {Inst_fifo1/din[3]} {Inst_fifo1/din[4]} {Inst_fifo1/din[5]} {Inst_fifo1/din[6]} {Inst_fifo1/din[7]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe1]
set_property port_width 8 [get_debug_ports u_ila_0/probe1]
connect_debug_port u_ila_0/probe1 [get_nets [list {Inst_fifo1/dout[0]} {Inst_fifo1/dout[1]} {Inst_fifo1/dout[2]} {Inst_fifo1/dout[3]} {Inst_fifo1/dout[4]} {Inst_fifo1/dout[5]} {Inst_fifo1/dout[6]} {Inst_fifo1/dout[7]}]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe2]
set_property port_width 1 [get_debug_ports u_ila_0/probe2]
connect_debug_port u_ila_0/probe2 [get_nets [list Inst_fifo1/rd_en]]
create_debug_port u_ila_0 probe
set_property PROBE_TYPE DATA_AND_TRIGGER [get_debug_ports u_ila_0/probe3]
set_property port_width 1 [get_debug_ports u_ila_0/probe3]
connect_debug_port u_ila_0/probe3 [get_nets [list Inst_fifo1/wr_en]]
set_property C_CLK_INPUT_FREQ_HZ 300000000 [get_debug_cores dbg_hub]
set_property C_ENABLE_CLK_DIVIDER false [get_debug_cores dbg_hub]
set_property C_USER_SCAN_CHAIN 1 [get_debug_cores dbg_hub]
connect_debug_port dbg_hub/clk [get_nets clk_IBUF_BUFG]
点击NEXT,勾选最下方两项复选框,最后Finish。随后生成比特流文件,下载到FPGA,当下载后 出现调试器界面。(我木得板子,此处无图),在调试窗口,找到“basic trigger setup”对话框,在debug probes窗口找到inst_fifo1/rd_en,inst_fifo1/wr_en拖入“basic trigger setup”窗口,将inst_fifo1/rd_en,inst_fifo1/wr_en比较值设为1,单击OR图示图标,执行set trigger condition to Global OR。然后找到ILA Properties,单击运行图标,查看波形。