Flag Metavalues detected by ??

Proposal Information

  • Current Owner: JimLewis, ...
  • Contributors: JimLewis, ...
  • Date Proposed: 2014-October-16
  • Date Last Updated: 2014-October-16
  • Priority:
  • Complexity:
  • Focus: All
  • Related Issues: None
  • Competing Issues: None

Issue Summary

When ?? receives a metavalue (U, X, Z, W, -) it quietly returns false

function "??" (l : STD_ULOGIC) return BOOLEAN is
begin
  return l = '1' or l = 'H';
end function "??";

Stack Overflow post identifies concerns about correctly handling metavalues.

In fact, if you look at "="[unsigned, unsigned return unsigned], you will note that if one of the inputs has an 'X', an assertion warning is produced.

Proposal

Add an assertion to ?? so that it produces an ERROR

function "??" (l : STD_ULOGIC) return BOOLEAN is
begin
  assert not is_x(l) or NO_WARNING
    report "STD_LOGIC_1164.""??"": metavalue detected, returning FALSE"
    severity warning;
  return l = '1' or l = 'H';
end function "??"; 

Often I prefer the readability of if over assert:

function "??" (l : STD_ULOGIC) return BOOLEAN is
begin
  if is_x(l) and not NO_WARNING then
    report "STD_LOGIC_1164.""??"": metavalue detected, returning FALSE"
    severity warning;
  end if ;
  return l = '1' or l = 'H';
end function "??";

Requires edit of LRM 9.2.9. Change:

NOTE 2—The condition operator is defined for type STD_ULOGIC defined in package STD_LOGIC_1164 (see 16.7).
Conversion of a value of type STD_ULOGIC converts '1' and 'H' to TRUE and all other values to FALSE.

To:

NOTE 2—The condition operator is defined for type STD_ULOGIC defined in package STD_LOGIC_1164 (see 16.7).
Conversion of a value of type STD_ULOGIC converts '1' and 'H' to TRUE and all other values to FALSE. If metavalue is detected, an assert severity WARNING is issued.

Concerns

May slow down evaluation of conditional expressions

Comments

Supporters

Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2020-02-17 - 15:34:56 - TWikiGuest
 
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback