Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] how to assign the following array

Status
Not open for further replies.

hulk789

Junior Member level 3
Joined
Jul 18, 2015
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
211
Code:
logic [23:0] array[28:0]='{9{24'h010000},10{24'h010000},10{24'h008000}};
array[28:20] should have the value 24'h010000
array[19:10] should have the value 24'h010000
array[9:0] should have the value 24'h008000
 

You can't do this as an array assignment pattern because assignment patterns expect the groupings of {}'s to match that array dimension. i.e. either a single replication of 29 elements, or a comma separated list of 29 elements.

And you can't do this as an unpacked array concatenation, because it does not allow replication. But you can get around the syntax restriction by introducing an intermediate expression:
Code:
   parameter logic [23:0] a1[9] = '{default:24'h010000};
   parameter logic [23:0] a2[10] = '{default:24'h010000};
   parameter logic [23:0] a3[10] = '{default:24'h008000};

   logic [23:0] array[28:0]={a1,a2,a3};
 
dave,

Code:
parameter logic [23:0] a1[9] = '{default:24'h010000};

I've actually never come across this syntax before. Could you explain the significance of the a1[9] specifically the [9][/]. I'm not sure how that translates to an array of values that get assigned to the array[28:20]. Is the [9] the number of array elements? And does the '{} stuff just get replicated over those 9 array elements?
 

For unpacked arrays, you can use the C-style of array declaration and just specify the number of elements. [9] is equivalent to [0:8] when declaring an unpacked array.

In an assignment pattern, default is used for any unspecified element. You do something like
Code:
   int a[5] = '{1:12, 4:42, default:3};

This assigns: a[0]=3, a[1]=12, a[2]=3, a[3]=3, a[4]=42
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top