RE: [sv-bc] logic A[ 2'b11<<1 ]

From: Steven Sharp <sharp_at_.....>
Date: Tue Oct 03 2006 - 11:55:32 PDT
And after considering further...

Where the text says [0:size-1], what does 'size' represent?  I think
it represents the *number* that was computed from the expression, not
the expression itself.  

If it represented the expression itself being substituted into the
larger expression, as Brad suggests, then things get really strange.
Note that there are no parentheses around size in the larger expression.
That allows a substituted expression to re-associate.  So if
"logic A[ 2'b11<<1 ]" just substitutes "2'b11<<1" for size in "size-1",
you get

  logic A[ 0 : 2'b11<<1-1 ]
  
which is equivalent to

  logic A[ 0 : 2'b11<<(1-1) ]

because '-' has higher precedence than '<<'.  So this isn't a 32-bit
expression after all, because the '-1' is in the shift count!  Anyway,
the result of this is

  logic A[ 0 : 2'b11<<0 ]
  
or

  logic A[ 0 : 2'd3 ]
  
Obviously this is not the intended behavior.  The 'size' that is being
substituted is not the expression, but the value of the expression.
The value of the expression is 2'b10.

Steven Sharp
sharp@cadence.com
Received on Tue Oct 3 11:55:38 2006

This archive was generated by hypermail 2.1.8 : Tue Oct 03 2006 - 11:55:51 PDT