Files
axipg/src/axi/axi_transaction.sv

80 lines
2.7 KiB
Systemverilog

// ----------------------------------------------------------------------
class axi_transaction extends uvm_sequence_item;
// Declare AXI transaction fields
rand axi_transaction_type_t txn_type; // Transaction type (read/write)
rand bit [`ADDR_WIDTH-1:0] addr; // Address
rand bit [`DATA_WIDTH-1:0] data; // Data
rand bit [`DATA_WIDTH_DIV_8-1:0] strb; // Byte enable
rand bit [2:0] size; // Size
rand bit [7:0] length; // Length
`uvm_object_utils_begin(axi_transaction)
`uvm_field_enum(axi_transaction_type_t, txn_type, UVM_DEFAULT)
`uvm_field_int(addr, UVM_DEFAULT)
`uvm_field_int(data, UVM_DEFAULT)
`uvm_field_int(strb, UVM_DEFAULT)
`uvm_field_int(size, UVM_DEFAULT)
`uvm_field_int(length, UVM_DEFAULT)
`uvm_object_utils_end
// Constructor
function new(string name = "axi_transaction");
super.new(name);
endfunction
// Get transaction id - made up of sequence ID and trasacton ID
function axi_transaction_id_t get_tid();
axi_transaction_id_t tid;
tid.seq_id = this.get_sequence_id();
tid.txn_id = this.get_transaction_id();
return tid;
endfunction
// Show transaction id - sequence ID:trasacton ID
function string show_tid();
return $sformatf("%0h:%0h", this.get_sequence_id(), this.get_transaction_id());
endfunction
// Show transaction tag - Transaction type:sequence ID:trasacton ID
function string show_tag();
return $sformatf("%s:%0h:%0h", this.txn_type.name(), this.get_sequence_id(), this.get_transaction_id());
endfunction
// Wait for transaction to be done
task wait_for_done();
uvm_event finished_event;
finished_event = get_event_pool().get("finished");
finished_event.wait_on();
endtask
// Copy method for cloning
virtual function uvm_object clone();
axi_transaction copy;
copy = axi_transaction::type_id::create(get_name());
copy.txn_type = this.txn_type;
copy.addr = this.addr;
copy.data = this.data;
copy.strb = this.strb;
copy.size = this.size;
copy.length = this.length;
return copy;
endfunction
// Comparison method for checking equality
virtual function bit compare(uvm_object rhs);
axi_transaction other;
if (!$cast(other, rhs)) return 0; // Ensure type match
return (this.txn_type == other.txn_type) &&
(this.addr == other.addr) &&
(this.data == other.data) &&
(this.strb == other.strb) &&
(this.size == other.size) &&
(this.length == other.length);
endfunction
endclass : axi_transaction