FPGA Design Repository
Interface summary

Input ports

  • Reset - Active high reset.

  • Clock - Board clock.

  • PS2Busy - Activate high to signal that a data transmission or reception is ongoing.

  • PS2Error - Activate high to signal a parity error or an acknowledge bit not received.

  • DataReady - Activate high to signal that a data byte may be read.

  • DataByte - A data byte from the PS/2 controller.

Output ports

  • Send - Active high signals a command is available for sending to the device.

  • Command - The command byte to send to the device.

  • CodeReady - Active high signals that a scan code may be read.

  • ScanCode - Bit 9 high signals an extended code and low a regular one.
     Bit 8 high signals break code and low make code.
     The remaining bits 7 down to 0 are the rest of the code.
     Example: "0001011010" is the <Enter> key make code and "0101011010" is the break code.

File dependencies

The keyboard mapper module has no file dependencies.

KeyboardMapper.vhd

Keyboard mapper

Description

The keyboard mapper module connects to the PS/2 controller receiving the data bytes coming from the keyboard, it detects the sequences that correspond to valid scan codes or command responses and acts accordingly, it also sends commands to the keyboard through the PS/2 controller.

For example, you press the <Caps Lock> key on your keyboard, transmission is done serially to the (host) PS/2 controller and a data byte is retrieved and passed to the keyboard mapper,  the corresponding scan code is put on the output port "ScanCode" but there's more, the keyboard mapper sends a command xED to the keyboard, this is the set/reset LEDs command, the keyboard replies xFA (acknowledge), the keyboard mapper then sends another byte indicating the LED set/reset states, once again the keyboard replies xFA upon reception and lights the Caps Lock LED.


Sender Byte Information
Keyboard x58 <Caps Lock> key pressed
Host xED Set/Reset LEDs command
Keyboard xFA Acknowledge
Host x04 Set Caps Lock LED on
Keyboard xFA Acknowledge

If you're interested about the keyboard commands take a look at http://www.Computer-Engineering.org/ps2keyboard/.

The keyboard mapper has no file dependencies but was designed specifically to connect to the PS/2 controller available here. A higher hierarchy module was created, instantiating both the PS/2 controller and the keyboard mapper for easier usage.

Copyright © 2008, Rui T. Sousa | Last modified on: 26/09/08