library ieee;

--library gold_lib;   --UNCOMMENT if you're using a GOLD model

use ieee.std_logic_1164.all;

--use gold_lib.all;   --UNCOMMENT if you're using a GOLD model



entity tb_divide is

end tb_divide;



architecture TEST of tb_divide is



  function INT_TO_STD_LOGIC( X: INTEGER; NumBits: INTEGER )

     return STD_LOGIC_VECTOR is

    variable RES : STD_LOGIC_VECTOR(NumBits-1 downto 0);

    variable tmp : INTEGER;

  begin

    tmp := X;

    for i in 0 to NumBits-1 loop

      if (tmp mod 2)=1 then

        res(i) := '1';

      else

        res(i) := '0';

      end if;

      tmp := tmp/2;

    end loop;

    return res;

  end;



  component divide

    PORT(

         X : in STD_LOGIC_VECTOR(31 downto 0);

         Y : in STD_LOGIC_VECTOR(31 downto 0);

         Z : out STD_LOGIC_VECTOR(31 downto 0);

         V : out STD_LOGIC

    );

  end component;



-- Insert signals Declarations here

  signal X : STD_LOGIC_VECTOR(31 downto 0);

  signal Y : STD_LOGIC_VECTOR(31 downto 0);

  signal Z : STD_LOGIC_VECTOR(31 downto 0);

  signal V : STD_LOGIC;



-- signal <name> : <type>;



begin

  DUT: divide port map(

                X => X,

                Y => Y,

                Z => Z,

                V => V

                );



--   GOLD: <GOLD_NAME> port map(<put mappings here>);



process



  begin



-- Insert TEST BENCH Code Here



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "00000000000000010000000000000000";

    Y <= "00000000000000001000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "00000000000000010000000000000000";

    Y <= "00000000000000000000000001000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "10101010101010101010101010101010";

    Y <= "01010101010101010101010101010101";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "00000000000001100000000000000000";

    Y <= "00000000000000110000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "01000000000000000000000000000000";

    Y <= "00000000000000001000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "00000000000010000000000000000000";

    Y <= "00000000000000110000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "11111111111111110000000000000000";

    Y <= "00000000000000001000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "11001100110011000000000000000000";

    Y <= "00000000000000001100110011001100";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "11001100110011000000000000000000";

    Y <= "00000000000000000000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "11001100110011000000000000000000";

    Y <= "00000000000000010000000000000000";

    wait for 10 ns;



--        AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB

    X <= "11001100110011000000000000000000";

    Y <= "00000000000000001100110011001100";

    wait for 10 ns;



  end process;

end TEST;

