8-bit SPI Master

Beginner
Sign in →
00:00
01General Operation

The SPI master generates the SCK clock by dividing the system clock (configurable via generic). A transaction starts on command and sends/receives a configurable number of bits in mode 0 (CPOL=0, CPHA=0). The module manages Slave Select and signals when busy.

Reset is synchronous and active-high.

  • SCK frequency is set by the g_CLK_DIV generic
  • Data is transmitted MSB first
02Interface

Generics:

  • g_CLK_DIV : positive (default 4) — System cycles per SCK half-period
  • g_DATA_WIDTH : positive (default 8) — Bits per frame

Ports:

SignalDirectionWidthDescription
i_clkInput1 bitSystem clock
i_rstInput1 bitSynchronous reset
i_startInput1 bitStart transaction
i_dataInputg_DATA_WIDTHData to transmit
o_sckOutput1 bitGenerated SPI clock
o_ss_nOutput1 bitActive-low Slave Select
o_mosiOutput1 bitMaster Out Slave In
i_misoInput1 bitMaster In Slave Out
o_dataOutputg_DATA_WIDTHReceived data
o_data_validOutput1 bitData valid pulse
o_busyOutput1 bitTransaction in progress