This repository contains a SystemVerilog verification testbench for an SPI (Serial Peripheral Interface) Master module. The testbench is designed to verify the functionality of the SPI Master by generating stimuli, driving transactions, monitoring the bus, and comparing results using a scoreboard.
The SPI module is the DUT (Device Under Test) and implements the SPI Master functionality. It includes an FSM (Finite State Machine) for handling different states such as idle and send. The module generates the clock (sclk), chip select (cs), and MOSI (mosi) signals.
The driver class is responsible for driving transactions into the SPI module. It includes tasks for resetting the driver and running transactions. The driver communicates with the SPI module through the virtual interface (vif).
The generator class generates random transactions and sends them to the driver for execution. It includes tasks for running the generator and utilizes mailboxes for communication between components.
The monitor class monitors the SPI bus, capturing data on the MOSI line during transactions. It communicates with the scoreboard through a mailbox.
The environment class orchestrates the entire verification environment. It instantiates the generator, driver, monitor, and scoreboard, connecting them through mailboxes. The class includes tasks for pre-test setup, running the test, and post-test actions.
The environment class orchestrates the entire verification environment. It instantiates the generator, driver, monitor, and scoreboard, connecting them through mailboxes. The class includes tasks for pre-test setup, running the test, and post-test actions.
The virtual interface (spi_if) defines the signals used for communication between the testbench components and the SPI module.
The transaction class defines the data structure representing SPI transactions. It includes fields for newd (new data), din (data in), cs (chip select), and mosi (Master Out Slave In). The class also includes display and copy functions.
- Initialize the virtual interface signals (
vif
). - Instantiate the SPI module (
spi
). - Instantiate the environment class (
environment
). - Configure the test parameters, such as the number of transactions, in the testbench.
- Run the testbench, which will execute the SPI transactions and perform verification.
The testbench is designed for simulation using SystemVerilog simulation tools. The testbench produces a VCD (Value Change Dump) file for waveform analysis.