// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: niu_intr_test_util.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
// ========== Copyright Header End ============================================
#include "niu_int_mgr.vrh"
#include "niu_int_dev.vrh"
extern CNiuIntrMgr NiuIntrMgr;
// CNiuIntrMgr NiuIntrMgr;
task setup_sid_tab(CNiuIntrDev dev,integer ldgno,integer type);
task programme_intmgr(CNiuIntrDev dev,integer ldgno, integer type, integer func_num);
task compute_sid(integer func_num, var bit [6:0] sid);
task intr_test_util :: new() {
if (get_plus_arg (CHECK,"INTR_GRPNUM="))
intr_grpnum = get_plus_arg(NUM,"INTR_GRPNUM=");
if (get_plus_arg (CHECK,"CMDL_GRPNUM="))
cmdl_grpnum = get_plus_arg(NUM,"CMDL_GRPNUM=");
NiuIntrMgr.initLdg(64'hffffffffffffffff); // Enable all LDG in Environment
NiuIntrMgr.SetTmrRes(100);
printf("Set Time resolution\n");
task intr_test_util :: setup_sid_tab(CNiuIntrDev dev,integer ldgno,integer type)
static integer tmp_grp_num = 0;
else if(intr_grpnum == 1)
else if(intr_grpnum == 2) {
} else if(intr_grpnum == 3) {
group_num = tmp_grp_num%64;
tmp_grp_num = tmp_grp_num + 16;
printf("Group number is %d for dev %d\n",group_num,dev.dev_id);
programme_intmgr(dev,group_num,1,func_num);
sid_tab[group_num].ldgno_bound = 1;
sid_tab[group_num].dev_bound[dev.dev_id] = 1;
task intr_test_util :: programme_intmgr(CNiuIntrDev dev,integer ldgno, integer type, integer func_num) {
if(sid_tab[ldgno].ldgno_bound) {
NiuIntrMgr.ldg[ldgno].SetIntrMgm(1/*Arm*/,10/*Timer*/);
NiuIntrMgr.ldg[ldgno].ldgbind(dev);
compute_sid(func_num,sid);
printf("Sid_table updated\n");
NiuIntrMgr.updateSidTab(ldgno,sid);
NiuIntrMgr.ldg[ldgno].SetIntrMgm(1/*Arm*/,10/*Timer*/);
NiuIntrMgr.ldg[ldgno].ldgbind(dev);
NiuIntrMgr.ldg[ldgno].rearm = 1;
task intr_test_util :: compute_sid(integer func_num, var bit [6:0] sid) {
static bit [31:0] mask = 32'h0;
if(mask[tmp_part_sid] == 0) {
// tmp_sid = {tmp_fn_num,tmp_part_sid};
sid = {tmp_fn_num,part_sid};