File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
source/SpinalHDL/Data types Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ The syntax to declare a vector is as follows:
2828 - | Create a vector where indexes point to the provided elements.
2929 | Does not create new hardware signals.
3030 | This constructor supports mixed element width.
31-
31+ * - Vec.fill(n1, n2, ...)(type: Data)
32+ - Create a multi-dimensional vector. Supports up to 5 dimensions
3233
3334Examples
3435~~~~~~~~
@@ -52,11 +53,26 @@ Examples
5253 }
5354
5455 // Map on vector
55- myVecOfMixedUInt.map(_ := 0) // Assign all elements with value 0
56+ myVecOfMixedUInt.map(_ := 0) // Assign all elements with value 0
5657
5758 // Assign 3 to the first element of the vector
5859 myVecOf_xyz_ref(1) := 3
5960
61+ // Create a 2D vector (3x4 matrix)
62+ val my2DVec = Vec.fill(3, 4)(UInt(8 bits))
63+ my2DVec(0)(0) := 10 // Access row 0, column 0
64+ my2DVec(1)(2) := 20 // Access row 1, column 2
65+
66+ // Create a 3D vector (2x3x4)
67+ val my3DVec = Vec.fill(2, 3, 4)(SInt(16 bits))
68+ my3DVec(0)(1)(2) := -5
69+
70+ // Iterate on a 2D vector
71+ for(i <- 0 until 3; j <- 0 until 4) {
72+ my2DVec(i)(j) := 0 // Initialize all elements to 0
73+ }
74+
75+
6076 Operators
6177^^^^^^^^^
6278
You can’t perform that action at this time.
0 commit comments