cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
inflector
Observer
Observer
836 Views
Registered: ‎08-29-2017

Bad Error gives wrong file and line number for missing "endmodule"

I encountered a bad error message that made it hard to determine where the error actually occurred. Here's a simple way to reproduce:

 

formula.v:

 

module formula(

    input wire clock,

    input wire[15:0] a,

    input wire[15:0] b,

    output wire[31:0] result

)

 

    result <= a + (b * 3);

endmodule

 

not_formula.v:

module not_formula(

    input wire clock,

    input wire[15:0] base,

    input wire[15:0] level,

    output wire[31:0] result

)

    reg[31:0] formula_result;

    formula formula_1(clock, base, level, formula_result);

    result <= ~formula_result;

endmodule

 

test_formula.v

 

`timescale 1ns / 1ps

module test_formula;

reg clock;
reg[15:0] base;
reg[15:0] level;
reg[31:0] result;

not_formula uut (
    .clock(clock),
    .base(base),
    .level(level),
    .result(result)
);

initial begin
    clock = 0;
    forever begin
        clock = #5 ~clock;
    end
end

initial begin

    base = 15'h0ffe;
    level = 15'h0c;

    #10
    $display("not_formula for %h, %h is %h", base, level, result);

    $finish;

endmodule

 

The above should give no errors (assuming I typed it correctly). But, if you remove the endmodule statement from the file formula.v like:

formula.v:

 

module formula(

    input wire clock,

    input wire[15:0] a,

    input wire[15:0] b,

    output wire[31:0] result

)

 

    result <= a + (b * 3);



during simulation you will get an error "unexpected EOF" showing the line number at the outer test file test_formula.v and not the correct file where the problem exists: formula.v

This can be difficult to understand if you don't have a background writing compilers. Especially if there are three or four layers of nesting and you edited five or six files in the process of making a change when you inadvertently deleted an endmodule statement.

Vivado should check for a matching endmodule at the end of parsing the file in which the module was defined.

 

(NOTE: I just typed in the above to show a simpler way of reproducing this problem. I have not created a project to test this specific example. If you can't reproduce this issue, let me know and I can send a project I saved with much more complex code that exhibits this misleading error message.)

 



 

 

 

 

0 Kudos
1 Reply
bandi
Moderator
Moderator
738 Views
Registered: ‎09-15-2016

Hi @inflector,

 

>>As you mentioned that during simulation we will get an error "unexpected EOF" showing the line number at the outer test file test_formula.v and not the correct file where the problem exists: formula.v

 

I tried creating a test case at my end in vivado 2017.3 but i was not able to reproduce the issue. Can you please let me know which version of vivado are you using?

 

As with vivado 2017.3 while i removed the endmodule statement in formula.v file and ran simulation i didnot come across any error and i see few critical warnings in the message column pointing to the exact line in formula.v as shown in below screen shot.

 

endmodule.JPG

Hence, can you please share the archived project and please let me know if i am missing anything to reproduce the issue at my end.

 

Thanks & Regards,

Sravanthi B

Thanks & Regards,
Sravanthi B
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos