Tests: Reformat some recent tests to mostly verilog-format standard. No test functional change.

This commit is contained in:
Wilson Snyder 2026-08-11 20:04:45 -04:00
parent da0c31926e
commit 08cd5fe30b
23 changed files with 79 additions and 72 deletions

View File

@ -12,6 +12,8 @@
# SPDX-FileCopyrightText: 2026 Wilson Snyder # SPDX-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
# These flags tested against verible-v0.0-4080-ga0a8d8eb
verible-verilog-format \ verible-verilog-format \
--inplace \ --inplace \
--wrap_end_else_clauses \ --wrap_end_else_clauses \

View File

@ -26,7 +26,9 @@ module t;
virtual function void deliver(); virtual function void deliver();
$display("fast delivery"); $display("fast delivery");
endfunction endfunction
virtual function int seats(); return 4; endfunction virtual function int seats();
return 4;
endfunction
endclass endclass
class MetaCar extends Car; class MetaCar extends Car;

View File

@ -6,7 +6,9 @@
// Output arg of class type-parameter accepts a base handle (upcast). // Output arg of class type-parameter accepts a base handle (upcast).
class Fifo #(type T = int); class Fifo #(
type T = int
);
T m_val; T m_val;
task get(output T t); task get(output T t);
t = m_val; t = m_val;

View File

@ -40,7 +40,8 @@ class con_rand_1d_array_test;
`check_rand(this, data[i]) `check_rand(this, data[i])
if (data[i] inside {8'h10, 8'h20, 8'h30, 8'h40, 8'h50}) begin if (data[i] inside {8'h10, 8'h20, 8'h30, 8'h40, 8'h50}) begin
$display("data[%0d] = %h is valid", i, data[i]); $display("data[%0d] = %h is valid", i, data[i]);
end else begin end
else begin
$display("Error: data[%0d] = %h is out of bounds", i, data[i]); $display("Error: data[%0d] = %h is out of bounds", i, data[i]);
$stop; $stop;
end end
@ -70,7 +71,8 @@ class con_rand_2d_array_test;
`check_rand(this, data[i][j]) `check_rand(this, data[i][j])
if (data[i][j] >= 8'h10 && data[i][j] <= 8'h50) begin if (data[i][j] >= 8'h10 && data[i][j] <= 8'h50) begin
$display("data[%0d][%0d] = %h is valid", i, j, data[i][j]); $display("data[%0d][%0d] = %h is valid", i, j, data[i][j]);
end else begin end
else begin
$display("Error: data[%0d][%0d] = %h is out of bounds", i, j, data[i][j]); $display("Error: data[%0d][%0d] = %h is out of bounds", i, j, data[i][j]);
$stop; $stop;
end end

View File

@ -18,6 +18,6 @@ test.compile(verilator_flags2=[
test.execute() test.execute()
test.file_grep(test.stats, r'Build jobs: 2') test.file_grep(test.stats, r'Build jobs: (\d+)', 2)
test.passes() test.passes()

View File

@ -4,10 +4,10 @@
// SPDX-FileCopyrightText: 2023 Wilson Snyder // SPDX-FileCopyrightText: 2023 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0 // SPDX-License-Identifier: CC0-1.0
// verilog_format: on // verilog_format: off
`define stop $stop `define stop $stop
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); `define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
// verilog_format: off // verilog_format: on
module t; module t;

View File

@ -18,6 +18,6 @@ memUsageMB = int(test.file_grep(test.stats, r'Peak Memory Usage \(MB\) +(\d+)')[
if memUsageMB > 128 and not test.have_dev_asan: if memUsageMB > 128 and not test.have_dev_asan:
test.error("Consumed over 128MB memory") test.error("Consumed over 128MB memory")
test.file_grep(test.stats, r'Verilate jobs: 2') test.file_grep(test.stats, r'Verilate jobs: (\d+)', 2)
test.passes() test.passes()

View File

@ -10,9 +10,7 @@
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); `define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
// verilog_format: on // verilog_format: on
typedef struct{ typedef struct {rand bit [31:0] x;} Bar;
rand bit [31:0] x;
} Bar;
class Foo; class Foo;
rand Bar bar0[]; rand Bar bar0[];

View File

@ -27,8 +27,7 @@ module t (
always_ff @(posedge clk) begin always_ff @(posedge clk) begin
`ifdef TEST_VERBOSE `ifdef TEST_VERBOSE
$write("[%0t] cyc==%0d crc=%x a=%b b=%b c=%b d=%b\n", $write("[%0t] cyc==%0d crc=%x a=%b b=%b c=%b d=%b\n", $time, cyc, crc, a, b, c, d);
$time, cyc, crc, a, b, c, d);
`endif `endif
cyc <= cyc + 1; cyc <= cyc + 1;
crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]};
@ -37,9 +36,11 @@ module t (
if (cyc == 0) begin if (cyc == 0) begin
crc <= 64'h5aef0c8d_d70a4497; crc <= 64'h5aef0c8d_d70a4497;
sum <= '0; sum <= '0;
end else if (cyc < 10) begin end
else if (cyc < 10) begin
sum <= '0; sum <= '0;
end else if (cyc == 99) begin end
else if (cyc == 99) begin
`checkh(crc, 64'hc77bb9b3784ea091); `checkh(crc, 64'hc77bb9b3784ea091);
`checkh(sum, 64'hdb7bc8bfe61f987e); `checkh(sum, 64'hdb7bc8bfe61f987e);
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");

View File

@ -26,8 +26,7 @@ module t (
always_ff @(posedge clk) begin always_ff @(posedge clk) begin
`ifdef TEST_VERBOSE `ifdef TEST_VERBOSE
$write("[%0t] cyc==%0d crc=%x a=%b b=%b c=%b d=%b\n", $write("[%0t] cyc==%0d crc=%x a=%b b=%b c=%b d=%b\n", $time, cyc, crc, a, b, c, d);
$time, cyc, crc, a, b, c, d);
`endif `endif
cyc <= cyc + 1; cyc <= cyc + 1;
crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]};
@ -36,9 +35,11 @@ module t (
if (cyc == 0) begin if (cyc == 0) begin
crc <= 64'h5aef0c8d_d70a4497; crc <= 64'h5aef0c8d_d70a4497;
sum <= '0; sum <= '0;
end else if (cyc < 10) begin end
else if (cyc < 10) begin
sum <= '0; sum <= '0;
end else if (cyc == 99) begin end
else if (cyc == 99) begin
`checkh(crc, 64'hc77bb9b3784ea091); `checkh(crc, 64'hc77bb9b3784ea091);
`checkh(sum, 64'hdb7bc8bfe61f987e); `checkh(sum, 64'hdb7bc8bfe61f987e);
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");

View File

@ -11,18 +11,17 @@
class Sub; class Sub;
typedef enum bit [1:0] { typedef enum bit [1:0] {
one, ONE,
two, TWO,
three, THREE,
four FOUR
} enum_t; } enum_t;
rand bit num; rand bit num;
rand enum_t en; rand enum_t en;
constraint c { constraint c {num == 0;}
num == 0;
};
endclass endclass
class Top; class Top;

View File

@ -46,6 +46,6 @@ test.compile(
test.execute() test.execute()
test.file_grep(test.stats, r'Verilate jobs: 2') test.file_grep(test.stats, r'Verilate jobs: (\d+)', 2)
test.passes() test.passes()