Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuEhbErrPEUStr.vr
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: ilupeuEhbErrPEUStr.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 ============================================
class EhbErrPEUStr extends PEUStrBase
{
integer f_errQueue; // A mailbox for bad pkt headers
integer f_len; // The packet's payload length
bit f_lenSpecified; // Was a length specified?
bit[4:0] f_type; // The packet's type
bit f_typeSpecified; // Was a type specified?
bit[3:0] f_mask; // Which bits to flip?
task new( PEUTestEnv a_env )
{
super.new( a_env );
f_errQueue = 0;
f_lenSpecified = 0;
f_typeSpecified = 0;
f_mask = 4'b0;
}
task SetErrQueue( integer a_queue )
{
f_errQueue = a_queue;
} /* end SetErrQueue */
task SetLength( integer a_len )
{
f_len = a_len;
f_lenSpecified = 1;
} /* end SetLength */
task SetType( integer a_type )
{
f_type = a_type;
f_typeSpecified = 1;
} /* end SetType */
task SetMask( bit[3:0] a_mask )
{
f_mask = a_mask;
} /* end SetMask */
task Execute()
{
bit[PEC_PCI__HDR] egressHdr; // The egress TLP's header
integer egressData; // A payload descriptor
bit[7:0] tlpTag; // The tag for the TLP
bit[7:0] egressAddr; // The DOU starting address
bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header
integer ingressData; // A payload descriptor
bit[3:0] errMask;
bit hdrOnly;
if ( f_mask != 0 )
errMask = f_mask;
else
errMask = urandom()%15 + 1;
if ( f_lenSpecified && f_len == 0 )
hdrOnly = 1;
else if ( f_lenSpecified )
hdrOnly = 0;
else
hdrOnly = urandom() % 2;
// Build a TLP, using the specified
// type and length, if any.
if ( !f_typeSpecified )
{
randcase
{
4 : { f_type = PEC_PCI__TYPE_MEM; {if( hdrOnly ) f_len = urandom()%4 + 1;
else f_len = urandom()%2 + 1;} }
1 : { f_type = PEC_PCI__TYPE_CFG0; f_len = 1; }
1 : { f_type = PEC_PCI__TYPE_CFG1; f_len = 1; }
1 : { f_type = PEC_PCI__TYPE_IO; f_len = 1; }
1 : { f_type = PEC_PCI__TYPE_CPL; f_len = urandom()%32 + 1; }
}
}
else if ( !f_lenSpecified || f_len == 0 )
{
if ( f_type == PEC_PCI__TYPE_CPL )
f_len = urandom()%32 + 1;
else if ( (f_type == PEC_PCI__TYPE_MEM) && hdrOnly )
f_len = urandom()%4 + 1;
else if ( (f_type == PEC_PCI__TYPE_MEM) && !hdrOnly )
f_len = urandom()%2 + 1;
else
f_len = 1;
}
// If a completion (with data) was
// requested, then base it on a DMA
// read request (which we won't submit).
if ( f_type == PEC_PCI__TYPE_CPL )
{
f_env.allocDmaTag( tlpTag );
f_env.genIngressRdReq( tlpTag, ingressHdr, ingressData, f_len );
f_env.genEgressCpl( ingressHdr, egressHdr, egressData );
f_env.allocCplData( ingressHdr[PEC_PCI__LEN],
egressHdr[PEC_PCI__LOWADDR],
egressAddr );
}
// If a PIO-write was requested,
// then get a tag and push a config
// write through, just to be sure that
// the tag isn't already in the pipe.
else if ( !hdrOnly )
{
f_env.allocWrTag( tlpTag, egressAddr );
f_env.genEgressWrReq( tlpTag, egressHdr, egressData,
1, PEC_PCI__TYPE_CFG0 );
f_env.driveILU( egressHdr, egressAddr, egressData );
f_env.expectPCIE( egressHdr, egressData );
f_env.genIngressCpl( egressHdr, ingressHdr, ingressData );
f_env.drivePCIE( ingressHdr, ingressData );
f_env.expectILU( ingressHdr, ingressData );
f_env.genEgressWrReq( tlpTag, egressHdr, egressData, f_len, f_type );
}
else
{
f_env.allocRdTag( tlpTag );
f_env.genEgressRdReq( tlpTag, egressHdr, egressData, f_len, f_type );
}
// Present the TLP to the ILU, and
// specify that parity errors are to
// be injected into the EHB.
// We aren't going to release the tag
// so that only one error is injected.
f_env.injectEHBerror( tlpTag, errMask );
f_env.driveILU( egressHdr, egressAddr, egressData );
// We can't expect the TLP from the TLU
// since it is corrupted. But we do
// expect to enter the "drain state".
f_env.enterDrainState();
// fork
// f_env.expectPCIE( egressHdr, egressData );
// join none
f_env.waitDrainState();
// Tell the error-checker about this
// bad-boy.
if ( f_errQueue != 0 )
{
mailbox_put( f_errQueue, e_ERR_oe_ehp );
mailbox_put( f_errQueue, 128'hx );
}
} /* end Execute */
} /* end EhbErrPEUStr */