I used the start_item/finish_item but I noticed that a certain variable in the previous transaction is also used in the next transaction.
It looks like the disadvantage of using this is that the next transaction is not created as a fresh copy.
start_item(req);
// Some codes here
// I assign a value to a variable here
req.var = 8'hab;
finish_item(req);
// This is the second transaction
start_item(req);
// Some codes here
// I did not assign req.var here but I noticed in the simulation that the value of req.var here is 8'hab, which is the same
// as the previous transaction.
finish_item(req);
Now I’m thinking if there’s a better way of using start_item/finish_item without having this issue?.. Or is it better to use uvm_do macros?.. But I read something here in the Verification Academy that using UVM macros is not advisable… So what do you think?
I’m thinking to use create_item before every start_item. Is that advisable?
start_item() will tell the sequencer that your sequence is available for arbitration by the sequencer. When it returns, your sequence should then set the variables in your sequence_item to the required values (i.e. by randomization or manual methods). finish_item() will then send the sequence_item to the driver.
When you re-use the same sequence_item handle, all the variables that you defined will remain as they were previously set.
There are several things you can do:
You can create() a new sequence item, but this has some additional overhead which can impact performance.
Randomize the sequence_item again and/or manually set the sequence_item variables
What is your concern about the sequence_item having the same values from the previous sequence?
Hi cgales. Thanks for the advise.
My only concern is that I have to add additional codes to prevent the next item to have the same values from the previous item.
I mean for a manual settings of the sequence_item, this may require the coder to set each non-rand variable to their default values each time a sequence_item is set. In using uvm_do macros, the coder will just have to use this macro and for every item the default values is always set, thus the code is simpler.
Anyway, I think the 2 solutions you mentioned is okay.
If you want to manually set values within your sequence_item, then you definitely don’t want to use the uvm_do macros. uvm_do will only allow you to randomize fields (with additional constraints). This can also have a significant impact on performance since the constraint solver is called.
It is recommended that you don’t use the macros and call randomize() or set values as required.