|
- `include "uvm_macros.svh"
- import uvm_pkg::*;
- class axi_mon1 extends uvm_monitor;
- `uvm_component_utils axi_mon1;
- virtual axi_slave_if mon_avif;
- uvm_analysis_port #(axi_txn) a_mon_ap;
- axi_txn w_trans;
- axi_txn r_trans;
- function new(string name axi_mon1",uvm_component parent =null);
- super.new(name, parent);
- // w_done =1;
- //r_done =1;
- endfunction
-
- function void build_phase(uvm_phase phase);
- super.build_phase(phase);
- `uvm_info("monitor","build_phase",UVM_MEDIUM)
- a_mon_ap=new("a_mon_ap",this);
- w_trans= axi_txn :: type_id :: create("axi_mon_txn");
- r_trans= axi_txn :: typeid :: create(" r_trans");
- endfunction:build_phase
-
- task run_phase(uvm_phase phase);
- forever begin
- // run_mon(phase);
- //@(mon_avif.clk);
- fork
- begin
- write_monitor();
- read_monitor();
- end
- join_none
- end
- endtask: run_phase
-
- /* task run_mon(uvm_phase phase);
- fork
- if(w_done) begin
- phase.raise_objection(this);
- w_done=0;
- write_monitor();
- w_done=1;
- phase.drop_objection(this);
- end
- if(r_done) begin
- phase.raise_objection(this);
- r_done=0;
- read_monitor();
- r_done=1;
- phase.drop_objection(this);
- end
-
- join_none
- endtask: run_mon */
- task write_monitor();
- if( mon_avif.awvalid && mon_avif.awready) begin
- w_trans = axi_txn ::type_id::create("w_trans");
- w_trans.awaddr = mon_avif.awaddr;
- w_trans.awid = mon_avif.awid;
- w_trans.awsize = mon_avif.awsize;
- w_trans.awlen = mon_avif.awlen;
- w_trans.awburst = mon_avif.awburst;
- w_trans.wdata = new [w_trans.awlen+1];
- for (int i=0; i<w_trans.awlen+1; i++) begin
- @( mon_avif.clk);
- wait( mon_avif.wvalid && mon_avif.wready);
- w_trans.wdata[i] = new [D_WIDTH/8];
- for (int j=0; j<D_WIDTH/8; j++) begin
- w_trans.wdata[i][j] = mon_avif.wdata[8*j+:8];
- end
- end
- ap.write(w_trans);
- `uvm_info("MMON", $sformatf("WTRANS %s", w_trans.convert2string()), UVM_HIGH)
- end
- endtask: write_monitor
-
- task read_monitor();
- if( mon_avif.arvalid && mon_avif.arready) begin
- r_trans = axi_txn#(D_WIDTH, A_WIDTH)::type_id::create("r_trans");
- r_trans.araddr = mon_avif.araddr;
- r_trans.arid = mon_avif.arid;
- r_trans.arsize = mon_avif.arsize;
- r_trans.awlen = mon_avif.awlen;
- r_trans.arburst = mon_avif.arburst;
- ap.write(r_trans);
- `uvm_info("MMON", $sformatf("RTRANS %s", r_trans.convert2string()), UVM_HIGH)
- end
- endtask: read_monitor
- endclass
- module top_v axi_mon1 dut;
- initial
- begin
- repeat(5)
- dut=new();
- assert(dut.randomize);
- $display("done");
- end
- endmodule
|