PS2 or USB keyboard for custom CPU

cpukeyboardparallelps2usb

I have made a CPU on an FPGA board. It works great but I cannot proceed to make a computer with it until I have an input. What use is a computer if it can talk to you, but you cannot talk to it? It runs all on 5V, has essentially a 20 bit address line, is 8-bit, and essentially operates at 12.5MHz. I may speed it up later, so what I am looking for is a maximum of 3 chip solution to give me keyboard input via PS2 or USB. It must give parallel output and operate within 55ns(as I may speed it up). An Atmega is not fast enough.

Best Answer

The PS/2 keyboard is very easy to interface, and a PC/XT keyboard (with the 5 pin DIN connector) is even easier. For the PC/XT keyboard you just need a 8-bit serial-to-parallel shift register. The keyboard will automatically clock out a 9-bit key scan code for each key press and release; you can connect the keyboard clock signal to the clock in pin of the shift register and data signal to the data in pin of the shift register and you'll conveniently get a 8-bit key code + 1 interrupt bit for each keypress (the 9th bit will be in the shift register's serial out pin and that one you can also use as an interrupt signal if you also clear the shift register after reading each scan code).

For PS/2 keyboard it's similar but there's a few extra bits. Since you are running on the FPGA, it's probably no problem for you to make a 12-bit shift register instead of a 9-bit shift register.