Verilog SPI
Go to file
Peter McGoron d7f66bfe3d v0.3 2023-04-20 19:10:45 +00:00
tests add reset pin 2023-04-20 19:10:04 +00:00
.gitignore rewrite entire test harness 2022-10-22 18:34:54 -04:00
COPYING add COPYING 2022-07-21 02:37:34 -04:00
COPYING_OHL rewrite entire test harness 2022-10-22 18:34:54 -04:00
Makefile rewrite entire test harness 2022-10-22 18:34:54 -04:00
README.md add SS 2022-10-23 04:27:28 -04:00
spi_master.v v0.3 2023-04-20 19:10:45 +00:00
spi_master_no_read.v rewrite entire test harness 2022-10-22 18:34:54 -04:00
spi_master_no_write.v add read only master with tests 2022-07-21 13:52:51 -04:00
spi_master_ss.v add SS 2022-10-23 04:27:28 -04:00
spi_master_ss_no_read.v add SS 2022-10-23 04:27:28 -04:00
spi_master_ss_no_write.v add SS 2022-10-23 04:27:28 -04:00
spi_master_ss_template.v v0.3 2023-04-20 19:10:45 +00:00
spi_slave.v v0.3 2023-04-20 19:10:45 +00:00
spi_slave_no_read.v add read only master with tests 2022-07-21 13:52:51 -04:00
spi_slave_no_write.v rewrite entire test harness 2022-10-22 18:34:54 -04:00

README.md

Verilog SPI

Verilog SPI master and slave that supports all modes and variable width via parameters.

License

All code in this project is licensed to the terms of the Mozilla Public License, v.2.0. A copy of this license may be found in the file COPYING. You can obtain one at https://mozilla.org/MPL/2.0/.

All Verilog source in this project is dual-licensed under the MPL v2.0 and the CERN-OHL-W v2.0 (or any later version).

Tests

Run ./mk.sh in tests/ to generate and run tests.

Modules

"master_no_read" and "slave_no_write" have no Master In, Slave Out ("miso") wires (and no corresponding shift registers), while "master_no_write" and "slave_no_read" have no Master Out, Slave In ("mosi") wires. This is for compatability for "SPI compatible" devices that are read only.

"master_ss" and others include a timer that will assert the Slave Select pin and wait a set number of clock cycles before starting the SPI transfer.

SPI Modes

Modes are denoted by modePH, where P is the polarity (0 for normal, 1 for inverted) and H for phase:

  • H = 0 means the device reads on a rising edge and writes on a falling edge.
  • H = 1 means the device reads on a falling edge and writes on a rising edge.

Although these modules support all SPI modes, they are labeled slightly differently from other SPI modes. The phase factor is denoted in terms of falling and rising edges, not in terms of leading and trailing edges. This means that polarity also flips the phase term, so a mode 3 device is a mode 10 device. Devices with regular clock polarity are unaffected, so a mode 0 device is a mode 00 device, and a mode 1 device is a mode 01 device.