[sv-bc] Errata in SV 3.1 BNF for unique/priority if...else


Subject: [sv-bc] Errata in SV 3.1 BNF for unique/priority if...else
From: Stuart Sutherland (stuart@sutherland-hdl.com)
Date: Sat Aug 30 2003 - 12:56:42 PDT


All,

There seems to be a discrepancy in the 3.1 LRM regarding the use of unique
and priority with if...else...if statements.

My understanding is that the correct usage is:

always_comb
   unique if (opcode == 0) y = a + b;
          else if (opcode == 1) y = a - b;
          else if (opcode == 2) y = a * b;
          else y = a / b;

This style matches the examples in section 8.4 of the final SV 3.1 LRM, and
conforms to the text in that section which states:

"The unique and priority keywords apply to the entire series of
if...else...if conditions...it would have been illegal to insert either
keyword after any of the occurrences of else."

The BNF in that same section, however, shows:

   if_else_if_statement ::=
     [ unique_priority ] if ( expression ) statement_or_null
     { else [ unique_priority ] if ( expression ) statement_or_null }
     [ else statement_or_null ]

According to the BNF, unique or priority can come after each else statement
in the if...else...if series. Does the BNF mean that the example above
either can be, or must be, written as:

always_comb
   unique if (opcode == 0) y = a + b;
   else unique if (opcode == 1) y = a - b;
   else unique if (opcode == 2) y = a * b;
   else y = a / b;

IMHO, the description in section 8.4 is correct, and the BNF is
wrong. Please let me know which example above is correct.

Stu

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stuart Sutherland Sutherland HDL Inc.
stuart@sutherland-hdl.com 22805 SW 92nd Place
phone: 503-692-0898 Tualatin, OR 97062

Sutherland HDL, Inc. -- Training Engineers to be Verilog, SystemVerilog
and VHDL Wizards! www.sutherland-hdl.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



This archive was generated by hypermail 2b28 : Sat Aug 30 2003 - 12:57:18 PDT