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_data

vmm_data is a data_structure which is used for holding all the fields/values that should be communicated between a checker and monitor, generator and bfm. I like to call it base class. Something that is used for communcating information from one object to other object. In VMM, vmm_data object is the one which moves in vmm_channel, is used in atomic generators, and scenario generators.

   

space.gif

Other then have fields or variables used for storing the useful data, it contains set of pre defined methods (functions) that work on these variables.

   

space.gif

Some of the methods are

   

space.gif

  • copy : This method is used for copying all field in current class instance to new class instance
  • compare : This method is used for comparing current class instance to class passed as parameter to compare method
  • psdisplay : This method returns the all field values and their value in string format
  • display : This method is same as psdisplay, but it display the string to simulation log
  • byte_pack : This is used for packing various fields into byte stream
  • byte_unpack : This is used for unpacking byte stream into various fields
  • is_valid : This is used for checking if object is valid or not. Example : Packet with CRC is not valid
   

space.gif

When there are many vmm_data object instances that are generated and stored in BFM or in checker, it becomes difficult to debug, To help debug vmm provides 3 variables which can be used for storing unique id

   

space.gif

  • stream_id : Stream idendifier
  • scenario_id : Sequence identifier within a stream
  • data_id : Instance identifier within a sequence
   

space.gif

Since vmm_data class is used with atomic/scenario generators, which we will

look in detail in later chapters. vmm_data class definition should contain

valid constraints to randmize the class.

   

space.gif

Note :Follow below rules to avoid problems

   

space.gif

  • vmm_log pointer in vmm_clas should be pointer passed from class which is using vmm_data. Never create new instance of vmm_log in vmm_data.
  • Never have functional coverage points in vmm_data. Have functional coverage points coded outside vmm_data like in monitor, Monitor can extract values from vmm_data and work on it
   

space.gif

   

space.gif

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

space.gif


  1 function new(vmm_log log);
  2 function vmm_log set_log(vmm_log log);
  3 function void display(string prefix = "");
  4 virtual function string psdisplay(string prefix = "");
  5 virtual function bit is_valid(bit silent = 1, int kind = -1);
  6 virtual function vmm_data allocate();
  7 virtual function vmm_data copy(vmm_data to = null);
  8 virtual protected function void copy_data(vmm_data to);
  9 virtual function bit compare( vmm_data to, output string diff, 
 10    input int kind = -1);
 11 virtual function int unsigned byte_size(int kind = -1);
 12 virtual function int unsigned max_byte_size(int kind = -1);
 13 virtual function int unsigned byte_pack(ref logic [7:0]bytes[], 
 14   input int unsigned offset = 0, input int kind = -1);
 15 virtual function int unsigned byte_unpack(const ref logic [7:0] bytes[], 
 16  input int unsigned offset = 0, input int len= -1, input int kind = -1);
 17 virtual function bit load(int file);
 18 virtual function void save(int file);
You could download file vmm_data_methods.sv here
   

