Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / fnx / vlib / FNXBasicUtilities / src / FNXArithUtil.vr
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: FNXArithUtil.vr
// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
//
// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// For the avoidance of doubt, and except that if any non-GPL license
// choice is available it will apply instead, Sun elects to use only
// the General Public License version 2 (GPLv2) at this time for any
// software where a choice of GPL license versions is made
// available with the language indicating that GPLv2 or any later version
// may be used, or where a choice of which version of the GPL is applied is
// otherwise unspecified.
//
// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
// CA 95054 USA or visit www.sun.com if you need additional information or
// have any questions.
//
// ========== Copyright Header End ============================================
#include "FNXArithUtilDefines.vri"
class FNXArithUtil {
integer Power2Array[16];
// Class constructor
task new() {
// Initialize the Power2Array. (to save time in doing the calculation)
Power2Array[0] = 1;
Power2Array[1] = 2;
Power2Array[2] = 4;
Power2Array[3] = 8;
Power2Array[4] = 16;
Power2Array[5] = 32;
Power2Array[6] = 64;
Power2Array[7] = 128;
Power2Array[8] = 256;
Power2Array[9] = 512;
Power2Array[10] = 1024;
Power2Array[11] = 2048;
Power2Array[12] = 4096;
Power2Array[13] = 8192;
Power2Array[14] = 16384;
Power2Array[15] = 32768;
}
// Calculates 2 ^ Y. Max value of Y is 'd16
function integer Power2(integer Y);
// Returns the min of X and Y
function integer Min(integer X, integer Y);
}
// Power2
function integer FNXArithUtil::Power2(integer Y) {
Power2 = Power2Array[Y];
}
// Min
function integer FNXArithUtil::Min(integer X, integer Y) {
if(X < Y) {
Min = X;
}
else {
Min = Y;
}
}