color space conversion ip...rgb to ycbcr converter supports rgb 6 bits,8 bits and 10 bits to ycbcr...

19
User Guide of Color Space Conversion IP Color Space Conversion IP User Guide 12/2014 Capital Microelectronics, Inc. China

Upload: others

Post on 23-Jan-2021

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

Color Space Conversion IP

User Guide

12/2014

Capital Microelectronics, Inc.

China

Page 2: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 2

Contents

Contents ................................................................................................................................................. 2

1 Introduction ..................................................................................................................................... 3

2 Color Space Conversion IP Overview .................................................................................................. 4

2.1 RGB to YCbCr Converter Overview .................................................................................................... 4

2.1.1 RGB to YCbCr converter Interface ............................................................................................... 4

2.1.2 RGB to YCbCr converter Block Diagram ....................................................................................... 4

2.2 YCbCr to RGB Converter Overview .................................................................................................... 5

2.2.1 YCbCr to RGB Converter Interface .............................................................................................. 5

2.2.2 YCbCr to RGB Converter Block Diagram....................................................................................... 6

3 Color Space Conversion IP Usage ....................................................................................................... 8

3.1 Color Space ..................................................................................................................................... 8

3.1.1 The RGB Color Space ................................................................................................................. 8

3.1.2 The YCbCr Color Space .............................................................................................................. 8

3.1.3 Conversion Equations and Parameterized Design ......................................................................... 8

3.2 Color Space Conversion IP Instantiation ............................................................................................ 9

3.3 Interface Timing ............................................................................................................................ 12

3.3.1 The RGB to YCbCr Converter Interface Timing ........................................................................... 12

3.3.2 The YCbCr to RGB Converter Interface Timing ........................................................................... 12

3.4 Resource Usage and Performance................................................................................................... 13

4 Generate File Directory Structure .................................................................................................... 15

4.1 M7 Color Space Conversion IP File Directory ................................................................................... 15

4.2 M5 Color Space Conversion IP File Directory ................................................................................... 16

4.3 HR3 Color Space Conversion IP File Directory .................................................................................. 17

Revision History .................................................................................................................................... 19

Page 3: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 3

1 Introduction

Color Space Conversion IP can complete RGB to YCbCr conversion and YCbCr to RGB conversion. The

Converter is a simplified 3*3 matrix multiplier that converts three input color samples to three output

samples in certain delay. The Color Space Conversion Reference Design is widely parameterizable and can

support custom color space conversion. meanwhile, to facilitate easy insertion to practical video systems,

the design takes up to three video stream control signals (H_SYNC, V_SYNC and DEN) and delays them

appropriately.

Feature

Support 6bits, 8bits and 10bits input data

Unsigned input data

Pipelined implementation

Configurable DSP block based or look-up-table (LUT) based multiplier implementations

Support RGB to YCbCr and YCbCr to RGB color conversion

Parameterized coefficients

Device family support:

CME-M7, CME-M5, CME-HR3

Page 4: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 4

2 Color Space Conversion IP Overview

Color space conversion is required when transferring data between devices that use different color space

models. The detailed design of CME color space conversion IP is followed.

2.1 RGB to YCbCr Converter Overview

This part is mainly describes the design of RGB to YCbCr converter.

2.1.1 RGB to YCbCr converter Interface

RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is

listed in table 2-1.

Table 2-1 RGB to YCbCr Interface

Name Direction Width Description

i_CLK Input 1 Input Pixel Clock

i_RST Input 1 Asynchronous active high system reset

i_PIX_DEN Input 1 Data Enable(RGB valid) synchronized with pixel clock

i_H_SYNC Input 1 Horizontal Sync

i_V_SYNC Input 1 Vertical Sync

i_Red[9:0] Input 6~10 Red component of Pixel

i_Green[9:0] Input 6~10 Green component of Pixel

i_Blue[9:0] Output 6~10 Blue component of Pixel

o_PIX_DEN Output 1 YCbCr Data valid synchronized with pixel clock

o_H_SYNC Output 1 Pipelined Horizontal Sync

o_V_SYNC Output 1 Pipelined Vertical Sync

o_Y[9:0] Output 6~10 Converted Y Component

o_Cb[9:0] Output 6~10 Converted Cb Component

o_Cr[9:0] Output 6~10 Converted Cr Component

2.1.2 RGB to YCbCr converter Block Diagram

System Block Diagram

The System block diagram of RGB to YCbCr Converter is showed in figure 2-1.

Page 5: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 5

RGB to YCbCr ConverterRGB to YCbCr ConverterRGB

Source

RGB

Source YCbCr DeviceYCbCr Device

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

i_CLK

i_RST

i_PIX_DEN

i_V_SYNC

i_H_SYNC

i_Red[9:0]

i_Green[9:0]

i_Bule[9:0]

