Returning an array in Specman

How do I return an array from a method call in Specman ? For instance.

method a : list of uint is { 
   var data: list of uint;
   .....
   result = data;

};

extend sys {
 var data_sys: list of uint;
 run() is also {
  data_sys = a();
 };
};

      

My printout shows some items are different from the array data and data_sys. Can you tell me what I missed?

+1


a source to share


2 answers


The code you posted will not compile. Put more print statements or set a breakpoint in the specview and run the code. Do you know at what test stage you make a printout? If you want to procedurally set data_sys (instead of generating it by Specman), you must specify the do-not-generate '!' Modifier.



[...]
!data_sys : list of uint;
[...]

      

+1


a source


pls provide sscce .

without it, this very simple example can do:

extend sys {
  m() : list of uint is {
    print result.size(); // result.size() = 0
  };

  run() is also {
    var m := m();
  };
};

      



methods can return an array which is provided to you by default. it is returned by a pointer, so be aware.

As a rule of thumb, try to avoid methods that return a list when you evaluate them. try passing the list as a parameter to pass its dynamic nature, unless the method is a create method or getter:

collect_packets(packets : list of packet) is {...};
get_collected_packets() : list of packet is {...};

      

+1


a source







All Articles