Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuIngParErr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ilupeuIngParErr.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 IngParErrStr 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 f_injectType;
43 bit[3:0] f_mask; // Which bits are in error?
44 integer bit_flip;
45
46 task new( PEUTestEnv a_env )
47 {
48 super.new( a_env );
49 f_errQueue = 0;
50 f_lenSpecified = 0;
51 f_typeSpecified = 0;
52 f_injectType = 0;
53 f_mask = 4'b0;
54 bit_flip = random() % 4;
55 }
56
57 task SetErrQueue( integer a_queue )
58 {
59 f_errQueue = a_queue;
60 } /* end SetErrQueue */
61
62 task SetLength( integer a_len )
63 {
64 f_len = a_len;
65 f_lenSpecified = 1;
66 } /* end SetLength */
67
68 task SetType( integer a_type )
69 {
70 f_type = a_type;
71 f_typeSpecified = 1;
72 } /* end SetType */
73
74 task SetInjectType( bit a_injectType )
75 {
76 f_injectType = a_injectType;
77 }
78
79 task SetMask( bit[3:0] a_mask )
80 {
81 f_mask = a_mask;
82 } /* end SetMask */
83
84 task Execute()
85 {
86 bit[PEC_PCI__HDR] egressHdr; // The egress TLP's header
87 integer egressData; // A payload descriptor
88 bit[7:0] tlpTag; // The tag for the TLP
89 bit[7:0] egressAddr; // The DOU starting address
90 bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header
91 integer ingressData; // A payload descriptor
92 bit[3:0] errMask;
93 bit [63:0] data;
94
95 if ( f_mask != 0 )
96 errMask = f_mask;
97 else
98 errMask = urandom()%15 + 1;
99
100
101 // Build a TLP, using the specified
102 // type and length, if any.
103 if ( !f_typeSpecified )
104 {
105 randcase
106 {
107 4 : { f_type = PEC_PCI__TYPE_MEM; f_len = urandom()%16 + 1; }
108 1 : { f_type = PEC_PCI__TYPE_MSG; f_len = 1; }
109 1 : { f_type = PEC_PCI__TYPE_CPL; f_len = urandom()%4 + 1; }
110 }
111 }
112
113 else if ( !f_lenSpecified )
114 {
115 if ( f_type == PEC_PCI__TYPE_CPL )
116 f_len = urandom()%4 + 1;
117 else if ( f_type == PEC_PCI__TYPE_MEM )
118 f_len = urandom()%16 + 1;
119 else
120 f_len = 1;
121 }
122
123 if (f_injectType ) {
124 data = f_env.readCSRdirect(f_env.getCSRaddr(e_CSR_tlu_diag));
125 data[FIRE_PLC_TLU_CTB_TLR_CSR_A_TLU_DIAG_IHI_PAR_SLC] = 1 << (bit_flip % 4);
126 data[FIRE_PLC_TLU_CTB_TLR_CSR_A_TLU_DIAG_IHI_TRG_SLC] = 1;
127 f_env.writeCSRdirect(f_env.getCSRaddr(e_CSR_tlu_diag), data);
128 f_env.enterDrainState();
129 } else {
130 data = f_env.readCSRdirect(f_env.getCSRaddr(e_CSR_tlu_diag));
131 data[FIRE_PLC_TLU_CTB_TLR_CSR_A_TLU_DIAG_IDI_PAR_SLC] = 1 << (bit_flip % 4);
132 data[FIRE_PLC_TLU_CTB_TLR_CSR_A_TLU_DIAG_IDI_TRG_SLC] = 1;
133 f_env.writeCSRdirect(f_env.getCSRaddr(e_CSR_tlu_diag), data);
134 }
135
136 repeat (100) @ (posedge CLOCK);
137
138 // If a completion (with data) was
139 // requested, then base it on a PIO
140 // read request.
141 if ( f_type == PEC_PCI__TYPE_CPL )
142 {
143 f_env.allocRdTag( tlpTag );
144 f_env.genEgressRdReq( tlpTag, egressHdr, egressData, f_len );
145 f_env.driveILU( egressHdr, 0, egressData );
146 f_env.expectPCIE( egressHdr, egressData );
147 f_env.genIngressCpl( egressHdr, ingressHdr, ingressData );
148 }
149 else
150 {
151 f_env.allocDmaTag( tlpTag );
152 if ( f_len == 0 )
153 f_env.genIngressRdReq( tlpTag, ingressHdr, ingressData );
154 else
155 f_env.genIngressWrReq( tlpTag, ingressHdr, ingressData, f_len );
156 }
157
158 // Present the TLP to the TLU, and
159 // specify that parity errors are to
160 // be injected into the IHB.
161 // We aren't going to release the tag
162 // so that only one error is injected.
163 f_env.reserveIngressCredits( ingressHdr );
164 f_env.drivePCIE( ingressHdr, ingressData );
165printf("drove the packet\n");
166 f_env.consumeIngressCredits( ingressHdr );
167
168 // Error injected on the Header are logged
169 // in the ILU Error register. Errors injected
170 // on the data pass through and are flagged upstream
171
172 if (f_injectType) {
173 if ( f_errQueue != 0 )
174 {
175 mailbox_put( f_errQueue, e_ERR_ilu_ihb );
176 mailbox_put( f_errQueue, ingressHdr );
177 }
178 } else {
179printf("Waiting for ILU packet\n");
180 f_env.expectILU( ingressHdr, ingressData );
181printf("received ILU packet\n");
182 }
183
184
185 } /* end Execute */
186 } /* end IngParErrStr */