0
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ stackoverflow.com/questions/39983442/… \$\endgroup\$ – jsotola Aug 25 '18 at 19:50
  • 1
    \$\begingroup\$ @jsotola That post does not specify what FPGA board they are using. I was wondering if the HPS infrastructure of the Cyclone V on my board would make the process easier. \$\endgroup\$ – Guacho Perez Aug 25 '18 at 20:09
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Can you support the claim that an additional soft IP core is required and that an ECHI one would be compatible? The Cyclone V Hard Processor Technical Reference Manual seems to indicate that the USB controller is a hard function (ie, fixed in silicon), implemented in a unique way and explicitly says it is not compatible with any of EHCI, UHCI, or OHCI. \$\endgroup\$ – Chris Stratton Aug 25 '18 at 22:10
  • \$\begingroup\$ Specifically, "The USB OTG controllers are instances of the Synopsys® † DesignWare® Cores USB 2.0 Hi‑Speed On‑The‑Go (DWC_otg) controller." - that's a hard function, and already has drivers in the Linux kernel sources. \$\endgroup\$ – Chris Stratton Aug 25 '18 at 22:19
  • \$\begingroup\$ @ChrisStratton, yep, you are right, no need for EHCI, just some undocumented DWC_otg should be there. The answer is corrected, thanks. \$\endgroup\$ – Ale..chenski Aug 26 '18 at 0:06
  • \$\begingroup\$ So there is no straightforward way of doing it with the Quartus Prime software and the onboard HPS? \$\endgroup\$ – Guacho Perez Aug 26 '18 at 1:20
  • \$\begingroup\$ @GuachoPerez, I am afraid this is the very straightforward way: you must generate all USB protocol steps (device enumeration) and maintain USB SOF/keep alive traffic and periodic interrupt inquiries to operate a simple USB keyboard. \$\endgroup\$ – Ale..chenski Aug 26 '18 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.