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

📄 genxlib_utils.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 - GenXlib_utils.vhd-- Author(s) - WC, Xilinx-- Creation - Jan 2006---- $RCSfile: GenXlib_utils.vhd,v $ $Revision: 1.4 $ $Date: 2006/01/20 00:33:10 $---- ************************************************************************LIBRARY ieee;USE ieee.std_logic_1164.ALL;  PACKAGE genxlib_utils IS-- ------------------------------------------------------------------------ -- TYPES:								    -- ------------------------------------------------------------------------   TYPE STD_LOGIC_VECTOR_ARRAY IS ARRAY ( NATURAL RANGE <>) OF std_logic_vector(256 downto 0);  TYPE INTEGER_ARRAY IS ARRAY(NATURAL RANGE<>) OF INTEGER; 	  -- ------------------------------------------------------------------------ -- FUNCTIONS:								    -- ------------------------------------------------------------------------     function LOG2_BASE(NUMBER:INTEGER) return integer;   function min( a: integer; b: integer)	return integer;  function max( a: integer; b: integer)	return integer;  function eval( condition: boolean)	return integer;  function when_int( condition: boolean; when_true: integer; when_false: integer)	return integer;  function yes_no( condition: integer) return string;	function MULT_DELAY(FAMILY_HAS_MAC: integer) return integer;	function ADD_DELAY(FAMILY_HAS_MAC: integer; fabric: integer) return integer;  function BRAM_DELAY(FAMILY_HAS_BRAMREG: integer) return integer;  function MULT_ADD_DELAY(FAMILY_HAS_MAC: integer; fabric: integer)return integer;END genxlib_utils;PACKAGE BODY genxlib_utils IS-- ------------------------------------------------------------------------   function eval( condition: boolean)	return integer is  begin    if (condition) then return 1; else return 0; end if;  end eval;  -- ------------------------------------------------------------------------   function yes_no( condition: integer) return string is  begin     if (condition=1) then return "yes"; else return "no"; end if;   end yes_no;-- ------------------------------------------------------------------------   function when_int( condition: boolean; when_true: integer; when_false: integer)	return integer is  begin     if (condition) then return when_true; else return when_false; end if;   end when_int;-- ------------------------------------------------------------------------   function min( a: integer; b: integer)	return integer is  begin     if (a<b) then return a; else return b; end if;   end min;-- ------------------------------------------------------------------------   function max( a: integer; b: integer)	return integer is  begin     if (a>b) then return a; else return b; end if;   end max;-- ------------------------------------------------------------------------ 	function MULT_DELAY(FAMILY_HAS_MAC: integer) return integer is   begin    return 2;     -- DSP48 based implementation, allows use of MREG and PREG    -- mult18x18s based implementation, takes advantage of buried register + adds a fabric register layer  end MULT_DELAY;-- ------------------------------------------------------------------------ 	function ADD_DELAY(FAMILY_HAS_MAC: integer; fabric: integer) return integer is  begin    if (fabric=1) OR (FAMILY_HAS_MAC = 0) then return 1; -- Fabric based solution        else return 2; -- DSP48 based implementation, allows use of AREG, PREG                               end if;  end ADD_DELAY;-- ------------------------------------------------------------------------   function BRAM_DELAY(FAMILY_HAS_BRAMREG: integer) return integer is  begin    return 2+ FAMILY_HAS_BRAMREG; -- read DELAY + dedicated output register +  fabric based output register                                  -- ADD ONE MORE IF YOU WANT TO INFER ADDR registers  end BRAM_DELAY;-- ------------------------------------------------------------------------   function MULT_ADD_DELAY(FAMILY_HAS_MAC: integer; fabric: integer) return integer is  begin--    if (FAMILY_HAS_MAC=1) and (fabric=0) then return 3;  -- MAC_DELAY--                          else return ADD_DELAY(FAMILY_HAS_MAC, fabric)+MULT_DELAY(FAMILY_HAS_MAC);   --    end if;    return 3;  end MULT_ADD_DELAY;-- ------------------------------------------------------------------------   FUNCTION LOG2_BASE(NUMBER:INTEGER)	RETURN INTEGER IS    VARIABLE INDEX 	: INTEGER := NUMBER;    VARIABLE SUM    : INTEGER := 1; 	BEGIN    		CASE INDEX IS			WHEN 1|2 => SUM := 1;			WHEN 3|4 => SUM := 2;			WHEN 5|6|7|8 => SUM := 3;			WHEN 9|10|11|12|13|14|15|16 => SUM := 4;			WHEN 17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32 => SUM := 5;			WHEN 33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64 => SUM := 6;			WHEN 65 to 128 => SUM := 7;			WHEN 129 to 256 => SUM := 8;   			WHEN 257 to 512 => SUM := 9;			WHEN 513 to 1024 => SUM := 10;			WHEN 1025 to 2048 => SUM := 11;			WHEN 2049 to 4096 => SUM := 12;			WHEN 4097 to 8192 => SUM := 13;			WHEN 8193 to 16384 => SUM := 14;			WHEN 16385 to 32786 => SUM := 15;			WHEN 32797 to 65536	=> SUM := 16;			WHEN 65537 to 131072 => SUM := 17;			WHEN 131073 to 262144 => SUM := 18;			WHEN 262145 to 524288 => SUM := 19;			WHEN 524289 to 1048576 => SUM := 20;			WHEN 1048577 to 2097152 => SUM := 21;			WHEN 2097153 to 4194304 => SUM := 22;			WHEN 4194305 to 8388608 => SUM := 23;			WHEN 8388609 to 16777216 => SUM := 24;			WHEN OTHERS => SUM := 25;			END CASE; 		RETURN SUM;    END LOG2_BASE;      END genxlib_utils;

⌨️ 快捷键说明

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