Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / fnx / vlib / XactorComponents / src / XactorTransaction.vr
// ========== 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
// have any questions.
//
// ========== 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"
#include "cReport.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);
// Resets Packet member
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
// transaction.
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
// 0 otherwise.
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
// expected value.
// 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
// Window of cycles.
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
// away.
virtual task Drive(integer D = 0);
// This task enables the transactor. Any scheduled drives or pending expects are resumed.
virtual task Enable();
// This task disables the transactor, preventing reporting of unexpected transactions or
// incorrect design behavior. Scheduled drives and pending expects are suspended, but not lost.
virtual task Disable();
// This task resets the state of the transactor. All scheduled drives and pending expects are lost.
virtual task Reset();
}
////////////////
// Definitions
////////////////
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) {
Packet.SetID(XactionID);
}
// Returns a CTTransactionID
function CTTransactionID XactorTransaction::GetID() {
GetID = Packet.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);
}
// Resets Packet member
task XactorTransaction::ResetPacket() {
Packet.PktReset();
}
// 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
// transaction.
task XactorTransaction::Display(string msg = "") {
if (msg == "")
Packet.PktDisplay(RTYP_INFO, "Current transaction");
else
Packet.PktDisplay(RTYP_INFO, msg);
}
// This function returns the name of the transactor.
function string XactorTransaction::Name() {
Name = XactorName;
}
// 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);
Manager.DumpExpects();
}
// Returns 1 if an expect (with the same value of the Packet member) is pending and
// 0 otherwise.
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
bit [1:0] Status = 2'b0;
// This is a copy of TransactionRemoved and is returned by this
// function
bit Success;
Packet.PktDisplay(RTYP_DEBUG_1, "Launching Expect Expire");
Manager.ExpectPkt(Packet,
Window,
Status
);
if (Status == 2'b10) { // Expect Expire was removed by transactor
Success = 1'b1;
Packet.PktDisplay(RTYP_INFO, "ExpectExpire Satisfied");
}
else if (Status == 2'b11) { // Expect Expire was removed by user
Success = 1'b0;
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");
}
ExpectExpire = Success;
}
// 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
// expected value.
// 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
bit [1:0] Status = 2'b0;
// This is a copy of TransactionRemoved and is returned by this
// function
bit Success;
Packet.PktDisplay(RTYP_DEBUG_1, "Launching Expect");
Manager.ExpectPkt(Packet,
Window,
Status
);
if (Status == 2'b10) { // Expect was removed by transactor
Success = 1'b1;
Packet.PktDisplay(RTYP_INFO, "Expect Satisfied");
}
else if (Status == 2'b11) { // Expect was removed by user
Success = 1'b0;
Packet.PktDisplay(RTYP_INFO, "Expect removed by user");
}
else { // Expect timeout
Success = 1'b0;
Packet.PktDisplay(RTYP_XACTOR_FMWORK_EXPECT_TIMEOUT_ERR, "Expect Timeout");
}
Expect = Success;
}
// 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,
integer Window = 50000
) {
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);
if(Remove) {
Packet.PktDisplay(RTYP_INFO, "Transaction removed successfully");
}
else {
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
// for driving.
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() {
Manager.EnableManager();
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);
Manager.ResetManager();
Packet.PktReset();
}