Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: XactorList.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 "XactorUtilities.vrh" | |
37 | #include "XactorBasePacket.vrh" | |
38 | #include "XactorBaseExpectDataStruct.vrh" | |
39 | #include "XactorDefines.vri" | |
40 | #include "XactorComponentsDefines.vri" | |
41 | ||
42 | typedef class ListNode; | |
43 | ||
44 | // This class declares and implements the node used by the linked list data structure. | |
45 | class ListNode { | |
46 | ||
47 | XactorBasePacket Item; // Xactor Packet | |
48 | event RemoveEvents[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS]; // Removed is an event flag that will | |
49 | // be triggered when the node is removed | |
50 | ListNode Next; // Next node in the linked list | |
51 | ListNode NextNext; // Next Next node in the linked list | |
52 | ||
53 | task new (XactorBasePacket i, | |
54 | var event e[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS]); | |
55 | ||
56 | // Copies an array of events | |
57 | virtual task AssignEvent(var event Dest[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS], | |
58 | var event Src[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS] | |
59 | ); | |
60 | ||
61 | // Returns the next element | |
62 | virtual function ListNode NextElement(); | |
63 | ||
64 | // Inserts a new element with the specified values at the end of the list | |
65 | virtual task Insert (XactorBasePacket i, | |
66 | var event e[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS] | |
67 | ); | |
68 | ||
69 | // Will keep walking through the link list checking for duplicated nodes | |
70 | virtual task CheckDuplicatedExpect(XactorBasePacket i); | |
71 | ||
72 | // Deletes a node with the specified values and returns | |
73 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
74 | virtual task Delete (XactorBasePacket i, | |
75 | var ListNode NodePtr, | |
76 | var bit success | |
77 | ); | |
78 | ||
79 | // Deletes a node with the specified reference i | |
80 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
81 | virtual task RefDelete (XactorBasePacket i, | |
82 | var ListNode NodePtr, | |
83 | var bit success | |
84 | ); | |
85 | ||
86 | // Will keep walking through the link list checking for duplicated nodes | |
87 | virtual task CheckWCDuplicatedExpect(XactorBasePacket i); | |
88 | ||
89 | // Deletes the first node with the specified values and returns | |
90 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
91 | // NOTE: This task accepts wildcards. | |
92 | virtual task WCDelete1 (XactorBasePacket i, | |
93 | var ListNode NodePtr, | |
94 | var bit success | |
95 | ); | |
96 | ||
97 | // Prints a specific node | |
98 | virtual task PrintNode (); | |
99 | ||
100 | // Returns 1 if i is in the linked list and 0 otherwise. | |
101 | // This function accepts "wildcards" | |
102 | virtual function bit InList (XactorBasePacket i); | |
103 | ||
104 | // Triggers the remove event on each node. This will cause all | |
105 | // the pending expect threads to finish. | |
106 | virtual task ResetNode (); | |
107 | ||
108 | } | |
109 | ||
110 | //////////////// | |
111 | // Definitions | |
112 | //////////////// | |
113 | ||
114 | task ListNode::new (XactorBasePacket i, | |
115 | var event e[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS]) { | |
116 | ||
117 | AssignEvent(RemoveEvents, e); | |
118 | Item = i; | |
119 | Next = null; | |
120 | NextNext = null; | |
121 | } | |
122 | ||
123 | task ListNode::AssignEvent(var event Dest[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS], | |
124 | var event Src[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS] | |
125 | ) { | |
126 | integer EventCnt; | |
127 | ||
128 | for(EventCnt = 0; EventCnt <= XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS - 1; EventCnt++) { | |
129 | Dest[EventCnt] = Src[EventCnt]; | |
130 | } | |
131 | } | |
132 | ||
133 | // Returns the next element | |
134 | function ListNode ListNode::NextElement() { | |
135 | NextElement = Next; | |
136 | } | |
137 | ||
138 | // Inserts a new element with the specified values at the end of the list | |
139 | task ListNode::Insert (XactorBasePacket i, | |
140 | var event e[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS] | |
141 | ) { | |
142 | ||
143 | if(Item.PktCompare("=?=", i)) { | |
144 | Item.PktDisplay(RTYP_XACTOR_FMWORK_DUP_EXPECT_ERR, "Posting a duplicated Expect"); | |
145 | } | |
146 | ||
147 | if (Next == null) { | |
148 | Next = new(i, e); | |
149 | } | |
150 | else { | |
151 | Next.Insert(i, e); | |
152 | } | |
153 | } | |
154 | ||
155 | // Will keep walking through the link list checking for duplicated nodes | |
156 | task ListNode::CheckDuplicatedExpect(XactorBasePacket i) { | |
157 | if(Item.PktCompare("===", i)) { | |
158 | Item.PktDisplay(RTYP_XACTOR_FMWORK_SAMPLED_DUP_XACTION_ERR, | |
159 | "Sampled Transaction satisfies duplicated Expect" | |
160 | ); | |
161 | } | |
162 | if (Next !== null) { | |
163 | Next.CheckDuplicatedExpect(i); | |
164 | } | |
165 | } | |
166 | ||
167 | // Deletes a node with the specified values and returns | |
168 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
169 | task ListNode::Delete (XactorBasePacket i, | |
170 | var ListNode NodePtr, | |
171 | var bit success | |
172 | ) { | |
173 | ||
174 | if (i.PktCompare("===", Item)) { | |
175 | i.SetID(Item.GetID()); | |
176 | ||
177 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_EVENT]); // Remove event | |
178 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_BY_XACTOR_EVENT]); // Removed by xactor | |
179 | ||
180 | NodePtr = Next; | |
181 | if(NodePtr !== null) | |
182 | NodePtr.CheckDuplicatedExpect(i); | |
183 | success = 1'b1; | |
184 | } | |
185 | else { | |
186 | if (Next == null) | |
187 | success = 1'b0; | |
188 | else | |
189 | Next.Delete(i, Next, success); | |
190 | } | |
191 | } | |
192 | ||
193 | // Deletes a node with the specified reference i | |
194 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
195 | task ListNode::RefDelete (XactorBasePacket i, | |
196 | var ListNode NodePtr, | |
197 | var bit success | |
198 | ) { | |
199 | if (i === Item) { | |
200 | i.SetID(Item.GetID()); | |
201 | ||
202 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_EVENT]); // Remove event | |
203 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_BY_USER_EVENT]); // Removed by xactor | |
204 | ||
205 | NodePtr = Next; | |
206 | success = 1'b1; | |
207 | } | |
208 | else { | |
209 | if (Next == null) | |
210 | success = 1'b0; | |
211 | else | |
212 | Next.RefDelete(i, Next, success); | |
213 | } | |
214 | } | |
215 | ||
216 | // Will keep walking through the link list checking for duplicated nodes | |
217 | task ListNode::CheckWCDuplicatedExpect(XactorBasePacket i) { | |
218 | if(Item.PktCompare("=?=", i)) { | |
219 | Item.PktDisplay(RTYP_XACTOR_FMWORK_SAMPLED_DUP_XACTION_ERR, | |
220 | "Sampled Transaction satisfies duplicated Expect" | |
221 | ); | |
222 | } | |
223 | if (Next !== null) { | |
224 | Next.CheckWCDuplicatedExpect(i); | |
225 | } | |
226 | } | |
227 | ||
228 | // Deletes the first node with the specified values and returns | |
229 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
230 | // NOTE: This task accepts wildcards. | |
231 | task ListNode::WCDelete1 (XactorBasePacket i, | |
232 | var ListNode NodePtr, | |
233 | var bit success | |
234 | ) { | |
235 | ||
236 | if (i.PktCompare("=?=", Item)) { | |
237 | i.SetID(Item.GetID()); | |
238 | Item.PktCopy(i); // Copy contents of Sampled packet to expected packet | |
239 | ||
240 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_EVENT]); // Remove event | |
241 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_BY_XACTOR_EVENT]); // Removed by xactor | |
242 | ||
243 | NodePtr = Next; | |
244 | if(NodePtr !== null) | |
245 | NodePtr.CheckWCDuplicatedExpect(i); | |
246 | success = 1'b1; | |
247 | } | |
248 | else { | |
249 | if (Next == null) | |
250 | success = 1'b0; | |
251 | else { | |
252 | Next.WCDelete1(i, | |
253 | Next, | |
254 | success | |
255 | ); | |
256 | } | |
257 | } | |
258 | } | |
259 | ||
260 | // Prints a specific node | |
261 | task ListNode::PrintNode () { | |
262 | ||
263 | Item.PktDisplay(RTYP_INFO, "Dump Expect List"); | |
264 | ||
265 | if (Next != null) | |
266 | Next.PrintNode(); | |
267 | } | |
268 | ||
269 | // Returns 1 if i is in the linked list and 0 otherwise. | |
270 | // This function accepts "wildcards" | |
271 | function bit ListNode::InList (XactorBasePacket i) { | |
272 | ||
273 | if (i.PktCompare("===", Item)) | |
274 | InList = 1'b1; | |
275 | else { | |
276 | if (Next == null) | |
277 | InList = 1'b0; | |
278 | else | |
279 | InList = Next.InList(i); | |
280 | } | |
281 | } | |
282 | ||
283 | // Triggers the remove event on each node. This will cause all | |
284 | // the pending expect threads to finish. | |
285 | task ListNode::ResetNode () { | |
286 | ||
287 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_EVENT]); // Remove event | |
288 | trigger(ON, RemoveEvents[XACT_COMP_EXPECT_REMOVED_BY_USER_EVENT]); // Removed by user event | |
289 | ||
290 | if (Next != null) | |
291 | Next.ResetNode(); | |
292 | } | |
293 | ||
294 | ||
295 | //######################## | |
296 | // XactorList class | |
297 | //######################## | |
298 | ||
299 | // This is the Link List data structure class. This is not an ordered list | |
300 | // since its main purpose is to be used to store packets with wildcards. | |
301 | class XactorList extends XactorBaseExpectDataStruct { | |
302 | ||
303 | protected ListNode Head; // head pointer of this data structure | |
304 | ||
305 | task new (); | |
306 | ||
307 | // Will return the number of nodes in the linked list. | |
308 | virtual function integer CountNodes(); | |
309 | ||
310 | // Inserts a new node with the specified values at the end of the list | |
311 | virtual task Insert (XactorBasePacket i, | |
312 | var event e[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS] | |
313 | ); | |
314 | ||
315 | // Deletes the first node with the specified values and returns: | |
316 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
317 | // No wildcards | |
318 | virtual task Delete (XactorBasePacket i, | |
319 | var bit success | |
320 | ); | |
321 | ||
322 | // Deletes the node that matches the reference value i | |
323 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
324 | virtual task RefDelete (XactorBasePacket i, | |
325 | var bit success | |
326 | ); | |
327 | ||
328 | // Deletes the first node with the specified values and returns: | |
329 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
330 | // Use of wildcards | |
331 | virtual task WildCardDelete1 (XactorBasePacket i, | |
332 | var bit success | |
333 | ); | |
334 | ||
335 | // Prints all the nodes of the link list. | |
336 | virtual task PrintNodes (); | |
337 | ||
338 | // Returns 1 if Item is within the link list and 0 otherwise. | |
339 | // Accepts wildcards | |
340 | virtual function bit InStructure (XactorBasePacket i); | |
341 | ||
342 | // Returns 1 if the link list is empty and 0 otherwise. | |
343 | virtual function bit Empty(); | |
344 | ||
345 | // Triggers every node's remove event and then deletes the | |
346 | // complete link list | |
347 | virtual task Reset(); | |
348 | ||
349 | } | |
350 | ||
351 | //////////////// | |
352 | // Definitions | |
353 | //////////////// | |
354 | ||
355 | task XactorList::new () {} | |
356 | ||
357 | // Will return the number of nodes in the linked list. | |
358 | function integer XactorList::CountNodes() { | |
359 | ||
360 | integer Counter = 0; | |
361 | ListNode NodeElement = Head; | |
362 | ||
363 | while(NodeElement != null) { | |
364 | Counter++; | |
365 | NodeElement = NodeElement.NextElement(); | |
366 | } | |
367 | ||
368 | CountNodes = Counter; | |
369 | } | |
370 | ||
371 | // Inserts a new node with the specified values at the end of the list | |
372 | task XactorList::Insert (XactorBasePacket i, | |
373 | var event e[XACT_EXPECT_DATA_STRUCT_REMOVE_EVENTS] | |
374 | ) { | |
375 | ||
376 | if (Head == null) | |
377 | Head = new(i, e); | |
378 | else | |
379 | Head.Insert(i, e); | |
380 | } | |
381 | ||
382 | // Deletes the first node with the specified values and returns: | |
383 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
384 | // No wildcards | |
385 | task XactorList::Delete (XactorBasePacket i, | |
386 | var bit success | |
387 | ) { | |
388 | if (Head == null) | |
389 | success = 1'b0; | |
390 | else | |
391 | Head.Delete(i, Head, success); | |
392 | } | |
393 | ||
394 | // Deletes the node that matches the reference value i | |
395 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
396 | task XactorList::RefDelete (XactorBasePacket i, | |
397 | var bit success | |
398 | ) { | |
399 | if (Head == null) | |
400 | success = 1'b0; | |
401 | else | |
402 | Head.RefDelete(i, Head, success); | |
403 | } | |
404 | ||
405 | // Deletes the first node with the specified values and returns: | |
406 | // Success = 1 if the node was found and deleted and Success = 0 otherwise. | |
407 | // Use of wildcards | |
408 | task XactorList::WildCardDelete1 (XactorBasePacket i, | |
409 | var bit success | |
410 | ) { | |
411 | ||
412 | if (Head == null) | |
413 | success = 1'b0; | |
414 | else { | |
415 | Head.WCDelete1(i, Head, success); | |
416 | } | |
417 | } | |
418 | ||
419 | // Prints all the nodes of the link list. | |
420 | task XactorList::PrintNodes () { | |
421 | ||
422 | if (Head != null) | |
423 | Head.PrintNode(); | |
424 | } | |
425 | ||
426 | // Returns 1 if Item is within the link list and 0 otherwise. | |
427 | // Accepts wildcards | |
428 | function bit XactorList::InStructure (XactorBasePacket i) { | |
429 | ||
430 | if (Head == null) | |
431 | InStructure = 1'b0; | |
432 | else | |
433 | InStructure = Head.InList(i); | |
434 | } | |
435 | ||
436 | // Returns 1 if the link list is empty and 0 otherwise. | |
437 | function bit XactorList::Empty () { | |
438 | if (Head == null) | |
439 | Empty = 1'b1; | |
440 | else | |
441 | Empty = 1'b0; | |
442 | } | |
443 | ||
444 | // Triggers every node's remove event and then deletes the | |
445 | // complete link list | |
446 | task XactorList::Reset () { | |
447 | ||
448 | if (Head != null) | |
449 | Head.ResetNode(); | |
450 | ||
451 | Head = null; | |
452 | } | |
453 | ||
454 | ||
455 |