verilog交通灯设计(15页).doc
《verilog交通灯设计(15页).doc》由会员分享,可在线阅读,更多相关《verilog交通灯设计(15页).doc(16页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-module jtd (zhi,clk,u,i);input zhi,clk;output 2:0u,i;reg2:0u,i;reg d;always(posedge clk)beginif(zhi) begin u2:0=3b100; i2:0=3b001; endelse 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
2、=0; endmodule 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)beginif(!rst) begin state=s0;u2:0=3b100;i2:0=3b001;endelsebegincase(state)s4:begin u2:0=3b100;i2:0=3b
3、001;if(zhi)begin state=s0;end else state=s4;ends0:begin u2:0=3b100;i2:0=3b001;d=d+1;if(d=30)begin state=s1;d=0;end else state=s0;ends1:begin u2:0=3b010;i2:0=3b001;d=d+1;if(d=4)begin state=s2;d=0;end else state=s1;ends2:begin u2:0=3b001;i2:0=3b100;d=d+1;if(d=30) begin state=s3;d=0;end else state=s2;e
4、nds3:begin u2:0=3b001;i2:0=3b010;d=d+1;if(d=4)begin state=s4;d=0;end else state=s3;enddefault: state=s4;endcaseendendendmodule黄灯闪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=5b100
5、00;always(posedge clk)beginif(!rst) begin state=s4;u2:0=3b100;i2:0=3b001;endelsebegincase(state)s4:begin u2:0=3b100;i2:0=3b001;if(zhi)begin state=s0;end else state=s4;ends0:begin u2:0=3b100;i2:0=3b001;d=d+1;if(d=30)begin state=s1;d=0;end else state=s0;ends1:begin d=d+1; if(d=1)begin u2:0=3b000;i2:0=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- verilog 交通灯 设计 15
限制150内