十字路口交通灯控制器_第1页
十字路口交通灯控制器_第2页
十字路口交通灯控制器_第3页
十字路口交通灯控制器_第4页
十字路口交通灯控制器_第5页
已阅读5页,还剩4页未读, 继续免费阅读

下载本文档

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

文档简介

EDA 实验报告实验报告 十字路口交通灯控制器设计十字路口交通灯控制器设计 姓名 康淼姓名 康淼 学号 学号指导教师 徐少莹指导教师 徐少莹 一 一 设计目的设计目的 1 熟悉数字电路中时序逻辑电路与组合逻辑电路的设计 2 熟悉并掌握用移位寄存器设计彩灯数码管控制的方法 二 二 设计任务及其要求设计任务及其要求 设计一个十字路口交通控制系统 要求 1 其东西 南北两个方向除了有红 黄 绿灯指示是否允许 通行外 2 设有时钟 以倒计时方式显示每一路允许通行的时间 绿 灯 黄灯 红灯的持续时间分别是 40 5 和 45 秒 3 当东西或南北两路中任一道上出现特殊情况 例如有消防 车 警车要去执行任务 此时交通控制系统应可由交警手动控制立 即进入特殊运行状态 即两条道上的所有车辆皆停止通行 红灯全 亮 时钟停止计时 且其数字在闪烁 当特殊运行状态结束后 管 理系统恢复原来的状态 继续正常运行 实际状态示意图如下 三 三 设计思路设计思路 首先路口的情况分为两种情况 第一是普通情况 第二是紧急情 况 因此设计一个 EN 作为交警手动控制位 当 EN 0 时 交通灯工 作在普通模式 当 EN 1 时 交通灯工作在紧急模式 一 普通模式 交通灯有三种颜色 红黄绿 通过观察可以发现这三种颜色 处在一个循环当中 当南北路口的红灯转绿灯时 东西路口应是黄灯转红灯 当 南北路口的绿灯转黄灯时 东西路口应是红灯不变 当南北 路口的黄灯转红灯时 东西路口应是红灯转绿灯 因此发现 东西路口缺少了一种绿转黄的状态 因此可知在程序设计时 考虑四种情况 1 南北路口的红灯转绿灯 此时东西路口黄灯转红灯 南北 置数 39 东西置数 44 2 南北路口的绿灯转黄灯 此时东西路口红灯不变 南北置 数 4 东西不置数 3 南北路口的黄灯转红灯 此时东西路口红灯转绿灯 南北 置数 44 东西置数 39 4 东西路口绿灯转黄灯 此时南北路口的红灯不变 南北不 置数 东西置数 4 其他情况里东西南北的置数递减即可 二 紧急模式 计时停止 当前的计时状态与 0000 进行交替闪烁 双向道路 全部变成红灯 四 四 程序编写程序编写 library ieee use ieee std logic 1164 all use ieee std logic unsigned all entity trafficlight is port clk en in std logic clock and en pin input led ns led we out std logic vector 2 downto 0 out pins north and south led west and east led t ns h t ns l t we h t we l out std logic vector 3 downto 0 clock of north and south or west and east end trafficlight architecture one of trafficlight is signal temp std logic clock signal signal l ns std logic vector 2 downto 0 100 red yellow green signal l we std logic vector 2 downto 0 010 at the begining ns is stopped we is allowed signal temp ns h std logic vector 3 downto 0 0100 north and south counter high bit signal temp ns l std logic vector 3 downto 0 0100 north and south counter low bit signal temp we h std logic vector 3 downto 0 0011 west and east counter high bit signal temp we l std logic vector 3 downto 0 1001 west and east counter low bit signal a b std logic vector 3 downto 0 0000 signal c d std logic vector 3 downto 0 0000 signal state std logic 0 begin process clk en begin if clk event and clk 1 then if en 0 then work in normal if temp ns h 0000 and temp ns l 0000 and l ns 100 then north and south time is 0 red led is on temp ns h 0011 temp ns l 1001 ns time is to 39 l ns 010 ns road red led is to low green led is to high temp we h 0100 temp we l 0100 we time is to 44 l we 100 we road red led is to high elsif temp ns h 0000 and temp ns l 0000 and l ns 010 then if north and south time is 0 green led is on temp ns h 0000 temp ns l 0100 l ns 001 temp we l temp we l 1 west and east sub 1 elsif temp ns h 0000 and temp ns l 0000 and l ns 001 then if north and south time is 0 yellow led is on temp ns h 0100 temp ns l 0100 44 l ns 100 temp we h 0011 temp we l 1001 39 l we 010 green is on elsif temp we h 0000 and temp we l 0000 and l we 010 then temp we h 0000 temp we l 0100 l we 001 temp ns l 0000 then temp ns l 1001 temp ns h temp ns h 1 else temp ns l 0000 then temp we l 1001 temp we h temp we h 1 else temp we l temp we l 1 end if if temp ns l 0000 and temp we l 0000 then temp ns l 1001 temp we l 1001 temp ns h temp ns h 1 temp we h temp we h 1 end if end if a temp ns h b temp ns l c temp we h d temp we l t ns h temp ns h t ns l temp ns l t we h temp we h t we l temp we l led ns l ns led we l we end if end if if en 1 then work in enmergency if clk 1 then a 0000 b 0000 c 0000 d 0000 else a temp ns h b temp ns l c temp we h d temp we l end if t ns h a t ns l b t we h c t we l d led ns 100 led we 100 end if end process end one 五 五 下载调试下载调试 将代码进行拷贝在电脑上 分析 无错误后进行 pins 配置 下载到 fpga 功能实现 计时状态正确 外部中断实现

温馨提示

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

评论

0/150

提交评论