Files

680 lines
14 KiB
Plaintext

# ports: a hand-aligned group stays aligned
module m (
input wire clk,
input wire [WIDTH-1:0] data,
output logic valid
);
endmodule
----
module m (
input wire clk,
input wire [WIDTH-1:0] data,
output logic valid
);
endmodule
====
# ports: single spaces stay flush, and a list that fits collapses
module m (
input wire clk,
input wire [WIDTH-1:0] data,
output logic valid
);
endmodule
----
module m (input wire clk, input wire [WIDTH-1:0] data, output logic valid);
endmodule
====
# ports: four excess spaces on one line converge the group to aligned
module m (
input wire clk,
input wire [WIDTH-1:0] data,
output logic valid
);
endmodule
----
module m (
input wire clk,
input wire [WIDTH-1:0] data,
output logic valid
);
endmodule
====
# ports: three excess spaces are below the threshold
module m (
input wire clk,
input wire [WIDTH-1:0] data,
output logic valid
);
endmodule
----
module m (input wire clk, input wire [WIDTH-1:0] data, output logic valid);
endmodule
====
# ports: equal prefixes have nothing to align, so the padding collapses
module m (
input wire clk,
input wire rst,
input wire ena
);
endmodule
----
module m (input wire clk, input wire rst, input wire ena);
endmodule
====
# ports: a standalone comment splits the group in two
module m (
input wire clk,
input wire [WIDTH-1:0] data,
// the outputs
output logic valid,
output logic [7:0] count
);
endmodule
----
module m (
input wire clk,
input wire [WIDTH-1:0] data,
// the outputs
output logic valid,
output logic [7:0] count
);
endmodule
====
# ports: a compiler directive splits the group in two
module m (
input wire clk,
input wire [WIDTH-1:0] data,
`ifdef DEBUG
output logic valid,
output logic [7:0] count
`endif
);
endmodule
----
module m (
input wire clk,
input wire [WIDTH-1:0] data,
`ifdef DEBUG
output logic valid,
output logic [7:0] count
`endif
);
endmodule
====
# ports: an aligned line past the limit takes the whole group back to flush
module m (
input wire [SOME_REALLY_LONG_PARAMETER_NAME_XXXXXXXXXXXXXXXXXXXX-1:0] b,
input wire a_very_long_signal_name_here_that_is_quite_long_indeed_yes,
output logic c
);
endmodule
----
module m (
input wire [SOME_REALLY_LONG_PARAMETER_NAME_XXXXXXXXXXXXXXXXXXXX-1:0] b,
input wire a_very_long_signal_name_here_that_is_quite_long_indeed_yes,
output logic c
);
endmodule
====
# ports: a continuation port has no prefix to pad, so the run ends at it
module m (
input wire clk,
input wire [3:0] sel, more,
output logic valid
);
endmodule
----
module m (
input wire clk,
input wire [3:0] sel,
more,
output logic valid
);
endmodule
====
# ports: an aligned group keeps its trailing comments
module m (
input wire clk, // the clock
input wire [WIDTH-1:0] data,
output logic valid // high for one cycle
);
endmodule
----
module m (
input wire clk, // the clock
input wire [WIDTH-1:0] data,
output logic valid // high for one cycle
);
endmodule
====
# ports: alignment holds a list open that would otherwise fit on one line
module m (
input wire clk,
output logic q
);
endmodule
----
module m (
input wire clk,
output logic q
);
endmodule
====
# connections: a hand-aligned group stays aligned
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
----
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
====
# connections: tight parens stay tight and the list collapses
module m;
sub u (
.clk(clk),
.reset_n(rst_n),
.data_valid(dv)
);
endmodule
----
module m;
sub u (.clk(clk), .reset_n(rst_n), .data_valid(dv));
endmodule
====
# connections: four spaces before one `(` converge the group to aligned
module m;
sub u (
.clk (clk),
.reset_n(rst_n),
.data_valid(dv)
);
endmodule
----
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
====
# connections: one space each is not a hint
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
----
module m;
sub u (.clk(clk), .reset_n(rst_n), .data_valid(dv));
endmodule
====
# connections: an author who over-padded gets the computed column
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
----
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
====
# connections: `.*` and an implicit `.name` are not alignable and split the group
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid,
.ready (rdy),
.last_thing (lt)
);
endmodule
----
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid,
.ready (rdy),
.last_thing (lt)
);
endmodule
====
# connections: a standalone comment splits the group
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
// the data side
.data_valid (dv),
.ready (rdy)
);
endmodule
----
module m;
sub u (
.clk (clk),
.reset_n (rst_n),
// the data side
.data_valid (dv),
.ready (rdy)
);
endmodule
====
# connections: equal-width names have nothing to align
module m;
sub u (
.clk_a (a),
.clk_b (b),
.clk_c (c)
);
endmodule
----
module m;
sub u (.clk_a(a), .clk_b(b), .clk_c(c));
endmodule
====
# params: a hand-aligned `=` column stays aligned
module m;
localparam int A = 1;
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1;
localparam int LONGER = 22;
endmodule
====
# params: single spaces stay flush
module m;
localparam int A = 1;
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1;
localparam int LONGER = 22;
endmodule
====
# params: four excess spaces before one `=` converge the group
module m;
localparam int A = 1;
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1;
localparam int LONGER = 22;
endmodule
====
# params: the name column aligns too when the types differ
module m;
localparam int A = 1;
localparam logic [31:0] LONGER = 32'hDEAD;
endmodule
----
module m;
localparam int A = 1;
localparam logic [31:0] LONGER = 32'hDEAD;
endmodule
====
# params: a blank line splits the group
module m;
localparam int A = 1;
localparam int LONGER = 22;
localparam int B = 3;
localparam int OTHER = 44;
endmodule
----
module m;
localparam int A = 1;
localparam int LONGER = 22;
localparam int B = 3;
localparam int OTHER = 44;
endmodule
====
# params: a standalone comment splits the group
module m;
localparam int A = 1;
localparam int LONGER = 22;
// a second table
localparam int B = 3;
localparam int OTHER = 44;
endmodule
----
module m;
localparam int A = 1;
localparam int LONGER = 22;
// a second table
localparam int B = 3;
localparam int OTHER = 44;
endmodule
====
# params: an unrelated item between two parameters splits the group
module m;
localparam int A = 1;
wire w;
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1;
wire w;
localparam int LONGER = 22;
endmodule
====
# params: a declaration without a value is not a row and splits the group
module m;
localparam int A = 1;
parameter P;
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1;
parameter P;
localparam int LONGER = 22;
endmodule
====
# params: two declarators in one statement are not a row
module m;
localparam int A = 1, B = 2;
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1, B = 2;
localparam int LONGER = 22;
endmodule
====
# params: an author who over-padded gets the computed column
module m;
localparam int A = 1;
localparam int LONGER = 22;
localparam int LONGEST_YET = 333;
endmodule
----
module m;
localparam int A = 1;
localparam int LONGER = 22;
localparam int LONGEST_YET = 333;
endmodule
====
# params: an aligned line past the limit takes the group back to flush
module m;
localparam int SHORT = 1;
localparam logic [31:0] A_MUCH_LONGER_PARAMETER_NAME_GOES_HERE_OK_LONGER = 32'hDEADBEEF + SOME_XYZ;
endmodule
----
module m;
localparam int SHORT = 1;
localparam logic [31:0] A_MUCH_LONGER_PARAMETER_NAME_GOES_HERE_OK_LONGER =
32'hDEADBEEF + SOME_XYZ;
endmodule
====
# params: one parameter is a group of one and never aligns
module m;
localparam int A = 1;
wire w;
endmodule
----
module m;
localparam int A = 1;
wire w;
endmodule
====
# params: a trailing comment rides along with an aligned row
module m;
localparam int A = 1; // the first
localparam int LONGER = 22; // the second
endmodule
----
module m;
localparam int A = 1; // the first
localparam int LONGER = 22; // the second
endmodule
====
# params: a fenced parameter is emitted verbatim and splits the group
module m;
localparam int A = 1;
// verilog_format: off
localparam int MID = 2;
// verilog_format: on
localparam int LONGER = 22;
endmodule
----
module m;
localparam int A = 1;
// verilog_format: off
localparam int MID = 2;
// verilog_format: on
localparam int LONGER = 22;
endmodule
====
# alignment applies inside a generate block at its own indentation
module m;
generate
if (X) begin : g
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
end
endgenerate
endmodule
----
module m;
generate
if (X) begin : g
sub u (
.clk (clk),
.reset_n (rst_n),
.data_valid (dv)
);
end
endgenerate
endmodule
====
# a comment written before an element's comma does not split the group
module m;
sub u (
.clk (clk) /* c */,
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
----
module m;
sub u (
.clk (clk) /* c */,
.reset_n (rst_n),
.data_valid (dv)
);
endmodule
====
# alignment in a package body: parameters align, the fence does not move
package p;
localparam int WIDTH = 8;
localparam int DEPTHXX = 16;
endpackage
----
package p;
localparam int WIDTH = 8;
localparam int DEPTHXX = 16;
endpackage
====
# a class body's parameters align the same way
class c;
localparam int WIDTH = 8;
localparam int DEPTHXX = 16;
endclass
----
class c;
localparam int WIDTH = 8;
localparam int DEPTHXX = 16;
endclass
====
# a hint on a list that would fit on one line still opens and aligns it
module m (input wire a, output logic b);
endmodule
----
module m (
input wire a,
output logic b
);
endmodule
====
# the same list without differing widths has nothing to align
module m (input wire a, input wire b);
endmodule
----
module m (input wire a, input wire b);
endmodule
====
# header parameter ports: hand-aligned table keeps its columns and trails comments cleanly
module m #(
parameter int Width = 8, // the width
parameter logic [31:0] LongName = 32'd16,
localparam int Derived = Width + 1
) (
input logic clk
);
endmodule
----
module m #(
parameter int Width = 8, // the width
parameter logic [31:0] LongName = 32'd16,
localparam int Derived = Width + 1
) (input logic clk);
endmodule
====
# header parameter ports: unaligned multi-line longer than budget stays flush under Infer
module m #(
parameter int Width = 8,
parameter logic [31:0] LongParameterNameExceedingTheHundredColumnBudgetForOneLine = 32'd16
) ();
endmodule
----
module m #(
parameter int Width = 8,
parameter logic [31:0] LongParameterNameExceedingTheHundredColumnBudgetForOneLine = 32'd16
) ();
endmodule
====
# header parameter ports: four-space hint opens and aligns both columns
module m #(parameter int A = 1, parameter bit LONGER = 0) ();
endmodule
----
module m #(
parameter int A = 1,
parameter bit LONGER = 0
) ();
endmodule
====
# header parameter ports: interface header aligns and comment splits groups
interface bus_if #(
parameter int W = 8,
parameter logic [15:0] Mask = 16'hFFFF,
// independent table
parameter bit Fast = 1'b1,
parameter int unsigned Depth = 4
) ();
endinterface
----
interface bus_if #(
parameter int W = 8,
parameter logic [15:0] Mask = 16'hFFFF,
// independent table
parameter bit Fast = 1'b1,
parameter int unsigned Depth = 4
) ();
endinterface
====
# header parameter ports: continuation without prefix or missing default splits group cleanly
module m #(
parameter int A = 1,
parameter bit LONGER = 0,
NO_PREFIX = 2,
parameter int NO_DEFAULT
) ();
endmodule
----
module m #(
parameter int A = 1,
parameter bit LONGER = 0,
NO_PREFIX = 2,
parameter int NO_DEFAULT
) ();
endmodule
====
# instance named parameter overrides: hand-aligned stays aligned, positional untouched
module m;
sub #(
.WIDTH (8),
.LONG_CFG (16)
) u0 (
.clk(clk)
);
sub #(16, 32) u1 (.clk(clk));
endmodule
----
module m;
sub #(
.WIDTH (8),
.LONG_CFG (16)
) u0 (.clk(clk));
sub #(16, 32) u1 (.clk(clk));
endmodule
====
# instance named parameter overrides: four-space hint opens and aligns, unaligned stays tight
module m;
sub #(.A (1), .LONGER(2)) u0 ();
sub #(.A(1), .LONGER(2)) u1 ();
endmodule
----
module m;
sub #(
.A (1),
.LONGER (2)
) u0 ();
sub #(.A(1), .LONGER(2)) u1 ();
endmodule
====
# bind named parameter overrides align identically to direct instantiations
module m;
bind target_mod chk #(
.ENABLE (1),
.ADDR_BITS (12)
) u_chk (
.clk_i(clk)
);
endmodule
----
module m;
bind target_mod chk #(
.ENABLE (1),
.ADDR_BITS (12)
) u_chk (.clk_i(clk));
endmodule