# Sequence to that respond to done signal

**URL:** <https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400>\
**Category:** UVM\
**Tags:** get\_response, Response-API, UVM, sequence, sequence-body\
**Created:** [August 4, 2021, 10:52am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400 "2021-08-04T10:52:11Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 4, 2021, 10:52am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/1 "2021-08-04T10:52:11Z")

</div>

I am writing the task body below

```verilog
task body();
  req = packet::type_id::create("rqst");

  start_item(req);
    void`(randomize() with req.sel == 1;
                           req.en == 1;
                           req.addr == 20'h0100;);
  finish_item(req);
endtask : body

```

I am driving this signals to DUT. After the operation is completed, **done** bit will be set to 1.  
On receiving done with I want to send address 20’h1100. So aim is to receive **done** as a response from DUT and send the packet to driver with another address. How can I code the sequence body for that.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [August 4, 2021, 11:33am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/2 "2021-08-04T11:33:05Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400):_

To be honest, I do not see any ‘done’ bit in your seq\_item.  
What do you mean with ‘done’ bit?  
Or do you want to send consecutive seq\_items? this automatically donw when adding a next start\_item/finish\_item.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 4, 2021, 1:25pm UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/3 "2021-08-04T13:25:58Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/2):_

**done** is a part of sequence item class, which is an output from DUT.  
done bit is raised to indicate current operation is done and next inputs can be passed.  
Should I use multiple start and finish items?

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [August 4, 2021, 1:58pm UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/4 "2021-08-04T13:58:11Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/3):_

This is what the call of item\_done() in the driver is doing. It is the indication to the sequencer to generate the next seq\_item.  
start\_item/finish\_item creates exactly 1 item. If you need more you have to implement multiple start\_item/finish\_item.  
To make your code easy you could use a loop construct in the body method like this

```verilog
task body();
 repeat (10) begin
  req = packet::type_id::create("req");
  start_item(req);
    void`(randomize() with sel == 1; en == 1; addr inside {20'h0000, 20'h0100};);
  finish_item(req);
endtask : body

```

This generates seq\_item with addr in random order.

It looks like your seq\_item has data members you do not need, like sel and en. You can set these variables directly in the driver.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 5, 2021, 6:22am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/5 "2021-08-05T06:22:33Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/4):_

I think, I didn’t give much details on my DUT behavior. It takes up the address and performs write action on next 100 addresses near to it. So I had wait till this action is completed to drive next address. If I am using the body you provided it will overwrite the initial address and address calculation for further operation will be blocked. Is there any way to involve response port here?

Also I cant set sel and enable in driver as the driving is different for other tests.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [August 5, 2021, 7:23am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/6 "2021-08-05T07:23:26Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/5):_

You are determining the timing behavior in your driver. The next seq\_item will be retrieved after the item\_done has been sent. This behavior does not override anything.  
How do you differentiate your tests? Do you have really differnet protocols in your driver?  
I do not believe it.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 5, 2021, 8:09am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/7 "2021-08-05T08:09:04Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/6):_

No. I use same protocol. I was looking forward something like response port to achieve this behavior.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 5, 2021, 8:12am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/8 "2021-08-05T08:12:41Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/7):_

> 

```verilog
repeat (10) begin
req = packet::type_id::create("req");
start_item(req);
void`(randomize() with sel == 1; en == 1; addr inside {20'h0000, 20'h0100};);
finish_item(req);

```

But I cant just put my body code like this. The addresses are deterministic in nature. So I have drive to those specific values in order. So should I use multiple start and finish item?

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [August 5, 2021, 8:22am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/9 "2021-08-05T08:22:08Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/8):_

Deterministic means you have to use fixed addresses in a well-defined order?

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 5, 2021, 8:23am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/10 "2021-08-05T08:23:37Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/9):_

Yes exactly

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [August 5, 2021, 8:34am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/11 "2021-08-05T08:34:18Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/10):_  
int addr\_q[$]; // declaration of a queu to store addresses

in the body method fill the queue with the proper addresses in the right order (using an assigment pattern or a loop.

```verilog
task body();
   int tmp_addr;
   addr_q = '{addr1, addr2, ...};

    repeat (10) begin
      req = packet::type_id::create("req");
      tmp_addr = addr_q.pop_front(); // returns the first element of this queue
      start_item(req);
        void`(randomize() with sel == 1; en == 1; addr == tmp_addr;);
      finish_item(req);
   end
endtask

```

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 5, 2021, 9:15am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/12 "2021-08-05T09:15:40Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/11):_

Yes this can work. A little bit modification in driver will realize my logic.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [August 5, 2021, 10:37am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/13 "2021-08-05T10:37:31Z")

</div>

_In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/12):_

Please let us know if it is working.  
If the next address depends on some data you receive from the DUT you need a response sent from the driver to the sequence.

---

<div class="post-metadata">

**Author:** ![bachan21](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bachan21/32/1208_2.png) [@bachan21](https://verificationacademy.com/forums/u/bachan21)\
**Post date:** [August 23, 2021, 6:32am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/14 "2021-08-23T06:32:47Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/13):_

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/13):_

Hi,  
This method is working. But I am facing an issue now.  
I have created two sequences with 2 different queue values.

```verilog
bit [19:0] q;

```

In first sequence (the name is a\_seq), I have given following values

```verilog
q = {20'h983, 20'h183};

```

In the second q(b\_seq), I have given following values

```verilog
q = {20'h903, 20'h103};

```

First sequence is working properly and done bit is produced for value 20’h983 and 20’h183  
In case of second test only 20’h903 is being passed successfully. Test is hanging when 20’h103 is passsed.

But the crazy thing is when I have assigned 20’h983 and 20’h183 to q of a\_seq. It’s driven successfully. Given that the other contents of a\_seq and b\_seq are same,it doesn’t make any sense. What can be the possible reason for hanging in this situation?

---

<div class="post-metadata">

**Author:** ![dddvlsique](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@dddvlsique](https://verificationacademy.com/forums/u/dddvlsique)\
**Post date:** [August 23, 2021, 11:20am UTC](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/15 "2021-08-23T11:20:55Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/14):_

> _In reply to [bachan21](https://verificationacademy.com/forums/t/sequence-to-that-respond-to-done-signal/39400/14):_  
> int addr\_q[$]; // declaration of a queu to store addresses  
> in the body method fill the queue with the proper addresses in the right order (using an assigment pattern or a loop.

```verilog
task body();
int tmp_addr;
addr_q = '{addr1, addr2, ...};
repeat (10) begin
req = packet::type_id::create("req");
tmp_addr = addr_q.pop_front(); // returns the first element of this queue
start_item(req);
void`(randomize() with sel == 1; en == 1; addr == tmp_addr;);
finish_item(req);
end
endtask

```

@chr_sue ,If i have to drive addr2 based on response of addr1 from driver to sequence depends on “done” bit of sequence item class ,so following below code of driver and sequence is correct ?

driver code ::

```verilog
task run_phase( uvm_phase phase );
  REQ req_item; //REQ is parameterized type for requests
  RSP rsp_item; //RSP is parameterized type for responses
 
  bit [15:0] rdata;
  bit resp;
 
  forever begin
    seq_item_port.get(req_item); // finish_item in sequence is unblocked
 
    //BFM handles all pin wiggling 
     drive(req_item);
 
    $cast(rsp_item, req_item.clone()); // Create a response transaction by cloning req_item
    rsp_item.set_id_info(req_item); // Set the rsp_item sequence id to match req_item
    
    rsp_item.done = resp;
    seq_item_port.put(rsp_item); // Handshake back to the sequence via its get_response() call
  end
endtask

```

sequence code ::

```verilog
task body();
   int tmp_addr;
   addr_q = '{addr1, addr2, ...};
 
      req = packet::type_id::create("req");
      tmp_addr = addr_q.pop_front(); // returns the first element of this queue
      start_item(req);
        void`(randomize() with sel == 1; en == 1; addr == tmp_addr;);
      finish_item(req);
     //first addr1 sequence is completed

     get_response(rsp); //wait for response for first addr1

    if(rsp.done == 1)
    begin
    req = packet::type_id::create("req");
      tmp_addr = addr_q.pop_front(); // returns the second element of this queue 
      start_item(req);
        void`(randomize() with sel == 1; en == 1; addr == tmp_addr;);  
      finish_item(req);
    end
    
     
endtask

```
