Programmable logic is great for signal processing thanks to its parallel nature. This means we can implement different processing stages at the same time from reception to filters and FFT.

In this project we are going to take a look at how we can use the Digilent Eclypse Z7 board along with the Zmod AWG and Zmod digitiser to implement a signal processing chain.

Unlike when we have done this in projects in the last we we will be focusing entirely on the PL and explaining the design decisions which go into the filter design also. My object is not just to show how the to create this project but for you to understand why it works also.

For this project we are going to be using Vivado 2022.2

Filters IntroductionFilters can be implemented very simply from a simple RC filter to more complex but still pretty simple active filters based around operational amplifiers e.g Sallen-Key. Indeed one of engineers first introductions to filters might be in the analog domain.

However, implementing filters in the digital domain if the ADC / DAC input bandwidth is wide enough offers several benefits. This includes frequency responses which would be difficult implement using analog methods and of course no drift of aging on passives, ease of modification and update in the field etc.

As any engineer will be aware there are four main types of filter; Low Pass which only allow signal below the predetermined cut off frequency. High Pass filters are the inverse of the Low Pass and will only allow frequencies above the cut off frequency through. Bandpass filters only allow through a pre determined bandwidth of frequencies preventing other frequencies. The final type of filter is Bandstop which is again the inverse of the Bandpass filter and therefore rejects a predetermined bandwidth while allowing all others to pass through.

Most basic digital filters are implemented in one of two methods Finite Impulse Response and Infinite Impulse Response, as you can see in this project we are implementing a FIR Filter.

The main difference between the two types of filter is the presence or lack of feedback, the absence of feedback within the FIR filter means that for a given input response the output of the filter will eventually settle to zero. An Infinite Impulse Response filter however, which does contain feedback will have a non-zero response.

The lack of feedback from the filter technology allows the FIR filter to be inherently stable as all of the filters poles are located at the origin.

If you where to asked to draw a diagram of the perfect low pass filter you would most engineers would draw a similar figure to that shown below.

The frequency response shown above is often called the “brickwall” filter as the transition from pass band to stop band is very abrupt and much sharper than can realistically be achieved, the frequency response also exhibits other “perfect” features such as the no pass band ripple and perfect attenuation in the stop band.

If you where to extend the diagram shown above such that it was symmetrical around 0 Hz extending out to both +/- FS Hz and performed a Inverse Discrete Fourier Transform (DFT) upon the response you would obtain the impulse response as shown below

This is the time domain representation of the frequency response of the perfect filter shown above. It is from this response that FIR or windowed SINC filters get their name as the impulse response is what is achieved if you plot the SINC function

Combined with the step response of the filter, these three responses— frequency, impulse and step—provide all the information on the filter performance you need to know to demonstrate that the filter under design will meet the requirements placed upon it.

*Frequency Response*

The frequency response is the traditional image engineers consider when thinking about a filter. It demonstrates how the filter modifies the frequency domain information. The frequency response allows you to observe the cutoff frequency, stopband attenuation and passband ripple. The roll-off between passband and stopband—often called the transition band—is also apparent in this response. Ripples in the passband will affect the signals being filtered. The stopband attenuation demonstrates how much of the unwanted frequencies remain within the filter output. This can be critical in applications where specific frequency rejection is required, for example when filtering one frequency-division multiplexed channel from another in a communications system.

*Impulse***Response**

It is from the impulse response that the coefficients for your filter are abstracted. However, to achieve the best performance from your filter, the standard practice is to use a windowing function. Windowing is the technique of applying an additional mathematical function to a truncated impulse response to reduce the undesired effects of truncation. The figures above demonstrates the impulse response extending out infinitely with ripples which, though they diminish significantly in amplitude, never settle at zero. Therefore, you must truncate the impulse response to N + 1 coefficients chosen symmetrically around the center main lobe, where N is the desired filter length (please remember that N must be an even number). This truncation affects the filter’s performance in the frequency domain due to the abrupt cutoff of the new, truncated impulse response. If you were to take a discrete Fourier transform (DFT) of this truncated impulse response, you would notice ripples in both the passband and stopband along with reduced roll-off performance. This is why it is common practice to apply a windowing function to improve the performance.

*Step**Response*

