⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 back_light.vhd

📁 1 前大灯可以随意打开和关闭; 2 当汽车左转弯的时候
💻 VHD
字号:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

ENTITY back_light IS
  PORT(
       clk            : IN STD_LOGIC;
       lights_control : IN STD_LOGIC_VECTOR( 2 DOWNTO 0);
       lights         : OUT STD_LOGIC_VECTOR( 2 DOWNTO 0)
      );
end back_light;
 
ARCHITECTURE arch_back_light OF back_light IS
TYPE  state1 IS(s0,s1,s2,s3);
TYPE  state2 IS(t0,t1);
SIGNAL presentstate1 : state1;
SIGNAL presentstate2 : state2;

BEGIN
  PROCESS( clk, presentstate1  )
   BEGIN
    if(clk'event and clk = '1') then
    if( lights_control  = "000") THEN
      lights <= "000";
    
    elsif( lights_control = "001") THEN
      case presentstate1 IS
        WHEN s0 =>
           lights <= "001";
           presentstate1 <= s1;
        WHEN s1 =>
           lights <= "011";
           presentstate1 <= s2;
        WHEN s2 =>
           lights <= "111";
           presentstate1 <= s3;
        WHEN s3 =>
           lights <= "000";
           presentstate1 <= s0;
     end case;
     
     elsif( lights_control  = "010") THEN
       case presentstate2 IS
         WHEN t0 =>
             lights <= "000";
             presentstate2 <= t1;
         WHEN t1 =>
             lights <= "111";
             presentstate2 <= t0;
        end case;
    
    elsif( lights_control = "100" ) THEN
      lights <= "111";
    end if;
 end if;
  END process;
end arch_back_light;    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -