-2

This is my code, and I get this compile error:

ERROR :near "initial": syntax error, unexpected initial

How do I fix this error?

module pract_wildcardequality();

logic [3:0] a,b;

function void wildcradd(a,b);
begin
if(a==?b)
$monitor ("a %d",a==?b);
else 
$monitor ("a else %d",a==?b);
end

initial begin
wildcardd(4'b010x,
4'b0101);
end
//end
endmodule
toolic
  • 57,801
  • 17
  • 75
  • 117

1 Answers1

1

You need to close a function using the endfunction keyword. This is similar to the endmodule keyword.

I also fixed a typo which caused another compile error: I changed your function call from wildcardd to wildcradd. I'm not sure which name you want, but they must match.

module pract_wildcardequality();

logic [3:0] a,b;

function void wildcradd(a,b);
begin
    if(a==?b)
    $monitor ("a %d",a==?b);
    else 
    $monitor ("a else %d",a==?b);
end
endfunction

initial begin
    wildcradd(4'b010x,
    4'b0101);
end
endmodule
toolic
  • 57,801
  • 17
  • 75
  • 117