space.gif

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

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   // You should use enum, when needed
   8   typedef enum {OKAY,ERROR,RETRY,SPLIT} rsp_t;
   9   typedef enum {IDLE,BUSY,NONSEQ,SEQ} tnr_t;
  10   typedef enum {WRITE,READ} cmd_t;
  11   typedef enum {SINGLE,INCR,WRAP4,INCR4,WRAP8,
  12   INCR8,WRAP16,INCR16} burst_t;
  13 
  14   // Declare all the fields
  15   rand bit [31:0] addr;
  16   rand bit [31:0] data [16];
  17   rand bit [3:0]  beats;
  18   rand tnr_t  transfer;
  19   rand rsp_t  response;
  20   rand cmd_t  cmd;
  21   rand burst_t burst;
  22 
  23   // Make sure all variables have init value 
  24   function new(vmm_log log);
  25     int i;
  26     super.new(log);
  27     this.log  = log;
  28     this.addr       = 0;
  29     for (i = 0; i < 16; i ++) begin
  30       this.data[1] = 0;
  31     end
  32     this.beats     = 0;
  33     this.transfer  = IDLE;
  34     this.response  = OKAY;
  35     this.cmd       = WRITE;
  36     this.burst     = SINGLE;
  37   endfunction
  38 
  39   // Print message
  40   function void display(string prefix = "");
  41     if (is_valid()) begin
  42      `vmm_debug(log,$psprintf("%s",psdisplay(prefix)));
  43     end else begin
  44      `vmm_error(log,$psprintf("%s",psdisplay(prefix)));
  45     end
  46   endfunction
  47 
  48   // Return the string members and their values
  49   virtual function string psdisplay(string prefix = "");
  50     string msg;
  51     int i;
  52     msg = $psprintf("   %s\n", prefix);
  53     msg = $psprintf("%s ADDRESS       : 32'h%x\n",msg,addr);
  54     msg = $psprintf("%s COMMAND       : %s\n",msg,cmd.name());
  55     msg = $psprintf("%s TRANSFER      : %s\n",msg,transfer.name());
  56     msg = $psprintf("%s RESPONSE      : %s\n",msg,response.name());
  57     msg = $psprintf("%s BEATS         : %0d\n",msg,beats);
  58     msg = $psprintf("%s BURST         : %s\n",msg,burst.name());
  59 
  60     for (i = 0; i < beats; i++) begin
  61       msg = $psprintf("%s DATA[%2d]      : 32'h%x\n",msg,i,data[i]);
  62     end
  63     psdisplay = msg;
  64   endfunction
  65 
  66   virtual function bit is_valid(bit silent = 1, int kind = -1);
  67     is_valid = (response  ! = ERROR);
  68   endfunction
  69 
  70   virtual function vmm_data copy(vmm_data to = null);
  71      ahb_data cpy;
  72      int i;
  73      if (to == null) begin
  74        cpy = new (log);
  75      end else begin
  76        if ( ! ($cast(cpy,to))) begin
  77          `vmm_fatal(log,"Object is not of type ahb_data");
  78        end
  79      end
  80     cpy.addr = this.addr;
  81     for (i = 0; i < 16; i ++) begin
  82       cpy.data[i] = this.data[1];
  83     end
  84     cpy.beats    = this.beats    ;
  85     cpy.transfer = this.transfer ;
  86     cpy.response = this.response ;
  87     cpy.cmd      = this.cmd      ;
  88     cpy.burst    = this.burst    ;
  89     copy         = cpy;
  90   endfunction
  91    
  92   virtual function bit compare( vmm_data to, output string diff, 
  93      input int kind = -1);
  94     int cmp = 1;
  95     ahb_data cp;
  96     if (to == null) begin
  97       `vmm_error(log,"Passed pointer to copy method is null");
  98       return 0;
  99     end else begin
 100       if ( ! ($cast(cp,to))) begin
 101         `vmm_fatal(log,"Object is not of type ahb_data");
 102       end
 103     end
 104     if (addr  ! = cp.addr) begin
 105       diff = $psprintf("Expected 32'h%x Got 32'h%x",addr, cp.addr);
 106       return 0;
 107     end
 108     if (beats  ! = cp.beats) begin
 109       diff = $psprintf("Expected 32'h%x Got 32'h%x",beats, cp.beats);
 110       return 0;
 111     end
 112     // You can add reset of the code here
 113     compare = cmp;
 114   endfunction
 115 
 116 endclass
 117 
 118 program test();
 119   vmm_log log = new("vmm_log_test","ahb_data");
 120   ahb_data mdata = new (log);
 121   initial begin
 122     if (mdata.randomize() == 0) begin
 123     end else begin
 124      mdata.display("PROGRAM");
 125     end
 126      #10 ;
 127   end
 128 endprogram
You could download file vmm_data_ex.sv here
   

space.gif

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

space.gif

 Debug[DEBUG] on vmm_log_test(ahb_data) at                    0:
        PROGRAM
      ADDRESS       : 32'hca358297
      COMMAND       : WRITE
      TRANSFER      : NONSEQ
      RESPONSE      : SPLIT
      BEATS         : 3
      BURST         : INCR8
      DATA[ 0]      : 32'hb6077db0
      DATA[ 1]      : 32'h04279b9b
      DATA[ 2]      : 32'h90134d03
   

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