Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / fc / vera / stubs / l2_packet.vr
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: l2_packet.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 <VeraListProgram.vrh>
#include <ListMacros.vrh>
#include "l2_stub_defines.vri"
#include "std_display_class.vrh"
class l2_packet {
// Transactor Name
string XactorName;
StandardDisplay dbg;
// Data fields: Add any data field related to a transaction
protected bit [ADDR_WIDTH-1:0] address; // Address field
protected bit [DATA_WIDTH-1:0] data; // Data field
protected bit [DATA_WIDTH-1:0] read_data; // Data to be sent back for read dma
protected bit [7:0] bytemask; // Which bytes to ignore
protected bit [15:0] tag; // Identifying tag needed for response
protected bit [3:0] opes; // ordered, posted, error, source (1=DMU, 0=NIU)
protected bit ordered; // SIU needs to know if it is ordered
protected bit posted; // SIU needs to know if it is posted
protected bit error; // Received a parity or UE error
protected bit source; // 1=DMU, 0=NIU
protected bit [2:0] bank_number; // Which L2 bank the packet goes to
protected bit [MAX_TRANSACTIONS:0] id; // Packet ID from the testbench (if needed)
protected bit last_packet; // This signifies the end of a group of packets
task new(string _XactorName, StandardDisplay _dbg);
// FieldType is a string that indicates which field to set. FieldValue is the actual value
// that the packet field will be set to
task set(string FieldType,
bit [MAX_FIELD_WIDTH-1:0] FieldValue);
// FieldType is a string that indicates which field to get. FieldValue is the returned value
// of the field indicated by FieldType
function bit [MAX_FIELD_WIDTH-1:0] get(string FieldType);
// This function will return a "compressed" expected value using the data fields of the
// packet. This task is not part of the Xactor Framework but has to be implemented if the
// transactor is going to expect transactions.
function bit [MAX_TOTAL_FIELD_WIDTH-1:0] FormExpected();
// Forms and return a packet object with the necessary information before
// it is sent to the drive manager.
task FormDriven();
// Compares two packets and return 1 if the compare operation is successful and 0 otherwise.
function bit compare(l2_packet packet);
// This task will display the contents of the packet. TypeRep is the report type used
// when printing the packet through the Report utility.
task display(string Message, bit error = 0);
// This task will reset the fields of the packet
task reset();
function l2_packet copy();
} // end of packet sub-class
MakeVeraList(l2_packet);
////////////////////////
// Definitions
/////////////////
// This method might not need customization
task l2_packet::new(string _XactorName, StandardDisplay _dbg) {
XactorName = _XactorName; // Name of transactor
dbg = _dbg;
this.reset(); // Reset this packet
}
// FieldType is a string that indicates which field to set. FieldValue is the actual value
// that the packet field will be set to
// This method needs customization.
task l2_packet::set(string FieldType, bit [MAX_FIELD_WIDTH-1:0] FieldValue) {
case (FieldType) {
// CUSTOMIZE
// Add a case element for every field of the packet.
"address" : address = FieldValue[ADDR_WIDTH-1:0];
"data" : data = FieldValue[DATA_WIDTH-1:0];
"read_data" : read_data = FieldValue[DATA_WIDTH-1:0];
"bytemask" : bytemask = FieldValue[7:0];
"tag" : tag = FieldValue[15:0];
"opes" : opes = FieldValue[3:0];
"ordered" : ordered = FieldValue[0];
"posted" : posted = FieldValue[0];
"error" : error = FieldValue[0];
"source" : source = FieldValue[0];
"bank_number" : bank_number = FieldValue[2:0];
"id" : id = FieldValue;
"last_packet" : last_packet = FieldValue[0];
default: dbg.dispmon(XactorName, MON_ERR, psprintf("The field %0s is not defined", FieldType));
}
}
// FieldType is a string that indicates which field to get. FieldValue is the returned value
// of the field indicated by FieldType
// This method needs customization.
function bit [MAX_FIELD_WIDTH-1:0] l2_packet::get(string FieldType) {
case (FieldType) {
// CUSTOMIZE
// Add a case element for every field of the packet
"address" : get = address;
"data" : get = data;
"read_data" : get = read_data;
"bytemask" : get = bytemask;
"tag" : get = tag;
"opes" : get = opes;
"ordered" : get = ordered;
"posted" : get = posted;
"error" : get = error;
"source" : get = source;
"bank_number" : get = bank_number;
"id" : get = id;
"last_packet" : get = last_packet;
default : dbg.dispmon(XactorName, MON_ERR, psprintf("The field %0s is not defined", FieldType));
}
}
// This function will return a "compressed" expected value using the data fields of the
// packet. This task is not part of the Xactor Framework but has to be implemented if the
// transactor is going to expect transactions.
// This method needs customization.
function bit [MAX_TOTAL_FIELD_WIDTH-1:0] l2_packet::FormExpected() {
FormExpected = {address, data, ordered, posted, error, source, bank_number};
}
// Forms and return a packet object with the necessary information before
// it is sent to the drive manager.
// This method needs customization.
task l2_packet::FormDriven() {
}
function bit l2_packet::compare(l2_packet packet) {
integer i;
bit [DATA_WIDTH-1:0] temp_data;
bit data_good = 1;
temp_data = packet.get("data");
if (|temp_data[511:256] == 0) {
for (i = 0; i < 8; i++) {
if (bytemask[i]) {
if (temp_data[8*i+7:8*i] !== data[8*i+7:8*i]) {
data_good = 0;
}
}
}
} else {
if (temp_data !== data) {
data_good = 0;
}
}
if ((packet.get("address") === address) && data_good &&
(packet.get("bytemask") === bytemask) && (packet.get("opes") === opes) &&
(packet.get("bank_number") === bank_number)) {
compare = 1;
} else {
compare = 0;
}
}
// This task will display the contents of the packet. TypeRep is the report type used
// when printing the packet through the Report utility.
// This method needs customization.
task l2_packet::display(string message, bit error = 0) {
if (error) {
dbg.dispmon(XactorName, MON_ERR, psprintf("%0s\tAddress: %0h Data: %0h bytemask: %0h Tag: %0h Opes: %0b Bank: %0d\n", message, address, data, bytemask, tag, opes, bank_number));
} else {
dbg.dispmon(XactorName, MON_ALWAYS, psprintf("%0s\tAddress: %0h Data: %0h bytemask: %0h Tag: %0h Opes: %0b Bank: %0d\n", message, address, data, bytemask, tag, opes, bank_number));
}
}
// This task will reset the fields of the packet
// This method needs customization.
task l2_packet::reset() {
address = 0;
data = 0;
read_data = 0;
bytemask = 0;
tag = 0;
opes = 0;
ordered = 0;
posted = 0;
error = 0;
source = 0;
bank_number = 0;
id = 0;
last_packet = 1;
}
function l2_packet l2_packet::copy() {
l2_packet new_pkt = new("Expect", dbg);
new_pkt.set("address", address);
new_pkt.set("data", data);
new_pkt.set("read_data", read_data);
new_pkt.set("bytemask", bytemask);
new_pkt.set("tag", tag);
new_pkt.set("opes", opes);
new_pkt.set("bank_number", bank_number);
new_pkt.set("id", id);
new_pkt.set("last_packet", last_packet);
copy = new_pkt;
}