o_PIX_DEN

o_V_SYNC

o_Y[9:0]

o_Cb[9:0]

o_Cr[9:0]

o_H_SYNC

Figure 2-1 System Block Diagram of RGB to YCbCr Converter

Functional Block Diagram

Considering the large amount of data path involved here, a pipelined implementation is provided to improve

the performance. The procedure of computing Y, Cb and Cr values is followed in figure 2-2. The MIN value is

set 0 and the MAX value is set 10’h3ff.

Figure 2-2 Functional Block Diagram

2.2 YCbCr to RGB Converter Overview

This part is mainly describes the design of YCbCr to RGB converter.

2.2.1 YCbCr to RGB Converter Interface

YCbCr to RGB Converter supports YCbCr to RGB color conversion, it support 6bits, 8bits and 10bits data

width .The interface is listed in table 2-2.

Page 6: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 6

Table 2-2 YCbCr to RGB Interface

Name Direction Width Description

i_PIX_CLK Input 1 Input Pixel Clock

i_RESET_B Input 1 Active High asynchronous system reset

i_PIX_DEN Input 1 Synchronous Data Enable(YCbCr valid)

i_PIX_HSYNC Input 1 Horizontal Sync

i_PIX_VSYNC Input 1 Vertical Sync

i_PIX_FID Input 1 Input Frame ID(odd/even field indicator)

i_Y[9:0] Input 6~10 Y component of Pixel

i_Cr[9:0] Input 6~10 Cr component of Pixel

i_Cb[9:0] Input 6~10 Cb component of Pixel

o_RGB_DEN Output 1 RGB Data valid

o_RGB_HSYNC Output 1 Pipelined Horizontal Sync

o_RGB_VSYNC Output 1 Pipelined Vertical Sync

o_RGB_FID Output 1 Output Odd/Even field indicator(pipelined)

o_R_DATA[9:0] Output 6~10 Converted Red pixel

o_G_DATA[9:0] Output 6~10 Converted Green pixel

o_B_DATA[9:0] Output 6~10 Converted Blue pixel

2.2.2 YCbCr to RGB Converter Block Diagram

System Block Diagram

The System block diagram of YCbCr to RGB Converter is showed in figure 2-3.

YCbCr to RGB ConverterYCbCr to RGB ConverterYCbCr

Source

YCbCr

Source RGB DeviceRGB Device

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

IOBIOB

i_PIX_CLK

i_RESET_B

i_PIX_DEN

i_PIX_VSYNC

i_PIX_HSYNC

i_Y[9:0]

i_Cb[9:0]

i_Cr[9:0]

o_RGB_DEN

o_RGB_VSYNC

o_R_DATA[9:0]

o_G_DATA[9:0]

o_B_DATA[9:0]

o_RGB_HSYNC

IOBIOBi_PIX_FID

IOBIOB o_RGB_FID

Figure 2-3 System Block Diagram

Functional Block Diagram

Considering the large amount of data path involved here, a pipelined implementation is provided here to

improve the performance. The procedure of computing R, G and B values is showed in figure 2-4, The MIN

value is set 0 and the MAX value is set 10’h3ff .Video synchronization signals will be delayed for controlling

Page 7: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 7

signals synchronized with the output RGB stream.

Figure 2-4 Functional Block Diagram

Page 8: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 8

3 Color Space Conversion IP Usage

3.1 Color Space

3.1.1 The RGB Color Space

The red, green and blue (RGB) color space is widely used throughout computer graphics. Red, green and blue

are three primary additive colors: individual components are added together to form a desired color and are

represented by a three dimensional. Red, Green and Blue have a nominal range of 0-255,Table 3-1 presents

the RGB values for 100% saturated color bars, a common video test.

Table 3-1 Common Video Test Color

Range White Yellow Cyan Green Magenta Red Blue Black

R 0~255 255 255 0 0 255 255 0 0

G 0~255 255 255 255 255 0 0 0 0

B 0~255 255 0 255 0 255 0 255 0

The RGB color space is the most prevalent choice for computer graphics because color displays use red, green

and blue to create the desired color. Also, a system that is designed using the RGB color space can take

advantage of a large number of existing software algorithms.

However, RGB is not very efficient when dealing with real-world images. All three components need equal

bandwidth to generate arbitrary colors within the RGB color cube. Also, processing an image in the RGB color

space is usually not the most efficient method. For example, to modify the intensity or color of a given pixel,

all three RGB values must be read, modified and written back to the frame buffer. If the system had access to

the image stored in the intensity and color format, the process would be faster.

3.1.2 The YCbCr Color Space

The YCbCr color space was developed as part of the ITU-R BT.601 during the development of a world-wide

digital component video standard. YCbCr is a scaled, offset version of the YUV color space. Y has a nominal

