文档详情

实验十汽车尾灯的控制电路.docx

发布:2017-04-18约2.41千字共6页下载文档
文本预览下载声明
实验十 汽车尾灯的控制电路 实验目的 通过用VHDL语言设计汽车尾灯控制电路,掌握用VHDL语言设计实际电路,解决用户的各种需求。 实验原理 采用模块化设计,各模块单独进行编辑、编译、仿真。编译、仿真正确后将各个模块进行封装,然后,新建原理图文件,将各模块的封装图调出来并进行连接(用细线连接信号,用粗线连接位矢量信号)。最后进行编译、仿真及 管脚的分配(用户自定义方式或自动分配方式)。 实验内容 用6个发光二极管模拟6个汽车尾灯(汽车尾部左、右3个),用2个开关作为转弯控制信号(1个开关控制右转弯,另1个开关控制左转弯)。 源程序清单 library ieee; use ieee.std_logic_1164.all; entity kong is port(left,right:in std_logic; lft,rit,lr:out std_logic); end kong; architecture wei of kong is begin process (left,right) variable a:std_logic_vector(1 downto 0); begin a:=leftright; case a is when00 = lft=0; rit=0; lr=0; when01 = lft=0; rit=1; lr=0; when10 = lft=1; rit=0; lr=0; when others = lft=1; rit=1; lr=1; end case; end process; end wei; 控制模块的波形仿真图如下图 封装图 LEFT LET RIGHT RIG LR Lfta模块 模块lfta的功能是当左转时控制左边的3个灯,当左右转信号都有效时,输出全为‘1’。 library ieee; use ieee.std_logic_1164.all; entity lfta is port (en,clk,lr:in std_logic; l2,l1,l0:out std_logic); end lfta; architecture wei of lfta is begin process(clk,en,lr) variable tmp: std_logic_vector(2 downto 0); begin if lr=1then tmp:=111; elsif en=0then tmp:=000; elsif clkevent and clk=1then if tmp=000 then tmp:=001; else tmp:=tmp(1 downto 0) 0; end if; end if; l2=tmp(2); l1=tmp(1); l0=tmp(0); end process; end wei; 模块lfta的波形仿真图如下图 模块lfta封装 EN L2 CLK L1 LR L0 Rita模块 模块rita的功能是控制右边的3个灯,与模块lfta类似。 library ieee; use ieee.std_logic_1164.all; entity rita is port(en,clk,lr:in std_logic; r2,r1,r0:out std_logic); end rita; architecture wei of rita is begin process (clk,en,lr) variable tmp:std_logic_vector(2 downto 0); begin if lr=1then tmp:=111; elsif en=0 then tmp:=000; elsif clkevent and clk=1then if tmp=000then tmp:=100; else tmp:=0tmp (2 downt
显示全部
相似文档