Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: pcxPktClass.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 | #include <vera_defines.vrh> | |
36 | #include <std_display_defines.vri> | |
37 | #include <ccxDevicesDefines.vri> | |
38 | #include <cmp.vri> | |
39 | // #include <defines.vri> | |
40 | ||
41 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
42 | // To use this class, you must have in your bench a files called globals.vri | |
43 | // that has all global extern declerations in it. | |
44 | #include <globals.vri> | |
45 | ||
46 | #include <std_display_class.vrh> | |
47 | #include <basePktClass.vrh> | |
48 | #include <cpxPktClass.vrh> | |
49 | #include <ccxDevBaseBFM.vrh> | |
50 | #include <ccxDevMemBFM.vrh> | |
51 | #include <ccxDevSpcBFM.vrh> | |
52 | ||
53 | #define MON_CCXPKT 24 | |
54 | ||
55 | ||
56 | // PCX Packet | |
57 | // defines fields in packet | |
58 | ||
59 | class PcxPkt extends BasePkt { | |
60 | ||
61 | // pcx vector | |
62 | public reg valid = 1; // 129 | |
63 | // in base public reg [4:0] rqtyp; | |
64 | public reg nc = 0; | |
65 | public reg [2:0] cpuId = 0; // 122:120 | |
66 | // in base public reg [2:0] tid; | |
67 | public reg inv = 0; // 116 invalidate | |
68 | public reg pf = 0; // 115 prefetch/BST block store | |
69 | public reg l1wayBis = 0; // 114 L1 way/BIS block init store/MAid | |
70 | public reg [1:0] l1wayMMUid = 0; | |
71 | public reg [7:0] size = 0; | |
72 | // in base public reg [39:0] addr; | |
73 | public reg [63:0] data = 0; // 63:0 | |
74 | // end pcx vector | |
75 | ||
76 | ||
77 | local reg [129:0] pktVec = 0; | |
78 | local reg [2:0] coreNum = 0; | |
79 | local bit io = 0; | |
80 | local integer printCount = 0; | |
81 | local PcxPkt receivedPkt = null; | |
82 | local reg [15:0] dummy = 0; | |
83 | ||
84 | task new (); | |
85 | task loadPkt(reg [145:0] dataIn, integer atPort=99); | |
86 | function reg [145:0] getVector(); | |
87 | task print(integer atPort); | |
88 | task send(integer fastResp=0); | |
89 | function reg [145:0] makeSignature(); | |
90 | task recv(); | |
91 | ||
92 | local task printHeader(); | |
93 | task createIntr(reg [5:0] thread, // 64 virtual cores | |
94 | reg [1:0] type, | |
95 | reg [5:0] vect); | |
96 | task recvPortByAddr(); | |
97 | } | |
98 | ||
99 | task PcxPkt::new () { | |
100 | name = "PcxPkt"; | |
101 | super.reqId = 0; | |
102 | super.reqTime = 0; | |
103 | super.pktArrived = 0; | |
104 | } | |
105 | ||
106 | // load this pkt from a vector | |
107 | task PcxPkt::loadPkt(reg [145:0] dataIn, integer atPort=99) { // keep 145:0 | |
108 | ||
109 | // #ifdef PKT_DEBUG | |
110 | // reqTime = get_time(LO); // time of request | |
111 | // #endif | |
112 | // #ifdef CCXDEVMEMBFM_DEBUG | |
113 | // reqTime = get_time(LO); // time of request | |
114 | // #endif | |
115 | ||
116 | pktVec = dataIn; | |
117 | '{valid,rqtyp,nc,cpuId,tid,inv,pf,l1wayBis,l1wayMMUid,size,addr,data} = dataIn; | |
118 | //printf("%0d bits = %146h\n",get_cycle(),{valid,rqtyp,nc,cpuId,tid,inv,pf,l1wayBis,l1wayMMUid,size,addr,data}; | |
119 | //unpackVec(); | |
120 | arrivalPort = atPort; | |
121 | senderPort = cpuId; | |
122 | if (atPort == DEV_NCU) io = 1; | |
123 | ||
124 | } | |
125 | ||
126 | function reg [145:0] PcxPkt::getVector() { | |
127 | getVector = {valid,rqtyp,nc,cpuId,tid,inv,pf,l1wayBis,l1wayMMUid,size,addr,data}; | |
128 | } | |
129 | ||
130 | task PcxPkt::print(integer atPort) | |
131 | { | |
132 | integer line = 999; | |
133 | ||
134 | printHeader () ; | |
135 | ||
136 | printf ("%9d:", get_time(LO)) ; | |
137 | printf ("|%2d", tid + (8*cpuId)) ; | |
138 | printf ("|PCX") ; | |
139 | printf ("|%2d", atPort) ; | |
140 | if (req_wire === 9'bxxxxxxxxx) printf ("|---"); | |
141 | else printf ("|%3h", req_wire) ; | |
142 | // printf ("|%3h", req_wire) ; | |
143 | // printf ("|%3h", atm_wire) ; | |
144 | printf ("|%1b", valid) ; | |
145 | case (rqtyp) | |
146 | { | |
147 | PCX_LD,PCX_PREF,PCX_PREF_ICE,PCX_DIAG_LD,PCX_D_INVAL: { | |
148 | if (pf & l1wayBis) printf ("|PREFETCH ICE"); | |
149 | else if (inv) printf ("|D INVALIDATE"); | |
150 | else if (pf) printf ("|PREFETCH "); | |
151 | else printf ("|LOAD/DIAG "); | |
152 | line = addr[10:4]; tag = addr[39:11]; | |
153 | } | |
154 | PCX_ST,PCX_BLK_ST,PCX_BLK_INIT_ST,PCX_DIAG_ST: { | |
155 | if (pf & l1wayBis) printf ("|BLK STORE "); | |
156 | else if (l1wayBis) printf ("|BLK INIT ST "); | |
157 | else printf ("|STORE/DIAG "); | |
158 | line = addr[10:4]; tag = addr[39:11]; | |
159 | } | |
160 | PCX_CAS1 : { | |
161 | printf ("|CAS 1 "); | |
162 | line = addr[10:4]; tag = addr[39:11]; | |
163 | } | |
164 | PCX_CAS2 : { | |
165 | printf ("|CAS 2 "); | |
166 | line = addr[10:4]; tag = addr[39:11]; | |
167 | } | |
168 | PCX_STR_LD : printf ("|STRM LOAD "); | |
169 | PCX_STR_ST : printf ("|STRM STORE "); | |
170 | PCX_SWAP : { | |
171 | printf ("|SWAP/LDSTUB "); | |
172 | line = addr[10:4]; tag = addr[39:11]; | |
173 | } | |
174 | PCX_MMU_LD : printf ("|MMU LOAD "); | |
175 | PCX_IFILL,PCX_I_INVAL: | |
176 | if (inv) printf ("|I INVALIDATE"); | |
177 | else printf ("|INSTR IFILL "); | |
178 | default : printf ("|??? %b",rqtyp) ; | |
179 | } | |
180 | printf ("|%2b", nc); | |
181 | printf ("|%3d", cpuId); | |
182 | printf ("|%1d", tid); | |
183 | printf ("|%2b", inv); | |
184 | printf ("|%2b", pf) ; | |
185 | printf ("|%6b", l1wayBis); | |
186 | printf ("|%5b", l1wayMMUid) ; | |
187 | printf ("|%4h", size); | |
188 | printf ("|%10h", addr); | |
189 | printf ("|%h", data) ; | |
190 | #ifdef CCXDEVMEMBFM_DEBUG | |
191 | printf (" "); | |
192 | printf ("|%3d", reqId); | |
193 | printf ("|%10h", addr); | |
194 | printf ("|%2h/%8h", line, tag); | |
195 | printf ("/%1h", lineWay); | |
196 | if (rqtyp == 0 && nc == 0) printf ("->%1h", l1wayMMUid*4+2); | |
197 | //printf ("|%8d", reqTime); | |
198 | #endif | |
199 | printf ("\n\n") ; | |
200 | ||
201 | printCount++ ; | |
202 | } | |
203 | ||
204 | ||
205 | task PcxPkt::printHeader () | |
206 | { | |
207 | printf ("\n%9d:", get_time(LO)) ; | |
208 | printf ("|VC") ; | |
209 | printf ("|PCX") ; | |
210 | printf ("|At") ; | |
211 | printf ("|Req"); | |
212 | // printf ("|Atm"); | |
213 | printf ("|V") ; | |
214 | printf ("|Type ") ; | |
215 | printf ("|NC") ; | |
216 | printf ("|CPU") ; | |
217 | printf ("|T") ; | |
218 | printf ("|Iv") ; | |
219 | printf ("|Pf") ; | |
220 | printf ("|WayBis"); | |
221 | printf ("|WayMM"); | |
222 | printf ("|Size"); | |
223 | printf ("|Addr "); | |
224 | printf ("|Data ") ; | |
225 | #ifdef CCXDEVMEMBFM_DEBUG | |
226 | printf (" "); | |
227 | printf ("|RID"); | |
228 | printf ("|Req Addr "); | |
229 | printf ("|DL/Tag/Way"); | |
230 | // printf ("|Req Time"); | |
231 | #endif | |
232 | printf ("\n") ; | |
233 | } | |
234 | ||
235 | ||
236 | // correct recvPort based on address | |
237 | // addr bits [8:6] determins which bank an access goes to. | |
238 | // review for partial bank | |
239 | task PcxPkt::recvPortByAddr() { | |
240 | targetPorts = 1 << addr[8:6]; | |
241 | } | |
242 | ||
243 | ||
244 | task PcxPkt::send(integer fastResp=0) { | |
245 | integer i; | |
246 | pktVec = {valid,rqtyp,nc,cpuId,tid,inv,pf,l1wayBis,l1wayMMUid,size,addr,data}; | |
247 | case (rqtyp) { | |
248 | PCX_CAS1: atomic = 1; | |
249 | PCX_CAS2: atomic = 2; | |
250 | } | |
251 | for (i=0;i<9;i++) { | |
252 | if (sendPorts[i]) { | |
253 | if (gCcxDevice[i] == null) | |
254 | error("Can't send packet from a nonExistant BFM! \n"); | |
255 | gCcxDevice[i].send(this,fastResp); | |
256 | } | |
257 | } | |
258 | } | |
259 | ||
260 | ||
261 | // makeSignature returns certain concatinated fields of the packet. | |
262 | // called by BFM that needs it. | |
263 | function reg [145:0] PcxPkt::makeSignature() { | |
264 | makeSignature = {30'b0,valid,rqtyp,cpuId,tid,addr[39:0],data[63:0]}; | |
265 | } | |
266 | ||
267 | ||
268 | // BFM knows everything that it needs from this packet, | |
269 | // especially the signature for packet matching. | |
270 | // This packet has the signature and recvPorts. | |
271 | // Note that recvPkt call inside the receiving BFM may be blocking review | |
272 | task PcxPkt::recv() { | |
273 | ||
274 | if (manyHot(this.targetPorts) !== 1) | |
275 | error("Need to set a single target port in targetPorts var! \n"); | |
276 | ||
277 | // hand off | |
278 | gCcxDevice[whichHot(this.targetPorts)].recv(this); | |
279 | } | |
280 | ||
281 | ||
282 | ||
283 | // Create/config Interrupt Pkt. this is really a store packet to a certain | |
284 | // I/O adddress at the NCU. The NCU then does an interrupt to the target. | |
285 | task PcxPkt::createIntr (reg [5:0] thread, // 64 virtual cores | |
286 | reg [1:0] type, | |
287 | reg [5:0] vect) { | |
288 | ||
289 | targetPorts = 1 << 8; // NCU | |
290 | valid = 1'b1; | |
291 | rqtyp = PCX_ST; | |
292 | nc = 0; | |
293 | cpuId = thread[5:3]; | |
294 | tid = thread[2:0]; | |
295 | inv = 0; | |
296 | pf = 0; | |
297 | l1wayBis = 0; | |
298 | l1wayMMUid = 0; | |
299 | size = 8'hff; | |
300 | addr = ASI_SWVR_UDB_INTR_W; | |
301 | data[63:0] = {42'b0,thread,type,8'b0,vect}; | |
302 | } | |
303 |