1、EDA试验设计报告EDA试验设计报告 -之交通灯学院:电子工程学院班级:021052学号:02105123姓名:阿鹏仁一、 选题目的:交通灯作为现代十字路口对交通信号灯进行管理,在我们的出行方面起很大的作用,防止了很多交通事故的发生,是现代交通建设方面不可缺少的一部分。本次试验是基于EDA技术实现对交通灯设计,因为交通灯比较好实现,各自之间的模块分明,还能掌握在设计交通灯过程中的一些模块,使我更加深刻的理解EDA这门将软件和硬件结合起来的技术。让我对VHDL语言有了更深一步的了解,跟C语言和其他的语言比起来,VHDL语言呈现了它独特的性质,它是并行运行的一种语言。此外,通过本次试验,使我熟悉掌
2、握了用EDA技术实现某一工程的全过程,在以后的运用中,能更熟练的操作。二、 设计目标:一个十字路口交通控制系统,其东西,南北两个方向除了有红、黄、绿灯指示是否允通行外,还设有时钟,以倒计时方式显示每一路允许通行的时间,绿灯,黄灯,红灯的持续时间分别是40、5和45秒。当东西或南北两路中任一道上出现特殊情况,例如有消防车,警车要去执行任务,此时交通控制系统应可由交警手动控制立即进入特殊运行状态,即两条道上的所有车辆皆停止通行,红灯全亮,时钟停止计时,且其数字在闪烁。当特殊运行状态结束后,管理系统恢复原来的状态,继续正常运行。通过VHDL语言的编写,生成元器件,然后手动连接电路,再对整个过程进行调
3、式,如果正确的话进行波形仿真,波形符合理论上的波形的话,最后一步在把整个程序烧进板子里面,实现对交通灯的模拟。三、 实现方案:原理框图: hold=0 hold=1 hold=1 hold=1 设计流程图:四、 设计过程设计交通灯需要四个模块,分别是:分频器、倒计时计数器、控制器、7字段译码器,其对应的实体名为:devide、M45、control、seg7。将程序编写好以后,以实体名为名的文件进行保存各模块代码:devide模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity de
4、vide isport ( clk :in std_logic; clk_out :out std_logic );end devide;architecture arc_devide of devide is signal count: std_logic_vector(21 downto 0); begin process begin wait until clkevent and clk=1; if( count4) then count=count+1; clk_out=0; else count0); clk_out=1; end if; end process;end archit
5、ecture arc_devide; M45模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m45 isport( CLK : in std_logic; EN : in std_logic; CR : in std_logic; QL,QH : out std_logic_vector(3 downto 0); OC : out std_logic );end m45;architecture behav of m45 is signal couL,couH: std_log
6、ic_vector(3 downto 0);begin process(CR,CLK,EN) begin if CR=0 then couL=0000; couH=0000; elsif clkevent and clk=1 then if EN=1 then if( couL=0 and couH=0)then couL=0100; couH=0100; elsif couL=0 then couL=1001; couH=couH-1; else couL=couL-1; end if; end if; end if; end process; process(couL,couH) begi
7、n if(couL=0 and couH=0)then OC=1; else OC=0; end if; end process; QL=couL; QH=couH;end behav; control模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity control is port( clk,hold: in std_logic; ared,agreen,ayellow,bred,bgreen,byellow : out std_logic);end control;archit
8、ecture behavior of control is type state_type is (s0,s1,s2,s3,s4); signal current_state,next_state : state_type; signal counter : std_logic_vector(6 downto 0); beginsynch : processbegin wait until clkevent and clk = 1; if hold=0 then counter=counter; else if counter=89 then counter=counter+1; else c
9、ounter0); end if; end if;end process; processbegin wait until clkevent and clk=1; current_state if hold=0 then next_state=s4; else if counter39 then next_state=s0; else next_state if hold=0 then next_state=s4; else if counter44 then next_state= s1; else next_state if hold=0 then next_state=s4; else
10、if counter84 then next_state= s2; else next_state if hold=0 then next_state= s4; else if counter89 then next_state=s3; else next_state if hold=0 then next_state=s4; else if counter39 then next_state=s0; elsif counter44 then next_state=s1; elsif counter84 then next_state=s2; elsif counter89 then next
11、_state ared=0; agreen=1; ayellow=0; bred=1; bgreen=0; byellow ared=0; agreen=0; ayellow=1; bred=1; bgreen=0; byellow ared=1; agreen=0; ayellow=0; bred=0; bgreen=1; byellow ared=1; agreen=0; ayellow=0; bred=0; bgreen=0; byellow ared=1; agreen=0; ayellow=0; bred=1; bgreen=0; byellowtmptmptmptmptmptmpt
12、mptmptmptmptmptmptmptmptmptmpnull; end case; end process; a=tmp(6); b=tmp(5); c=tmp(4); d=tmp(3); e=tmp(2); f=tmp(1); g=tmp(0);end arc; 顶层文件: 五、 遇到的问题和解决的方案在此次试验中遇到的问题是,实际按照书上的写好程序后,波形也仿真真确,但是烧到板子的时候没有结果。最后发现问题出在管脚没有绑定,绑定管脚之后还是没有结果,经分析,发现分频分的太小了,而且理论上的七字段译码器与实际还不一样,最后按照PPT上的改过来之后,结果仿真出来了,但交通灯只有南北方向而没有东西方向,对顶层文件扩充之后,烧到板子结果完全真确。六、 实验结果波形仿真图:七、 对该课程的意见对该课程的一点小小的意见是:希望老师上课多给我们讲一些东西,不要老是叫一些同学上去做题,这样不仅浪费时间而且对我们帮助不大。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1