function기능을 이용해서 multimux를 구현해 보겠습니다.

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
function Mux(x0 : in std_logic; x1 : in std_logic; s : in std_logic) return std_logic is
begin
if s = '0' then
return x0;
else
return x1;
end if;
end function;
signal F : std_logic_vector( 1 downto 0 );
begin
F(0) <= Mux(X(0), X(1), S(0));
F(1) <= Mux(X(2), X(3), S(1));
Y <= Mux(F(0), F(1), S(2));
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;
Waveform
