2014-12-25 2 views
0

이 키보드 인터페이스 때문에 발생하는 문제가 있습니다. 나는 키보드와 앰프로 디지털 피아노를 만들려고 노력하고 있지만 소리는 우리가 버튼을 누를 때 오지 않는다. ~ 1 초의 지연이 있습니다. 이 문제로 나를 도울 수 있니? 우리가PS2 키보드 지연 오류/VHDL

Shift2_next <= Shift1(0) & Shift2(10 downto 1);

Shift2_next <= PS2Df & Shift2(10 downto 1);

에 코드 부분을 변경하면 원하지만 지금은 소리가 멈추지 않는 한 또한 키는 즉시 사운드를 제공합니다; 그 경우에는 중단 코드가 손상되었다고 생각합니다. 당신이 도울 수 있기를 바랍니다. 감사.

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 

entity keyboard_ctrl is 
    port(
    clk25 : in STD_LOGIC; 
    PS2C : in STD_LOGIC; 
    PS2D : in STD_LOGIC; 
    xkey : out STD_LOGIC_VECTOR(16 downto 1) 
); 
end keyboard_ctrl; 

architecture keyboard of keyboard_ctrl is 
    signal PS2Cf, PS2Df: std_logic; 
    signal PS2Cf_next, PS2Df_next: std_logic; 
    signal ps2c_filter, ps2d_filter: std_logic_vector(7 downto 0); 
    signal shift1,shift2: std_logic_vector(10 downto 0); 
    signal shift1_next,shift2_next: std_logic_vector(10 downto 0); 
begin 

    xkey <= shift1(8 downto 1)&shift2(8 downto 1); 

    -- filter for PS2 clock and data 
    filter: process(clk25) 
    begin 
    if clk25'event and clk25 = '1' then 
     ps2c_filter(7) <= PS2C; 
     ps2c_filter(6 downto 0) <= ps2c_filter(7 downto 1); 
     ps2d_filter(7) <= PS2D; 
     ps2d_filter(6 downto 0) <= ps2d_filter(7 downto 1); 

     PS2Cf <= PS2Cf_next; 
     PS2Df <= PS2Df_next; 
    end if; 
    end process filter; 
    PS2Cf_next <= '1' when ps2c_filter = X"FF" else 
        '0' when ps2c_filter = X"00" else 
        PS2Cf; 
    PS2Df_next <= '1' when ps2d_filter = X"FF" else 
        '0' when ps2d_filter = X"00" else 
        PS2Df; 

    --Shift used to clock in scan codes from PS2-- 
    shift: process(PS2Cf) 
    begin 
    if (PS2Cf'event and PS2Cf = '0') then 
     shift1 <= shift1_next; 
     shift2 <= shift2_next; 
    end if; 
    end process shift; 

    Shift1_next <= PS2Df & Shift1(10 downto 1); 
    Shift2_next <= Shift1(0) & Shift2(10 downto 1); 
end keyboard; 
+0

이 디자인은 더 더블 FF 입력 동기화 (는 PS2 프로토콜에 대한 중요합니다)이없는, 그것을 변경하고

최고의 소원을 사용할 수 있습니다. 'shift1'과'shift2'는 자체 생성 클록 신호로 클럭킹되기 때문에 동기 설계가 아니므로이 부분을 향상시킬 수 있습니다. ps2c 및 ps2d에서 AND 필터를 사용하는 이유는 무엇입니까? 이 전선은 결함이 없다고 추측 할 수 있습니다. 회로는 버스 유휴 상태, 시작 조건, 패리티, 버스의 종료 상태에 아무런주의를 기울이지 않습니다. – Paebbels

답변

0

PS2를 사용할 때 특별히 동기식으로 디자인을 변경해야합니다. 난 당신이 25 MHz의 핀에 연결되어 있는지 확인하거나 높은 주파수 시계를 사용하여 정확한 타이밍을 얻을 때까지 그것을 나눠 PS2에 대한 시계를 확인하는 것이 좋습니다. 3으로 시계를 나누어 첨부 예를 들어, 당신은

library ieee; 
    use ieee.std_logic_1164.all; 
    use ieee.std_logic_unsigned.all; 

entity divide_by_3 is 
    port (
     cout :out std_logic; -- Output clock 
     clk :in std_logic; -- Input clock 
     reset :in std_logic -- Input reset 
    ); 
end entity; 

architecture rtl of divide_by_3 is 
    signal pos_cnt :std_logic_vector (1 downto 0); 
    signal neg_cnt :std_logic_vector (1 downto 0); 
begin 
    process (clk, reset) begin 
     if (reset = '1') then 
      pos_cnt <= (others=>'0'); 
     elsif (rising_edge(clk)) then 
      if (pos_cnt = 2) then 
       pos_cnt <= pos_cnt + 1; 
      end if; 
     end if; 
    end process; 

    process (clk, reset) begin 
     if (reset = '1') then 
      neg_cnt <= (others=>'0'); 
     elsif (falling_edge(clk)) then 
      if (neg_cnt = 2) then 
       neg_cnt <= neg_cnt + 1; 
      end if; 
     end if; 
    end process; 

    cout <= '1' when ((pos_cnt /= 2) and (neg_cnt /= 2)) else 
      '0'; 
end architecture; 
------------------------------------------------------- 
-- Testbench to check the divide_by_3 logic 
------------------------------------------------------- 
library ieee; 
    use ieee.std_logic_1164.all; 
    use ieee.std_logic_textio.all; 
    use std.textio.all; 

entity div3_tb is 
end entity; 
architecture test of div3_tb is 

    signal cout :std_logic; 
    signal clk :std_logic := '1'; 
    signal reset :std_logic := '1'; 

    component divide_by_3 is 
    port (
     cout :out std_logic; 
     clk :in std_logic; 
     reset :in std_logic 
    ); 
    end component; 
begin 

    -- Generate clock 
    clk <= not clk after 10 ns; 
    reset <= '0' after 20 ns; 

    Inst_div3 : divide_by_3 


     port map (
      cout => cout, -- Output 
      clk => clk, -- Input 
      reset => reset -- Iinput 
     ); 
    end architecture 

;