8to1 Mux Using 4to1 Mux
8to1 Mux Using 4to1 Mux
VHDL Lab
Code:
VHDL (MUX)
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 10:20:07 11/02/2020
-- Design Name:
-- Module Name: mux - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
port(
A: in std_logic_vector(7 downto 0);
S: in std_logic_vector(2 downto 0);
Z: out STD_LOGIC
);
end mux;
begin
m1: mux4 port map(A(3 downto 0),S(1 downto 0),m(0));
m2: mux4 port map(A(7 downto 4),S(1 downto 0),m(1));
m3: mux2 port map(m,S(2),Z);
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux4 is
port(
end process;
end bhv;
entity mux2 is
port(A: in std_logic_vector(1 downto 0);
S: in STD_LOGIC;
Z: out STD_LOGIC);
end mux2;
begin
process (A,S) is
begin
if (S ='0') then
Z <= A(0);
else
Z <= A(1);
end if;
end process;
end Behavioral;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_mux IS
END tb_mux;
COMPONENT mux
PORT(
A : IN std_logic_vector(7 downto 0);
S : IN std_logic_vector(2 downto 0);
Z : OUT std_logic
);
END COMPONENT;
BEGIN
uut: mux PORT MAP (
A => A,
S => S,
Z => Z
);
-- Stimulus process
stim_proc: process
begin
-- wait for 100 ns;
A<="10101010";
S<="000";
wait for 100 ns;
S<="001";
wait for 100 ns;
S<="010";
wait for 100 ns;
S<="011";
wait for 100 ns;
A<="11110000";
S<="000";
wait for 100 ns;
S<="001";
wait for 100 ns;
S<="010";
wait for 100 ns;
S<="011";
wait for 100 ns;
A<="00001111";
S<="000";
wait for 100 ns;
S<="001";
wait for 100 ns;
S<="010";
wait for 100 ns;
S<="011";
wait;
end process;
END;
Waveform