source code
module led(
input sys_clk , //系统时钟
input sys_rst_n, //系统复位,低电平有效
output [1:0] led //LED灯
);
//reg define
reg [25:0] cnt ;
//*****************************************************
//** main code
//*****************************************************
//对计数器的值进行判断,以输出LED的状态
assign led = (cnt < 26'd2500_0000) ? 2'b01 : 2'b10 ;
//assign led = (cnt < 26'd5) ? 2'b01 : 2'b10 ; //仅用于仿真
//计数器在0~5000_000之间进行计数
always @ (posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)
cnt <= 26'd0;
else if(cnt < 26'd5000_0000)
// else if(cnt < 26'd10) //仅用于仿真
cnt <= cnt + 1'b1;
else
cnt <= 26'd0;
end
endmodule
xdc文件
set_property -dict {PACKAGE_PIN U18 IOSTANDARD LVCMOS33} [get_ports sys_clk]
set_property -dict {PACKAGE_PIN N16 IOSTANDARD LVCMOS33} [get_ports sys_rst_n]
set_property -dict {PACKAGE_PIN H15 IOSTANDARD LVCMOS33} [get_ports {led[0]}]
set_property -dict {PACKAGE_PIN L15 IOSTANDARD LVCMOS33} [get_ports {led[1]}]
标签:cnt,set,led,PIN,PACKAGE,sys,实验,闪烁
From: https://www.cnblogs.com/xzh-personal-issue/p/17321590.html