verilog交通灯设计.pdf
《verilog交通灯设计.pdf》由会员分享,可在线阅读,更多相关《verilog交通灯设计.pdf(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、 module jtd(zhi,clk,u,i);input zhi,clk;output 2:0u,i;reg2:0u,i;reg d;always(posedge clk)begin if(zhi)begin u2:0=3b100;i2:0=3b001;end else begin d=d+1;if(d=30)u2:0=3b010;if(d=34)begin u2:0=3b001;i2:0=3b100;end if(d=64)begin u2:0=3b001;i2:0=3b010;end if(d=68)begin u2:0=3b100;i2:0=3b001;d=0;end module
2、jtd(zhi,u,i,clk,rst);input zhi,clk,rst;output 2:0u,i;reg 2:0u,i;reg4:0state;reg 5:0d;initial d=0;parameter s0=5b00001,s1=5b00010,s2=5b00100,s3=5b01000,s4=5b10000;always(posedge clk)begin if(!rst)begin state=s0;u2:0=3b100;i2:0=3b001;end else begin case(state)s4:begin u2:0=3b100;i2:0=3b001;if(zhi)begi
3、n state=s0;end else state=s4;end s0:begin u2:0=3b100;i2:0=3b001;d=d+1;if(d=30)begin state=s1;d=0;end else state=s0;end s1:begin u2:0=3b010;i2:0=3b001;d=d+1;if(d=4)begin state=s2;d=0;end else state=s1;end s2:begin u2:0=3b001;i2:0=3b100;d=d+1;if(d=30)begin state=s3;d=0;end else state=s2;end s3:begin u
4、2:0=3b001;i2:0=3b010;d=d+1;if(d=4)begin state=s4;d=0;end else state=s3;end default:state=s4;endcase end end endmodule 黄灯闪 module jtde(zhi,u,i,clk,rst);input zhi,clk,rst;output 2:0u,i;reg 2:0u,i;reg4:0state;reg 6:0d;initial d=0;parameter s0=5b00001,s1=5b00010,s2=5b00100,s3=5b01000,s4=5b10000;always(p
5、osedge clk)begin if(!rst)begin state=s4;u2:0=3b100;i2:0=3b001;end else begin case(state)s4:begin u2:0=3b100;i2:0=3b001;if(zhi)begin state=s0;end else state=s4;end s0:begin u2:0=3b100;i2:0=3b001;d=d+1;if(d=30)begin state=s1;d=0;end else state=s0;end s1:begin d=d+1;if(d=1)begin u2:0=3b000;i2:0=3b001;s
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- verilog 交通灯 设计
限制150内