chipsalliance / verible

Verible is a suite of SystemVerilog developer tools, including a parser, style-linter, formatter and language server
https://chipsalliance.github.io/verible/
Other
1.33k stars 202 forks source link

Long `localparam` lines are not formatted #2156

Open goekce opened 5 months ago

goekce commented 5 months ago

Test case

module aman;
  localparam int unsigned DigitCountLg2 = 2,
DigitCount = 2 ** DigitCountLg2,
AVeryLongLineAndInformationAndIdontKnowWhatToWrite = 4;
endmodule

version: 3624 d256d779

Actual output

Same. If the long line is removed, the line is formatted to a single line though.

$ verible-verilog-format --show_token_partition_tree ...

Full token partition tree:
{ ([<auto>], policy: always-expand) @{}
  { ([<auto>], policy: always-expand) @{0}, (origin: "module aman...;
endmodule")
    { ([module aman ;], policy: fit-else-expand, (origin: "module aman;")) }
    { (>>[localparam int unsigned DigitCountLg2 = 2 , DigitCount = 2 ** DigitCountLg2 , AVeryLongLineAndInformationAndIdontKnowWhatToWrite = 4 ;], policy: fit-else-expand, (origin: "localparam ...oWrite = 4;")) }
    { ([endmodule], policy: always-expand, (origin: "endmodule")) }
  }
}

Expected or suggested output

module aman;
  localparam int unsigned
    DigitCountLg2 = 2,
    DigitCount = 2 ** DigitCountLg2,
    AVeryLongLineAndInformationAndIdontKnowWhatToWrite = 4;
endmodule

I could not find any reference to the formatting of this style of many parameters in a single localparam statement in the style guides I searched for.

I can create a PR if a fix is needed.

goekce commented 5 months ago

Probably related:

Test case

module test;
  localparam int unsigned
    DigitCount = 2 ** DigitCountLg2,
    SegmentCount = 7,
    MaxReprNumber = 10 ** DigitCount - 1,
BcdCount = $clog2(10);
endmodule

Actual output

module test;
  localparam int unsigned
    DigitCount = 2 ** DigitCountLg2,
    SegmentCount = 7,
    MaxReprNumber = 10 ** DigitCount - 1,
BcdCount = $clog2(
      10
  );
endmodule

Expected or suggested output

module test;
  localparam int unsigned
    DigitCount = 2 ** DigitCountLg2,
    SegmentCount = 7,
    MaxReprNumber = 10 ** DigitCount - 1,
    BcdCount = $clog2(10);
endmodule