Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

how to create matrix in VHDL

Altera_Forum
Honored Contributor II
4,498 Views

Hi guys! I am trying to create a matrix or an array. 4 columns and 2 rows. Is my code correct? 

 

type row_t is array(0 to 3) of std_logic_vector(7 downto 0); type matrix_t is array(0 to 1, 0 to 3) of std_logic_vector(7 downto 0); 

 

Also I want to assign a variable to the first column? what is the syntax for this? thank you.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
3,547 Views

Yes, it is a matrix 

2d matrices cannot be slices, so you need to assign individual elements. 

You could build it with 1d arrays, which can be sliced to apply an entire row.
0 Kudos
Altera_Forum
Honored Contributor II
3,547 Views

what is the syntax for slicing a row?

0 Kudos
Altera_Forum
Honored Contributor II
3,547 Views

like this (not possible with 2d array: 

 

op <= matrix(a to b); 

 

or 

 

op <= matrix(b downto a); 

 

You really need to try some code yourself - this is very basic VHDL fundamentals you should be learning yourself from a book or from a tutorial.
0 Kudos
Altera_Forum
Honored Contributor II
3,547 Views

 

--- Quote Start ---  

Yes, it is a matrix 

2d matrices cannot be slices, so you need to assign individual elements. 

You could build it with 1d arrays, which can be sliced to apply an entire row. 

--- Quote End ---  

 

 

Excuse me for being pedantic but the OP asked how to assign a variable to the first column. Which is as tedious for a 1Dx1D as for a 2D array?
0 Kudos
Reply