|
|
|

|
|
|
|
|
|

|
|
 |
Array literals
|
|
|
Array literals are syntactically similar to C initializers, but with the replicate operator ( {{}} ) allowed. The nesting of braces must follow the number of dimensions, unlike in C. |
|
|

|
|
|
|
|
|

|
|
 |
Example - Array Literals
|
|
|

|
|
|
1 `timescale 1ns/100ps
2 module array_literals ();
3
4 byte a [0:1][0:2] = '{'{0,1,2},'{3{8'h9}}};
5
6 initial begin
7 $display ("a [0][0] = %d", a[0][0]);
8 $display ("a [0][1] = %d", a[0][1]);
9 $display ("a [0][2] = %d", a[0][2]);
10 $display ("a [1][0] = %d", a[1][0]);
11 $display ("a [1][1] = %d", a[1][1]);
12 $display ("a [1][2] = %d", a[1][2]);
13 #1 $finish;
14 end
15
16 endmodule
You could download file array_literals.sv here
|
|
|

|
|
 |
Simulator Output
|
|
|

|
|
|
a [0][0] = 0
a [0][1] = 1
a [0][2] = 2
a [1][0] = 9
a [1][1] = 9
a [1][2] = 9
|
|
|

|
|
|

|
|
|

|
|
|
|
|
|

|
|
|
|
|
|

|
|
Copyright © 1998-2025 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|