Skip to content

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

@kamilrakoczy

Description

@kamilrakoczy

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions