Beruflich Dokumente
Kultur Dokumente
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity keyboard is
port(clock :in std_logic;
--??????
R_line : in std_logic_vector(3 downto 0); --????
R_row : out std_logic_vector(3 downto 0);
--????
num : out integer range 0 to 16 );
--?????????
end entity;
architecture behav of Keyboard is
----------------------------------------------------------component div is
port(clkin:in std_logic;
clk_div:out std_logic);
end component;
-----------------------------------------------------------component xiaod is
--????
port(CLK_XD:in std_logic;
--???????
KEY_IN:in integer range 0 to 16;
--????
KEY_OUT:out integer range 0 to 16); --?????????
end component xiaod;
------------------------------------------------------------signal counter: integer range 0 to 3;
--????????
signal counterB: integer range 0 to 3;
--????
signal Decode: std_logic_vector(0 to 7);
signal out_num: integer range 0 to 16;
signal Scan:std_logic_vector(3 downto 0);
signal clk_in:std_logic;
begin
u1: xiaod port map(CLK_XD=>clock,KEY_IN=>out_num,KEY_OUT=>num);
u2: div port map (clkin=>clock,clk_div=>clk_in);
process(clk_in)
begin
if rising_edge(clk_in) then
if counter=3 then
--????????
counter<=0;
else
counter<=counter+1;
end if;
case counter is
--????
when 0=> Scan<="1000";
when 1=> Scan<="0100";
when 2=> Scan<="0010";
when 3=> Scan<="0001";
end case;
end if;
end process;
process(clk_in)
begin
if falling_edge (clk_in) then
if R_line="0000" then
--????????????????
if counterB=3 then
counterB<=0;
out_num<=16;
else counterB<=counterB+1;
end if;
else counterB<=0;
case Decode is
--??
when "10000001" => out_num<=0;
when "10000010" => out_num<=1;
--????
-- ??