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.

matrix entry in vhdl

Status
Not open for further replies.

ammassk

Member level 2
Joined
Jul 19, 2012
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,606
Hi all
How can I store a matrix which has 4 rows and 8 columns in memory? Each element in the matrix is character 0 or 1.
 

so basically its just 4x 8bit words - 32 bits? its not very big, you could just store it in a single register.
 

each element is a character. I represented array as shown below.

type hmatrix_array is array(integer range 0 to 3 , integer range 0 to 7)of character;
constant mem:hmatrix_array:=("01011001","11100100","00100111","10011010");

But this is showing error.I need to access each element in this matrix.Please give me the correct syntax to represent this matrix.
 

the character type is literally that, characters, like 'a', 'c', '5' etc. They have no numerical value. What you have is an array of 4x8 std_logic_vectors. so try:

type hmatrix_array is array(0 to 3, 0 to 7) of std_logic_vector(7 downto 0);
 

What you have is an array of 4x8 std_logic_vectors.

It's not a 4x8 array of std_logic_vector, because '0' and '1' can't be std_logic_vector literals. It can be an array of character, as defined. But if '0' and '1' are the only values, an array of std_logic would be the obvious solution.
Code:
type hmatrix_array is array(0 to 3, 0 to 7) of std_logic;
constant mem:hmatrix_array:=("01011001","11100100","00100111","10011010");

Of course it's also a 1D array of std_logic_vector.
Code:
type hmatrix_array is array(0 to 3) of std_logic_vector(7 downto 0);
 
  • Like
Reactions: bigdogguru

    bigdogguru

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
but i dont want to access the whole 8 bits at a time. In my code i actually meant each each bit vector is a row and i need to access each bit in a row. It is working in my simulation model. But not synthesizable. Can you please tell me how to access each bit at a time. What I am trying to do is to find out column and row number of the element '1' in the matrix. That is why i used two dimensional array representation. Here, How can I enter my values accordingly?
 

std_logic_vector elements are individually accessable. The first point is that you don't need characters, just bits (or std_logic type) to represent '0' and '1' values.

I don't understand what's the problem with synthesizing. Characters are synthesizable as well, if you actually need it. I assume a problem of syntax errors.

You didn't yet ask a clear question nor reported a specific error message.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top