Electrical – How to connect a USB keyboard to a DE1-SoC

fpgaintel-fpgausb

I recently got a DE1-SoC development board from Intel and I wanted to use it to instantiate a computer design I created while following along the Nand2Tetris course on Coursera. Unfortunately, this design requires a keyboard to be connected to the board and I do not have PS2 keyboards (only USB ones) or USB to PS2 adapters. While I could go and get the required hardware, I think that PS2 keyboards are becoming outdated, so I want to be able to use my USB keyboard. The board has 2 USB ports and according to this document, they should be able to interface to the FPGA fabric. Unfortunately, this guide specifies only how to instantiate a USB OTG port and how to connect its clock to the top-level design. It does not specify how to access the data coming from the USB. I have searched for specific instructions online, but so far I have found nothing. Is there a way to, say, display the scan code of the key pressed on a USB keyboard on the board's LEDs?

Best Answer

The DE1-SoC Cyclon-V is a System-on-Chip, with dual ARM9 processors. The DE1 system board has a ULPI port connected to ULPI PHY, which is connected to a USB hub with two user ports.

As I understand from specifications, AN702, and from comments from Chris Stratton, the SoC provides two "USB On-the-Go(OTG) controllers". The USB 2.0 Hi‑Speed On‑The‑Go DWC_otg controller (see Chapter 18) is something that was created by Synopsis - a provider of hard IP - in place of more widespread and established EHCI controller.

To connect a keyboard to this system via USB, you need to make the system a USB host. To make it a USB host, you would need to enable the DWC_otg controller. To get across across the soldered-on USB hub, you will need split-transaction support. To make the DWC_otg operational, you would need to load full Linux OS with USB hub support, which means that you need a full running OS with proprietary DWC_otg support (actual datasheets for register-based access, AFAIK, are available only under NDA).

So, the USB access is "interfaced with FPGA fabric" via DWC_OTG controller, you just need a proper software to use it. Only then you will be able to communicate with USB keyboard on the DE1-SoC Cyclon-V.

Good things are that the DWC_otg hardware seems to be also used in Broadcom BCM2836 SoC, which is the core of Raspberry Pi, so the software might be running more or less smoothly. However, one needs to keep in mind that it took about 15 years for entire Microsoft to make the EHCI USB host running on PCs, so expect some glitches on the way with DWC_otg.

Alternatively, you can select three GPIO at 3.3V CMOS level, and emulate the entire USB host functionality (LS only) via bit-banging. Or create your own LS host controller with your own proprietary interface, to drive the ULPI interface and PHY directly.