1、 数字电路设计报告数字电路设计报告 课题名称:汽车尾灯控制设计方案汽车尾灯控制设计方案 一、实验任务一、实验任务 用 6 个发光二极管模拟 6 个汽车尾灯(汽车尾部左、右各 3 个) ,用两个开关作为转弯 控制信号(一个开关控制又转弯,另一个开关控制左转弯) 。 要求:当汽车往前行使时(此时两个开关都未接通) ,6 个灯全灭。当汽车转弯时,若 右转弯(即右转开关接通) ,右边 3 个尾灯从左至右顺序亮灭,左边 3 个灯全灭;若左转弯 (即左转开关接通) ,左边 3 个尾灯从右至左顺序亮灭,右边 3 个灯全灭。当左、右两个开 关同时接通时,6 个尾灯同时明、暗闪烁。 总体框图如图所示: 二、模块
2、及模块功能二、模块及模块功能 A、模块模块 MAGIC(见电路图)(见电路图) 。 此模块为整个程序的控制模块。当左转时,LFT 信号有效;右转时,RIT 信号有效; 当左右信号都有效时,LR 信号有效。 library ieee; use ieee.std_logic_1164.all; entity magic is port(left,right:in std_logic; lft , rit ,lr: out std_logic); end magic; architecture magic_arc of magic is bigin process (left ,right ) va
3、riable a:std_logic_vector(1 downto 0); begin a: =left case a is when “00“=lft=0; rit=0; lrlft=1; rit=0; lrrit=1; lft=0; lrrit=1; lft=1; lr=1; end case ; end process; end magic_arc; B模块模块 RIGHT(见见电路电路图图) 。 此模块的功能是当左转时控制左边的 3 个灯,当左右转信号都有效时,输出全 为“1” 。 library ieee; use ieee.std_logic_1164.all; entity r
4、ight is port (en, clk,lr: in std_logic ; r2,r1, ro: out std_logic); end right; architecture right_arc of right is begin process (clk , en , lr) variable tmp : std_logic_vector(2 doento 0); begin if lr=1 then tmp :=“111“; elsif en=0 then tmp :=“000“; elsif clkevent and clk =1 then if tmp=“000“ then tmp:=“100“; else tmp:=0 end if; end if; r2=tmp(2); r1=tmp(1); ro=tmp(0); end process; end right_arc C、模块模块 LEFT(见见电路电路图图) 。 此模块的功能是控制右边的 3 个灯,与模块 LEFT 类似