AX301 led_test

module led_test(
input rst,
input clk,

output reg [3:0]led
);

reg [31:0] timer;
always @(posedge clk or negedge rst)
begin
	if (!rst)
		timer <=32'd0;
	else if (timer == 32'd299_999_999)
		timer <=32'd0;
	else
		timer <= timer +1;
end

always @(posedge clk or negedge rst)
begin
	if (!rst)
		led <= 4'b0001;
	else if (timer == 32'b10)
		led <= {led[2:0], led[3]};
	else
		led <= led;
end


endmodule
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页