资源描述:
《数电大作业实验报告(二)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、数电大作业实验报告(二)十字路口交通灯自动控制器设计实验实验报告一、实验内容及要求设计一个十字路口交通控制系统,其东西,南北两个方向除了有红、黄、绿灯指示是否允许通行外,还设有时钟,以倒计时方式显示每一路允许通行的时间,绿灯,黄灯,红灯的持续时间分别是40、5和45秒。当东西或南北两路中任一道上出现特殊情况,例如有消防车,警车要去执行任务,此时交通控制系统应可由交警手动控制立即进入特殊运行状态,即两条道上的所有车辆皆停止通行,红灯全亮,时钟停止计时,且其数字在闪烁。当特殊运行状态结束后,管理系统恢复原来的状态,继续正常运行.
2、二、VHDL语言实现libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useieee.std_logic_arith.all;entitydengisport(clk,hold:instd_logic;ared,agreen,ayellow,bred,bgreen,byellow:outstd_logic;a1,a2,b1,b2:outstd_logic_vector(3downto0));enddeng;architectureone
3、ofdengistypestate_typeis(s0,s1,s2,s3,s4);signalcurrent_state,next_state:state_type;signalcounter:integerrange0to90;signaladeng_temp,bdeng_temp:integerrange0to45;signalaql,aqh,bql,bqh:integerrange0to9;beginprocessbeginwaituntilclk'eventandclk='1';ifhold='0'thencount
4、er<=counter;elseifcounter<89thencounter<=counter+1;elsecounter<=0;endif;endif;endprocess;processbeginwaituntilclk'eventandclk='1';current_state<=next_state;endprocess;process(current_state)begincasecurrent_stateiswhens0=>ifhold='0'thennext_state<=s4;elseifcounter<3
5、9thennext_state<=s0;elsenext_state<=s1;endif;endif;whens1=>ifhold='0'thennext_state<=s4;elseifcounter<44thennext_state<=s1;elsenext_state<=s2;endif;endif;whens2=>ifhold='0'thennext_state<=s4;elseifcounter<84thennext_state<=s2;elsenext_state<=s3;endif;endif;whens3=>
6、ifhold='0'thennext_state<=s4;elseifcounter<89thennext_state<=s3;elsenext_state<=s0;endif;endif;whens4=>ifhold='0'thennext_state<=s4;elseifcounter<39thennext_state<=s0;elsifcounter<44thennext_state<=s1;elsifcounter<84thennext_state<=s2;elsifcounter<89thennext_state<
7、=s3;endif;endif;endcase;endprocess;process(current_state)begincasecurrent_stateiswhens0=>ared<='0';agreen<='1';ayellow<='0';bred<='1';bgreen<='0';byellow<='0';whens1=>ared<='0';agreen<='0';ayellow<='1';bred<='1';bgreen<='0';byellow<='0';whens2=>ared<='1';agreen<='0
8、';ayellow<='0';bred<='0';bgreen<='1';byellow<='0';whens3=>ared<='1';agreen<='0';ayellow<='0';bred<='0';bgreen<='0';byellow<='1';whens4=>ared<='1'