VHDL CODE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity xorgate is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
y : out STD_LOGIC
);
end xorgate;
architecture Behavioral of xorgate is
begin
y<= a xor b;
end Behavioral;
TEST BENCH
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY xorgate_tb IS
END xorgate_tb;
ARCHITECTURE behavior OF xorgate_tb IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT xorgate
PORT(
a : IN std_logic;
b : IN std_logic;
y : out std_logic);
END COMPONENT;
--Inputs
signal a : std_logic := '0';
signal b : std_logic := '0';
--Outputs
signal y : std_logic;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: xorgate PORT MAP (
a => a,
b => b,
y => y
);
-- Stimulus process
stim_proc: process
begin
a <= '0';
b <= '0';
wait for 100 ns;
a <= '1';
b <= '0';
wait for 100 ns;
a <= '0';
b <= '1';
wait for 100 ns;
a <= '1';
b <= '1';
wait for 100 ns;
wait;
end process;
END;