Hi, The LRM says in 7.2.1, "If any data type within a packed structure is 4-state, the structure as a whole is treated as a 4-state vector. If there are also 2-state members in the structure, there is an implicit conversion from 4-state to 2-state when reading those members and from 2-state to 4-state when writing them." I agree this is not clear enough. I believe the meaning is this: The entire structure, i.e., all its members, become 4-state. The LRM says, "A packed structure can be used as a whole with arithmetic and logical operators." When you read a 2-state member, like s.b, you expect to get a 2-state entity. However, internally it is 4-state. So, when the read operation is performed, a conversion is performed from 4-state to 2-state. However, internally it remains 4-state. Less clear is the write operation. When you write a 2-state member, the value will get converted to 4-state internally, because it is being stored internally as 4-state. I think the question is what happens when you write s.b = 'x; Does the 'x get written internally without change, or is 'x converted to a 2-state '0 since you are writing a 2-state variable, and then the 2-state '0 get converted to a 4-state '0? I ran this test on 2 different simulators and indeed got different results. One gave xxxxxxxx and another gave xxxx0000. However, even the tool that returned xxxx0000 gave xxxxxxxx if the assignment was s = 'x. Regards, Shalom-----Original Message----- From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Daniel Mlynek Sent: Tuesday, April 26, 2011 1:57 PM To: sv-bc@eda.org Subject: [sv-bc] packed struct with 2 and 4 val fields struct packed {reg[1:0][1:0] r; bit [1:0][1:0]b;} s; module top; initial begin s.b='x; $display("%b", s); //should print all x or xxxx0000??? end endmodule In above example s is 4 value as stated in LRM My question is what should be written into s.b when it is assigned with 'x. LRM says that when writing to a 2-val field then implicit 2val to 4 val cast occurs. But in this case I'm writing 4 value value into 2 val field. In my opinion this LRM statement about 2val to 4val implicit cast is not clear. DANiel--------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
This archive was generated by hypermail 2.1.8 : Tue Apr 26 2011 - 11:23:56 PDT