0
\$\begingroup\$

I am trying to implement a simple mips1 clone in Verilog at the moment, works all fine in simulators but I also want to run it on an actual FPGA.

Basically I would like to send/receive characters to the running CPU via UART, also I would like to read values from buttons/switches on the FPGA. Now I'm wondering what is the best way to interface GPIO pins and UART.

The only idea I could come up with is to just have separate chips running on the FPGA, directly connected to the GPIO pins and to the UART interface. These chips would just read from/write to specific memory locations and do their job based on that data.

I could also imagine that I will need some kind of interrupt controller for this so the CPU could run some snippet of code when a button is pressed. But I can only imagine this to be useful for input from something, not when I want to make an LED light up.

How does a microcontroller or a Raspberry get an LED to light up?

\$\endgroup\$
  • 1
    \$\begingroup\$ "How does a microcontroller or a raspberry get an led to light up?" By connecting peripherals to the CPU bus. Then read/write the peripherals. In your case you have to write the Verilog code for the peripherals. There are hundreds of Verilog modules for a UART out there. "All" you have to do is connect/adapt them to whatever your bus interface is. \$\endgroup\$ – Oldfart Sep 17 '18 at 14:42
3
\$\begingroup\$

What you want is a "memory mapped peripheral". You add some logic to the address bus so that, if the address matches a specific pattern, instead of read/write being routed to the memory they are routed to a peripheral.

The peripheral then contains one or more registers, which can be directly connected to pieces of the peripheral. So for example when reading from address 0x1234 you might read directly from the GPIO.

Interrupts are useful but not essential.

You might find it convenient to implement "AXI" or "AMBA" bus protocols, especially if you want to connect to pre-existing IP blocks for peripherals.

(I learned this from Micro Interfacing Circuits by RA Penfold, but that's an extremely old book)

\$\endgroup\$
  • \$\begingroup\$ They're all extremely old, and were quite old when I read them in the 90s, but I think all of RA Penfold's books should be required reading. I miss there being a rack of them at Maplin. Hell, I miss there being a Maplin to find them in. :) \$\endgroup\$ – Jules Sep 17 '18 at 19:12
  • \$\begingroup\$ I figured out that an AXI Interconnect probably is what I need. Do the addresses of the different components need to be hardcoded or is there any other way to get them dynamically? \$\endgroup\$ – Tom K Sep 18 '18 at 8:10
  • 1
    \$\begingroup\$ Dynamic allocation might be possible but it's usually unhelpful - you pick addresses for the peripherals as part of the design. \$\endgroup\$ – pjc50 Sep 18 '18 at 8:52

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.