The step response, which is obtained by integrating the impulse response, demonstrates the time-domain performance of the filter and how the filter itself modifies this performance. The three parameters of importance when you are observing the step response are the rise time, overshoot and linearity. The rise time is the number of samples it takes to rise between 10 percent and 90 percent of the amplitude levels, demonstrating the speed of the filter. To be of use within your final system, the filter must be able to distinguish between events in the input signal; therefore, the step response must be shorter than the spacing of events in the signal. Overshoot is the distortion that the filter adds to the signal as it is processing it. Reducing the overshoot in the step response allows you to determine if the signal distortion results from either the system or the information that it is measuring. Overshoot reduces the uncertainty of the source of the distortion, degrading the final system performance, and possibly means the system does not meet the desired performance requirements. If the signal’s upper and lower halves are symmetrical, the phase response of the filter will have a linear phase, which is needed to ensure the rising edge and falling edge of the step response are the same. It is worth nothing at this point that is very difficult to optimize a filter for good performance in both the time and frequency domains. Therefore, you must understand which of those domains contains the information you are required to process. For FIR filters, the information required is within the frequency domain. Therefore, the frequency response tends to dominate.

*Windowing the Filter*

Using a truncated impulse response will not provide the best-performing digital filter, as it will demonstrate none of the ideal characteristics. For this reason, designers use windowing functions to improve the passband ripple, roll-off and stopband attenuation performance of the filter. There are many window functions that you can apply to the truncated sinc, for example Gaussian, Bartlett, Hamming, Blackman and Kaiser—the list goes on. However, two of the most popular window functions are the Hamming and Blackman. Let’s explore them in more detail. Both of these windows, when applied, reduce the passband ripple and increase the roll-off and attenuation of the filter. The figures below shows the impulse and frequency responses for a truncated sinc, and with Blackman and Hamming windows applied. As you can see, both windows significantly improve the passband ripple. The roll-off of the filter is determined not only by the window but by the length of the filter—that is, the number of coefficients, often called filter taps.

Hamming window:

**w[i] = 0.54 – 0.46 cos(2PI*i/N)**

Blackman window:

**w[i] = 0.42 – 0.52 cos (2PI*i/N) + 0.08 cos(4PI*i/N)**

Where I runs from 0 to N, providing a total of N + 1 points. To apply these windows to the truncated impulse response, you must multiply the window coefficients with the truncated impulse response coefficients to produce the desired filter coefficients.

While the window type determines the roll-off frequency, a rule of thumb is that for a desired transition bandwidth the number of taps required is indicated by

**N = 4 / BW**

where BW is the transition bandwidth.

Zmod Set upFor this project we will be using the Digilent Zmod AWG and the Zmod Digitizer. Both of these provide us with 14 bit resolution, while the AWG has a max sampling rate of 100MS/s and the Digitizer has a sampling rate of 125MS/s

On the Eclypse board the Digitizer will be connected to ZmodA and the AWG in ZmodB.

Before we can get started with including the Zmod in out design we need to first install the Digilent IP which provides simple and easy to use drivers for the AWG and Digitiser. These can be downloaded here once the library is downloaded unzip it and open Vivado as we are ready to start creating the design.

Once Vivado is open we are going to create a new project which targets the Eclypse board.

Once the project is created the next step is to add in the Digilent Libraries, this is achieved by opening the Vivado IP Library. Right click on add repository

Select the location of the extracted Vivado IP Library

This should find all of the IP cores in the library

The next step is to create the block diagram

Once the diagram is open we need to add in the following IP from the IP catalogue

- ZmodAWGController
- ZModDigitiserController
- Clocking Wizard connected to the 125MHz PL system clock
- Clocking Wizard for the DAC 90 degree clock
- Reset Block
- Utility Logic Vector
- Constant blocks
- FIR Compiler

Set the Clocking wizard to give out 100MHz on its output and connect it to the following on the ZmodAWG and ZmodDigitizer

- Sysclk100
- ClkGenPriRefClk

Connect the Digitzer ZmodDcoClkOut to the ZmodAWG DACInIOCLK this is the clock that the AXIS output data is synchronised with

Connect the Digitzer ZmodDcoClkOut to the second clock wizard and shift its phase by 90 degrees and connect it to the ZmodAWG DAC CLK input

Zmod DigitizerOn the ZMod Digitizer set the following IO to be external

