FPGA程序总结_fpga总结

2020-02-28 其他工作总结 下载本文

FPGA程序总结由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“fpga总结”。

1流水灯程序

module ww(clk,led,rst);

input clk,rst;

output [3:0]led;

reg [3:0]led;

reg [24:0] cnt;

always@(posedge clk or negedge rst)

begin

if(!rst)cnt

else

begin

if(cnt==25'd24999999)cnt

else cnt

end

end

通过cnt对时钟的计数实现0.5s定时。设输入时钟是50M always@(posedge clk or negedge rst)

begin

if(!rst)led

else

begin

if(cnt==25'd24999999)

begin

led

if(led==4'b0000)led

end

else led

end

end endmodule

学会计数判断实现定时,和移位的使用

将第二个always改为下面的,就是跑马灯了。(相当向左循环移位)always@(posedge clk or negedge rst)

begin

if(!rst)led

else

begin

if(cnt==25'd24999999)

led

else led

end

end

2共阴数码管

3FH,06H,5BH,4FH,66H,6DH,7DH,07H[0-7]7FH,6FH ,77H,7CH,39H,5EH,79H,71H[8-F]注意:easyfpga板独立的2个数码管是共阴的,断码8位顺序:dp,g,f,e,d,c,b,a//dp在高位 0—F显示 输入时钟50M

module ww(clk,seg,wei,rst);

input clk,rst;

output [7:0]seg;

output [1:0]wei;

reg [7:0]seg;

reg [3:0]dat;reg [25:0] cnt;

always@(posedge clk or negedge rst)//1秒定时 begin

if(!rst)cnt

else

begin

if(cnt==26'd49999999)cnt

end

end

always@(posedge clk or negedge rst)begin

if(!rst)dat

else

begin

if(cnt==26'd49999999)begin

dat

if(dat==4'hf)dat

end

always@(dat)

begin

case(dat)

4'h0:seg=8'h3f;

4'h1:seg=8'h06;

4'h2:seg=8'h5b;else dat

4'h3:seg=8'h4f;4'h4:seg=8'h66;4'h5:seg=8'h6d;4'h6:seg=8'h7d;4'h7:seg=8'h07;4'h8:seg=8'h7f;4'h9:seg=8'h6f;4'ha:seg=8'h77;4'hb:seg=8'h7c;4'hc:seg=8'h39;4'hd:seg=8'h5e;4'he:seg=8'h79;4'hf:seg=8'h71;endcase end

aign wei=2'b00;endmodule

《FPGA程序总结.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
FPGA程序总结
点击下载文档
相关专题 fpga总结 程序 FPGA fpga总结 程序 FPGA
[其他工作总结]相关推荐
    [其他工作总结]热门文章
      下载全文