ImageVerifierCode 换一换
格式:DOCX , 页数:27 ,大小:326.03KB ,
资源ID:7435051      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7435051.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(基于VHDL的交通灯设计与实现.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

基于VHDL的交通灯设计与实现.docx

1、基于VHDL的交通灯设计与实现华中科技大学基于xilinx FPGA的VHDL交通灯操纵器的设计 -基于Spartan3E开发板专业: 电子信息工程一. 任务设计要求 设计一个十字路口交通信号灯的按时操纵电路。要求红、绿灯按必然的规律亮和灭,并在亮灯期间进行倒计时,并将运行时刻用数码管/液晶显示出来。绿灯亮时,为该车道许诺通行信号,红灯亮时,为该车道禁止通行信号。要求骨干道每次通行时刻为99秒,支干道每次通行时刻为30秒。每次变换运行车道前绿灯闪烁,持续时刻为5秒。即车道要由骨干道转换为支干道时,骨干道在通行时刻只剩下5秒钟时,绿灯闪烁显示,支干道仍为红灯,以便骨干道上已过停车线的车继续通行,

2、未过停车线的车停止通行。同理,当车道由支干道转换为骨干道时,支干道绿灯闪烁显示5秒钟,骨干道仍为红灯。 对红、绿灯的运行时刻要能比较方便的进行从头设置。 对器件进行在系统编程和实验验证。用VHDL语言对设计进行描述,设计一个测试方案,通过ISE对设计进行仿真验证。并能够下载到实验板上调试成功。任务扩展:在原设计的基础上加入指示方向的功能。二. 系统设计1.系统原理图与说明由系统设计原理图,我以清楚地将系统分为六个模块:分频模块,时刻设置模块,状态转换模块,时刻计算模块,LED流水灯模块,LCD显示模块。1)分频模块 分频模块其作用为:由于Spartan3E板上提供的时钟信号为50MHz,而设计

3、所需时钟信号为1Hz,故利用分频模块将50MHz信号分频为1Hz信号。2)时刻置数模块由于任务设计要求能够对骨干道,支干道上左转、绿灯运行的时刻进行从头设置调整,因此要对系统进行参数化设计。第一引入一组参数,main_gh,main_gl,main_lh,main_ll,branch_gh,branch_gl,branch_lh,branch_ll(下划线后面的字母别离取green,left,high,low首字母).需要置数时,第一选择对骨干道仍是支干道时刻置数,那个地址设置一个main_or_branch参数,当main_or_branch为高时设置支干道时刻,为低时设置骨干道时刻。置数时

4、,通过s_set_button,l_set_button对时刻进行设置,具体方式参见代码。为了置数方便,引入一个add_or_decent参数,低电平常按下button能够增计数,高电平常按下能够减计数。3)状态转换模块状态转化模块是整个系统的核心模块它操纵整个交通灯系统的状态转变,整个进程划分为四个大体状态:骨干道绿灯、骨干道左转、支干道绿灯、支干道左转,用state、s_or_l为00、0一、10、11来代表。每当一个状态的计数器为00时,state、s_or_l发生改变,以实现状态间的转换,进而操纵交通灯的转变。4)时刻计算模块这次设计中扩展了左转向的功能,因此红灯时刻不单单是另一干道的

5、直行时刻,而是直行时刻和左转时刻之和。5)LCD显示模块Spartan3E板上只有LCD显示模块,因此采纳此模块显示当前亮灯的剩余时刻和设置时刻模块的时刻显示。通过输入counterplay_1l,counterplay_1h,counterplay_2l,counterplay_2h四位二进制数,加上0011显示成十进制数,别离代表两位数的低位和高位6)LED显示模块由输入信号state、s_or_l、flash,别离取000,001,010,011,100,101,110,111所取得的main_green,main_left,main_red,branch_left,branch_gre

