Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / siu / vera / monitors / siu_l2_mon.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: siu_l2_mon.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 "siumon.if.vrh"
36#include "siumon_ports_binds.vrh"
37#include "std_display_class.vrh"
38#include "siu_l2_packet.vrh"
39#include "siu_monitor.vrh"
40
41class siu_l2_monitor {
42 l2_mon_port monitor;
43
44 Siu_L2_Packet snd_packet;
45 Siu_L2_Packet rec_packet;
46 integer snd_mbox, rec_mbox;
47
48 StandardDisplay dbg;
49 string myname;
50 integer myid;
51
52 task new (l2_mon_port monitor, integer snd_mbox, integer rec_mbox, integer myid, StandardDisplay dbg);
53
54 task monitor_l2_send ();
55 task monitor_l2_recv ();
56
57 function integer get_send_pkt(Cycle_Mode mode, integer cycle);
58 function integer check_send(Cycle_Mode mode);
59 function integer get_recv_pkt(Cycle_Mode mode, integer cycle);
60 function integer check_recv(Cycle_Mode mode);
61}
62
63task siu_l2_monitor::new(l2_mon_port monitor, integer snd_mbox, integer rec_mbox, integer myid, StandardDisplay dbg)
64{
65 this.monitor = monitor;
66
67 snd_packet = new(RDD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
68 rec_packet = new(RDD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
69
70 this.dbg = dbg;
71 myname = "siu-l2";
72 this.myid = myid;
73 this.snd_mbox = snd_mbox;
74 this.rec_mbox = rec_mbox;
75
76 dbg.dispmon(myname, MON_NORMAL, psprintf ("siu-l2 monitor [%1d] ready", myid));
77
78 fork { monitor_l2_send(); } join none
79 fork { monitor_l2_recv(); } join none
80}
81
82task siu_l2_monitor::monitor_l2_recv()
83{
84Siu_L2_Packet packet;
85integer i, data_cycles;
86integer fail, result, temp;
87
88 while (1)
89 {
90 @(posedge monitor.$clk);
91 if (monitor.$req_vld == 1'b0) {
92 if (monitor.$dbg_req !== 2'b00)
93 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong when no req", myid));
94 }
95 else
96 if (monitor.$req_vld === 1'b1)
97 {
98 data_cycles = 0;
99 fail = 0;
100 temp = 0;
101
102 // header
103 result = get_recv_pkt(HEADER_C, 1);
104 fail = check_recv(HEADER_C);
105 case (monitor.$req[26:24]) {
106 3'b100: data_cycles = 16;
107 3'b010: data_cycles = 2;
108 3'b001: data_cycles = 2;
109 default:
110 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet type unknown", myid));
111 }
112
113 dbg.dispmon(myname, MON_NORMAL, psprintf ("l2%1d recv pkt=%x ", myid, rec_packet.id));
114 case (monitor.$req[26:24]) {
115 3'b100: if (monitor.$dbg_req != 2'b10)
116 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong for WRI", myid));
117 3'b010: if (monitor.$dbg_req != 2'b11)
118 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong for WR8", myid));
119 3'b001: if (monitor.$dbg_req != 2'b01)
120 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong for RDD", myid));
121 default:
122 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet type wrong", myid));
123 }
124
125 // addr cycles
126 @(posedge monitor.$clk);
127 result = get_recv_pkt(ADDR_C, 1);
128 fail = check_recv(ADDR_C);
129 if (monitor.$dbg_req != 2'b00)
130 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong at addr cycle", myid));
131
132 // data cycles
133 for (i=0; i<data_cycles; i++)
134 {
135 @(posedge monitor.$clk);
136 result = get_recv_pkt(DATA_C, i);
137 temp = check_recv(DATA_C);
138 fail += temp;
139 if (monitor.$dbg_req != 2'b00)
140 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet dbg_req wrong at data cycle", myid));
141 }
142
143 dbg.dispmon(myname, MON_NORMAL, psprintf ("l2%1d recv pa=%x", myid, rec_packet.pa));
144
145 if (fail != 0)
146 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv pkt=%x protocol fail!", myid, rec_packet.id));
147 else
148 mailbox_put(rec_mbox, rec_packet);
149 }
150 }
151}
152
153task siu_l2_monitor::monitor_l2_send()
154{
155integer i, result, fail, temp, data_cycles;
156
157 while (1)
158 {
159 @(posedge monitor.$clk);
160 if (monitor.$ctag_vld === 1'b1)
161 {
162 fail = 0;
163 temp = 0;
164
165 result = get_send_pkt(HEADER_C, 1);
166 fail = check_send(HEADER_C);
167
168 dbg.dispmon(myname, MON_NORMAL, psprintf ("l2%1d send pkt=%x ", myid, snd_packet.id));
169
170 if (monitor.$data[16] === 1'b1)
171 data_cycles = 16;
172 if (monitor.$data[16] === 1'b0)
173 data_cycles = 0;
174
175 for (i=0; i<data_cycles; i++)
176 {
177 @(posedge monitor.$clk);
178 result = get_send_pkt(DATA_C, i);
179 temp = check_send(DATA_C);
180 fail += temp;
181 }
182
183 if (fail != 0)
184 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d send pkt=%x protocol fail!", myid, snd_packet.id));
185 else
186 mailbox_put(snd_mbox, snd_packet);
187 }
188 }
189}
190
191function integer siu_l2_monitor::get_recv_pkt(Cycle_Mode mode, integer cycle)
192{
193
194 if (mode == HEADER_C)
195 {
196 rec_packet.bypass = ~monitor.$req[30];
197 rec_packet.posted = monitor.$req[29];
198 rec_packet.ue = monitor.$req[28];
199 rec_packet.source = monitor.$req[27];
200 case (monitor.$req[26:24]) {
201 3'b100: rec_packet.type = WRI;
202 3'b010: rec_packet.type = WRM;
203 3'b001: rec_packet.type = RDD;
204 default:
205 dbg.dispmon(myname, MON_ERR, psprintf ("l2%1d recv packet type unknown", myid));
206 }
207 if (monitor.$req[31] === 1'b1)
208 {
209 if (rec_packet.type == WRM) rec_packet.type = JWR;
210 if (rec_packet.type == RDD) rec_packet.type = JRD;
211 }
212 rec_packet.id = monitor.$req[23:8];
213 if (rec_packet.type == WRM)
214 rec_packet.byte_en = monitor.$req[15:8];
215 rec_packet.pa[39:32] = monitor.$req[7:0];
216 }
217 if (mode == ADDR_C)
218 {
219 rec_packet.pa[31:0] = monitor.$req;
220 }
221 if (mode == DATA_C)
222 {
223 integer index = cycle/2;
224
225 if (cycle & 1 == 0)
226 rec_packet.data[index] = monitor.$req;
227 else
228 rec_packet.data[index] = {monitor.$req , rec_packet.data[index][31:0]};
229 }
230}
231
232function integer siu_l2_monitor::check_send(Cycle_Mode mode)
233{
234 integer fail = 0;
235
236 if (mode == HEADER_C)
237 {
238 }
239 if (mode == DATA_C)
240 {
241 }
242
243 check_send = fail;
244}
245
246function integer siu_l2_monitor::get_send_pkt(Cycle_Mode mode, integer cycle)
247{
248 if (mode == HEADER_C)
249 {
250 snd_packet.bypass = ~monitor.$data[23];
251 snd_packet.posted = monitor.$data[22];
252 snd_packet.ue = monitor.$data[21];
253 snd_packet.source = monitor.$data[20];
254 snd_packet.id = monitor.$data[15:0];
255 if (monitor.$data[31] === 1'b1)
256 {
257 if (monitor.$data[16] === 1'b1)
258 snd_packet.type = JRD;
259 else
260 snd_packet.type = JWR;
261 }
262 else
263 {
264 if (monitor.$data[16] === 1'b1)
265 snd_packet.type = RDD;
266 else
267 snd_packet.type = WRI;
268 }
269 }
270 if (mode == DATA_C)
271 {
272 integer index = cycle/2;
273
274 //if (cycle & 1 == 0)
275 if (cycle % 2 == 0)
276 snd_packet.data[index] = monitor.$data;
277 else
278 {
279 snd_packet.data[index] = {snd_packet.data[index][31:0], monitor.$data};
280 if (snd_packet.type == RDD)
281 dbg.dispmon(myname, MON_NORMAL, psprintf ("l2%1d send pkt=%x data=%x", myid, snd_packet.id, snd_packet.data[index]));
282 }
283
284 }
285}
286
287function integer siu_l2_monitor::check_recv(Cycle_Mode mode)
288{
289 integer fail = 0;
290
291 if (mode == HEADER_C)
292 {
293 }
294 if (mode == DATA_C)
295 {
296 }
297
298 check_recv = fail;
299}