계층 구조 설계.
모듈에서 다른 모듈을 불러와서 선언하는 두 가지 방법을 익히겠습니다. (사실 두가지 방법인데 이론은 똑같습니다. component가 더 편한 것 같네요)

도면은 그대로 사용
inner mux를 하나 만들어준다. 이전에 만들어둔 먹스를 사용합니다.
(예전 베릴로그 공부할때는 몰랐는데, 기존 파일을 가져와도 복사후에 프로젝트 폴더에 복사되는게 아니더라고요. vhd파일을 다른 프로젝트에서 불러와서 수정하면 기존 파일이 수정되서,, 차라리 복사 후 새로 add source한 후 붙여넣기 하겠습니다.)
inner_mux의 dut
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity inner_mux is
Port ( X : in std_logic_vector(1 downto 0);
S : in std_logic;
Y : out std_logic );
end inner_mux;
architecture Behavioral of inner_mux is
begin
y <= X(1) when s = '1' else
X(0) when s = '0' else
'0';
end Behavioral;
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
signal F : std_logic_vector( 1 downto 0 );
begin
mux1 : entity work.inner_mux port map
(X(0) => X(0) , X(1) => X(1), S => S(0), Y => F(0));
mux2 : entity work.inner_mux port map
(X(0) => X(2) , X(1) => X(3), S => S(1), Y => F(1));
mux3 : entity work.inner_mux port map
(X(0) => F(0) , X(1) => F(1), S => S(2), Y => Y);
end Behavioral;
testbench (기존 그대로 사용)
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
DUT : 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;
output
