1、 汽车尾灯汽车尾灯控制电路设计控制电路设计 班级:班级: 学号:学号: 姓名:姓名: 指导教师:指导教师: 一、 总体设计要求及系统功能描述 设计一个汽车尾灯控制的电路; 1) 用 6 个发光二极管模拟 6 个汽车尾灯(左、右各 3 个, 高电平点亮) ,用 2 个开关作为左转弯、右转弯控制信 号(高电平有效) 。 2) 当汽车往前行驶时,6 个灯全灭; 3) 汽车左转时,左边三个灯顺序点亮,右边灯则全不亮; 反之,右转时,情况相反; 4) 踩刹车时,汽车灯全亮; 5) 紧急情况时,左边灯和右边灯都亮,但是都是闪烁状 态。 二、 系统设计方案论述 1) 端口 数据类型 功能 备注 CLK ST
2、D_LOGIC 时钟信号 输入 zuo STD_LOGIC 左转向信 号 输入 you STD_LOGIC 右转向信 号 输入 sha STD_LOGIC 刹车信号 输入 en STD_LOGIC 双闪信号 输入 z_out STD_LOGIC_VECTOR(2 左灯输出 输出 downto 0) y_out STD_LOGIC_VECTOR(2 downto 0) 右灯输出 输出 2) 顶层电路图 3)设计源程序说明: library ieee; use ieee.std_logic_1164.all; entity weideng is port(zuo,you,clk,en:in std
3、_logic; z_out:out std_logic_vector(2 downto 0); y_out:out std_logic_vector(2 downto 0) ); end weideng; architecture qiche of weideng is signal zo,yu,sha:std_logic; begin process(zuo,you) variable a:std_logic_vector(1 downto 0); -定义刹车(sha)信号- begin a:=zuo case a is when “00“=zo=0; yu=0; shazo=1; yu=0
4、; shayu=1; zo=0; shayu=1; zo=1; sha=1;-只有左右都是 1, 才是刹车 信号 end case; end process; -左边三个灯- process(clk,en,sha,zuo,) variable tmp:std_logic_vector(2 downto 0); begin if sha=1 then tmp:=“111“;-若输入刹车信号,三个灯全亮 elsif clkevent and clk=1 then if en=1 then if tmp =“000“ then tmp:=“111“; else tmp:=“000“;-若输入紧急 (
5、en) 信号, 灯双闪 end if; elsif zuo=0and you =0 then tmp:=“000“;-若左右输入信号为 0 时,灯 全不亮 elsif zuo=1 then if tmp=“000“ then tmp:=“001“;-若输入左转信号,三个灯 顺序点亮 else tmp:=tmp(1 downto 0) end if; end if; end if; z_out=tmp; end process; -右边三个灯- process(clk,en,sha,you) variable tmp:std_logic_vector(2 downto 0); begin if sha=1 then tmp:=“111“; elsif clkevent and clk=1 then if en=1 then if tmp=“000“then tmp:=“111“; else tmp:=“000“; end if; elsif zuo=0 and you=0 then tmp:=“000“; elsif you=1 then if tmp=“000“ then tmp:=“100“; else tmp:=0 end if; end if; end if; y_out=tmp; end process; end qiche; 4)仿真图说明 在 en(紧急情况)