.
.
EDA综合设计报告
班级    11级 2班
日期    2013.12.5
.
设计题目  同组人 小组分工 上机编译、调试,再进行仿真。  1、东西、南北方向有红、黄、绿指示灯,两个显示数码管。 2、当南北方向允许通行亮绿灯时,东西方向亮红灯,而东西方向允许通行亮绿灯时,南北方向亮红灯。 3、工作顺序为东西方向红灯亮30秒,前25秒南北方向绿灯亮,后5秒黄灯亮。然后南北方向红灯亮30秒,前25秒东西方向绿灯亮,后5秒黄灯亮。依次循环。   EDA交通灯综合设计  班级  学号                  上网查阅资料,编写程序。 设计思路 1、首先打开Quartus2软件,新建一个工程,并新建一个VHDL File。 设计过程  2、按照自己的想法,编写VHDL程序。 程序如下: library ieee; .
.
use ieee.std_logic_11.all; use ieee.std_logic_unsigned.all; entity traffic IS   port (clk1k,SN:in std_logic;         led1, led2, led3, led4 :out std_logic_vector (3 downto 0); --显示管显示时间用 light:out std_logic_vector (5 downto 0));    --红绿黄灯 end traffic; architecture traffic1 of traffic IS signal S:std_logic_vector (1 downto 0);         --状态 signal DXT:std_logic_vector(7 downto 0):=X\"01\"; --东西方向时间 signal NBX:std_logic_vector(7 downto 0):=X\"01\";   --南北方向时间 signal ART,AGT,AYT,BRT,BGT,BYT: std_logic_vector(7 downto 0);--红绿黄灯信号 signal SL: std_logic; signal temp: integer range 0 to 1023; --产生1s计数器时计数  signal clk: std_logic;                                   begin                                          sL<='1';                                --红绿灯时间设.
.
定 ART<=\"00110000\"; AGT<=\"00100101\"; AYT<=\"00000101\"; BRT<=\"00110000\"; BGT<=\"00100101\"; BYT<=\"00000101\"; process(clk1k)                         -- 选频率为1024HZ begin  if (clk1k'event and clk1k='1') then  if temp=1023 then  temp<=0;  clk<='1';  else  temp<=temp+1;  clk<='0';  end if; end if;  end process;                                --进程结束 process(clk,DXT,NBX)                    --状态转换进程 begin .
.
if clk'event and clk ='1' then   if(DXT =\"00000001\")OR (NBX = \"00000001\")  then S<=S+1;       else S<=S; end if;                                   --状态转换结束 end if; end process; process (clk,SN,S)                       --倒计时模块 begin    if  SN = '1' then   DXT<=DXT; NBX<=NBX; else if clk'event and clk='1' then  if (DXT=\"0000000\") OR (NBX=\"00000000\") then  case S IS                  when \"00\"=>DXT<=ART;  NBX<=BYT;   -南北黄灯、东西红灯  when \"01\"=> NBX<=BGT;  DXT<=ART;  --南北绿灯、东西红灯  when \"10\"=>DXT<=AYT;  NBX<=BRT;  --南北红灯、东西黄灯  when \"11\"=>DXT<=AGT;  NBX<=BRT              --南北红灯、东西绿灯 .
.
when others=>NULL;  end case; end if; if DXT/=\"00000000\" then            if DXT(3 downto 0)= \"0000\" then    DXT(3 downto 0)<=\"1001\";   DXT(7 downto 4)<=DXT(7 downto 4)-1; else DXT(3 downto 0)<=DXT(3 downto 0)-1;      DXT(7 downto 4)<=DXT(7 downto 4); end if; end if; if NBX/=\"00000000\" then             if NBX(3 downto 0)=\"0000\" then     NBX(3 downto 0)<=\"1001\";    NBX(7 downto 4)<=NBX(7 downto 4)-1; else NBX(3 downto 0)<=NBX(3 downto 0)-1;      NBX(7 downto 4)<=NBX(7 downto 4); end if; end if; end if; end if; end process;      --倒计时模块结束 .
.
process(SL,DXT,NBX,S,SN)   --显示模块 begin  case SL IS       when '1'=>led1<=NBX(3 downto 0);   led2<=NBX(7 downto 4);   led3<=DXT(3 downto 0);   led4<=DXT(7 downto 4); when others=>NULL; end case; if SN ='1' then light<=\"001001\"; else  case S IS          when \"00\"=>light<=\"010001\";   when \"01\"=> light <=\"100001\";   when \"10\"=> light <=\"001010\";   when \"11\"=> light <=\"001100\"; when others=>NULL; end case; end if; end process; end traffic1; 3、对自己编写的VHDL程序进行编译并仿真。 .
.
4、仿真无误后,根据FPGA引脚进行管脚绑定,然后再重新编译一次。 引脚锁定:CLK      PIN_    SW4A               RST      PIN_91    SW1A               EN       PIN_90    SW2A               LOAD     PIN_88    SW3A               DOUT[0]  PIN_72    LED1               DOUT[1]  PIN_73    LED2               DOUT[2]  PIN_74    LED3               DOUT[3]  PIN_75    LED4               COUT     PIN_76    LED5               空闲     PIN_77    LED6  仿真波形如下:  编写程序时 遇到的问题及解决办法 问题: 1、实体名和工程名不一样 2、库函数缺少程序不正确 解决方法: .
.
1、在桌面建的工程名称改成和程序中实体名一样,保持一致。 2、将库函数添加进去,再进行编译、仿真。  通过这次课程设计,我进一步加深了对电子设计自动化的了解。并进一步熟练了对QuartusII软件的操作。 在编写程序的过程中,遇到了很多问题,使我发现自己以前学习上存在的不足。通过与同学探讨和请教老师,终于把问题都解决了,并加深了对交通灯原理和设计思路的了解。同时也掌握了做课程设计的一般流程,为以后的设计积累了一定的经验。做课程设计时,先查阅相关知识,把原理吃透,确定一个大的设计心得体会 方向,在按照这个方向分模块的把要实现的功能用流程图的形式展示。最后参照每个模块把输入和输出引脚设定,运用我们所学的VHDL语言进行编程。 总之,通过这次的设计,进一步了解了EDA技术,收获很大,对软件编程、排错调试、相关仪器设备的使用技能等方面得到较全面的锻炼和提高。
.