Simple SPI Slave Component in VHDL

I’ve been looking for a simple example of a SPI Slave component in VHDL for some time, and in the end, decided it would be more fun and educational to write my own. To keep the code as clean and simple as possible, I’ve focused entirely on Mode 0 SPI.

I now use this as part of a lab for our stage-2 electronics and robotics students (the lab sheet is included). The connections for a Terasic DE-0 Nano can be found in the reference data folder. The only signals you need to connect across are ground, MOSI, MISO, SCLK and a chip select (CS). You may want to change the signal assignments in the Quartus file.

  • The MCU code is written for with classic Mbed and has been exported to Keil uVision. It should work on the free evaluation version.
  • The FPGA code is written for Intel Quartus II v18.X, although should work with earlier versions. The free lite edition should be fine.

For anyone interested, the link is shared below. Feel free to clone / fork this as long as you acknowledge the source. If you find any bugs, feel free to raise an issue via GitHub.

https://github.com/UniversityOfPlymouth-Electronics/spi_slave

 

By Nicholas Outram

Dr. Nicholas Outram is an Associate Professor in Computing and Electronics in the School of Computing and Mathematics, Plymouth University, UK. He specialises in iOS development, Biomedical Signal Processing, Embedded Software Development and VHDL. Dr. Outram has developed and heads-up an intensive fast-track iOS development course for students, academics and engineers both in Plymouth and overseas. He also develops iOS applications for research and teaching. Dr. Outram has a Ph.D. in Biomedical Signal Processing and Artificial Intelligence and a first class honours degree in Electrical & Electronic Engineering. Before returning to academia, he worked for 5 years in industry as a DSP engineer and research engineer.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.