This repository contains the implementation of an Arithmetic Logic Unit (ALU) reference model in C, which is called from a SystemVerilog testbench using Direct Programming Interface (DPI). The ALU performs a variety of operations such as addition, subtraction, multiplication, division, and bitwise operations. The outputs from the C-based reference model are compared with the outputs from the Design Under Test (DUT), ensuring correct behavior of the ALU.
The project demonstrates the following:
- C Reference Model: A simple ALU model implemented in C, which can handle 8-bit inputs and perform operations based on a 4-bit control signal (
ALU_Sel
). - DPI Integration: The ALU function in C is imported into the SystemVerilog testbench using DPI.
- Testbench: The testbench compares the expected values from the C model with the actual output from the hardware ALU implemented in SystemVerilog.
- Addition
- Subtraction
- Multiplication
- Division
- Logical Shift (Left/Right)
- Rotate (Left/Right)
- Logical AND, OR, XOR, NAND, NOR, XNOR
- Comparisons (Equal, Greater Than)
-
alu_reference_model.c:
Contains the C implementation of the ALU model. This function is invoked from the SystemVerilog testbench via DPI. -
alu_tb.sv:
The testbench that tests the ALU operations by calling the C function and comparing its results with the DUT output. -
alu.sv:
SystemVerilog implementation of the ALU (Design Under Test). -
Makefile (optional):
A Makefile for compilation and simulation, if applicable.
- The ALU operations are defined in the C function
alu_reference_model
. - This function is imported into the SystemVerilog testbench using DPI.
- The testbench applies a set of test vectors to both the hardware ALU and the C reference model.
- It compares the expected output from the C model with the actual output from the hardware ALU.
- The results (pass/fail) for each test are printed in the simulation output.
- Clone the repository:
git clone https://github.com/yourusername/alu-dpi-verification.git