From 242cfbb4c5d93b41ee66846d5a02f902794becf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 18 Feb 2022 10:34:35 +0100 Subject: done lab4 --- lab4/KBD_ENC.vhd | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/lab4/KBD_ENC.vhd b/lab4/KBD_ENC.vhd index 6d4a0ab..383a57e 100644 --- a/lab4/KBD_ENC.vhd +++ b/lab4/KBD_ENC.vhd @@ -89,6 +89,15 @@ begin -- * PS2_data_shift_reg * -- * * -- *********************************** + process(clk) begin + if rising_edge(clk) then + if rst = '1' then + PS2Data_sr <= (others => '0'); + elsif PS2Clk_op = '1' then + PS2Data_sr <= PS2Data & PS2Data_sr(10 downto 1); + end if; + end if; + end process; @@ -104,7 +113,17 @@ begin -- * PS2_bit_Counter * -- * * -- *********************************** - + process(clk) begin + if rising_edge(clk) then + if rst='1' then + PS2BitCounter <= (others => '0'); + elsif PS2BitCounter = 11 then + PS2BitCounter <= (others => '0'); + elsif PS2Clk_op = '1' then + PS2BitCounter <= PS2BitCounter + 1; + end if; + end if; + end process; @@ -119,7 +138,30 @@ begin -- * PS2_State * -- * * -- *********************************** - + process(clk) begin + if rising_edge(clk) then + if rst = '1' then + PS2state <= IDLE; + else + case PS2state is + when IDLE => + if PS2BitCounter = 11 then + if ScanCode = x"F0" then + PS2State <= BREAK; + else + PS2State <= MAKE; + end if; + end if; + when MAKE => + PS2State <= IDLE; + when BREAK => + if PS2BitCounter = 11 then + PS2State <= IDLE; + end if; + end case; + end if; + end if; + end process; -- cgit v1.2.1