How to create a Finite Impulse Response (FIR) Bandpass Filter, using Verilog in MATLAB

Abdullah Ansari

--

DIGITAL FILTERS:

Digital filters are commonly used in discrete signal processing to eliminate or preserve certain portions of the signal. Digital filters are divided into two categories which are Finite Impulse Response (FIR) and Infinite Impulse Response (IIR). The most common types of digital filters are following 

  1. Low pass filter
  2. High pass filter
  3. Bandpass filter

BANDPASS FILTER:

A bandpass filter is a device that allows frequencies within a specified range and ignores frequencies beyond that range.

CENTER FREQUENCY

The frequency at the center of the high cut-off frequency and low cut-off frequency is called the center frequency.

PASS BANDWIDTH

The difference between the high cut-off frequency and the low cut-off frequency is called pass bandwidth.

ANALOG BAND PASS FILTER:

Before we jump in to design a digital FIR band pass filter we should understand how an analog band pass filter works.

DIAGRAM

ANALOG BAND PASS FILTER

EXPLANATION

The analog band pass filter circuit is created by cascading a high pass filter and a low pass filter by choosing appropriate values of resistors and capacitors shown in the diagram. The high cut-off frequency is calculated by the formula fc1 = 1 / 2π*R1*C1. While the low cut-off frequency is calculated by the formula fc2 = 1 / 2π*R2*C2. By using the values of fc1 and fc2 we can calculate the pass bandwidth and center frequency of an analog band pass filter.

OUTPUT

OUTPUT

CALCULATIONS:

Here we will calculate fpass1, fpass2 and sampling frequency according to the given OBE requirements.

Here we found out that Fpass1 = 29500 Hz and Fpass2 = 30500 KHz, and if we use these values we gets a pass bandwidth of 1 KHz. 

  1. Fpass2 — Fpass1 = Bandwidth
  2. 30500–29500 = Bandwidth
  3. 1000 Hz = Bandwidth

To calculate sampling frequency we will use the Nyquist formula:

“it is necessary to use a sampling rate “fs” at least twice the highest waveform frequency.” 

  1. fpass = ½(fs)
  2. fs = 62000 Hz

We can apply a sampling frequency greater than or equal to 62000 Hz in our band pass filter.

FILTER DESIGN:

First, we will open Matlab and type the command “filterDesigner” in the command window. The filter Designer window appears as shown below.

Step 1

Now we will select options i.e. Response Type, Design Method, and Frequency Specifications according to the calculations we made earlier. By putting all the values we get a band pass filter of center frequency 30000 Hz as shown below.

Step 2

The impulse response of the bandpass filter.

Step 3

Now we will quantize the filter before generating its Verilog code.

Step 4

Now select Target => Generate HDL following dialog box appears we will select appropriate options and then click “Generate” button.

Step 5

Verilog code generation of our band pass filter starts as shown in the command window below.

Step 6

The Verilog code after being generated gets stored as shown below.

Step 6

RTL SCHEMATIC

The following RTL schematic is obtained after synthesizing the generated Verilog code.

SIMULATION

After running the simulation of the testbench file, we get the following timing diagram, which confirms that our band pass filter code is working correctly.

VERILOG CODE

The complete code can be found at:

https://github.com/AbdullahAnsarii/BandPassFilter

Also check out my portfolio website for more such projects at:
https://abdullahansari.me/

--

--

No responses yet