Microchip UG0938 Gamma Correction IP User Guide
Microchip UG0938 Gamma Correction IP User Guide
User Guide
Gamma Correction
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: sales.support@microsemi.com
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
Microsemi logo are registered trademarks of Products include high-performance and radiation-hardened analog mixed-signal integrated circuits, FPGAs, SoCs and
Microsemi Corporation. All other trademarks ASICs; power management products; timing and synchronization devices and precise time solutions, setting the world's
and service marks are the property of their standard for time; voice processing devices; RF solutions; discrete components; enterprise storage and communication
respective owners. solutions, security technologies and scalable anti-tamper products; Ethernet solutions; Power-over-Ethernet ICs and
midspans; as well as custom design capabilities and services. Learn more at www.microsemi.com.
1 Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Revision 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Revision 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Supported Families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 Inputs and Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4 Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.1 IP Configurator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 Encrypted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 RTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 Simulation Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1 Timing Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Input Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3 Output Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5 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.
2 Introduction
A camera sensor converts the light intensity of a pixel into equivalent digital value. The digital value is
directly proportional to the light intensity of a pixel and hence has a linear relationship. However, a human
eye perceives the images as a logarithmic function of intensity instead of a linear function. If the images
from a camera sensor are directly displayed on a display device, then the scene will appear unnatural
because of the differences between the camera sensor and human eye perception. To compensate this,
the image from the camera sensor goes through the gamma correction.
Gamma correction uses an exponent function to compensate for the logarithmic perception by using the
below equation:
Dout = (Din)γ
Equation 1
where,
Dout represents output image data (RGB). Represented in the range of 0 to 1.
Din represents input image data (RGB). Represented in the range of 0 to 1.
γ represents the gamma correction factor. A fixed gamma correction factor of 0.4545 corresponding to a
gamma of 2.2 is implemented in the IP.
The Gamma correction IP is implemented using a LUT for exponent function.
The width of the input data determines the number of entries in the LUT. For example, 8-bit input data
would require 28 (256) entries in the LUT.
This section describes the inputs and outputs and configuration parameters of the Gamma Correction IP.
SYS_CLK_I
RESETN_I DATA_VALID_O
DATA_VALID_I RED_O
Gamma Correction
RED_I GREEN_O
GREEN_I BLUE_O
BLUE_I
The following table lists the input and output ports of the Gamma Correction IP.
Table 2 • Input and Output Ports for AXI4 Stream Video Interface
2.4.1 IP Configurator
The IP configurator is shown in the following figure.
Figure 2 • IP Configurator
3 Testbench
A testbench is provided to check the functionality of the Gamma Correction IP. To ensure that the
testbench works correctly, the configuration parameters listed in Table 4 must be configured at the
beginning of the testbench file.
Name Description
CLKPERIOD Clock period
g_DATAWIDTH Width of each pixel
HEIGHT Vertical resolution
WIDTH Horizontal resolution
IMAGE_FILE_NAME Input image file
3.1 License
Gamma-Correction clear RTL is license locked and the encrypted RTL available for free.
3.1.1 Encrypted
Complete RTL code is provided for the core, allowing the core to be instantiated with the SmartDesign
tool. Simulation, synthesis, and layout can be performed within Libero® System-on-Chip (SoC). The RTL
code for the core is obfuscated.
3.1.2 RTL
Complete RTL source code is provided for the core.
A testbench is provided to check the functionality of the Gamma-Correction IP. This testbench is working
only in Native Video Interface with a data width of 8.
The following steps describe how to simulate the core using the testbench. The packaged testbench will
gamma correct an input image.
1. In the Design Flow window, expand Create Design. Right-click Create SmartDesign testbench
and click Run, as shown in the following figure.
Figure 3 • Design Flow
SmartDesign testbench is created, and a canvas appears to the right of the Design Flow pane.
2. In the Libero SoC Catalog (View > Windows > Catalog), expand Solutions-Video, and drag the
Gamma-Correction IP core onto the SmartDesign testbench canvas.
Figure 4 • Libero SoC Catalog
9. Import the Input Image file “CFA_RGB_in.txt” from the following path:
..\<Project_name>\component\Microsemi\SolutionCore\Gamma-Correction\4.0.0\Stimulus. To
import a different file, browse the folder that contains the required file, and click Open. The imported
file is listed under simulation as shown in the following figure.
Figure 8 • Simulation
10. On Stimulus Hierarchy tab, right-click gamma_correction_test testbench file and click Open
Interactively from Simulate Pre-Synth Design.
Figure 9 • Stimulus Hierarchy
The ModelSim tool appears with the test bench file loaded onto it, as shown in the following figure.
Figure 10 • ModelSim tool
If the simulation is interrupted because of the runtime limit in the DO file, use the run -all command to
complete the simulation. By default, the output image file is placed in the Files/simulation directory and
uses the CFA_RGB_out.txt.
4 Simulation Results
5 Resource Utilization
Gamma correction is implemented on PolarFire FPGA (MPF500T -1FCG1152I package). The following
table shows the resource utilization report after synthesis.