SPI Protocol

SPI Protocol Overview

SPI (Serial Peripheral Interface) is a synchronous, full-duplex communication protocol used for high-speed data exchange over short distances. It follows a master–slave architecture with four primary signals:

Bits are shifted out on MOSI and shifted in on MISO on each clock edge, according to the configured clock polarity (CPOL) and phase (CPHA).

Creating the Project in ChipInventor

4. Click Create.

Blocks Used

Block

Function

spi_master

Generates SCLK, MOSI, and CS_n; sends incremental byte values

spi_slave

Samples MOSI on SCLK rising edge; outputs data_valid pulse

data_register

Synchronously latches input d into q when load = 1

LEDs

Displays the 8-bit output from the register

Slave Blocks: On one workstation, instantiate and configure the spi_slave and data_register blocks. Record a GIF showing:

Master Block: On a separate workstation, instantiate and configure the spi_master block. Record a GIF that demonstrates:

 

Top-Level Connections

In this project, the FPGA Master and FPGA Slave are interconnected as follows:

Simulation

1. Go to the Simulate tab and select Advanced Simulation.

2. Run Iverilog.

3. Check the console for compilation errors.

4. In the waveform viewer, monitor key signals:

5. Confirm that on each deassertion of CS_n, eight bits are received, data_valid pulses, and data_out matches the transmitted byte.

 

FPGA Synthesis and Programming

 

Hardware Validation

 

Wrapping Up

Congratulations! You have developed a complete SPI communication project using the ChipInventor platform.

Now that you understand the SPI protocol, you can expand this knowledge and implement communication with other sensors and devices.