# Best way to introduce delay between sequences

**URL:** <https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096>\
**Category:** UVM\
**Tags:** UVM, sequence-delays\
**Created:** [May 15, 2019, 11:10pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096 "2019-05-15T23:10:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 15, 2019, 11:10pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/1 "2019-05-15T23:10:23Z")

</div>

I have a scenario where in, I just provide a trigger(input control) signal to DUT and series of processes take place inside the DUT. And on TB side, i have to wait for as many clock(around 300,000 clks) before sending another trigger, to ensure that the outputs following the first trigger are generated.  
Which is the recommended way to achieve?

1. send a sequence with control(trigger) signals set to high and another sequence with control signals set to zero. In driver, wait for as many clocks in the drive task. But not sure this delay will be effective after sending 2nd sequence. Remember , coming across a situation wherein, simulation ended after the last sequence.
2. Keep sending the sequences on every clock(even for delay period waiting for DUT processing) with control signal set to zero. That is what i did in some other case. But in this case, its a huge delay.
3. Is there any way I can access the clock in sequence and introduce required delay(in terms of clocks) before sending next trigger?

Please let me know

---

<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:** [May 16, 2019, 6:11am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/2 "2019-05-16T06:11:24Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096):_

The sequencer/sequence works on the transaction level. This does not know anything about timing, clock cycles etc. And the sequencer is not sending anything. The driver is retrieving a seq\_item from the sequencer. In the default implementation this interface is blocking, i.e. the driver is waiting until a seq\_item is ready.  
In your case you have to implement ‘your delay’ in the driver. I believe you have soething like an acknowledge indicating your DUT is ready and waiting for a new input.  
After seeing this acknowledge you can execute ‘item\_done’. Then the driver will get the next seq\_item.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 16, 2019, 4:31pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/3 "2019-05-16T16:31:44Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/2):_

@chr_sue, no, my DUT doesn’t have any indication. That’s the tricky part. But i think, i can come up with approximate number of clock cycles(using some parameters). Need to see. DuT generates addresses, wr\_en for two different RAMs after an input trigger with some deliberate delays in between.

BTW, if at all there is an acknowledgement, how do we handle? Is it through an uvm\_event from monitor to driver? Was just curious to know.  
Thank you!

I came across a link related to above topic:

> **[How to delay a sequence from a test](https://forums.accellera.org/topic/1871-how-to-delay-a-sequence-from-a-test/)**
>
> Hi, I have a sequence running but i want to delay that sequence for 50 clk. How can i do it from the test. Is reset\_phase a good option in the test class? or is their another way out. thanks

---

<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:** [May 16, 2019, 6:11pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/4 "2019-05-16T18:11:23Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/3):_

A certain number of clock cycles can be also such an indication.

Following the link from Accellera is not a good coding practice because you are violating the TLM rules. This might also cause additional problems or additional waiting times.  
If have never seen this in practice and I have never used this in projects and I’ll never, never recommend this.  
You can control in all cases the delay from the driver. The monitor is also not a good idea because the monitor does not have any permission to stop the execution of the DUT. This would result in a loss of data.

If you are doing this in the driver, you do not need any uvm\_event. Add to your drivers run\_phase (at the end) only the number of clock cycles you have to wait.  
Then call item\_done and you can retrieve with get\_next\_item the next seq\_item.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 16, 2019, 7:13pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/5 "2019-05-16T19:13:29Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/4):_

I wasn’t either convinced with the inputs in above Accellera link. Hence posted the question here.

I didn’t mean to add any delay in monitor. I wanted to ask, if there is an acknowledgement from the DUT to get the next set of inputs, do we pass this acknowledgement from monitor to driver through an event? I wanted to check that.

Will look into possibilities of coming up with certain delay. Thank you!

---

<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:** [May 16, 2019, 8:09pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/6 "2019-05-16T20:09:56Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/5):_

You can observe all pinlevel signals in the driver. If there is an acknowledgement you can do this from the driver. This is the easiest way. If you like complicated solutions you can observe the ack in the monitor and trigger an event which is considered in the driver (not recommended).

You can also add a random delay in the driver between 2 seq\_items by randomizing a local variable.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 16, 2019, 10:34pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/7 "2019-05-16T22:34:28Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/6):_

oh!yes. realized it later. Thank you!

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 17, 2019, 10:22pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/8 "2019-05-17T22:22:31Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/7):_

> _In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/7):_  
> A certain number of clock cycles can be also such an indication.

@chr_sue  
I could come up with certain number of clocks to introduce delay in driver. Looks like i am kind of stuck with the monitor now.  
Here are the thigs to follow for my TB:

1. Write into RAM1 (800 bytes):  
\*\*\*\* I generated sequences with wr\_addr, wr\_en, wr\_data

2. Trigger a control module which reads data from the above RAM1, writes into another similar RAM2 (with huge interleaved delays)  
\*\*\*\* I generated sequences t set/reset the trigger bit  
\*\*\*\* based on the above trigger bit, I waited for a certain delay in the Driver

3. Read the RAM2 and check the data integrity.

I have just started working on Monitor. Since there is a clk delay to read RAM2, i need to add 1 clk delay to get rd\_data, without affecting inputs capture.  
I am thinking something like below:

```verilog

seq_item mon_items[$];
virtual task run_phase(uvm_phase phase);
  fork
    forever begin
      seq_item seq_item_collected=new;
     @(vif.cb_clk);
     // capture the RAM1 write inputs
      seq_item_collected.ram1_wr_addr= vif.ram1_wr_addr;
       :
       :
     if(vif.trigger) begin //for the control_module
       //wait for **certain delay**  
       delay_done = '1;
      end
      if(delay_done)
        seq_item_collected.ram2_rd_addr= vif.ram2_rd_addr;
      mon_items.push(seq_item_collected);
    end //forever
    forever begin
      @(vif.cb_clk);
      @(vif.cb_clk);
       if(mon_items.size() > 0) begin
         seq_item seq_item_collected = mon_items.pop_front();

       seq_item_collected.ram2_rd_data= vif.cb_clk.ram2_rd_data;

       if(seq_item_collected.ram1_wr == 1 || delay_done)
         trans_collected_port.write(seq_item_collected);
       end
    end //forever
  join
endtask  

```

Its a rough code that i have thought.

1. With above approach, i am apprehensive if all the certain delays(driver, monitor) would match and the sequences would occur as expected. And also the read to RAM2(rd\_addr,rd\_data) are placed at right time.
2. Other way is sending an uvm\_event from driver when actual read\_addr are placed for RAM2 so that, driver and monitor are in sync.  
3.Add a control bit in seq\_item, just to indicate its a read to RAM2. This can be used in monitor to sample the rd\_data from RAM2. This is more clear than other two options. But is it good practice to add a bit in seq\_item just for TB use?  
I have just started working on UVM TBs and don’t have any UVM code, guidelines or anyone who knows UVM at work.  
Just get thinking about the options. Please guide.

---

<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:** [May 18, 2019, 2:31pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/9 "2019-05-18T14:31:58Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/8):_

A few questions to get the right understanding:  
(1) you have sequence executing WR to RAM1; generates 800 seq\_items with different addr and data. Correct?  
(2) What kind of component is the control module you are triggering. Is this a Verilog module or is it a uvm\_component belonging to your verification environment?

You can obeserve the internals of this control module. If it is a Verilog/SV module you can bind an observing component to the control module counting the numbers of reads and writes. If the reads and writes are complete you can trigger an event which is waited on in the driver and you can continue with your writes to RAM1

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 20, 2019, 3:21am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/10 "2019-05-20T03:21:19Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/9):_

1.yws. 800 sequences have different address and data for RAM1(writing into all the locations)  
2. Yes, control module is a verilog module. I am sending two sequences which would ensure a pulse of trigger(high and low). This value will be set to zero in above 800 sequences.

What you have suggested matches to option 2 of above list. I think I have access to signals of control module through interface. Does the bind you mentioned is similar to bind used in assertions?  
Thank you, will look into it.

---

<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:** [May 20, 2019, 6:29am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/11 "2019-05-20T06:29:10Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/10):_

SystemVerilog has only 1 bind construct. You can use it to observe signals in your DUT and also drive signals if the DUT is written in SV. Binding assertions to your DUT is one application.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 20, 2019, 8:24pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/12 "2019-05-20T20:24:06Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/11):_

Thank you chr\_sue.  
I was exploring uvm\_events and came across a post with your reply(in this forum):

```verilog
class driver1 extends uvm_driver #(my_tx);
uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
//...
task run_phase(uvm_phase phase);
uvm_event ev = ev_pool.get("driver1_ev");
ev.trigger(req);

endtask
//...
endclass

class driver2 extends uvm_driver #(my_tx);
uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
//...
task run_phase(uvm_phase phase);
uvm_event ev = ev_pool.get("driver1_ev");
ev.wait_trigger();
$cast(req, ev.get_trigger_data()); 
//...
endtask 
//...
endclass 

```

In driver1, I see:  
ev.trigger(req);  
But i dont see #type mentioned while declaring uvm\_event ev. Isn’t it required? It takes any data type?  
On driver2, I see:  
$cast(req, ev.get\_trigger\_data());  
req will hold the data from driver1, right?

And one more thing, with event\_pool, we can access the events in any component including sequence, right?

---

<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:** [May 21, 2019, 5:44am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/13 "2019-05-21T05:44:58Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/12):_

The uvm\_event\_pool is a construct useful for horizontal synchronization between different agents. If you are in the same agent you can simply use uvm\_event.  
With respect to your questions.

```verilog
ev.trigger(req);

```

accepts as argument any uvm\_object, like a seq\_item because it is extended from uvm\_object.

```verilog
ev.wait_trigger();
$cast(req, ev.get_trigger_data());

```

get\_trigger returns an object of uvm\_object and we have to cast this to our seq\_item type.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 22, 2019, 4:01am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/14 "2019-05-22T04:01:05Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/13):_

Thank you so much!  
I will remove global\_pool for events. My understanding is that, we can use global-pool within same agent but it’s unnecessarily gets complicated.

I can use uvm\_config\_db to set(in driver)/get(in other modules) the event, right? Any other method recommended?

Thanks again

---

<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:** [May 22, 2019, 6:44am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/15 "2019-05-22T06:44:35Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/14):_

Yes you can pass the event to the config\_db and retrieve in another component. Or you are adding the vent to your virtual interface. Then you can simply trigger like a clock.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 22, 2019, 4:50pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/16 "2019-05-22T16:50:56Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/15):_

Thank you!  
Sorry, didn’t get the second part.  
“Or you are adding the vent to your virtual interface. Then you can simply trigger like a clock.”

Any link to understand it better would be helpful. I have already implemented using configDb. But just wanted to know about the other option too.

---

<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:** [May 23, 2019, 6:01am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/17 "2019-05-23T06:01:56Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/16):_

You can add to your SV interface which makes the connection between the DUT and the UVM environment an additional signal of type uvm\_event. This will be triggered somewhere in a driver and caan be seen in the monitor for instance.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 23, 2019, 10:56pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/18 "2019-05-23T22:56:02Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/17):_

Thanks Chris,  
I could almost achieve what i wanted. Will keep the above option in my mind.

I have 2 questions, which i came across with this TB:(Please let me know if i need to raise these questions separately in the forum)

1. In sequence, I was trying to wait for uvm\_event(triggered in driver). But got a loading error for configdb check line. I removed it and added few extra sequences to take care of it. Can’t we use uvm\_event in sequence?

```verilog
class grp_ctrl_sequence extends uvm_sequence#(grp_ctrl_seq_item);
  grp_ctrl_seq_item req;
  uvm_event DELAY_DONE;
  virtual task body;
   //got a loading error for below
    if(!uvm_config_db#(uvm_event)::get(this, "", "driver_event", DELAY_DONE))
      `uvm_fatal("NO_UVM_EVENT",{"uvm event must be set for: ",get_full_name(),".driver_event"}); 
   :
   :
     // DELAY_DONE.wait_trigger();
   :
   :
 endtask
endclass

```

1. There are multiple instances of below RAM in my design. read\_addr input is provided by the TB with clocking block. So it has input skew. I did check the waveform to confirm the same. But the strange thing is, rd\_data is available in the same clock(i.e. it behaves as if there is no input skew). Below is the code. Any idea, why does it behave so?

```verilog
module RAM #(
    parameter DATA = 16,
    parameter ADDR = 4
) (
    input logic clk, 
    // Write Port
    input logic wr,
    input logic [ADDR-1:0] wr_addr,
    input logic [DATA-1:0] wr_data, 
    // Read Port
    input logic [ADDR-1:0] rd_addr,
    output logic [DATA-1:0] rd_data
); 
    // Shared memory
    logic [DATA-1:0] mem [(2**ADDR)-1:0];
    initial begin 
        for (int i = 0; i < 2**ADDR; i++) begin
            mem[i] = '0;
        end
    end     
    // Write Port
    always @(posedge clk)
        if(wr)
            mem[wr_addr] <= wr_data;     
    // Read Port
    logic [ADDR-1:0] rd_addr_reg;
    always @(posedge clk)
        rd_addr_reg <= rd_addr;
     
    assign rd_data = mem[rd_addr_reg]; 
endmodule

```

---

<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:** [May 24, 2019, 6:18am UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/19 "2019-05-24T06:18:09Z")

</div>

_In reply to [uvmsd](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/18):_

There is limitation regarding the usage of the uvm\_event. The problem with the uvm\_event in the sequence is you do not know when the get is issued. Looks like you do in the sequence the get to the config\_db before the set was done.  
With respect to the uvm\_components this does not happen because the run\_phases are executed in parallel.

If you need the trigger in the sequence the event\_pool is recommended.

With respect to your DUT model. It works as you have described. The read data are available in the same clock cycle where you pass the addr.  
If you want to see the read data later you have to insert an additional clock edge.

---

<div class="post-metadata">

**Author:** ![uvmsd](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/u/b9bd4f/32.png) [@uvmsd](https://verificationacademy.com/forums/u/uvmsd)\
**Post date:** [May 24, 2019, 7:25pm UTC](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/20 "2019-05-24T19:25:49Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/best-way-to-introduce-delay-between-sequences/36096/19):_

Thank you Chris!  
Right now, I don’t really need event trigger in sequence.

Yes,you are right about DUT(RAM)behavior. TB should handle it that way when input(with respect to RTL) skew is non-zero.  
Thank you!
