Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ios / vera / ras / siodmu_err_mon.vr
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: siodmu_err_mon.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 <vera_defines.vrh>
#include <VeraListProgram.vrh>
#include <ListMacros.vrh>
#include "ios_err_packet.vrh"
#include "ios_rasmon.if.vrh"
#include "ios_rasmon_ports_binds.vrh"
#include "std_display_class.vrh"
#include "siu_common.vrh"
ExternVeraList(ios_err_packet);
class siodmu_err_mon {
siodmu_errmon_port siodmu;
local VeraList_ios_err_packet err_list;
StandardDisplay dbg;
local string myname;
task new(siodmu_errmon_port siodmu, StandardDisplay dbg);
task input_mon();
task report_mon();
function integer errlist_size() { errlist_size = err_list.size(); }
}
task siodmu_err_mon::new(siodmu_errmon_port siodmu, StandardDisplay dbg)
{
integer i;
this.siodmu = siodmu;
this.dbg = dbg;
this.myname = "sio-dmu rasmon";
err_list = new();
fork { input_mon(); } join none
fork { report_mon(); } join none
}
task siodmu_err_mon::report_mon()
{
ios_err_packet err_pkt;
SocErr_Type err_type[3];
string err_msg[3];
bit [2:0] dmuncu_rpt;
integer i, found;
integer monitor_on = 1;
VeraListIterator_ios_err_packet list_ptr;
err_type[0] = SIODMU_DP; err_msg[0] = "data pe";
err_type[1] = SIODMU_CCE; err_msg[1] = "ctag ce";
err_type[2] = SIODMU_CUE; err_msg[2] = "ctag ue";
if (get_plus_arg(CHECK, "sio_dmu_ras_chk_off")){
monitor_on = 0;
}
while (monitor_on)
{
@(posedge siodmu.$clk);
dmuncu_rpt = {siodmu.$ctag_ue, siodmu.$ctag_ce, siodmu.$d_pe};
if (dmuncu_rpt !== 3'b000 && dmuncu_rpt !== 3'bxxx)
{
if (err_list.empty())
dbg.dispmon(myname, MON_ERR, psprintf("dmu report unexpected errors!"));
else
for (i=0; i<3; i++)
if (dmuncu_rpt[i] !== 0)
{
list_ptr = err_list.start();
err_pkt = list_ptr.data();
found = 0;
while (err_pkt != null && !found)
{
if (err_pkt.type == err_type[i])
{
list_ptr = err_list.erase(list_ptr);
dbg.dispmon(myname, MON_NORMAL, psprintf("matched! dmu report %s!", err_msg[i]));
found = 1;
}
else
list_ptr.next();
if (list_ptr != null)
err_pkt = list_ptr.data();
}
if (!found)
dbg.dispmon(myname, MON_NORMAL, psprintf("dmu report unexpected %s!", err_msg[i]));
}
}
}
}
task siodmu_err_mon::input_mon()
{
bit [15:0] cur_ctag;
bit [5:0] cur_cecc;
bit [5:0] my_cecc;
bit [127:0] cur_data;
bit [127:0] tmp_data;
bit [7:0] tmp_parity;
integer i, j, cce, cue, dpe;
ios_err_packet err_pkt;
while (1)
{
@(posedge siodmu.$clk);
if (siodmu.$req === 1'b1)
{
cce = 0;
cue = 0;
dpe = 0;
dbg.dispmon(myname, MON_INFO, psprintf("capture sio-dmu valid"));
// verify the ecc
cur_ctag = siodmu.$data[79:64];
my_cecc = gen_ctag_ecc(cur_ctag);
cur_cecc = siodmu.$data[61:56];
for (i=0; i<6 && cce<2; i++)
cce += (cur_cecc[i] !== my_cecc[i]) ? 1 : 0;
if (cce == 1)
{
dbg.dispmon(myname, MON_NORMAL, psprintf("capture sio-dmu ctag ce get %x, exp %x", cur_cecc, my_cecc));
err_pkt = new(SIODMU_CCE, cur_ctag, 40'h8000000000);
err_list.push_back(err_pkt);
}
if (cce > 1)
{
dbg.dispmon(myname, MON_NORMAL, psprintf("capture sio-dmu ctag ue get %x, exp %x", cur_cecc, my_cecc));
err_pkt = new(SIODMU_CUE, cur_ctag, 40'h8000000000);
err_list.push_back(err_pkt);
}
// for read, verify the data parity
if (siodmu.$data[125] === 1'b1)
{
for (i=0; i<4 && !dpe; i++)
{
@(posedge siodmu.$clk);
cur_data = siodmu.$data;
tmp_parity[7:6] = interleave_parity(cur_data[127:96], 32);
tmp_parity[5:4] = interleave_parity(cur_data[95:64], 32);
tmp_parity[3:2] = interleave_parity(cur_data[63:32], 32);
tmp_parity[1:0] = interleave_parity(cur_data[31:0], 32);
if (tmp_parity !== siodmu.$parity)
{
dpe = 1;
dbg.dispmon(myname, MON_NORMAL, psprintf("capture sio-dmu data parity error get %x exp %x", siodmu.$parity, tmp_parity));
err_pkt = new(SIODMU_DP, cur_ctag, 40'h8000000000);
err_list.push_back(err_pkt);
}
}
}
}
}
}