Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuIhbErrPEUStr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ilupeuIhbErrPEUStr.vr
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35class IhbErrPEUStr extends PEUStrBase
36 {
37 integer f_errQueue; // A mailbox for bad pkt headers
38 integer f_len; // The packet's payload length
39 bit f_lenSpecified; // Was a length specified?
40 bit[4:0] f_type; // The packet's type
41 bit f_typeSpecified; // Was a type specified?
42 bit[3:0] f_mask; // Which bits are in error?
43
44 task new( PEUTestEnv a_env )
45 {
46 super.new( a_env );
47 f_errQueue = 0;
48 f_lenSpecified = 0;
49 f_typeSpecified = 0;
50 f_mask = 4'b0;
51 }
52
53 task SetErrQueue( integer a_queue )
54 {
55 f_errQueue = a_queue;
56 } /* end SetErrQueue */
57
58 task SetLength( integer a_len )
59 {
60 f_len = a_len;
61 f_lenSpecified = 1;
62 } /* end SetLength */
63
64 task SetType( integer a_type )
65 {
66 f_type = a_type;
67 f_typeSpecified = 1;
68 } /* end SetType */
69
70 task SetMask( bit[3:0] a_mask )
71 {
72 f_mask = a_mask;
73 } /* end SetMask */
74
75 task Execute()
76 {
77 bit[PEC_PCI__HDR] egressHdr; // The egress TLP's header
78 integer egressData; // A payload descriptor
79 bit[7:0] tlpTag; // The tag for the TLP
80 bit[7:0] egressAddr; // The DOU starting address
81 bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header
82 integer ingressData; // A payload descriptor
83 bit[3:0] errMask;
84 bit[63:0] address;
85
86 if ( f_mask != 0 )
87 errMask = f_mask;
88 else
89 errMask = urandom()%15 + 1;
90
91
92 // Build a TLP, using the specified
93 // type and length, if any.
94 if ( !f_typeSpecified )
95 {
96 randcase
97 {
98 4 : { f_type = PEC_PCI__TYPE_MEM; f_len = urandom()%16 + 1; }
99 1 : { f_type = PEC_PCI__TYPE_MSG; f_len = 1; }
100 1 : { f_type = PEC_PCI__TYPE_CPL; f_len = urandom()%4 + 1; }
101 }
102 }
103
104 else if ( !f_lenSpecified )
105 {
106 if ( f_type == PEC_PCI__TYPE_CPL )
107 f_len = urandom()%4 + 1;
108 else if ( f_type == PEC_PCI__TYPE_MEM )
109 f_len = urandom()%16 + 1;
110 else
111 f_len = 1;
112 }
113
114 // If a completion (with data) was
115 // requested, then base it on a PIO
116 // read request.
117 if ( f_type == PEC_PCI__TYPE_CPL )
118 {
119 f_env.allocRdTag( tlpTag );
120 f_env.genEgressRdReq( tlpTag, egressHdr, egressData, f_len );
121 f_env.driveILU( egressHdr, 0, egressData );
122 f_env.expectPCIE( egressHdr, egressData );
123 f_env.genIngressCpl( egressHdr, ingressHdr, ingressData );
124 }
125 else
126 {
127 f_env.allocDmaTag( tlpTag );
128 if ( f_len == 0 )
129 f_env.genIngressRdReq( tlpTag, ingressHdr, ingressData );
130 else
131 f_env.genIngressWrReq( tlpTag, ingressHdr, ingressData, f_len );
132 }
133
134// Tweak a couple of parameters for IOS so it looks like a bypass packet
135#ifdef N2_IOS
136 ingressHdr[PEC_PCI__FMT_4DW] = 1;
137 address = ingressHdr[PEC_PCI__ADDR];
138 address[63:39] = 25'h1fff800;
139 ingressHdr[PEC_PCI__ADDR] = address;
140#endif
141
142 // Present the TLP to the TLU, and
143 // specify that parity errors are to
144 // be injected into the IHB.
145 // We aren't going to release the tag
146 // so that only one error is injected.
147 f_env.reserveIngressCredits( ingressHdr );
148 f_env.injectIHBerror( tlpTag, errMask );
149 f_env.drivePCIE( ingressHdr, ingressData );
150 f_env.consumeIngressCredits( ingressHdr );
151
152 // We can't expect the TLP from the ILU
153 // since it is corrupted. But we do
154 // expect to enter the "drain state".
155 f_env.enterDrainState();
156
157 // We have to wait for a bit before
158 // we can tell the error-checker
159 // about the problem.
160// f_env.waitIngressLatency( ingressHdr );
161//N2 review while( !IHB.err ) @(posedge IHB.clk);
162 f_env.wait(100);
163
164 // Free the tag if we sent in a PIO req.
165// if ( f_type == PEC_PCI__TYPE_CPL )
166// f_env.freePioTag( tlpTag );
167
168 // Tell the error-checker about this
169 // bad-boy.
170 if ( f_errQueue != 0 )
171 {
172 mailbox_put( f_errQueue, e_ERR_ilu_ihb );
173 mailbox_put( f_errQueue, ingressHdr );
174 }
175
176 } /* end Execute */
177 } /* end IhbErrPEUStr */