# Can't functions call other functions?

**URL:** <https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, functions, tasks\
**Created:** [February 8, 2020, 4:25am UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154 "2020-02-08T04:25:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SparkyNZ](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/sparkynz/32/3819_2.png) [@SparkyNZ](https://verificationacademy.com/forums/u/SparkyNZ)\
**Post date:** [February 8, 2020, 4:25am UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/1 "2020-02-08T04:25:34Z")

</div>

I’m getting the error “functions can’t enable tasks”. Why am I getting this error when I’m not using tasks (as far as I know) ?

I’m trying to improve the readability of my code by splitting it up into functions - and I will want to add other code in the **always\_ff** block.

The compiler doesn’t like this:

```verilog
function void HandleRxIdle;
endfunction

function void HandleReceiveStates;
  unique case( rxState )
    RX_IDLE : HandleRxIdle();
  endcase
endfunction

always_ff @( posedge clk )
begin
  HandleReceiveStates();
end

```

But it doesn’t complain if I do this:

```verilog
function void HandleRxIdle;
endfunction

always_ff @( posedge clk )
begin
  unique case( rxState )
    RX_IDLE : HandleRxIdle();
  endcase
end

```

What is the problem here?

---

<div class="post-metadata">

**Author:** ![sbellock](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/f4b2a3/32.png) [@sbellock](https://verificationacademy.com/forums/u/sbellock)\
**Post date:** [February 8, 2020, 5:34pm UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/2 "2020-02-08T17:34:43Z")

</div>

What happens if you change

```verilog
HandleReceiveStates;

```

to

```auto
HandleReceiveStates();

```

?

---

<div class="post-metadata">

**Author:** ![SparkyNZ](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/sparkynz/32/3819_2.png) [@SparkyNZ](https://verificationacademy.com/forums/u/SparkyNZ)\
**Post date:** [February 8, 2020, 6:57pm UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/3 "2020-02-08T18:57:51Z")

</div>

_In reply to [sbellock](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/2):_

Same thing I’m afraid. I even tried putting empty brackets on the function definition itself but that made no difference either.

```verilog
function void Oranges();
endfunction

function void Apples();
  Oranges();
endfunction

```

Same deal above. I added these to remove any dependency on my **always\_ff()** block.

---

<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:** [February 8, 2020, 9:05pm UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/4 "2020-02-08T21:05:39Z")

</div>

_In reply to [SparkyNZ](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/3):_  
It would help if you learn how to post a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Maybe the problem is somewhere else. This code below ran on 4 different tools:

```verilog
module top;
  bit clk,rxState;
  localparam RX_IDLE = 0;
  
  function void HandleRxIdle;
endfunction
 
function void HandleReceiveStates;
  unique case( rxState )
    RX_IDLE : HandleRxIdle();
  endcase
endfunction
 
always_ff @( posedge clk )
begin
  HandleReceiveStates();
end
  
initial begin
  #5 clk =1;
  #5 $finish;
end
endmodule

```

---

<div class="post-metadata">

**Author:** ![SparkyNZ](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/sparkynz/32/3819_2.png) [@SparkyNZ](https://verificationacademy.com/forums/u/SparkyNZ)\
**Post date:** [February 9, 2020, 1:35am UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/5 "2020-02-09T01:35:24Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/4):_

> _In reply to [SparkyNZ](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/4):_  
> It would help if you learn how to post a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Maybe the problem is somewhere else. This code below ran on 4 different tools:

Apologies for not providing a complete module file. If your example module works on 4 different tools then I guess it is a problem/feature specific to Quartus II.

As you can see below, we get the same problem:

 ![](https://verificationacademy.com/forums/uploads/default/original/1X/9a7421cfed9378c9bf346bb53b71f008cc47d70c.png)

---

<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:** [February 9, 2020, 2:43am UTC](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/6 "2020-02-09T02:43:39Z")

</div>

_In reply to [SparkyNZ](https://verificationacademy.com/forums/t/cant-functions-call-other-functions/37154/5):_

Yes, this is a tool bug. I’m guessing it doesn’t like functions calling void functions.
