用下面这段代码闪亮板子上3个led,这段代码在altera的板子上执行后led会闪烁,但是在xilinx的板子上没有得到相同的效果。在xilinx的板子上只是这3个led亮了,但是不闪(板子上共有8个led)
module led(sys_clk,
sys_rstn,
led
);
input sys_clk;
input sys_rstn;
output [2:0] led;
reg [2:0] led;
reg [24:0] delay_cnt;
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
delay_cnt <= 25'd0;
else
begin
if(delay_cnt == 25'd24999999)
delay_cnt <= 25'd0;
else
delay_cnt<=delay_cnt+1'b1;
end
end
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
led<=3'b111;
else
begin
if(delay_cnt==25'd24999999)
led<=~led;
else
led<=led;
end
end
endmodule
此帖出自
小平头技术问答
module led(sys_clk,
sys_rstn,
led
);
input sys_clk;
input sys_rstn;
output [2:0] led;
reg [2:0] led;
reg [24:0] delay_cnt;
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
delay_cnt <= 25'd0;
led<=3'b111;
else
begin
if(delay_cnt == 25'd24999999)
delay_cnt <= 25'd0;
led<=~led;
else
delay_cnt<=delay_cnt+1'b1;
end
end
而且,这种的,最好用简单的组合电路组成就好,占用资源也少.
一周热门 更多>