range of 16-235; Cb and Cr have a nominal range of 16-240. There are several YCbCr sampling formats, such

as 4:4:4, 4:2:2 and 4:2:0.

3.1.3 Conversion Equations and Parameterized Design

The RGB to YCbCr Conversion Equations

The equation of converting RGB to YCbCr, consisting of one luma component(Y) representing brightness and

two chroma components (Cb and Cr) is the following conversion expressions:

Y = 16 + (0.257 * Red) + (0.504 * Green) + (0.098 * Blue)

Cb = 128 + (-0.148 * Red) + (-0.291 * Green) + (0.439 * Blue)

Page 9: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 9

Cr = 128 + (0.439 * Red) + (-0.368 * Green) + (-0.071* Blue)

The initialized Parameters is followed:

Red_coef0 = 0. 257*2^8;

Green_coef0 = 0.504*2^8;

Blue_coef0 = 0.098*2^8;

Coef_constant0 =16*2^8;

Red_coef1 = 0.148*2^8;

Green_coef1 =0.291*2^8;

Blue_coef1 =0.439*2^8;

Coef_constant1 = 128*2^8;

Red_coef2 = 0.439*2^8;

Green_coef2 =0.368*2^8;

Blue_coef2 =0.071*2^8;

Coef_constant2 = 128*2^8;

The YCbCr to RGB Conversion Equations

The Equation of converting YCbCr to RGB is the following conversion expressions:

R = 1.164(Y-16) + 1.596(Cr-128)

G = 1.164(Y-16) - 0.813(Cr-128) - 0.392(Cb-128)

B = 1.164(Y-16) + 2.017(Cb-128)

The initialized parameter configured is followed:

Y_coef0 = 1.164*2^8;

Cr_coef0 = 1.569*2^8;

Y_constant = 16;

Y_coef1 = Y_coef0;

Cb_coef1 = 0.392*2^8;

Cr_coef1 = 0.813*2^8;

Cb_constant = 128;

Y_coef2 = Y_coef1;

Cb_coef2 = 2.017*2^8;

Cr_constant = 128;

3.2 Color Space Conversion IP Instantiation

Color Space Conversion IP instantiation flow is showed in following steps.

Step 1: Open the Wizard Manager and choose Color Space Conversion IP.

Page 10: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 10

Figure 3-1 Wizard Manager

Step 2: Click “Next” tags and input user name.

Figure 3-2 Color Space Conversion IP Wizard Manager (1)

Step 3: Click “Next” tags and configure the Color Space Conversion IP parameters according to user needs.

Page 11: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 11

Figure 3-3 Color Space Conversion IP Wizard Manager (2)

Converter Mode: RGB2YCbCr and YCbCr2RGB. When RGB2YCbCr is selected, the Wizard is showed in

figure 3-3 ; When YCbCr2RGB is selected, the Wizard is showed in figure 3-4.

Data Width: Support 6bits, 8 bits and 10 bits.

Luma offset and Chroma offset: The default value of Luma offset and Chroma offset is showed in table 3-2,

the values can be modified according to needs.

Table 3-2 The Default Luma Offset And Chroma Offset Value

Data Width Luma offset Chroma offset

6 bits 4 32

8 bits 16 128

10 bits 64 512

DSP Enabled: M7 and M5 support DSP enabled and disabled, HR3 only support DSP disabled

Page 12: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 12

Figure 3-4 YCbCr2RGB Wizard

3.3 Interface Timing

3.3.1 The RGB to YCbCr Converter Interface Timing

The interface timing of RGB to YCbCr converter is followed in figure 3-5 :

Figure 3-5 The Interface Timing Of RGB To YCbCr Converter

3.3.2 The YCbCr to RGB Converter Interface Timing

The interface timing of YCbCr to RGB converter is followed in figure 3-6:

Page 13: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 13

Figure 3-6 The Interface Timing Of YCbCr To RGB Converter

3.4 Resource Usage and Performance

Color Space Conversion IP is suitable for CME-M7, CME-M5 and CME-HR3, The performance and resources

usage in different chips is listed in table 3-3 and table 3-4.

Table 3-3 Color Space Conversion IP Performance

Function Device DSP_Block_en Performance

RGB to YCbCr

M7 0 130

1 230

M5 0 140

1 200

HR3 0 60

YCbCr to RGB

M7 0 130

1 230

M5 0 140

1 200

HR3 0 60

Table 3-4 Color Space Conversion IP Resource Usage

Function Data Width DSP_Block_en LUTs Regs MAC

RGB to YCbCr

6 0 770 800 0

1 180 160 9

8 0 790 800 0

1 190 220 9

10 0 820 810 0

Page 14: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 14

1 190 220 9

YCbCr to RGB

6 0 520 540 0

1 120 210 5

8 0 530 550 0

1 130 230 5

10 0 560 560 0

1 160 230 5

