// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: XactorTransaction.vr
// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// For the avoidance of doubt, and except that if any non-GPL license
// choice is available it will apply instead, Sun elects to use only
// the General Public License version 2 (GPLv2) at this time for any
// software where a choice of GPL license versions is made
// available with the language indicating that GPLv2 or any later version
// may be used, or where a choice of which version of the GPL is applied is
// otherwise unspecified.
// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
// CA 95054 USA or visit www.sun.com if you need additional information or
// ========== Copyright Header End ============================================
#include <vera_defines.vrh>
#include "XactorUtilities.vrh"
#include "XactorBaseBuilder.vrh"
#include "XactorBasePacket.vrh"
#include "XactorBaseSignalInterface.vrh"
#include "XactorBaseManager.vrh"
#include "XactorBaseTransaction.vrh"
#include "XactorManager.vrh"
#include "XactorDefines.vri"
#include "CTTransactionID.vrh"
class XactorTransaction extends XactorBaseTransaction {
// MyReport declared in XactorBaseTransaction
// Transactor Name declared in XactorBaseTransaction
// Data Packet declared in XactorBaseTransaction
// Transaction Manager declared in XactorBaseTransaction
// Interface Manager declared in XactorBaseTransaction
task new(XactorBaseBuilder Builder);
// Pass a CTTransactionID object to the transaction
virtual task SetID(CTTransactionID XactionID);
// Returns a CTTransactionID
virtual function CTTransactionID GetID();
// FieldType is a string that indicates which field (within the Packet member) to set.
// FieldValue is the actual value that the packet field will be set to.
virtual task SetPacket(string FieldType,
bit [XACT_FIELD_WIDTH-1:0] FieldValue
// FieldType is a string that indicates which field (within the Packet member) to get.
// FieldValue is the returned value of the field indicated by FieldType.
virtual function bit [XACT_FIELD_WIDTH-1:0] GetPacket(string FieldType);
virtual task ResetPacket();
// FieldType is a string that indicates which field (within the Signal Interface member)
// to set. FieldValue is the actual value that the packet field will be set to.
virtual task SetSignalInterface(string FieldType,
bit [XACT_FIELD_WIDTH-1:0] FieldValue
// FieldType is a string that indicates which field (within the Signal Interface member)
// to get. FieldValue is the returned value of the field indicated by FieldType.
virtual function bit [XACT_FIELD_WIDTH-1:0] GetSignalInterface(string FieldType);
// This task will use the report utility to print all the information about the
virtual task Display(string msg = "");
// This function returns the name of the transactor.
virtual function string Name();
// This task prints a complete list of all the pending expects of the transactor.
virtual task DumpExpectList();
// Returns 1 if an expect (with the same value of the Packet member) is pending and
virtual function bit IsExpectPending();
// Returns the number of pending expects of the transactor.
virtual function integer ExpectCount();
// This function is similar to the Expect(next one). The only difference is in the case of a
// timeout, the expect thread will be silently removed from the expect manager data structures.
virtual function bit ExpectExpire(integer Window);
// This function will launch an expect thread. The thread will be installed in the data
// structures of the expect manager and will stay there waiting for the DUT to drive the
// If Expect is satisfied by a matched transaction driven by the DUT within the Window period,
// then the function returns a 1 indicating success. If the Window period elapses without a
// match, then it returns a 0.
virtual function bit Expect(integer Window);
// This task will launch a thread that will be waiting for the next transaction driven by the
// DUT. It will then return a packet object (through the parameter list) with the data fields
// of the sampled transaction.
// The transactor timesout on a Sample() if no transaction is driven by the DUT within the
virtual task Sample(XactorBasePacket Pkt, integer Window = 50000);
// This function removes a pending expect for a transaction that matches the values in Packet. If
// a pending expect is found the function returns 1, and 0 otherwise.
virtual function bit Remove();
// This task initiates a transaction to be driven to the DUT.
// D : Number of cycles (delay) before the transaction is sent to the drive manager to be
// scheduled. It could be seen as a priority given to the drive transaction, the larger the
// delay number, the longer the time the transaction will have to wait before it is scheduled
// for driving. The default value is 0 which means that the transaction is scheduled right
virtual task Drive(integer D = 0);
// This task enables the transactor. Any scheduled drives or pending expects are resumed.
// This task disables the transactor, preventing reporting of unexpected transactions or
// incorrect design behavior. Scheduled drives and pending expects are suspended, but not lost.
// This task resets the state of the transactor. All scheduled drives and pending expects are lost.
task XactorTransaction::new(XactorBaseBuilder Builder
XactorName = Builder.CreateName();
Packet = Builder.CreatePacket();
MyReport = Builder.CreateReport();
Manager = Builder.CreateManager();
SignalInterface = Builder.CreateSignalInterface();
// Pass a CTTransactionID object to the transaction
task XactorTransaction::SetID(CTTransactionID XactionID) {
// Returns a CTTransactionID
function CTTransactionID XactorTransaction::GetID() {
// FieldType is a string that indicates which field (within the Packet member) to set.
// FieldValue is the actual value that the packet field will be set to.
task XactorTransaction::SetPacket(string FieldType,
bit [XACT_FIELD_WIDTH-1:0] FieldValue
Packet.Set(FieldType, FieldValue);
// FieldType is a string that indicates which field (within the Packet member) to get.
// FieldValue is the returned value of the field indicated by FieldType.
function bit [XACT_FIELD_WIDTH-1:0] XactorTransaction::GetPacket(string FieldType) {
GetPacket = Packet.Get(FieldType);
task XactorTransaction::ResetPacket() {
// FieldType is a string that indicates which field (within the Signal Interface member)
// to set. FieldValue is the actual value that the packet field will be set to.
task XactorTransaction::SetSignalInterface(string FieldType,
bit [XACT_FIELD_WIDTH-1:0] FieldValue
SignalInterface.Set(FieldType, FieldValue);
// FieldType is a string that indicates which field (within the Signal Interface member)
// to get. FieldValue is the returned value of the field indicated by FieldType.
function bit [XACT_FIELD_WIDTH-1:0] XactorTransaction::GetSignalInterface(string FieldType
GetSignalInterface = SignalInterface.Get(FieldType);
// This task will use the report utility to print all the information about the
task XactorTransaction::Display(string msg = "") {
Packet.PktDisplay(RTYP_INFO, "Current transaction");
Packet.PktDisplay(RTYP_INFO, msg);
// This function returns the name of the transactor.
function string XactorTransaction::Name() {
// This task prints a complete list of all the pending expects of the transactor.
task XactorTransaction::DumpExpectList() {
MyReport.report(RTYP_INFO, "%0s: Dumping Expects", XactorName);
// Returns 1 if an expect (with the same value of the Packet member) is pending and
function bit XactorTransaction::IsExpectPending() {
IsExpectPending = Manager.ExpectPending(Packet);
// Returns the number of pending expects of the transactor.
function integer XactorTransaction::ExpectCount() {
ExpectCount = Manager.NumExpects();
MyReport.report(RTYP_INFO, "%0s: Number of Expects Pending = %0d", XactorName, ExpectCount);
// This function is similar to the Expect(next one). The only difference is in the case of a
// timeout, the expect thread will be silently removed from the expect manager data structures.
function bit XactorTransaction::ExpectExpire(integer Window
// Status[1] = 1'b0 Expect not removed
// Status[1] = 1'b1 Expect removed
// Status[0] = 1'b0 Expect removed by transactor
// Status[0] = 1'b1 Expect removed by user
// This is a copy of TransactionRemoved and is returned by this
Packet.PktDisplay(RTYP_DEBUG_1, "Launching Expect Expire");
Manager.ExpectPkt(Packet,
if (Status == 2'b10) { // Expect Expire was removed by transactor
Packet.PktDisplay(RTYP_INFO, "ExpectExpire Satisfied");
else if (Status == 2'b11) { // Expect Expire was removed by user
Packet.PktDisplay(RTYP_XACTOR_FMWORK_EXPECT_REMOVED_BY_USER, "Expect Expire removed by user");
else { // Expect Expire timeout
Success = 1'b0; // No Success
Packet.PktDisplay(RTYP_INFO, "ExpectExpire Expired");
// This function will launch an expect thread. The thread will be installed in the data
// structures of the expect manager and will stay there waiting for the DUT to drive the
// If Expect is satisfied by a matched transaction driven by the DUT within the Window period,
// then the function returns a 1 indicating success. If the Window period elapses without a
// match, then it returns a 0.
function bit XactorTransaction::Expect(integer Window
// Status[1] = 1'b0 Expect not removed
// Status[1] = 1'b1 Expect removed
// Status[0] = 1'b0 Expect removed by transactor
// Status[0] = 1'b1 Expect removed by user
// This is a copy of TransactionRemoved and is returned by this
Packet.PktDisplay(RTYP_DEBUG_1, "Launching Expect");
Manager.ExpectPkt(Packet,
if (Status == 2'b10) { // Expect was removed by transactor
Packet.PktDisplay(RTYP_INFO, "Expect Satisfied");
else if (Status == 2'b11) { // Expect was removed by user
Packet.PktDisplay(RTYP_INFO, "Expect removed by user");
Packet.PktDisplay(RTYP_XACTOR_FMWORK_EXPECT_TIMEOUT_ERR, "Expect Timeout");
// This task will launch a thread that will be waiting for the next transaction driven by the
// DUT. It will then return a packet object (through the parameter list) with the data fields
// of the sampled transaction.
task XactorTransaction::Sample(XactorBasePacket Pkt,
MyReport.report(RTYP_DEBUG_1, "%0s: Waiting to Sample next transaction", XactorName);
Manager.SamplePkt(Pkt, Window);
// This function removes a pending expect for a transaction that matches the values in Packet. If
// a pending expect is found the function returns 1, and 0 otherwise.
function bit XactorTransaction::Remove() {
Remove = Manager.Remove(Packet);
Packet.PktDisplay(RTYP_INFO, "Transaction removed successfully");
Packet.PktDisplay(RTYP_INFO, "Failed to remove Transaction");
// This task initiates a transaction to be driven to the DUT.
// D : Number of cycles (delay) before the transaction is sent to the drive manager to be
// scheduled. It could be seen as a priority given to the drive transaction, the larger the
// delay number, the longer the time the transaction will have to wait before it is scheduled
task XactorTransaction::Drive(integer D = 0
Manager.DrivePkt(Packet.FormDriven(), D);
// This task enables the transactor. Any scheduled drives or pending expects are resumed.
task XactorTransaction::Enable() {
MyReport.report(RTYP_INFO, "%0s: Enabled", XactorName);
// This task disables the transactor, preventing reporting of unexpected transactions or
// incorrect design behavior. Scheduled drives and pending expects are suspended, but not lost.
task XactorTransaction::Disable() {
Manager.DisableManager();
MyReport.report(RTYP_INFO, "%0s: Disabled", XactorName);
// This task resets the state of the transactor. All scheduled drives and pending expects are lost.
task XactorTransaction::Reset() {
MyReport.report(RTYP_INFO, "%0s: Reset", XactorName);