FPGA交通灯实验报告_第1页
FPGA交通灯实验报告_第2页
FPGA交通灯实验报告_第3页
FPGA交通灯实验报告_第4页
FPGA交通灯实验报告_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、交通灯实验报告一, 实验目的实现两路信号灯交替亮起,并利用两组数码管分别对两路信号进行倒计时。两路信号时间分别为:v: 绿灯( 30s)h:红灯(35s)黄灯( 5s)绿灯(30s)红灯( 35s)黄灯(5s)二, 实验步骤建立工程可在欢迎界面点击“ creat a new project”进入工程建立界面,亦可关闭欢迎界面, 点击菜单栏的 “file ”,点击“ new project wizard ”进入建立工程界面。右侧为建立工程界面,点击 next 。在此界面选定工程路径,取好工程名, 点击“next”。 注意:路径中不能有中文,工程名也不能有中文。一直点击 “next”进入器件设置界

2、面,de2-70 开发工具采用的cyclone ii系列的 ep2c70f896c6n。点击“ finish ”,完成工程建立1、点击“ file”,点击“2,点击主界面工具栏中的3、写入 verilog代码。new”选择“选择“verilog hdl verilog hdl”代码如下:moduletraffic(clk_50m,rst,ledr_h,ledg_h,ledy_h,ledr_v,ledg_v,ledy_v,seg7_vh,seg7_vl,seg7_hh,seg7_h l,led15);parameter s1=2b00;parameter s2=2b01;parameter s3

3、=2b10;parameter s4=2b11;input clk_50m,rst;output ledr_h,ledg_h,ledy_h,ledr_v,ledg_v,ledy_v;output6:0 seg7_vh,seg7_vl,seg7_hh,seg7_hl;output led15;/-div for 1hz-start-reg clk_1hz;reg 31:0 cnt_1hz;always(posedge clk_50m or negedge rst)beginif(!rst)begincnt_1hz=1;clk_1hz=25000000)begincnt_1hz=1;clk_1hz

4、=clk_1hz;endelsecnt_1hz=30)cnt30=1;elsecnt30=5)cnt30=1;elsecnt30=30)cnt30=1;elsecnt30=5)cnt30=1;elsecnt30=30)cntv=1;elsecntv=5)cntv=1;elsecntv=35)cntv=1;elsecntv=35)cnth=1;elsecnth=30)cnth=1;elsecnth=5)cnth=1;elsecnth29)begincntdis7:4=3;cntdis3:019)begincntdis7:4=2;cntdis3:09)begincntdis7:4=1;10 进制计

5、数器cntdis3:0=cntvv - 10;endelsecntdis29)begincntdiss7:4=3;cntdiss3:019)begincntdiss7:4=2;cntdiss3:09)begincntdiss7:4=1;cntdiss3:0=cnthh - 10;endelsecntdiss=30)beginstate=5)beginstate=30)beginstate=5)beginstate=s1;enddefault:beginstate=s1;endendcaseendalways(posedge clk_1hz)begincase(state)s1:beginsta

6、teh=s1;statev=s1;ends2:beginstateh=s1;statev=s2;ends3:beginstateh=s2;statev=s3;ends4:beginstateh=s3;statev=s3;endendcaseendalways(posedge clk_50m or negedge rst)beginif(!rst)beginledr_h=0;ledg_h=0;ledy_h=0;ledr_v=0;ledg_v=0;ledy_v=0;endelsebegincase(state)s1:beginledr_h=1;ledg_h=0;ledy_h=0;ledr_v=0;

7、ledg_v=1;ledy_v=0;ends2:beginledr_h=1;ledg_h=0;ledy_h=0;ledr_v=0;ledg_v=0;ledy_v=1;ends3:beginledr_h=0;ledg_h=1;ledy_h=0;ledr_v=1;ledg_v=0;ledy_v=0;ends4:beginledr_h=0;ledg_h=0;ledy_h=1;ledr_v=1;ledg_v=0;ledy_v=0;enddefault:beginledr_h=0;ledg_h=0;ledy_h=0;ledr_v=0;ledg_v=0;ledy_v=0;endendcaseendenda

8、ssign led15=state;endmodulemodule seg7_lut(oseg,idig );input3:0idig;output6:0oseg;reg6:0oseg;always (idig)begincase(idig)4h1: oseg = 7b1111001;/ -t-4h2: oseg = 7b0100100;/ |4h3: oseg = 7b0110000;/ ltrt4h4: oseg = 7b0011001;/ |4h5: oseg = 7b0010010;/ -m-4h6: oseg = 7b0000010;/ |4h7: oseg = 7b1111000;

9、/ lbrb4h8: oseg = 7b0000000;/ |4h9: oseg = 7b0011000;/ -b-4ha: oseg = 7b0001000;4hb: oseg = 7b0000011;4hc: oseg = 7b1000110;4hd: oseg = 7b0100001;4he: oseg = 7b0000110;4hf: oseg = 7b0001110;4h0: oseg = 7b1000000;endcaseendendmodule编译工程保存文件,将文件放在所建工程所在路径下点击主界面工具栏中的图标也 可 点 击 菜 单 栏 中 “ processing ” , 点

10、 击 “ start compilation ”分配关键如下:clk_50m inputpin_ad15ledg_houtputpin_ad9ledg_voutputpin_aj6ledr_houtputpin_aj7 )ledr_voutputpin_aj5 )ledy_houtputpin_ad8ledy_voutputpin_ak5rst inputpin_aa23seg7_hh6outputpin_g1seg7_hh5outputpin_h3seg7_hh4outputpin_h2seg7_hh3outputpin_h1seg7_hh2 output pin_j2seg7_hh1 ou

11、tput pin_j1seg7_hh0outputpin_k3seg7_hl6 output pin_e4seg7_hl5 output pin_f4seg7_hl4 output pin_g4seg7_hl3 output pin_h8seg7_hl2 output pin_h7seg7_hl1 output pin_h4seg7_hl0outputpin_h6seg7_vh6 output pin_ad17seg7_vh5outputpin_af177seg7_vh4outputpin_ae177seg7_vh3 output pin_ag16seg7_vh2outputpin_af167

12、seg7_vh1outputpin_ae167seg7_vh0outputpin_ag13seg7_vl6 output pin_ad12seg7_vl5 output pin_ad11seg7_vl4outputpin_af108seg7_vl3 output pin_ad10seg7_vl2outputpin_ah9 8seg7_vl1outputpin_af9 8seg7_vl0outputpin_ae8 8烧写代码在管脚配置完成后,还需将工程再编译一次,成功后,点击主界面工具栏中的亦可点击主界面菜单栏中“tools ”,点击“ programmer”进入代码烧写界面后,点击“ start ”,当“ progress ”为 100%时,

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论