----------------------------------------------------------------- -- scancode_to_vector.vhd -- Christopher Kowalski -- -- Scan Code converter from a recieved Scan code value to an encoded -- bit Vector. -- -- Following the code is a table containing the Scan Code conversion. -- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity scancode_to_vector is port(scancode : in std_logic_vector(7 downto 0); reset, clock, transfer : in std_logic; done : out std_logic; vector : out std_logic_vector(3 downto 0)); end scancode_to_vector; architecture behavioural of scancode_to_vector is -- declare internal signals begin convert : process (clock) is -- process variable variable count:natural range 0 to 2; begin if rising_edge(clock) then if reset = '1' then vector <= (others => '0'); count := 0; done <= '0'; elsif transfer = '1' then -- a load signal if count = 2 then -- this gives the circuit time to have the done <= '1'; -- correct value at it's output else case scancode is when "01110111" => -- x77 NumLock vector <= "0000"; when "01101100" => -- x6C 7 vector <= "0001"; when "01110101" => -- x75 8 vector <= "0010"; when "01111101" => -- x7D 9 vector <= "0011"; when "01101011" => -- x6B 4 vector <= "0100"; when "01110011" => -- x73 5 vector <= "0101"; when "01110100" => -- x74 6 vector <= "0110"; when "01101001" => -- x69 1 vector <= "0111"; when "01110010" => -- x72 2 vector <= "1000"; when "01111010" => -- x7A 3 vector <= "1001"; when "01110000" => -- x70 0 vector <= "1010"; when "01110001" => -- x71 . vector <= "1011"; when "01111001" => -- x79 + vector <= "1100"; when others => vector <= "1111"; end case; count:= (count +1); end if; elsif transfer = '0' then done <= '0'; count := 0; end if; end if; end process convert; end behavioural; -------------------------------------------------------------------------- -- |Scan | Scan in HEX | Binary Value | Encoded Vector | -- |--------|-------------------|-------------------|-------------------| -- | Numlock| 77 | 0111 0111 | 0000 | -- | 7 | 6C | 0110 1100 | 0001 | -- | 8 | 75 | 0111 0101 | 0010 | -- | 9 | 7D | 0111 1101 | 0011 | -- | 4 | 6B | 0110 1011 | 0100 | -- | 5 | 73 | 0111 0011 | 0101 | -- | 6 | 74 | 0111 0100 | 0110 | -- | 1 | 69 | 0110 1001 | 0111 | -- | 2 | 72 | 0111 0010 | 1000 | -- | 3 | 7A | 0111 1010 | 1001 | -- | 0 | 70 | 0111 0000 | 1010 | -- | . | 71 | 0111 0001 | 1011 | -- | + | 79 | 0111 1001 | 1100 | -- | ERROR | FF | 1111 1111 | 1111 | -------------------------------------------------------------------------- --