Research article preview imageExperiment

FIR Filter SystemC Implementation

Arthur Mwang'onda
Arthur Mwang'onda
Author

Introduction

This project demonstrates the implementation of a Finite Impulse Response (FIR) filter using SystemC, a C++-based modeling platform widely used for hardware design and simulation. The FIR filter is designed to process digital signals by applying a set of predefined coefficients, producing filtered output signals based on the convolution of input data with these coefficients.

In addition to the filter implementation, the project includes a comprehensive testbench to simulate input signals, drive the filter, and verify the correctness of the output. The entire design is modular and written in a way that allows for easy modification and extension.

You can view and clone the full project on GitHub: https://github.com/arthurnamz/fir_filter

Project Structure

The source code is organized into several files, each responsible for a specific part of the system:

  • src/fir.cc: Contains the main implementation of the FIR filter logic.
  • src/fir.h: Header file that declares the FIR filter module and its interface.
  • src/tb.cc: Implements the testbench, which drives input data to the filter and captures the output.
  • src/tb.h: Declares the testbench module and its communication ports.
  • src/main.cc: The top-level simulation file. It connects the FIR filter and testbench, starts the simulation, and manages signal tracing.
  • src/Makefile: A Makefile to automate the build and run process. It includes targets to compile the project, execute the simulation, and compare results.

Each module communicates via SystemC channels, following hardware design principles.

How to Build the Project

To build and run this SystemC-based project, follow these steps:

1. Prerequisites

Ensure you have the SystemC library installed on your system. You can download it from the official Accellera website or install it through your package manager (if available).

2. Configure the Makefile

Open the Makefile in the src directory and set the SYSTEMC environment variable to point to the root of your SystemC installation. For example:

SYSTEMC=/path/to/systemc

3. Build the Project

Open a terminal in the src directory and run:

make

This will compile all source files and generate an executable named main.

Running the Simulation

Once the project is built successfully, you can run the simulation using:

./main

The simulation will execute the FIR filter logic using input signals generated by the testbench. The filtered output will be saved in a file called output.dat. This output can be used for further analysis or compared with a reference output to validate correctness.

Validating the Output

The project includes a feature to compare the simulation output against a known-good reference file to ensure that the filter is functioning correctly.

Steps:

  1. Ensure the reference output file ref_output.dat is located in the ./golden directory.
  2. Run the comparison command:
make cmp_result

This will check the contents of output.dat against golden/ref_output.dat. If they match, you'll see a message indicating the test passed; otherwise, it will report a failure and possibly show the differences.

Understanding the FIR Filter

The FIR filter works by applying a set of coefficients (also called taps) to the most recent set of input samples. The result is a weighted sum, where each weight corresponds to a coefficient.

The mathematical formula for an FIR filter is:

y[n] = b0*x[n] + b1*x[n-1] + ... + bN*x[n-N]

Where:

  • y[n] is the output at time step n
  • x[n] is the input at time step n
  • b0 to bN are the filter coefficients

This type of filter is widely used in digital signal processing because it is simple, stable, and has a linear phase response.

Conclusion

This project offers a clear and practical example of how to model a digital FIR filter using SystemC. It includes both the core filter logic and a testbench environment for simulation and validation.

Key highlights:

  • Modular and easy-to-understand structure
  • Automated build and test process
  • Suitable for learning and experimenting with digital filters in a hardware simulation context

Whether you're a student, a researcher, or a hardware engineer exploring SystemC, this project provides a solid foundation.

👉 GitHub Repository: https://github.com/arthurnamz/fir_filter

Feel free to explore the code, modify the filter coefficients, and experiment with different input signals. Contributions and suggestions are always welcome!