Randomizing different signals in different transactions

Hi,

I’m a newbie to UVM. I want to randomize two separate signals in two different transactions. For the example below- I want to randomize in_data in first transaction(u_tx) and then the reset in next transaction(u_tx1). How to achieve this? (constructors are left out for briefness)

class uart_transaction extends uvm_sequence_item;
  `uvm_object_utils(uart_transaction)
  
  rand bit [7:0] in_data;
  rand bit reset;
  bit [7:0]out_data;
  
endclass

class uart_sequence extends uvm_sequence#(uart_transaction);
  `uvm_object_utils(uart_sequence)
  
  task body;
    uart_transaction u_tx;
    uart_transaction u_tx1;
   
      begin
        u_tx= uart_transaction::type_id::create("u_tx");
        u_tx1= uart_transaction::type_id::create("u_tx1");
        start_item(u_tx);
        assert(u_tx.randomize);
        finish_item(u_tx);
        
      end
  endtask
endclass

typedef uvm_sequencer#(uart_transaction)uart_sequencer;

In reply to Vireshsingh Rana:

You do never randomizing signals in a transaction. A transaction has data fields which might relate to signals, but they do not have to do this.
I gues you want to see different certain values for the data fields after randomization. You can achieve this by setting certain constraints. But in a high quality verification environment you do not want to work with deterministic data, you want to use randomized data, i.e. don’t set to much constraints.

In reply to chr_sue:

Yes chr_sue, it’s true that I want to see different values for the data fields, but my concern is that I don’t want all the signals to randomize in a single transaction.

In reply to Rana_Meet:

Maybe you can just ignore some data fields in one case and another one not. If this will not work you need at least one additional sequence which takes care for some specific values in the data fields.

In reply to chr_sue:

Hi, you could also have a configuration-object (or a series of fields in the transaction) that would be something like this for each of the fields:

bit set_to_fixed_value;
<field_type> fixed_value_to_use;

When you create the instance, but before randomizing, set the various non-rand bits.
you could either constrain to “randomize” to the fixed value, or in post_randomize() you could simply assign the randomized values to the new fixed value.

Is that what you’re looking for? I feel like I’m not quite clear on what your goal is.

In reply to erik.k.jessen@raytheon.com:

I’m not looking to constrain anything. I just want “in_data” to randomize in first transaction keeping “reset” constant. Then in next transaction I want to randomize “reset” keeping “in_data” constant.

In reply to Rana_Meet:
You can call

assert(u_tx.randomize(in_data)); // only randomizes in_data

or you you can set
u_tx.reset.rand_mode(0);

But you never explained how you send multiple transactions.

In reply to dave_59:

Thank you Dave. About how I’m sending multiple transactions- I will call u_tx1 transaction from the driver, and have the u_tx1 randomize some signal.

Please tell me if this the best approach, I’m a newbie.