Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / ilu_peu / vera / N2str / ilupeuIngressDmaRdStr.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ilupeuIngressDmaRdStr.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 DmaRdPEUStr extends PEUStrBase
36 {
37 integer f_len; // The packet's payload length
38 bit[3:0] f_firstDWBE; // It's "first DWBE" field
39 bit[3:0] f_lastDWBE; // It's "last DWBE" field
40 integer f_bndy; // The address' boundary
41 bit f_lenSpecified; // Was a length specified?
42 bit f_firstSpecified; // Was a "firstDWBE" specified?
43 bit f_lastSpecified; // Was a "lastDWBE" specified?
44 bit f_bndySpecified; // Was an addr bndy specified?
45 bit f_poison; // Is the completion poisoned?
46 bit f_UR; // Is the completion UR?
47 bit f_CA; // Is the completion CA?
48
49 task new( PEUTestEnv a_env )
50 {
51 super.new( a_env );
52 f_lenSpecified = 0;
53 f_firstSpecified = 0;
54 f_lastSpecified = 0;
55 f_bndySpecified = 0;
56 f_poison = 0;
57 f_UR = 0;
58 f_CA = 0;
59 }
60 task SetLen( integer a_len )
61 {
62 f_len = a_len;
63 f_lenSpecified = 1;
64 }
65 task SetFirstDWBE( bit[3:0] a_dwbe )
66 {
67 f_firstDWBE = a_dwbe;
68 f_firstSpecified = 1;
69 }
70 task SetLastDWBE( bit[3:0] a_dwbe )
71 {
72 f_lastDWBE = a_dwbe;
73 f_lastSpecified = 1;
74 }
75 task SetAddrBndy( integer a_bndy )
76 {
77 f_bndy = a_bndy;
78 f_bndySpecified = 1;
79 }
80 task SetPoisonedPayload()
81 {
82 f_poison = 1;
83 }
84 task SetUC( bit isUR )
85 {
86 if ( isUR )
87 f_UR = 1;
88 else
89 f_CA = 1;
90 }
91 task Execute()
92 {
93 bit[PEC_PCI__HDR] ingressHdr; // The ingress TLP's header
94 integer ingressData; // A payload descriptor
95 bit[7:0] ingressTag; // The tag for the TLP
96 bit[PEC_PCI__HDR] egressHdr; // The egress TLP's header
97 integer egressData; // The completion payload
98 bit[7:0] egressAddr; // The payload's DOU address
99 integer dwTotal; // #DWs required for completion
100 integer dwDone; // #DWs completed so far
101
102 // First, get in line for a DMA tag...
103 f_env.allocDmaTag( ingressTag );
104
105 // Then build a TLP
106 if ( f_lenSpecified )
107 f_env.genIngressRdReq( ingressTag, ingressHdr, ingressData, f_len );
108 else
109 f_env.genIngressRdReq( ingressTag, ingressHdr, ingressData );
110
111 // ...and set fields as requested
112 // by the caller.
113 if ( f_bndySpecified )
114 f_env.setAddrBndy( ingressHdr, f_bndy, 64 );
115 //N2 Set the DWBE after setAddrBndy since it adjusts the DWBE now
116 if ( f_firstSpecified )
117 ingressHdr[PEC_PCI__FIRST_DWBE] = f_firstDWBE;
118 if ( f_lastSpecified )
119 ingressHdr[PEC_PCI__LAST_DWBE] = f_lastDWBE;
120
121 // Send the read-request through the
122 // ingress pipeline.
123 f_env.reserveIngressCredits( ingressHdr );
124 f_env.drivePCIE( ingressHdr, ingressData );
125 f_env.consumeIngressCredits( ingressHdr );
126 f_env.expectILU( ingressHdr, ingressData );
127
128 // Now send a completion to our
129 // original request through the
130 // egress pipeline.
131 // An unsuccesful completion is simple.
132 if ( !sync( CHECK, f_env.ev_drainStateEnd ) ){ //If drainStateEnd then finish strategy
133 if ( f_UR || f_CA )
134 {
135 f_env.genEgressCpl( ingressHdr, egressHdr, egressData );
136 egressHdr[PEC_PCI__FMT_DATA] = 0;
137 if ( f_UR )
138 egressHdr[PEC_PCI__CPL_STATUS] = PEC_PCI__CPL_STATUS_UR;
139 else
140 egressHdr[PEC_PCI__CPL_STATUS] = PEC_PCI__CPL_STATUS_CA;
141 f_env.driveILU( egressHdr, 0, egressData );
142 f_env.expectPCIE( egressHdr, egressData );
143 }
144
145 // Just one completion for a simple
146 // memory-read request...
147 else if ( ingressHdr[PEC_PCI__LEN] > 0
148 && 4*ingressHdr[PEC_PCI__LEN] <= f_env.getMaxPayloadSize() )
149 {
150 f_env.genEgressCpl( ingressHdr, egressHdr, egressData );
151 if ( f_poison ) f_env.poisonPayload( egressData );
152 f_env.allocCplData( ingressHdr[PEC_PCI__LEN],
153 egressHdr[PEC_PCI__LOWADDR],
154 egressAddr );
155 f_env.driveILU( egressHdr, egressAddr, egressData );
156 if ( f_poison ) egressHdr[PEC_PCI__EP] = 1;
157 if ( !sync( CHECK, f_env.ev_drainStateEnd ) ){
158 f_env.expectPCIE( egressHdr, egressData );
159 }
160 }
161 // ...or as many as it takes for a
162 // complex ('bulk') request.
163 else
164 {
165 dwTotal = ingressHdr[PEC_PCI__LEN];
166 if ( dwTotal == 0 ) dwTotal = 1024;
167 dwDone = 0;
168 while( dwTotal > dwDone )
169 {
170 f_env.genEgressPartialCpl( ingressHdr, egressHdr, egressData, dwDone );
171 dwDone = dwDone + egressHdr[PEC_PCI__LEN];
172 if ( f_poison ) f_env.poisonPayload( egressData );
173 f_env.allocCplData( egressHdr[PEC_PCI__LEN],
174 egressHdr[PEC_PCI__LOWADDR],
175 egressAddr );
176
177 repeat( urandom_range( f_env.Scenario.ilupeuDmaMRdCplDelayMax, f_env.Scenario.ilupeuDmaMRdCplDelayMin)) @(posedge CLOCK);
178 f_env.driveILU( egressHdr, egressAddr, egressData );
179 if ( f_poison ) egressHdr[PEC_PCI__EP] = 1;
180 if ( !sync( CHECK, f_env.ev_drainStateEnd ) ){
181 f_env.expectPCIE( egressHdr, egressData );
182 }else{
183 dwTotal = dwDone;
184 }
185 }
186 }
187 }
188
189 /* The environment frees the completion's DOU space */
190 /* So we only have to free the tag. */
191 f_env.freeDmaTag( ingressTag );
192 } /* end Execute */
193 } /* end DmaRdPECStr */