library ieee;
use ieee.std_logic_1164.all;

entity six_bit_segment is
    port (x : in std_logic_vector(3 downto 0);
          pins : out std_logic_vector(6 downto 0));
end entity;

architecture rtl of six_bit_segment is
begin
    pins(0) <= (not x(0) and not x(1) and x(2)) or (x(0) and not x(1) and not x(2) and not x(3));
    pins(1) <= (not x(0) and x(1) and x(2)) or (x(0) and not x(1) and x(2));
    pins(2) <= (not x(0) and x(1) and not x(2));
    pins(3) <= (not x(0) and not x(1) and x(2)) or (x(0) and not x(1) and not x(2) and not x(3)) or (x(0) and x(1) and x(2));
    pins(4) <= (not x(1) and x(2)) or x(0);
    pins(5) <= (x(1) and not x(2)) or (x(0) and not x(2) and not x(3)) or (x(0) and x(1));
    pins(6) <= (not x(1) and not x(2) and not x(3)) or (x(0) and x(1) and x(2));
end architecture;

library ieee;
use ieee.std_logic_1164.all;

use ieee.numeric_std.all;

entity six_bit_decimal is
    port (SW : in std_logic_vector(9 downto 0);
          HEX1, HEX0 : out std_logic_vector(6 downto 0));
end entity;

architecture rtl of six_bit_decimal is
    signal digits : std_logic_vector(7 downto 0);
begin
    convert : process(SW)
        variable value : unsigned(7 downto 0);
    begin
        value := (others => '0');
        -- Replace this raw nibble with six shift-and-correct stages.
        value(3 downto 0) := unsigned(SW(3 downto 0));
        digits <= std_logic_vector(value);
    end process;
    tens : entity work.six_bit_segment port map (digits(7 downto 4), HEX1);
    ones : entity work.six_bit_segment port map (digits(3 downto 0), HEX0);
end architecture;
