MUX 2-1 Behavioral
MUX 2-1 Behavioral
-Design
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux is
Port ( x : in STD_LOGIC;
y : in STD_LOGIC;
s : in STD_LOGIC;
m : out STD_LOGIC);
end mux;
begin
process (x,y,m)
begin
if (s='0') then
m<=x;
m<=y;
end if;
end process;
end Behavioral;
-testbench
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Design Name:
-- Target Device:
-- Tool versions:
-- Description:
--
--
-- Dependencies:
--
-- Revision:
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
--USE ieee.numeric_std.ALL;
ENTITY mux_band IS
END mux_band;
COMPONENT mux
PORT(
x : IN std_logic;
y : IN std_logic;
sel : IN std_logic;
z : OUT std_logic
);
END COMPONENT;
--Inputs
signal z : std_logic;
BEGIN
x => x,
y => y,
z => z
);
-- Stimulus process
stim_proc: process
begin
x <= '1';
y <= '0';
x <= '0';
y <= '1';
wait;
end process;
END;
x y s z
0 1 0 0
0 1 0 1