| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: N2fcPioMWrStr.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 N2fcPioMWrStr extends PioMWrPEUStr { |
| 36 | |
| 37 | local string cmd; |
| 38 | local bit [63:0] addr; |
| 39 | local bit [31:0] length; |
| 40 | local bit [63: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 | // ****************************************************************** |
| 46 | // Constructor |
| 47 | // ****************************************************************** |
| 48 | public task new (PEUTestEnv a_env, |
| 49 | string a_cmd, |
| 50 | bit [63:0] a_addr, |
| 51 | bit [31:0] a_length, |
| 52 | bit [63:0] a_dat, |
| 53 | bit [63:0] a_base, |
| 54 | (bit [63:0] a_offset = 0), |
| 55 | integer err); |
| 56 | |
| 57 | public task Execute(); |
| 58 | local task SetupParms (); |
| 59 | } |
| 60 | |
| 61 | |
| 62 | |
| 63 | //------------------------------------------------------------------- |
| 64 | // Method Name: |
| 65 | // Description: |
| 66 | //------------------------------------------------------------------- |
| 67 | task N2fcPioMWrStr::new(PEUTestEnv a_env, |
| 68 | string a_cmd, |
| 69 | bit [63:0] a_addr, |
| 70 | bit [31:0] a_length, |
| 71 | bit [63:0] a_dat, |
| 72 | bit [63:0] a_base, |
| 73 | (bit[63:0] a_offset = 0), |
| 74 | integer err) |
| 75 | { |
| 76 | super.new(a_env); |
| 77 | this._env = a_env; |
| 78 | |
| 79 | if ( err == 3 ) { |
| 80 | return; // don't set up an expect or a completion |
| 81 | } |
| 82 | |
| 83 | this.cmd = a_cmd; |
| 84 | this.addr = a_addr; |
| 85 | this.length = a_length; |
| 86 | this.dat = a_dat; |
| 87 | this.base = a_base; |
| 88 | this.offset = a_offset; |
| 89 | this.pio_error = err; |
| 90 | |
| 91 | this.SetupParms (); |
| 92 | this.Execute (); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | |
| 97 | //------------------------------------------------------------------- |
| 98 | // Method Name: |
| 99 | // Description: |
| 100 | //------------------------------------------------------------------- |
| 101 | task N2fcPioMWrStr::Execute() { |
| 102 | integer cnt1,cnt2; |
| 103 | |
| 104 | SetPacketParams(); |
| 105 | |
| 106 | if (pio_error == 4) { |
| 107 | //Make denali check for this instead of just disabling error |
| 108 | //[PCISIG-PHY.2.3#11]. [port_0].RX Nullified TLP |
| 109 | // f_env.Pod.FNXPCIEEnableTrans.tempSuppressDenaliErr( PCIE_PL_NONFATAL_FRAME_NULL_TLP ); |
| 110 | //Packet will come out as a NULL packet so set the Xtr to check |
| 111 | // for the PCIE_PL_NONFATAL_FRAME_NULL_TLP error |
| 112 | _env.Pod.FNXPCIEEnableTrans.ExpectNullPkt(); |
| 113 | cnt1 = _env.Pod.FNXPCIEBldr.SignalInterface.expectNullPkt; |
| 114 | } |
| 115 | |
| 116 | // Set up the Reqest ID bits from the CSR |
| 117 | pktHdr[PEC_PCI__REQ_ID] = PiuCsrs.piuREQ_ID; |
| 118 | |
| 119 | this._env.expectPCIE(pktHdr, this._data, 1); |
| 120 | |
| 121 | //If the packet gets transmitted than make sure its NULL |
| 122 | if (pio_error == 4) { |
| 123 | cnt2 = _env.Pod.FNXPCIEBldr.SignalInterface.expectNullPkt; |
| 124 | //Make sure packet expect wasn't removed and a NULL pkt was received |
| 125 | if( cnt1 !== (cnt2 + 1) && !sync( CHECK, _env.ev_removePcie ) ){ |
| 126 | _env.Report.report(RTYP_TEST_ERROR,"N2fcPioMWrStr Outgoing packet matched but a NullPkt wasn't received\n"); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if ( this.pio_error == 1 ) { |
| 131 | printf ("\nDEBUG : N2fcPioMWrStr::Execute pio timeout requested, but for MEM32/64 Wr there is no completion\n"); |
| 132 | } |
| 133 | |
| 134 | this._env.freePioTag(this._tag); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | |
| 139 | //------------------------------------------------------------------- |
| 140 | // Method Name: SetupParms() |
| 141 | // Description: Override the base class SetupParms(), to set up the |
| 142 | // expected fields based on the PIO the core executed. |
| 143 | //------------------------------------------------------------------- |
| 144 | task N2fcPioMWrStr::SetupParms() { |
| 145 | bit [63:0] tmpAddr; |
| 146 | |
| 147 | tmpAddr = this.addr - (this.base + 64'hc0_0000_0000) | this.offset; |
| 148 | |
| 149 | _addr_msb_min = tmpAddr[63:32]; |
| 150 | _addr_msb_max = tmpAddr[63:32]; |
| 151 | |
| 152 | _addr_lsb_min = tmpAddr[31:0]; |
| 153 | _addr_lsb_max = tmpAddr[31:0]; |
| 154 | |
| 155 | if(tmpAddr[63:32]) { |
| 156 | _format_req_prob_3dw = 0; |
| 157 | _format_req_prob_4dw = 100; |
| 158 | } |
| 159 | else { |
| 160 | _format_req_prob_3dw = 100; |
| 161 | _format_req_prob_4dw = 0; |
| 162 | } |
| 163 | |
| 164 | _data_min = this.dat; |
| 165 | |
| 166 | _req_id_min = 0; |
| 167 | _req_id_max = 0; |
| 168 | |
| 169 | |
| 170 | // Select DWBE based on address, length combination |
| 171 | if((length[7:4] == 0) && (length[3:0] != 0)) { |
| 172 | // got to "shift up" the dwbe, addr[2], and data since first_dwbe == 0 is illegal |
| 173 | _first_dwbe_min = {length[0], length[1], length[2], length[3]}; |
| 174 | _last_dwbe_min = 0; |
| 175 | // make sure that address bit 2 is set |
| 176 | _addr_lsb_min[2] = 1; |
| 177 | _data_min[63:32] = this.dat[31:0]; |
| 178 | } |
| 179 | else { |
| 180 | _first_dwbe_min = {length[4], length[5], length[6], length[7]}; |
| 181 | _last_dwbe_min = {length[0], length[1], length[2], length[3]}; |
| 182 | // make sure that address bit 2 is cleared |
| 183 | _addr_lsb_min[2] = 0; |
| 184 | } |
| 185 | _addr_lsb_max[2] = _addr_lsb_min[2]; |
| 186 | |
| 187 | _last_dwbe_max = _last_dwbe_min; |
| 188 | _first_dwbe_max = _first_dwbe_min; |
| 189 | |
| 190 | _data_max = _data_min; |
| 191 | |
| 192 | if( (length[7:4] != 0) && (length[3:0] != 0) ) |
| 193 | _len_min = 2; |
| 194 | else |
| 195 | _len_min = 1; |
| 196 | |
| 197 | _len_max = _len_min; |
| 198 | |
| 199 | printf ("UDEBUG :N2fcPioMWrStr: length = %0h %0h %0h - _len = %0h\n\t_addr_msb_min %h _addr_lsb_min %h addr %h base %h offset %h\n", |
| 200 | length, length[3:0], length[7:4], _len_min, _addr_msb_min, _addr_lsb_min, addr, base, offset); |
| 201 | } |