Is it illegal to use an (enum) as a function input?

OP #6380851
I'm still very much interested in finding out whether or not it's 
possible for a Verilog function to have a boolean value as input, but 
while I was waiting for input on that I decided to rewrite a version of 
my Verilog code to use an (enum) instead of a (boolean). Much to my 
amazement, it appears that I can't use an (enum) as an input to a 
function either! I wrote the following code:
1
module useBin ();
2

3
typedef enum { ADD, MULTIPLY } binOp;
4

5
function integer execOp;
6
    input integer left;
7
    input integer right;
8
    input   binOp op;
9
  begin
10
    execOp = op == ADD ? left + right : left * right;
11
  end
12
endfunction
13

14
endmodule
When I ran Icarus to simulate it I got:
1
D:\Hf\Verilog\Unpacked\Common>ive useBin
2
\Icarus\bin\iverilog -g2009 -o useBin.out useBin.sv
3
useBin.sv:8: syntax error
4
useBin.sv:5: error: Syntax error defining function.
5

6
D:\Hf\Verilog\Unpacked\Common>
I can kind of understand why a (boolean) might cause a problem when used 
as a function input, but why in the world would it be illegal to use an 
(enum) like my (binOp) as a function input?

Reply

A question of your own? This thread is over 6 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.