* Bare skeleton implementation of everything * Testbench builds with Verilator * Test runs
118 lines
4.0 KiB
Systemverilog
118 lines
4.0 KiB
Systemverilog
// ----------------------------------------------------------------------
|
|
// Monitor for AXI transactions
|
|
// ----------------------------------------------------------------------
|
|
class axi_monitor extends uvm_monitor; // #(axi_transaction);
|
|
virtual `AXI_INTF.MANAGER m_if;
|
|
virtual `AXI_INTF.SUBORDINATE s_if;
|
|
agent_type_t agent_type;
|
|
|
|
// Declare the analysis export
|
|
uvm_analysis_port ap;
|
|
|
|
// Filehandle for transaction tracker file
|
|
int trk_file;
|
|
|
|
`uvm_component_utils(axi_monitor)
|
|
|
|
// --------------------------------------------------
|
|
// Constructor
|
|
function new(string name = "axi_monitor", uvm_component parent = null);
|
|
super.new(name, parent);
|
|
ap = new("analysis_export", this);
|
|
endfunction
|
|
|
|
// --------------------------------------------------
|
|
// Set agent type
|
|
function void set_agent_type(agent_type_t atype);
|
|
agent_type = atype;
|
|
`uvm_info("set_agent_type", $sformatf("Agent type set to %s", agent_type.name()), UVM_LOW)
|
|
endfunction
|
|
|
|
// --------------------------------------------------
|
|
// Set virtual interfaces
|
|
function void set_virtual_intefaces(virtual `AXI_INTF.MANAGER m_if_p,
|
|
virtual `AXI_INTF.SUBORDINATE s_if_p);
|
|
`uvm_info("set_virtual_intefaces", $sformatf("Setting virtual interfaces"), UVM_LOW)
|
|
|
|
m_if = m_if_p;
|
|
s_if = s_if_p;
|
|
endfunction
|
|
|
|
// --------------------------------------------------
|
|
// Run phase
|
|
virtual function void run_phase(uvm_phase phase);
|
|
// Open transaction log file
|
|
trk_file = $fopen($sformatf("axi_transactions.%s.log", agent_type.name()), "w");
|
|
if (trk_file == 0) begin
|
|
`uvm_error("AXI_MONITOR", "Failed to open transaction log file")
|
|
end else begin
|
|
`uvm_info("AXI_MONITOR", "Transaction log file opened successfully", UVM_LOW)
|
|
end
|
|
|
|
// Start monitoring
|
|
do_monitor();
|
|
endfunction
|
|
|
|
// --------------------------------------------------
|
|
// Monitor logic to capture transactions
|
|
virtual task do_monitor();
|
|
if (agent_type == MANAGER) begin
|
|
do_manager_monitor();
|
|
end else if (agent_type == SUBORDINATE) begin
|
|
do_subordinate_monitor();
|
|
end else begin
|
|
`uvm_fatal("AXI_MONITOR", "Unknown agent type")
|
|
end
|
|
endtask
|
|
|
|
// --------------------------------------------------
|
|
// Monitor logic for MANAGER agent
|
|
virtual task do_manager_monitor();
|
|
// Placeholder for actual monitoring logic
|
|
// This would typically involve sampling signals and creating transactions
|
|
forever begin
|
|
axi_transaction txn;
|
|
@(posedge m_if.ACLK);
|
|
|
|
txn = axi_transaction::type_id::create("txn");
|
|
|
|
// Capture transaction details here
|
|
|
|
ap.write(txn);
|
|
write_transaction_to_file(txn);
|
|
end
|
|
endtask
|
|
|
|
// --------------------------------------------------
|
|
// Monitor logic for SUBORDINATE agent
|
|
virtual task do_subordinate_monitor();
|
|
// Placeholder for actual monitoring logic
|
|
// This would typically involve sampling signals and creating transactions
|
|
forever begin
|
|
axi_transaction txn;
|
|
@(posedge s_if.ACLK);
|
|
|
|
txn = axi_transaction::type_id::create("txn");
|
|
|
|
// Capture transaction details here
|
|
|
|
ap.write(txn);
|
|
write_transaction_to_file(txn);
|
|
end
|
|
endtask
|
|
|
|
// --------------------------------------------------
|
|
// Report phase
|
|
virtual function void report_phase(uvm_phase phase);
|
|
// Report any captured transactions or statistics
|
|
`uvm_info("axi_monitor", $sformatf("Reporting on %s",
|
|
get_full_name()), UVM_LOW)
|
|
endfunction
|
|
|
|
// --------------------------------------------------
|
|
// Function to write captured transaction into a file
|
|
function void write_transaction_to_file(axi_transaction txn);
|
|
$fwrite(trk_file, "%s\n", txn.sprint());
|
|
endfunction
|
|
endclass : axi_monitor
|