 |
|
|
|
|
|
|
|
|
|
|
|
|
SVUG Community Forum
|
|
| Author |
Messages |
|
Arjun
Posts:3
 |
| 06/17/2008 11:53 AM |
|
hey all,
I want some help as to how a packed array can be assigned to an unpacked array.
bit Ε:0] parity // an 8 bit packed array
bit collect_parity[] ; // dynamic array .. hence unpacked
some where in a function , say I do
collect_parity= newΖ] // assign the array size
and then want to assign
collect_parity = parity ; // assigning packed to unpacked throws an error
This cannot be done . One obvious way out is to have "parity " also as an unpacked array. But is there a way to have this as packed and still be able to make this assignment ?
Also could you tell me , how the reverse assignment can be done too ... i.e unpacked to a packed.
Thanks
|
|
|
|
|
Arjun
Posts:3
 |
| 06/17/2008 11:57 AM |
|
I am sorry , the line --> collect_parity= newΖ] // assign the array size should have read --> collect_parity= newΖ] // assign the array size |
|
|
|
|
Arjun
Posts:3
 |
| 06/17/2008 11:58 AM |
|
the editor for some reason is not showing the size of the array I have set as 8 using the new [] operator |
|
|
|
|
Shalom
Posts:11
 |
| 06/18/2008 2:22 AM |
|
Try using the streaming operators. Shalom |
|
|
|
|
Dave
Posts:17
 |
| 06/18/2008 9:15 AM |
|
Use a bitstream cast. A bitstream cast works when source and destination types have a matching number of bits at the time of the assignment. If the destination of the assignment is dynamically sized, the cast will automatically pick the size to match the size of the source.
A good practice is to use typedefs for all your types.
typedef bit [ 31:0 ] packed_t;
typedef bit [ 7:0 ] unpacked_t[ ]
packed_t A;
unpacked_t B;
A = packed_t'(B); // creates an unpacked array of 4 bytes
B = unpacked_t'(A); // This works only when A has 4 bytes.
Dave Rich |
|
|
|
|
|
| You are not authorized to post a reply. |
|
|
|
ActiveForums 3.7
|
|
|

|
|
|
|
|
|
|
|
|
|
 |
|