# Raise Objection Syntax

**URL:** <https://verificationacademy.com/forums/t/raise-objection-syntax/32723>\
**Category:** UVM\
**Tags:** objection-syntax, UVM, illegal-declaration, SystemVerilog-Syntax\
**Created:** [January 4, 2017, 11:29am UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723 "2017-01-04T11:29:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![enbiya.h](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/a698b9/32.png) [@enbiya.h](https://verificationacademy.com/forums/u/enbiya.h)\
**Post date:** [January 4, 2017, 11:29am UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/1 "2017-01-04T11:29:54Z")

</div>

Hi everyone,

I’m trying to build a dummy uvm enviroment. I’ve got an compilation error which I actually solved but I don’t know the reason . What I recognized is that i can not write anything before the create statement.

In the run\_phase of my dummy test I want to raise an objection, create a sequence, start the sequence and drop the objection.

Below is run\_phase method which can be compiled without errors.

```verilog

task dummy_test::run_phase(uvm_phase phase);
  abc_sequence abc = abc_sequence::type_id::create("abc");
  phase.raise_objection (this, "dummy_test");
  abc.start(m_env.m_v_sequencer.abc_sequencer_t);
  #100ns;
  phase.drop_objection(this , "dummy_test");
endtask : run_phase 

```

Below is run\_phase method which can’t be compiled due to Illegal declaration error.  
Error message;  
_dummy\_test.sv(25): Illegal declaration after the statement near line ‘23’. Declarations must be precede statements. Look for stray semicolons._  
Line 25 is the sequence start line  
Line 23 is the raise objection line

```verilog

task dummy_test::run_phase(uvm_phase phase);
  phase.raise_objection (this, "dummy_test");
  abc_sequence abc = abc_sequence::type_id::create("abc");
  abc.start(m_env.m_v_sequencer.abc_sequencer_t);
  #100ns;
  phase.drop_objection(this , "dummy_test");
endtask : run_phase 

```

What am I missing and what shouldn’t I do ?

---

<div class="post-metadata">

**Author:** ![frodus](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@frodus](https://verificationacademy.com/forums/u/frodus)\
**Post date:** [January 4, 2017, 11:55am UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/2 "2017-01-04T11:55:09Z")

</div>

_In reply to [enbiya.h](https://verificationacademy.com/forums/t/raise-objection-syntax/32723):_

Hi,

in system verilog it is not allowed to declare variables after a command.

In verilog a task was defined like this:

task a();  
reg i = 0;  
begin  
call\_to\_function();  
endtask;

In system verilog it is allowed to leave the begin out but you still have to follow the  
order.

I hope this helps bye

---

<div class="post-metadata">

**Author:** ![enbiya.h](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/a698b9/32.png) [@enbiya.h](https://verificationacademy.com/forums/u/enbiya.h)\
**Post date:** [January 4, 2017, 12:09pm UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/3 "2017-01-04T12:09:22Z")

</div>

_In reply to [frodus](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/2):_

> _In reply to [enbiya.h](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/2):_  
> Hi,  
> in system verilog it is not allowed to declare variables after a command.  
> In verilog a task was defined like this:  
> task a();  
> reg i = 0;  
> begin  
> call\_to\_function();  
> endtask;  
> In system verilog it is allowed to leave the begin out but you still have to follow the  
> order.  
> I hope this helps bye

Thank you.  
By building the enviroment I was referring to the cookbook examples. In the Block Level Testbench example we can see the blow given run phase method in spi\_test.

```verilog

task spi_test::run_phase(uvm_phase phase);
  phase.raise_objection(this, "spi_test");
  check_regs_seq reset_test_seq = check_regs_seq::type_id::create("rest_test_seq");
  send_spi_char_seq spi_char_seq = send_spi_char_seq::type_id::create("spi_char_seq");

  reset_test_seq.start(m_env.m_v_sqr.apb);
  spi_char_seq.start(m_env.m_v_sqr.apb);
  #100ns;
  phase.drop_objection(this, "spi_test");
endtask: run_phase

```

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [January 4, 2017, 5:58pm UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/4 "2017-01-04T17:58:26Z")

</div>

_In reply to [enbiya.h](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/3):_  
That code snippit is not legal - within any procedural block of code, all declarations must precede any statements. If you can post a link to where you saw this, I can try to get it fixed,

---

<div class="post-metadata">

**Author:** ![enbiya.h](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/e/a698b9/32.png) [@enbiya.h](https://verificationacademy.com/forums/u/enbiya.h)\
**Post date:** [January 5, 2017, 7:13am UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/5 "2017-01-05T07:13:38Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/4):_

> _In reply to [enbiya.h](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/4):_  
> That code snippit is not legal - within any procedural block of code, all declarations must precede any statements. If you can post a link to where you saw this, I can try to get it fixed,

Hi Dave,  
I saw it on the example _“Complete block level testbench example for a simple SPI DUT”_. Below is the download link for the example and the path for the code snippet.

Block Level Testbench - Complete block level testbench example for a simple SPI DUT.  
[Download link block level testbench example](https://verificationacademy.com/cookbook/download?file=/w/images/7/7c/Uvm_Tb_build_bl_tb.tgz)

…\tb\_build\block\_level\_tbs\spi\_tb\test\spi\_test.svh Line:50

---

<div class="post-metadata">

**Author:** ![aishwaryah](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aishwaryah](https://verificationacademy.com/forums/u/aishwaryah)\
**Post date:** [January 6, 2017, 8:12am UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/6 "2017-01-06T08:12:16Z")

</div>

_In reply to [enbiya.h](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/5):_

Hi,  
If you only requirement is to create the sequence after raising an objection, you can spilt the declaration and creation of the sequence.  
For eg.  
task dummy\_test::run\_phase(uvm\_phase phase);  
abc\_sequence abc; ==================================\> Sequence declared  
phase.raise\_objection (this, “dummy\_test”);  
abc = abc\_sequence::type\_id::create(“abc”); =========\> Sequence created  
abc.start(m\_env.m\_v\_sequencer.abc\_sequencer\_t);  
#100ns;  
phase.drop\_objection(this , “dummy\_test”);  
endtask : run\_phase

Hope this helps.

---

<div class="post-metadata">

**Author:** ![aishwaryah](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@aishwaryah](https://verificationacademy.com/forums/u/aishwaryah)\
**Post date:** [January 6, 2017, 8:12am UTC](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/7 "2017-01-06T08:12:19Z")

</div>

_In reply to [enbiya.h](https://verificationacademy.com/forums/t/raise-objection-syntax/32723/6):_

Hi,  
If your only requirement is to create the sequence after raising an objection, you can spilt the declaration and creation of the sequence.  
For eg.  
task dummy\_test::run\_phase(uvm\_phase phase);  
abc\_sequence abc; ==================================\> Sequence declared  
phase.raise\_objection (this, “dummy\_test”);  
abc = abc\_sequence::type\_id::create(“abc”); =========\> Sequence created  
abc.start(m\_env.m\_v\_sequencer.abc\_sequencer\_t);  
#100ns;  
phase.drop\_objection(this , “dummy\_test”);  
endtask : run\_phase

Hope this helps.
