Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: baseCCXtrans.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 <globals.vri> | |
37 | // #include <ccxDefines.vri> | |
38 | // #include <cmp.vri> | |
39 | #include <ccxDevicesDefines.vri> | |
40 | #include <defines.vri> | |
41 | #include <std_display_defines.vri> | |
42 | ||
43 | #include <baseParamsClass.vrh> | |
44 | #include <sparcParams.vrh> | |
45 | #include <baseUtilsClass.vrh> | |
46 | #include <sparcBenchUtils.vrh> | |
47 | #include <std_display_class.vrh> | |
48 | #include <basePktClass.vrh> | |
49 | #include <cpxPktClass.vrh> | |
50 | #include <pcxPktClass.vrh> | |
51 | #include <ccxDevBaseBFM.vrh> | |
52 | #include <ccxDevMemBFM.vrh> | |
53 | #include <ccxDevSpcBFM.vrh> | |
54 | #include <memArray.vrh> | |
55 | #include <ccx_tag_class.vrh> | |
56 | ||
57 | ||
58 | #include <utilsClass.vrh> | |
59 | ||
60 | // uncomment to debug | |
61 | //#define CCXBASETRANS_DEBUG | |
62 | ||
63 | ||
64 | #define CLASSNAME BaseCCXtrans | |
65 | #define CLASSNAMEQ "BaseCCXtrans" | |
66 | ||
67 | // BFMs | |
68 | // gCcxDevice[] 0-16 !== null | |
69 | ||
70 | // virtual ports | |
71 | // EXTERN ccxPort gPcxPort[17]; | |
72 | // EXTERN ccxPort gCpxPort[17]; | |
73 | ||
74 | class CLASSNAME { | |
75 | ||
76 | local string className = CLASSNAMEQ; | |
77 | protected StandardDisplay dbg; | |
78 | protected ccxPort anyMemPort; // generic | |
79 | protected ccxPort anySpcPort; // generic | |
80 | protected reg l2BFMs; | |
81 | protected reg [7:0] spcBfms; // these ports have BFMs | |
82 | ||
83 | // PCX things to randomize | |
84 | // rand protected reg valid = 1; // 129 | |
85 | // rand protected reg [4:0] rqtyp; | |
86 | // rand protected reg nc = 0; | |
87 | // rand protected reg [2:0] cpuId = 0; // 122:120 | |
88 | // rand protected reg [2:0] tid; | |
89 | // rand protected reg inv = 0; // 116 invalidate | |
90 | // rand protected reg pf = 0; // 115 prefetch/BST block store | |
91 | // rand protected reg l1wayBis = 0; // 114 L1 way/BIS block init store/MAid | |
92 | // rand protected reg [1:0] l1wayMMUid = 0; | |
93 | // rand protected reg [7:0] size = 0; | |
94 | // rand protected reg [39:0] addr; | |
95 | // rand protected reg [63:0] data = 0; // 63:0 | |
96 | ||
97 | // CPX things to randomize | |
98 | ||
99 | ||
100 | // constraints | |
101 | ||
102 | ||
103 | task new(StandardDisplay dbgHndl, reg l2BFMs); | |
104 | ||
105 | task sendIntr(reg [5:0] tid, reg [1:0] type, | |
106 | reg [5:0] vect, integer sendPort = DEV_NCU); | |
107 | task bogusEvict(reg [7:0] targets, reg [7:0] sendPorts, | |
108 | reg [39:0] evictPA = 40'h0); | |
109 | task ifillPair(integer target, reg [7:0] sendPorts, | |
110 | reg [127:0] data0 = 128'h0, | |
111 | reg [127:0] data1 = 128'h0); | |
112 | task spcCheck(string msg); | |
113 | task pickCore(var integer num, var reg [7:0] mask); | |
114 | } | |
115 | ||
116 | task CLASSNAME::new(StandardDisplay dbgHndl, reg l2BFMs) { | |
117 | integer i; | |
118 | ||
119 | srandom(gSeed,this); | |
120 | this.dbg = dbgHndl; | |
121 | this.l2BFMs = l2BFMs; | |
122 | spcBfms = 0; | |
123 | for (i=0;i<8;i++) if (gCcxDevice[i] !== null) spcBfms[i] = 1; | |
124 | } | |
125 | ||
126 | // generic call to send intr from NCU port. | |
127 | task CLASSNAME::sendIntr(reg [5:0] tid, | |
128 | reg [1:0] type, | |
129 | reg [5:0] vect, | |
130 | integer sendPort = DEV_NCU) | |
131 | { | |
132 | CpxPkt reqPkt; | |
133 | ||
134 | reqPkt = new(); | |
135 | reqPkt.createIntr(tid,type,vect); // INTR_RESET,INTR_POR | |
136 | reqPkt.sendPorts = 1 << sendPort; | |
137 | reqPkt.targetPorts = 1 << tid[5:3]; | |
138 | PR_NORMAL(CLASSNAMEQ, MON_NORMAL, | |
139 | psprintf ("Send Interrupt to C%0d T%0d type=%b vector=%b", | |
140 | tid[5:3],tid[2:0],type,vect)); | |
141 | reqPkt.send(1); | |
142 | } | |
143 | ||
144 | ||
145 | ||
146 | // send a pair of IFILL resp | |
147 | task CLASSNAME::ifillPair(integer target, reg [7:0] sendPorts, | |
148 | reg [127:0] data0 = 128'h0, | |
149 | reg [127:0] data1 = 128'h0) { | |
150 | ||
151 | CpxPkt pkt,pkt2; | |
152 | ||
153 | pkt = new(); | |
154 | pkt.tid = random(); | |
155 | pkt.sendPorts = sendPorts << 8; | |
156 | pkt.rtntyp = CPX_IFILL; | |
157 | pkt.rtntypU = U_CPX_IFILL; | |
158 | pkt.l2miss = 0; | |
159 | pkt.targetPorts = 1<<target; | |
160 | pkt.data = data0; | |
161 | ||
162 | pkt2 = new(); | |
163 | pkt2 = pkt.object_copy(); | |
164 | pkt2.data = data1; | |
165 | pkt2.atmIf2 = 1; | |
166 | ||
167 | pkt.send(1); // doit | |
168 | pkt2.send(1); // doit | |
169 | ||
170 | PR_NORMAL(CLASSNAMEQ, MON_NORMAL, | |
171 | psprintf ("Sending IFILL resp pkt pair to target=%0d, data0=0x%h, data1=0x%h", | |
172 | target,data0,data1)); | |
173 | ||
174 | } | |
175 | ||
176 | // enqueue noop eviction from a port to some port. | |
177 | task CLASSNAME::bogusEvict(reg [7:0] targets, reg [7:0] sendPorts, | |
178 | reg [39:0] evictPA = 40'h0) | |
179 | { | |
180 | ||
181 | CpxPkt pkt; | |
182 | ||
183 | pkt = new(); | |
184 | //pktRecv = new(); | |
185 | pkt.tid = random(); | |
186 | pkt.sendPorts = sendPorts << 8; | |
187 | pkt.rtntyp = CPX_EVICT; | |
188 | pkt.rtntypU = U_CPX_EVICT; | |
189 | pkt.addr = evictPA; | |
190 | pkt.l2miss = 0; | |
191 | pkt.targetPorts = targets; | |
192 | pkt.data = 0; | |
193 | ||
194 | // end to end checking | |
195 | // pktRecv.signature = pkt.makeSignature(); | |
196 | // pktRecv.targetPorts = | |
197 | // pktRecv.recv(); | |
198 | ||
199 | ||
200 | pkt.send(1); // doit | |
201 | ||
202 | PR_NORMAL(CLASSNAMEQ, MON_NORMAL, | |
203 | psprintf ("Sending bogus EVICTION pkt to targets=0b%b, a=0x%h, vec=0x%h", | |
204 | pkt.targetPorts,0,0)); | |
205 | ||
206 | } | |
207 | ||
208 | task CLASSNAME::spcCheck(string msg) { | |
209 | ||
210 | if (! spcBfms) PR_ALWAYS(CLASSNAMEQ, MON_ALWAYS, | |
211 | psprintf ("%s needs at least 1 SPC BFM!", msg)); | |
212 | if (! spcBfms) PR_ERROR(CLASSNAMEQ, MON_ERROR, | |
213 | psprintf ("%s needs at least 1 SPC BFM!", msg)); | |
214 | repeat (25) @(posedge CLOCK); | |
215 | error("%s needs at least 1 SPC BFM!", msg); | |
216 | } | |
217 | ||
218 | // pick a random existing core BFM | |
219 | task CLASSNAME::pickCore(var integer num, var reg [7:0] mask) { | |
220 | ||
221 | spcCheck("pickCore"); | |
222 | mask = 0; | |
223 | while (!mask) { | |
224 | num = urandom_range(7,0); | |
225 | mask = (1 << num) & spcBfms; | |
226 | } | |
227 | } |