Sabtu, 06 Juni 2015

FPGA - Perancangan VHDL Keyboard Converter PS/2

Sistem modul keyboard converter seperti pada Gambar 1 dirancang berdasarkan tabel  kode ASCII. Operasi modul keyboard converter yaitu membandingkan masukan code keyboard dengan make code, break code dan command code. Jika code keyboard berupa make code maka code akan langsung diterjemahkan ke dalam bentuk kode ASCII. Dan jika code keyboard berupa break code atau berupa command code maka code keyboard tersebut diabaikan sampai code berupa make code.



Gambar 1 Modul Keyboard Converter

Keterangan:
•    code    = masukan sinyal code 8 bit
•    ascii    = keluaran sinyal kode ASCII 8 bit


VHDL Keyboard Converter PS/2:
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date:    13:20:53 10/14/2014
-- Design Name:
-- Module Name:    keyboard_converter - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity keyboard_converter is
    Port ( code : in  STD_LOGIC_VECTOR (7 downto 0);
               ascii : out  STD_LOGIC_VECTOR (7 downto 0));
end keyboard_converter;

architecture Behavioral of keyboard_converter is

begin
    process(code)
        begin
         case code is 
            when x"45" =>
                  ascii <= x"30"; --0
            when x"16" =>
                  ascii <= x"31"; --1
            when x"1E" =>
                  ascii <= x"32"; --2
            when x"26" =>
                  ascii <= x"33"; --3
            when x"25" =>
                  ascii <= x"34"; --4   
            when x"2E" =>
                  ascii <= x"35"; --5
            when x"36" =>
                  ascii <= x"36"; --6
            when x"3D" =>
                  ascii <= x"37"; --7       
            when x"3E" =>
                  ascii <= x"38"; --8       
            when x"46" =>
                  ascii <= x"39"; --9
            when x"66" =>
                  ascii <= x"08"; --backspace (BS control code)
            when x"5A" =>
                  ascii <= x"0D"; --enter (CR control code)       
            when x"75" =>
                  ascii <= x"18"; --UP               
            when x"72" =>
                  ascii <= x"19"; --bottom
            when others =>
                  ascii <= x"00";
        end case;
    end process;
end Behavioral;

Tidak ada komentar:

Posting Komentar