Skip to content

Commit

Permalink
Fix handling forced assigns in V3Life (verilator#5757)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-chmiel authored Jan 28, 2025
1 parent e2a6e19 commit a379382
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/V3Life.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ class LifeVisitor final : public VNVisitor {
}
}
void visit(AstNodeAssign* nodep) override {
if (nodep->isTimingControl()) {
// V3Life doesn't understand time sense - don't optimize
if (nodep->isTimingControl() || VN_IS(nodep, AssignForce)) {
// V3Life doesn't understand time sense nor force assigns - don't optimize
setNoopt();
iterateChildren(nodep);
return;
Expand Down
18 changes: 18 additions & 0 deletions test_regress/t/t_force_assign.py
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 2025 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('simulator')

test.compile()

test.execute()

test.passes()
24 changes: 24 additions & 0 deletions test_regress/t/t_force_assign.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Antmicro.
// SPDX-License-Identifier: CC0-1.0

module t;
reg [2:0] a = 0;

initial begin
a = 1;
if (a != 1) $stop;

force a = 2;
if (a != 2) $stop;

a = 3;
if (a != 2) $stop;

$write("*-* All Finished *-*\n");
$finish;
end

endmodule

0 comments on commit a379382

Please sign in to comment.