FAQ | Points | Add... | Recent posts | Search | Register | Log in


kalkulator vhdl z wykorzystaniem klawiatury PS2


Post new topic  Reply to topic      Main Page -> Forum Index -> Microcontrollers Generally -> Programmable Systems -> kalkulator vhdl z wykorzystaniem klawiatury PS2
Author
Message
mojrzesz8
Poziom 1
Poziom 1


Joined: 05 Feb 2011
Posts: 1

Post#1 Post from the author of the topic 24 Dec 2011 16:28   

kalkulator vhdl z wykorzystaniem klawiatury PS2


Proszę o pomoc w projekcie jaki otrzymałem do zrobienia na mikrokontrolerze altera cyclone 2. Chodzi o napisanie prostego kalkulatora który wykorzystywał by klawiature PS2. Wpisana cyfa jak i wynik działania miała by się pokazywać na 7-segmentowym wyświetlaczu. Proszę o jakąkolwiek pomoc nawet o wskazówki dotyczące zwykłego wykorzystania klawiatury PS2. Będę bardzo wdzięczny za podpowiedzi w tym temacie.
Back to top
   
Google

Google Adsense


Post# Post from the author of the topic 24 Dec 2011 16:28   





Back to top
   
robik2
Poziom 14
Poziom 14


Joined: 02 Apr 2006
Posts: 151
Location: biała podlaska

Post#2 25 Dec 2011 20:52   

Re: kalkulator vhdl z wykorzystaniem klawiatury PS2


Jedyne co mogę pomóc to to że cyclone altery to nie jest mikrokontroler.
Back to top
   
Google

Google Adsense


Post# 25 Dec 2011 20:52   





Back to top
   
cepelia
Poziom 11
Poziom 11


Joined: 03 Jun 2007
Posts: 67
Location: czestochowa

Post#3 03 Jan 2012 19:19helpful post - solution   

Re: kalkulator vhdl z wykorzystaniem klawiatury PS2


Używanie klawiatury w vhdl'u
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity KeyboardController is
    Port ( Clock : in STD_LOGIC;
           KeyboardClock : in  STD_LOGIC;
           KeyboardData : in  STD_LOGIC;
           LeftPaddleDirection : buffer  integer;
           RightPaddleDirection : buffer  integer
   );
end KeyboardController;

architecture Behavioral of KeyboardController is

signal bitCount : integer range 0 to 100 := 0;
signal scancodeReady : STD_LOGIC := '0';
signal scancode : STD_LOGIC_VECTOR(7 downto 0);
signal breakReceived : STD_LOGIC := '0';

constant keyboardA : STD_LOGIC_VECTOR(7 downto 0) := "00011100";
constant keyboardY : STD_LOGIC_VECTOR(7 downto 0) := "00011010";
constant keyboardK : STD_LOGIC_VECTOR(7 downto 0) := "01000010";
constant keyboardM : STD_LOGIC_VECTOR(7 downto 0) := "00111010";

-- tutaj dajesz stałe przycisków które cię interesują
-- według rysunku wklejonego niżej... to akurat do sterowania pongiem ale zasada -- działania jest taka sama

begin

   keksfabrik : process(KeyboardClock)
   begin
      if falling_edge(KeyboardClock) then
         if bitCount = 0 and KeyboardData = '0' then --keyboard wants to send data
            scancodeReady <= '0';
            bitCount <= bitCount + 1;
         elsif bitCount > 0 and bitCount < 9 then -- shift one bit into the scancode from the left
            scancode <= KeyboardData & scancode(7 downto 1);
            bitCount <= bitCount + 1;
         elsif bitCount = 9 then -- parity bit
            bitCount <= bitCount + 1;
         elsif bitCount = 10 then -- end of message
            scancodeReady <= '1';
            bitCount <= 0;
         end if;
      end if;
   end process keksfabrik;

   kruemelfabrik : process(scancodeReady, scancode)
   begin
      if scancodeReady'event and scancodeReady = '1' then
         -- breakcode breaks the current scancode
         if breakReceived = '1' then
            breakReceived <= '0';
            if scancode = keyboardA or scancode = keyboardY then
               LeftPaddleDirection <= 0;
            elsif scancode = keyboardK or scancode = keyboardM then
               RightPaddleDirection <= 0;
            end if;
         elsif breakReceived = '0' then
            -- scancode processing
            if scancode = "11110000" then -- mark break for next scancode
               breakReceived <= '1';
            end if;

            if scancode = keyboardA then
               LeftPaddleDirection <= -1;
            elsif scancode = keyboardY then
               LeftPaddleDirection <= 1;
            elsif scancode = keyboardK then
               RightPaddleDirection <= -1;
            elsif scancode = keyboardM then
               RightPaddleDirection <= 1;
            end if;
         end if;
      end if;
   end process kruemelfabrik;
end Behavioral;


do top modułu dołączasz moduł kontrolera zgodnie z zasadami składni

Code:
component KeyboardController is
    Port ( Clock : in STD_LOGIC;
           KeyboardClock : in  STD_LOGIC;
           KeyboardData : in  STD_LOGIC;
           LeftPaddleDirection : out  integer;
           RightPaddleDirection : out  integer
   );
end component;


potem mapujesz

Code:
kbController : KeyboardController port map ( clk, kb_clk, kb_data, leftPaddleDirection, rightPaddleDirection );


i tyle jeżeli chodzi o obsługę klawiszy
Back to top
   
Post new topic  Reply to topic      Main Page -> Forum Index -> Microcontrollers Generally -> Programmable Systems -> kalkulator vhdl z wykorzystaniem klawiatury PS2
Page 1 of 1
Similar topics
[attiny2313][bascom]emulator klawiatury ps2 (5)
klawiatura ps2 + uC - dziwna transmisja z klawiatury (2)
uC klawiatura PS2, rozkazy do klawiatury (2)
Emulacja klawiatury komputerowej na PS2 (36)
C++ Builder 6 wpiszwanie liczb z klawiatury (kalkulator=. (2)
Potrzebna pomoc: Prosty kalkulator w VHDL (7)
kalkulator w VHDL (3)
[vhdl] Model układu LM75 z wykorzystaniem bibliotek FMF (1)
Kalkulator z wykorzystaniem instrukcji switch (3)
Problem z fragmentem kodu VHDL kalkulator w VHDL (2)

Page generation time: 0.157 seconds


FAQ || Administrator || Moderators || Widgets and banners || Contact
elektroda.pl topic RSS feed