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

Wrong evaluation of unsized constant when used in operation with sized constant #3979

Open
kamilrakoczy opened this issue Aug 7, 2024 · 0 comments

Comments

@kamilrakoczy
Copy link
Collaborator

Test:

module top();
	initial $display($bits('hff & 10'hf));
endmodule

Executing Surelog with -parse -elabuhdm gives following tree:

|uhdmallModules:
\_module_inst: work@top (work@top), file:dut.sv, line:1:1, endln:3:10
  |vpiParent:
  \_design: (work@top)
  |vpiFullName:work@top
  |vpiDefName:work@top
  |vpiProcess:
  \_initial: , line:2:2, endln:2:33
    |vpiParent:
    \_module_inst: work@top (work@top), file:dut.sv, line:1:1, endln:3:10
    |vpiStmt:
    \_sys_func_call: ($display), line:2:10, endln:2:32
      |vpiParent:
      \_initial: , line:2:2, endln:2:33
      |vpiArgument:
      \_operation: , line:2:19, endln:2:31
        |vpiParent:
        \_sys_func_call: ($display), line:2:10, endln:2:32
        |vpiOpType:28
        |vpiOperand:
        \_constant: , line:2:19, endln:2:23
          |vpiParent:
          \_operation: , line:2:19, endln:2:31
          |vpiDecompile:'hff
          |vpiSize:-1
          |HEX:ff
          |vpiConstType:5
        |vpiOperand:
        \_constant: , line:2:26, endln:2:31
          |vpiParent:
          \_operation: , line:2:19, endln:2:31
          |vpiDecompile:10'hf
          |vpiSize:10
          |HEX:f
          |vpiConstType:5
      |vpiName:$display
|uhdmtopModules:
\_module_inst: work@top (work@top), file:dut.sv, line:1:1, endln:3:10
  |vpiName:work@top
  |vpiDefName:work@top
  |vpiTop:1
  |vpiTopModule:1
  |vpiProcess:
  \_initial: , line:2:2, endln:2:33
    |vpiParent:
    \_module_inst: work@top (work@top), file:dut.sv, line:1:1, endln:3:10
    |vpiStmt:
    \_sys_func_call: ($display), line:2:10, endln:2:32
      |vpiParent:
      \_initial: , line:2:2, endln:2:33
      |vpiArgument:
      \_operation: , line:2:19, endln:2:31
        |vpiParent:
        \_sys_func_call: ($display), line:2:10, endln:2:32
        |vpiOpType:28
        |vpiOperand:
        \_constant: , line:2:19, endln:2:23
          |vpiDecompile:'hff
          |vpiSize:10
          |HEX:ff
          |vpiConstType:5
        |vpiOperand:
        \_constant: , line:2:26, endln:2:31
      |vpiName:$display

According to standard (11.6.1 Rules for expression bit lengths) such expression should have max size of both operands, where size of unsized constant should equal to size of integer.

In uhdmallModules, 'hff is unsized (|vpiSize:-1), but in uhdmtopModules it have size |vpiSize:10 instead of size of integer (in case of Surelog, I think it should be 64)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant