library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity PS2Tastatur is port( CLK: in std_logic; ps2c: inout std_logic; ps2d: inout std_logic; led: out std_logic_vector(15 downto 0)); end PS2Tastatur; architecture Behavioral of PS2Tastatur is signal clkDiv : std_logic_vector (8 downto 0); signal Takt100kHz: std_logic; -- signal PS2_Takt, PS2_Dat: std_logic; signal shiftReg: std_logic_vector(10 downto 0):="00000000000"; signal ct: std_logic_vector(7 downto 0); begin --========================================================= -- Erzeugung eines 100kHz-Taktes (50MHz/2^9) ----------------------------------------------------------- Taktteiler: Process (CLK) begin if (CLK = '1' and CLK'Event) then clkDiv <= clkDiv +1; end if; end Process; ----------------------------------------------------------- Takt100kHz <= clkDiv(8); --========================================================= -- Abtasten der eingehenden PS2-Signale ----------------------------------------------------------- Process (Takt100kHz) begin if (Takt100kHz = '1' and Takt100kHz'Event) then ps2_Takt<= ps2c; ps2_Dat <= ps2d; end if; end process; --========================================================= -- Datenübernahme in einem Schieberegister ----------------------------------------------------------- Process(ps2_Takt) begin if (ps2_Takt = '0' and ps2_Takt'Event) then -- fallende Flanke ShiftReg(10 downto 0) <= ps2_Dat & ShiftReg(10 downto 1); ct<=ct+1; end if; end process; --========================================================= -- kombinatorische Ausgabe ----------------------------------------------------------- led <= ct(4 downto 0) & ShiftReg; ----------------------------------------------------------- end Behavioral;