| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: XactorTransaction.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 "XactorBaseBuilder.vrh" |
| 38 | #include "XactorBasePacket.vrh" |
| 39 | #include "XactorBaseSignalInterface.vrh" |
| 40 | #include "XactorBaseManager.vrh" |
| 41 | #include "XactorBaseTransaction.vrh" |
| 42 | #include "XactorManager.vrh" |
| 43 | #include "XactorDefines.vri" |
| 44 | |
| 45 | #include "CTTransactionID.vrh" |
| 46 | |
| 47 | #include "cReport.vrh" |
| 48 | |
| 49 | class XactorTransaction extends XactorBaseTransaction { |
| 50 | |
| 51 | // MyReport declared in XactorBaseTransaction |
| 52 | |
| 53 | // Transactor Name declared in XactorBaseTransaction |
| 54 | |
| 55 | // Data Packet declared in XactorBaseTransaction |
| 56 | |
| 57 | // Transaction Manager declared in XactorBaseTransaction |
| 58 | |
| 59 | // Interface Manager declared in XactorBaseTransaction |
| 60 | |
| 61 | task new(XactorBaseBuilder Builder); |
| 62 | |
| 63 | // Pass a CTTransactionID object to the transaction |
| 64 | virtual task SetID(CTTransactionID XactionID); |
| 65 | |
| 66 | // Returns a CTTransactionID |
| 67 | virtual function CTTransactionID GetID(); |
| 68 | |
| 69 | // FieldType is a string that indicates which field (within the Packet member) to set. |
| 70 | // FieldValue is the actual value that the packet field will be set to. |
| 71 | virtual task SetPacket(string FieldType, |
| 72 | bit [XACT_FIELD_WIDTH-1:0] FieldValue |
| 73 | ); |
| 74 | |
| 75 | // FieldType is a string that indicates which field (within the Packet member) to get. |
| 76 | // FieldValue is the returned value of the field indicated by FieldType. |
| 77 | virtual function bit [XACT_FIELD_WIDTH-1:0] GetPacket(string FieldType); |
| 78 | |
| 79 | // Resets Packet member |
| 80 | virtual task ResetPacket(); |
| 81 | |
| 82 | // FieldType is a string that indicates which field (within the Signal Interface member) |
| 83 | // to set. FieldValue is the actual value that the packet field will be set to. |
| 84 | virtual task SetSignalInterface(string FieldType, |
| 85 | bit [XACT_FIELD_WIDTH-1:0] FieldValue |
| 86 | ); |
| 87 | |
| 88 | // FieldType is a string that indicates which field (within the Signal Interface member) |
| 89 | // to get. FieldValue is the returned value of the field indicated by FieldType. |
| 90 | virtual function bit [XACT_FIELD_WIDTH-1:0] GetSignalInterface(string FieldType); |
| 91 | |
| 92 | // This task will use the report utility to print all the information about the |
| 93 | // transaction. |
| 94 | virtual task Display(string msg = ""); |
| 95 | |
| 96 | // This function returns the name of the transactor. |
| 97 | virtual function string Name(); |
| 98 | |
| 99 | // This task prints a complete list of all the pending expects of the transactor. |
| 100 | virtual task DumpExpectList(); |
| 101 | |
| 102 | // Returns 1 if an expect (with the same value of the Packet member) is pending and |
| 103 | // 0 otherwise. |
| 104 | virtual function bit IsExpectPending(); |
| 105 | |
| 106 | // Returns the number of pending expects of the transactor. |
| 107 | virtual function integer ExpectCount(); |
| 108 | |
| 109 | // This function is similar to the Expect(next one). The only difference is in the case of a |
| 110 | // timeout, the expect thread will be silently removed from the expect manager data structures. |
| 111 | virtual function bit ExpectExpire(integer Window); |
| 112 | |
| 113 | // This function will launch an expect thread. The thread will be installed in the data |
| 114 | // structures of the expect manager and will stay there waiting for the DUT to drive the |
| 115 | // expected value. |
| 116 | // If Expect is satisfied by a matched transaction driven by the DUT within the Window period, |
| 117 | // then the function returns a 1 indicating success. If the Window period elapses without a |
| 118 | // match, then it returns a 0. |
| 119 | virtual function bit Expect(integer Window); |
| 120 | |
| 121 | // This task will launch a thread that will be waiting for the next transaction driven by the |
| 122 | // DUT. It will then return a packet object (through the parameter list) with the data fields |
| 123 | // of the sampled transaction. |
| 124 | // The transactor timesout on a Sample() if no transaction is driven by the DUT within the |
| 125 | // Window of cycles. |
| 126 | virtual task Sample(XactorBasePacket Pkt, integer Window = 50000); |
| 127 | |
| 128 | // This function removes a pending expect for a transaction that matches the values in Packet. If |
| 129 | // a pending expect is found the function returns 1, and 0 otherwise. |
| 130 | virtual function bit Remove(); |
| 131 | |
| 132 | // This task initiates a transaction to be driven to the DUT. |
| 133 | // D : Number of cycles (delay) before the transaction is sent to the drive manager to be |
| 134 | // scheduled. It could be seen as a priority given to the drive transaction, the larger the |
| 135 | // delay number, the longer the time the transaction will have to wait before it is scheduled |
| 136 | // for driving. The default value is 0 which means that the transaction is scheduled right |
| 137 | // away. |
| 138 | virtual task Drive(integer D = 0); |
| 139 | |
| 140 | // This task enables the transactor. Any scheduled drives or pending expects are resumed. |
| 141 | virtual task Enable(); |
| 142 | |
| 143 | // This task disables the transactor, preventing reporting of unexpected transactions or |
| 144 | // incorrect design behavior. Scheduled drives and pending expects are suspended, but not lost. |
| 145 | virtual task Disable(); |
| 146 | |
| 147 | // This task resets the state of the transactor. All scheduled drives and pending expects are lost. |
| 148 | virtual task Reset(); |
| 149 | |
| 150 | } |
| 151 | |
| 152 | //////////////// |
| 153 | // Definitions |
| 154 | //////////////// |
| 155 | |
| 156 | task XactorTransaction::new(XactorBaseBuilder Builder |
| 157 | ) { |
| 158 | |
| 159 | XactorName = Builder.CreateName(); |
| 160 | Packet = Builder.CreatePacket(); |
| 161 | MyReport = Builder.CreateReport(); |
| 162 | Manager = Builder.CreateManager(); |
| 163 | SignalInterface = Builder.CreateSignalInterface(); |
| 164 | } |
| 165 | |
| 166 | // Pass a CTTransactionID object to the transaction |
| 167 | task XactorTransaction::SetID(CTTransactionID XactionID) { |
| 168 | Packet.SetID(XactionID); |
| 169 | } |
| 170 | |
| 171 | // Returns a CTTransactionID |
| 172 | function CTTransactionID XactorTransaction::GetID() { |
| 173 | GetID = Packet.GetID(); |
| 174 | } |
| 175 | |
| 176 | // FieldType is a string that indicates which field (within the Packet member) to set. |
| 177 | // FieldValue is the actual value that the packet field will be set to. |
| 178 | task XactorTransaction::SetPacket(string FieldType, |
| 179 | bit [XACT_FIELD_WIDTH-1:0] FieldValue |
| 180 | ) { |
| 181 | Packet.Set(FieldType, FieldValue); |
| 182 | } |
| 183 | |
| 184 | // FieldType is a string that indicates which field (within the Packet member) to get. |
| 185 | // FieldValue is the returned value of the field indicated by FieldType. |
| 186 | function bit [XACT_FIELD_WIDTH-1:0] XactorTransaction::GetPacket(string FieldType) { |
| 187 | GetPacket = Packet.Get(FieldType); |
| 188 | } |
| 189 | |
| 190 | // Resets Packet member |
| 191 | task XactorTransaction::ResetPacket() { |
| 192 | Packet.PktReset(); |
| 193 | } |
| 194 | |
| 195 | // FieldType is a string that indicates which field (within the Signal Interface member) |
| 196 | // to set. FieldValue is the actual value that the packet field will be set to. |
| 197 | task XactorTransaction::SetSignalInterface(string FieldType, |
| 198 | bit [XACT_FIELD_WIDTH-1:0] FieldValue |
| 199 | ) { |
| 200 | SignalInterface.Set(FieldType, FieldValue); |
| 201 | } |
| 202 | |
| 203 | // FieldType is a string that indicates which field (within the Signal Interface member) |
| 204 | // to get. FieldValue is the returned value of the field indicated by FieldType. |
| 205 | function bit [XACT_FIELD_WIDTH-1:0] XactorTransaction::GetSignalInterface(string FieldType |
| 206 | ) { |
| 207 | GetSignalInterface = SignalInterface.Get(FieldType); |
| 208 | } |
| 209 | |
| 210 | // This task will use the report utility to print all the information about the |
| 211 | // transaction. |
| 212 | task XactorTransaction::Display(string msg = "") { |
| 213 | if (msg == "") |
| 214 | Packet.PktDisplay(RTYP_INFO, "Current transaction"); |
| 215 | else |
| 216 | Packet.PktDisplay(RTYP_INFO, msg); |
| 217 | } |
| 218 | |
| 219 | // This function returns the name of the transactor. |
| 220 | function string XactorTransaction::Name() { |
| 221 | Name = XactorName; |
| 222 | } |
| 223 | |
| 224 | // This task prints a complete list of all the pending expects of the transactor. |
| 225 | task XactorTransaction::DumpExpectList() { |
| 226 | MyReport.report(RTYP_INFO, "%0s: Dumping Expects", XactorName); |
| 227 | Manager.DumpExpects(); |
| 228 | } |
| 229 | |
| 230 | // Returns 1 if an expect (with the same value of the Packet member) is pending and |
| 231 | // 0 otherwise. |
| 232 | function bit XactorTransaction::IsExpectPending() { |
| 233 | IsExpectPending = Manager.ExpectPending(Packet); |
| 234 | } |
| 235 | |
| 236 | // Returns the number of pending expects of the transactor. |
| 237 | function integer XactorTransaction::ExpectCount() { |
| 238 | ExpectCount = Manager.NumExpects(); |
| 239 | MyReport.report(RTYP_INFO, "%0s: Number of Expects Pending = %0d", XactorName, ExpectCount); |
| 240 | } |
| 241 | |
| 242 | // This function is similar to the Expect(next one). The only difference is in the case of a |
| 243 | // timeout, the expect thread will be silently removed from the expect manager data structures. |
| 244 | function bit XactorTransaction::ExpectExpire(integer Window |
| 245 | ) { |
| 246 | // Status[1] = 1'b0 Expect not removed |
| 247 | // Status[1] = 1'b1 Expect removed |
| 248 | // Status[0] = 1'b0 Expect removed by transactor |
| 249 | // Status[0] = 1'b1 Expect removed by user |
| 250 | bit [1:0] Status = 2'b0; |
| 251 | |
| 252 | // This is a copy of TransactionRemoved and is returned by this |
| 253 | // function |
| 254 | bit Success; |
| 255 | |
| 256 | Packet.PktDisplay(RTYP_DEBUG_1, "Launching Expect Expire"); |
| 257 | |
| 258 | Manager.ExpectPkt(Packet, |
| 259 | Window, |
| 260 | Status |
| 261 | ); |
| 262 | |
| 263 | if (Status == 2'b10) { // Expect Expire was removed by transactor |
| 264 | Success = 1'b1; |
| 265 | Packet.PktDisplay(RTYP_INFO, "ExpectExpire Satisfied"); |
| 266 | } |
| 267 | else if (Status == 2'b11) { // Expect Expire was removed by user |
| 268 | Success = 1'b0; |
| 269 | Packet.PktDisplay(RTYP_XACTOR_FMWORK_EXPECT_REMOVED_BY_USER, "Expect Expire removed by user"); |
| 270 | } |
| 271 | else { // Expect Expire timeout |
| 272 | Success = 1'b0; // No Success |
| 273 | Packet.PktDisplay(RTYP_INFO, "ExpectExpire Expired"); |
| 274 | } |
| 275 | |
| 276 | ExpectExpire = Success; |
| 277 | } |
| 278 | |
| 279 | // This function will launch an expect thread. The thread will be installed in the data |
| 280 | // structures of the expect manager and will stay there waiting for the DUT to drive the |
| 281 | // expected value. |
| 282 | // If Expect is satisfied by a matched transaction driven by the DUT within the Window period, |
| 283 | // then the function returns a 1 indicating success. If the Window period elapses without a |
| 284 | // match, then it returns a 0. |
| 285 | function bit XactorTransaction::Expect(integer Window |
| 286 | ) { |
| 287 | // Status[1] = 1'b0 Expect not removed |
| 288 | // Status[1] = 1'b1 Expect removed |
| 289 | // Status[0] = 1'b0 Expect removed by transactor |
| 290 | // Status[0] = 1'b1 Expect removed by user |
| 291 | bit [1:0] Status = 2'b0; |
| 292 | |
| 293 | // This is a copy of TransactionRemoved and is returned by this |
| 294 | // function |
| 295 | bit Success; |
| 296 | |
| 297 | Packet.PktDisplay(RTYP_DEBUG_1, "Launching Expect"); |
| 298 | |
| 299 | Manager.ExpectPkt(Packet, |
| 300 | Window, |
| 301 | Status |
| 302 | ); |
| 303 | |
| 304 | if (Status == 2'b10) { // Expect was removed by transactor |
| 305 | Success = 1'b1; |
| 306 | Packet.PktDisplay(RTYP_INFO, "Expect Satisfied"); |
| 307 | } |
| 308 | else if (Status == 2'b11) { // Expect was removed by user |
| 309 | Success = 1'b0; |
| 310 | Packet.PktDisplay(RTYP_INFO, "Expect removed by user"); |
| 311 | } |
| 312 | else { // Expect timeout |
| 313 | Success = 1'b0; |
| 314 | Packet.PktDisplay(RTYP_XACTOR_FMWORK_EXPECT_TIMEOUT_ERR, "Expect Timeout"); |
| 315 | } |
| 316 | |
| 317 | Expect = Success; |
| 318 | } |
| 319 | |
| 320 | // This task will launch a thread that will be waiting for the next transaction driven by the |
| 321 | // DUT. It will then return a packet object (through the parameter list) with the data fields |
| 322 | // of the sampled transaction. |
| 323 | task XactorTransaction::Sample(XactorBasePacket Pkt, |
| 324 | integer Window = 50000 |
| 325 | ) { |
| 326 | MyReport.report(RTYP_DEBUG_1, "%0s: Waiting to Sample next transaction", XactorName); |
| 327 | Manager.SamplePkt(Pkt, Window); |
| 328 | } |
| 329 | |
| 330 | // This function removes a pending expect for a transaction that matches the values in Packet. If |
| 331 | // a pending expect is found the function returns 1, and 0 otherwise. |
| 332 | function bit XactorTransaction::Remove() { |
| 333 | Remove = Manager.Remove(Packet); |
| 334 | if(Remove) { |
| 335 | Packet.PktDisplay(RTYP_INFO, "Transaction removed successfully"); |
| 336 | } |
| 337 | else { |
| 338 | Packet.PktDisplay(RTYP_INFO, "Failed to remove Transaction"); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | // This task initiates a transaction to be driven to the DUT. |
| 343 | // D : Number of cycles (delay) before the transaction is sent to the drive manager to be |
| 344 | // scheduled. It could be seen as a priority given to the drive transaction, the larger the |
| 345 | // delay number, the longer the time the transaction will have to wait before it is scheduled |
| 346 | // for driving. |
| 347 | task XactorTransaction::Drive(integer D = 0 |
| 348 | ) { |
| 349 | Manager.DrivePkt(Packet.FormDriven(), D); |
| 350 | } |
| 351 | |
| 352 | // This task enables the transactor. Any scheduled drives or pending expects are resumed. |
| 353 | task XactorTransaction::Enable() { |
| 354 | Manager.EnableManager(); |
| 355 | MyReport.report(RTYP_INFO, "%0s: Enabled", XactorName); |
| 356 | } |
| 357 | |
| 358 | // This task disables the transactor, preventing reporting of unexpected transactions or |
| 359 | // incorrect design behavior. Scheduled drives and pending expects are suspended, but not lost. |
| 360 | task XactorTransaction::Disable() { |
| 361 | Manager.DisableManager(); |
| 362 | MyReport.report(RTYP_INFO, "%0s: Disabled", XactorName); |
| 363 | } |
| 364 | |
| 365 | // This task resets the state of the transactor. All scheduled drives and pending expects are lost. |
| 366 | task XactorTransaction::Reset() { |
| 367 | MyReport.report(RTYP_INFO, "%0s: Reset", XactorName); |
| 368 | Manager.ResetManager(); |
| 369 | Packet.PktReset(); |
| 370 | } |
| 371 | |
| 372 | |