Subject: [sv-bc] questions about structure literals
From: Francoise Martinolle (fm@cadence.com)
Date: Wed Oct 22 2003 - 13:48:39 PDT
The section 2.8 about structure literals is not clear on what are the legal
expressions (size and type) allowed in structure literals and the rules
which apply when a
structure literal is assigned to a struct.
Can structure literals be assigned to packed structs?
In the syntax where the type tick is not present, a structure literal looks
syntactically like a concatenation. Does it mean it is treated as a
concatenation of the contiguous bits and the result is extended/truncated
to the width of the packed struck.
OR does it mean that each element of the structure literal is assigned and
extended to each member of the packed struct? This would lead to a
different result.
Can you have unsized numbers in a structure literal applied to a packed struct?
Or does the expression size must exactly match the size of the members?
(May not be good if the structure member are controlled by parameters...)
For example:
typedef packed struct {
[2:0] a;
[3:0] b;
} my_packed_struct_type;
my_packed_struct_type packed_var_struct;
initial
packed_var_struct = { 1, 16}; //concatenation of unsized numbers is
not legal.
// is this legal? is 16
truncated to 4 bits?
packed_var_struct = {1'b0, 5'b1} // is this legal - what is the result?
packed_var_struct = my_packed_struct_type'{1'b0, 5'b1} // does this
yield a different result than above?
What about if the left hand side was an unpacked struct?
typedef struct {
[2:0] a;
[3:0] b;
} my__struct_type;
my_struct_type var_struct;
initial
var_struct = { 1, 16}; //is this legal? is 16 truncated to 4 bits?
var_struct = {1'b0, 1'b1} // is this legal - what is the result?
var_struct = {1'b0, 5'b1} // is this legal - what is the result?
Francoise
'
This archive was generated by hypermail 2b28 : Wed Oct 22 2003 - 13:50:59 PDT