otsdaq_prepmodernization  v2_05_02_indev
bmg_tb_pkg.vhd
1 
2 --------------------------------------------------------------------------------
3 --
4 -- BLK MEM GEN v7_3 Core - Testbench Package
5 --
6 --------------------------------------------------------------------------------
7 --
8 -- (c) Copyright 2006_3010 Xilinx, Inc. All rights reserved.
9 --
10 -- This file contains confidential and proprietary information
11 -- of Xilinx, Inc. and is protected under U.S. and
12 -- international copyright and other intellectual property
13 -- laws.
14 --
15 -- DISCLAIMER
16 -- This disclaimer is not a license and does not grant any
17 -- rights to the materials distributed herewith. Except as
18 -- otherwise provided in a valid license issued to you by
19 -- Xilinx, and to the maximum extent permitted by applicable
20 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
21 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
22 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
23 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
24 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
25 -- (2) Xilinx shall not be liable (whether in contract or tort,
26 -- including negligence, or under any other theory of
27 -- liability) for any loss or damage of any kind or nature
28 -- related to, arising under or in connection with these
29 -- materials, including for any direct, or any indirect,
30 -- special, incidental, or consequential loss or damage
31 -- (including loss of data, profits, goodwill, or any type of
32 -- loss or damage suffered as a result of any action brought
33 -- by a third party) even if such damage or loss was
34 -- reasonably foreseeable or Xilinx had been advised of the
35 -- possibility of the same.
36 --
37 -- CRITICAL APPLICATIONS
38 -- Xilinx products are not designed or intended to be fail-
39 -- safe, or for use in any application requiring fail-safe
40 -- performance, such as life-support or safety devices or
41 -- systems, Class III medical devices, nuclear facilities,
42 -- applications related to the deployment of airbags, or any
43 -- other applications that could lead to death, personal
44 -- injury, or severe property or environmental damage
45 -- (individually and collectively, "Critical
46 -- Applications"). Customer assumes the sole risk and
47 -- liability of any use of Xilinx products in Critical
48 -- Applications, subject only to applicable laws and
49 -- regulations governing limitations on product liability.
50 --
51 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
52 -- PART OF THIS FILE AT ALL TIMES.
53 
54 --------------------------------------------------------------------------------
55 --
56 -- Filename: bmg_tb_pkg.vhd
57 --
58 -- Description:
59 -- BMG Testbench Package files
60 --
61 --------------------------------------------------------------------------------
62 -- Author: IP Solutions Division
63 --
64 -- History: Sep 12, 2011 - First Release
65 --------------------------------------------------------------------------------
66 --
67 --------------------------------------------------------------------------------
68 -- Library Declarations
69 --------------------------------------------------------------------------------
70 
71 
72 LIBRARY IEEE;
73 USE IEEE.STD_LOGIC_1164.ALL;
74 USE IEEE.STD_LOGIC_ARITH.ALL;
75 USE IEEE.STD_LOGIC_UNSIGNED.ALL;
76 
77 PACKAGE BMG_TB_PKG IS
78 
79  FUNCTION DIVROUNDUP (
80  DATA_VALUE : INTEGER;
81  DIVISOR : INTEGER)
82  RETURN INTEGER;
83  ------------------------
84  FUNCTION IF_THEN_ELSE (
85  CONDITION : BOOLEAN;
86  TRUE_CASE : STD_LOGIC_VECTOR;
87  FALSE_CASE : STD_LOGIC_VECTOR)
88  RETURN STD_LOGIC_VECTOR;
89  ------------------------
90  FUNCTION IF_THEN_ELSE (
91  CONDITION : BOOLEAN;
92  TRUE_CASE : STRING;
93  FALSE_CASE :STRING)
94  RETURN STRING;
95  ------------------------
96  FUNCTION IF_THEN_ELSE (
97  CONDITION : BOOLEAN;
98  TRUE_CASE : STD_LOGIC;
99  FALSE_CASE :STD_LOGIC)
100  RETURN STD_LOGIC;
101  ------------------------
102  FUNCTION IF_THEN_ELSE (
103  CONDITION : BOOLEAN;
104  TRUE_CASE : INTEGER;
105  FALSE_CASE : INTEGER)
106  RETURN INTEGER;
107  ------------------------
108  FUNCTION LOG2ROUNDUP (
109  DATA_VALUE : INTEGER)
110  RETURN INTEGER;
111 
112 END BMG_TB_PKG;
113 
114 PACKAGE BODY _BMG_TB_PKG IS
115 
116  FUNCTION DIVROUNDUP (
117  DATA_VALUE : INTEGER;
118  DIVISOR : INTEGER)
119  RETURN INTEGER IS
120  VARIABLE DIV : INTEGER;
121  BEGIN
122  DIV := DATA_VALUE/DIVISOR;
123  IF ( (DATA_VALUE MOD DIVISOR) /= 0) THEN
124  DIV := DIV+1;
125  END IF;
126  RETURN DIV;
127  END DIVROUNDUP;
128  ---------------------------------
129  FUNCTION IF_THEN_ELSE (
130  CONDITION : BOOLEAN;
131  TRUE_CASE : STD_LOGIC_VECTOR;
132  FALSE_CASE : STD_LOGIC_VECTOR)
133  RETURN STD_LOGIC_VECTOR IS
134  BEGIN
135  IF NOT CONDITION THEN
136  RETURN FALSE_CASE;
137  ELSE
138  RETURN TRUE_CASE;
139  END IF;
140  END IF_THEN_ELSE;
141  ---------------------------------
142  FUNCTION IF_THEN_ELSE (
143  CONDITION : BOOLEAN;
144  TRUE_CASE : STD_LOGIC;
145  FALSE_CASE : STD_LOGIC)
146  RETURN STD_LOGIC IS
147  BEGIN
148  IF NOT CONDITION THEN
149  RETURN FALSE_CASE;
150  ELSE
151  RETURN TRUE_CASE;
152  END IF;
153  END IF_THEN_ELSE;
154  ---------------------------------
155  FUNCTION IF_THEN_ELSE (
156  CONDITION : BOOLEAN;
157  TRUE_CASE : INTEGER;
158  FALSE_CASE : INTEGER)
159  RETURN INTEGER IS
160  VARIABLE RETVAL : INTEGER := 0;
161  BEGIN
162  IF CONDITION=FALSE THEN
163  RETVAL:=FALSE_CASE;
164  ELSE
165  RETVAL:=TRUE_CASE;
166  END IF;
167  RETURN RETVAL;
168  END IF_THEN_ELSE;
169  ---------------------------------
170  FUNCTION IF_THEN_ELSE (
171  CONDITION : BOOLEAN;
172  TRUE_CASE : STRING;
173  FALSE_CASE : STRING)
174  RETURN STRING IS
175  BEGIN
176  IF NOT CONDITION THEN
177  RETURN FALSE_CASE;
178  ELSE
179  RETURN TRUE_CASE;
180  END IF;
181  END IF_THEN_ELSE;
182  -------------------------------
183  FUNCTION LOG2ROUNDUP (
184  DATA_VALUE : INTEGER)
185  RETURN INTEGER IS
186  VARIABLE WIDTH : INTEGER := 0;
187  VARIABLE CNT : INTEGER := 1;
188  BEGIN
189  IF (DATA_VALUE <= 1) THEN
190  WIDTH := 1;
191  ELSE
192  WHILE (CNT < DATA_VALUE) LOOP
193  WIDTH := WIDTH + 1;
194  CNT := CNT *2;
195  END LOOP;
196  END IF;
197  RETURN WIDTH;
198  END LOG2ROUNDUP;
199 
200 END BMG_TB_PKG;