library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity test_array is end entity;
architecture bench of test_array is
    type digits_t is array (0 to 15) of std_logic_vector(6 downto 0);
    constant digit : digits_t := ("1000000", "1111001", "0100100", "0110000", "0011001", "0010010", "0000010", "1111000",
        "0000000", "0010000", "0001000", "0000011", "1000110", "0100001", "0000110", "0001110");
    signal sw : std_logic_vector(9 downto 0);
    signal h5, h4, h3, h2, h1, h0 : std_logic_vector(6 downto 0);
begin
    dut : entity work.array_product port map (sw,h5,h4,h3,h2,h1,h0);
    process
        variable a,b,product : natural;
    begin
        for word in 0 to 1023 loop
            sw <= std_logic_vector(to_unsigned(word, 10));
            wait for 1 ns;
            a := (word / 16) mod 16; b := word mod 16; product := a*b;
            assert h5=digit(product/16) and h4=digit(product mod 16) and
                h3="1111111" and h2=digit(a) and h1="1111111" and h0=digit(b)
                report "FAIL A=" & integer'image(a) & " B=" & integer'image(b) severity failure;
        end loop;
        report "PASS 1024 switch words, every product and all six displays";
        wait;
    end process;
end architecture;
