Q&A Home > 고객지원 > 기술지원 > Q&A
[re]HBE Combo 2를 이용한 키 패드 제어 질문드립니다.
카테고리FPGA/SoC
작성자HB_SoC 아이피121.183.237.176
작성일11-08-11 10:19 조회수1615
파일

한백전자의 이장겸입니다.

문제가 되는 부분을 확인해보았습니다.


첨부된 소스에서

process(clk)
begin
    if clk'event and clk = '1' then
        if k_stop = '1' then
            null;
        else
            case k_s is
                when "000" => key_data <= "001";
                when "001" => key_data <= "010";
                when "010" => key_data <= "100";
                when "100" => key_data <= "001";
                when others => null;
           end case;
        end if;
    end if;
end process;

의 부분에서 소스가 잘못 쓰여졌습니다.   책에 오류가 있었습니다.

위의 부분에서 when 문의 key_data 를 key_s로 수정하시면 됩니다.


process(clk)
begin
    if clk'event and clk = '1' then
        if k_stop = '1' then
            null;
        else
            case k_s is
                when "000" => key_s <= "001";
                when "001" => key_s <= "010";
                when "010" => key_s <= "100";
                when "100" => key_s <= "001";
                when others => null;
           end case;
        end if;
    end if;
end process;


불편을 끼쳐 드려 죄송합니다.


즐거운 하루 보내세요.


>

User Manual 에 예제 소스가 있어서 예제 소스를 보고 이해하려고 해도 도무지 이해도 안될 뿐더러 오류가 나서 컴파일러도 되지 않습니다.
유저매뉴얼 241쪽에 7.1 키패드 제어 라고 있는데, 한번 보시고 다른 예제 소스좀 부탁드립니다. 오류가 나서 제대로 시물레이션이 안되네요.

소스 남깁니다.
 library ieee;
use ieee.std_logic_1164.all;

entity Keypad_exam is
 port (
  clk  : in std_logic;
  k_s  : buffer std_logic_vector(2 downto 0);
  k_d  : in std_logic_vector(3 downto 0);
  led  : out std_logic_vector(7 downto 0));
end Keypad_exam;

architecture hb of keypad_exam is

signal scaan : integer range 0 to 2;
signal led_cnt  : integer range 0 to 15;
signal k_stop  : std_logic;
signal key_data : integer range 0 to 15;

begin
 
k_stop <= k_d(3) or k_d(2) or k_d(1) or k_d(0);

process(clk)
begin
 if clk'event and clk ='1' then
  if k_stop ='1' then
   null;
  else
  case k_s is
   when "000" => key_data <= "001";
   when "001" => key_data <= "010";
   when "010" => key_data <= "100";
   when "100" => key_data <= "001";
   when others => null;
  end case;
  end if;
 end if;
end process;

process (clk)
begin
 if clk'event and clk ='1' then
  case k_s is
   when "001" =>
   case k_d is
    when "0001" => key_data <=1;
    when "0010" => key_data <=4;
    when "0100" => key_data <=7;
    when "1000" => key_data <=0;
    when others => key_data <=0;
   end case;
   when "010" =>
   case k_d is
    when "0001" => key_data <=2;
    when "0010" => key_data <=5;
    when "0100" => key_data <=8;
    when "1000" => key_data <=10;
    when others => key_data <=0;
   end case;
   when "100" =>
   case k_d is
    when "0001" => key_data <=3;
    when "0010" => key_data <=6;
    when "0100" => key_data <=9;
    when "1000" => key_data <=0;
    when others => key_data <=0;
   end case;
  when others => key_data <= 0;
  end case;
 end if;
end process;

process (clk)
begin
 if clk'event and clk ='1' then
  case key_data is
   when 0 => led <= "00000000";
   when 1 => led <= "00000001";
   when 2 => led <= "00000010";
   when 3 => led <= "00000011";
   when 4 => led <= "00000100";
   when 5 => led <= "00000101";
   when 6 => led <= "00000110";
   when 7 => led <= "00000111";
   when 8 => led <= "00001000";
   when 9 => led <= "00001001";
   when 10 => led <= "00001010";
   when others => led <= "00000000";
  end case;
 end if;
end process;

end hb;


다음글 HBE Combo 2를 이용한 키 패드 제어 질문드립니다.
이전글 센서네트워크를 공부하는 학생입니다.

댓글 등록은 로그인 하신후 이용하실 수 있습니다.