|  |  | 
  1 virtual function void display(string prefix = "");
  2 virtual function string psdisplay(string prefix = "");
  3 virtual function vmm_notify copy(vmm_notify to = null);
  4 virtual function int configure(int notification_id = -1,
  5       		  sync_e sync = ONE_SHOT);
  6 virtual function int is_configured(int notification_id);
  7 virtual function bit is_on(int notification_id);
  8 virtual task wait_for(int notification_id);
  9 virtual task wait_for_off(int notification_id);
 10 virtual function bit is_waited_for(int notification_id);
 11 virtual function void terminated(int notification_id);
 12 virtual function vmm_data status(int notification_id);
 13 virtual function time timestamp(int notification_id);
 14 virtual function void indicate(int notification_id,
 15           		  vmm_data status = null);
 16 virtual function void set_notification(int notification_id,
 17       		          vmm_notification ntfy = null);
 18 virtual function vmm_notification get_notification(int notification_id);
 19 virtual function void reset(int     notification_id = -1,
 20                                reset_e rst_typ         = SOFT);
You could download file vmm_notify_methods.sv here | 
|  |  | 
   1 `include "vmm.sv"
   2 
   3 // Note : This is not exact representation of AHB data class
   4 // All data class needs to extend from vmm_data
   5 class ahb_data extends vmm_data;
   6   vmm_log log;
   7   // Declare all the fields
   8   rand bit [31:0] addr;
   9   rand bit [31:0] data [16];
  10   rand bit [3:0]  beats;
  11 
  12   // Make sure all variables have init value 
  13   function new(vmm_log log);
  14     int i;
  15     super.new(log);
  16     this.log  = log;
  17     this.addr       = 0;
  18     for (i = 0; i < 16; i ++) begin
  19       this.data[1] = 0;
  20     end
  21     this.beats     = 1;
  22   endfunction
  23 
  24   // Print message
  25   function void display(string prefix = "");
  26     if (is_valid()) begin
  27      `vmm_debug(log,$psprintf("%s",psdisplay(prefix)));
  28     end else begin
  29      `vmm_error(log,$psprintf("%s",psdisplay(prefix)));
  30     end
  31   endfunction
  32 
  33   // Return the string members and their values
  34   virtual function string psdisplay(string prefix = "");
  35     string msg;
  36     int i;
  37     msg = $psprintf("   %s\n", prefix);
  38     msg = $psprintf("%s ADDRESS       : 32'h%x\n",msg,addr);
  39     msg = $psprintf("%s BEATS         : %0d\n",msg,beats);
  40 
  41     for (i = 0; i < beats; i++) begin
  42       msg = $psprintf("%s DATA[%2d]      : 32'h%x\n",msg,i,data[i]);
  43     end
  44     psdisplay = msg;
  45   endfunction
  46 endclass
  47 
  48 // We need to add below line to construct vmm_channel for object ahb_data
  49 `vmm_channel(ahb_data)
  50 
  51 // This class generates transactions
  52 // Don't worry about vmm_xactor, will will see them later
  53 class source extends vmm_xactor;
  54   vmm_log log;
  55   ahb_data_channel fifo;
  56   // Declare new notify event
  57   // As int
  58   int SOURCE_DONE; 
  59   // As event
  60   typedef enum {SOURCE_START} notifications_e;
  61 
  62   
  63   function new(vmm_log log,string name, ahb_data_channel fifo);
  64     super.new(name, name);
  65     this.log = log;
  66     this.fifo = fifo;
  67     // Configure SOURCE_DONE as ON_OFF type
  68     this.SOURCE_DONE = this.notify.configure(-1,vmm_notify::ON_OFF);
  69     this.notify.configure(SOURCE_START);
  70   endfunction
  71 
  72   virtual task main();
  73     int i;
  74     ahb_data mdata;
  75     super.main();
  76      #10 ;
  77     // Generate 2 transactions
  78     this.notify.indicate(SOURCE_START);
  79     for (i = 0; i < 2; i++) begin
  80       mdata = new (log);
  81       fifo.sneak(mdata);
  82       // Wait for object to be process before generating next object
  83       mdata.notify.wait_for(vmm_data::ENDED);
  84       $display("Time to generate next object");
  85     end
  86     // Done with generation, so indicate done
  87     this.notify.indicate(SOURCE_DONE);
  88   endtask
  89 
  90 endclass
  91 
  92 // This class sinks transactions
  93 class sink extends vmm_xactor;
  94   ahb_data_channel fifo;
  95   vmm_log log;
  96   
  97   function new(vmm_log log, string name, ahb_data_channel fifo);
  98     super.new(name,name);
  99     this.log = log;
 100     this.fifo = fifo;
 101   endfunction
 102 
 103   virtual task main();
 104      ahb_data d;
 105      super.main();
 106      while (1) begin
 107        wait_if_stopped_or_empty(fifo);
 108        fifo.get(d);
 109        // Indicate we are processing the object
 110        d.notify.indicate(vmm_data::STARTED);
 111         #10 ;
 112        // Indicate we done with processing the object
 113        $display("Indicating done processing");
 114        d.notify.indicate(vmm_data::ENDED);
 115      end
 116   endtask
 117 endclass
 118 
 119 program test();
 120   vmm_log log = new("test","ahb_data");
 121   ahb_data_channel fifo = new ("CHANNEL","FIFO");
 122   source src = new(log,"SOURCE",fifo);
 123   sink   snk  = new(log,"SINK",fifo);
 124 
 125   initial begin
 126      snk.start_xactor();
 127      src.start_xactor();
 128      // Wait for source to start
 129      src.notify.wait_for(source::SOURCE_START);
 130      $display("Came out of SOURCE START");
 131      // Wait for source to end
 132      src.notify.wait_for(src.SOURCE_DONE);
 133      $display("Came out of SOURCE DONE");
 134       #100 ;
 135   end
 136 endprogram
You could download file vmm_notify_ex.sv here |