LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY talu IS END talu; ARCHITECTURE one OF talu IS --declare and configure the mbalu here -- --Signals to hook up the alu SIGNAL a,b,res : std_logic_vector(7 downto 0); SIGNAL addsub,cin,arlo : std_logic; -- inputs SIGNAL csel : std_logic_vector(1 downto 0); -- input SIGNAL func : std_logic_vector(3 downto 0); -- input SIGNAL cout,n,z : std_logic; -- output signals SIGNAL err : std_logic; BEGIN -- instantiate the DUT - the mbalu --Generate the stimulus -- res and cout value is auto checked--DO N and V visually PROCESS BEGIN --initailize things a <= "00000000"; b<="00000000"; addsub<='1'; cin<='0'; csel<="00"; arlo<='0'; err <= '0'; func<="1000"; WAIT FOR 10 ns; --start with logic operations func<="1000"; -- AND function a <= "00000000"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "00000000") THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; --next a <= "11111111"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "00000000") THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; --next a <= "11111111"; b<="01010101"; WAIT FOR 5 ns; IF (res /= "01010101") THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; --next func<="1110"; -- OR function a <= "00000000"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "00000000") THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; --next a <= "11111111"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "11111111") THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; --next a <= "11111111"; b<="01010101"; WAIT FOR 5 ns; IF (res /= "11111111") THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; --START ARITH -- a+b+cin where cin=0 arlo<='1'; cin<='0'; csel<="00"; addsub<='1'; a <= "11111111"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "11111111") THEN err<='1'; END IF; IF (cout /= '0')THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; -- a+b+1 arlo<='1'; cin<='0'; csel<="11"; addsub<='1'; a <= "11111111"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "00000000") THEN err<='1'; END IF; IF (cout /= '1')THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; -- a+b+cin where cin is 1 arlo<='1'; cin<='1'; csel<="00"; addsub<='1'; a <= "11111111"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "00000000") THEN err<='1'; END IF; IF (cout /= '1')THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; -- a-b with no carry in use arlo<='1'; cin<='0'; csel<="11"; addsub<='0'; a <= "11111111"; b<="00000000"; WAIT FOR 5 ns; IF (res /= "11111111") THEN err<='1'; END IF; IF (cout /= '1')THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; -- a+b-cin arlo<='1'; cin<='0'; csel<="01"; addsub<='1'; a <= "11110001"; b<="00000011"; WAIT FOR 5 ns; IF (res /= "11101110") THEN err<='1'; END IF; IF (cout /= '1')THEN err<='1'; END IF; WAIT FOR 1 ns; err<='0'; WAIT FOR 4 ns; -- You can add more tests if you like -- Note that N and Z are not tested for -- DO THAT VISUALLY WAIT FOR 20 ns; WAIT; END PROCESS; END one;