资源描述:
《汽车尾灯设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
汽车尾灯设计VHDL§言--EDA课程设计(2009-06-0317:30:10)元件列化部分Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_unsigned.all;EntitytpisPort(clk:instd_logic;Left:instd_logic;Right:instd_logic;Brake:instd_logic;Night:instd_logic;Ld1,ld2,ld3:outstd_logic;Rd1,rd2,rd3:outstd_logic);End;ArchitecturebhoftpisSignaltmp0,tmp1,tmp2,tmp3,tmp4:std_logic;Signalerr0,err1,err2,err3,err4,err5:std_logic;signalbm:std_logic;BeginComponentszisPort(clk:instd_logic;
1Cp:outstd_logic);Endcomponent;ComponentctrlisPort(left,right,brake,night:instd_logic;Lp,rp,lr,brake_led,night_led:outstd_logic);Endcomponent;ComponentlcisPort(clk,lp,lr,brake,night:instd_logic;Ledl,ledb,ledn:outstd_logic);Endcomponent;ComponentrcisPort(clk,rp,lr,brake,night:instd_logic;Ledr,ledb,ledn:outstd_logic);Endcomponent;U1:szportmap(clk,bm);U2:ctrlportmap(left,right,brake,night,tmp0,tmp1,tmp2,tmp3,tmp4);U3:lcportmap(clk,tmp0,tmp2,tmp3,tmp4,err0,err1,err2);U4:rcportmap(clk,tmp1,tmp2,tmp3,tmp4,err3,err4,err5);Ld1<=err0andbm;Ld2<=err1;Ld3<=err2;Rd1<=err3andbm;Rd2<=err4;
2Rd3<=err5;End;汽车尾灯主控制模块CTRL:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYCTRLISPORT(LEFT,RIGHT,BRAKE,NIGHT:INSTD_LOGIC;LP,RP,LR,BRAKE_LED,NIGHT_LED:OUTSTD_LOGIC);ENDENTITYCTRL;ARCHITECTUREARTOFCTRLISBEGINNIGHT_LED<=NIGHT;BRAKE_LED<=BRAKE;PROCESS(LEFT,RIGHT)VARIABLETEMP:STD_LOGIC_VECTOR(1DOWNTO0);BEGINTEMP:=LEFT&RIGHT;CASETEMPISWHEN"00"=>LP<='0';RP<='0';LR<='0';WHEN"01"=>LP<='0';RP<='1';LR<='0';WHEN"10"=>LP<='1';RP<='0';LR<='0';
3输出错WHENOTHERS=>LP<='0';RP<='0';LR<='1';误控制信号ENDCASE;ENDPROCESS;ENDARCHITECTUREART;时钟分频模块SZ:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYSZISPORT(CLK:INSTD_LOGIC;--时钟输入CP:OUTSTD_LOGIC);ENDENTITYSZ;ARCHITECTUREARTOFSZISSIGNALCOUNT:STD_LOGIC_VECTORD(7OWNTO0);--定义八位标准逻辑位矢量数据类型BEGINPROCESS(CLK)BEGINIFCLK'EVENTANDCLK='1'THEN检测时钟上升沿
4COUNT<=COUNT+1;ENDIF;ENDPROCESS;CP<=COUNT(3);--输出第五位ENDARCHITECTUREART;右边尾灯控制模块RC:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYRCISPORT(CLK,RP,LR,BRAKE,NIGHT:INSTD_LOGIC;LEDR,LEDB,LEDN:OUTSTD_LOGIC);ENDENTITYRC;ARCHITECTUREARTOFRCISBEGINLEDB<=BRAKE;LEDN<=NIGHT;PROCESS(CLK,RP,LR)BEGINIFCLK'EVENTANDCLK='1'THEN--检测时钟上升沿IF(RP='0')THEN
5LEDR<='0';ELSELEDR<='1';ENDIF;ELSELEDR<='0';ENDIF;ENDIF;ENDPROCESS;ENDARCHITECTUREART;左边尾灯控制模块LC:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYLCISPORT(CLK,LP,LR,BRAKE,NIGHT:INSTD_LOGIC;LEDL,LEDB,LEDN:OUTSTD_LOGIC);ENDENTITYLC;ARCHITECTUREARTOFLCISBEGINLEDB<=BRAKE;LEDN<=NIGHT;PROCESS(CLK,LP,LR)BEGIN
6IFCLK'EVENTANDCLK='1'THEN检测时钟上升沿IF(LR='0')THENIF(LP='0')THENLEDL<='0';ELSELEDL<='1';ENDIF;ELSELEDL<='0';ENDIF;ENDIF;ENDPROCESS;ENDARCHITECTUREART;