




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
基于VHDL语言的交通灯控制器设计2009年06月18日 星期四 20:38设计要求1、显示一个方向的绿、黄、红的指示状态。2、特殊情况按键能实现特殊的功能,计数器停止计数并保持在原来的状态,显示红灯状态。 特殊状态解除后能继续计数.3、复位按键实现总体计数清零功能。4、实现正常的倒计时功能. 用数码管作为倒计时显示, 显示时间为绿灯17s,黄灯3s红灯20s。|-|-|-| 绿灯 |黄灯| 红灯 |设计思想 首先由晶振产生出发信号,由控制器处理成1HZ的时钟,利用此时钟进行计数,通过判断计数的值来控制交通灯的亮灭。通过每种灯亮的时间总数和计数值比较得到数码管应该显示的数值,利用分位程序将其分成十位和个位。通过译码电路来实现数码管的显示。 本实验所使用的芯片为EPM7128SLS84-6,实体逻辑单元为64点,结构体逻辑单元为128点,是一种小型芯片。软件 本实验使用MAXplus II 10来进行程序的编写,编译,仿真以及下载。在实验中发现其功能虽然使用,但仍有地方需要改进,不支持MOD取余运算。(源程序) *在MAX+plus II中,汉字很容易出现乱码,建议大家用英文,这里为了考虑到读者的习惯,因此在写论文时都译成中文Library IEEE;Use IEEE.std_logic_1164.all;Entity redgreen isPort( clock_in:in std_logic; hold_state:in std_logic; reset_state:in std_logic; led_red,led_green,led_yellow:out std_logic; select_en:buffer std_logic; select_display:out std_logic_vector(0 to 6);end;Architecture half of redgreen isconstant loop_hz:integer:=800000; -一根据晶振实际频率算出来signal count_time:integer range 0 to loop_hz;signal clock_buffer:std_logic;signal clock_out:std_logic;signal count_num:integer range 0 to 40;signal display_num:integer range 0 to 20;signal display_shi:integer range 0 to 9;signal display_ge:integer range 0 to 9;constant loop_time:integer:=40;个循环周期的时间constant red_time:integer:=20; -红灯的时间constant green_time:integer:=17; -绿灯的时间constant yellow_time:integer:=3; -黄灯的时间begin process(clock_in) -分频进程 begin if rising_edge(clock_in) then if count_time=loop_hz then count_time=0; clock_buffer=not clock_buffer; else count_time=count_time+1; end if; end if; clock_out=clock_buffer; -输入1HZ的频率 end process; process(reset_state,clock_out) -计数进程 begin if reset_state=1 then -重启后计数归零 count_num=0; elsif rising_edge(clock_out) then if hold_state=1 then -紧急时计数占停 count_num=count_num; else if count_num=loop_time-1 then count_num=0; else count_num=count_num+1; end if; end if; end if; end process; process(clock_out) -交通灯显示 begin if falling_edge(clock_in) then if hold_state=1 then -占停时红灯亮 led_red=1; led_green=0; led_yellow=0; else if count_num display_num=green_time-count_num; led_red=0; led_green=1; led_yellow=0; elsif count_num display_num=green_time+yellow_time-count_num; led_red=0; led_green=0; led_yellow=1; else display_num=loop_time-count_num; led_red=1; led_green=0; led_yellow=20 then display_shi=2; display_ge=10 then display_shi=1; display_ge=display_num-10; else display_shi=0; display_ge=display_num; end if; end process; process(clock_in) -数码管显示 begin if falling_edge(clock_in) then select_enselect_displayselect_displayselect_displayselect_display=0000000; end case; if select_en=1 then select_enselect_displayselect_displayselect_displayselect_displayselect_displayselect_displayselect_displayselect_displayselect_displayselect_displayselect_display=0000000; end case; end if; end if; end process;end;-由于时间和硬件限制,这个程序仅仅实现了一路交通灯,用类似的方法可以写出两路交通灯的程序。library ieee;use ieee.std_logic_1164.all;entity redgreen isPort( clock_in:in std_logic; hold_state:in std_logic; reset_state:in std_logic; led_red,led_green,led_yellow:out std_logic; select_en:buffer std_logic; select_display:out std_logic_vector(0 to 6);end;architecture half of redgreen isbeginsignal count_time:integer range 0 to 800000;signal clock_buffer:std_logic;signal clock_out:std_logic;signal count_num:integer range 0 to 40;signal display_num:integer range 0 to 20;signal display_shi:integer range 0 to 9;signal display_ge:integer range 0 to 9;constant loop_time:integer:=50; constant red_time:integer:=25; constant green_time:integer:=20; constant yellow_time:integer:=5; begin process(clock_in) begin if rising_edge(clock_in) then if count_time=loop_hz then count_time=0; clock_buffer=not clock_buffer; else count_time=count_time+1; end if; end if; clock_out=clock_buffer; end process; process(reset_state,clock_out) begin if reset_state=1 then count_num=0; elsif rising_edge(clock_out) then if hold_state=1 then count_num=count_num; else if count_num=loop_time-1 then count_num=0; else count_num=count_num+1; end if; end if; end if; end process; process(clock_out) begin if falling_edge(clock_in) then if hold_state=1 then led_red=1; led_green=0; led_yellow=0; else if count_num display_num=green_time-count_num; led_red=0; led_green=1; led_yellow=0; elsif count_num display_num=green_time+yellow_time-count_num; led_red=0; led_green=0; led_yellow=1; else display_num=loop_time-count_num; led_red=1; led_green=0; led_yellow=20 then display_shi=2; display_ge=10 then display_shi=1; display_ge=display_num-10; else display_shi=0; display_ge=display_num; end if; end process; process(clock_in) begin if falling_edge(clock_in) then select_enselect_displayselect_displayselect_displayselect_display=0000000; end case; if
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年事业单位工勤技能-广西-广西水利机械运行维护工二级(技师)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广西-广西工程测量员一级(高级技师)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广东-广东计算机操作员二级(技师)历年参考题库含答案解析
- 2025年事业单位工勤技能-广东-广东水工闸门运行工三级(高级工)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广东-广东医技工二级(技师)历年参考题库典型考点含答案解析
- 2020-2025年设备监理师之设备工程监理基础及相关知识高分通关题型题库附解析答案
- 2020-2025年基金从业资格证之私募股权投资基金基础知识通关题库(附答案)
- 2025年中级卫生职称-主管技师-输血技术(中级)代码:390历年参考题库典型考点含答案解析
- 2025年银行金融类-金融考试-期货从业历年参考题库含答案解析(5套)
- 2023年设备监理师之设备监理合同通关提分题库及完整答案
- 企业资产收购尽职调查操作手册
- 2025年陕西省综合评标评审专家库考试历年参考题库含答案详解(5套)
- 软件开发项目进展汇报
- 六安市辅警真题2024
- 心电监护技术操作并发症的预防与处理
- 海南省省直辖县级行政单位2024-2025学年七年级下学期7月期末考试语文试卷(含答案)
- 2025年《资料员》考试题库附答案【模拟题】
- 磷石膏砌块项目可行性研究报告
- Unit 8 Let's Communicate!Section A(1a-1d)同步练习(含答案)2025-2026学年人教版(2024)八年级英语上册
- 现场调试合同协议书模板
- DB65∕T 4791-2024 水工隧洞敞开式TBM施工技术规范
评论
0/150
提交评论