Course: Accelerometer FPGA interface using open-source VHDL libraries

Learn to build a VHDL design with open-source RTL modules from Open Logic and OSVVM verification components, and interface the ADXL362 accelerometer chip on the Pmod ACL2 over SPI.

Category: Tags: , , ,

Description

In this course, we read an ADXL362 accelerometer with an FPGA and plot the live motion on the computer. The chip communicates with the FPGA over SPI, the FPGA forwards the data over UART, and a Python GUI shows the X, Y, and Z acceleration as bars that move as you tilt the board.

But this course is about more than reading a sensor. The real subject is how to put together a VHDL project from open-source libraries instead of writing every module from scratch. The SPI master, UART transmitter, reset generator, synchronizer, and debouncer all come from the Open Logic VHDL standard library. The only RTL we write by hand is the finite-state machine that controls the accelerometer.

Open Logic is worth knowing about by itself. VHDL has had great verification frameworks for years, but no standardized library of synthesizable RTL modules with a consistent interface. Open Logic fills that gap. You can read more about it in this guest post by its creator, Oliver Bründler, here on VHDLwhiz.

We read the ADXL362 datasheet together and translate the register map into SPI transactions: soft reset, interrupt mapping, output data rate, and measure mode. The finite-state machine sequences it all through ready/valid handshakes and reads the X, Y, Z, and temperature registers in a single SPI burst.

The testbench is built the same way as the design: from ready-made components. OSVVM’s SPI peripheral model stands in for the accelerometer, and its UART receiver model plays the host computer. The result is an uncomplicated self-checking testbench that verifies every command and data byte the design sends.

Finally, we implement the design in Vivado and create the Python GUI that plots the live data. We let AI (ChatGPT) generate the Python code, but you don’t need an AI subscription as the finished program is included in the course.

This course is only available in the VHDLwhiz Membership.

The membership subscription gives you access to this and many other courses and VHDL resources.

You pay monthly to access the membership and can cancel the automatic renewal anytime. There is no lock-in period or hidden fees.

You can follow most of the course in simulation because the testbench models both the accelerometer and the host computer. But you need the hardware below to stream live acceleration data.

Hardware used in the course

Software used in the course

I use Windows 11 in the course. All the other software is available for free for Windows and Linux:

Course outline

Number of lessons:
15
Average video duration:
12m44s
Total video duration:
3h10m

The overview below shows the lessons in this course.

video lesson icon/default Created with Sketch.

1 - Introduction

Welcome to the course! Here's what you will learn.

video lesson icon/default Created with Sketch.

2 - Open Logic VHDL standard library

Open Logic is a collection of open-source VHDL modules and packages that we can use as building blocks in our project.

video lesson icon/default Created with Sketch.

3 - OSVVM testbench framework

We'll use the OSVVM VHDL verification framework for the testbench because it has simulation models for SPI peripherals as well as UART.

video lesson icon/default Created with Sketch.

4 - Accelerometer chip datasheet

To get a good understanding of how the Analog Devices ADXL362 MEMS accelerometer works, we'll read the datasheet before starting on the code.

video lesson icon/default Created with Sketch.

5 - Top module and pin constraints

Let's start with the top-level VHDL module. We need to examine the reference manuals to derive the signal names and pin numbers.

video lesson icon/default Created with Sketch.

6 - Open Logic reset synchronizer

We'll start easy with the module that generates the internal reset as the first to import from the Open Logic VHDL standard library.

video lesson icon/default Created with Sketch.

7 - Open Logic SPI master

Let's skip writing an SPI controller from scratch and instead configure the Open Logic SPI master for the Analog Devices ADXL362 accelerometer.

video lesson icon/default Created with Sketch.

8 - Control and UART modules

It's time to start on the control module that will contain our VHDL finite-state machine. The UART transmitter we'll import from Open Logic.

video lesson icon/default Created with Sketch.

9 - Async signal handling

You need a strategy for handling asynchronous inputs like pushbuttons and interrupts. We'll use a 2FF synchronizer, a debouncer, and an edge detector.

video lesson icon/default Created with Sketch.

10 - Control module FSM states

Now we can start on the control module's finite-state machine (FSM) that will communicate with the SPI master and UART transmitter modules.

video lesson icon/default Created with Sketch.

11 - SPI peripheral verification component

OSVMM has a verification component (VC) for simulating SPI peripherals (formerly called SPI slaves). We'll use it to check that our VHDL design follows the protocol.

video lesson icon/default Created with Sketch.

12 - Configuration data

Let's start the FSM by issuing a SOFT_RST command before setting up the ADXL362's config registers, including INTMAP1, FILTER_CTL, and POWER_CTL.

video lesson icon/default Created with Sketch.

13 - UART transmitter and verification component

We'll transmit the data to the host computer using the Open Logic UART transmitter while using OSVVM's UART receiver VC in the testbench

video lesson icon/default Created with Sketch.

14 - Implementation

Finally, it's time to implement the design in Vivado and program the board. But will we see acceleration data streaming from the FPGA?

video lesson icon/default Created with Sketch.

15 - Visual representation

Let's create a beautiful graphical user interface (GUI) that displays the X, Y, and Z acceleration data as bars that move in real time as we tilt the FPGA and accelerometer.

This course is only available in the VHDLwhiz Membership.

The membership subscription gives you access to this and many other courses and VHDL resources.

You pay monthly to access the membership and can cancel the automatic renewal anytime. There is no lock-in period or hidden fees.

Reviews

There are no reviews yet.

Be the first to review “Course: Accelerometer FPGA interface using open-source VHDL libraries”

Your email address will not be published. Required fields are marked *