Code Browser Pages:
| /////////////////////////////////////// /////////////////////////////////////// //// //// //// VMM 1.2 example //// //// //// //// For more vmm examples //// //// visit www.testbench.in //// //// //// /////////////////////////////////////// /////////////////////////////////////// //----------------------------------------------------------------------------- // Dummy rtl monitor-xactor Class //----------------------------------------------------------------------------- // monitor callback class typedef class my_monitor_callbacks; // Scoreboard typedef class my_sb; class my_monitor extends vmm_xactor; // dummy rtl transacion channel packet_channel mon_chan; // dummy rtl interface virtual dut_if.monitor mon_if; //----------------------------------------------------------------------------- // new() - Constructor //----------------------------------------------------------------------------- function new(string inst, int unsigned stream_id = -1, virtual dut_if.monitor mon_if, packet_channel in_chan = null ); super.new("MY_MONITOR", inst, stream_id); this.mon_if = mon_if; this.mon_chan = in_chan; endfunction : new //----------------------------------------------------------------------------- // reset_xactor () //----------------------------------------------------------------------------- virtual function void reset_xactor(reset_e rst_typ = SOFT_RST); super.reset_xactor(rst_typ); endfunction : reset_xactor //----------------------------------------------------------------------------- // main () //----------------------------------------------------------------------------- protected virtual task main(); fork super.main(); get_data(); join_none endtask : main //----------------------------------------------------------------------------- // get_data () //----------------------------------------------------------------------------- virtual task get_data(); packet p1 = new(); @(posedge this.mon_if.clk); while(1) begin p1.reset(); `vmm_callback(my_monitor_callbacks, pre_packet_rx(this, p1)); monitor_data(p1); `vmm_callback(my_monitor_callbacks, post_packet_rx(this, p1)); mon_chan.sneak(p1); end endtask : get_data //----------------------------------------------------------------------------- // monitor_data () //----------------------------------------------------------------------------- virtual task monitor_data(ref packet p1); `vmm_note(log,"monitor_data() - Inside "); @(posedge this.mon_if.clk); p1.address = this.mon_if.address; p1.data = (this.mon_if.rdwr) ? this.mon_if.o_data : this.mon_if.i_data ; p1.rdwr = (this.mon_if.rdwr) ? packet::WRITE : packet::READ ; p1.en = (this.mon_if.en) ? packet::EN : packet::nEN ; $display ("[%0t] :: MONITOR :: ENABLE = TYPE = - ADDRESS = %0h - DATA = %0h",$realtime, p1.en.name, p1.rdwr.name, p1.address, p1.data); `vmm_note(log,"monitor_data() - Exiting "); endtask : monitor_data endclass : my_monitor //----------------------------------------------------------------------------- // Dummy rtl monitor-xactor callback Class //----------------------------------------------------------------------------- class my_monitor_callbacks extends vmm_xactor_callbacks; my_sb scbd; int pkt_cnt = 0; vmm_data matched; vmm_data lost[]; static vmm_log log = new("MONITOR_CALLBACKS", "Class"); function new(my_sb scbd); this.scbd = scbd; endfunction : new // Callbacks before a transaction is started virtual task pre_packet_rx(my_monitor mon, packet p); // Empty endtask : pre_packet_rx // Callback after a transaction is completed virtual task post_packet_rx(my_monitor mon, packet p); int stream = 1; void'(this.scbd.expect_with_losses(p, matched, lost, stream)); `vmm_note(log, $psprintf(" Packet Recieved by monitor = 0", pkt_cnt++)); endtask : post_packet_rx endclass : my_monitor_callbacks //----------------------------------------------------------------------------- // End of file //----------------------------------------------------------------------------- |