PS2 keyboard reading VHDL

Status
Not open for further replies.

r0nald

Newbie level 3
Joined
May 18, 2009
Messages
3
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,303
keyboard vhdl

I need to keep in my register playerAkeyb(7 downto 0) data about which key is down or not.

Right not I am using testled for debugging.

If I do not look which particular key was pressed, the code works well. If I check wether the key pressed was something particular(stored in playerAkeys(4)), then the behaviour is random(sometimes work, sometimes doesnt).

Code:
  process(clk25MHz)
  begin
		if clk25MHz'event and clk25MHz = '1' then
			if ps2_rdy = '1' then
				if scancode = release_key_const then
					key_release <= '1';
				else
					--if scancode = playerAkeys(4) then
						if key_release = '0' then
							playerAkeyb(4) <= '1';
						else
							playerAkeyb(4) <= '0';
							key_release <= '0';
						end if;
					--end if;
				end if;
				ps2_clr_rdy <= '1';
			end if;
			
			if ps2_clr_rdy = '1' then
				ps2_clr_rdy <= '0';
			end if;
		end if;			
	end process;
	
	testled <= playerAkeyb(4);

So the current code works, but can not differentiate between keys pressed. If I uncomment the "if scancode = playerAkeys(4) then", the thing sometimes works, sometimes doesnt.

Here is the whole code: **broken link removed**
Here is the PS2 driver code: **broken link removed**

I guess there is some simple stupid thing what I am missing and why I am smashing myself through the wall for 2 days now.
 

ps2 keyboard vhdl

playerAkeys(4) is only one bit of data, not 4. Note that PS/2 scan code is 8-bit. You need a multi-bit register, and optionally, slice notation: playerAkeys(7 downto 0).
 

reading a key bord in vhdl

Please see that playerAkeyb is bit_vector(7 downto 0) and playerAkeys is vector of bit_vector(7 downto 0). They are 2 different signals with a similar name

The syntax is correct, otherwise it wouldnt even synthesize
 

vhdl ps2

Wrote the whole code in a big-and-slow state-machine fashion and it now works OK. I guess it takes some effort to stop quit thinking that I am writing software, not hardware
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…