top of page

MicroZed Chronicles: Spartan 7 and AXI over UART

One of the things I’ve been doing recently is working with the Leonidas development board which we developed back in 2023. This board combines a small Spartan 7 with an RP2040 from the Raspberry Pi foundation with Pmods, LEDs, switches, and memories (SDRAM and QSPI) connected to the FPGA.

As part of this bring up, I’ve been working to create a design capable of controlling servos in a robot arm. I wanted to create a system that works for the Leonidas board in addition to any AMD board with a USB UART interface like an Arty S7 or Cmod.

In this example, we are going to create RTL files which illustrates the following:

  1. Configurable UART which outs and receives data for transmission over AXI Stream

  2. Protocol convertor which converts bytes received over the UART into register values. This is an adaption of the protocol conversion here which converted the UART to AXI Lite.

  3. PWM cores designed to operate at 60 Hz as standard for many servos.

I’ve uploaded the code into the Git repository here and the completed project should look like the figure below which shows eight PWM implementations.

In order to test the code prior to deployment, I’ve created a test bench which uses a structural element to connect the unit under test (UUT). The test bench also creates a bus functional model of the UART within a package. The package and the structural test bench are then used to create a test case which can exercise the UUT. The use of Bus Functional Model (BFM) and packages etc. to abstract away test bench interfaces is very useful. I recommend reading this project on Hackster if you want to know more about this process and how to properly create an IP module.

The protocol to send data over the UART is pretty simple.

The payloads of these bytes are as follows:


  • Write Op Code – 1 byte, value 0x09

  • Address – 4 bytes the address of the register

  • Length – 1 byte always 1

  • Payload – Words to be written, 4 bytes are provided for a register write


Running this project in the Vivado simulator will show the simulation working as we expected.

Now that we are confident the modules will work as desired, it’s time to write a simple application for the RP2040. This will just send various values down to the registers in the FPGA and change the width of the pulse output.


We will be able to see this on the oscilloscope and notice the commands as they are changing

I also included an ILA on the output of the AXIS UART in the design to enable me to verify the commands sent from the RP2040.

The next step in this development will be to get Jupyter Labs communicating with the RP2040 in order to provide simple and easy control from the desktop machine. While it will not be running on the device, the host machine will still enable us to do some interesting projects!

Workshops and Webinars

If you enjoyed the blog why not take a look at the free webinars, workshops and training courses we have created over the years. Highlights include

Embedded System Book   

Do you want to know more about designing embedded systems from scratch? Check out our book on creating embedded systems. This book will walk you through all the stages of requirements, architecture, component selection, schematics, layout, and FPGA / software design. We designed and manufactured the board at the heart of the book! The schematics and layout are available in Altium here   Learn more about the board (see previous blogs on Bring up, DDR validation, USB, Sensors) and view the schematics here.

Sponsored by AMD



bottom of page