diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2022-02-18 10:34:35 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2022-02-18 10:34:35 +0100 |
| commit | 242cfbb4c5d93b41ee66846d5a02f902794becf5 (patch) | |
| tree | 868ad41ae3dc7b39d89c78a56b379e9149f38f26 | |
| parent | 320ad28a656ffc66c2ecb5c81f3249d3bb5898a1 (diff) | |
| download | tsea83-main.tar.gz | |
done lab4main
| -rw-r--r-- | lab4/KBD_ENC.vhd | 46 |
1 files 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; |
