BFM class svidBFM extends vmm_xactor; virtual svidIntf.md_svid svid_intf; // svid bus virtual svidIntf.md_mon mon_intf; // check some flag svidTrans trans; svidTrans_channel bfm_chan; bit vclk_stop; // 采样值,也可以放在transaction中,而不是作为静态变量放在BFM中 static bit dvida_is_high=0; static bit dvidb_is_high=0; static bit alert_is_active=0; static bit[7:0] dac_vida_smp=0; static bit[7:0] dac_vidb_smp=0; extern function new( virtual svidIntf svidintf, svidTrans_channel bfm_chan = null); extern virtual protected task main(); extern virtual task send_trans(input svidTrans trans); endclass //*************************************************** // functions and tasks //*************************************************** function svidBFM::new( virtual svidIntf svidintf, svidTrans_channel bfm_chan = null); super.new("svidBFM","class"); // naming the svidBFM this.svid_intf=svidintf; // one interface multi-modport : bfm this.mon_intf=svidintf; // one interface multi-modport : monitor if(bfm_chan==null) bfm_chan = new("svidBFM bfm_chan", "class"); this.bfm_chan=bfm_chan; this.vclk_stop=1'b1; endfunction task svidBFM::main(); super.main(); fork // SVID transaction while(1) begin wait_if_stopped_or_empty(bfm_chan); bfm_chan.peek(trans); send_trans(trans); bfm_chan.get(trans); end // gated vclk while(1) begin @(svid_intf.virtual_vclk or vclk_stop) begin svid_intf.vclk<=svid_intf.virtual_vclk|vclk_stop; end end // alert sampling while(1) begin @(svid_intf.cb_svid); alert_is_active=~svid_intf.valert; end join endtask