module ledblink(sys_clk,sys_rstn,led);input sys_clk;input sys_rstn;output [7:0] led;reg [7:0] led;reg [49:0] delay_cnt;always@(posedge sys_clk or negedge sys_rstn) begin if(!sys_rstn) delay_cnt<=50'd0; else begin if(delay_cnt==50'd49999999) delay_cnt<=50'd0; else delay_cnt<=delay_cnt+1'b1; end endalways@(posedge sys_clk or negedge sys_rstn) begin if(!sys_rstn) led<=8'b11111111; else begin if(delay_cnt==50'd49999999) led<=~led; else led<=led; end end endmodule实现功能:流水灯
module ledblink(sys_clk,sys_rstn,led);input sys_clk;input sys_rstn;output [7:0] led;reg [7:0] led;reg [49:0] delay_cnt;always@(posedge sys_clk or negedge sys_rstn) begin if(!sys_rstn) delay_cnt<=50'd0; else begin if(delay_cnt==50'd49999999) delay_cnt<=50'd0; else delay_cnt<=delay_cnt+1'b1; end endalways@(posedge sys_clk or negedge sys_rstn) begin if(!sys_rstn) led<=8'b11111111; else begin if(delay_cnt==50'd49999999) begin led<=led<<1; if(led==8'b00000000) led<=8'b11111111; end else led<=led; end end endmodulee,编写完代码,先编译一次,方便引脚映射
f,映射硬件引脚