靠,怎么又是流水灯。
这个实验主要是体验Verilog语言的用法
module flow_led(
input sys_clk50,
input rst_n,
output reg [3:0] led
);
reg [23:0] cnt; //20ns
always @(posedge sys_clk50 or negedge rst_n)
begin
if(!rst_n)
cnt<=1'b0;
else
if(cnt<24'd1000_0000)
cnt<=cnt+1'd1;
else cnt<=24'd0;
end
always @(posedge sys_clk50 or negedge rst_n)
begin
if(!rst_n)
led<=4'b0001;
else
if(cnt==24'd1000_0000)
led<={led[2:0],led[3]};
else led<=led;
end
endmodule