Testbench For OR Gate
Testbench For OR Gate
library IEEE;
use IEEE.std_logic_1164.all;
entity testbench is
-- empty
end testbench;
architecture tb of testbench is
-- DUT component
component ALU_74381IC is
Port (
-- 4-bit A, B, F0 - F3 Inputs
A, B : in STD_LOGIC_VECTOR(3 downto 0);
F : in STD_LOGIC_VECTOR(2 downto 0);
-- 4-bit Y Output
Y : out STD_LOGIC_VECTOR (3 downto 0);
C : out STD_LOGIC
);
end component;
signal c_out: std_logic;
signal a_in, b_in, q_out: std_logic_vector(3 downto 0);
signal f_in: std_logic_vector(2 downto 0);
begin
-- Connect DUT
DUT: ALU_74381IC port map(a_in, b_in, f_in, q_out, c_out);
process
begin
a_in <= "1000";
b_in <= "1001";
f_in <= "100";
wait for 1 ns;
assert(q_out="0001" and c_out='0') report "Test 0" severity error;
a_in <= "1000";
b_in <= "1001";
f_in <= "011";
wait for 1 ns;
assert(q_out="0001" and c_out='1') report "Test 1" severity error;
a_in <= "1000";
b_in <= "1001";
f_in <= "110";
wait for 1 ns;
assert(q_out="1000" and c_out='0') report "Test 2" severity error;
a_in <= "1000";
b_in <= "1001";
f_in <= "111";
wait for 1 ns;
assert(q_out="1111" and c_out='0') report "Test 3" severity error;
a_in <= "0000";
b_in <= "1111";
f_in <= "100";
wait for 1 ns;
assert(q_out="1111" and c_out='0') report "Test 4" severity error;
a_in <= "1111";
b_in <= "1111";
f_in <= "011";
wait for 1 ns;
assert(q_out="1110" and c_out='1') report "Test 5" severity error;
a_in <= "0101";
b_in <= "1001";
f_in <= "010";
wait for 1 ns;
assert(q_out="1100" and c_out='0') report "Test 6" severity error;
a_in <= "0101";
b_in <= "1001";
f_in <= "001";
wait for 1 ns;
assert(q_out="0100" and c_out='0') report "Test 7" severity error;
a_in <= "0101";
b_in <= "1001";
f_in <= "101";
wait for 1 ns;
assert(q_out="1101" and c_out='0') report "Test 8" severity error;
a_in <= "0101";
b_in <= "1001";
f_in <= "000";
wait for 1 ns;
assert(q_out="0000" and c_out='0') report "Test 9" severity error;
a_in <= "0110";
b_in <= "1010";
f_in <= "011";
wait for 1 ns;
assert(q_out="0000" and c_out='1') report "Test 10" severity error;
-- Clear inputs
a_in <= "0000";
b_in <= "0000";
f_in <= "000";
library ieee;
use ieee.std_logic_1164.all;
Entity alu is
Generic(N:natural);
);
End alu;
Begin
process(A,B)
Begin
else O<='1'(:=others);
End if;
End process;
End alu1;
library IEEE;
use IEEE.std_logic_1164.all;
ENTITY ALU_74381IC IS
PORT (
C : out STD_LOGIC
);
END ALU_74381IC ;
BEGIN
PROCESS ( F, A, B )
BEGIN F IS
Y <= "1111" ;
END CASE ;
END PROCESS ;
END rtl ;