In the following code, I need to send a randc data for each resp[i], but the randomize() is not supported in the constraint, how can I implement this? Please advise! Thanks!
class rand_resp extends uvm_component;
randc bit[5:0] data;
end class : rand_resp
class abc_seqeunce extends base_sequence;
rand_resp m_rand_resp;
endclass : abc_sequence
virtual task body() ;
`uvm_rand_send_with(item,
{
foreach(resp[i]) {
m_rand_resp.randomize();
resp[i] == m_rand_resp.data;
}
)
Your code isn’t very clear with respect to what you are trying to accomplish. I don’t see where resp is an array, so I’m not sure why you are using a foreach() construct.
Also, you shouldn’t use the uvm_rand_send_with macro (or any other uvm_send* macro). Try writing out your sequence using the appropriate APIs and it will probably be easier for you to understand what your issue is.
Note that ‘randc’ is only valid for a single class instance. The `uvm_send_* macros will create() a new object every time, which is why their usage isn’t recommended.
Thanks Cgales for the reply. What would be the equivalent code to the macro of `uvm_rand_send_with ? the code was trying to send out a request of a burst, so there is an array there …
Thanks Cgales. I have replaced the macro with normal sequence code (e.g. start_item() … finish_item()), and it’s working now …
You mentioned ‘randc’ is only valid for a single class instance. If I have the following class gets instantiated by different sequence, the randc value won’t be unique anymore for a single simulation run? Thanks!
class abc extends uvm_object;
randc bit[5:0] data;
`uvm_object_utils(abc)
function new(string name = "abc");
super.new(name);
endfunction : new
endclass : abc
The ‘randc’ qualifier is only valid for a specific instance of a class. If you create a second instance, ‘randc’ is independent for that second instance and has no effect on the first instance.
Thanks Cgales. That makes sense. Do you have idea how to make “data” generated in two different sequences are unique? using a common list and exclude from that list every time? Looks like using randc can only guarantee the data generated in the current sequence are unique … Thanks!
If you want to create sequences with unique data, then you should use a virtual sequence that creates the data and then starts sub-sequences ensuring that each sequence is initialized with the unique data.