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

Long localparam lines are not formatted #2156

Open
goekce opened this issue Apr 12, 2024 · 1 comment
Open

Long localparam lines are not formatted #2156

goekce opened this issue Apr 12, 2024 · 1 comment
Labels
formatter Verilog code formatter issues

Comments

@goekce
Copy link

goekce commented Apr 12, 2024

Test case

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

version: 3624 d256d77

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 goekce added the formatter Verilog code formatter issues label Apr 12, 2024
@goekce
Copy link
Author

goekce commented Apr 12, 2024

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

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

No branches or pull requests

2 participants
@goekce and others