已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
西南石油大学计算机科学学院实验/上机报告课程名称:可编程逻辑系统设计专业:成绩:指导教师:姓名:日期:2012-04-27项目序号:学号:时间:14:3017:55项目名称:交通信号灯控制器的设计组号:地点:一、实验目的1. 通过一个简单交通信号灯控制器的设计,认识状态机的典型程序结构2. 掌握同步时序系统的 VHDL 设计方法二、实验环境1. 硬件:PC 机、EDA/SOPC/DSP 实验系统2. 软件:Quartus II 9.0三、实验内容1. 完成一个简单交通信号灯控制器的设计并实现功能仿真和硬件模拟运行2. 考虑一定安全性策略,在前者的基础上改进系统设计,并实现功能仿真和硬件模拟运行四、实验过程(一) 利用 VHDL 设计一个简单交通灯信号控制器新建一个 VHDL 文件,输入下列参考程序,以ctr1_traffic 命名保存:-library ieee;use ieee.std_logic_1164. all;entity ctr1_traffic is port (clock, car, timed: in std_logic; major_green,minor_green,start_timer:out std_logic);end ctr1_traffic;architecture ex1 of ctr1_traffic is type state_type is (G, R); signal present_state, next_state: state_type; begin seq: process (clock) is begin if (rising_edge (clock) then present_state = next_state; end if; end process seq; com: process (car, timed, present_state) is begin start_timer major_green = 1; minor_green = 0; if (car=1) then start_timer = 1; next_state = R; else next_state major_green = 0; minor_green = 1; if (timed=1) then next_state = G; else next_state = R; end if; end case; end process com;end ex1;-此程序编译无误后建立矢量波形图,设置输入激励波形组合,所得波形结果如下:刚开始,让major_green=1,在时钟脉冲信号clock控制下,当car=1,马上启动start_timer,即start_timer=1,然后在下一个时钟脉冲信号到来的时候,主街道绿灯灭,次街道绿灯亮(major_green=0,minor_green=1),当timed=1时,次街道绿灯灭,主街道绿灯亮(major_green=1,minor_green=0),建立适当波形,完成功能仿真后得到以上波形图,与预期效果一样,实验成功!(二) 增加“支道通行时间定时器“设计的简单交通灯信号控制器再次新建一个 VHDL 文件,输入下列参考程序,以timer 命名保存:-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity timer isport(clock,start_timer: in std_logic;timed: buffer std_logic);end timer;architecture ex1 of timer issignal timing: std_logic;beginp0: process(start_timer,timed,clock) isbeginif rising_edge(clock) thenif start_timer=1thentiming=1;elsif timed=1 thentiming=0;end if;end if;end process p0;p1:process(timing,clock)isvariable temp: std_logic_vector(7 downto 0);beginif timing=1 thenif rising_edge(clock) thentemp:=temp-1;if temp=0 thentimed=1;else timed0);完全编译无误后,将ctr1_traffic.vhd、timer.vhd 文件生成其各自的元件符号,连接好线,配置合适的引脚,得到如下的电路图。重新完全编译,下载至实验系统硬件中,利用按键模拟“支道有车需通行”的情况,设计的模拟灯运行情况与设计目标一致,实验成功!(三) 修改设计,提高简单交通信号灯控制器的安全性 实验(二)中只有红绿两种灯,当灯由绿直接变红的时候很容易造成交通事故,所我认为可以再增加一种黄灯,当绿灯要变成红灯的时候,先变成黄灯,提示一下灯要变红。由此便可得到如下的设计: 新建三个VHDL文件:traffic_GRY,timer0,timer1,分别输入下列参考程序:traffic_GRY-library ieee;use ieee.std_logic_1164.all;entity traffic_GRY isport(clock,reset,timed0,timed1:in std_logic; major_green,major_red,major_yellow, minor_green,minor_red,minor_yellow,start_time0,start_time1:out std_logic);end traffic_GRY;architecture behave1 of traffic_GRY is type state_type is(s0,s1,s2,s3); signal present_state,next_state:state_type;begin seq:process(clock) is begin if reset=0 then present_state=s0; elsif (rising_edge(clock)then present_state=next_state; end if; end process seq; com:process(reset,present_state) is begin start_time0=0; start_time1 major_green=1; minor_green=0; major_red=0; minor_red=1; major_yellow=0; minor_yellow=0; start_time0=1; if(timed0=1)then next_state=s1; start_time1=1; else next_state major_green=0; minor_green=0; major_red=0; minor_red=1; major_yellow=1; minor_yellow=0; if(timed1=1)then next_state=s2; start_time0=1; else next_state major_green=0; minor_green=1; major_red=1; minor_red=0; major_yellow=0; minor_yellow=0; if(timed0=1)then next_state=s3; start_time1=1; else next_state major_green=0; minor_green=0; major_red=1; minor_red=0; major_yellow=0; minor_yellow=1; if(timed1=1)then next_state=s0; else next_state=s3; end if; end case; end process com;end behave1;-Timer0:-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity timer0 is port(clock,start_time0: in std_logic; timed0: buffer std_logic);end timer0;architecture behave2 of timer0 is signal timing0: std_logic; begin p0:process(start_time0,timed0,clock) is begin if rising_edge(clock) then if start_time0=1then timing0=1; elsif timed0=1 then timing0=0; end if; end if; end process p0; p1:process(timing0,clock)is variable temp: std_logic_vector(31 downto 0); begin if timing0=1 then if rising_edge(clock) then temp:=temp+1; if temp=250000000 then timed0=1; else timed00); end if; end process p1;end behave2;-timer1:-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity timer1 is port(clock,start_time1: in std_logic; timed1: buffer std_logic);end timer1;architecture behave3 of timer1 is signal timing1: std_logic; begin p0:process(start_time1,timed1,clock) is begin if rising_edge(clock) then if start_time1=1then timing1=1; elsif timed1=1 then timing1=0; end if; end if; end process p0; p1:process(timing1,clock)is variable temp: std_logic_vector(31 downto 0); begin if timing1=1 then if rising_edge(clock) then temp:=temp+1; if temp=500000000 then timed1=1; else timed10); end if; end process p1;end behave3;-对traffic_GRY程序编译无误后建立矢量波形图,设置输入激励波形,所得波形结果如下:刚开始,绿红灯亮(major_green=1,minor_red=1),在时钟脉冲信号clock控制下,当timed0=1,马上启动start_time0,然后在下一个时钟脉冲信号到来的时候,黄红灯亮(major_yellow=1,minor_red=1),当timed1=1时,马上启动start_time1,然后在下一个时钟脉冲信号到来的时候,红绿灯亮(major_red=1,minor_green=1),再依次将timed0,timed1置1,将会控制相应的交通信号灯的亮灭,建立适当波形,完成功能仿真后得到以上波形图,与预期效果一样,实验成功!完全编译无误后,将三个VHDL文件:traffic_GRY,timer0,timer1生成其各自的元件符号,连接好线,配置合适的引脚,得到如下的电路图。重新完全编译,下载至实验系统硬件中,模拟“支道有车需通行”的情况,设计的模拟灯运行情况与设计目标一致,按下reset按键,回到最初状态,实验成功!(4)本次实验遇到的问题及解决办法在本次实验中,我遇到了比较多的问题,首先,我一开始都没注意设置工程制定顶层实体,导致在有多个工程时编译报错,还有经常会出现顶层实体与我程序中的实体名称不一样,这样也会导致编译报错,提示找不到工程,这个错误在多次实验反复纠正后现在基本不会出现这个细节错误;在同一个工程中有时候我不注意时经常会在两个文件中使用同名实体,这样就产生冲突,在看了实验知道后也得到了纠正,知道同一工程不能出现同名实体,要是出现,必须修改实体名或者把一个移出工程;在用网表描述设计一位全加器时,刚开始我根本不知道这些代码应该怎么放置,是放在同一个文件中呢,还是怎么样,编译很多次都没通过,后来在同学的耐心讲解下我才知道原来这样的网表描述设计应该是分别放在同一个工程的不同的文件中,然后把主要的那个文件设为顶层实体,这样在执行顶层实体的时候系统会调用其他的实体。 做实验(三)的时候,用了比较多的时间在编程、仿真上面,当仿真正确了,下载至实验系统硬件中模拟交通指
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 南京市人民医院高级职称晋升病例答辩评审
- 南昌市中医院超声诊断医师上岗资格认证
- 直播装修优惠活动方案
- 看电影师德活动方案
- 粽子插花活动方案
- 纪念灾难活动方案
- 百年人寿反洗钱活动方案
- 精心制定活动方案
- 相亲游园大会活动方案
- 相亲名片活动方案
- 学术道德与学术规范
- 中邮保险招聘笔试题库2024
- 城市作战案例研究报告
- 2024年基本级执法资格考试题库及解析(200题)
- HG∕T 5229-2017 热空气老化箱
- DL-T1362-2014输变电工程项目质量管理规程
- 2024年四川省成都市中考英语试卷(含官方答案)
- 第五章运动中的中枢控制
- 授权他人使用车辆委托书
- JJG 4-2015钢卷尺行业标准
- 乌鸡白凤丸中成药介绍
评论
0/150
提交评论