This project implements a Sobel Edge Detection Accelerator in Verilog. Milestone 1 focuses on the behavioral simulation and functional verification of the Sobel operator, ensuring accurate gradient computation before moving toward RTL synthesis and hardware implementation.
The Sobel operator detects edges by calculating the image intensity gradient at each pixel. It uses two 3x3 kernels to convolve with the original image:
-
Horizontal Gradient (
$G_x$ ): Detects vertical edges. -
Vertical Gradient (
$G_y$ ): Detects horizontal edges. -
Gradient Magnitude: Calculated as
$|G| = \sqrt{G_x^2 + G_y^2}$ (often approximated as$|G_x| + |G_y|$ in FPGA hardware to save resources). - Thresholding: The result is clipped to an 8-bit value for final display.
- Input: Grayscale Image (8-bit pixels,
.hexformat). - Output: Edge-detected Image (8-bit pixels,
.hexformat).
The verification process involves a hybrid approach using Python/MATLAB for pre-processing and Verilog for core computation:
- Pre-processing: Convert
input.pngtoinput01_image.hex(Verilog readable format) using a high-level script. - Verilog Simulation:
- The Testbench loads the
.hexfile into memory. - Pixels are fed into the
conv_test.vmodule. - Processed pixels are written back to
output.hex.
- The Testbench loads the
- Post-processing: Convert the resulting
output.hexback into a.pngfile to visualize the edges.
- Prepare Data: Generate the grayscale
.hexfile from your source image. - Setup Simulation: Save the reference image in the simulation directory:
Edge Detection Algorithm/Edge Detection Algorithm.sim/sim_1/behav/x_sim - Execute: Run the behavioral simulation in Vivado or ModelSim.
- Verify: Convert the generated
output.hexback into an image and compare it with your high-level reference model.
/Source code: Verilog source files (Sobel core, convolution logic)./Test code: Testbench for behavioral simulation./scripts: Python scripts for image-to-hex conversion./Summary: Simulation results and waveforms.
- Implementation based on the hardware architectures discussed in:
usmanwardag, “Implementation of Sobel Filter in Verilog,” GitHub, 2025.
Developed for EE587: Digital System and Design Synthesis.