forked from verilator/verilator
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bartłomiej Chmiel <[email protected]>
- Loading branch information
Showing
16 changed files
with
305 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// DESCRIPTION: Verilator: Verilog Test module | ||
// | ||
// This file ONLY is placed under the Creative Commons Public Domain, for | ||
// any use, without warranty, 2024 by Antmicro. | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
localparam N = 256; // Wider than expand limit. | ||
|
||
module t( | ||
input wire [N-1:0] i, | ||
output logic [N-1:0] o_multiple1, | ||
output logic [N-1:0] o_multiple2, | ||
output wire [N-1:0] o | ||
); | ||
|
||
// Exclude from inline wide expressions referenced multiple times. | ||
wire [N-1:0] wide_multiple_assigns = N >> i; | ||
wire [N-1:0] wide = N << i; | ||
|
||
for (genvar n = 0; n < N - 1; ++n) begin | ||
assign o[n] = i[N-1-n] | wide[N-1-n]; | ||
end | ||
|
||
assign o_multiple1 = wide_multiple_assigns | i + 1; | ||
assign o_multiple2 = wide_multiple_assigns | i + 2; | ||
endmodule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2024 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
import vltest_bootstrap | ||
|
||
test.scenarios('vlt') | ||
|
||
test.lint(verilator_flags2=['--stats', '--expand-limit 5']) | ||
|
||
test.file_grep(test.stats, r'Optimizations, Gate excluded wide expressions\s+(\d+)', 0) | ||
test.file_grep(test.stats, r'Optimizations, Gate sigs deleted\s+(\d+)', 1) | ||
|
||
test.passes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// DESCRIPTION: Verilator: Verilog Test module | ||
// | ||
// This file ONLY is placed under the Creative Commons Public Domain, for | ||
// any use, without warranty, 2024 by Antmicro. | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
module t; | ||
logic [255:0] arrd [0:0] = '{ 1 }; | ||
logic [255:0] y0; | ||
|
||
// Do not exclude from inlining wide arraysels. | ||
always_comb y0 = arrd[0]; | ||
|
||
always_comb begin | ||
if (y0 != 1 && y0 != 0) begin | ||
$stop; | ||
end | ||
end | ||
endmodule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2024 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
import vltest_bootstrap | ||
|
||
test.scenarios('vlt') | ||
|
||
test.lint(verilator_flags2=['--stats', '--expand-limit 5']) | ||
|
||
test.file_grep(test.stats, r'Optimizations, Gate excluded wide expressions\s+(\d+)', 0) | ||
test.file_grep(test.stats, r'Optimizations, Gate sigs deleted\s+(\d+)', 2) | ||
|
||
test.passes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// DESCRIPTION: Verilator: Verilog Test module | ||
// | ||
// This file ONLY is placed under the Creative Commons Public Domain, for | ||
// any use, without warranty, 2024 by Antmicro. | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
module t; | ||
logic [255:0] arrd = 256'b0; | ||
logic [255:0] y0; | ||
|
||
// Do not exclude from inlining wide variables with const assignments. | ||
always_comb y0 = 256'(arrd[0]); | ||
|
||
always_comb begin | ||
if (y0 != 1 && y0 != 0) begin | ||
$stop; | ||
end | ||
end | ||
endmodule | ||
|
18 changes: 18 additions & 0 deletions
18
test_regress/t/t_gate_inline_wide_noexclude_other_scope.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2024 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
import vltest_bootstrap | ||
|
||
test.scenarios('vlt') | ||
|
||
test.lint(verilator_flags2=['--stats', '--expand-limit 5']) | ||
|
||
test.file_grep(test.stats, r'Optimizations, Gate excluded wide expressions\s+(\d+)', 0) | ||
|
||
test.passes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// DESCRIPTION: Verilator: Verilog Test module | ||
// | ||
// This file ONLY is placed under the Creative Commons Public Domain, for | ||
// any use, without warranty, 2024 by Antmicro. | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
localparam N = 256; // Wider than expand limit. | ||
|
||
module t( | ||
input wire [N-1:0] i, | ||
output wire [N-1:0] o | ||
); | ||
|
||
// Do not exclude from inlining wides referenced in different scope. | ||
wire [N-1:0] wide = N ~^ i; | ||
|
||
sub sub(i, wide, o); | ||
endmodule | ||
|
||
module sub(input wire [N-1:0] i, input wire [N-1:0] wide, output logic [N-1:0] o); | ||
initial begin | ||
for (integer n = 0; n < N ; ++n) begin | ||
o[n] = i[N-1-n] | wide[N-1-n]; | ||
end | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2024 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
import vltest_bootstrap | ||
|
||
test.scenarios('vlt') | ||
|
||
test.lint(verilator_flags2=['--stats', '--expand-limit 5']) | ||
|
||
test.file_grep(test.stats, r'Optimizations, Gate excluded wide expressions\s+(\d+)', 1) | ||
test.file_grep(test.stats, r'Optimizations, Gate sigs deleted\s+(\d+)', 9) | ||
|
||
test.passes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// DESCRIPTION: Verilator: Verilog Test module | ||
// | ||
// This file ONLY is placed under the Creative Commons Public Domain, for | ||
// any use, without warranty, 2024 by Antmicro. | ||
// SPDX-License-Identifier: CC0-1.0 | ||
|
||
module t ( | ||
output reg [1020:0] res1, | ||
output reg [1020:0] res2, | ||
output reg [1022:0] res3, | ||
output reg [1022:0] res4 | ||
); | ||
always_inline always_inline(res1, res2); | ||
dont_inline dont_inline(res3, res4); | ||
endmodule | ||
|
||
module always_inline( | ||
output reg [1020:0] res1, | ||
output reg [1020:0] res2 | ||
); | ||
|
||
wire [1023:0] a; | ||
wire [478:0] b; | ||
|
||
assign b = a[510:32]; | ||
assign res1 = {542'b0, b}; | ||
assign res2 = {542'b1, b}; | ||
endmodule | ||
|
||
// SEL does not have proper offset so we do not have guarantee that it will be | ||
// emitted as '[' operator, thus we do not exclude it from inlining. | ||
module dont_inline( | ||
output reg [1022:0] res1, | ||
output reg [1022:0] res2 | ||
); | ||
|
||
wire [1023:0] a; | ||
wire [480:0] b; | ||
|
||
// LSB % 32 != 0 | ||
assign b = a[510:30]; | ||
assign res1 = {542'b0, b}; | ||
assign res2 = {542'b1, b}; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2024 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
import vltest_bootstrap | ||
|
||
test.scenarios('vlt') | ||
|
||
test.lint(verilator_flags2=['--stats', '--expand-limit 5']) | ||
|
||
test.file_grep(test.stats, r'Optimizations, Gate excluded wide expressions\s+(\d+)', 0) | ||
|
||
test.passes() |
Oops, something went wrong.