Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2fc / N2fcPioMRdStr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: N2fcPioMRdStr.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 N2fcPioMRdStr extends PioMRdPEUStr {
36
37 local string cmd;
38 local bit [63:0] addr;
39 local bit [31:0] length;
40 local bit [31:0] dat;
41 local bit [63:0] base;
42 local bit [63:0] offset;
43 local integer pio_error; // 0 = no error, 1 = timeout, 2 = uc
44
45 public task new(PEUTestEnv a_env,
46 string a_cmd,
47 bit [63:0] a_addr,
48 bit [31:0] a_length,
49 bit [31:0] a_dat,
50 bit [63:0] a_baseaddr,
51 (bit[63:0] a_offset = 0),
52 (integer a_err = 0)
53 );
54
55 public task Execute();
56
57 local task SetCplHdr ();
58 local task SetupParms ();
59}
60
61
62
63//-------------------------------------------------------------------
64// Method Name:
65// Description:
66//-------------------------------------------------------------------
67task N2fcPioMRdStr::new(PEUTestEnv a_env,
68 string a_cmd,
69 bit [63:0] a_addr,
70 bit [31:0] a_length,
71 bit [31:0] a_dat,
72 bit [63:0] a_baseaddr,
73 (bit[63:0] a_offset = 0),
74 (integer a_err = 0)
75 )
76{
77 super.new(a_env);
78
79 if ( a_err == 3 ) {
80 return; // don't set up an expect or a completion
81 }
82
83 this._env = a_env;
84 this.cmd = a_cmd;
85 this.addr = a_addr;
86 this.length = a_length;
87 this.dat = a_dat;
88 this.base = a_baseaddr;
89 this.offset = a_offset;
90 this.pio_error = a_err;
91
92 this.SetupParms ();
93 this.Execute ();
94}
95
96
97
98task N2fcPioMRdStr::Execute() {
99
100 SetPacketParams();
101
102 // Set up the Reqest ID bits from the CSR
103 reqHdr[PEC_PCI__REQ_ID] = PiuCsrs.piuREQ_ID;
104 cplHdr[PEC_PCI__CPL_REQ_ID] = PiuCsrs.piuREQ_ID;
105
106 this._env.expectPCIE(reqHdr, 0, 1);
107 non_posted_read_cmpl_outstanding++;
108
109 SetCplHdr (); // gets the Request Id
110
111 if ( this.pio_error == 1 ) {
112 printf ("\nDEBUG : N2fcPioMRdStr::Execute pio timeout requested, so no completion generated\n");
113 return; // timeout - don't send a completion
114 }
115
116 fork { // don't block other expects
117
118 sync( ALL, _env.ev_StallPioCpl); // stall the completion if event is OFF
119
120 if ( (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) ||
121 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) ||
122 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) ||
123 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) {
124 this._env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_TL_NONFATAL_TLP_MF_vlCplSt ); //Malformed Completion TLP - Reserved completion status (%u).
125 }
126
127 //if ( this._ep_cpl && super.f_abortErrTlp )
128 if (this.pio_error == 2) {
129 this._cpl_status = PEC_PCI__CPL_STATUS_UR;
130 cplHdr [PEC_PCI__CPL_STATUS] = PEC_PCI__CPL_STATUS_UR;
131 cplHdr [PEC_PCI__FMT] = PEC_PCI__FMT_NO_DATA_3DW;
132 cplHdr [PEC_PCI__LEN] = 0;
133 this._env.drivePCIE(cplHdr, this._data, *, *, *, 1);
134 }
135 else {
136 this._env.drivePCIE(cplHdr, this._data);
137 }
138
139 if ((this._cpl_status === PEC_PCI__CPL_STATUS_CA) ||
140 (this._cpl_status === PEC_PCI__CPL_STATUS_UR) ||
141 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) ||
142 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) ||
143 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) ||
144 (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) {
145
146 //// this._env.expectILU(urHdr, this._data);
147 //mailbox_put(this._errQueue, e_ERR_oe_ruc);
148 //mailbox_put(this._errQueue, cplHdr );
149 }
150
151 else if (this._cpl_status === PEC_PCI__CPL_STATUS_CRS) {
152
153 // Nothing pops out here.
154 this._env.waitIngressLatency(cplHdr);
155 //mailbox_put(this._errQueue, e_ERR_ue_mfp);
156 //mailbox_put(this._errQueue, cplHdr );
157 }
158
159 else if (this._ep_cpl === 1'b_1) {
160
161 repeat(2) @(posedge CLOCK);
162 cplHdr [PEC_PCI__EP] = 0;
163
164 SetCplHdr ();
165 this._env.drivePCIE(cplHdr, this._data);
166 //// this._env.expectILU(cplHdr, this._data);
167// if ( this._errQueue != 0 )
168// {
169// //N2 - Add checking of request header
170// mailbox_put( this._errQueue, e_ERR_none );
171// mailbox_put( this._errQueue, -1 );
172// mailbox_put( this._errQueue, reqHdr );
173// mailbox_put( this._errQueue, e_ERR_ue_pp );
174// cplHdr [PEC_PCI__EP] = 1;
175// mailbox_put(this._errQueue, cplHdr);
176// }
177 }
178
179 else {
180 //// this._env.expectILU(cplHdr, this._data);
181 }
182
183 this._env.freePioTag(this._tag);
184 non_posted_read_cmpl_outstanding--;
185 } join none
186
187}
188
189
190task N2fcPioMRdStr::SetupParms() {
191
192 bit [63:0] tmpAddr;
193
194 tmpAddr = this.addr - (this.base + 64'hc0_0000_0000) | this.offset;
195
196 _addr_msb_min = tmpAddr[63:32];
197 _addr_msb_max = tmpAddr[63:32];
198
199 _addr_lsb_min = tmpAddr[31:0];
200 _addr_lsb_max = tmpAddr[31:0];
201
202 if(tmpAddr[63:32]) {
203 _format_req_prob_3dw = 0;
204 _format_req_prob_4dw = 100;
205 }
206 else {
207 _format_req_prob_3dw = 100;
208 _format_req_prob_4dw = 0;
209 }
210
211 _data_min = dat;
212 _data_max = dat;
213
214 _ep_cpl_prob_false = 100;
215 _ep_cpl_prob_true = 0;
216
217 _td_cpl_prob_false = 100;
218 _td_cpl_prob_true = 0;
219
220 _cpl_status_prob_sc = 100;
221 _cpl_status_prob_ur = 0;
222 _cpl_status_prob_crs = 0;
223 _cpl_status_prob_ca = 0;
224 _cpl_status_prob_rsvd1 = 0;
225 _cpl_status_prob_rsvd2 = 0;
226 _cpl_status_prob_rsvd3 = 0;
227 _cpl_status_prob_rsvd4 = 0;
228
229 _bcm_prob_false = 100;
230 _bcm_prob_true = 0;
231
232
233
234 // Select DWBE based on address, length combination
235 //
236 _first_dwbe_min = 4'b0000;
237 _last_dwbe_min = 4'b0000;
238
239
240 _len_min = 1;
241
242
243 case (length) {
244 32'd1 :
245 case (addr[1:0]) {
246 2'b00 : _first_dwbe_min = 4'b0001;
247 2'b01 : _first_dwbe_min = 4'b0010;
248 2'b10 : _first_dwbe_min = 4'b0100;
249 2'b11 : _first_dwbe_min = 4'b1000;
250 default :
251 error ("\n N2fcPioMRdStr::SetupParms size ERROR A = %0h L = %0d\n", addr[3:0], length);
252 }
253
254 32'd2 :
255 case (addr[1:0]) {
256 2'b00 : _first_dwbe_min = 4'b0011;
257 2'b10 : _first_dwbe_min = 4'b1100;
258 default :
259 error ("\n N2fcPioMRdStr::SetupParms size ERROR A = %0h L = %0d\n", addr[3:0], length);
260 }
261
262 32'd4 : {
263 _first_dwbe_min = 4'b1111;
264 }
265
266 32'd8 : {
267 _first_dwbe_min = 4'b1111;
268 _last_dwbe_min = 4'b1111;
269 _len_min = 2;
270 }
271
272 32'd16 : {
273 _first_dwbe_min = 4'b1111;
274 _last_dwbe_min = 4'b1111;
275 _len_min = 4;
276 }
277
278 default :
279 error ("\n N2fcPioMRdStr::SetupParms ERROR Illegal Size = %0d\n", length);
280 }
281
282 _first_dwbe_max = _first_dwbe_min;
283 _last_dwbe_max = _last_dwbe_min;
284 _len_max = _len_min;
285
286 printf ("UDEBUG :N2fcPioMRdStr _first_dwbe = %0h _last_dwbe = %0h _len = %0d\n\t_addr_msb_min %h _addr_lsb_min %h addr %h base %h offset %h\n", _first_dwbe_max, _last_dwbe_max, _len_max, _addr_msb_min, _addr_lsb_min, addr, base, offset );
287}
288
289
290
291task N2fcPioMRdStr::SetCplHdr () {
292 //printf ("UDEBUG : N2fcPioMRdStr::SetCplHdr Got a Req Tag of %0h\n", this._env.ReceivedReqTag);
293 cplHdr[PEC_PCI__CPL_TAG] = this._env.ReceivedReqTag;
294}
295