mirror of
https://github.com/verilator/verilator.git
synced 2025-01-05 22:27:35 +00:00
Tests: Test future if condition optimization (#2726)
This commit is contained in:
parent
9f8b17230a
commit
97255dc835
22
test_regress/t/t_optm_if_cond.pl
Executable file
22
test_regress/t/t_optm_if_cond.pl
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2019 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
|
||||
|
||||
scenarios(vlt => 1);
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ['--stats'],
|
||||
);
|
||||
|
||||
if ($Self->{vlt_all}) {
|
||||
file_grep($Self->{stats}, qr/Node count, IF +\d+ +\d+ +\d+ +\d+ +(\d+)/, 11);
|
||||
}
|
||||
|
||||
ok(1);
|
||||
1;
|
57
test_regress/t/t_optm_if_cond.v
Normal file
57
test_regress/t/t_optm_if_cond.v
Normal file
@ -0,0 +1,57 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2020 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t(/*AUTOARG*/
|
||||
// Outputs
|
||||
q0, q1, q2, q3, q4,
|
||||
// Inputs
|
||||
clk, rst, en, i0, i1, i2, i3, i4
|
||||
);
|
||||
input clk;
|
||||
|
||||
input rst;
|
||||
input en;
|
||||
output int q0; input int i0;
|
||||
output int q1; input int i1;
|
||||
output int q2; input int i2;
|
||||
output int q3; input int i3;
|
||||
output int q4; input int i4;
|
||||
|
||||
always @ (posedge clk) begin
|
||||
if (rst) begin
|
||||
if (en) q0 <= i0;
|
||||
end
|
||||
else q0 <= 0;
|
||||
|
||||
if (rst) begin
|
||||
if (en) q1 <= i1;
|
||||
end
|
||||
else q1 <= 0;
|
||||
|
||||
if (rst) begin
|
||||
if (en) q2 <= i2;
|
||||
end
|
||||
else q2 <= 0;
|
||||
|
||||
if (rst) begin
|
||||
if (en) q3 <= i3;
|
||||
end
|
||||
else q3 <= 0;
|
||||
end
|
||||
|
||||
always_comb begin
|
||||
q4 = i4;
|
||||
if (q4 == 0) begin
|
||||
// Conflicts with condition
|
||||
q4 = 1;
|
||||
end
|
||||
if (q4 == 0) begin
|
||||
// Conflicts with condition
|
||||
q4 = 2;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user