Beginning FPGA Programming - Partie70
Beginning FPGA Programming - Partie70
14.4 Summary
In this chapter, we showed you the steps to create your own interface IP and we created a complicated
command list for the SPI from the UART interface. It is important to define the requirements first and then
define the port list. The last step is going to create the VHDL process (sequential and combination logic)
based on the requirements.
We created a generic SPI master interface module. It supports a very wide range of SPI clock frequencies
and it is programmable at runtime. The module only does one byte at a time, which is the basic unit for SPI
interfaces. This allows higher-level software/hardware to create different read/write operations for different
SPI slaves.
In the SPI master module, we only used one 17-bit counter, one 4-bit counter, two 8-bit shift registers,
and some registers. This helps to demonstrate that creating an interface module is not all that difficult.
343
PART IV
15.1 Introduction
We are going to use the Raspberry PI SPI (Serial Peripheral Interface) master to control the BeMicro MAX10
LEDs (light-emitting diodes). We need to design an SPI slave interface in the FPGA (field-programmable gate
array) to let the Raspberry PI control the LEDs on the board. In the following section, we will show you how
to connect a Raspberry Pi to BeMicro MAX10 board, design an SPI slave for the FPGA, and write a simple
Python script to run on the Raspberry Pi that will do two-way communication on the SPI interface.
Figure 15-1. SPI two-way communication between Raspberry Pi and MAX10 FPGA block diagram
There are some general purpose input/output pins (GPIO) on the BeMicro MAX10 board labeled pin
header 5 (J5). We need to find four pins available from J5 for the SPI to use. Table 15-1 shows the pins we
selected from the FPGA and Raspberry Pi. We will use the Raspberry Pi SPI0 CE1 Master to talk with the
FPGA SPI slave on J5. Figure 15-2 shows both the FPGA and Raspberry Pi pin locations with color codes.
Black is the ground. It is very important to connect the ground pins first before you make another pin
connection. Yellow is the CLOCK. Orange is the SLAVE SELECT. RED is the MOSI. BROWN is the MISO. The
same color jumper wires are used to connect them to the breadboard. There is one more color, BLACK, in
Figure 15-2.
Figure 15-2. Cable connection between the Raspberry Pi and the BeMicro MAX10 for SPI
■■Note Before making any connection between two boards, make sure both of them are powered off and
connect the ground between the two boards first! The jumper J1 and jumper J9 on the BeMicro MAX10 board
provide a selection of 2.5V or 3.3V for the pin header 5 (J5). Both of them need to be set to 3.3V. (Figure 15-3 in
the lower right corner shows the correct jumper locations: near the edge of the board.) Pin 39 on the Raspberry
Pi and J5 pin 12 on the BeMicro MAX10 are both grounds.
348
Chapter 15 ■ Two-Way Communications with Your Raspberry Pi: SPI
Figure 15-3. SPI slave example wires set up with Raspberry Pi SPI 0 CE1 Master
349