//间隔点亮发光二极管
module led_interval
(sys_rst,sys_clk,
led);
input sys_rst;
input sys_clk;
output led;
reg [3:0] led;
reg [25:0] delay_cnt;
reg [2:0] display;
always@(posedge sys_clk or negedge sys_rst)
begin
if(!sys_rst)
delay_cnt<=26'd0;
else if(delay_cnt==26'd49999999)
delay_cnt<=26'd0;
else
delay_cnt<=delay_cnt+1'b1;
end
always@(posedge sys_clk or negedge sys_rst)
begin
if(!sys_rst)
display<=2'd0;
else if(delay_cnt==26'd49999999)
display<=display+1'b1;
else
display<=display;
end
always@(display)
begin
case(display)
3'h1: led=4'b1110;
3'h2: led=4'b1111;
3'h3: led=4'b1011;
3'h4: led=4'b1111;
3'h5: led=4'b1101;
3'h6: led=4'b1111;
3'h7: led=4'b0111;
3'h8: led=4'b1111;
endcase
end
endmodule
//向左流水灯功能
module led_yjg (sys_rst,
sys_clk,
led);
input sys_rst;
input sys_clk;
output led;
reg [3:0] led;
reg [25:0] delay_cnt;
reg [1:0] display;
always @ (posedge sys_clk or negedge sys_rst)
begin
if(!sys_rst)
delay_cnt<=26'd0;
else if(delay_cnt==26'd49999999)
delay_cnt<=26'd0;
else
delay_cnt<=delay_cnt+1'b1;
end
always @ (posedge sys_clk or negedge sys_rst)
begin
if(!sys_rst)
display<=2'd0;
else if(delay_cnt==26'd49999999)
display<=display+1'b1;
else
display<=display;
end
always @ (display)
begin
case(display)
2'h1: led=4'b0111;
2'h2: led=4'b0011;
2'h3: led=4'b0001;
2'h4: led=4'b0000;
endcase
end
endmodule
//向右跑马灯功能
module horse_lamp_right (sys_rst,
sys_clk,
led);
input sys_rst;
input sys_clk;
output led;
reg [3:0] led;
reg [25:0] delay_cnt;
reg [1:0] display;
always @ (posedge sys_clk or negedge sys_rst)
begin
if(!sys_rst)
delay_cnt<=26'd0;
else if(delay_cnt==26'd49999999)
delay_cnt<=26'd0;
else
delay_cnt<=delay_cnt+1'b1;
end
always @ (posedge sys_clk or negedge sys_rst)
begin
if(!sys_rst)
display<=2'd0;
else if(delay_cnt==26'd49999999)
display<=display+1'b1;
else
display<=display;
end
always @ (display)
begin
case(display)
2'h1: led=4'b1110;
2'h2: led=4'b1101;
2'h3: led=4'b1011;
2'h4: led=4'b0111;
endcase
end
endmodule
回复
有奖活动 | |
---|---|
【有奖活动——B站互动赢积分】活动开启啦! | |
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |