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_xactor

vmm_xactor class is used for anywhere in verification enviroment we need to have threads, Like always blocks in Verilog. vmm_xactor implements or have infrastrucre which allows thread to stoped, restarted and method to help working with vmm_channel.

   

space.gif

../images/systemverilog/vmm_xactor.png
   

space.gif

In the above image, following are threads

   

space.gif

  • bfm
  • flow_ctrl
   

space.gif

Above methods or threads needs to forked with join_none in main method. The way it works in when start_sim is called, it emits a event inside the vmm_xactor, which causes main method to fork off bfm and flow_ctrl\.

   

space.gif

When ever stop_xactor method is called, it emits a event inside the vmm_xactor, which causes main method to terminate earlier forked off bfm and flow_ctrl\.

   

space.gif

When ever reset_xactor method is called, it internall emits event to stop and start the threads inside main.

   

space.gif

Below is list of methods inside a vmm_xactor, which are commonly used

   

space.gif

   

space.gif

   

space.gif

  • main : This method should fork off all the threads in current class or vmm_xactor
  • start_xactor : This method should call start_xactor of all the child class or class which are instanciated in current class and have threads inside.
  • them.
  • stop_xactor : This method should call stop_xactor of all the child class as in the case of stop_xactor
  • reset_xactor : This method should call reset_xactor of all the child class as in the case of stop_xactor.
  • xactor_status : This method is used for printing vmm_xactor status
  • wait_if_stopped : This method is used to check if stop_xactor was called.
  • wait_if_stopped_or_empty : This method is used for waiting for atleast one item to be available in vmm_channel or waits if stop_xactor is called
  • append_callback : This method is used for appending callback class to vmm_xactor class, we will see more of this in next page.
   

space.gif

Note :Follow below rules to avoid problems

   

space.gif

  • Make sure you fork off threads only from main
  • Make sure you don't fork off threads of lower level class from main or any other thread/method inside current class.
  • Make sure you call lower level class start_xactor from current start_xactor, same rule applied to stop_xactor and reset_xactor
   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif vmm_data Methods
   

space.gif


  1 virtual function string get_name();
  2 virtual function string get_instance();
  3 virtual function void start_xactor();
  4 virtual function void stop_xactor();
  5 virtual function void reset_xactor(reset_e rst_typ = SOFT_RST);
  6 virtual function void save_rng_state();
  7 virtual function void restore_rng_state();
  8 virtual function void xactor_status(string prefix = "");
  9 virtual protected task main();
 10 protected task wait_if_stopped();
 11 protected task wait_if_stopped_or_empty(vmm_channel chan);
 12 virtual function void prepend_callback(vmm_xactor_callbacks cb);
 13 virtual function void append_callback(vmm_xactor_callbacks cb);
 14 virtual function void unregister_callback(vmm_xactor_callbacks cb);
You could download file vmm_xactor_methods.sv here
   

space.gif

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

space.gif


   1 `include "vmm.sv"
   2 
   3 // Need to extend from base class vmm_xactor
   4 class child extends vmm_xactor;
   5   vmm_log log;
   6   
   7   function new(vmm_log log,string name);
   8     super.new(name, "child");
   9     this.log = log;
  10   endfunction
  11 
  12   virtual task main();
  13     super.main();
  14     fork
  15       begin
  16         this.bfm();
  17       end
  18     join_none
  19   endtask
  20 
  21   task bfm();
  22     while(1) begin
  23        #10 ; // This can be clock event
  24       wait_if_stopped();
  25       `vmm_note(log,"Child is running");
  26     end
  27   endtask
  28 endclass
  29 
  30 // Need to extend from base class vmm_xactor
  31 class parent extends vmm_xactor;
  32   vmm_log log;
  33   child   divya;
  34   
  35   function new(vmm_log log,string name);
  36     super.new(name, "parent");
  37     this.log = log;
  38     this.divya = new(log,name);
  39   endfunction
  40 
  41   virtual task main();
  42     super.main();
  43     fork
  44       begin
  45         this.bfm();
  46       end
  47       begin
  48         this.flow_ctrl();
  49       end
  50     join_none
  51   endtask
  52 
  53   virtual function void start_xactor();
  54     super.start_xactor();
  55     this.divya.start_xactor();
  56   endfunction
  57 
  58   virtual function void stop_xactor();
  59     super.stop_xactor();
  60     this.divya.stop_xactor();
  61   endfunction
  62 
  63   virtual function void reset_xactor(reset_e rst_typ = SOFT_RST);
  64     super.reset_xactor();
  65     this.divya.reset_xactor();
  66   endfunction
  67 
  68   virtual function void xactor_status(string prefix = "");
  69    super.xactor_status(prefix);
  70    this.divya.xactor_status(prefix);
  71   endfunction
  72 
  73   task bfm();
  74     while(1) begin
  75        #10 ; // This can be clock event
  76       wait_if_stopped();
  77       `vmm_note(log,"Parent bfm is running");
  78     end
  79   endtask
  80 
  81   task flow_ctrl();
  82     while(1) begin
  83        #10 ; // This can be clock event
  84       wait_if_stopped();
  85       `vmm_note(log,"Parent flow_ctrl is running");
  86     end
  87   endtask
  88 endclass
  89 
  90 program test();
  91   vmm_log log = new("test","test");
  92   parent  deepak    = new(log,"PROGRAM");
  93   initial begin
  94      $display("--------------------------------");
  95      $display(" Calling start_xactor");
  96      $display("--------------------------------");
  97      deepak.start_xactor();
  98      deepak.xactor_status("ASIC-WORLD ");
  99       #20 ;
 100      $display("--------------------------------");
 101      $display(" Calling stop_xactor");
 102      $display("--------------------------------");
 103      deepak.stop_xactor();
 104      deepak.xactor_status("ASIC-WORLD ");
 105       #100 ;
 106      $display("--------------------------------");
 107      $display(" Calling start_xactor");
 108      $display("--------------------------------");
 109      deepak.start_xactor();
 110      deepak.xactor_status("ASIC-WORLD ");
 111       #20 ;
 112      $display("--------------------------------");
 113      $display(" Calling reset_xactor");
 114      $display("--------------------------------");
 115      deepak.reset_xactor();
 116      deepak.xactor_status("ASIC-WORLD ");
 117       #40 ;
 118   end
 119 endprogram
You could download file vmm_xactor_ex.sv here
   

space.gif

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

space.gif

 --------------------------------
  Calling start_xactor
 --------------------------------
 Normal[NOTE] on PROGRAM(parent) at                    0:
     ASIC-WORLD Transactor PROGRAM (parent):
     ASIC-WORLD Transactor is STOPPED
 Normal[NOTE] on PROGRAM(child) at                    0:
     ASIC-WORLD Transactor PROGRAM (child):
     ASIC-WORLD Transactor is STOPPED
 Trace[INTERNAL] on PROGRAM(parent) at                    0:
     Started
 Trace[INTERNAL] on PROGRAM(child) at                    0:
     Started
 Normal[NOTE] on test(test) at                   10:
     Parent bfm is running
 Normal[NOTE] on test(test) at                   10:
     Parent flow_ctrl is running
 Normal[NOTE] on test(test) at                   10:
     Child is running
 --------------------------------
  Calling stop_xactor
 --------------------------------
 Trace[INTERNAL] on PROGRAM(parent) at                   20:
     Stop requested
 Trace[INTERNAL] on PROGRAM(parent) at                   20:
     0 out of 1 threads have now stopped
 Trace[INTERNAL] on PROGRAM(child) at                   20:
     Stop requested
 Trace[INTERNAL] on PROGRAM(child) at                   20:
     0 out of 1 threads have now stopped
 Normal[NOTE] on PROGRAM(parent) at                   20:
     ASIC-WORLD Transactor PROGRAM (parent):
     ASIC-WORLD Transactor is STOPPING (0 out of 1 threads stopped)
 Normal[NOTE] on PROGRAM(child) at                   20:
     ASIC-WORLD Transactor PROGRAM (child):
     ASIC-WORLD Transactor is STOPPING (0 out of 1 threads stopped)
 Trace[INTERNAL] on PROGRAM(parent) at                   20:
     1 out of 1 threads have now stopped
 Trace[INTERNAL] on PROGRAM(parent) at                   20:
     Stopped
 Trace[INTERNAL] on PROGRAM(parent) at                   20:
     2 out of 1 threads have now stopped
 Trace[INTERNAL] on PROGRAM(parent) at                   20:
     Stopped
 Trace[INTERNAL] on PROGRAM(child) at                   20:
     1 out of 1 threads have now stopped
 Trace[INTERNAL] on PROGRAM(child) at                   20:
     Stopped
 --------------------------------
  Calling start_xactor
 --------------------------------
 Normal[NOTE] on PROGRAM(parent) at                  120:
     ASIC-WORLD Transactor PROGRAM (parent):
     ASIC-WORLD Transactor is STOPPED
 Normal[NOTE] on PROGRAM(child) at                  120:
     ASIC-WORLD Transactor PROGRAM (child):
     ASIC-WORLD Transactor is STOPPED
 Trace[INTERNAL] on PROGRAM(parent) at                  120:
     Restarted
 Normal[NOTE] on test(test) at                  120:
     Parent bfm is running
 Normal[NOTE] on test(test) at                  120:
     Parent flow_ctrl is running
 Trace[INTERNAL] on PROGRAM(child) at                  120:
     Restarted
 Normal[NOTE] on test(test) at                  120:
     Child is running
 Normal[NOTE] on test(test) at                  130:
     Parent bfm is running
 Normal[NOTE] on test(test) at                  130:
     Parent flow_ctrl is running
 Normal[NOTE] on test(test) at                  130:
     Child is running
 --------------------------------
  Calling reset_xactor
 --------------------------------
 Normal[NOTE] on PROGRAM(parent) at                  140:
     ASIC-WORLD Transactor PROGRAM (parent):
     ASIC-WORLD Transactor is STOPPED
 Normal[NOTE] on PROGRAM(child) at                  140:
     ASIC-WORLD Transactor PROGRAM (child):
     ASIC-WORLD Transactor is STOPPED
 Normal[NOTE] on test(test) at                  140:
     Parent bfm is running
 Normal[NOTE] on test(test) at                  140:
     Parent flow_ctrl is running
 Normal[NOTE] on test(test) at                  140:
     Child is running
 Trace[INTERNAL] on PROGRAM(parent) at                  140:
     Reset
 Trace[INTERNAL] on PROGRAM(child) at                  140:
     Reset
   

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