信息工程专业2009级《可编程逻辑器件及应用》课程设计实践报告设计题目交通灯控制器设计专业班级_______信息工程091_________学号_______2009018295______________姓名___________________完成时间_______20120528_____________《可编程逻辑器件及应用》课程设计实践报告1.设计题目交通灯控制器的设计2.设计要求利用VHDL语言和原理图混合的方法设计一个设计一个由一条主干道和一条支干道的汇合点形成的十字交叉路口的交通灯控制器,具体要求如下:(1)主、支干道各设有一个绿、黄、红指示灯,两个显示数码管。(2)主干道处于常允许通行状态,而支干道有车来才允许通行。(3)当主、支道均有车时,两者交替允许通行,主干道每次放行45s,支干道每次放行25s,在每次由亮绿灯变成亮红灯的转换过程中,要亮5s的黄灯作为过渡,并进行减计时显示。3.设计方案根据交通灯控制器功能设计要求,本系统可由以下6个模块组成:45S计时模块CNT45S;25S计时模块CNT25S;05S计时模块CNT05S;交通灯控制模块JTDKZ;显示子模块XSKZ;译码器模块YMQ。4.具体实现(根据不同的方法进行描述,给出具体实现步骤,包括程序)1.在D盘建立七个文件夹,JTDKZ、CNT45S、CNT25S、CNT05S、XSKZ、YMQ、JTDKZQSJ。2.运行QuartusII软件,选择File..NewProjectWizard菜单建立一个新工程。工程名称及顶层文件名称为JTDKZ,器件设置对话框中选择EPM240T100C5芯片,完成新工程的建立。3.选择File..New菜单,创建VHDL描述语言设计文件,打开文本编辑器界面。4.选择File..SaveAs菜单,将创建的VHDL设计文件保存为JTDKZ.VHD。5.在文本编辑器界面中编写VHDL程序,代码如下:--JTDKZ.VHDLIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYJTDKZISPORT(CLK,SM,SB:INSTD_LOGIC;MR,MY,MG,BR,BY,BG:OUTSTD_LOGIC);ENDENTITYJTDKZ;ARCHITECTUREARTOFJTDKZISTYPESTATE_TYPEIS(A,B,C,D);SIGNALSTATE:STATE_TYPE;BEGINCNT:PROCESS(CLK)ISVARIABLES:INTEGERRANGE0TO45;VARIABLECLR,EN:BIT;BEGINIF(CLK'EVENTANDCLK='1')THENIFCLR='0'THENS:=0;ELSIFEN='0'THENS:=S;ELSES:=S+1;ENDIF;CASESTATEISWHENA=MR='0';MY='0';MG='1';BR='1';BY='0';BG='0';IF(SBANDSM)='1'THENIFS=45THENSTATE=B;CLR:='0';EN:='0';ELSESTATE=A;CLR:='1';EN:='1';ENDIF;ELSIF(SBAND(NOTSM))='1'THENSTATE=B;CLR:='0';EN:='0';ELSESTATE=A;CLR:='1';EN:='1';ENDIF;WHENB=MR='0';MY='1';MG='0';BR='1';BY='0';BG='0';IFS=5THENSTATE=C;CLR:='0';EN:='0';ELSESTATE=B;CLR:='1';EN:='1';ENDIF;WHENC=MR='1';MY='0';MG='0';BR='0';BY='0';BG='1';IF(SMANDSB)='1'THENIFS=25THENSTATE=D;CLR:='0';EN:='0';ELSESTATE=C;CLR:='1';EN:='1';ENDIF;ELSIFSB='0'THENSTATE=D;CLR:='0';EN:='0';ELSESTATE=C;CLR:='1';EN:='1';ENDIF;WHEND=MR='1';MY='0';MG='0';BR='0';BY='1';BG='0';IFS=5THENSTATE=A;CLR:='0';EN:='0';ELSESTATE=D;CLR:='1';EN:='1';ENDIF;ENDCASE;ENDIF;ENDPROCESSCNT;ENDARCHITECTUREART;6.选择Tools..CompilerTool菜单,编译JTDKZ.VHD源文件。(可选项:编译无误后建立仿真波形文件JTDKZ.VWF。选择Tools..SimulatorTool菜单进行仿真)。选择File..Create/Update..CreateSymbolFileforCurrentFile菜单,为当前工程生成一个符号文件JTDKZ.BSF文件。选择File..CloseProject菜单关闭工程JTDKZ。重复上面的过程,建立CNT45S,最后为当前工程生成一个符号文件CNT45S.BSF文件。--CNT45S.VHDLIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCNT45SISPORT(SB,CLK,EN45:INSTD_LOGIC;DOUT45M,DOUT45B:OUTSTD_LOGIC_VECTOR(7DOWNTO0));ENDENTITYCNT45S;ARCHITECTUREARTOFCNT45SISSIGNALCNT6B:STD_LOGIC_VECTOR(5DOWNTO0);BEGINPROCESS(SB,CLK,EN45)ISBEGINIFSB='0'THENCNT6B=CNT6B-CNT6B-1;ELSIF(CLK'EVENTANDCLK='1')THENIFEN45='1'THENCNT6B=CNT6B+1;ELSIFEN45='0'THENCNT6B=CNT6B-CNT6B-1;ENDIF;ENDIF;ENDPROCESS;PROCESS(CNT6B)ISBEGINCASECNT6BISWHEN000000=DOUT45M=01000101;DOUT45B=01010000;WHEN000001=DOUT45M=01000100;DOUT45B=01001001;WHEN000010=DOUT45M=01000011;DOUT45B=01001000;WHEN000011=DOUT45M=01000010;DOUT45B=01000111;WHEN000100=DOUT45M=01000001;DOUT45B=01000110;WHEN000101=DOUT45M=01000000;DOUT45B=01000101;WHEN000110=DOUT45M=00111001;DOUT45B=01000100;WHEN000111=DOUT45M=00111000;DOUT45B=01000011;WHEN001000=DOUT45M=00110111;DOUT45B=01000010;WHEN001001=DOUT45M=00110110;DOUT45B=01000001;WHEN001010=DOUT45M=00110101;DOUT45B=01000000;WHEN001011=DOUT45M=00110100;DOUT45B=01101001;WHEN001100=DOUT45M=00110011;DOUT45B=00111000;WHEN001101=DOUT45M=00110010;DOUT45B=00110111;WHEN001110=DOUT45M=00110001;DOUT45B=00110110;WHEN001111=DOUT45M=00110000;DOUT45B=00110101;WHEN010000=DOUT45M=00101001;DOUT45B=00110100;WHEN010001=DOUT45M=00101000;DOUT45B=00110011;WHEN010010=DOUT45M=00100111;DOUT45B=00110010;WHEN010011=DOUT45M=00100110;DOUT45B=00110001;WHEN010100=DOUT45M=00100101;DOUT45B=00110000;WHEN010101=DOUT45M=00100100;DOUT45B=00101001;WHEN010110=DOUT45M=00100011;DOUT45B=00101000;WHEN010111=DOUT45M=00100010;DOUT45B=00100111;WHEN011000=DOUT45M=00100001;DOUT45B=00100110;WHEN011001=DOUT45M=00100000;DOUT45B=00100101;WHEN011010=DOUT45M=00011001;DOUT45B=00100100;WHEN011011=DOUT45M=00011000;DOUT45B=00100011;WHEN011100=DOUT45M=00010111;DOUT45B=00100010;WHEN011101=DOUT45M=00010110;DOUT45B=00100001;WHEN011110=DOUT45M=00010101;DOUT45B=00100000;WHEN011111=DOUT45M=00010100;DOUT45B=00011001;WHEN100000=DOUT45M=00010011;DOUT45B=00011000;WHEN100001=DOUT45M=00010010;DOUT45B=00010111;WHEN100010=DOUT45M=00010001;DOUT45B=00010110;WHEN100011=DOUT45M=00010000;DOUT45B=00010101;WHEN100100=DOUT45M=00001001;DOUT45B=00010100;WHEN100101=DOUT45M=00001000;DOUT45B=00010011;WHEN100110=DOUT45M=00000111;DOUT45B=00010010;WHEN100111=DOUT45M=00000110;DOUT45B=00010001;WHEN101000=DOUT45M=00000101;DOUT45B=00010000;WHEN101001=DOUT45M=00000100;DOUT45B=00001001;WHEN101010=DOUT45M=00000011;DOUT45B=00001000;WHEN101011=DOUT45M=00000010;DOUT45B=00000111;WHEN101100=DOUT45M=00000001;DOUT45B=00000110;WHENOTHERS=DOUT45M=00000000;DOUT45B=00000000;ENDCASE;ENDPROCESS;ENDARCHITECTUREART;重复上面的过程,建立CNT25S,最后为当前工程生成一个符号文件CNT25S.BSF文件。--CNT25S.VHDLIBRARYIEEE;USEIEEE