# Syntax error in a code block

**URL:** <https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973>\
**Category:** UVM\
**Tags:** UVM, SystemVerilog, syntax-error\
**Created:** [August 19, 2020, 7:15pm UTC](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973 "2020-08-19T19:15:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![khaledismail](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/2acd7d/32.png) [@khaledismail](https://verificationacademy.com/forums/u/khaledismail)\
**Post date:** [August 19, 2020, 7:15pm UTC](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973/1 "2020-08-19T19:15:11Z")

</div>

I have the following code block where a syntax error is fired:

```verilog

  virtual task body();
     forever begin
	my_transaction m_req;
	// Blocking wait for a transaction request:
	p_sequencer.m_request_fifo.get(m_req);
	// Generate response based on "req_kind" value:
	if ( m_req.req_kind == REQ ) begin
	   `uvm_do_with(req, {req_kind == REQ;} )
	end
	else begin
	   `uvm_do_with(req, {req_kind == NO_REQ;} )	   
	end
     end
  endtask

```

I get the following error message:

```verilog

Error-[SE] Syntax error
  Following verilog source has syntax error :
  "./src/my_transaction.sv", 77: token is ')'
  	if ( m_req.req_kind == REQ ) begin
                                      ^

```

If I comment the if and else lines as follows, this code block compiles normally:

```verilog

  virtual task body();
     forever begin
	my_transaction m_req;
	// Blocking wait for a transaction request:
	p_sequencer.m_request_fifo.get(m_req);
	// Generate response based on "req_kind" value:
	//if ( m_req.req_kind == REQ ) begin
	   `uvm_do_with(req, {req_kind == REQ;} )
	//end
	//else begin
	   `uvm_do_with(req, {req_kind == NO_REQ;} )	   
	//end
     end
  endtask

```

I tried commenting this line

```verilog
my_transaction m_req;

```

as well and expected an error to fire up due to undefined

```verilog
m_req

```

identifier. But the code actually compiles!

What can possibly be the issue?

---

<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 19, 2020, 7:57pm UTC](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973/2 "2020-08-19T19:57:03Z")

</div>

_In reply to [khaledismail](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973):_

You are doing very specific things:

```verilog
p_sequencer.m_request_fifo.get(m_req);

```

Which kind of code is this? The driver is performing the get.  
Could you please show the declaration of req\_kind?

---

<div class="post-metadata">

**Author:** ![khaledismail](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/2acd7d/32.png) [@khaledismail](https://verificationacademy.com/forums/u/khaledismail)\
**Post date:** [August 19, 2020, 8:14pm UTC](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973/3 "2020-08-19T20:14:43Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973/2):_

The definition of req\_kind is:

```verilog

class my_transaction extends uvm_sequence_item;
   typedef enum {REQ, NO_REQ} req_kind_e;
   rand req_kind_e req_kind;
...
...
...

```

and the class my\_transaction is type forwarded in the file where the compilation error is present:

```verilog
typedef class my_transaction;

```

The code block in question is a sequence in a sequence library where m\_request\_fifo is the port used in the slave sequencer to retrieve the sequence.

---

<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 20, 2020, 6:14am UTC](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973/4 "2020-08-20T06:14:54Z")

</div>

_In reply to [khaledismail](https://verificationacademy.com/forums/t/syntax-error-in-a-code-block/37973/3):_

Even with this information it is hard to give you an advice. But your approach should be re-archtiected.  
Dealing with master/slave scenarios is shown in the code examples of the Verification Academy:  
[https://verificationacademy.com/cookbook/code-examples](https://verificationacademy.com/cookbook/code-examples)  
Search for ‘Slave Agent Examples’.
