DIC Homework 4-Median Filter Engine Solved

35.00 $

Category:

Description

Rate this product

 

1 Introduction

The median filter is a non-linear digital filtering technique, which is often used to remove noise from an image or signal. Such noise reduction is a typical pre- processing step to improve the results of later processing (for example, edge detection on an image). In this homework, please implement an median filter engine (MFE), which uses median filter to convolve the image. The specification and function of MFE circuit will be described in detail in the following section.

2 Design Specifications 2.1 Block overview

Fig. 1 – System operation flow

2.2 I/O Interface

Name I/O
clk I 1

reset I 1 ready I 1

System clock signal. This system is synchronized with the positive edge of the clock.
Active-high asynchronous reset signal.
Grayscale image ready indication signal. When this

Width

Description

busy

signal is high, the grayscale image memory is already prepared. MFE can start sending grayscale image address to obtain the data.

1

System busy indication signal. When MFE receives high level ready signal and MFE is ready to start the calculation, this signal has to be set as high. After the calculation is completed and the result is completely output, set this signal to low and the testbench will start checking if the result is correct.

iaddr

O

O 14 I

I

O

O

O

The signal for grayscale image memory address, which is used to request grayscale image pixel date.

idata

data_rd

addr

data_wr

wen

8

Input grayscale image pixel data signal, which represents an 8 bits unsigned integer. The testbench will send the pixel data according to the address iaddr indicates.

8

Result memory read data signal, which represents an 8 bits unsigned integer. This signal is used to send the result memory data to MFE circuit.

14

Result memory read/write address.
This signal indicates which address of the result memory will be read or written.

8

Result memory write data signal, which represents an 8 bits unsigned integer. The operation result of the MFE circuit is written to result memory using this signal.

1

Result memory write enable signal.
When this signal is low (read), the data with address addr in result memory is sent by data_rd.
When this signal is high (write), the data sent by data_wr is written to the address addr in result memory.

2.3 Function Description

Input Image: 128x128x1

Zero padding Median Filter

Fig. 2 – Circuit operation flow

Result image

The size of the input image in this system is 128×128, which is stored in the grayscale image memory. The correspondence between each pixel of the grayscale image and memory arrangement is shown in Figure 4. In the operation process, the MFE circuit uses the iaddr signal to send the address of requested image data (as shown in Figure 3. t1 time point). After the negative edge of each clock, the pixel data at requested address will be sent into the MFE circuit by the idata signal (as shown in figure 3. t2 time point).

Fig. 3 – Timing diagram while reading grayscale image memory

8 bits

128 pixels

Pixel 0

Pixel 1

Pixel 2

Pixel 3

Pixel Pixel Pixel Pixel 012 127

Pixel 128

Pixel 16256

Pixel 129

Pixel 16257

16384 pixels

Pixel 16381

Pixel 16382

Pixel 16383

Fig. 4 – Arrangement mapping of input grayscale image and grayscale memory

Pixel 16383

128 pixels

The first step of the system is to perform zero-padding on the image to avoid size-changing of the image when doing MFE operation. Then the padded image is convolved with median filter to obtain result image. After the calculation is finished, the busy signal should be set to 0, and then testbench will start the verification process.

Fig. 5 – The median filtering operation.
In the reading phase, the addr signal represents the memory address of result

memory to read and the data_rd signal will provide the data. wen signal should be set as low. The timing diagram of result memory reading operation is shown in figure 6.

In the writing phase, the addr signal informs the memory address to be written and the data_wr signal should provide the writing data. wen signal should be set as high. The timing diagram of result memory writing operation is shown in figure 7.

Fig. 6 – Timing diagram of reading result memory.

Fig. 7 – Timing diagram of writing result memory.

3 Software Verification

You need to write a program to verify your circuit. You can write your program by using C, C++ and python. The requirements and functionality of this program should be as following:

  1. Be able to read any jpg image. The file path for reading has to be ./image.jpg.
  2. Convert RGB image to gray scale.
  3. Resize the image into 128×128.
  4. Add salt and pepper noise to the image.

    (You may set the probability of the noise to 0.02.)

  5. Process median filtering to the image with noise.
  6. Output the image with noise and the filtered image as img.dat and golden.dat,

    respectively. The format of the output files should be the same as the img.dat and golden.dat which TA gave. The output file should be able to be read by the testbench and simulate correctly.

  7. Please name your program in the format: main.c, main.cpp or main.py.

4 Scoring

4.1 Functional Simulation [40%]
All of the result should be generated correctly, and you will get the following

message in ModelSim simulation.

4.2

Gate Level Simulation [20%] 4.2.1Synthesis

Your code should be synthesizable. After it is synthesized in Quartus, a file named MFE.vo will be obtained.
4.2.2Simulation

All of the result should be generated correctly using MFE.vo, and you will get the following message in ModelSim simulation.

4.3
The performance is scored by the total logic elements, total memory bit, and

embedded multiplier 9-bit element your design used in gate-level simulation and the simulation time your design takes. The score will be decided by your ranking in all received homework. (The smaller, the better)

Scoring = (Total logic elements + total memory bit + 9*embedded multiplier 9- bit element) × (longest gate-level simulation time in ns)

4.4 Software Verification [20%]
All requirements have to be completed. TA will generate testing data with your

software program to verify your design. Please ensure your design can pass with the testing data which TA provided and the testing data generated by your software program.

Performance [20%]

5 Submission

5.1 Submitted files
You should classify your files into four directories and compress them to .zip

format. The naming rule is HW4_studentID_name.zip. If your file is not named according to the naming rule, you will lose five points.

*.v All of your Verilog RTL code

*.vo Gate-Level netlist generated by Quartus
*.sdo SDF timing information generated by Quartus

5.2 Report file
Please follow the spec of report. If your report does not meet the spec, you may

lose part of score. You are asked to describe how the circuit is designed as detailed as possible, and the flow summary result is necessary in the report. Please fill the field of total logic elements, total memory bits, and embedded multiplier 9-bit elements according to the flow summary of your synthesized design. And fill the field of gate-level simulation time according to the gate-level simulation result that Modelsim shows.

RTL category

Gate-Level category

Documentary category

*.pdf

The report file of your design (in pdf).

Verification category

*

The verification program.

5.3 Note
In this homework, you are allowed to modify the defined CYCLE in testbench

file. End_CYCLE, which decides the maximum cycles your circuit took to complete simulation, can also be modified according to your design. Please do not modify any other content of testbench.

  • DIC_HW4-kxlmmr.zip