Page 15: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 15

4 Generate File Directory Structure

4.1 M7 Color Space Conversion IP File Directory

The Color Space Conversion IP wizard for M7 generated file includes: source files (src), simulation files(sim),

and related document. The detailed design directory structure is showed in figure 4-1.

Project

src outputs ip_core

ip_top.v(define by user)

*.v

simsrc doc

m7s_sim.v

file_list.f

csc_tb.do*.vp (Protected RTL)

CME_Color_Space_Conversion_user_guide_EN01.pdf

Color_Space_Conversion_v1

src_vp

csc_tb.vhd

= directory

= source RTL code

= simulation related files

= documentation

sim_m7

Figure 4-1 IP Wizard Generated File Directory Structure

Table 4-1 Generated File Directory structure

Directory Description

src\ Directory for project source code, including IP

wizard generate code.

ip_core\ The directory specially for all IPs

\Color_Space_Conversion_v1 Directory for Color Space Conversion IP

\doc

\CME_Color_Space_Conversion

_user_guide_EN01.doc

User guide for Color Space Conversion IP

\src IP Design RTL

\*.v Color Space Conversion IP Verilog file

\sim

\m7s_sim.v M7 simulation document

\sim_m7

\csc_tb.v Test bench of Color Space Conversion IP

\file_list.f ModelSim simulation related files

Page 16: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 16

\csc_tb.do Do script for ModelSim simulation

\src_vp Protected design RTL for ModelSim simulation

\*.vp Color Space Conversion IP related Verilog file

4.2 M5 Color Space Conversion IP File Directory

The Color Space Conversion IP wizard for M5 generated file includes: source files (src), simulation files(sim),

and related document. The detailed design directory structure is showed in figure 4-2.

Project

src outputs ip_core

ip_top.v(define by user)

*.v

simsrc doc

CME3_sim.v

file_list.f

csc_tb.do*.vp (Protected RTL)

CME_Color_Space_Conversion_user_guide_EN01.pdf

Color_Space_Conversion_v1

src_vp

csc_tb.vhd

= directory

= source RTL code

= simulation related files

= documentation

sim_m5

Figure 4-2 IP Wizard Generated File Directory Structure

Table 4-2 Generated File Directory Structure

Directory Description

src\ Directory for project source code, including IP

wizard generate code.

ip_core\ The directory specially for all IPs

\Color_Space_Conversion_v1 Directory for Color Space Conversion IP

\doc

\CME_Color_Space_Conversion

_user_guide_EN01.doc

User guide for Color Space Conversion IP

\src IP Design RTL

\*.v Color Space Conversion IP Verilog file

\sim

\CME3_sim.v M5 simulation document

\sim_m5

\csc_tb.v Test bench of Color Space Conversion IP

\file_list.f ModelSim simulation related files

\csc_tb.do Do script for ModelSim simulation

Page 17: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 17

\src_vp Protected design RTL for ModelSim simulation

\*.vp Color Space Conversion IP related Verilog file

4.3 HR3 Color Space Conversion IP File Directory

The Color Space Conversion IP wizard for HR3 generated file includes: source files (src), simulation files(sim)

and related document. The detailed design directory structure is showed in figure 4-3.

Project

src outputs ip_core

ip_top.v(define by user)

*.v

simsrc doc

l3_sim.v

file_list.f

csc_tb.do*.vp (Protected RTL)

CME_Color_Space_Conversion_user_guide_EN01.pdf

Color_Space_Conversion_v1

src_vp

csc_tb.vhd

= directory

= source RTL code

= simulation related files

= documentation

sim_hr3

Figure 4-3 IP Wizard Generated File Directory Structure

Table 4-3 Generated File Directory Structure

Directory Description

src\ Directory for project source code, including IP

wizard generate code.

ip_core\ The directory specially for all IPs

\Color_Space_Conversion_v1 Directory for Color Space Conversion IP

\doc

\CME_Color_Space_Conversion

_user_guide_EN01.doc

User guide for Color Space Conversion IP

\src IP Design RTL

\*.v Color Space Conversion IP Verilog file

\sim

\l3_sim.v HR3 simulation document

\sim_hr3

\csc_tb.v Test bench of Color Space Conversion IP

\file_list.f ModelSim simulation related files

\csc_tb.do Do script for ModelSim simulation

Page 18: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 18

\src_vp Protected design RTL for ModelSim simulation

\*.vp Color Space Conversion IP related Verilog file

Page 19: Color Space Conversion IP...RGB to YCbCr Converter supports RGB 6 bits,8 bits and 10 bits to YCbCr color conversion. The interface is listed in table 2-1. Table 2-1 RGB to YCbCr Interface

User Guide of Color Space Conversion IP

http://www.capital-micro.com 19

Revision History

Revision Date Comments

1.0 2014-10-10 Initial release