Ovm_do problem()

i have a problem ,when i use ovm_do to randomize my sequence_item, i also want some property like content[$] to be set equal to constant value , so i use mid_do function to set req.content[0]==* … but it turns out to be wrong , i am confused … help me ~~

It’s hard to tell what it wrong with the limited information that you posted.

I would recommend that you don’t use ovm_do macro or mid_do.

Instead, use the function API directly. It makes debugging problems a lot easier.

In your body…

$cast(txn_handle, create_item(transaction_classname::type_id::get(), m_sequencer, “name”));
// Do what you need to do to set transaction fields, randomize, etc. here

See the OVM reference for more information on create_item, start_item, and finish_item.


thanks kurts, i think i may not clearly describe my problem.
for example
class my_trans extends ovm_transaction
rand bit a;
rand bit [7:0] payload[$];


the class have two property ,and i can add constraint in sequence to send my_trans with a=1,

class my_seq_1 extends ovm_sequence #( my_trans)

task body;

but how can i constraint payload to a constant array ? if in some sequence i need payload[0]=h30,payload[1]=h40,…

Here are two ways you could do this:

  1. call rand_mode(0) on your transaction field before randomizing (e.g. txn.payload.rand_mode(0)) and then assign directly to the payload array.

  2. In your constraint, use the foreach construct:

{ foreach ( payload[i] ) payload[i] == other_constant_array[i]; }

There is probably another, easier way, but these two ways are what I can think of off the top of my head.