学海荡舟手机网
导航

主页 > 电子设备技术 > 电器电路基础 > > 详细内容

[VHDL实例]多路选择器(使用case语句)

-- Multiplexer 16-to-4 using if-then-elsif-else Statement  

use ieee.std_log_1164.all;

 

entity mux is port(

        a, b, c, d:     in std_logic_vector(3 downto 0);

        s:              in std_logic_vector(1 downto 0);

        x:              out std_logic_vector(3 downto 0));

end mux;

 

architecture archmux of mux is

begin

mux4_1: process (a, b, c, d)

        begin

                if s = "00" then

                        x <= a;

                elsif s = "01" then

                        x <= b;

                elsif s = "10" then

                        x <= c;

                else

                        x <= d;

                end if;

        end process mux4_1;

end archmux;

 


相关文章