# Why the body of sequence is running for one time, even if the repeat statement is used in it?

**URL:** <https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266>\
**Category:** UVM\
**Tags:** UVM, assertstdrandomizevariable, sequence-body\
**Created:** [September 15, 2016, 12:53pm UTC](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266 "2016-09-15T12:53:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swatisatpathy10](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@swatisatpathy10](https://verificationacademy.com/forums/u/swatisatpathy10)\
**Post date:** [September 15, 2016, 12:53pm UTC](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/1 "2016-09-15T12:53:20Z")

</div>

/ **/body of transaction**

```verilog
class adder_transaction extends uvm_sequence_item;
  rand bit [3:0]a0;
  rand bit [3:0]b0;
  rand bit doAdd0;
  bit [3:0]result0;

	`uvm_object_utils(adder_transaction)

  function new(string name = "");
		super.new(name);
	endfunction
  
  constraint c{a0 inside {[1:15]};b0 inside {[1:15]};}
endclass

```

/ **/body of sequence**

```verilog
class adder_sequence extends uvm_sequence#(adder_transaction);
     `uvm_object_utils(adder_sequence)

     function new(string name = "");
          super.new(name);
     endfunction: new
 
    task body();
      $display("body of sequence");
      repeat(15)
      begin
        
            sa_tx = adder_transaction::type_id::create("sa_tx");
               start_item(sa_tx);
                    assert(sa_tx.randomize());
               finish_item(sa_tx);
      end
     endtask: body
         
       endclass

```

---

<div class="post-metadata">

**Author:** ![mayurkubavat](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/a9a28c/32.png) [@mayurkubavat](https://verificationacademy.com/forums/u/mayurkubavat)\
**Post date:** [September 15, 2016, 1:24pm UTC](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/2 "2016-09-15T13:24:46Z")

</div>

_In reply to [swatisatpathy10](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266):_

Code looks good. Are you running any other sequence in parallel? Add display in loop, probably after finish\_item() and check the output.

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [September 15, 2016, 9:33pm UTC](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/3 "2016-09-15T21:33:51Z")

</div>

_In reply to [swatisatpathy10](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/2):_

Don’t use assert() when randomizing a transaction. Use an ‘if’ statement to determine if the randomization() call failed.

Are you calling raise\_objection() and drop\_objection() in your test? If the objections aren’t handled correctly, the test sequences will end prematurely.

---

<div class="post-metadata">

**Author:** ![swatisatpathy10](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@swatisatpathy10](https://verificationacademy.com/forums/u/swatisatpathy10)\
**Post date:** [September 30, 2016, 7:15am UTC](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/4 "2016-09-30T07:15:05Z")

</div>

_In reply to [MayurKubavat](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/3):_

thank you for your reply.

I found the error. actually there was connection problem in my code, in agent block, so the code was not running.

---

<div class="post-metadata">

**Author:** ![swatisatpathy10](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@swatisatpathy10](https://verificationacademy.com/forums/u/swatisatpathy10)\
**Post date:** [September 30, 2016, 7:15am UTC](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/5 "2016-09-30T07:15:59Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/why-the-body-of-sequence-is-running-for-one-time-even-if-the-repeat-statement-is-used-in-it/32266/4):_

Thank you very much for your reply
