`ifndef MONITOR_SV
`define MONITOR_SV
class monitor;
virtual ahb_slv_if slv_if;
mailbox mon2scb_mbx = new();
transaction tr;
int tr_num;
logic[31:0] haddr_ld;
logic hwrite_ld;
logic[1:0] htrans_ld;
logic[1:0] hsize_ld;
logic hsel_ld;
extern function new(virtual ahb_slv_if slv_if, mailbox mon2scb_mbx, int tr_num);
extern function build();
extern task run();
endclass
function monitor::new(virtual ahb_slv_if slv_if, mailbox mon2scb_mbx, int tr_num);
this.slv_if = slv_if;
this.mon2scb_mbx = mon2scb_mbx;
this.tr_num = tr_num;
endfunction
function monitor::build();
endfunction
task monitor::run();
@(posedge slv_if.hresetn);
@slv_if.mon_cb;
@slv_if.mon_cb;
repeat(tr_num)begin
tr = new();
haddr_ld <= slv_if.mon_cb.haddr;
htrans_ld <= slv_if.mon_cb.htrans;
hsize_ld <= slv_if.mon_cb.hsize;
hwrite_ld <= slv_if.mon_cb.hwrite;
hsel_ld <= slv_if.mon_cb.hsel;
@slv_if.mon_cb;
tr.haddr = haddr_ld;
tr.htrans = htrans_ld;
tr.hsize = hsize_ld;
tr.hwrite = hwrite_ld;
tr.hsel = hsel_ld;
tr.hwdata = slv_if.mon_cb.hwdata;
tr.hrdata = slv_if.mon_cb.hrdata;
mon2scb_mbx.put(tr);
end
repeat(10)begin
@slv_if.mon_cb;
end
endtask
`endif
monitor.sv
最新推荐文章于 2024-09-12 08:07:34 发布