quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif vmm_notify

vmm_notify class implements the notitication service. This can used for communicating information like when a transcation started, when a transaction ended. It can be used for indicating state of a transaction or a object.

   

space.gif

One of the most common usage of vmm_notify is STARTED and ENDED notify event in vmm_data class.

   

space.gif

Below is list of commonly used vmm_notify methods

   

space.gif

  • configure: This method is used to confiure type of notification
  • indicate : This method is used to set notification
  • wait_for : This method is used for waiting for a notification
  • reset : This method is used for reset the state of notification
   

space.gif

Most of the vmm classes have pre defined notify events. But at times one need to needs to define new notify events. There are two ways to define a notify event

   

space.gif

  • int :In this notify event is declared as int
  • enum :In this notify event is declared as enum
   

space.gif

Example shows usage of both

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif vmm_notify Methods
   

space.gif


  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
   

space.gif

  ../images/main/bulllet_4dots_orange.gif Example : vmm_notify
   

space.gif


   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
   

space.gif

  ../images/main/bulllet_4dots_orange.gif Simulation Log : vmm_notify
   

space.gif

 Trace[INTERNAL] on SOURCE(SOURCE) at                    0:
     Started
 Trace[INTERNAL] on SINK(SINK) at                    0:
     Started
 Trace[INTERNAL] on SINK(SINK) at                    0:
     1 threads have now stopped or blocked
 Debug[INTERNAL] on CHANNEL(FIFO) at                   10:
     New instance added to channel @-1 (level 1 of 1/0)
            
      ADDRESS       : 32'h00000000
      BEATS         : 1
      DATA[ 0]      : 32'h00000000
     
 Came out of SOURCE START
 Debug[INTERNAL] on CHANNEL(FIFO) at                   10:
     New instance peeked from channel @0 (level 1 of 1/0)
            
      ADDRESS       : 32'h00000000
      BEATS         : 1
      DATA[ 0]      : 32'h00000000
     
 Debug[INTERNAL] on CHANNEL(FIFO) at                   10:
     New instance removed from channel @0 (level 0 of 1/0)
            
      ADDRESS       : 32'h00000000
      BEATS         : 1
      DATA[ 0]      : 32'h00000000
     
 Indicating done processing
 Trace[INTERNAL] on SINK(SINK) at                   20:
     1 threads have now stopped or blocked
 Time to generate next object
 Debug[INTERNAL] on CHANNEL(FIFO) at                   20:
     New instance added to channel @-1 (level 1 of 1/0)
            
      ADDRESS       : 32'h00000000
      BEATS         : 1
      DATA[ 0]      : 32'h00000000
     
 Debug[INTERNAL] on CHANNEL(FIFO) at                   20:
     New instance peeked from channel @0 (level 1 of 1/0)
            
      ADDRESS       : 32'h00000000
      BEATS         : 1
      DATA[ 0]      : 32'h00000000
     
 Debug[INTERNAL] on CHANNEL(FIFO) at                   20:
     New instance removed from channel @0 (level 0 of 1/0)
            
      ADDRESS       : 32'h00000000
      BEATS         : 1
      DATA[ 0]      : 32'h00000000
     
 Indicating done processing
 Trace[INTERNAL] on SINK(SINK) at                   30:
     1 threads have now stopped or blocked
 Time to generate next object
 Came out of SOURCE DONE
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com