⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xil_rgb2ycrcb_sg_wrap.vhd

📁 基于FPGA的YUV转换RGB的色度空间转换
💻 VHD
字号:
--*******************************************************************-- Copyright(C) 2005 by Xilinx, Inc. All rights reserved.-- This text/file contains proprietary, confidential-- information of Xilinx, Inc., is distributed under license-- from Xilinx, Inc., and may be used, copied and/or-- disclosed only pursuant to the terms of a valid license-- agreement with Xilinx, Inc. Xilinx hereby grants you-- a license to use this text/file solely for design, simulation,-- implementation and creation of design files limited-- to Xilinx devices or technologies. Use with non-Xilinx-- devices or technologies is expressly prohibited and-- immediately terminates your license unless covered by-- a separate agreement.---- Xilinx is providing this design, code, or information-- "as is" solely for use in developing programs and-- solutions for Xilinx devices. By providing this design,-- code, or information as one possible implementation of-- this feature, application or standard, Xilinx is making no-- representation that this implementation is free from any-- claims of infringement. You are responsible for-- obtaining any rights you may require for your implementation.-- Xilinx expressly disclaims any warranty whatsoever with-- respect to the adequacy of the implementation, including-- but not limited to any warranties or representations that this-- implementation is free from claims of infringement, implied-- warranties of merchantability or fitness for a particular-- purpose.---- Xilinx products are not intended for use in life support-- appliances, devices, or systems. Use in such applications are-- expressly prohibited.---- This copyright and support notice must be retained as part-- of this text at all times. (c) Copyright 2005 Xilinx, Inc.-- All rights reserved.---- Title - Xil_RGB2YCrCb.vhd-- Author(s) - GZ & WCC, Xilinx-- Creation - 7 Dec 2005---- $RCSfile: Xil_RGB2YCrCb.vhd,v $ $Revision: 1.8 $ $Date: 2006/01/19 19:55:41 $---- ************************************************************************--  *008*   RGB2YCrCb Macro---- Description: Color Space Converter (RGB to YCrCb)---- Generalized conversion:-- Y  =   |   AC    (1-AC-BC)    BC   |   |R|    |Yoffset| -- Cr = CC| (1-AC)  (AC+BC-1)   -BC   | * |G| +  |Coffset|-- Cb = CD|  -AC    (AC+BC-1)  (1-BC) |   |B|    |Coffset|------ Refactored format conversion:-- Y  = AC*R + (1-AC-BC)*G + BC*B + Yoffset -- Cr = CC*(R-Y) +  Coffset-- Cb = CD*(B-Y) +  Coffset-- ITU 601 (SDTV):-- if RGB data is between 0 and 255 ---- Y  =  0.299 * R' + 0.587 * G' + 0.114 * B' + 0   -- Cr =  0.5   * R' - 0.419 * G' - 0.081 * B' + 0.5-- Cb = -0.169 * R' - 0.331 * G' + 0.5   * B' + 0.5------------------------------------------------------------------------- Refactoring:-- if RGB data is between 0 and 255 (R'G'B' are gamma corrected)---- Y   = 0.299 * (R' - G') + G' + 0.114 * (B' - G') -- Cr  = 0.713 * (R' - Y') + 0.5-- Cb  = 0.564 * (B' - Y') + 0.5---- ******************************************************************  library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_signed.all; LIBRARY work;USE work.color_space_pkg.all;LIBRARY work;USE work.genxlib_utils.ALL;entity Xil_RGB2YCrCb_sg is     generic (     FAMILY_HAS_MAC: integer:= 1;    FABRIC_ADDS   : integer:= 1; -- Adders are implemented using logic fabric based adders    IWIDTH        : integer:= 9;    CWIDTH        : integer:= 17; -- Coefficients are unsigned    MWIDTH        : integer:= 17;   -- Width of (B' - Y'_601) and (R' - Y'_601) data (data width at CCOEF and DCOEF multipliers)    OWIDTH        : integer:= 9;    YMAX          : integer:= 255;    YMIN          : integer:= 0;    CMAX          : integer:= 255;    CMIN          : integer:= 0;    YOFFSET       : integer:= 0;    COFFSET       : integer:= 128;    -- represent 0.5 in 9.7 format    ACOEF         : integer:= 613;    -- 0.29931    BCOEF         : integer:= 233;    -- 0.11376953125    CCOEF         : integer:= 1460;   -- 0.712890625    DCOEF         : integer:= 1155;   -- 0.56396484375    HAS_CLIP      : integer:= 1;     HAS_CLAMP     : integer:= 1);   port (                                   Y             : out std_logic_vector(OWIDTH-1 downto 0);  -- Y  = a(R-G) + G + b(B-G)    Cr            : out std_logic_vector(OWIDTH-1 downto 0);  -- Cr = d(R-Y)      Cb            : out std_logic_vector(OWIDTH-1 downto 0);  -- Cb = c(B-Y)    R             : in std_logic_vector(IWIDTH-1 downto 0);       G             : in std_logic_vector(IWIDTH-1 downto 0);    B             : in std_logic_vector(IWIDTH-1 downto 0);    V_SYNC_in     : in std_logic := '0';    H_SYNC_in     : in std_logic := '0';    PIX_EN_in     : in std_logic := '1';    V_SYNC_out    : out std_logic;    H_SYNC_out    : out std_logic;    PIX_EN_out    : out std_logic;    clk           : in std_logic;    ce            : in std_logic := '1';    en            : in std_logic := '1';    rst           : in std_logic := '0');end Xil_RGB2YCrCb_sg;    architecture rtl of Xil_RGB2YCrCb_sg is              component Xil_RGB2YCrCb    generic (       FAMILY_HAS_MAC: integer:= 1;      FABRIC_ADDS   : integer:= 1; -- Adders are implemented using logic fabric based adders      IWIDTH        : integer:= 9;      CWIDTH        : integer:= 17; -- Coefficients are unsigned      MWIDTH        : integer:= 17;   -- Width of (B' - Y'_601) and (R' - Y'_601) data (data width at CCOEF and DCOEF multipliers)      OWIDTH        : integer:= 9;      YMAX          : integer:= 255;      YMIN          : integer:= 0;      CMAX          : integer:= 255;      CMIN          : integer:= 0;      YOFFSET       : integer:= 0;      COFFSET       : integer:= 128;    -- represent 0.5 in 9.7 format      ACOEF         : integer:= 613;    -- 0.29931      BCOEF         : integer:= 233;    -- 0.11376953125      CCOEF         : integer:= 1460;   -- 0.712890625      DCOEF         : integer:= 1155;   -- 0.56396484375      HAS_CLIP      : integer:= 1;       HAS_CLAMP     : integer:= 1);     port (                                     Y             : out std_logic_vector(OWIDTH-1 downto 0);  -- Y  = a(R-G) + G + b(B-G)      Cr            : out std_logic_vector(OWIDTH-1 downto 0);  -- Cr = d(R-Y)        Cb            : out std_logic_vector(OWIDTH-1 downto 0);  -- Cb = c(B-Y)      R             : in std_logic_vector(IWIDTH-1 downto 0);         G             : in std_logic_vector(IWIDTH-1 downto 0);      B             : in std_logic_vector(IWIDTH-1 downto 0);      V_SYNC_in     : in std_logic := '0';      H_SYNC_in     : in std_logic := '0';      PIX_EN_in     : in std_logic := '1';      V_SYNC_out    : out std_logic;      H_SYNC_out    : out std_logic;      PIX_EN_out    : out std_logic;      clk           : in std_logic;      ce            : in std_logic := '1';      sclr          : in std_logic := '0');    end component;  signal ce_net: std_logic;begin  ce_net <= ce and en;    colorspaceRGB2YCrCb: Xil_RGB2YCrCb    generic map (      FAMILY_HAS_MAC  => FAMILY_HAS_MAC,      FABRIC_ADDS     => FABRIC_ADDS   ,      IWIDTH          => IWIDTH        ,       CWIDTH          => CWIDTH        ,      MWIDTH          => MWIDTH        ,      OWIDTH          => OWIDTH        ,      YMAX            => YMAX          ,      YMIN            => YMIN          ,      CMAX            => CMAX          ,      CMIN            => CMIN          ,      YOFFSET         => YOFFSET       ,      COFFSET         => COFFSET       ,      ACOEF           => ACOEF         ,      BCOEF           => BCOEF         ,      CCOEF           => CCOEF         ,      DCOEF           => DCOEF         ,      HAS_CLIP        => HAS_CLIP      ,      HAS_CLAMP       => HAS_CLAMP)    port map (      R               => R,      G               => G,      B               => B,
      V_SYNC_in       => V_SYNC_in,      H_SYNC_in       => H_SYNC_in,      PIX_EN_in       => PIX_EN_in,      V_SYNC_out      => V_SYNC_out,      H_SYNC_out      => H_SYNC_out,      PIX_EN_out      => PIX_EN_out,      clk             => clk,      ce              => ce_net,      sclr            => rst,      Y               => Y,      Cr              => Cr,      Cb              => Cb );end rtl;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -