mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-28 16:53:45 +02:00
Do not cprop through ternaries if the selector is an l-value.
It turns out that it is possible for an otherwise constant net
mux to be non-constant if there is a force that can drive the
net. This can be detected as an l-value reference to an otherwise
constant selector.
(cherry picked from commit abc4eb9d52)
This commit is contained in:
@@ -823,6 +823,10 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj)
|
||||
|
||||
/* If the select input is constant, then replace with a BUFZ */
|
||||
bool flag = obj->pin_Sel().nexus()->drivers_constant();
|
||||
/* Note that this cannot be constant if there are assignments
|
||||
to this nexus. (Assignments include "force" to nets.) */
|
||||
flag &= !obj->pin_Sel().nexus()->assign_lval();
|
||||
|
||||
verinum::V sel_val = flag? obj->pin_Sel().nexus()->driven_value() : verinum::Vx;
|
||||
if ((sel_val != verinum::Vz) && (sel_val != verinum::Vx)) {
|
||||
NetBUFZ*tmp = new NetBUFZ(obj->scope(), obj->name(), obj->width());
|
||||
|
||||
Reference in New Issue
Block a user