Difference between revisions of "IOP16 PS/2 Keyboard"

From Land Boards Wiki
Jump to navigation Jump to search
 
(18 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
=== Software Interface ===
 
=== Software Interface ===
  
==== Address i_RegSel - Register Select = 0  - Status register ====
+
==== Status register (Read only) ====
  
 +
* Addr = 0
 
* Value = 0x00, No data present
 
* Value = 0x00, No data present
 
* Value = 0x01, Data present
 
* Value = 0x01, Data present
  
==== Address i_RegSel - Register Select = 0  - Data register ====
+
==== Data register (Read only) ====
  
 +
* Addr = 1
 
* ASCII Data
 
* ASCII Data
 +
 +
== PS/2 Keyboard Subroutines ==
 +
 +
=== Get character from keyboard ===
 +
 +
* Blocking routine waits for keypress
 +
* Returns ASCII key value in Reg1
 +
 +
<pre>
 +
RDKBD JSR WTKBRX WAIT FOR KBD RX CHAR
 +
IOR 0X01 0X0D READ KBD CHAR
 +
RTS
 +
WTKBRX IOR 0X01 0X0C READ KBD STATUS
 +
ARI 0X01 0X01 RX RDY BIT
 +
BEZ WTKBRX LOOP UNTIL CHAR PRESENT
 +
</pre>
 +
 +
=== Poll the keyboard ===
 +
 +
* Returns keyboard status in Reg1
 +
** Returns 0x00 = No key
 +
** Returns 0x01 - Key was pressed
 +
 +
<pre>
 +
POLLKBD IOR 0X01 0X0C
 +
RTS
 +
</pre>
  
 
== Hook-up ==
 
== Hook-up ==
 +
 +
* Add to Top Level VHDL code
 +
 +
=== Pins ===
 +
 +
* Add to top level entity pins list
 +
 +
<pre>
 +
  -- PS/2
 +
  ps2Clk  : inout std_logic;
 +
  ps2Data : inout std_logic;
 +
</pre>
 +
 +
=== Signals ===
 +
 +
* Add signal into architecture section
 +
 +
<pre>
 +
-- Decodes/Strobes
 +
...
 +
signal w_kbcs : std_logic;
 +
 +
-- Interfaces
 +
...
 +
  signal w_KbdData  :  std_logic_vector(7 downto 0);
 +
</pre>
  
 
=== VHDL Instance ===
 
=== VHDL Instance ===
Line 34: Line 89:
 
</pre>
 
</pre>
  
=== Hook-up ===
+
=== Hook-up Strobes/Read Mux ===
 +
 
 +
* Add to strobes and read mux
  
 
<pre>
 
<pre>
 
-- Strobes/Selects
 
-- Strobes/Selects
 +
  ...
 
   w_kbcs <= '1' when (w_periphAdr(7 downto 1) = "0000110") and (w_periphRd = '1') else '0';
 
   w_kbcs <= '1' when (w_periphAdr(7 downto 1) = "0000110") and (w_periphRd = '1') else '0';
  
Line 45: Line 103:
 
   ...
 
   ...
 
</pre>
 
</pre>
 
=== Signals ===
 
 
<pre>
 
-- Decodes/Strobes
 
...
 
signal w_kbcs : std_logic;
 
 
-- Interfaces
 
...
 
  signal w_KbdData : std_logic_vector(7 downto 0);
 
</pre>
 
 
  
 
== Resources ==
 
== Resources ==
Line 63: Line 108:
 
* Logic Cells: 708
 
* Logic Cells: 708
 
* Registers: 95
 
* Registers: 95
* Memory Bits: 8336
+
* Memory Bits: 0
* M9Ks: 3
+
* M9Ks: 0

Latest revision as of 17:59, 16 April 2022

PS/2 Keyboard

  • Wrapper for PS/2 keyboard interfaces
  • PS/2 to ASCII conversion

Software Interface

Status register (Read only)

  • Addr = 0
  • Value = 0x00, No data present
  • Value = 0x01, Data present

Data register (Read only)

  • Addr = 1
  • ASCII Data

PS/2 Keyboard Subroutines

Get character from keyboard

  • Blocking routine waits for keypress
  • Returns ASCII key value in Reg1
RDKBD	JSR	WTKBRX		WAIT FOR KBD RX CHAR
	IOR	0X01	0X0D	READ KBD CHAR
	RTS			
WTKBRX	IOR	0X01	0X0C	READ KBD STATUS
	ARI	0X01	0X01	RX RDY BIT
	BEZ	WTKBRX		LOOP UNTIL CHAR PRESENT

Poll the keyboard

  • Returns keyboard status in Reg1
    • Returns 0x00 = No key
    • Returns 0x01 - Key was pressed
POLLKBD	IOR	0X01	0X0C
	RTS		

Hook-up

  • Add to Top Level VHDL code

Pins

  • Add to top level entity pins list
  -- PS/2 
  ps2Clk  : inout std_logic;
  ps2Data : inout std_logic;

Signals

  • Add signal into architecture section
-- Decodes/Strobes
...
 signal w_kbcs : std_logic;

-- Interfaces
...
  signal w_KbdData  :  std_logic_vector(7 downto 0);

VHDL Instance

-- PS/2 keyboard/mapper to ANSI
KEYBOARD : ENTITY  WORK.Wrap_Keyboard
port MAP (
  i_CLOCK_50 => i_clk,
  i_n_reset  => w_resetClean_n,
  i_kbCS     => w_kbcs,
  i_RegSel   => w_periphAdr(0),
  i_rd_Kbd   => w_kbcs,
  i_ps2_clk  => ps2Clk,
  i_ps2_data => ps2Data,
  o_kbdDat   => w_KbdData
);

Hook-up Strobes/Read Mux

  • Add to strobes and read mux
-- Strobes/Selects
  ...
  w_kbcs <= '1' when (w_periphAdr(7 downto 1) = "0000110") and (w_periphRd = '1') else '0';

-- Peripheral bus read mux
  w_periphIn <= ...
    w_KbdData  when w_periphAdr(7 downto 1) = "0000110"	else
  ...

Resources

  • Logic Cells: 708
  • Registers: 95
  • Memory Bits: 0
  • M9Ks: 0