| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: CTTransactionID.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 | class CTTransactionID { |
| 38 | |
| 39 | //////////////////////////////////////////////////////////////////////////// |
| 40 | // Member Variables |
| 41 | // |
| 42 | |
| 43 | protected integer TransID; |
| 44 | protected integer ContextID; |
| 45 | protected integer StrategyID; |
| 46 | |
| 47 | // |
| 48 | //////////////////////////////////////////////////////////////////////////// |
| 49 | |
| 50 | //////////////////////////////////////////////////////////////////////////// |
| 51 | // Member Methods |
| 52 | // |
| 53 | |
| 54 | task new(integer ContextID = 'hx, integer StrategyID = 'hx, integer TransID = 'hx); |
| 55 | virtual task SetTransID(integer value); |
| 56 | virtual task SetContextID(integer value); |
| 57 | virtual task SetStrategyID(integer value); |
| 58 | virtual function integer GetTransID(); |
| 59 | virtual function integer GetContextID(); |
| 60 | virtual function integer GetStrategyID(); |
| 61 | virtual function string GetString(); // return a string for printing IDs |
| 62 | virtual function string GetSString(); // return a string for printing IDs (for backward compatibility) |
| 63 | |
| 64 | virtual function CTTransactionID NextContextID(); // return a new instantion of an ID object with the next ContextID |
| 65 | virtual function CTTransactionID NextStrategyID(); // return a new instantion of an ID object with the next StrategyID |
| 66 | virtual function CTTransactionID NextTransID(); // return a new instantion of an ID object with the next TransID |
| 67 | // |
| 68 | //////////////////////////////////////////////////////////////////////////// |
| 69 | |
| 70 | } |
| 71 | |
| 72 | //////////////////////////////////////////////////////////////////////////// |
| 73 | // Set |
| 74 | // |
| 75 | task CTTransactionID::new(integer ContextID = 'hx, integer StrategyID = 'hx, integer TransID = 'hx) { |
| 76 | this.SetContextID(ContextID); |
| 77 | this.SetStrategyID(StrategyID); |
| 78 | this.SetTransID(TransID); |
| 79 | } |
| 80 | |
| 81 | task CTTransactionID::SetTransID(integer value) {TransID = value;} |
| 82 | task CTTransactionID::SetContextID(integer value) {ContextID = value;} |
| 83 | task CTTransactionID::SetStrategyID(integer value) {StrategyID = value;} |
| 84 | |
| 85 | // |
| 86 | //////////////////////////////////////////////////////////////////////////// |
| 87 | |
| 88 | //////////////////////////////////////////////////////////////////////////// |
| 89 | // Get |
| 90 | // |
| 91 | |
| 92 | function integer CTTransactionID::GetTransID() {GetTransID = TransID;} |
| 93 | function integer CTTransactionID::GetContextID() {GetContextID = ContextID;} |
| 94 | function integer CTTransactionID::GetStrategyID() {GetStrategyID = StrategyID;} |
| 95 | |
| 96 | function string CTTransactionID::GetString() { |
| 97 | // sprintf (GetString, "TransID=%0d StrategyID=%0d ContextID=%0d", TransID, StrategyID, ContextID); |
| 98 | sprintf (GetString, "(c%0d,s%0d,t%0d)", ContextID, StrategyID, TransID); |
| 99 | } |
| 100 | |
| 101 | function string CTTransactionID::GetSString() { |
| 102 | GetSString = GetString(); |
| 103 | } |
| 104 | |
| 105 | // |
| 106 | //////////////////////////////////////////////////////////////////////////// |
| 107 | |
| 108 | |
| 109 | function CTTransactionID CTTransactionID::NextContextID() { |
| 110 | NextContextID = new(ContextID++, 0, 0); |
| 111 | } |
| 112 | |
| 113 | function CTTransactionID CTTransactionID::NextStrategyID() { |
| 114 | NextStrategyID = new(ContextID, StrategyID++, 0); |
| 115 | } |
| 116 | |
| 117 | function CTTransactionID CTTransactionID::NextTransID() { |
| 118 | NextTransID = new(ContextID, StrategyID, TransID++); |
| 119 | } |
| 120 | |
| 121 | // |
| 122 | // end CTTransactionID |
| 123 | //////////////////////////////////////////////////////////////////////////// |
| 124 | //////////////////////////////////////////////////////////////////////////// |