traffic_mux.vhd

来自「【经典设计】VHDL源代码下载~~ 其中经典的设计有:【自动售货机】、【电子钟」· VHDL 代码 · 共 40 行

VHD
40
字号
LIBRARY IEEE;   
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_unsigned.all;   
USE IEEE.std_logic_arith.all;
entity traffic_mux is
  port(reset: in std_logic;
       clk:in std_logic;
       ena_scan:in std_logic;
       recount:in std_logic; 
       sign_state: in std_logic_vector(1 downto 0);
       load: out std_logic_vector(7 downto 0));
end;   
--define the signal_structure and flow of the device
architecture BEHAVIOR of traffic_mux is
CONSTANT yellow0_time: integer := 5; 
CONSTANT green0_time: integer := 20;
CONSTANT yellow1_time: integer := 5;
CONSTANT green1_time : integer := 20; 
begin
  load_time:process(reset,clk)
  begin
     if reset='1' then
        load<="00000000"; 
     elsif (clk'event and clk='1') then
        if (ena_scan='1' and recount = '1') then
           CASE sign_state IS
            	WHEN "00" =>
                   load <= CONV_STD_LOGIC_VECTOR(green1_time,8);
        	    WHEN "01" =>
                   load <= CONV_STD_LOGIC_VECTOR(yellow0_time,8);
        	    WHEN "10" =>
                   load <= CONV_STD_LOGIC_VECTOR(green0_time,8);
        	    WHEN OTHERS =>
                   load <= CONV_STD_LOGIC_VECTOR(yellow1_time,8);
           END CASE;
        end if;
     end if;
  end process;
end BEHAVIOR;

⌨️ 快捷键说明

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