Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / vera / ccxDevices / ccxPktMon.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: ccxPktMon.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 <globals.vri>
36
37#include <ccxDevicesDefines.vri>
38#include <cmp.vri>
39#include <std_display_defines.vri>
40
41#include <std_display_class.vrh>
42#include <basePktClass.vrh>
43#include <cpxPktClass.vrh>
44#include <pcxPktClass.vrh>
45#include <baseParamsClass.vrh>
46#include <sparcParams.vrh>
47#include <ccxDevBaseBFM.vrh>
48
49#define CLASSNAME CCXpktMon
50
51class CCXpktMon {
52
53 local integer myPort;
54 local ccxPort portVarC; // CPX
55 local ccxPort portVarP; // PCX
56
57 task new (integer portIn, ccxPort pcxPort, ccxPort cpxPort);
58 local task monitorMem();
59 local task monitorSpc();
60
61}
62
63
64task CLASSNAME::new(integer portIn, ccxPort pcxPort, ccxPort cpxPort) {
65 myPort = portIn;
66 portVarC = cpxPort;
67 portVarP = pcxPort;
68 if (myPort < 8) monitorSpc();
69 else monitorMem();
70}
71
72
73
74// mem side
75task CLASSNAME::monitorMem() {
76 integer i = 1;
77 reg [7:0] atm = 0;
78 reg [7:0] req = 0;
79
80 fork
81 {
82 // monitor l2 out going pkts
83 if (gParam.ccxPktPrint[PP_CPX] ||
84 gParam.ccxPktPrint[PP_MEM] ||
85 gParam.ccxPktPrintMask[myPort]) {
86
87 // monitor mem out going pkts
88 // need to detect req changing back to zero here.
89 while (1) {
90
91 if (!portVarC.$req) {
92 @(portVarC.$req);
93 req = portVarC.$req;
94 if (myPort !== DEV_NCU && portVarC.$atmo) {
95 i = 2;
96 atm = portVarC.$atmo;
97 } else {
98 i = 1;
99 atm = 0;
100 }
101 }
102
103 repeat (i) {
104 // need to fork off to handle streaming/ back to back packets
105 // this is broken if ifill pkt 2 gets dropped (review?). assuming
106 // ifill 1 & 2 go back to back! May print dropped packets...
107 {
108 CpxPkt pktHndl = new(); // keep in repeat block
109 fork {
110 if (myPort !== DEV_NCU) pktHndl.atm_wire = portVarC.$atmo; //atm;
111 pktHndl.req_wire = portVarC.$req;
112 @(negedge portVarC.$clk);
113 pktHndl.loadPkt(portVarC.$datao, myPort);
114 pktHndl.print(myPort);
115 } join none
116 }
117 @(negedge portVarC.$clk);
118 }// rep i
119 } // while
120 } // if
121 } join none
122
123
124 fork
125 { // monitor incomming PCX pkts to l2
126
127 if (gParam.ccxPktPrint[PP_PCX] ||
128 gParam.ccxPktPrint[PP_MEM] ||
129 gParam.ccxPktPrint[PP_TRG] ||
130 gParam.ccxPktPrintMask[myPort]) {
131
132 // we can get back to back packets...
133 while (1) {
134
135 if (!portVarP.$rdy) {
136 @(portVarP.$rdy);
137 }
138
139 { // keep block
140 PcxPkt pktHndlP = new();
141 // need to fork to handle back to back reqs
142 // and delayed responses
143 fork {
144 // if on L2 port, look at portVar.$atmi
145 if (myPort !== DEV_NCU) pktHndlP.atm_wire = portVarP.$atmi;
146 @(negedge portVarP.$clk);
147 pktHndlP.loadPkt(portVarP.$datai, myPort);
148 pktHndlP.print(myPort);
149 } join none
150 } // blk
151 @(negedge portVarP.$clk);
152 } // while
153 } // if
154 } join none
155}
156
157
158// CPU side
159task CLASSNAME::monitorSpc() {
160 CpxPkt pktHndlC;
161 reg [9:0] atm,req;
162 integer i;
163
164 pktHndlC = new();
165
166 fork
167 {
168 // monitor SPC out going requests.
169 if (gParam.ccxPktPrint[PP_PCX] ||
170 gParam.ccxPktPrint[PP_SPC] ||
171 gParam.ccxPktPrintMask[myPort]) {
172
173 // monitor SPC out going requests.
174 // need to detect req changing back to zero here.
175 while (1) {
176
177 if (!portVarP.$req) {
178 @(portVarP.$req);
179 req = portVarP.$req;
180 if (portVarP.$atmo) {
181 i = 2;
182 atm = portVarP.$atmo;
183 } else {
184 i = 1;
185 atm = 0;
186 }
187 }
188
189 repeat (i) {
190 // need to fork off to handle streaming/ back to back packets
191 {
192 PcxPkt pktHndl = new(); // keep in block
193 fork {
194 pktHndl.atm_wire = atm;
195 pktHndl.req_wire = req;
196 @(negedge portVarP.$clk);
197 pktHndl.loadPkt(portVarP.$datao, myPort);
198 pktHndl.print(myPort);
199 } join none
200 }
201 @(negedge portVarP.$clk);
202 }// rep
203 } // while
204 } // if
205 } join none
206
207
208 fork
209 {
210 // monitor SPC incomming packets/responses
211 if (gParam.ccxPktPrint[PP_CPX] ||
212 gParam.ccxPktPrint[PP_SPC] ||
213 gParam.ccxPktPrint[PP_TRG] ||
214 gParam.ccxPktPrintMask[myPort]) {
215
216 while (1) {
217 if (portVarC.$datai[145] == 0) @(posedge portVarC.$datai[145]);
218 pktHndlC.loadPkt(portVarC.$datai, myPort);
219 pktHndlC.print(myPort);
220 @(negedge portVarC.$clk);
221 }
222 }
223 } join none
224}