本帖最后由 zeshoufx 于 2020-9-14 13:55 编辑
一、平台
基于安路科技开发板,EG4A20BG256,
引脚配置:
CLK :E1
LED3:D9
LED2:C9
LED1:F9
LED0:E10
RESET:N13
EG4A资源
二、效果
三、程序
module LED_Flash(
CLK_50M,
RST_N,
LED
);
input CLK_50M;
input RST_N;
output [3:0] LED;
reg [31:0] timer;
reg [3:0] LED_n;
reg [3:0] LED;
always @(posedge CLK_50M or negedge RST_N)
begin
if (~RST_N)
timer <= 0;
else if (timer == 32'd19_999_999)
begin
timer <= 0;
LED_n <= LED_n + 1'b1;
if (LED_n == 3'd4)
LED_n <= 0;
end
else
timer <= timer + 1'b1;
end
always @(posedge CLK_50M or negedge RST_N)
begin
if (~RST_N)
LED <= 4'b0000;
else if (LED_n == 4'd1)
LED <= 4'b0001;
else if (LED_n == 4'd2)
LED <= 4'b0010;
else if (LED_n == 4'd3)
LED <= 4'b0100;
else if (LED_n == 4'd4)
LED <= 4'b1000;
end
endmodule
|