VERILOG2015: Non-void function return values should not be ignored

Summary

Count: 1

ReliabilitySecurityMaintainabilityCode attributeEffort to fixTags
HIGH--Intentionality | Logical10minsynthesis, vscode, linter, simulation, dead-code

Description

Noncompliant code example

module top(input x, output reg y);
  function int foo;
    return 1;
  endfunction

  function int bar;
    return 0;
  endfunction

  always @ (posedge x) begin
    foo(); // Noncompliant
    bar(); // Noncompliant
  end
endmodule

Compliant solution

module top(input x, output reg y);
  function int foo;
    return 1;
  endfunction

  function int bar;
    return 0;
  endfunction

  always @ (posedge x) begin
    y <= foo(); // Compliant: Return value is used
    void'(bar()); // Compliant: Explicit cast to 'void'
  end
endmodule

A non-void function is invoked without inspecting its return value.

Capture the result or explicitly cast the call to void if it is the expected behavior.

Parameters

No parameters.