- DacClkIN
- aCG PLL Lock - set this via the logic utility vector as an AND gate make the AND gate inputs external to GPIO1 and GPIO4 of the SYZYGY interface.
- diZmodADC_Data[13:0] - this is the double data rate parallel data bus from the DAC on the Zmd
- ZmodSync, ZmodSDIO, ZmodCS, ZmodCLK, ZmodCDCE_CLKP/N, REFEL, HW_SW_CTRL, PDN, and CDECIIC

On theZmod AWG set the following IO to be external

- ZmodCS, ZmodSDIO, ZmodCLK, Reset, SetFS1, SetFS2, EnOut
- DAC_CLKP/N,
- ZmodData[13:0]

Connect the Enables of both Zmod to '1' and set test mode to '0'

FIR Filter

Connect the output of the ZmodDigitiser AXIS stream to the FIR compiler input and the output from the FIR compiler to the ZmodAWG AXIS Input

This will give us functionality on Channel 2 of both the Zmods

The completed Diagram should look like below

The Zmod both work with a 32 bit vector on the AXIS bits 31-16 are channel 1 and 15-0 are channel 2. This design will therefore show the behaviour of the channel 2 only. However, to understand about filtering only one channel is needed.

The configurations of the IO blocks are as below

*Digitizer*

*AWG*

*Clocking Wizard*

**Clocking Wizard - phase shift**

*FIR Compiler*

The FIR Filter is set up as below - for the time being do not worry too much about the coefficients for the time being

The set up for the project is to connect the Zmod Digitizer to WaveGen out of the Analog Discovery Pro, while the output from the Zmod AWG is connected to the Analog Discovery Scope Input.

To design the filter we are going to use the free online filter software called T-Filter which is available here

Using T Filter we can define our filter and generate the quantised integer coefficients we need to store into FIR Compiler

Lets first define a filter which is going to act as a low pass filter. the Pass Band is 0 to 10 MHz, the stop band from 15 MHz to 50 MHz.

Remember we are sampling at 100MHz so that makes our maximum frequency we can sample 50MHz.

We can also control the attenuation of the signal in the filter design.

The coefficients for the filter are

`273`

234

47

-436

-1131

-1759

-1922

-1264

339

2650

5102

6975

7677

6975

5102

2650

339

-1264

-1922

-1759

-1131

-436

47

234

273

These can be entered into the FIR filter compiler, and the design implemented and bit stream programmed.

As we have two ILA in the design one before and one after the filter we are able to see the difference the filter makes on the analog signal.

We are also able to connect the output up to the analog discovery pro and see both the time domain and frequency domain output.

When we apply a 10 MHz tone we see the following output.

If we increase the frequency to 25MHz there is a much reduced level

If we wanted design a high pass filter in this case signals above 10 MHz should be passed those below rejected

Its coefficients are

`-2427`

1048

1044

1065

1001

756

276

-447

-1367

-2389

-3388

-4227

-4786

27785

-4786

-4227

-3388

-2389

-1367

-447

276

756

1001

1065

1044

1048

-2427

Setting a 1 MHz tone and looking at the output shows no output

We can confirm this looking at the ILA output of the filter

While the input signal looks

Setting 9 MHz input signal shows the signal being passed

Our final filter is a band pass filter

This will pass a signal between 5 and 10 MHz

The coefficients are

`237`

160

152

95

-6

-125

-230

-287

-277

-202

-87

29

106

120

75

4

-46

-28

76

249

435

553

534

340

-6

-426

-804

-1022

-1004

-746

-319

150

523

695

642

423

163

5

48

301

669

979

1039

717

-2

-983

-1970

-2655

-2776

-2208

-1020

532

2068

3191

3603

3191

2068

532

-1020

-2208

-2776

-2655

-1970

-983

-2

717

1039

979

669

301

48

5

163

423

642

695

523

150

-319

-746

-1004

-1022

-804

-426

-6

340

534

553

435

249

76

-28

-46

4

75

120

106

29

-87

-202

-277

-287

-230

-125

-6

95

152

160

237

`One`

of the best ways to test filters is with a wideband noise input, this should help you see the shape of the filter. The Analogue Discovery Pro is able to generate a noise output so I tried it with this filter.

Designing FPGA Filters is not hard and can be done very simply as this project has shown. Of course like everything there Filters can be much more complex however this project hopefully has given a good introduction to digital filter design.

## Comments