“Packed array initialization”: asignación a vector simple
1 2 3 |
logic [3:0] [7:0] v1 = 32' h0;// or '0 logic [3:0] [7:0] v2 = { 8'h3, 8'hz, 8'h9, 8'h0 };// concatenation logic [3:0] [7:0] v3 = { 16{2'b01} }; |
“Unpacked array initialization”: lista de valores entre ‘{ and }
1 2 3 4 5 6 7 8 9 10 |
int arr [2] [4] = '{ '{4, 8, 7, 2}, '{9, 1, 0, 6} }; // arr[0][0] = 4 arr[1][0] = 9 // arr[0][1] = 8 arr[1][1] = 1 // arr[0][2] = 7 arr[1][2] = 0 // arr[0][3] = 2 arr[1][3] = 6 int arr2 [2] [4] = '{ 2{4, 8, 7, 2} }; // arr2[0][0] = 4 arr2[1][0] = 4 // arr2[0][1] = 8 arr2[1][1] = 8 // arr2[0][2] = 7 arr2[1][2] = 7 // arr2[0][3] = 2 arr2[1][3] = 2 |
Default initialization: Muy util para la inicialización de unpacked arrays
1 2 3 4 5 6 7 8 9 10 |
int arr3 [2] [4] = '{ default :9}; // arr3[0][0] = 9 arr3[1][0] = 9 // arr3[0][1] = 9 arr3[1][1] = 9 // arr3[0][2] = 9 arr3[1][2] = 9 // arr3[0][3] = 9 arr3[1][3] = 9 int arr4 [2] [4] = '{ '{ default : 1}, '{default : 9}}; // arr4[0][0] = 1 arr4[1][0] = 9 // arr4[0][1] = 1 arr4[1][1] = 9 // arr4[0][2] = 1 arr4[1][2] = 9 // arr4[0][3] = 1 arr4[1][3] = 9 |