Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / vera / classes / asmEvent.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: asmEvent.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
37// This class holds a list of event classes (other instances of self).
38// All of the additional (>1) user events for a pc are in the associative array/list.
39// The top event class can just be a holder for the associative array/list once
40// the initial event is done. It also operates on the associative array/list.
41// NOTE the done bit below.
42class EventClass {
43
44 // for general use
45 reg [63:0] misc64A = 64'hffffffffffffffff; // misc 64 bit reg
46 reg [63:0] misc64B = 64'hffffffffffffffff;
47 reg [63:0] misc64C = 64'hffffffffffffffff;
48 reg [63:0] misc64D = 64'hffffffffffffffff;
49 reg [63:0] misc64E = 64'hffffffffffffffff;
50 reg misc01A = 0; // misc 1 bit reg
51 reg misc01B = 0; // misc 1 bit reg
52 reg misc01C = 0; // misc 1 bit reg
53 reg misc01D = 0; // misc 1 bit reg
54 integer miscIntA = -1; // misc integer
55 integer miscIntB = -1; // misc integer
56 integer miscIntC = -1; // misc integer
57 integer miscIntD = -1; // misc integer
58 integer miscIntE = -1; // misc integer
59 string miscStrA = "-";
60 string miscStrB = "-";
61 string miscStrC = "-";
62 reg [127:0] misc128A = 128'hffffffffffffffffffffffffffffffff;
63
64 // for somewhat specific use
65 reg [63:0] tid = 64'hffffffffffffffff; // target tid
66 reg [63:0] intType = 64'hffffffffffffffff; // intp type/data/etc
67 reg [63:0] tidMask = 0; // a selection of which threads will get an interrupt
68 reg [63:0] thisTid = 64; // Event is ignored unless PC & thread match.
69 reg multiShot = 0; // The user event will be acted apon many times, not discarded.
70 integer wait = 0; // delay/wait
71 integer src = 16; // driving or sending port.
72 string routine = "-"; // task
73 reg [63:0] pc = 64'hffffffffffffffff;
74
75
76 // internal use
77
78 // each object uses these
79 protected reg done; // this event is done if not multiShot.
80 protected EventClass next; // pointer to next event obj for this pc
81 protected EventClass head; // pointer always points to head obj of list
82
83 // used in head object only
84 protected integer remain; // total items left to process
85 protected integer count; // total items in list
86 protected EventClass tail; // pointer always points to tail obj of list
87 protected EventClass doingEvent; // points to next item to process. circular.
88
89 // static
90 protected static reg [31:0] eventCount; // total events
91
92 task new (reg noCount = 0) {
93 // init statics
94 if (eventCount !== 32'bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) {
95 if (!noCount) eventCount++;
96 } else {
97 eventCount = 1; // first time
98 }
99
100 head = this;
101 tail = this;
102 doingEvent = this;
103 remain = 1;
104 count = 1;
105 done = 0;
106 next = null;
107
108 }
109
110
111 // add additional events for this same pc.
112 // every event has head pointing to same head.
113 // this can only be called from head object.
114 task push(EventClass newEvent) {
115 if (this !== head)
116 error("asmEvent: push can only be called from the head object\n");
117
118 newEvent.head = this.head;
119 tail.next = newEvent;
120 head.tail = newEvent;
121 head.remain++;
122 head.count++;
123
124
125 // only tracked in head object
126 newEvent.count = 999999999;
127 newEvent.remain = 999999999;
128 newEvent.doingEvent = null;
129 newEvent.tail = null;
130
131#ifdef DEBUGEVENTCLASS
132 newEvent.printSelf();
133#endif
134 }
135
136
137 // get head pointer and reset doingEvent
138 function EventClass getHeadEvent() {
139 getHeadEvent = head;
140 head.doingEvent = head;
141 }
142
143
144 /*
145 When processing, it is assumed that ALL events will be done for PC at
146 once in some sort of zero time loop. Events are never added after
147 the initial events.ev file parsing is done. multiShot events are
148 never consumed/done. If the functions returned EventClass value is
149 null, then all events for this single PC's encounter are processed
150 (but not actually consumed if multiShot). Everything is finished
151 for this PC when remaining = 0 (inplies no multishots). if notDone
152 is set, consider this event "not done yet" no matter what.
153 Called after an event has been handled.
154 */
155 function EventClass getNextEvent(var integer remaining,
156 reg notDone = 0,
157 var integer evCount) {
158
159 if (!remain)
160 error("Can't call getNextEvent after remaining goes to zero\n");
161 if (this !== head)
162 error("asmEvent: getNextEvent can only be called from the head object\n");
163
164 // default return
165 getNextEvent = null;
166
167 // doingEvent will be done if not multishot and notDone was not passed
168 if (head.doingEvent.multiShot == 0 && notDone == 0) {
169 head.doingEvent.done = 1;
170 head.remain--; // track in head only
171 eventCount--; // static
172 }
173
174 // figure out which event in list is next. always starts w/ head.
175 // doingEvent starts at head. if doingEvent == head, we are finishing head event.
176 if (head.remain) {
177
178 // find next event that is not done, or hit tail
179 while (head.doingEvent.next !== null) {
180 head.doingEvent = head.doingEvent.next;
181 if (!head.doingEvent.done) {
182 getNextEvent = head.doingEvent;
183 break;
184 }
185 }
186
187 } else {
188 // no remaining events in this PCs list
189 head.doingEvent = null;
190 getNextEvent = null;
191 }
192
193 // return values
194 remaining = head.remain;
195 evCount = eventCount;
196
197 }
198
199
200
201
202 function EventClass getHead() {
203 getHead = head;
204 }
205
206 function integer remaining() {
207 remaining = remain;
208 }
209
210 function integer getEventCount() {
211 getEventCount = eventCount;
212 }
213
214 task setDone(reg done) {
215 this.done = done;
216 }
217
218 // null all pointers for this PC's list
219 task delete() {
220 EventClass localNext;
221 localNext = next;
222 while (localNext !== null) {
223 next = null;
224 localNext = localNext.next;
225 }
226 localNext = null;
227 this.next = null;
228 }
229
230
231 task printSelf() {
232 printf("---self start--------------------------------------------------------\n");
233 printLines();
234 printf("---self end ---------------------------------------------------------\n");
235 }
236
237 // print from this node down
238 task printList() {
239 integer i;
240 EventClass tmpPtr;
241
242 // printf("--------------------------------------------------------------\n");
243 printf("---list start-------------------------------------------------\n");
244 this.printLines();
245 tmpPtr = this.next;
246 while (tmpPtr !== null) {
247 printf("----\n");
248 tmpPtr.printLines();
249 tmpPtr = tmpPtr.next;
250 }
251 printf("---list end---------------------------------------------------\n");
252 // printf("--------------------------------------------------------------\n");
253 }
254
255 task printLines() {
256 printf("EventClass: routine = %s\n", routine);
257 printf("EventClass: pc[63:0] = 0x%h\n", pc);
258 printf("EventClass: tid[5:0] = 0x%0h\n", tid);
259 printf("EventClass: tidMask[63:0] = 0x%h\n",tidMask);
260 printf("EventClass: wait = %0d\n", wait);
261 printf("EventClass: src = %0d\n", src);
262 printf("EventClass: multiShot = %0d\n", multiShot);
263 printf("EventClass: intType[63:0] = 0x%0h\n", intType);
264 printf("EventClass: misc64A[63:0] = 0x%0h\n", misc64A);
265 printf("EventClass: misc64B[63:0] = 0x%0h\n", misc64B);
266 printf("EventClass: misc64C[63:0] = 0x%0h\n", misc64C);
267 printf("EventClass: misc64D[63:0] = 0x%0h\n", misc64D);
268 printf("EventClass: misc64E[63:0] = 0x%0h\n", misc64E);
269 printf("EventClass: misc01A = %0b\n", misc01A);
270 printf("EventClass: misc01B = %0b\n", misc01B);
271 printf("EventClass: misc01C = %0b\n", misc01C);
272 printf("EventClass: misc01D = %0b\n", misc01D);
273 printf("EventClass: miscIntA = %0d\n", miscIntA);
274 printf("EventClass: miscIntB = %0d\n", miscIntB);
275 printf("EventClass: miscIntC = %0d\n", miscIntC);
276 printf("EventClass: miscIntD = %0d\n", miscIntD);
277 printf("EventClass: miscIntE = %0d\n", miscIntE);
278 printf("EventClass: miscStrA = %s\n", miscStrA);
279 printf("EventClass: miscStrB = %s\n", miscStrB);
280 printf("EventClass: miscStrC = %s\n", miscStrC);
281 printf("EventClass: head.remain = %0d\n", head.remain); //head == this ? remain : -99);
282 printf("EventClass: head.count = %0d\n", head.count);
283 printf("EventClass: eventCount = %0d\n", eventCount);
284 printf("EventClass: done = %0d\n", done);
285 printf("EventClass: head = %s\n", head == this ? "I AM HEAD":"NOT HEAD");
286 printf("EventClass: next = %s\n", next == null ? "NULL":"-->");
287 printf("EventClass: doingEvent = %s\n", doingEvent == null ? "NULL":"-->");
288 }
289}