veripool / verilog-mode

Verilog-Mode for Emacs with Indentation, Hightlighting and AUTOs. Master repository for pushing to GNU, verilog.com and veripool.org.
http://veripool.org/verilog-mode
GNU General Public License v3.0
247 stars 90 forks source link

Fix bug in verilog-in-generate-region-p #1815

Closed gmlarumbe closed 1 year ago

gmlarumbe commented 1 year ago

Hi,

This PR fixes a bug in the function verilog-in-generate-region-p.

module foo;

    some_if my_if;

    // If point is here, `verilog-in-generate-region-p' returns t:
    //  - Wrongly detects the if of the interface type as if it was a
    //    keyword due to regexp word boundaries not set properly

    generate begin : test_gen
        if (CONDITION == "TRUE") begin

            always @(posedge Clk) begin
                if (!Rst_n) begin
                    signal <= 0;
                end else begin
                    signal <= 1;
                end
            end

        end else if (CONDITION == "FALSE") begin

            always @(posedge Clk) begin
                if (!Rst_n) begin
                    signal <= 0;
                end else begin
                    signal <= 2;
                end
            end

        end else begin

            always @(posedge Clk) begin
                if (!Rst_n) begin
                    signal <= 0;
                end else begin
                    signal <= 3;
                end
            end

        end
    end : test_gen

    endgenerate

    // If point is here, `verilog-in-generate-region-p' returns t:
    //  - Wrongly detects the if of always blocks as if they were part
    //    of the 'generate if' condition

endmodule

It includes two commits:

Thanks!