Microchip_UG0693_Image_Edge_Detection_IP_User_Guide
Microchip_UG0693_Image_Edge_Detection_IP_User_Guide
User Guide
Image Edge Detection
Microsemi makes no warranty, representation, or guarantee regarding the information contained herein or the suitability of
its products and services for any particular purpose, nor does Microsemi assume any liability whatsoever arising out of the
application or use of any product or circuit. The products sold hereunder and any other products sold by Microsemi have
been subject to limited testing and should not be used in conjunction with mission-critical equipment or applications. Any
performance specifications are believed to be reliable but are not verified, and Buyer must conduct and complete all
performance and other testing of the products, alone and together with, or installed in, any end-products. Buyer shall not
Microsemi Headquarters
rely on any data and performance specifications or parameters provided by Microsemi. It is the Buyer’s responsibility to
One Enterprise, Aliso Viejo, independently determine suitability of any products and to test and verify the same. The information provided by Microsemi
CA 92656 USA hereunder is provided “as is, where is” and with all faults, and the entire risk associated with such information is entirely
Within the USA: +1 (800) 713-4113 with the Buyer. Microsemi does not grant, explicitly or implicitly, to any party any patent rights, licenses, or any other IP
Outside the USA: +1 (949) 380-6100 rights, whether with regard to such information itself or anything described by such information. Information provided in this
Sales: +1 (949) 380-6136 document is proprietary to Microsemi, and Microsemi reserves the right to make any changes to the information in this
Fax: +1 (949) 215-4996 document or to any products and services at any time without notice.
Email: [email protected]
www.microsemi.com
About Microsemi
©2021 Microsemi, a wholly owned Microsemi, a wholly owned subsidiary of Microchip Technology Inc. (Nasdaq: MCHP), offers a comprehensive portfolio of
subsidiary of Microchip Technology Inc. All semiconductor and system solutions for aerospace & defense, communications, data center and industrial markets.
rights reserved. Microsemi and the Products include high-performance and radiation-hardened analog mixed-signal integrated circuits, FPGAs, SoCs and
Microsemi logo are registered trademarks of ASICs; power management products; timing and synchronization devices and precise time solutions, setting the world's
Microsemi Corporation. All other trademarks standard for time; voice processing devices; RF solutions; discrete components; enterprise storage and communication
and service marks are the property of their solutions, security technologies and scalable anti-tamper products; Ethernet solutions; Power-over-Ethernet ICs and
respective owners. midspans; as well as custom design capabilities and services. Learn more at www.microsemi.com.
1 Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Revision 5.0 .......................................................................1
1.2 Revision 4.0 .......................................................................1
1.3 Revision 3.0 .......................................................................1
1.4 Revision 2.0 .......................................................................1
1.5 Revision 1.0 .......................................................................1
3 Hardware Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.1 Write LSRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.2 Read LSRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.3 Sobel Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.1 Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.2 Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.3 IP Configurator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 Timing Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.1 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.1.1 Encrypted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.1.2 RTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
6 Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.1 Simulation Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
7 Simulation Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
8 Resource Utilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1 Revision History
The revision history describes the changes that were implemented in the document. The changes are
listed by revision, starting with the most current publication.
Image Edge Detection is an image processing method for feature detection and extraction. This method
is used to identify points in a digital image where the brightness changes sharply and discontinues. The
edge detection method reduces the amount of data in an image and preserves the structural properties
for further processing. In a gray level image, the edge is a local feature with in a neighborhood separate
regions.The gray level is more or less uniform with in different values on the two sides of the edge. For a
noisy image, it is difficult to detect edges as both edge and noise contains high frequency contents, which
results in blurred and distorted images.
Microsemi offers the Image Edge Detection IP that enables designers to use the edge detection for
image processing.
The Image Edge Detection IP implements Sobel filter, which is a classical algorithm in the field of image
and video processing for the extraction of object edges. Sobel filter works on the premise of computing
an estimate of the first derivative of an image to extract the edge information. By computing the x and y
direction derivatives of a specific pixel against a neighborhood of surrounding pixels, it is possible to
extract the boundary between two distinct elements in an image. Due to the computational load of
calculating derivatives using the squaring and square root operators, fixed coefficient masks are adopted
as a suitable approximation in computing the derivative at a specific point. In the case of Sobel, the
masks used are shown in the following figure.
Figure 1 • Sobel Operator Horizontal and Vertical Kernels
-1 0 1 1 2 1
-2 0 2 0 0 0
-1 0 1 -1 -2 1
These kernels can be combined together to find the absolute magnitude of the gradient at each point.
The gradient magnitude is computed using:
2 2
G = Gx + Gy
This is much faster to compute. The Sobel operator has the advantage of simplicity in calculation.
3 Hardware Implementation
The following figure shows the Image Edge Detection block diagram.
Figure 2 • Image Edge Detection Block Diagram
RESETN_I
SYS_CLK_I
DATA_VALID_O
DATA_VALID_I Write LSRAM Read LSRAM Sobel Filter
3x3
DATA_I Data
Matrix DATA_O
3 x LSRAM
As shown in Figure 2, page 4, the Image Edge Detection IP consists of the following subsystems:
4 Interfaces
This section describes the input/output ports and the configuration parameters of the Image Edge
Detection IP.
4.1 Ports
The following table lists the input and output ports.
Table 2 • Input and Output Ports for AXI4 Stream Video Interface
Name Description
Data Width Width of each pixel
RAM Size Size of the RAM to store one horizontal line
Choose values which are powers of 2, such as 2048, and 4096
Video Interface Native Video Interface and AXI4 Stream Video Interface
4.3 IP Configurator
The IP configurator is shown in the following figure.
Figure 3 • IP Configurator
5 Timing Diagram
The following figures show the timing diagram of the Image Edge Detection IP.
Figure 4 • Timing Diagram of Edge Detection Showing Valid Input and Output Data
5.1 License
Image Edge Detection clear RTL is license locked, and the encrypted RTL available for free.
5.1.1 Encrypted
Complete RTL code is provided for the core, allowing it to be instantiated with the SmartDesign tool.
Simulation, synthesis, and layout can be performed within Libero® System-on-Chip (SoC). The RTL code
is encrypted for the core.
5.1.2 RTL
Complete RTL source code is provided for the core.
6 Testbench
A testbench is provided to check the functionality of the Image Edge Detection IP. The following table lists
the parameters that can be configured according to the application.
Name Description
CLKPERIOD Clock Period
HEIGHT Height of the image
WIDTH Width of the image
WAIT Amount of delay after each line of input image
DATAWIDTH Width of each pixel
IMAGE_FILE_NAME Input image name
2. Enter a name for the SmartDesign testbench as shown in the following figure.
Figure 6 • Naming the Testbench
3. Go to the Catalog tab and in search bar type "edge". After that, drag the Image Edge Detection IP to
the testbench canvas. The Image Edge Detection IP is highlighted in the following figure.
Figure 7 • IP Location
4. After dragging the IP to the testbench canvas, the IP appears as shown in the following figure.
Figure 8 • Instantiation of the IP
5. Select all of the ports and promote them to top level using the Promote to Top Level option, as
shown in the following figure.
Figure 9 • Promote the Ports to Top Level
6. The ports are promoted to the top level, as shown in the following figure.
Figure 10 • Ports Promoted to Top-level
8. Go to the Files tab and select simulation > Import Files as shown in the following figure.
Figure 12 • The Import Files Option
Note: To import a different file, browse the folder that contains the required file, and click Open.
10. Go to the Stimulus Hierarchy tab and select edge_detection_test (edge_detection_tb.v) >
Simulate Pre-Synth Design > Open Interactively. The core is simulated for one frame.
11. ModelSim opens with the testbench file as shown in the following figure.
Figure 15 • ModelSim Simulation Window
If the simulation is interrupted due to the runtime limit specified in the DO file, use the run -all
command to complete the simulation.
The testbench output image file appears in the Files/simulation folder after the simulation
completes.
7 Simulation Result
This section shows an image before and after being processed using the Image Edge Detection IP.
The following figure shows the input image.
Figure 16 • Input Image
The following figure shows the output image after being processed using the Image Edge Detection IP.
Figure 17 • Output Image
8 Resource Utilization
Resource Usage
DFFs 384
4LUTs 671
LSRAM 3
MACC 0
Resource Usage
DFFs 400
4LUTs 713
RAM1K18 3
RAM64x18 0
MACC 0