6、en,branch_red的不同值,来操纵骨干道,支干道红绿左转灯的亮灭。其中 1表示亮,0表示灭。如表3-1 所示。由上表可取得: main_green = NOT(state) AND NOT(s_or_l) AND (NOT(flash AND clk); main_left = NOT(state) AND s_or_l AND (NOT(flash AND clk); main_red = state; branch_green = state AND NOT(s_or_l) AND (NOT(flash AND clk); branch_left = state AND s_or_

7、l AND (NOT(flash AND clk); branch_red = NOT(state);2.输入输出设计任务设计开发板基于Spartan3E板,具体输入输出设定如下:1)输入: 开关:main_or_branch:设置骨干道仍是支干道 EN: 使能信号 run_or_set: 设置运行模式还是时间设置模式 add_or_decent: 置数模式:增加或者减少 按键:s_set_button: 直行时间设置按键 l_set_button: 左转时间设置按钮 时钟:clk2)输出: LCD显示屏:别离显示当前亮灯的剩余秒数 LED灯:main_green,main_red,main_

8、left branch_left,branch_green,branch_red3、状态转换图S0状态:骨干道绿灯、支干道红灯S1状态:骨干道左转、支干道红灯S2状态:支干道绿灯、骨干道红灯S3状态:支干道左转、骨干道红灯三各模块代码和仿真波形分频模块代码因为1HZ波形太长,不易仿真,故仿真波形采纳100HZ的输入clk :50MHZ输出clk1:100HZ时刻设置模块部份代码以上是直行时刻设置代码。左转设置类似,在此再也不复制仿真 设置 输入 :clk main_or_branch 设置为0 add_or_decent 设置为0 s_set_button 设置为周期为1周期的信号 l_set

9、_button 设置为低电平波形如下时刻计算模块代码波形仿真输入输出与预期相符合。状态转换模块波形仿真别离给骨干道,支干道个颜色灯持续时刻赋值,再给定,当前亮灯的剩余时刻,然后又进行仿真,结果符合预期LED模块代码波形仿真别离给予输入不同周期的高低点评,彼此叠加的结果符合预期。LCD模块代码library IEEE;use LCD is port( clk : in STD_LOGIC; rst_n : in STD_LOGIC; counter_play1h, counter_play1l : in STD_LOGIC_VECTOR(3 downto 0); counter_play2h,

10、counter_play2l : in STD_LOGIC_VECTOR(3 downto 0); -degree1, degree2 : in STD_LOGIC_VECTOR(3 downto 0); SF_D : out STD_LOGIC_VECTOR(3 downto 0); LCD_E, LCD_RS, LCD_RW: out STD_LOGIC );end LCD;architecture behavior of LCD is type tx_sequence is (high_setup, high_hold, oneus, low_setup, low_hold, forty

11、us, done); signal tx_state : tx_sequence := done; signal tx_byte : std_logic_vector(7 downto 0); signal tx_init : std_logic := 0; type init_sequence is (idle, fifteenms, one, two, three, four, five, six, seven, eight, done); signal init_state : init_sequence := idle; signal init_init, init_done : st

12、d_logic := 0; signal i : integer range 0 to 750000 := 0; signal i2 : integer range 0 to 2000 := 0; signal i3 : integer range 0 to 82000 := 0; signal SF_D0, SF_D1 : std_logic_vector(3 downto 0); signal LCD_E0, LCD_E1 : std_logic; signal mux : std_logic;-? type display_state is (init, function_set, en

13、try_set, set_display, clr_display, pause, set_addr, max_degree_1,max_degree_2,temperature_1,temperature_2,degree_1,degree_2,blank1,blank2,blank3); signal cur_state : display_state := init;begin -LED = tx_byte; -for diagnostic purposes -SF_CE0 = 1; -disable intel strataflash LCD_RW = 0; -write only -

14、The following with statements simplify the process of adding and removing states. -when to transmit a command/data and when not to with cur_state select tx_init = 0 when init | pause , 1 when others; -control the bus with cur_state select mux = 1 when init, 0 when others; -control the initialization

15、 sequence with cur_state select init_init = 1 when init, 0 when others; -register select with cur_state select LCD_RS = 0 when function_set|entry_set|set_display|clr_display|set_addr, 1 when others; -what byte to transmit to lcd -refer to datasheet for an explanation of these values with cur_state s

16、elect tx_byte = 00101000 when function_set, - ? 00000110 when entry_set, 00001100 when set_display, 00000001 when clr_display, when set_addr, 0011&counter_play1h when max_degree_1, 0011&counter_play1l when max_degree_2, 00100000 when blank1, 0011&counter_play2h when temperature_1, 0011&counter_play2

17、l when temperature_2, 00100000 when blank2, 00100000 when degree_1, 00100000 when degree_2, 00100000 when blank3, 00100000 when others; -main state machine display: process(clk, rst_n) begin if(rst_n=0) then cur_state if(init_done = 1) then cur_state = function_set; else cur_state if(i2 = 2000) then

18、 cur_state = entry_set; else cur_state if(i2 = 2000) then cur_state = set_display; else cur_state if(i2 = 2000) then cur_state = clr_display; else cur_state i3 = 0; if(i2 = 2000) then cur_state = pause; else cur_state if(i3 = 82000) then cur_state = set_addr; i3 = 0; else cur_state = pause; i3 if(i2

19、 = 2000) then cur_state = max_degree_1; else cur_state if(i2 = 2000) then cur_state = max_degree_2; else cur_state if(i2 = 2000) then cur_state = blank1; else cur_state if(i2 = 2000) then cur_state = temperature_1; else cur_state if(i2 = 2000) then cur_state = temperature_2; else cur_state if(i2 = 2

20、000) then cur_state = blank2; else cur_state if(i2 = 2000) then cur_state = degree_1; else cur_state if(i2 = 2000) then cur_state = degree_2; else cur_state if(i2 = 2000) then cur_state = blank3; else cur_state if(i2 = 2000) then cur_state =set_addr ; else cur_state = blank3; end if; end case; end i

21、f;end process display; with mux select SF_D = SF_D0 when 0, -transmit SF_D1 when others; -initialize with mux select LCD_E = LCD_E0 when 0, -transmit LCD_E1 when others; -initialize -specified by datasheet transmit : process(clk, rst_n, tx_init) begin if(rst_n=0) then tx_state -40ns LCD_E0 = 0; SF_D

22、0 = tx_byte(7 downto 4); if(i2 = 2) then tx_state = high_hold; i2 = 0; else tx_state = high_setup; i2 -230ns LCD_E0 = 1; SF_D0 = tx_byte(7 downto 4); if(i2 = 12) then tx_state = oneus; i2 = 0; else tx_state = high_hold; i2 LCD_E0 = 0; if(i2 = 50) then tx_state = low_setup; i2 = 0; else tx_state = on

23、eus; i2 LCD_E0 = 0; SF_D0 = tx_byte(3 downto 0); if(i2 = 2) then tx_state = low_hold; i2 = 0; else tx_state = low_setup; i2 LCD_E0 = 1; SF_D0 = tx_byte(3 downto 0); if(i2 = 12) then tx_state = fortyus; i2 = 0; else tx_state = low_hold; i2 LCD_E0 = 0; if(i2 = 2000) then tx_state = done; i2 = 0; else tx_state = fortyus; i2 LCD_E0 = 0; if(tx_init = 1) then tx_state = high_setup; i2 = 0; else tx_state = done; i2 = 0; end if; end case; end if; end process transmit; -specified by datasheet power_on_initialize: process(clk, rst_n, i

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1