Skip to content

multiple drivers on a variable in a module change values of input ports when using prep #5212

@toby-bro

Description

@toby-bro

Version

Yosys 0.54 (git sha1 db72ec3, g++ 12.2.0-14+deb12u1 -fPIC -O3)

On which OS did this happen?

Linux

Reproduction Steps

read_verilog -sv <<EOT
module simple_sub (
    input logic [7:0] a,
    input logic [7:0] b,
    output logic [7:0] a_out,
    output logic [7:0] b_out,
    output logic [7:0] diff
);
    wire [7:0] conflict_wire;
    assign a_out = a;
    assign b_out = b;
    assign conflict_wire = b;
    assign conflict_wire = a;
    assign diff = a - b;
    always_comb assert(b != a);
endmodule

module top;
    logic [7:0] a, b, a_out, b_out, diff;
    
    assign a = 8'hAA;
    assign b = 8'h55;

    simple_sub dut (
        .a(a),
        .b(b),
        .a_out(a_out),
        .b_out(b_out),
        .diff(diff)
    );

endmodule
EOT

prep -top top
chformal -lower
select simple_sub
sat -prove-asserts -verify

Tried to write a yosys script to simplify reproduction of bug, (hopefully it is correct 😅)

Expected Behavior

I don't really know (I thought I would mention it as this behaviour surprised me), I would have thought that for conflict_wire the value could be either that of a or that of b but I would have thought that the inputs are not modified in the module.

Actual Behavior

module simple_sub(a, b, a_out, b_out, diff);
  input [7:0] a;
  wire [7:0] a;
  output [7:0] a_out;
  wire [7:0] a_out;
  input [7:0] b;
  wire [7:0] b;
  output [7:0] b_out;
  wire [7:0] b_out;
  wire [7:0] conflict_wire;
  output [7:0] diff;
  wire [7:0] diff;
  assign diff = a - a;
  assign a_out = a;
  assign b = a;
  assign b_out = a;
  assign conflict_wire = a;
endmodule

b is assigned the value of a

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-verificationThis issue is pending verification and/or reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions