Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clocking drive with macro generates incorrect syntax error #1

Closed
rekendahl opened this issue Jun 28, 2018 · 2 comments
Closed

Clocking drive with macro generates incorrect syntax error #1

rekendahl opened this issue Jun 28, 2018 · 2 comments
Assignees
Labels

Comments

@rekendahl
Copy link

The following code generates an error at the ';' of line 13 where it shouldn't.
The error message in the comment marked with //^ on line 14.

Notice: Line 11 (with #100) works while the one with a macro definition fails.

`define TCQ 100

module issue;
    always @(posedge clk) begin

        if (a == 1'b1) begin
            diff_pntr         <= 0;
        end else begin
            if (wr_en)
                diff_pntr <= #100 (wr_pntr - adj_rd_pntr_wr + 2'h1);  // **WORKS!**
            else if (wr_en)
                diff_pntr <= #`TCQ (wr_pntr - adj_rd_pntr_wr);
                //^ <expression> expected, got ';'
        end
    end
endmodule
@EdaphicStudio EdaphicStudio self-assigned this Jun 28, 2018
@EdaphicStudio
Copy link
Owner

Thank you for filling the issue. We can reproduce the error on our end. Will try to resolve in next release.

@EdaphicStudio
Copy link
Owner

Interesting test case. The logic for resolving macros blindly took any ( as the start of macro arguments even when the define had no actual arguments. Which meant that in the following code everything inside the parenthesis was passed to the macro and then simply dropped resulting in bad code.

diff_pntr <= #`TCQ (wr_pntr - adj_rd_pntr_wr);

The short-term solution, which will be available in beta 4, is to look up if a macro needs arguments and only then look for a (

The medium-term solution is to error-check that the number of arguments used by a macro matches the expected number from the define and flag errors as appropriate. Today the plug-in assumes you pass it the correct amount of arguments and doesn't flag errors for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants