| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: N2fcPioCfgIORdStr.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 ============================================ |
| 35 | class N2fcPioCfgIORdStr extends PioCfgIORdPEUStr { |
| 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 integer pio_error; // 0 = no error, 1 = timeout, 2 = uc |
| 42 | |
| 43 | // ****************************************************************** |
| 44 | // The Test Environment objects need to execute the strategy. |
| 45 | // ****************************************************************** |
| 46 | protected PEUTestEnv _env; |
| 47 | |
| 48 | public task new (PEUTestEnv a_env, string cmd, bit [63:0] addr, bit [31:0] length, bit [31:0] dat, integer err); |
| 49 | public task Execute(); |
| 50 | local task SetCplHdr (); |
| 51 | local task SetupParms (); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | task N2fcPioCfgIORdStr::new (PEUTestEnv a_env, |
| 56 | string cmd, |
| 57 | bit [63:0] addr, |
| 58 | bit [31:0] length, |
| 59 | bit [31:0] dat, |
| 60 | integer err |
| 61 | ) { |
| 62 | |
| 63 | super.new (a_env); |
| 64 | |
| 65 | if ( err == 3 ) { |
| 66 | return; // don't set up an expect or a completion |
| 67 | } |
| 68 | |
| 69 | this._env = a_env; |
| 70 | |
| 71 | this.cmd = cmd; |
| 72 | this.addr = addr; |
| 73 | this.length = length; |
| 74 | this.dat = dat; |
| 75 | this.pio_error = err; |
| 76 | |
| 77 | this.SetupParms (); |
| 78 | this.Execute (); |
| 79 | |
| 80 | } |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | //------------------------------------------------------------------------- |
| 86 | // over-ride parent class method |
| 87 | //------------------------------------------------------------------------- |
| 88 | |
| 89 | task N2fcPioCfgIORdStr::Execute() { |
| 90 | |
| 91 | bit CfgRdCpl=0; //If set the env will flip the completion byte order |
| 92 | // since Denali does it automatically so DMUXtr doesn't |
| 93 | // need to store an array for the payload |
| 94 | |
| 95 | //// printf ("\nUDEBUG : N2fcPioCfgIORdStr::Execute called \n"); |
| 96 | SetPacketParams(); |
| 97 | |
| 98 | // Set up the Reqest ID bits from the CSR |
| 99 | reqHdr[PEC_PCI__REQ_ID] = PiuCsrs.piuREQ_ID; |
| 100 | cplHdr[PEC_PCI__CPL_REQ_ID] = PiuCsrs.piuREQ_ID; |
| 101 | |
| 102 | this._env.expectPCIE(reqHdr, 0, 1); |
| 103 | non_posted_read_cmpl_outstanding++; |
| 104 | |
| 105 | SetCplHdr (); |
| 106 | |
| 107 | if ( this.pio_error == 1 ) { |
| 108 | printf ("\nDEBUG : N2fcPioCfgIORdStr::Execute pio timeout requested, so no completion generated\n"); |
| 109 | return; // timeout - don't send a completion |
| 110 | } |
| 111 | |
| 112 | fork { // don't block other expects |
| 113 | |
| 114 | sync( ALL, _env.ev_StallPioCpl); // stall the completion if event is OFF |
| 115 | |
| 116 | //Added CfgRdCpl since Denali flips the bytes for Cfg Reads |
| 117 | // this will flip the bytes back so the DMUXtr doesn't need to be changed |
| 118 | //IOS extends this class and has its own execute so it won't affect IOS |
| 119 | //FullChip needs to do the same |
| 120 | CfgRdCpl = (this._type_req !== PEC_PCI__TYPE_IO); |
| 121 | |
| 122 | if ((this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) || |
| 123 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) || |
| 124 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) || |
| 125 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) { |
| 126 | this._env.Pod.FNXPCIEEnableTrans.SuppressDenaliErr( PCIE_TL_NONFATAL_TLP_MF_vlCplSt ); //Malformed Completion TLP - Reserved completion status (%u). |
| 127 | } |
| 128 | |
| 129 | printf ("\nDEBUG : N2fcPioCfgIORdStr::Execute _op_cpl %d f_abortErrTlp %d pio_error %d\n\n", this._ep_cpl, super.f_abortErrTlp, pio_error); |
| 130 | |
| 131 | //if ( this._ep_cpl && super.f_abortErrTlp ) { |
| 132 | if (this.pio_error == 2) { |
| 133 | this._cpl_status = PEC_PCI__CPL_STATUS_UR; |
| 134 | cplHdr [PEC_PCI__CPL_STATUS] = PEC_PCI__CPL_STATUS_UR; |
| 135 | cplHdr [PEC_PCI__FMT] = PEC_PCI__FMT_NO_DATA_3DW; |
| 136 | cplHdr [PEC_PCI__LEN] = 0; |
| 137 | |
| 138 | this._env.drivePCIE(cplHdr, this._data,*,*,*, 1, CfgRdCpl); |
| 139 | } |
| 140 | else { |
| 141 | this._env.drivePCIE(cplHdr, this._data,*,*,*, *, CfgRdCpl ); |
| 142 | } |
| 143 | |
| 144 | if ((this._cpl_status === PEC_PCI__CPL_STATUS_CA) || |
| 145 | (this._cpl_status === PEC_PCI__CPL_STATUS_UR) || |
| 146 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) || |
| 147 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) || |
| 148 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) || |
| 149 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) { |
| 150 | //this._env.expectILU(urHdr, this._data); |
| 151 | //mailbox_put(this._errQueue, e_ERR_oe_ruc); |
| 152 | //mailbox_put(this._errQueue, cplHdr ); |
| 153 | if ( (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD1) || |
| 154 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD2) || |
| 155 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD3) || |
| 156 | (this._cpl_status === PEC_PCI__CPL_STATUS_RSVD4)) { |
| 157 | this._env.Pod.FNXPCIEEnableTrans.unSuppressDenaliErr( PCIE_TL_NONFATAL_TLP_MF_vlCplSt ); //Malformed Completion TLP - Reserved completion status (%u). |
| 158 | } |
| 159 | } |
| 160 | else if (this._cpl_status === PEC_PCI__CPL_STATUS_CRS) { |
| 161 | |
| 162 | this._env.expectTimeoutCpl(reqHdr); |
| 163 | //mailbox_put(this._errQueue, e_ERR_oe_crs); |
| 164 | //mailbox_put(this._errQueue, cplHdr ); |
| 165 | } |
| 166 | else if (this._ep_cpl === 1'b_1) { |
| 167 | |
| 168 | @(posedge CLOCK); |
| 169 | cplHdr [PEC_PCI__EP] = 0; |
| 170 | |
| 171 | this._env.drivePCIE(cplHdr, this._data,*,*,*,*,CfgRdCpl ); |
| 172 | this._env.expectILU(cplHdr, this._data); |
| 173 | if ( this._errQueue != 0 ) |
| 174 | { |
| 175 | cplHdr [PEC_PCI__EP] = 1; |
| 176 | //mailbox_put(this._errQueue, e_ERR_ue_pp); |
| 177 | //mailbox_put(this._errQueue, cplHdr); |
| 178 | } |
| 179 | } |
| 180 | else { |
| 181 | //// this._env.expectILU(cplHdr, this._data); |
| 182 | } |
| 183 | |
| 184 | this._env.freePioTag(this._tag); |
| 185 | non_posted_read_cmpl_outstanding--; |
| 186 | } join none |
| 187 | |
| 188 | } |
| 189 | |
| 190 | //------------------------------------------------------------------------- |
| 191 | // New method. capture the header Request Tag and return it on completion |
| 192 | //------------------------------------------------------------------------- |
| 193 | |
| 194 | task N2fcPioCfgIORdStr::SetCplHdr () { |
| 195 | |
| 196 | printf ("\nUDEBUG : N2fcPioCfgIORdStr::SetCplHdr Got a Req Tag of %0h\n", this._env.ReceivedReqTag); |
| 197 | cplHdr[PEC_PCI__CPL_TAG] = this._env.ReceivedReqTag; |
| 198 | |
| 199 | } |
| 200 | |
| 201 | |
| 202 | |
| 203 | //------------------------------------------------------------------------- |
| 204 | // New method. Setup parent properties based on Core request |
| 205 | //------------------------------------------------------------------------- |
| 206 | |
| 207 | task N2fcPioCfgIORdStr::SetupParms() { |
| 208 | |
| 209 | // setup parameters based on request |
| 210 | // |
| 211 | _type_req_prob_cfg0 = 0; |
| 212 | _type_req_prob_cfg1 = 0; |
| 213 | _type_req_prob_io = 0; |
| 214 | |
| 215 | _len_min = 1; |
| 216 | _len_max = 1; |
| 217 | |
| 218 | _cpl_id_min = 0; |
| 219 | _cpl_id_max = 0; |
| 220 | |
| 221 | _data_min = dat; |
| 222 | _data_max = dat; |
| 223 | |
| 224 | _format_req_prob_3dw = 100; |
| 225 | _format_req_prob_4dw = 0; |
| 226 | |
| 227 | _ep_cpl_prob_false = 100; |
| 228 | _ep_cpl_prob_true = 0; |
| 229 | |
| 230 | _td_cpl_prob_false = 100; |
| 231 | _td_cpl_prob_true = 0; |
| 232 | |
| 233 | _cpl_status_prob_sc = 100; |
| 234 | _cpl_status_prob_ur = 0; |
| 235 | _cpl_status_prob_crs = 0; |
| 236 | _cpl_status_prob_ca = 0; |
| 237 | _cpl_status_prob_rsvd1 = 0; |
| 238 | _cpl_status_prob_rsvd2 = 0; |
| 239 | _cpl_status_prob_rsvd3 = 0; |
| 240 | _cpl_status_prob_rsvd4 = 0; |
| 241 | |
| 242 | _bcm_prob_false = 100; |
| 243 | _bcm_prob_true = 0; |
| 244 | |
| 245 | case (cmd) { |
| 246 | "CFGRD0" : { |
| 247 | this._type_req_prob_cfg0 = 1; |
| 248 | _addr_lsb_min = {addr[27:12], 4'b0, addr[11:2], 2'b0}; |
| 249 | } |
| 250 | "CFGRD1" : { |
| 251 | this._type_req_prob_cfg1 = 1; |
| 252 | _addr_lsb_min = {addr[27:12], 4'b0, addr[11:2], 2'b0}; |
| 253 | } |
| 254 | "IORD" : { |
| 255 | this._type_req_prob_io = 1; |
| 256 | _addr_lsb_min = {addr[27:2], 2'b0}; |
| 257 | } |
| 258 | |
| 259 | default : { printf ("\n N2fcPioCfgIORdStr unknown command \n"); } |
| 260 | } |
| 261 | |
| 262 | _addr_lsb_max = _addr_lsb_min; |
| 263 | |
| 264 | |
| 265 | // Select DWBE based on address, length combination |
| 266 | // |
| 267 | _last_dwbe_min = 4'b0000; |
| 268 | _last_dwbe_max = _last_dwbe_min; |
| 269 | |
| 270 | case (length) { |
| 271 | 32'd1 : |
| 272 | case (addr[1:0]) { |
| 273 | 2'b00 : _first_dwbe_min = 4'b0001; |
| 274 | 2'b01 : _first_dwbe_min = 4'b0010; |
| 275 | 2'b10 : _first_dwbe_min = 4'b0100; |
| 276 | 2'b11 : _first_dwbe_min = 4'b1000; |
| 277 | default : |
| 278 | printf ("\n N2fcPioCfgIORdStr::SetupParms size warning A = %0h L = %0d\n", addr[1:0], length); |
| 279 | } |
| 280 | |
| 281 | 32'd2 : |
| 282 | case (addr[1:0]) { |
| 283 | 2'b00 :_first_dwbe_min = 4'b0011; |
| 284 | 2'b10 :_first_dwbe_min = 4'b1100; |
| 285 | default : |
| 286 | printf ("\n N2fcPioCfgIORdStr::SetupParms size warning A = %0h L = %0d\n", addr[1:0], length); |
| 287 | } |
| 288 | |
| 289 | 32'd4 : |
| 290 | case (addr[1:0]) { |
| 291 | 2'b00 :_first_dwbe_min = 4'b1111; |
| 292 | default : |
| 293 | printf ("\n N2fcPioCfgIORdStr::SetupParms size warning A = %0h L = %0d\n", addr[1:0], length); |
| 294 | } |
| 295 | |
| 296 | 32'd8 : { |
| 297 | _first_dwbe_min = 4'b1111; |
| 298 | _last_dwbe_min = 4'b1111; |
| 299 | _len_min = 2; |
| 300 | printf ("\n N2fcPioCfgIORdStr::SetupParms size warning A = %0h L = %0d\n", addr[1:0], length); |
| 301 | } |
| 302 | |
| 303 | default : |
| 304 | printf ("\n N2fcPioCfgIORdStr::SetupParms warning: Illegal Size = %0d\n", length); |
| 305 | } |
| 306 | |
| 307 | _first_dwbe_max = _first_dwbe_min; |
| 308 | |
| 309 | } |