----------------------------------------------------------------- -- key.vhd -- Christopher Kowalski -- -- This code recieves the input from a AT keyboard. This is usefull -- for hooking up a PS2 keyboard to the Altera UP1 board. -- Vector. -- The character entered on the keyboard must be read before another -- is entered or the incorret value will be read. This should be OK -- is cases where the typist can not type faster then the clock rate -- rate of the system, in this case arount 25 MHZ. -- The start bit, stop bit, and parity bit are not stored. -- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity key is port(keyboard, reset, keyclock : in std_logic; scancode : out std_logic_vector(7 downto 0); gotcode : out std_logic); end key; architecture behavioural of key is -- declare internal signals begin scancoder : process (keyclock, reset) is -- process variable variable count:natural range 0 to 10; variable index:natural range 0 to 7; begin if reset = '1' then count:= 0; gotcode <= '0'; elsif falling_edge(keyclock) then if count = 10 then count:= 0; elsif count = 9 then count:= (count +1); gotcode <= '1'; elsif count = 0 then count:= (count + 1); gotcode <= '0'; else index:= (count-1); scancode(index) <= keyboard; count:= (count + 1); end if; end if; end process scancoder; end behavioural;