Re: [sv-bc] confusion in evalution of assignment pattern for structure array with more matching type keys than actual structure member

From: Greg Jaxon <Greg.Jaxon_at_.....>
Date: Thu Aug 30 2007 - 10:06:19 PDT
Shalom identified one of the principles that must apply:

> I would think that the second approach is correct, as in 1800-2005,
> 8.13.1, in the paragraph beginning, "For type:value," ends, "If more
> than one type matches the same element, the last value shall be used."
> 
> Shalom 

I agree that that prescription determines which of the type labels
supplies the final value for each data type.

One other policy bears mentioning here:
bit is a 2-state and logic is a 4-state type.
Although these are assignment compatible, they are not "matching"
types, which is what governs the assignment pattern application.

Although you did not declare your struct type to be packed, there
are nonetheless situations during streaming operations and casting
where it will be taken "as a whole", which would permit the 2-state
fields to be treated as 4-state.  This does not affect assignment
patterns, which are controlled by the abstract description of the
data type and not by the data in its fields which may be padded
for storage uniformity.

Mixing 2/4 statefulness is an eccentric coding style, with few,
if any, practical merits.

Greg

Sumay Guin wrote:
> 
> Hi,
>     Consider the scenario,
> 
>     typedef struct  {
>          bit    r1;
>          logic  r2;
>     } node;
>     .....................
>      node p[1:0];
>     .....................
>     .......................
>     p =  '{'{ bit:1'b0, logic: 1'b1, bit: 1'b1, logic: 1'b0 },
>            '{ bit:1'b0, logic: 1'b1, bit: 1'b1, logic: 1'b0 } } ;
>        The value of the of p after assigning the assignment pattern 
> can be different if we follow two different approaches for
> evaluation of the above assignment pattern for p.
> 
>     First approach :
> 
>                if we consider bit : 1'b0  and  bit : 1'b0 for structure
> member r1 of p[1] and p[0] &  logic : 1'b1 and logic : 1'b1 for
> structure  member  r2 of p[1] and p[0] then the  resulting array p  will
> contains  value  '{'{1'b0, 1'b1},'{1'b0, 1'b1}}, as we take the value
> associated with key, which matches with the type of the r1 and r2 for
> p[1] and p[0] first.
> 
>     Second approach :
> 
>                if we consider  bit : 1'b1  and  bit : 1 'b1 for
> structure member r1 of p[1] and p[0]  &  logic : 1'b0 and logic : 1'b0
> for structure member  r2  of  p[1] and p[0]  then the  resulting  array
> p  will contains value '{'{1'b1, 1'b0},'{1'b1, 1'b0}} as we take the
> value associated with key, which matches with the type of the r1 and r2
> for p[1] and p[0] last.
> 
> Can someone tell me what would be the right  behaviour for the above
> scenario.
> 
> Thanks,
> Sumay
> 
>                
> 
> 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Aug 30 10:06:37 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 30 2007 - 10:06:52 PDT