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

"end" not indented correctly after replication with variable number #1237

Closed
veripoolbot opened this issue Oct 18, 2017 · 5 comments
Closed
Labels

Comments

@veripoolbot
Copy link
Collaborator


Author Name: David Rogoff
Original Redmine Issue: 1237 from https://www.veripool.org

Original Assignee: Alex Reed


I've been hitting this a long time but am finally reporting it. If I use a variable for the replication count, the following line doesn't indent correctly. Here's an example with the correct indentation and 2 examples of bad indentation.

module test;

    initial begin
       string in_str;

       if (in_str == "") begin : empty_string
	 a_string = { 5 {" "}};  // all spaces
       end // block: empty_string
    end // initial begin
    

    initial begin
       string in_str;
       int    width = 5;

       if (in_str == "") begin : empty_string
	 a_string = { width {" "}};  // all spaces
    end // block: empty_string
    end // initial begin
    

    function string a_string (string in_str);
       
       if (in_str == "") begin : empty_string
	 a_string = { width {" "}};  // all spaces
    end // block: empty_string
       
endmodule // test

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2017-10-18T20:55:11Z


I think it's getting mistaken for a constraint. Might you be able to try a fix? Here's another

module test_dummy_concat;

    always @(posedge clk or posedge reset)
      begin
         if (reset)
           begin
              counter <= {COUNTERBITS{1'b0}};
         out1 <= 1'b0;
         out2 <= 1'b0;
      end
    end
endmodule

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: David Rogoff
Original Date: 2017-10-18T21:00:57Z


Wilson Snyder wrote:

I think it's getting mistaken for a constraint. Might you be able to try a fix? Here's another

[...]

My elisp isn't nearly up for this!

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Alex Reed
Original Date: 2017-11-13T20:59:42Z


This commit fixes the test-case.

commit 377003e15853bb921c6e4717f8a517f8ebbce8b4
Author: Alex Reed <alex.reed@broadcom.com>
Date:   Mon Nov 13 14:49:09 2017

     Improve indention of begin/end near nested braces
     
     * verilog-mode (verilog-at-constraint-p):  begin/end are illegal inside
       constraint blocks, so use that knowledge to make smarter indentation
       decisions.


I'm not particularly happy with some of the code in this area. The function @verilog-at-constraint-p@ is pretty precarious (really, all of the constraint detection code is difficult, and it spans most of the indent code). I find that it's very easy to get stuck in infinite loops with minor changes in this area. I also notice a pretty deep/expensive code path that's called 2x per indentation, and certain portions are called increasingly more often as the number of @{}@ pairs increases in a statement. Something is awry, but more investigation will have to wait for another day...

@lyuzhaodi
Copy link

lyuzhaodi commented Oct 20, 2020

yes, it still exists some issues in @verilog-at-constraint-p like this: @veripoolbot
counter <= {COUNTERBITS-1{1'b0}};
or:
counter <= {COUNTERBITS*2{1'b0}};
or
counter <= {COUNTERBITS/2{1'b0}};

@lyuzhaodi
Copy link

yes, it still exists some issues in @verilog-at-constraint-p like this: @veripoolbot
counter <= {COUNTERBITS-1{1'b0}};
or:
counter <= {COUNTERBITS*2{1'b0}};
or
counter <= {COUNTERBITS/2{1'b0}};

@wsnyder

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