Connecting FPGAs to MATLAB via UDP

Cleverly implemented code takes advantage MATLAB's Instrumental Control toolbox to stream data via UDP from a host PC to their FPGA.

From the time when I was a brand new EE student my freshman year of undergrad, all the way up to present day as a senior electrical engineer, I've found MATLAB to be an abundantly useful tool. So when I see new uses/hacks for MATLAB, especially when it involves FPGAs, it catches my eye.

This week I stumbled upon one of those hacks that's so clever, you're mad you didn't come up with it yourself. An electrical and computer engineering professor at Cornell, Bruce Land, created a setup utilizing MATLAB's instrument control toolbox support of UDP communication objects to connect an FPGA running an embedded Linux image for bidirectional data transfer.

This project is broken down into three main components:

  • Setting up UDP communication from ARM-core on FPGA to outside world.
  • Setting up UDP communication from outside world to ARM-core on FPGA.
  • The MATLAB code to sending/receiving data using the instrument control toolbox.

Setting up a UDP connection is pretty straightforward on a Linux image running on the ARM processor of an FPGA, the tricky part comes with setting up some sort of ACK functionality for synchronization of the data being send across the UDP network connection. As Land discovered, the UDP receive function in MATLAB is the bottleneck in that it is too slow, which he addresses by reducing the overhead of data being sent over the connection by duplicating samples in the C code on the FPGA.

Read the quick project write-up here. While Land is using an Intel/Altera-based FPGA, the overall steps can be extrapolated to any FPGA development platform since the core focus is UDP communication and MATLAB. The C code running in the Linux image on the ARM-core of the FPGA is opening a socket on port 9090 then sending audio samples to/from a audio codec FIFO (which you could replace this code to supply whatever desired data) while the MATLAB code on the host PC opens a UDP object, listens for data, then echos it as a string to the command window.

whitney-knitter

All thoughts/opinions are my own and do not reflect those of any company/entity I currently/previously associate with.

Latest Articles