Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verilog: Mixing integer and real values causes error #4780

Open
flafflar opened this issue Nov 28, 2024 · 2 comments
Open

Verilog: Mixing integer and real values causes error #4780

flafflar opened this issue Nov 28, 2024 · 2 comments
Labels
pending-verification This issue is pending verification and/or reproduction

Comments

@flafflar
Copy link

Version

Yosys 0.47+135 (git sha1 6f3376c, g++ 14.2.1 -fPIC -O3)

On which OS did this happen?

Linux

Reproduction Steps

A Verilog code that can cause the bug is the following:

module test (
    input [31:0] a,
    output q
);

parameter VALUE = 100;

assign q = a > VALUE * 1.2;

endmodule

Expected Behavior

Yosys should parse that Verilog code into RTLIL successfully

Actual Behavior

The read_verilog command fails with the following error :

ERROR: Found error in internal cell \test.$gt$test.v:8$1 ($gt) at kernel/rtlil.cc:1333:
  attribute \src "test.v:8.12-8.27"
  cell $gt $gt$test.v:8$1
    parameter \Y_WIDTH 1
    parameter \B_WIDTH 32
    parameter \A_WIDTH 32
    parameter \B_SIGNED 1
    parameter \A_SIGNED 0
    connect \Y $gt$test.v:8$1_Y
    connect \B 120
    connect \A \a
  end
@flafflar flafflar added the pending-verification This issue is pending verification and/or reproduction label Nov 28, 2024
@KrystalDelusion
Copy link
Member

The error being raised is actually in an if (check_matched_sign) { block, so I suspect the problem is because it's comparing B as signed and A as unsigned that is causing the error. Notice connect \B 120; which means it correctly multiplies 100*1.2.

@flafflar
Copy link
Author

You're probably right, changing the code to this:

module test (
    input signed [31:0] a,
    output q
);

parameter VALUE = 100;

assign q = a > VALUE * 1.2;

endmodule

throws no error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-verification This issue is pending verification and/or reproduction
Projects
None yet
Development

No branches or pull requests

2 participants