Sign in

Not a member? | Forgot your Password?

Search code

Search tips

Free PDF Downloads

A Quadrature Signals Tutorial: Complex, But Not Complicated

Understanding the 'Phasing Method' of Single Sideband Demodulation

Complex Digital Signal Processing in Telecommunications

Introduction to Sound Processing

C++ Tutorial

Introduction of C Programming for DSP Applications

Fixed-Point Arithmetic: An Introduction

Cascaded Integrator-Comb (CIC) Filter Introduction

FIR Filter Design Software

See Also

Embedded SystemsFPGA

DSP Code Sharing > FPGA IIR Lowpass Direct Form I Filter Generator

FPGA IIR Lowpass Direct Form I Filter Generator

Language: Python

Processor: Not Relevant

Submitted by Christopher Felton on Aug 23 2011

Licensed under a Creative Commons Attribution 3.0 Unported License

FPGA IIR Lowpass Direct Form I Filter Generator


This code snippet illustrates how to use the SIIR object to genrate Verilog and VHDL for a Direct Form I IIR Lowpass filter.  More information available from this blog post and code for the SIIR object is available here.  

To use the generator download and install the dependencies, download the Python script, and either modify the script (bottom, main script execution) or execute the commands in the code snippet section. 


  * siir object (above link)
  * python 2.7 (tested with 2.7)
  * numpy (
  * scipy (
  * MyHDL (

Example Plots Generated; the designed filter response.

The simulated filter response.

After running the Convert method the Verilog and VHDL will be generated.  The Verilog or VHDL can then be used in normal FPGA process.


# Instantiate the SIIR object.  Pass the cutoff frequency
# Fc and the sample rate Fs in Hz.  Also define the input
# and output fixed-point type.  W=(wl, iwl) where
# wl = word-length and iwl = integer word-length.  This
# example uses 23 fraction bits and 1 sign bit.
>>> from siir import SIIR
>>> flt = SIIR(Fstop=1333, Fs=48000, W=(24,0))

# Plot the response of the fixed-point coefficients
>>> plot(flt.hz, 20*log10(flt.h)

# Create a testbench and run a simulation
# (get the simulated response)
>>> from myhdl import Simulation
>>> tb = flt.TestFreqResponse(Nloops=128, Nfft=1024)
>>> Simulation(tb).run()
>>> flt.PlotResponse()

# Happy with results generate the Verilog and VHDL
>>> flt.Convert()
Rate this code snippet:
Rating: 5 | Votes: 1
posted by Christopher Felton
Christopher Felton's current favorite projects are implementing DSP digital circuits with MyHDL for FPGAs. More information @ LinkedIn.


No comments yet for this code

Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )