cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
eml
Explorer
Explorer
397 Views
Registered: ‎03-31-2017

xvlog bug

Jump to solution

The code below fails to compile on Vivado 2020.2, with "[VRFC 10-732] function/task declaration not allowed inside generate loop".

It compiles Ok with Xcelium, Questa, Riviera-PRO, and Icarus. With VCS, it compiles with the '-sverilog' switch, but fails when compiled as Verilog ("Function/Task 'user_code' cannot be declared inside a 'generate for' loop").

The 2005 LRM is clear that function and task declarations are allowed in a for-generate:

loop_generate_construct ::=
  for ( genvar_initialization ; genvar_expression ; genvar_iteration )
    generate_block

generate_block ::=
  module_or_generate_item | ...

module_or_generate_item ::=
  { attribute_instance } module_or_generate_item_declaration | ...

module_or_generate_item_declaration ::=
  ...
  | task_declaration
  | function_declaration

Additionally, 12.4 states that

"A generate block may not contain port declarations, parameter declarations, specify blocks, or specparam declarations. All other module items, including other generate constructs, are allowed in a generate block."

12.1.3 in the 2001 LRM stated that "Tasks and functions declarations shall also be permitted within the generate scope, however not in a generate loop". This was inconsistent with the productions, and was corrected in the 2005 LRM.


module test1();
   genvar instA;

   generate
      for(instA=0; instA<2; instA=instA+1) begin : A
         task user_code(inout integer r1);
           r1 = r1 + 1;
         endtask
      end
   endgenerate
endmodule

 

0 Kudos
1 Solution

Accepted Solutions
miti
Xilinx Employee
Xilinx Employee
378 Views
Registered: ‎06-10-2020

Hi @eml ,

I will create change request for this issue, so verilog parser will not flag the error. 

 As workaround please use "-sv" along with xvlog command.

-------------------------------------------------------------------------
Don't forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
miti
Xilinx Employee
Xilinx Employee
379 Views
Registered: ‎06-10-2020

Hi @eml ,

I will create change request for this issue, so verilog parser will not flag the error. 

 As workaround please use "-sv" along with xvlog command.

-------------------------------------------------------------------------
Don't forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------

View solution in original post

0 Kudos