교재에 있는 멀티먹스를 다양한 형태로 만들어 보려고 합니다.

MultiMux.jpg

좀 더 익숙해지기 위해 배열로 선언해 봤습니다.

DUT

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity multimux is
    Port ( X : in std_logic_vector( 3 downto 0);
        S : in std_logic_vector( 2 downto 0);
        Y : out std_logic );
        
end multimux;

architecture Behavioral of multimux is

signal F : std_logic_vector( 1 downto 0 );

begin

process1 : process(X(0), X(1), S(0))
begin
    if S(0) = '0' then
        F(0) <= X(0);
    else
        F(0) <= X(1);
    end if;        
    
end process;

process2 : process(X(2), X(3), S(1))
begin
    if S(1) = '0' then
        F(1) <= X(2);
    else
        F(1) <= X(3);
    end if;        
    
end process;

process3 : process(F(0), F(1), S(2))
begin
    if S(2) = '0' then
        Y <= F(0);
    else
        Y <= F(1);
    end if;        
    
end process;

end Behavioral;

테스트벤치

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity tb_multimux is
end tb_multimux;

architecture Behavioral of tb_multimux is
    signal input : std_logic_vector(3 downto 0);
    signal sel : std_logic_vector(2 downto 0);
    signal output : std_logic;

begin
UUT : entity work.multimux port map
(x => input, y => output, s => sel);

process
    begin
    input <= "0101";
    
    sel <= "000";
    wait for 10ns;
    
    sel <= "001";
    wait for 10ns;
    
    sel <= "010";
    wait for 10ns;
    
    sel <= "011";
    wait for 10ns;    

    sel <= "100";
    wait for 10ns;
    
    sel <= "101";
    wait for 10ns;
    
    sel <= "110";
    wait for 10ns;
    
    sel <= "111";
    wait for 10ns;
    
    report "종료" severity failure;
end process;

end Behavioral;

예상 LUT

image.png

waveform

image.png

실제 output이 lut와 같게 나온 것을 확인할 수 있습니다.