library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.numeric_std.all;
entity CrossLED is
Port (
nRST: in std_logic; -- 系统复位控制信号,低电平有效。
--
-- 各信号下标3、2、1、0对应方向东、南、西、北。
-- 输出0,对应信号灯亮;输出1,对应信号灯灭。
--
State: in std_logic_vector(1 downto 0); --
Yellow: out std_logic_vector(3 downto 0);
Red: out std_logic_vector(3 downto 0);
Blue: out std_logic_vector(3 downto 0)
);
end CrossLED;
architecture Behavioral of CrossLED is
begin
Yellow <= "0000" when nRST = '0' else -- 复位状态东西南北黄灯亮。
"1111" when State = "00" else -- 东西两侧红灯亮,南北两侧绿灯亮。
"1010" when State = "01" else -- 东西两侧红灯亮,南北两侧黄灯亮(准备变红灯)。
"1111" when State = "10" else -- 东西两侧绿灯亮,南北两侧红灯亮。
"0101" when State = "11" else -- 东西两侧黄灯亮(准备变红灯),南北两侧红灯亮。
"0000";
Red <= "1111" when nRST = '0' else -- 复位状态东西南北黄灯亮。
"0101" when State = "00" else -- 东西两侧红灯亮,南北两侧绿灯亮。
"0101" when State = "01" else -- 东西两侧红灯亮,南北两侧黄灯亮(准备变红灯)。
"1010" when State = "10" else -- 东西两侧绿灯亮,南北两侧红灯亮。
"1010" when State = "11" else -- 东西两侧黄灯亮(准备变红灯),南北两侧红灯亮。
"1111";
Blue <= "1111" when nRST = '0' else -- 复位状态东西南北黄灯亮。
"1010" when State = "00" else -- 东西两侧红灯亮,南北两侧绿灯亮。
"1111" when State = "01" else -- 东西两侧红灯亮,南北两侧黄灯亮(准备变红灯)。
"0101" when State = "10" else -- 东西两侧绿灯亮,南北两侧红灯亮。
"1111" when State = "11" else -- 东西两侧黄灯亮(准备变红灯),南北两侧红灯亮。
"1111";
end Behavioral;